@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,4 +1,4 @@
1
- import type { ClientContract } from "../contracts/contract.js";
1
+ import type { AvContractClient } from "../contracts/contract.js";
2
2
  import type { AvProtocolRequest } from "./http-request.decoder.js";
3
3
  import type { AvProtocolResponse } from "./http-response.encoder.js";
4
4
  /**
@@ -6,14 +6,15 @@ import type { AvProtocolResponse } from "./http-response.encoder.js";
6
6
  * entity tag, the quoted contract hash. The bytes include `protocol.hash`, although
7
7
  * the hash's own input excludes it.
8
8
  */
9
- export type ContractDocument = {
9
+ type ContractDocument = {
10
10
  readonly body: string;
11
11
  readonly etag: string;
12
12
  };
13
13
  /** The bound ClientContract as the document `_contract` serves. */
14
- export declare function contractDocumentOf(client: ClientContract): ContractDocument;
14
+ export declare function contractDocumentOf(client: AvContractClient): ContractDocument;
15
15
  /**
16
- * `protocol.encodeContract(request)`: the `GET <entrypoint>/_contract` responder. In
16
+ * `protocol.encodeContract(request)`: the `GET <api>/_contract` responder. In
17
17
  * order:
18
18
  */
19
19
  export declare function encodeContractRequest(document: ContractDocument, received: AvProtocolRequest): AvProtocolResponse;
20
+ export {};
@@ -1,10 +1,10 @@
1
- import { canonicalizeContract } from "../contracts/contract-canonicalizer.js";
1
+ import { canonicalContractTextOf } from "../contracts/contract-canonicalizer.js";
2
2
  import { CONTRACT_ROUTE, GET_ONLY, readRequest, } from "./http-request.reader.js";
3
3
  import { transportFailure } from "./protocol-failure.js";
4
4
  import { headers, headerValue } from "./protocol-headers.js";
5
5
  export function contractDocumentOf(client) {
6
6
  return Object.freeze({
7
- body: canonicalizeContract(client),
7
+ body: canonicalContractTextOf(client),
8
8
  etag: `"${client.protocol.hash}"`,
9
9
  });
10
10
  }
@@ -1,15 +1,16 @@
1
- import type { FrameworkContracts } from "../compiler/contract.compiler.js";
2
- import type { ClientOperationRequest } from "../runtime/operation-request.js";
3
- import type { ClientTransactionRequest } from "../transactions/transaction-request.js";
1
+ import type { AvContracts } from "../compiler/contract.compiler.js";
2
+ import type { RemoteRequestOrigin } from "../config/config-layer.js";
3
+ import type { AvRequestProtocol, RemoteOperationRequest } from "../runtime/operation-request.js";
4
+ import type { AvAgentTransactionRequest, AvClientTransactionRequest } from "../transactions/transaction-request.js";
4
5
  import type { AvProtocolResponse } from "./http-response.encoder.js";
5
6
  /** One HTTP request as a host hands it to the protocol. */
6
7
  export type AvProtocolRequest = {
7
8
  /** The HTTP method as received. Anything but `POST` on a framework route is `A2012`. */
8
9
  readonly method: string;
9
10
  /**
10
- * The request path RELATIVE to the configured entrypoint, as received (not yet
11
- * URL-decoded): `/_resources/users/find/many`, `/_transactions`, `/_contract` —
12
- * the space `protocol.surface()`'s paths live in.
11
+ * The request path relative to the configured `api` mount path, as received (not yet
12
+ * URL-decoded): `/_resources/users/find/many`, `/_transactions`, `/_contract`,
13
+ * in the same form as the paths `protocol.surface()` returns.
13
14
  */
14
15
  readonly path: string;
15
16
  /**
@@ -19,8 +20,8 @@ export type AvProtocolRequest = {
19
20
  */
20
21
  readonly headers: Readonly<Record<string, string | readonly string[] | undefined>>;
21
22
  /**
22
- * The body, in one of two explicitly named arms — the decoder never guesses which
23
- * one it was given:
23
+ * The body, in one of two explicitly named arms, so the decoder never guesses
24
+ * which one it was given:
24
25
  */
25
26
  readonly body: {
26
27
  readonly kind: "raw";
@@ -45,19 +46,22 @@ type Decoded<Request> = {
45
46
  readonly response: AvProtocolResponse;
46
47
  readonly requestId: string;
47
48
  };
48
- /** What `protocol.decodeOperation` answers. */
49
- export type DecodedOperation = Decoded<ClientOperationRequest>;
49
+ /**
50
+ * What `protocol.decodeOperation` answers: a client-origin request, or an
51
+ * agent-origin one from a binding made with `{ origin: "agent" }`.
52
+ */
53
+ export type DecodedOperation = Decoded<RemoteOperationRequest>;
50
54
  /** `protocol.decodeOperation`'s success value: the request `framework.execute` takes. */
51
55
  export type DecodedOperationRequest = Extract<DecodedOperation, {
52
56
  ok: true;
53
57
  }>;
54
58
  /** What `protocol.decodeTransaction` answers. */
55
- export type DecodedTransaction = Decoded<ClientTransactionRequest>;
59
+ export type DecodedTransaction = Decoded<AvClientTransactionRequest | AvAgentTransactionRequest>;
56
60
  /**
57
61
  * `protocol.decodeOperation(request)` — one operation route's HTTP request as
58
62
  * the client-origin request `framework.execute` takes, or its answer.
59
63
  */
60
- export declare function decodeOperationRequest(contracts: FrameworkContracts, received: AvProtocolRequest): DecodedOperation;
64
+ export declare function decodeOperationRequest(contracts: AvContracts, received: AvProtocolRequest, origin?: RemoteRequestOrigin): DecodedOperation;
61
65
  /**
62
66
  * `protocol.decodeTransaction(request)` — the `/_transactions` request as the client-
63
67
  * origin plan request `framework.executeTransaction` takes, or its answer. The same
@@ -66,7 +70,23 @@ export declare function decodeOperationRequest(contracts: FrameworkContracts, re
66
70
  * the plan then runs under ClientContract rules: the plan is client origin and cannot
67
71
  * say otherwise. The body is the plan verbatim.
68
72
  */
69
- export declare function decodeTransactionRequest(contracts: FrameworkContracts, received: AvProtocolRequest): DecodedTransaction;
73
+ export declare function decodeTransactionRequest(contracts: AvContracts, received: AvProtocolRequest, origin?: RemoteRequestOrigin): DecodedTransaction;
74
+ /** A `/_access/can` request as core answers it: its origin, identity and body. */
75
+ type DecodedCanRequest = {
76
+ readonly origin: RemoteRequestOrigin;
77
+ readonly requestId: string;
78
+ readonly protocol: AvRequestProtocol;
79
+ /** The body, a JSON object: `{ questions }`, read by core. */
80
+ readonly body: object;
81
+ };
82
+ /**
83
+ * The `/_access/can` request as the request core answers, or its answer: the same
84
+ * steps as {@link decodeTransactionRequest}, with the path exactly `/_access/can`
85
+ * and its absence being a Contract without its `access` section. The body is read
86
+ * as a JSON object and handed to core verbatim; its `questions` are core's to
87
+ * judge.
88
+ */
89
+ export declare function decodeCanRequest(contracts: AvContracts, received: AvProtocolRequest, origin?: RemoteRequestOrigin): Decoded<DecodedCanRequest>;
70
90
  /**
71
91
  * Whether `value` is a body this decoder parsed from raw content. Only the protocol's
72
92
  * own shortcuts ask, about a request they have just decoded, before any host code
@@ -1,22 +1,22 @@
1
- import { checkOperationRoute, checkTransactionsRoute, } from "./absent-route.responder.js";
1
+ import { checkAccessCanRoute, checkOperationRoute, checkTransactionsRoute, } from "./absent-route.responder.js";
2
2
  import { readRequest } from "./http-request.reader.js";
3
3
  import { transportFailure, } from "./protocol-failure.js";
4
4
  import { headerValue } from "./protocol-headers.js";
5
- export function decodeOperationRequest(contracts, received) {
5
+ export function decodeOperationRequest(contracts, received, origin = "client") {
6
6
  const read = readRequest(received);
7
7
  if (!read.ok) {
8
8
  return read;
9
9
  }
10
- const route = checkOperationRoute(contracts, read);
10
+ const route = checkOperationRoute(contracts, read, origin);
11
11
  if (!route.ok) {
12
12
  return refused(route.response, read.requestId);
13
13
  }
14
- const body = readBody(read, contracts);
14
+ const body = readBody(read, contracts, origin);
15
15
  return body.ok
16
16
  ? {
17
17
  ok: true,
18
18
  request: {
19
- origin: "client",
19
+ origin,
20
20
  requestId: read.requestId,
21
21
  resource: route.resource,
22
22
  ...route.operation,
@@ -28,21 +28,21 @@ export function decodeOperationRequest(contracts, received) {
28
28
  }
29
29
  : refused(body.response, read.requestId);
30
30
  }
31
- export function decodeTransactionRequest(contracts, received) {
31
+ export function decodeTransactionRequest(contracts, received, origin = "client") {
32
32
  const read = readRequest(received);
33
33
  if (!read.ok) {
34
34
  return read;
35
35
  }
36
- const route = checkTransactionsRoute(contracts, read);
36
+ const route = checkTransactionsRoute(contracts, read, origin);
37
37
  if (!route.ok) {
38
38
  return refused(route.response, read.requestId);
39
39
  }
40
- const body = readBody(read, contracts);
40
+ const body = readBody(read, contracts, origin);
41
41
  return body.ok
42
42
  ? {
43
43
  ok: true,
44
44
  request: {
45
- origin: "client",
45
+ origin,
46
46
  requestId: read.requestId,
47
47
  protocol: route.protocol,
48
48
  transport: transportOf(read),
@@ -52,14 +52,37 @@ export function decodeTransactionRequest(contracts, received) {
52
52
  }
53
53
  : refused(body.response, read.requestId);
54
54
  }
55
+ export function decodeCanRequest(contracts, received, origin = "client") {
56
+ const read = readRequest(received);
57
+ if (!read.ok) {
58
+ return read;
59
+ }
60
+ const route = checkAccessCanRoute(contracts, read, origin);
61
+ if (!route.ok) {
62
+ return refused(route.response, read.requestId);
63
+ }
64
+ const body = readBody(read, contracts, origin);
65
+ return body.ok
66
+ ? {
67
+ ok: true,
68
+ request: {
69
+ origin,
70
+ requestId: read.requestId,
71
+ protocol: route.protocol,
72
+ body: body.value,
73
+ },
74
+ requestId: read.requestId,
75
+ }
76
+ : refused(body.response, read.requestId);
77
+ }
55
78
  function refused(response, requestId) {
56
79
  return { ok: false, response, requestId };
57
80
  }
58
81
  function transportOf(read) {
59
82
  return { method: "POST", headers: read.headers };
60
83
  }
61
- function readBody(read, contracts) {
62
- const code = bodyValue(read.request.body, headerValue(read.headers, "content-type"), contracts.client.limits.maxRequestBytes);
84
+ function readBody(read, contracts, origin) {
85
+ const code = bodyValue(read.request.body, headerValue(read.headers, "content-type"), contracts[origin].limits.maxRequestBytes);
63
86
  return typeof code === "string"
64
87
  ? { ok: false, response: transportFailure(code, read.requestId) }
65
88
  : { ok: true, value: code.value };
@@ -1,10 +1,12 @@
1
- import type { ClientProtocolIdentity } from "../runtime/operation-request.js";
1
+ import type { AvRequestProtocol } from "../runtime/operation-request.js";
2
2
  import type { OperationRouteSegments } from "./absent-route.responder.js";
3
3
  import type { AvProtocolRequest } from "./http-request.decoder.js";
4
4
  import type { AvProtocolResponse } from "./http-response.encoder.js";
5
- /** `POST <entrypoint>/_transactions`. */
5
+ /** `POST <api>/_transactions`. */
6
6
  export declare const TRANSACTIONS_ROUTE = "/_transactions";
7
- /** `GET <entrypoint>/_contract`. */
7
+ /** `POST <api>/_access/can`. */
8
+ export declare const ACCESS_CAN_ROUTE = "/_access/can";
9
+ /** `GET <api>/_contract`. */
8
10
  export declare const CONTRACT_ROUTE = "/_contract";
9
11
  /** The methods an operation or `/_transactions` route accepts: `POST`, only. */
10
12
  export declare const POST_ONLY: readonly string[];
@@ -12,7 +14,7 @@ export declare const POST_ONLY: readonly string[];
12
14
  export declare const GET_ONLY: readonly string[];
13
15
  /**
14
16
  * Whether a path lies in the protocol's namespace: underscore-prefixed paths beneath
15
- * the entrypoint are reserved for framework facilities; every other path is the
17
+ * the `api` mount path are reserved for framework facilities; every other path is the
16
18
  * host's.
17
19
  */
18
20
  export declare function isProtocolPath(path: string): boolean;
@@ -25,10 +27,10 @@ export type ReadRequest = {
25
27
  /** Adopted from `Aventara-Request-Id`, else minted. */
26
28
  readonly requestId: string;
27
29
  /** `undefined` when either identity header is absent (`A2000`). */
28
- readonly protocol: ClientProtocolIdentity | undefined;
30
+ readonly protocol: AvRequestProtocol | undefined;
29
31
  };
30
32
  /** What a value that is not an `AvProtocolRequest` reads as. */
31
- export type UnreadableRequest = {
33
+ type UnreadableRequest = {
32
34
  readonly ok: false;
33
35
  readonly response: AvProtocolResponse;
34
36
  readonly requestId: string;
@@ -43,3 +45,4 @@ export declare function readRequest(received: unknown): ReadRequest | Unreadable
43
45
  * `undefined` when it is not one.
44
46
  */
45
47
  export declare function operationRouteSegments(path: string): OperationRouteSegments | undefined;
48
+ export {};
@@ -3,6 +3,7 @@ import { transportFailure } from "./protocol-failure.js";
3
3
  import { adoptedRequestId, normalizeHeaders, protocolIdentityOf, } from "./protocol-headers.js";
4
4
  const OPERATION_ROUTE = /^\/_resources\/([^/]*)\/([^/]*)\/([^/]*)$/;
5
5
  export const TRANSACTIONS_ROUTE = "/_transactions";
6
+ export const ACCESS_CAN_ROUTE = "/_access/can";
6
7
  export const CONTRACT_ROUTE = "/_contract";
7
8
  export const POST_ONLY = Object.freeze(["POST"]);
8
9
  export const GET_ONLY = Object.freeze(["GET"]);
@@ -1,5 +1,5 @@
1
- import { type OperationResponse } from "../runtime/operation-response.js";
2
- import type { TransactionResponse } from "../transactions/transaction-response.js";
1
+ import { type AvOperationResponse } from "../runtime/operation-response.js";
2
+ import type { AvTransactionResponse } from "../transactions/transaction-response.js";
3
3
  /**
4
4
  * One HTTP response as the protocol hands it to a host: what the encoders
5
5
  * (`protocol.encodeOperation` / `encodeTransaction`) and `protocol.failure`
@@ -28,7 +28,7 @@ export type UnencodableReport = (error: unknown, operation?: number) => void;
28
28
  * `requestId` is echoed as `Aventara-Request-Id` — pass the id the request ran under,
29
29
  * which the decoder supplies.
30
30
  */
31
- export declare function encodeOperationResponse(response: OperationResponse, requestId: string, report?: UnencodableReport): AvProtocolResponse;
31
+ export declare function encodeOperationResponse(response: AvOperationResponse, requestId: string, report?: UnencodableReport): AvProtocolResponse;
32
32
  /**
33
33
  * `protocol.encodeTransaction(response, requestId)`: the same for a plan's response. A
34
34
  * committed plan is `200 A1009` — even when it created something — with each
@@ -37,4 +37,4 @@ export declare function encodeOperationResponse(response: OperationResponse, req
37
37
  * status. A step whose result cannot be encoded answers `A3003` → 500 naming that step
38
38
  * as `cause.operation`, as every internal failure inside a plan does.
39
39
  */
40
- export declare function encodeTransactionResponse(response: TransactionResponse, requestId: string, report?: UnencodableReport): AvProtocolResponse;
40
+ export declare function encodeTransactionResponse(response: AvTransactionResponse, requestId: string, report?: UnencodableReport): AvProtocolResponse;
@@ -1,16 +1,16 @@
1
1
  import { encodeBase64, WIRE_SCALAR_PATTERNS, } from "../contracts/wire-scalar-format.js";
2
- import { Decimal } from "../runtime/decimal.js";
2
+ import { isAvDecimal } from "../runtime/decimal.js";
3
3
  import { SERIALIZATION_FAILURE_MESSAGE } from "../runtime/error-boundary.js";
4
4
  import { operationFailure, } from "../runtime/operation-response.js";
5
5
  import { httpStatus } from "./http-status.table.js";
6
6
  import { headers } from "./protocol-headers.js";
7
7
  export function encodeOperationResponse(response, requestId, report) {
8
8
  try {
9
- return written(response, toWire(response.data, new Set()), requestId);
9
+ return written(response, toWireText(response.data), requestId);
10
10
  }
11
11
  catch (error) {
12
12
  report?.(error);
13
- return written(serializationFailure(), null, requestId);
13
+ return written(serializationFailure(), "null", requestId);
14
14
  }
15
15
  }
16
16
  export function encodeTransactionResponse(response, requestId, report) {
@@ -25,13 +25,16 @@ export function encodeTransactionResponse(response, requestId, report) {
25
25
  }
26
26
  const steps = [];
27
27
  for (step = 0; step < data.length; step += 1) {
28
- steps.push(toWireElement(data, step, new Set()));
28
+ if (!Object.hasOwn(data, step)) {
29
+ throw unencodable(data);
30
+ }
31
+ steps.push(toWireText(data[step]));
29
32
  }
30
- return written(response, steps, requestId);
33
+ return written(response, `[${steps.join(",")}]`, requestId);
31
34
  }
32
35
  catch (error) {
33
36
  report?.(error, step);
34
- return written(serializationFailure(step), null, requestId);
37
+ return written(serializationFailure(step), "null", requestId);
35
38
  }
36
39
  }
37
40
  function serializationFailure(operation) {
@@ -51,82 +54,118 @@ function written(response, wireData, requestId) {
51
54
  "Content-Type": "application/json",
52
55
  [headers.requestId]: requestId,
53
56
  },
54
- body: JSON.stringify({ data: wireData, code, cause }),
57
+ body: `{"data":${wireData},${JSON.stringify({ code, cause }).slice(1)}`,
55
58
  };
56
59
  }
57
60
  function unencodable(value) {
58
61
  return new TypeError("A result value has no wire form.", { cause: value });
59
62
  }
60
- function toWire(value, ancestors) {
63
+ function toWireText(value) {
64
+ const output = [];
65
+ const ancestors = new Set();
66
+ const stack = [{ kind: "value", value }];
67
+ while (stack.length > 0) {
68
+ const task = stack.pop();
69
+ if (task.kind === "text") {
70
+ output.push(task.text);
71
+ continue;
72
+ }
73
+ if (task.kind === "leave") {
74
+ ancestors.delete(task.container);
75
+ continue;
76
+ }
77
+ const current = task.value;
78
+ const scalar = scalarWireText(current);
79
+ if (scalar !== undefined) {
80
+ output.push(scalar);
81
+ continue;
82
+ }
83
+ const container = current;
84
+ if (ancestors.has(container)) {
85
+ throw unencodable(container);
86
+ }
87
+ ancestors.add(container);
88
+ stack.push({ kind: "leave", container });
89
+ if (Array.isArray(container)) {
90
+ pushList(stack, container);
91
+ }
92
+ else {
93
+ pushRecord(stack, container);
94
+ }
95
+ }
96
+ return output.join("");
97
+ }
98
+ function pushList(stack, list) {
99
+ const tasks = [{ kind: "text", text: "[" }];
100
+ for (let index = 0; index < list.length; index += 1) {
101
+ if (!Object.hasOwn(list, index)) {
102
+ throw unencodable(list);
103
+ }
104
+ if (index > 0) {
105
+ tasks.push({ kind: "text", text: "," });
106
+ }
107
+ tasks.push({ kind: "value", value: list[index] });
108
+ }
109
+ tasks.push({ kind: "text", text: "]" });
110
+ pushReversed(stack, tasks);
111
+ }
112
+ function pushRecord(stack, record) {
113
+ const prototype = Object.getPrototypeOf(record);
114
+ if (prototype !== Object.prototype && prototype !== null) {
115
+ throw unencodable(record);
116
+ }
117
+ const tasks = [{ kind: "text", text: "{" }];
118
+ for (const key of Object.keys(record)) {
119
+ const member = record[key];
120
+ if (member === undefined) {
121
+ continue;
122
+ }
123
+ tasks.push({
124
+ kind: "text",
125
+ text: `${tasks.length > 1 ? "," : ""}${JSON.stringify(key)}:`,
126
+ });
127
+ tasks.push({ kind: "value", value: member });
128
+ }
129
+ tasks.push({ kind: "text", text: "}" });
130
+ pushReversed(stack, tasks);
131
+ }
132
+ function pushReversed(stack, tasks) {
133
+ for (let index = tasks.length - 1; index >= 0; index -= 1) {
134
+ stack.push(tasks[index]);
135
+ }
136
+ }
137
+ function scalarWireText(value) {
61
138
  switch (typeof value) {
62
139
  case "string":
63
140
  case "boolean":
64
- return value;
141
+ return JSON.stringify(value);
65
142
  case "number":
66
143
  if (Number.isFinite(value)) {
67
- return value;
144
+ return JSON.stringify(value);
68
145
  }
69
146
  throw unencodable(value);
70
147
  case "bigint":
71
- return value.toString(10);
148
+ return JSON.stringify(value.toString(10));
72
149
  case "object":
73
150
  break;
74
151
  default:
75
152
  throw unencodable(value);
76
153
  }
77
154
  if (value === null) {
78
- return null;
155
+ return "null";
79
156
  }
80
157
  if (value instanceof Date) {
81
158
  const wire = Number.isNaN(value.getTime()) ? "" : value.toISOString();
82
159
  if (!WIRE_SCALAR_PATTERNS.datetime.test(wire)) {
83
160
  throw unencodable(value);
84
161
  }
85
- return wire;
162
+ return JSON.stringify(wire);
86
163
  }
87
- if (value instanceof Decimal) {
88
- return value.toString();
164
+ if (isAvDecimal(value)) {
165
+ return JSON.stringify(value.toString());
89
166
  }
90
167
  if (value instanceof Uint8Array) {
91
- return encodeBase64(value);
92
- }
93
- if (ancestors.has(value)) {
94
- throw unencodable(value);
95
- }
96
- ancestors.add(value);
97
- try {
98
- return Array.isArray(value)
99
- ? toWireList(value, ancestors)
100
- : toWireRecord(value, ancestors);
101
- }
102
- finally {
103
- ancestors.delete(value);
104
- }
105
- }
106
- function toWireList(list, ancestors) {
107
- const wire = [];
108
- for (let index = 0; index < list.length; index += 1) {
109
- wire.push(toWireElement(list, index, ancestors));
110
- }
111
- return wire;
112
- }
113
- function toWireElement(list, index, ancestors) {
114
- if (!Object.hasOwn(list, index)) {
115
- throw unencodable(list);
116
- }
117
- return toWire(list[index], ancestors);
118
- }
119
- function toWireRecord(record, ancestors) {
120
- const prototype = Object.getPrototypeOf(record);
121
- if (prototype !== Object.prototype && prototype !== null) {
122
- throw unencodable(record);
123
- }
124
- const members = [];
125
- for (const key of Object.keys(record)) {
126
- const member = record[key];
127
- if (member !== undefined) {
128
- members.push([key, toWire(member, ancestors)]);
129
- }
168
+ return JSON.stringify(encodeBase64(value));
130
169
  }
131
- return Object.fromEntries(members);
170
+ return undefined;
132
171
  }
@@ -1,7 +1,7 @@
1
- import type { OperationCode } from "../runtime/operation-response.js";
1
+ import type { AvOperationCode } from "../runtime/operation-response.js";
2
2
  /**
3
3
  * `AvProtocol.httpStatus` — the HTTP status each A-code carries, as passive data.
4
4
  */
5
5
  export declare const httpStatus: {
6
- readonly [C in OperationCode]: number;
6
+ readonly [C in AvOperationCode]: number;
7
7
  };
@@ -1,5 +1,5 @@
1
- import { type OperationResponse } from "../runtime/operation-response.js";
1
+ import { type AvOperationResponse } from "../runtime/operation-response.js";
2
2
  /**
3
3
  * The HTTP status plays no part — a code is read even at an unexpected status.
4
4
  */
5
- export declare function isOperationResponse(value: unknown): value is OperationResponse;
5
+ export declare function isOperationResponse(value: unknown): value is AvOperationResponse;
@@ -1,4 +1,4 @@
1
- import type { ClientProtocolIdentity } from "../runtime/operation-request.js";
1
+ import type { AvRequestProtocol } from "../runtime/operation-request.js";
2
2
  /** `AvProtocol.headers` — the header names the protocol owns, as passive data. */
3
3
  export declare const headers: Readonly<{
4
4
  readonly protocolVersion: "Aventara-Protocol-Version";
@@ -22,11 +22,11 @@ export declare function normalizeHeaders(received: ReceivedHeaders): Readonly<Re
22
22
  */
23
23
  export declare function headerValue(normalized: Readonly<Record<string, string>>, name: string): string | undefined;
24
24
  /**
25
- * The identity headers as the `ClientProtocolIdentity` core checks, or `undefined`
25
+ * The identity headers as the `AvRequestProtocol` core checks, or `undefined`
26
26
  * when either is ABSENT — a request without them is malformed: it does not say which
27
27
  * protocol and ClientContract it speaks, so there is nothing to compare.
28
28
  */
29
- export declare function protocolIdentityOf(normalized: Readonly<Record<string, string>>): ClientProtocolIdentity | undefined;
29
+ export declare function protocolIdentityOf(normalized: Readonly<Record<string, string>>): AvRequestProtocol | undefined;
30
30
  /**
31
31
  * The identity headers a request did not send, in the order the framework sends them —
32
32
  * what the `A2000` answering it names. Empty exactly when {@link protocolIdentityOf}
@@ -1,5 +1,5 @@
1
- import type { ClientContract } from "../contracts/contract.js";
2
- import { type OperationIdentity } from "../operations/operation-identity.js";
1
+ import type { AvContractClient } from "../contracts/contract.js";
2
+ import { type AvOperationIdentity } from "../operations/operation-identity.js";
3
3
  /**
4
4
  * One route of the protocol surface: a route a host mounts for the bound
5
5
  * ClientContract, tagged by `kind`.
@@ -9,7 +9,7 @@ export type SurfaceRoute = ({
9
9
  readonly method: "POST";
10
10
  readonly path: `/_resources/${string}`;
11
11
  readonly resource: string;
12
- } & OperationIdentity) | {
12
+ } & AvOperationIdentity) | {
13
13
  readonly kind: "contract";
14
14
  readonly method: "GET";
15
15
  readonly path: "/_contract";
@@ -17,11 +17,16 @@ export type SurfaceRoute = ({
17
17
  readonly kind: "transactions";
18
18
  readonly method: "POST";
19
19
  readonly path: "/_transactions";
20
+ } | {
21
+ readonly kind: "can";
22
+ readonly method: "POST";
23
+ readonly path: "/_access/can";
20
24
  };
21
25
  /**
22
26
  * The route list of one ClientContract: every route a host mounts, from one list,
23
27
  * deep-frozen — exactly the advertised operation triples in the Contract's own key
24
28
  * order, then `GET /_contract`, then `POST /_transactions` when, and only when,
25
- * `transactions === "interactive"`.
29
+ * `transactions === "interactive"`, then `POST /_access/can` when, and only when,
30
+ * the Contract has its `access` section.
26
31
  */
27
- export declare function surfaceOf(client: ClientContract): readonly SurfaceRoute[];
32
+ export declare function surfaceOf(client: AvContractClient): readonly SurfaceRoute[];
@@ -37,5 +37,12 @@ export function surfaceOf(client) {
37
37
  path: "/_transactions",
38
38
  }));
39
39
  }
40
+ if (client.access !== undefined) {
41
+ routes.push(Object.freeze({
42
+ kind: "can",
43
+ method: "POST",
44
+ path: "/_access/can",
45
+ }));
46
+ }
40
47
  return Object.freeze(routes);
41
48
  }