@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
@@ -1,3 +1,4 @@
1
+ import type { AvJsonListCheck, AvJsonNumberCheck, AvJsonStringCheck } from "./field-check.js";
1
2
  /**
2
3
  * The phantom key a Json Shape's TypeScript type travels under. Type-level only:
3
4
  * no value ever holds it.
@@ -20,7 +21,15 @@ export type JsonSchemaPrimitive = string | number | boolean | null;
20
21
  * the forms Aventara emits.
21
22
  */
22
23
  export type JsonSchema = {
23
- readonly type: "string" | "number" | "integer" | "boolean" | "null";
24
+ readonly type: "boolean" | "null";
25
+ } | {
26
+ readonly type: "string";
27
+ /** The node's checks, in the order they were added. */
28
+ readonly checks?: readonly AvJsonStringCheck[];
29
+ } | {
30
+ readonly type: "number" | "integer";
31
+ /** The node's checks, in the order they were added. */
32
+ readonly checks?: readonly AvJsonNumberCheck[];
24
33
  } | {
25
34
  readonly const: JsonSchemaPrimitive;
26
35
  } | {
@@ -39,6 +48,8 @@ export type JsonSchema = {
39
48
  } | {
40
49
  readonly type: "array";
41
50
  readonly items: JsonSchema;
51
+ /** The list's length checks, in the order they were added. */
52
+ readonly checks?: readonly AvJsonListCheck[];
42
53
  } | {
43
54
  readonly type: "array";
44
55
  readonly prefixItems: readonly [JsonSchema, ...JsonSchema[]];
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Where a field's value comes from, without saying whether it is writable:
3
3
  * `DEFAULTED` and `GENERATED_ON_*` by the data source, `COMPUTED_ON_*` by a
4
- * framework behavior; `VIRTUAL` marks a field that is not stored.
4
+ * compute stage; `VIRTUAL` marks a field that is not stored.
5
5
  */
6
6
  export declare const LIFECYCLE_TRAITS: readonly ["DEFAULTED", "GENERATED_ON_CREATE", "GENERATED_ON_UPDATE", "COMPUTED_ON_CREATE", "COMPUTED_ON_UPDATE", "COMPUTED_ON_READ", "VIRTUAL"];
7
7
  /** One of {@link LIFECYCLE_TRAITS}. */
8
- export type LifecycleTrait = (typeof LIFECYCLE_TRAITS)[number];
8
+ export type AvLifecycleTrait = (typeof LIFECYCLE_TRAITS)[number];
@@ -1,62 +1,62 @@
1
- import type { ProjectionScope, WriteScope } from "./capability.js";
1
+ import type { AvProjectionScope, AvWriteScope } from "./capability.js";
2
2
  /**
3
3
  * The argument scopes one advertised operation variant qualifies its arguments
4
4
  * with: which projection position its projection arguments sit in, and which write
5
5
  * position its data argument sits in.
6
6
  */
7
- export type OperationVariantScopes = {
8
- readonly projection: ProjectionScope;
9
- readonly write?: WriteScope;
7
+ export type AvOperationVariantScopes = {
8
+ readonly projection: AvProjectionScope;
9
+ readonly write?: AvWriteScope;
10
10
  } | {
11
- readonly projection?: ProjectionScope;
12
- readonly write: WriteScope;
11
+ readonly projection?: AvProjectionScope;
12
+ readonly write: AvWriteScope;
13
13
  };
14
14
  /**
15
15
  * Availability of one standard operation variant: `true` for "available, with no
16
16
  * scope qualification stated", or the scopes the variant qualifies its arguments
17
17
  * with.
18
18
  */
19
- export type OperationAvailability = true | OperationVariantScopes;
19
+ export type AvOperationAvailability = true | AvOperationVariantScopes;
20
20
  /** Availability of protocol-defined standard operations for one Resource. */
21
- export type ResourceOperations = {
21
+ export type AvResourceOperations = {
22
22
  readonly find?: {
23
- readonly first?: OperationAvailability;
24
- readonly unique?: OperationAvailability;
25
- readonly many?: OperationAvailability;
26
- readonly count?: OperationAvailability;
23
+ readonly first?: AvOperationAvailability;
24
+ readonly unique?: AvOperationAvailability;
25
+ readonly many?: AvOperationAvailability;
26
+ readonly count?: AvOperationAvailability;
27
27
  };
28
28
  readonly create?: {
29
- readonly one?: OperationAvailability;
30
- readonly many?: OperationAvailability;
31
- readonly count?: OperationAvailability;
29
+ readonly one?: AvOperationAvailability;
30
+ readonly many?: AvOperationAvailability;
31
+ readonly count?: AvOperationAvailability;
32
32
  };
33
33
  readonly update?: {
34
- readonly first?: OperationAvailability;
35
- readonly unique?: OperationAvailability;
36
- readonly many?: OperationAvailability;
37
- readonly count?: OperationAvailability;
34
+ readonly first?: AvOperationAvailability;
35
+ readonly unique?: AvOperationAvailability;
36
+ readonly many?: AvOperationAvailability;
37
+ readonly count?: AvOperationAvailability;
38
38
  };
39
39
  readonly delete?: {
40
- readonly first?: OperationAvailability;
41
- readonly unique?: OperationAvailability;
42
- readonly many?: OperationAvailability;
43
- readonly count?: OperationAvailability;
40
+ readonly first?: AvOperationAvailability;
41
+ readonly unique?: AvOperationAvailability;
42
+ readonly many?: AvOperationAvailability;
43
+ readonly count?: AvOperationAvailability;
44
44
  };
45
45
  readonly upsert?: {
46
- readonly unique?: OperationAvailability;
46
+ readonly unique?: AvOperationAvailability;
47
47
  };
48
48
  };
49
49
  /**
50
- * Whether one `ResourceOperations` entry marks its variant available: it is
50
+ * Whether one `AvResourceOperations` entry marks its variant available: it is
51
51
  * `true` or an argument-position descriptor.
52
52
  */
53
- export declare function isOperationVariantAvailable(availability: unknown): availability is OperationAvailability;
53
+ export declare function isOperationVariantAvailable(availability: unknown): availability is AvOperationAvailability;
54
54
  /**
55
55
  * The projection position one advertised variant's projection arguments sit in.
56
56
  */
57
- export declare function projectionScopeOf(availability: unknown): ProjectionScope;
57
+ export declare function projectionScopeOf(availability: unknown): AvProjectionScope;
58
58
  /**
59
59
  * The write position one advertised variant's data argument sits in, and the write
60
60
  * mirror of {@link projectionScopeOf}.
61
61
  */
62
- export declare function writeScopeOf(availability: unknown): WriteScope;
62
+ export declare function writeScopeOf(availability: unknown): AvWriteScope;
@@ -1,12 +1,18 @@
1
- import type { Contract } from "./contract.js";
2
- import type { Field } from "./field.js";
3
- import type { Identifier } from "./identifier.js";
4
- import type { ResourceOperations } from "./resource-operations.js";
1
+ import type { AvContract } from "./contract.js";
2
+ import type { AvCreateRequirements } from "./create-requirements.js";
3
+ import type { AvField } from "./field.js";
4
+ import type { AvIdentifier } from "./identifier.js";
5
+ import type { AvResourceOperations } from "./resource-operations.js";
5
6
  /** A Resource's fields, by name. */
6
- export type ResourceFieldMap<C extends Contract> = Readonly<Record<string, Field<C>>>;
7
- /** One Resource: its fields, identifiers and available operations. */
8
- export type Resource<C extends Contract, TFields extends ResourceFieldMap<C> = ResourceFieldMap<C>> = {
7
+ export type AvResourceFieldMap<C extends AvContract> = Readonly<Record<string, AvField<C>>>;
8
+ /**
9
+ * One Resource: its fields, identifiers and available operations, and what a
10
+ * create of it cannot do without.
11
+ */
12
+ export type AvResource<C extends AvContract, TFields extends AvResourceFieldMap<C> = AvResourceFieldMap<C>> = {
9
13
  readonly fields: TFields;
10
- readonly identifiers: readonly Identifier<TFields>[];
11
- readonly operations: ResourceOperations;
14
+ readonly identifiers: readonly AvIdentifier<TFields>[];
15
+ readonly operations: AvResourceOperations;
16
+ /** What a create must write; absent when it requires nothing. */
17
+ readonly createRequirements?: AvCreateRequirements;
12
18
  };
@@ -1,42 +1,42 @@
1
- import type { Decimal } from "../runtime/decimal.js";
2
- import type { JsonValue } from "../runtime/json-value.js";
3
- import type { Contract } from "./contract.js";
4
- import type { ScalarField } from "./field.js";
1
+ import type { AvDecimal } from "../runtime/decimal.js";
2
+ import type { AvJsonValue } from "../runtime/json-value.js";
3
+ import type { AvContract } from "./contract.js";
4
+ import type { AvScalarField } from "./field.js";
5
5
  import type { JsonFieldType } from "./json-shape.js";
6
- import type { BuiltInScalar } from "./scalar.js";
6
+ import type { AvBuiltInScalar } from "./scalar.js";
7
7
  /**
8
8
  * A scalar-form map: the TypeScript type each built-in scalar takes on one side
9
9
  * of a boundary. Every built-in must be listed.
10
10
  */
11
11
  export type ScalarForms = {
12
- readonly [Scalar in BuiltInScalar]: unknown;
12
+ readonly [Scalar in AvBuiltInScalar]: unknown;
13
13
  };
14
14
  /**
15
15
  * The TypeScript form each built-in scalar takes in process: in results of
16
16
  * either origin, and in `framework.application` arguments. `decimal` is
17
- * Aventara's own {@link Decimal}.
17
+ * Aventara's own {@link AvDecimal}.
18
18
  */
19
- export type ApplicationScalarForms = {
19
+ export type AvApplicationScalarForms = {
20
20
  readonly string: string;
21
21
  readonly boolean: boolean;
22
22
  readonly int: number;
23
23
  readonly float: number;
24
24
  readonly bigint: bigint;
25
- readonly decimal: Decimal;
25
+ readonly decimal: AvDecimal;
26
26
  readonly datetime: Date;
27
27
  readonly bytes: Uint8Array;
28
28
  /**
29
29
  * Any JSON value. A field-level `null` is the field's absence and is allowed
30
30
  * only where the field is nullable; a `null` inside the value is JSON's own.
31
31
  */
32
- readonly json: Exclude<JsonValue, null>;
32
+ readonly json: Exclude<AvJsonValue, null>;
33
33
  };
34
34
  /**
35
35
  * The encoded forms of the built-in scalars: base-10 bigint strings, decimal strings,
36
36
  * canonical ISO-8601 UTC datetimes and RFC 4648 base64 bytes. For a transport or a
37
37
  * generated client to pass as `Forms`.
38
38
  */
39
- export type WireScalarForms = {
39
+ export type AvWireScalarForms = {
40
40
  readonly string: string;
41
41
  readonly boolean: boolean;
42
42
  readonly int: number;
@@ -46,10 +46,10 @@ export type WireScalarForms = {
46
46
  readonly datetime: string;
47
47
  readonly bytes: string;
48
48
  /** The same as in process: a JSON value needs no encoding to cross a JSON wire. */
49
- readonly json: Exclude<JsonValue, null>;
49
+ readonly json: Exclude<AvJsonValue, null>;
50
50
  };
51
51
  /** One value of a scalar field, before `list` and `nullable` apply. */
52
- export type ScalarAtom<C extends Contract, Type, Forms extends ScalarForms> = Type extends {
52
+ export type ScalarAtom<C extends AvContract, Type, Forms extends ScalarForms> = Type extends {
53
53
  readonly enum: infer Enum extends keyof C["enums"];
54
54
  } ? C["enums"][Enum]["values"][number] : Type extends {
55
55
  readonly scalar: infer Scalar;
@@ -58,7 +58,7 @@ export type ScalarAtom<C extends Contract, Type, Forms extends ScalarForms> = Ty
58
58
  * One value of a scalar field, before `list` and `nullable` apply: its Json
59
59
  * Shape's type where the field is shaped, otherwise {@link ScalarAtom}.
60
60
  */
61
- export type FieldAtom<C extends Contract, Field extends {
61
+ export type FieldAtom<C extends AvContract, Field extends {
62
62
  readonly type: unknown;
63
63
  readonly json?: unknown;
64
64
  }, Forms extends ScalarForms> = Field extends {
@@ -78,5 +78,7 @@ type ListValue<List, Atom> = [List] extends [false] ? Atom : [List] extends [tru
78
78
  * - `list: true` → `readonly T[]`, whose entries are never `null`;
79
79
  * - `nullable: true` → `| null`, on the whole value, list or not.
80
80
  */
81
- export type ScalarValueType<C extends Contract, Field extends ScalarField<C>, Forms extends ScalarForms = ApplicationScalarForms> = ListValue<Field["list"], FieldAtom<C, Field, Forms>> | (true extends Field["nullable"] ? null : never);
81
+ export type AvScalarValueType<C extends AvContract, Field extends AvScalarField<C>, Forms extends ScalarForms = AvApplicationScalarForms> = [
82
+ ListValue<Field["list"], FieldAtom<C, Field, Forms>> | (true extends Field["nullable"] ? null : never)
83
+ ] extends [infer Value] ? Value : never;
82
84
  export {};
@@ -1,10 +1,10 @@
1
1
  /** The built-in scalar types of the Aventara protocol. */
2
2
  export declare const BUILT_IN_SCALARS: readonly ["string", "boolean", "int", "float", "bigint", "decimal", "datetime", "bytes", "json"];
3
3
  /** One of {@link BUILT_IN_SCALARS}. */
4
- export type BuiltInScalar = (typeof BUILT_IN_SCALARS)[number];
4
+ export type AvBuiltInScalar = (typeof BUILT_IN_SCALARS)[number];
5
5
  /** One entry of a scalar registry. */
6
- export type ScalarDefinition = {
6
+ export type AvScalarDefinition = {
7
7
  readonly builtin: true;
8
8
  };
9
9
  /** The scalar types an adapter model or Contract supports, by name. */
10
- export type ScalarRegistry = Readonly<Record<string, ScalarDefinition>>;
10
+ export type AvScalarRegistry = Readonly<Record<string, AvScalarDefinition>>;
@@ -1,4 +1,4 @@
1
1
  /** The transaction capabilities. */
2
2
  export declare const TRANSACTION_CAPABILITIES: readonly ["none", "interactive"];
3
3
  /** `"none"` or `"interactive"`: whether transactions can run. */
4
- export type TransactionCapability = (typeof TRANSACTION_CAPABILITIES)[number];
4
+ export type AvTransactionCapability = (typeof TRANSACTION_CAPABILITIES)[number];
@@ -1,5 +1,5 @@
1
- import type { BuiltInScalar } from "./scalar.js";
2
- import type { ApplicationScalarForms, WireScalarForms } from "./scalar-value-type.js";
1
+ import type { AvBuiltInScalar } from "./scalar.js";
2
+ import type { AvApplicationScalarForms, AvWireScalarForms } from "./scalar-value-type.js";
3
3
  /**
4
4
  * The built-in scalars whose wire form is not their runtime form — the ones a JSON
5
5
  * wire carries as a string with a grammar of its own. Derived from the two form maps
@@ -7,8 +7,8 @@ import type { ApplicationScalarForms, WireScalarForms } from "./scalar-value-typ
7
7
  * compile below until its grammar is written.
8
8
  */
9
9
  type WireEncodedScalar = {
10
- readonly [S in BuiltInScalar]: WireScalarForms[S] extends ApplicationScalarForms[S] ? never : S;
11
- }[BuiltInScalar];
10
+ readonly [S in AvBuiltInScalar]: AvWireScalarForms[S] extends AvApplicationScalarForms[S] ? never : S;
11
+ }[AvBuiltInScalar];
12
12
  /**
13
13
  * `AvProtocol.scalarFormats` — the wire grammars of protocol version 1, as passive
14
14
  * data: one anchored pattern SOURCE string per wire-encoded scalar, in
@@ -0,0 +1,116 @@
1
+ import type { AvContract } from "../contracts/contract.js";
2
+ import type { AvApplicationScalarForms } from "../contracts/scalar-value-type.js";
3
+ import type { AvResourceKey, AvUniqueWhereInput } from "../operations/operation-arguments.js";
4
+ import type { AvAccessProvider } from "../policy/access-provider.interface.js";
5
+ import type { AvAccessQuestion } from "../policy/access-question.js";
6
+ import type { AccessQuestionsAnswerer } from "../policy/access-question.runtime.js";
7
+ import type { AvAccessVerbs } from "../policy/access-verbs.js";
8
+ import type { AvState } from "../runtime/request-state.js";
9
+ /** The questions a client of `C` may ask: one per Resource, with its own unique `where` in the application forms. */
10
+ export type AccessQuestionOf<C extends AvContract> = C extends AvContract ? {
11
+ readonly [R in AvResourceKey<C>]: AvAccessQuestion<R, AvUniqueWhereInput<C, R, AvApplicationScalarForms>>;
12
+ }[AvResourceKey<C>] : never;
13
+ /** The headers a server-side `$access` call hands Access: a Web `Headers`, or a Node request's `headers`. */
14
+ type AccessHeadersInput = {
15
+ get(name: string): string | null;
16
+ has(name: string): boolean;
17
+ forEach(callback: (value: string, name: string) => void): void;
18
+ } | {
19
+ readonly [name: string]: string | readonly string[] | undefined;
20
+ };
21
+ /** A server-side `$access` call's options. */
22
+ type ServerAccessOptions = {
23
+ /** As `AvExecutionOptions.requestId`: `can`'s request id. */
24
+ readonly requestId?: string;
25
+ /**
26
+ * As `AvExecutionOptions.state`: the state `can` is answered under. Left out,
27
+ * `can` is answered under the state the provider seeds from `headers`, or
28
+ * anonymously without them.
29
+ */
30
+ readonly state?: AvState & object;
31
+ /**
32
+ * The request's headers, which Access reads the session from: a Web
33
+ * `Headers`, or a Node request's `headers` (`req.headers`). Omitted, none.
34
+ */
35
+ readonly headers?: AccessHeadersInput;
36
+ /** The host's own request, handed to Access as `state` is. */
37
+ readonly request?: unknown;
38
+ /**
39
+ * The host's own response (Express's `res`, Fastify's `reply`): Access sets
40
+ * a sign-in's or sign-out's cookie on it. Under Next, a Server Action needs
41
+ * none: Access sets it through Next's `cookies()`.
42
+ */
43
+ readonly response?: unknown;
44
+ };
45
+ /** What a verb's `call` resolves, `null` and `undefined` taken out. */
46
+ type CallResult<Verb> = Verb extends {
47
+ call(input: never): Promise<infer Result>;
48
+ } ? Exclude<Result, null | undefined> : unknown;
49
+ /** The `args` a verb's `call` reads. */
50
+ type CallArgs<Verb> = Verb extends {
51
+ call(input: infer Input): Promise<unknown>;
52
+ } ? Input extends {
53
+ readonly args: infer Args;
54
+ } ? Args : unknown : unknown;
55
+ /** The provider's `client`, when its type states one. */
56
+ type ClientOf<A> = A extends {
57
+ readonly client: infer Client;
58
+ } ? Exclude<Client, undefined> : never;
59
+ /** The verbs a provider's `verbs` type states as present (an optional one is no verb). */
60
+ type PresentVerbs<Verbs> = {
61
+ [V in keyof Verbs]-?: undefined extends Verbs[V] ? never : V;
62
+ }[keyof Verbs] & ProviderVerbName;
63
+ /** The verbs a provider's `client` may state. */
64
+ type ProviderVerbName = keyof NonNullable<AvAccessProvider["client"]>["verbs"];
65
+ /** `$access` of a client of `C` whose provider is `A`: `can`, and the verbs its `client` offers. */
66
+ type ServerAccess<C extends AvContract, A> = [ClientOf<A>] extends [never] ? Pick<AvAccessVerbs<AccessQuestionOf<C>, never, {
67
+ signIn: never;
68
+ signUp: never;
69
+ resetPassword: never;
70
+ switchUser: never;
71
+ setPin: never;
72
+ enrollDevice: never;
73
+ revokeDevice: never;
74
+ }, ServerAccessOptions>, "can"> : ClientOf<A> extends {
75
+ readonly verbs: infer Verbs;
76
+ } ? Pick<AvAccessVerbs<AccessQuestionOf<C>, CallResult<VerbOf<Verbs, "me">>, {
77
+ signIn: CallArgs<VerbOf<Verbs, "signIn">>;
78
+ signUp: CallArgs<VerbOf<Verbs, "signUp">>;
79
+ resetPassword: CallArgs<VerbOf<Verbs, "resetPassword">>;
80
+ switchUser: CallArgs<VerbOf<Verbs, "switchUser">>;
81
+ setPin: CallArgs<VerbOf<Verbs, "setPin">>;
82
+ enrollDevice: CallArgs<VerbOf<Verbs, "enrollDevice">>;
83
+ revokeDevice: CallArgs<VerbOf<Verbs, "revokeDevice">>;
84
+ }, ServerAccessOptions>, "can" | PresentVerbs<Verbs>> : never;
85
+ /** One verb of a provider's `verbs` type, or `never` when it states none. */
86
+ type VerbOf<Verbs, V extends string> = V extends keyof Verbs ? Exclude<Verbs[V], undefined> : never;
87
+ /** The configuration's `access` provider; `undefined` without one. */
88
+ export type AccessProviderOf<Cfg> = Cfg extends {
89
+ readonly access: infer A extends AvAccessProvider;
90
+ } ? A : undefined;
91
+ /**
92
+ * `framework.serverClient`'s `$access` member over the Client Contract's view
93
+ * `C`: `{ $access }` with `access`, nothing (`unknown`) without it.
94
+ */
95
+ export type ServerClientAccess<C, A> = [A] extends [undefined] ? unknown : C extends AvContract ? {
96
+ /**
97
+ * The policy's answers for the UI (`can`) and, when the provider
98
+ * states its `client`, the Aventara Access verbs, each run in
99
+ * process with the headers the call names.
100
+ */
101
+ readonly $access: ServerAccess<C, A>;
102
+ } : unknown;
103
+ /** What `$access` reads off the Framework. */
104
+ type ServerClientAccessDependencies = {
105
+ /** The Client Contract, whose unique `where`s a question's is encoded by. */
106
+ readonly contract: AvContract;
107
+ /** The `can` route's answerer. */
108
+ readonly answer: AccessQuestionsAnswerer;
109
+ /** The provider's `client`, when it has one. */
110
+ readonly client: AvAccessProvider["client"];
111
+ /** The provider's `state`, called on the provider: `can`'s state from a call's `headers`. */
112
+ readonly state: AvAccessProvider["state"];
113
+ };
114
+ /** A server-side `$access`, as `serverClient` carries it. */
115
+ export declare function createServerClientAccess(dependencies: ServerClientAccessDependencies): object;
116
+ export {};
@@ -0,0 +1,120 @@
1
+ import { projectJsonValue } from "../contracts/json-schema.projector.js";
2
+ import { ACCESS_VERB_NAMES, ACCESS_VERBS, providerVerb, } from "../policy/access-verb.table.js";
3
+ import { copyAtDoor } from "../runtime/caller-data.door.js";
4
+ import { requestIdOf } from "../runtime/request-id.js";
5
+ import { stateOptionOf } from "../runtime/request-state.resolver.js";
6
+ import { encodeOperationArgumentsForWire } from "../transactions/operation-arguments-encoder.js";
7
+ import { settleOperation } from "./operation-facade.js";
8
+ export function createServerClientAccess(dependencies) {
9
+ const { contract, answer, client } = dependencies;
10
+ const stateFor = async (options) => {
11
+ if (options?.state !== undefined || options?.headers === undefined) {
12
+ return stateOf(options);
13
+ }
14
+ return {
15
+ state: await dependencies.state({
16
+ headers: requestHeadersOf(options.headers),
17
+ ...(options.request === undefined ? {} : { request: options.request }),
18
+ }),
19
+ };
20
+ };
21
+ const can = async (questions, options) => settleOperation(await answer({
22
+ origin: "client",
23
+ requestId: requestIdOf(options),
24
+ ...(await stateFor(options)),
25
+ body: wireQuestions(contract, questions),
26
+ }));
27
+ if (client === undefined) {
28
+ return Object.freeze({ can });
29
+ }
30
+ const verbs = { can };
31
+ for (const name of ACCESS_VERB_NAMES) {
32
+ const verb = providerVerb(client.verbs, name);
33
+ if (verb !== undefined) {
34
+ verbs[name] = serverVerb(verb, ACCESS_VERBS[name]);
35
+ }
36
+ }
37
+ return Object.freeze(verbs);
38
+ }
39
+ function serverVerb(verb, shape) {
40
+ const run = async (args, options) => {
41
+ const answer = await verb.call({
42
+ args,
43
+ headers: requestHeadersOf(options?.headers),
44
+ ...(options?.request === undefined ? {} : { request: options.request }),
45
+ ...(options?.response === undefined
46
+ ? {}
47
+ : { response: options.response }),
48
+ });
49
+ switch (shape.resolves) {
50
+ case "nothing":
51
+ return undefined;
52
+ default:
53
+ return answer === null || answer === undefined
54
+ ? null
55
+ : projectJsonValue(answer, verb.result);
56
+ }
57
+ };
58
+ return shape.args
59
+ ? (args, options) => run(args, options)
60
+ : (options) => run(undefined, options);
61
+ }
62
+ function stateOf(options) {
63
+ const state = stateOptionOf(options);
64
+ return state === undefined ? {} : { state };
65
+ }
66
+ function isRecord(value) {
67
+ return typeof value === "object" && value !== null && !Array.isArray(value);
68
+ }
69
+ function wireQuestions(contract, questions) {
70
+ const copy = copyAtDoor({ questions });
71
+ if (!copy.ok) {
72
+ return { questions };
73
+ }
74
+ const body = copy.value;
75
+ if (!Array.isArray(body.questions)) {
76
+ return body;
77
+ }
78
+ return {
79
+ questions: body.questions.map((question) => {
80
+ if (!isRecord(question) ||
81
+ !Object.hasOwn(question, "where") ||
82
+ typeof question.resource !== "string" ||
83
+ !Object.hasOwn(contract.resources, question.resource)) {
84
+ return question;
85
+ }
86
+ const encoded = encodeOperationArgumentsForWire(contract, { family: "find", variant: "unique", resource: question.resource }, { where: question.where });
87
+ return { ...question, where: encoded.where };
88
+ }),
89
+ };
90
+ }
91
+ function requestHeadersOf(headers) {
92
+ if (headers !== undefined &&
93
+ typeof headers.get === "function") {
94
+ return headers;
95
+ }
96
+ const lowered = new Map();
97
+ for (const [name, value] of Object.entries(headers ?? {})) {
98
+ const values = typeof value === "string"
99
+ ? [value]
100
+ : Array.isArray(value)
101
+ ? value
102
+ : [];
103
+ if (values.length > 0) {
104
+ const key = name.toLowerCase();
105
+ const before = lowered.get(key);
106
+ lowered.set(key, before === undefined
107
+ ? values.join(", ")
108
+ : `${before}, ${values.join(", ")}`);
109
+ }
110
+ }
111
+ return Object.freeze({
112
+ get: (name) => lowered.get(name.toLowerCase()) ?? null,
113
+ has: (name) => lowered.has(name.toLowerCase()),
114
+ forEach: (callback) => {
115
+ for (const [name, value] of lowered) {
116
+ callback(value, name);
117
+ }
118
+ },
119
+ });
120
+ }