@appport/sdk 1.0.1

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 (387) hide show
  1. package/LICENSE +126 -0
  2. package/README.md +39 -0
  3. package/dist/index.d.ts +14 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +14 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/node.d.ts +3 -0
  8. package/dist/node.d.ts.map +1 -0
  9. package/dist/node.js +3 -0
  10. package/dist/node.js.map +1 -0
  11. package/node_modules/@appport/authorization/README.md +28 -0
  12. package/node_modules/@appport/authorization/dist/index.d.ts +94 -0
  13. package/node_modules/@appport/authorization/dist/index.d.ts.map +1 -0
  14. package/node_modules/@appport/authorization/dist/index.js +131 -0
  15. package/node_modules/@appport/authorization/dist/index.js.map +1 -0
  16. package/node_modules/@appport/authorization/package.json +28 -0
  17. package/node_modules/@appport/client/README.md +35 -0
  18. package/node_modules/@appport/client/dist/channel.d.ts +14 -0
  19. package/node_modules/@appport/client/dist/channel.d.ts.map +1 -0
  20. package/node_modules/@appport/client/dist/channel.js +58 -0
  21. package/node_modules/@appport/client/dist/channel.js.map +1 -0
  22. package/node_modules/@appport/client/dist/client.d.ts +61 -0
  23. package/node_modules/@appport/client/dist/client.d.ts.map +1 -0
  24. package/node_modules/@appport/client/dist/client.js +214 -0
  25. package/node_modules/@appport/client/dist/client.js.map +1 -0
  26. package/node_modules/@appport/client/dist/contract.d.ts +55 -0
  27. package/node_modules/@appport/client/dist/contract.d.ts.map +1 -0
  28. package/node_modules/@appport/client/dist/contract.js +12 -0
  29. package/node_modules/@appport/client/dist/contract.js.map +1 -0
  30. package/node_modules/@appport/client/dist/discovery.d.ts +17 -0
  31. package/node_modules/@appport/client/dist/discovery.d.ts.map +1 -0
  32. package/node_modules/@appport/client/dist/discovery.js +56 -0
  33. package/node_modules/@appport/client/dist/discovery.js.map +1 -0
  34. package/node_modules/@appport/client/dist/duplex.d.ts +25 -0
  35. package/node_modules/@appport/client/dist/duplex.d.ts.map +1 -0
  36. package/node_modules/@appport/client/dist/duplex.js +194 -0
  37. package/node_modules/@appport/client/dist/duplex.js.map +1 -0
  38. package/node_modules/@appport/client/dist/index.d.ts +13 -0
  39. package/node_modules/@appport/client/dist/index.d.ts.map +1 -0
  40. package/node_modules/@appport/client/dist/index.js +13 -0
  41. package/node_modules/@appport/client/dist/index.js.map +1 -0
  42. package/node_modules/@appport/client/dist/transport.d.ts +42 -0
  43. package/node_modules/@appport/client/dist/transport.d.ts.map +1 -0
  44. package/node_modules/@appport/client/dist/transport.js +2 -0
  45. package/node_modules/@appport/client/dist/transport.js.map +1 -0
  46. package/node_modules/@appport/client/package.json +32 -0
  47. package/node_modules/@appport/core/README.md +91 -0
  48. package/node_modules/@appport/core/dist/appboundry-contract.d.ts +80 -0
  49. package/node_modules/@appport/core/dist/appboundry-contract.d.ts.map +1 -0
  50. package/node_modules/@appport/core/dist/appboundry-contract.js +160 -0
  51. package/node_modules/@appport/core/dist/appboundry-contract.js.map +1 -0
  52. package/node_modules/@appport/core/dist/application-implementation.d.ts +125 -0
  53. package/node_modules/@appport/core/dist/application-implementation.d.ts.map +1 -0
  54. package/node_modules/@appport/core/dist/application-implementation.js +220 -0
  55. package/node_modules/@appport/core/dist/application-implementation.js.map +1 -0
  56. package/node_modules/@appport/core/dist/application-lifecycle.d.ts +150 -0
  57. package/node_modules/@appport/core/dist/application-lifecycle.d.ts.map +1 -0
  58. package/node_modules/@appport/core/dist/application-lifecycle.js +70 -0
  59. package/node_modules/@appport/core/dist/application-lifecycle.js.map +1 -0
  60. package/node_modules/@appport/core/dist/application-source.d.ts +109 -0
  61. package/node_modules/@appport/core/dist/application-source.d.ts.map +1 -0
  62. package/node_modules/@appport/core/dist/application-source.js +186 -0
  63. package/node_modules/@appport/core/dist/application-source.js.map +1 -0
  64. package/node_modules/@appport/core/dist/application.d.ts +122 -0
  65. package/node_modules/@appport/core/dist/application.d.ts.map +1 -0
  66. package/node_modules/@appport/core/dist/application.js +515 -0
  67. package/node_modules/@appport/core/dist/application.js.map +1 -0
  68. package/node_modules/@appport/core/dist/artifact.d.ts +395 -0
  69. package/node_modules/@appport/core/dist/artifact.d.ts.map +1 -0
  70. package/node_modules/@appport/core/dist/artifact.js +392 -0
  71. package/node_modules/@appport/core/dist/artifact.js.map +1 -0
  72. package/node_modules/@appport/core/dist/assembly.d.ts +237 -0
  73. package/node_modules/@appport/core/dist/assembly.d.ts.map +1 -0
  74. package/node_modules/@appport/core/dist/assembly.js +458 -0
  75. package/node_modules/@appport/core/dist/assembly.js.map +1 -0
  76. package/node_modules/@appport/core/dist/authority-attestation.d.ts +34 -0
  77. package/node_modules/@appport/core/dist/authority-attestation.d.ts.map +1 -0
  78. package/node_modules/@appport/core/dist/authority-attestation.js +72 -0
  79. package/node_modules/@appport/core/dist/authority-attestation.js.map +1 -0
  80. package/node_modules/@appport/core/dist/authorization-grant.d.ts +107 -0
  81. package/node_modules/@appport/core/dist/authorization-grant.d.ts.map +1 -0
  82. package/node_modules/@appport/core/dist/authorization-grant.js +131 -0
  83. package/node_modules/@appport/core/dist/authorization-grant.js.map +1 -0
  84. package/node_modules/@appport/core/dist/binding.d.ts +294 -0
  85. package/node_modules/@appport/core/dist/binding.d.ts.map +1 -0
  86. package/node_modules/@appport/core/dist/binding.js +263 -0
  87. package/node_modules/@appport/core/dist/binding.js.map +1 -0
  88. package/node_modules/@appport/core/dist/builtins.d.ts +18 -0
  89. package/node_modules/@appport/core/dist/builtins.d.ts.map +1 -0
  90. package/node_modules/@appport/core/dist/builtins.js +38 -0
  91. package/node_modules/@appport/core/dist/builtins.js.map +1 -0
  92. package/node_modules/@appport/core/dist/capability.d.ts +94 -0
  93. package/node_modules/@appport/core/dist/capability.d.ts.map +1 -0
  94. package/node_modules/@appport/core/dist/capability.js +85 -0
  95. package/node_modules/@appport/core/dist/capability.js.map +1 -0
  96. package/node_modules/@appport/core/dist/concurrency.d.ts +16 -0
  97. package/node_modules/@appport/core/dist/concurrency.d.ts.map +1 -0
  98. package/node_modules/@appport/core/dist/concurrency.js +46 -0
  99. package/node_modules/@appport/core/dist/concurrency.js.map +1 -0
  100. package/node_modules/@appport/core/dist/context.d.ts +59 -0
  101. package/node_modules/@appport/core/dist/context.d.ts.map +1 -0
  102. package/node_modules/@appport/core/dist/context.js +14 -0
  103. package/node_modules/@appport/core/dist/context.js.map +1 -0
  104. package/node_modules/@appport/core/dist/contract-artifact.d.ts +15 -0
  105. package/node_modules/@appport/core/dist/contract-artifact.d.ts.map +1 -0
  106. package/node_modules/@appport/core/dist/contract-artifact.js +152 -0
  107. package/node_modules/@appport/core/dist/contract-artifact.js.map +1 -0
  108. package/node_modules/@appport/core/dist/contract-attestation.d.ts +68 -0
  109. package/node_modules/@appport/core/dist/contract-attestation.d.ts.map +1 -0
  110. package/node_modules/@appport/core/dist/contract-attestation.js +76 -0
  111. package/node_modules/@appport/core/dist/contract-attestation.js.map +1 -0
  112. package/node_modules/@appport/core/dist/crash-injection.d.ts +3 -0
  113. package/node_modules/@appport/core/dist/crash-injection.d.ts.map +1 -0
  114. package/node_modules/@appport/core/dist/crash-injection.js +8 -0
  115. package/node_modules/@appport/core/dist/crash-injection.js.map +1 -0
  116. package/node_modules/@appport/core/dist/events.d.ts +33 -0
  117. package/node_modules/@appport/core/dist/events.d.ts.map +1 -0
  118. package/node_modules/@appport/core/dist/events.js +79 -0
  119. package/node_modules/@appport/core/dist/events.js.map +1 -0
  120. package/node_modules/@appport/core/dist/execution-barrier.d.ts +13 -0
  121. package/node_modules/@appport/core/dist/execution-barrier.d.ts.map +1 -0
  122. package/node_modules/@appport/core/dist/execution-barrier.js +33 -0
  123. package/node_modules/@appport/core/dist/execution-barrier.js.map +1 -0
  124. package/node_modules/@appport/core/dist/execution-ledger.d.ts +81 -0
  125. package/node_modules/@appport/core/dist/execution-ledger.d.ts.map +1 -0
  126. package/node_modules/@appport/core/dist/execution-ledger.js +173 -0
  127. package/node_modules/@appport/core/dist/execution-ledger.js.map +1 -0
  128. package/node_modules/@appport/core/dist/execution.d.ts +387 -0
  129. package/node_modules/@appport/core/dist/execution.d.ts.map +1 -0
  130. package/node_modules/@appport/core/dist/execution.js +165 -0
  131. package/node_modules/@appport/core/dist/execution.js.map +1 -0
  132. package/node_modules/@appport/core/dist/idempotency.d.ts +36 -0
  133. package/node_modules/@appport/core/dist/idempotency.d.ts.map +1 -0
  134. package/node_modules/@appport/core/dist/idempotency.js +36 -0
  135. package/node_modules/@appport/core/dist/idempotency.js.map +1 -0
  136. package/node_modules/@appport/core/dist/implementation.d.ts +110 -0
  137. package/node_modules/@appport/core/dist/implementation.d.ts.map +1 -0
  138. package/node_modules/@appport/core/dist/implementation.js +65 -0
  139. package/node_modules/@appport/core/dist/implementation.js.map +1 -0
  140. package/node_modules/@appport/core/dist/index.d.ts +44 -0
  141. package/node_modules/@appport/core/dist/index.d.ts.map +1 -0
  142. package/node_modules/@appport/core/dist/index.js +44 -0
  143. package/node_modules/@appport/core/dist/index.js.map +1 -0
  144. package/node_modules/@appport/core/dist/invocation.d.ts +253 -0
  145. package/node_modules/@appport/core/dist/invocation.d.ts.map +1 -0
  146. package/node_modules/@appport/core/dist/invocation.js +258 -0
  147. package/node_modules/@appport/core/dist/invocation.js.map +1 -0
  148. package/node_modules/@appport/core/dist/manifest.d.ts +157 -0
  149. package/node_modules/@appport/core/dist/manifest.d.ts.map +1 -0
  150. package/node_modules/@appport/core/dist/manifest.js +255 -0
  151. package/node_modules/@appport/core/dist/manifest.js.map +1 -0
  152. package/node_modules/@appport/core/dist/memory-application-data-store.d.ts +19 -0
  153. package/node_modules/@appport/core/dist/memory-application-data-store.d.ts.map +1 -0
  154. package/node_modules/@appport/core/dist/memory-application-data-store.js +161 -0
  155. package/node_modules/@appport/core/dist/memory-application-data-store.js.map +1 -0
  156. package/node_modules/@appport/core/dist/operations.d.ts +61 -0
  157. package/node_modules/@appport/core/dist/operations.d.ts.map +1 -0
  158. package/node_modules/@appport/core/dist/operations.js +210 -0
  159. package/node_modules/@appport/core/dist/operations.js.map +1 -0
  160. package/node_modules/@appport/core/dist/public.d.ts +19 -0
  161. package/node_modules/@appport/core/dist/public.d.ts.map +1 -0
  162. package/node_modules/@appport/core/dist/public.js +18 -0
  163. package/node_modules/@appport/core/dist/public.js.map +1 -0
  164. package/node_modules/@appport/core/dist/registration.d.ts +165 -0
  165. package/node_modules/@appport/core/dist/registration.d.ts.map +1 -0
  166. package/node_modules/@appport/core/dist/registration.js +253 -0
  167. package/node_modules/@appport/core/dist/registration.js.map +1 -0
  168. package/node_modules/@appport/core/dist/registry.d.ts +29 -0
  169. package/node_modules/@appport/core/dist/registry.d.ts.map +1 -0
  170. package/node_modules/@appport/core/dist/registry.js +148 -0
  171. package/node_modules/@appport/core/dist/registry.js.map +1 -0
  172. package/node_modules/@appport/core/dist/repository-connection.d.ts +100 -0
  173. package/node_modules/@appport/core/dist/repository-connection.d.ts.map +1 -0
  174. package/node_modules/@appport/core/dist/repository-connection.js +57 -0
  175. package/node_modules/@appport/core/dist/repository-connection.js.map +1 -0
  176. package/node_modules/@appport/core/dist/resolver.d.ts +130 -0
  177. package/node_modules/@appport/core/dist/resolver.d.ts.map +1 -0
  178. package/node_modules/@appport/core/dist/resolver.js +252 -0
  179. package/node_modules/@appport/core/dist/resolver.js.map +1 -0
  180. package/node_modules/@appport/core/dist/runtime-manifest.d.ts +68 -0
  181. package/node_modules/@appport/core/dist/runtime-manifest.d.ts.map +1 -0
  182. package/node_modules/@appport/core/dist/runtime-manifest.js +84 -0
  183. package/node_modules/@appport/core/dist/runtime-manifest.js.map +1 -0
  184. package/node_modules/@appport/core/dist/sanitize.d.ts +14 -0
  185. package/node_modules/@appport/core/dist/sanitize.d.ts.map +1 -0
  186. package/node_modules/@appport/core/dist/sanitize.js +49 -0
  187. package/node_modules/@appport/core/dist/sanitize.js.map +1 -0
  188. package/node_modules/@appport/core/dist/server-internal.d.ts +5 -0
  189. package/node_modules/@appport/core/dist/server-internal.d.ts.map +1 -0
  190. package/node_modules/@appport/core/dist/server-internal.js +4 -0
  191. package/node_modules/@appport/core/dist/server-internal.js.map +1 -0
  192. package/node_modules/@appport/core/dist/sessions.d.ts +29 -0
  193. package/node_modules/@appport/core/dist/sessions.d.ts.map +1 -0
  194. package/node_modules/@appport/core/dist/sessions.js +39 -0
  195. package/node_modules/@appport/core/dist/sessions.js.map +1 -0
  196. package/node_modules/@appport/core/dist/sha256.d.ts +3 -0
  197. package/node_modules/@appport/core/dist/sha256.d.ts.map +1 -0
  198. package/node_modules/@appport/core/dist/sha256.js +46 -0
  199. package/node_modules/@appport/core/dist/sha256.js.map +1 -0
  200. package/node_modules/@appport/core/dist/source-verification.d.ts +53 -0
  201. package/node_modules/@appport/core/dist/source-verification.d.ts.map +1 -0
  202. package/node_modules/@appport/core/dist/source-verification.js +92 -0
  203. package/node_modules/@appport/core/dist/source-verification.js.map +1 -0
  204. package/node_modules/@appport/core/dist/state-context.d.ts +312 -0
  205. package/node_modules/@appport/core/dist/state-context.d.ts.map +1 -0
  206. package/node_modules/@appport/core/dist/state-context.js +100 -0
  207. package/node_modules/@appport/core/dist/state-context.js.map +1 -0
  208. package/node_modules/@appport/core/dist/state.d.ts +96 -0
  209. package/node_modules/@appport/core/dist/state.d.ts.map +1 -0
  210. package/node_modules/@appport/core/dist/state.js +89 -0
  211. package/node_modules/@appport/core/dist/state.js.map +1 -0
  212. package/node_modules/@appport/core/dist/streams.d.ts +38 -0
  213. package/node_modules/@appport/core/dist/streams.d.ts.map +1 -0
  214. package/node_modules/@appport/core/dist/streams.js +123 -0
  215. package/node_modules/@appport/core/dist/streams.js.map +1 -0
  216. package/node_modules/@appport/core/dist/telemetry.d.ts +42 -0
  217. package/node_modules/@appport/core/dist/telemetry.d.ts.map +1 -0
  218. package/node_modules/@appport/core/dist/telemetry.js +32 -0
  219. package/node_modules/@appport/core/dist/telemetry.js.map +1 -0
  220. package/node_modules/@appport/core/dist/wasm-engine.d.ts +22 -0
  221. package/node_modules/@appport/core/dist/wasm-engine.d.ts.map +1 -0
  222. package/node_modules/@appport/core/dist/wasm-engine.js +367 -0
  223. package/node_modules/@appport/core/dist/wasm-engine.js.map +1 -0
  224. package/node_modules/@appport/core/package.json +58 -0
  225. package/node_modules/@appport/mobile/README.md +10 -0
  226. package/node_modules/@appport/mobile/dist/index.d.ts +66 -0
  227. package/node_modules/@appport/mobile/dist/index.d.ts.map +1 -0
  228. package/node_modules/@appport/mobile/dist/index.js +182 -0
  229. package/node_modules/@appport/mobile/dist/index.js.map +1 -0
  230. package/node_modules/@appport/mobile/package.json +33 -0
  231. package/node_modules/@appport/protocol/README.md +41 -0
  232. package/node_modules/@appport/protocol/dist/blob.d.ts +46 -0
  233. package/node_modules/@appport/protocol/dist/blob.d.ts.map +1 -0
  234. package/node_modules/@appport/protocol/dist/blob.js +23 -0
  235. package/node_modules/@appport/protocol/dist/blob.js.map +1 -0
  236. package/node_modules/@appport/protocol/dist/compatibility.d.ts +25 -0
  237. package/node_modules/@appport/protocol/dist/compatibility.d.ts.map +1 -0
  238. package/node_modules/@appport/protocol/dist/compatibility.js +189 -0
  239. package/node_modules/@appport/protocol/dist/compatibility.js.map +1 -0
  240. package/node_modules/@appport/protocol/dist/envelopes.d.ts +175 -0
  241. package/node_modules/@appport/protocol/dist/envelopes.d.ts.map +1 -0
  242. package/node_modules/@appport/protocol/dist/envelopes.js +97 -0
  243. package/node_modules/@appport/protocol/dist/envelopes.js.map +1 -0
  244. package/node_modules/@appport/protocol/dist/errors.d.ts +74 -0
  245. package/node_modules/@appport/protocol/dist/errors.d.ts.map +1 -0
  246. package/node_modules/@appport/protocol/dist/errors.js +91 -0
  247. package/node_modules/@appport/protocol/dist/errors.js.map +1 -0
  248. package/node_modules/@appport/protocol/dist/ids.d.ts +12 -0
  249. package/node_modules/@appport/protocol/dist/ids.d.ts.map +1 -0
  250. package/node_modules/@appport/protocol/dist/ids.js +50 -0
  251. package/node_modules/@appport/protocol/dist/ids.js.map +1 -0
  252. package/node_modules/@appport/protocol/dist/index.d.ts +20 -0
  253. package/node_modules/@appport/protocol/dist/index.d.ts.map +1 -0
  254. package/node_modules/@appport/protocol/dist/index.js +20 -0
  255. package/node_modules/@appport/protocol/dist/index.js.map +1 -0
  256. package/node_modules/@appport/protocol/dist/jsonschema.d.ts +50 -0
  257. package/node_modules/@appport/protocol/dist/jsonschema.d.ts.map +1 -0
  258. package/node_modules/@appport/protocol/dist/jsonschema.js +6 -0
  259. package/node_modules/@appport/protocol/dist/jsonschema.js.map +1 -0
  260. package/node_modules/@appport/protocol/dist/manifest.d.ts +131 -0
  261. package/node_modules/@appport/protocol/dist/manifest.d.ts.map +1 -0
  262. package/node_modules/@appport/protocol/dist/manifest.js +20 -0
  263. package/node_modules/@appport/protocol/dist/manifest.js.map +1 -0
  264. package/node_modules/@appport/protocol/dist/names.d.ts +26 -0
  265. package/node_modules/@appport/protocol/dist/names.d.ts.map +1 -0
  266. package/node_modules/@appport/protocol/dist/names.js +85 -0
  267. package/node_modules/@appport/protocol/dist/names.js.map +1 -0
  268. package/node_modules/@appport/protocol/dist/operations.d.ts +34 -0
  269. package/node_modules/@appport/protocol/dist/operations.d.ts.map +1 -0
  270. package/node_modules/@appport/protocol/dist/operations.js +9 -0
  271. package/node_modules/@appport/protocol/dist/operations.js.map +1 -0
  272. package/node_modules/@appport/protocol/dist/session.d.ts +27 -0
  273. package/node_modules/@appport/protocol/dist/session.d.ts.map +1 -0
  274. package/node_modules/@appport/protocol/dist/session.js +7 -0
  275. package/node_modules/@appport/protocol/dist/session.js.map +1 -0
  276. package/node_modules/@appport/protocol/dist/validate.d.ts +37 -0
  277. package/node_modules/@appport/protocol/dist/validate.d.ts.map +1 -0
  278. package/node_modules/@appport/protocol/dist/validate.js +321 -0
  279. package/node_modules/@appport/protocol/dist/validate.js.map +1 -0
  280. package/node_modules/@appport/protocol/dist/version.d.ts +27 -0
  281. package/node_modules/@appport/protocol/dist/version.d.ts.map +1 -0
  282. package/node_modules/@appport/protocol/dist/version.js +26 -0
  283. package/node_modules/@appport/protocol/dist/version.js.map +1 -0
  284. package/node_modules/@appport/protocol/package.json +25 -0
  285. package/node_modules/@appport/schema/README.md +32 -0
  286. package/node_modules/@appport/schema/dist/builder.d.ts +85 -0
  287. package/node_modules/@appport/schema/dist/builder.d.ts.map +1 -0
  288. package/node_modules/@appport/schema/dist/builder.js +278 -0
  289. package/node_modules/@appport/schema/dist/builder.js.map +1 -0
  290. package/node_modules/@appport/schema/dist/from-json-schema.d.ts +12 -0
  291. package/node_modules/@appport/schema/dist/from-json-schema.d.ts.map +1 -0
  292. package/node_modules/@appport/schema/dist/from-json-schema.js +186 -0
  293. package/node_modules/@appport/schema/dist/from-json-schema.js.map +1 -0
  294. package/node_modules/@appport/schema/dist/index.d.ts +23 -0
  295. package/node_modules/@appport/schema/dist/index.d.ts.map +1 -0
  296. package/node_modules/@appport/schema/dist/index.js +22 -0
  297. package/node_modules/@appport/schema/dist/index.js.map +1 -0
  298. package/node_modules/@appport/schema/dist/standard.d.ts +46 -0
  299. package/node_modules/@appport/schema/dist/standard.d.ts.map +1 -0
  300. package/node_modules/@appport/schema/dist/standard.js +42 -0
  301. package/node_modules/@appport/schema/dist/standard.js.map +1 -0
  302. package/node_modules/@appport/schema/dist/types.d.ts +40 -0
  303. package/node_modules/@appport/schema/dist/types.d.ts.map +1 -0
  304. package/node_modules/@appport/schema/dist/types.js +19 -0
  305. package/node_modules/@appport/schema/dist/types.js.map +1 -0
  306. package/node_modules/@appport/schema/package.json +28 -0
  307. package/node_modules/@appport/server/README.md +39 -0
  308. package/node_modules/@appport/server/dist/connection.d.ts +45 -0
  309. package/node_modules/@appport/server/dist/connection.d.ts.map +1 -0
  310. package/node_modules/@appport/server/dist/connection.js +217 -0
  311. package/node_modules/@appport/server/dist/connection.js.map +1 -0
  312. package/node_modules/@appport/server/dist/fetch.d.ts +10 -0
  313. package/node_modules/@appport/server/dist/fetch.d.ts.map +1 -0
  314. package/node_modules/@appport/server/dist/fetch.js +50 -0
  315. package/node_modules/@appport/server/dist/fetch.js.map +1 -0
  316. package/node_modules/@appport/server/dist/http.d.ts +80 -0
  317. package/node_modules/@appport/server/dist/http.d.ts.map +1 -0
  318. package/node_modules/@appport/server/dist/http.js +306 -0
  319. package/node_modules/@appport/server/dist/http.js.map +1 -0
  320. package/node_modules/@appport/server/dist/index.d.ts +11 -0
  321. package/node_modules/@appport/server/dist/index.d.ts.map +1 -0
  322. package/node_modules/@appport/server/dist/index.js +11 -0
  323. package/node_modules/@appport/server/dist/index.js.map +1 -0
  324. package/node_modules/@appport/server/dist/node-entry.d.ts +4 -0
  325. package/node_modules/@appport/server/dist/node-entry.d.ts.map +1 -0
  326. package/node_modules/@appport/server/dist/node-entry.js +4 -0
  327. package/node_modules/@appport/server/dist/node-entry.js.map +1 -0
  328. package/node_modules/@appport/server/dist/node.d.ts +45 -0
  329. package/node_modules/@appport/server/dist/node.d.ts.map +1 -0
  330. package/node_modules/@appport/server/dist/node.js +190 -0
  331. package/node_modules/@appport/server/dist/node.js.map +1 -0
  332. package/node_modules/@appport/server/dist/server.d.ts +83 -0
  333. package/node_modules/@appport/server/dist/server.d.ts.map +1 -0
  334. package/node_modules/@appport/server/dist/server.js +114 -0
  335. package/node_modules/@appport/server/dist/server.js.map +1 -0
  336. package/node_modules/@appport/server/dist/websocket.d.ts +25 -0
  337. package/node_modules/@appport/server/dist/websocket.d.ts.map +1 -0
  338. package/node_modules/@appport/server/dist/websocket.js +221 -0
  339. package/node_modules/@appport/server/dist/websocket.js.map +1 -0
  340. package/node_modules/@appport/server/package.json +34 -0
  341. package/node_modules/@appport/transport-electron/README.md +56 -0
  342. package/node_modules/@appport/transport-electron/dist/index.d.ts +11 -0
  343. package/node_modules/@appport/transport-electron/dist/index.d.ts.map +1 -0
  344. package/node_modules/@appport/transport-electron/dist/index.js +11 -0
  345. package/node_modules/@appport/transport-electron/dist/index.js.map +1 -0
  346. package/node_modules/@appport/transport-electron/dist/main.d.ts +31 -0
  347. package/node_modules/@appport/transport-electron/dist/main.d.ts.map +1 -0
  348. package/node_modules/@appport/transport-electron/dist/main.js +61 -0
  349. package/node_modules/@appport/transport-electron/dist/main.js.map +1 -0
  350. package/node_modules/@appport/transport-electron/dist/preload.d.ts +22 -0
  351. package/node_modules/@appport/transport-electron/dist/preload.d.ts.map +1 -0
  352. package/node_modules/@appport/transport-electron/dist/preload.js +29 -0
  353. package/node_modules/@appport/transport-electron/dist/preload.js.map +1 -0
  354. package/node_modules/@appport/transport-electron/dist/renderer.d.ts +16 -0
  355. package/node_modules/@appport/transport-electron/dist/renderer.d.ts.map +1 -0
  356. package/node_modules/@appport/transport-electron/dist/renderer.js +36 -0
  357. package/node_modules/@appport/transport-electron/dist/renderer.js.map +1 -0
  358. package/node_modules/@appport/transport-electron/dist/types.d.ts +49 -0
  359. package/node_modules/@appport/transport-electron/dist/types.d.ts.map +1 -0
  360. package/node_modules/@appport/transport-electron/dist/types.js +5 -0
  361. package/node_modules/@appport/transport-electron/dist/types.js.map +1 -0
  362. package/node_modules/@appport/transport-electron/package.json +46 -0
  363. package/node_modules/@appport/transport-http/README.md +24 -0
  364. package/node_modules/@appport/transport-http/dist/index.d.ts +18 -0
  365. package/node_modules/@appport/transport-http/dist/index.d.ts.map +1 -0
  366. package/node_modules/@appport/transport-http/dist/index.js +223 -0
  367. package/node_modules/@appport/transport-http/dist/index.js.map +1 -0
  368. package/node_modules/@appport/transport-http/package.json +29 -0
  369. package/node_modules/@appport/transport-inprocess/README.md +24 -0
  370. package/node_modules/@appport/transport-inprocess/dist/index.d.ts +16 -0
  371. package/node_modules/@appport/transport-inprocess/dist/index.d.ts.map +1 -0
  372. package/node_modules/@appport/transport-inprocess/dist/index.js +30 -0
  373. package/node_modules/@appport/transport-inprocess/dist/index.js.map +1 -0
  374. package/node_modules/@appport/transport-inprocess/package.json +30 -0
  375. package/node_modules/@appport/transport-tauri/README.md +45 -0
  376. package/node_modules/@appport/transport-tauri/dist/index.d.ts +23 -0
  377. package/node_modules/@appport/transport-tauri/dist/index.d.ts.map +1 -0
  378. package/node_modules/@appport/transport-tauri/dist/index.js +44 -0
  379. package/node_modules/@appport/transport-tauri/dist/index.js.map +1 -0
  380. package/node_modules/@appport/transport-tauri/package.json +29 -0
  381. package/node_modules/@appport/transport-websocket/README.md +22 -0
  382. package/node_modules/@appport/transport-websocket/dist/index.d.ts +26 -0
  383. package/node_modules/@appport/transport-websocket/dist/index.d.ts.map +1 -0
  384. package/node_modules/@appport/transport-websocket/dist/index.js +72 -0
  385. package/node_modules/@appport/transport-websocket/dist/index.js.map +1 -0
  386. package/node_modules/@appport/transport-websocket/package.json +29 -0
  387. package/package.json +79 -0
@@ -0,0 +1,150 @@
1
+ import { type ApplicationManifest } from "./manifest.js";
2
+ import type { ApplicationRegistry } from "./registration.js";
3
+ export type ApplicationLifecyclePhase = "DRAFT" | "VALIDATED" | "REGISTERED" | "ACTIVE" | "CHANGE_PROPOSED" | "RETIRED";
4
+ export type LifecycleEventType = "DEFINED" | "VALIDATED" | "VALIDATION_FAILED" | "REGISTERED" | "CHANGE_PROPOSED" | "CHANGE_APPLIED" | "PROMOTED" | "RETIRED";
5
+ export interface ContractValidation {
6
+ readonly validationId: string;
7
+ readonly fingerprint: string;
8
+ readonly valid: boolean;
9
+ readonly reasons: readonly string[];
10
+ readonly validatedAt: string;
11
+ }
12
+ export interface ContractRevision {
13
+ readonly revisionId: string;
14
+ readonly version: string;
15
+ readonly fingerprint: string;
16
+ readonly manifest: ApplicationManifest;
17
+ readonly disposition: "DRAFT" | "ACTIVE" | "SUPERSEDED";
18
+ readonly createdAt: string;
19
+ }
20
+ export interface PromotionRecord {
21
+ readonly promotionId: string;
22
+ readonly revisionId: string;
23
+ readonly fingerprint: string;
24
+ readonly promotedAt: string;
25
+ }
26
+ export interface LifecycleEvent {
27
+ readonly eventId: string;
28
+ readonly sequence: number;
29
+ readonly type: LifecycleEventType;
30
+ readonly from?: ApplicationLifecyclePhase;
31
+ readonly to: ApplicationLifecyclePhase;
32
+ readonly revisionId: string;
33
+ readonly fingerprint: string;
34
+ readonly occurredAt: string;
35
+ }
36
+ export interface ApplicationLifecycleRecord {
37
+ readonly applicationId: string;
38
+ readonly phase: ApplicationLifecyclePhase;
39
+ readonly sequence: number;
40
+ readonly pendingRevisionId: string;
41
+ readonly activeRevisionId?: string;
42
+ readonly registrationId?: string;
43
+ readonly revisions: readonly ContractRevision[];
44
+ readonly validations: readonly ContractValidation[];
45
+ readonly promotions: readonly PromotionRecord[];
46
+ readonly history: readonly LifecycleEvent[];
47
+ readonly updatedAt: string;
48
+ }
49
+ export interface ApplicationLifecycleStore {
50
+ get(applicationId: string): Promise<ApplicationLifecycleRecord | undefined>;
51
+ put(record: ApplicationLifecycleRecord, expectedSequence: number | undefined): Promise<void>;
52
+ list(): Promise<ApplicationLifecycleRecord[]>;
53
+ }
54
+ export declare class LifecycleConflictError extends Error {
55
+ constructor(id: string);
56
+ }
57
+ export declare class MemoryApplicationLifecycleStore implements ApplicationLifecycleStore {
58
+ private readonly records;
59
+ get(id: string): Promise<ApplicationLifecycleRecord | undefined>;
60
+ put(record: ApplicationLifecycleRecord, expected: number | undefined): Promise<void>;
61
+ list(): Promise<ApplicationLifecycleRecord[]>;
62
+ }
63
+ export interface LifecycleRegistrationGateway {
64
+ validate(revision: ContractRevision): Promise<{
65
+ valid: boolean;
66
+ reasons: readonly string[];
67
+ }>;
68
+ register(revision: ContractRevision): Promise<{
69
+ registrationId: string;
70
+ }>;
71
+ promote(revision: ContractRevision, registrationId: string): Promise<void>;
72
+ apply(revision: ContractRevision, registrationId: string): Promise<void>;
73
+ retire(applicationId: string, registrationId: string): Promise<void>;
74
+ promotionChecks(revision: ContractRevision): Promise<{
75
+ valid: boolean;
76
+ reasons: readonly string[];
77
+ }>;
78
+ }
79
+ /** Connects lifecycle commands to the existing authoritative registry boundary. */
80
+ export declare class ApplicationRegistryLifecycleGateway implements LifecycleRegistrationGateway {
81
+ private readonly registry;
82
+ private readonly checks;
83
+ constructor(registry: ApplicationRegistry, checks?: (revision: ContractRevision) => Promise<{
84
+ valid: boolean;
85
+ reasons: readonly string[];
86
+ }>);
87
+ validate(revision: ContractRevision): Promise<{
88
+ valid: boolean;
89
+ reasons: readonly string[];
90
+ }>;
91
+ register(revision: ContractRevision): Promise<{
92
+ registrationId: string;
93
+ }>;
94
+ promote(revision: ContractRevision, registrationId: string): Promise<void>;
95
+ apply(revision: ContractRevision, registrationId: string): Promise<void>;
96
+ retire(applicationId: string, registrationId: string): Promise<void>;
97
+ promotionChecks(revision: ContractRevision): Promise<{
98
+ valid: boolean;
99
+ reasons: readonly string[];
100
+ }>;
101
+ }
102
+ /** The only command boundary allowed to manufacture authoritative lifecycle facts. */
103
+ export declare class ApplicationLifecycleOperations {
104
+ private readonly store;
105
+ private readonly gateway;
106
+ private readonly now;
107
+ constructor(store: ApplicationLifecycleStore, gateway: LifecycleRegistrationGateway, now?: () => string);
108
+ define(manifest: ApplicationManifest): Promise<ApplicationLifecycleRecord>;
109
+ validate(id: string): Promise<ApplicationLifecycleRecord>;
110
+ register(id: string): Promise<ApplicationLifecycleRecord>;
111
+ promote(id: string): Promise<{
112
+ phase: "ACTIVE";
113
+ sequence: number;
114
+ activeRevisionId: string;
115
+ revisions: ContractRevision[];
116
+ promotions: PromotionRecord[];
117
+ history: LifecycleEvent[];
118
+ updatedAt: string;
119
+ applicationId: string;
120
+ pendingRevisionId: string;
121
+ registrationId?: string;
122
+ validations: readonly ContractValidation[];
123
+ }>;
124
+ proposeChange(id: string, manifest: ApplicationManifest): Promise<ApplicationLifecycleRecord>;
125
+ applyChange(id: string): Promise<{
126
+ phase: "ACTIVE";
127
+ sequence: number;
128
+ activeRevisionId: string;
129
+ revisions: ContractRevision[];
130
+ promotions: PromotionRecord[];
131
+ history: LifecycleEvent[];
132
+ updatedAt: string;
133
+ applicationId: string;
134
+ pendingRevisionId: string;
135
+ registrationId?: string;
136
+ validations: readonly ContractValidation[];
137
+ }>;
138
+ retire(id: string): Promise<ApplicationLifecycleRecord>;
139
+ get: (id: string) => Promise<ApplicationLifecycleRecord | undefined>;
140
+ list: () => Promise<ApplicationLifecycleRecord[]>;
141
+ private activate;
142
+ private advance;
143
+ private revision;
144
+ private event;
145
+ private required;
146
+ private expect;
147
+ private pending;
148
+ private active;
149
+ }
150
+ //# sourceMappingURL=application-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-lifecycle.d.ts","sourceRoot":"","sources":["../src/application-lifecycle.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,MAAM,yBAAyB,GAAG,OAAO,GAAG,WAAW,GAAG,YAAY,GAAG,QAAQ,GAAG,iBAAiB,GAAG,SAAS,CAAC;AACxH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,WAAW,GAAG,mBAAmB,GAAG,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,UAAU,GAAG,SAAS,CAAC;AAC9J,MAAM,WAAW,kBAAkB;IAAG,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAAE;AAChM,MAAM,WAAW,gBAAgB;IAAG,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ,GAAG,YAAY,CAAC;IAAC,QAAQ,CAAC,S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AC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB;IACvD,WAAW,CAAC,EAAE,EAAE,MAAM;;;;;;;;uBA9BwC,MAAM;2BAAoG,MAAM;yBAAgE,MAAM;qBAAyE,SAAS,kBAAkB,EAAE;;IA+B1V,MAAM,CAAC,EAAE,EAAE,MAAM;IACvB,GAAG,GAAI,IAAI,MAAM,qDAAwB;IAAC,IAAI,8CAA2B;YAC3D,QAAQ;YACR,OAAO;IACrB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,KAAK;YACC,QAAQ;IACtB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM;CACf"}
@@ -0,0 +1,70 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { fingerprintManifest } from "./manifest.js";
3
+ export class LifecycleConflictError extends Error {
4
+ constructor(id) { super(`Concurrent lifecycle update rejected for "${id}"`); this.name = "LifecycleConflictError"; }
5
+ }
6
+ export class MemoryApplicationLifecycleStore {
7
+ records = new Map();
8
+ async get(id) { const record = this.records.get(id); return record ? structuredClone(record) : undefined; }
9
+ async put(record, expected) { const current = this.records.get(record.applicationId); if (current?.sequence !== expected)
10
+ throw new LifecycleConflictError(record.applicationId); this.records.set(record.applicationId, structuredClone(record)); }
11
+ async list() { return [...this.records.values()].map(record => structuredClone(record)).sort((a, b) => a.applicationId.localeCompare(b.applicationId)); }
12
+ }
13
+ /** Connects lifecycle commands to the existing authoritative registry boundary. */
14
+ export class ApplicationRegistryLifecycleGateway {
15
+ registry;
16
+ checks;
17
+ constructor(registry, checks = async () => ({ valid: true, reasons: [] })) {
18
+ this.registry = registry;
19
+ this.checks = checks;
20
+ }
21
+ validate(revision) { return this.checks(revision); }
22
+ async register(revision) { const state = await this.registry.registerWithValidation({ identity: revision.manifest.application, manifest: revision.manifest, fingerprint: revision.fingerprint, verification: { ready: true, errors: [], warnings: [], provides: revision.manifest.provides.map(item => ({ name: item.name, version: item.version })), requires: revision.manifest.requires.map(item => ({ name: item.name, version: item.version })), implementations: new Map(revision.manifest.provides.map(item => [`${item.name}@${item.version}`, "bound"])) } }); return { registrationId: state.registrationId }; }
23
+ async promote(revision, registrationId) { const current = await this.registry.get(revision.manifest.application.id); if (!current || current.registrationId !== registrationId)
24
+ throw new Error("Registration incarnation changed before promotion"); await this.registry.activate(current.id); }
25
+ async apply(revision, registrationId) { const current = await this.registry.get(revision.manifest.application.id); if (!current || current.registrationId !== registrationId)
26
+ throw new Error("Registration incarnation changed before applying lifecycle revision"); await this.register(revision); }
27
+ async retire(applicationId, registrationId) { const current = await this.registry.get(applicationId); if (!current || current.registrationId !== registrationId)
28
+ throw new Error("Registration incarnation changed before retirement"); await this.registry.retire(applicationId); }
29
+ promotionChecks(revision) { return this.checks(revision); }
30
+ }
31
+ /** The only command boundary allowed to manufacture authoritative lifecycle facts. */
32
+ export class ApplicationLifecycleOperations {
33
+ store;
34
+ gateway;
35
+ now;
36
+ constructor(store, gateway, now = () => new Date().toISOString()) {
37
+ this.store = store;
38
+ this.gateway = gateway;
39
+ this.now = now;
40
+ }
41
+ async define(manifest) { if (await this.store.get(manifest.application.id))
42
+ throw new Error(`Application "${manifest.application.id}" already exists; propose a change`); const at = this.now(), revision = this.revision(manifest, at); const record = { applicationId: manifest.application.id, phase: "DRAFT", sequence: 1, pendingRevisionId: revision.revisionId, revisions: [revision], validations: [], promotions: [], history: [this.event(1, "DEFINED", undefined, "DRAFT", revision, at)], updatedAt: at }; await this.store.put(record, undefined); return record; }
43
+ async validate(id) { const current = await this.required(id); this.expect(current, ["DRAFT", "CHANGE_PROPOSED"]); const revision = this.pending(current), canonical = fingerprintManifest(revision.manifest), external = await this.gateway.validate(revision), reasons = [...(canonical === revision.fingerprint ? [] : ["Canonical contract fingerprint mismatch"]), ...external.reasons], valid = external.valid && canonical === revision.fingerprint, validation = { validationId: `val_${randomUUID()}`, fingerprint: revision.fingerprint, valid, reasons, validatedAt: this.now() }; return this.advance(current, valid ? "VALIDATED" : current.phase, valid ? "VALIDATED" : "VALIDATION_FAILED", revision, { validations: [...current.validations, validation] }); }
44
+ async register(id) { const current = await this.required(id); this.expect(current, ["VALIDATED"]); if (current.activeRevisionId)
45
+ throw new Error("An active application change must be applied, not registered again"); const revision = this.pending(current), registration = await this.gateway.register(revision); return this.advance(current, "REGISTERED", "REGISTERED", revision, { registrationId: registration.registrationId }); }
46
+ async promote(id) { const current = await this.required(id); this.expect(current, ["REGISTERED"]); return this.activate(current, "PROMOTED"); }
47
+ async proposeChange(id, manifest) { const current = await this.required(id); this.expect(current, ["ACTIVE"]); if (manifest.application.id !== id)
48
+ throw new Error("A change cannot alter application identity"); const revision = this.revision(manifest, this.now()); if (revision.fingerprint === this.active(current).fingerprint)
49
+ throw new Error("Proposed contract is identical to active contract"); return this.advance(current, "CHANGE_PROPOSED", "CHANGE_PROPOSED", revision, { pendingRevisionId: revision.revisionId, revisions: [...current.revisions, revision] }); }
50
+ async applyChange(id) { const current = await this.required(id); this.expect(current, ["VALIDATED"]); if (!current.activeRevisionId || !current.registrationId)
51
+ throw new Error("No active application exists for this change"); const revision = this.pending(current), checks = await this.gateway.promotionChecks(revision); if (!checks.valid)
52
+ throw new Error(`Promotion checks failed: ${checks.reasons.join("; ")}`); await this.gateway.apply(revision, current.registrationId); return this.activate(current, "CHANGE_APPLIED", checks); }
53
+ async retire(id) { const current = await this.required(id); this.expect(current, ["ACTIVE"]); if (!current.registrationId)
54
+ throw new Error("Cannot retire an unregistered application"); await this.gateway.retire(id, current.registrationId); return this.advance(current, "RETIRED", "RETIRED", this.active(current)); }
55
+ get = (id) => this.store.get(id);
56
+ list = () => this.store.list();
57
+ async activate(current, event, checked) { const revision = this.pending(current), checks = checked ?? await this.gateway.promotionChecks(revision); if (!checks.valid)
58
+ throw new Error("Promotion checks failed"); if (!current.registrationId)
59
+ throw new Error("Promotion requires an authoritative registration"); await this.gateway.promote(revision, current.registrationId); const at = this.now(), sequence = current.sequence + 1, revisions = current.revisions.map(item => item.revisionId === revision.revisionId ? { ...item, disposition: "ACTIVE" } : item.disposition === "ACTIVE" ? { ...item, disposition: "SUPERSEDED" } : item), promotion = { promotionId: `promo_${randomUUID()}`, revisionId: revision.revisionId, fingerprint: revision.fingerprint, promotedAt: at }, next = { ...current, phase: "ACTIVE", sequence, activeRevisionId: revision.revisionId, revisions, promotions: [...current.promotions, promotion], history: [...current.history, this.event(sequence, event, current.phase, "ACTIVE", revision, at)], updatedAt: at }; await this.store.put(next, current.sequence); return next; }
60
+ async advance(current, to, type, revision, patch = {}) { const at = this.now(), sequence = current.sequence + 1, next = { ...current, ...patch, phase: to, sequence, history: [...current.history, this.event(sequence, type, current.phase, to, revision, at)], updatedAt: at }; await this.store.put(next, current.sequence); return next; }
61
+ revision(manifest, at) { return { revisionId: `rev_${randomUUID()}`, version: manifest.application.version, fingerprint: fingerprintManifest(manifest), manifest, disposition: "DRAFT", createdAt: at }; }
62
+ event(sequence, type, from, to, revision, at) { return { eventId: `life_${randomUUID()}`, sequence, type, ...(from ? { from } : {}), to, revisionId: revision.revisionId, fingerprint: revision.fingerprint, occurredAt: at }; }
63
+ async required(id) { const value = await this.store.get(id); if (!value)
64
+ throw new Error(`Unknown application "${id}"`); return value; }
65
+ expect(record, phases) { if (!phases.includes(record.phase))
66
+ throw new Error(`Illegal lifecycle operation from ${record.phase}`); }
67
+ pending(record) { return record.revisions.find(item => item.revisionId === record.pendingRevisionId); }
68
+ active(record) { return record.revisions.find(item => item.revisionId === record.activeRevisionId); }
69
+ }
70
+ //# sourceMappingURL=application-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-lifecycle.js","sourceRoot":"","sources":["../src/application-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAA4B,MAAM,eAAe,CAAC;AAW9E,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAAG,YAAY,EAAU,IAAI,KAAK,CAA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AAC,UAAU,KAAK,MAAM,CAAC,iBAAiB,CAAE,CAAC,CAAC,CAAC;IACpI,MAAM,CAAC,MAAkC,IAAI,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,MAAM,CAAC,gBAAgB,CAAE,CAAC,CAAC,CAAC;CAC3I"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Application Source Connections (F6)
3
+ *
4
+ * A source is an external repository that *implements* part of an application
5
+ * AppBoundry already owns. A source connection therefore:
6
+ *
7
+ * - references an applicationId but never creates or redefines it,
8
+ * - attests `appboundry.contract.json` against the authoritative fingerprint,
9
+ * - declares implementation coverage that must be a subset of the contract,
10
+ * - carries its own small lifecycle, distinct from the application lifecycle.
11
+ *
12
+ * Multiple sources per application, and multiple sources per capability, are
13
+ * first-class. None of them is a provider identity.
14
+ */
15
+ import type { AuthoritativeApplicationContract, ContractAttestation } from "./contract-attestation.js";
16
+ import { type RepositorySourceObservation, type SourceVerificationFailure } from "./source-verification.js";
17
+ export type ApplicationSourceStatus = "pending" | "connected" | "stale" | "disconnected" | "failed";
18
+ /** Durable authority record for one repository/source connection. */
19
+ export interface ApplicationSourceConnection {
20
+ readonly id: string;
21
+ readonly applicationId: string;
22
+ readonly sourceType: "repository";
23
+ readonly repositoryIdentity: string;
24
+ readonly ref?: string;
25
+ readonly verifiedCommitSha?: string;
26
+ /** Fingerprint the source attested. Equals the authoritative one when connected. */
27
+ readonly contractFingerprint: string;
28
+ readonly contractRevision?: number;
29
+ /** Contract capabilities this source implements (always a contract subset). */
30
+ readonly coveredCapabilities: readonly string[];
31
+ /** Claims rejected because the contract never declared them. */
32
+ readonly rejectedCapabilities: readonly string[];
33
+ readonly status: ApplicationSourceStatus;
34
+ /** Optimistic-concurrency sequence for durable updates. */
35
+ readonly sequence: number;
36
+ readonly createdAt: string;
37
+ readonly verifiedAt?: string;
38
+ readonly disconnectedAt?: string;
39
+ readonly attestation?: ContractAttestation;
40
+ readonly failures: readonly SourceVerificationFailure[];
41
+ readonly reasons: readonly string[];
42
+ }
43
+ export interface ApplicationSourceStore {
44
+ get(applicationId: string, sourceId: string): Promise<ApplicationSourceConnection | undefined>;
45
+ put(record: ApplicationSourceConnection, expectedSequence?: number): Promise<void>;
46
+ list(applicationId?: string): Promise<ApplicationSourceConnection[]>;
47
+ }
48
+ export declare class ApplicationSourceConflictError extends Error {
49
+ constructor(id: string);
50
+ }
51
+ /** Reference in-memory authority, used where FeltDB is not available. */
52
+ export declare class MemoryApplicationSourceStore implements ApplicationSourceStore {
53
+ #private;
54
+ get(applicationId: string, sourceId: string): Promise<ApplicationSourceConnection | undefined>;
55
+ put(record: ApplicationSourceConnection, expectedSequence?: number): Promise<void>;
56
+ list(applicationId?: string): Promise<ApplicationSourceConnection[]>;
57
+ }
58
+ /**
59
+ * The authoritative contract of a registered application.
60
+ *
61
+ * AppBoundry owns the application identity and its contract; a source may only
62
+ * reference them. A retired application has no authoritative contract, so no
63
+ * source can attest one.
64
+ */
65
+ export declare function registeredApplicationContract(registry: {
66
+ get(applicationId: string): Promise<{
67
+ fingerprint: string;
68
+ manifest: import("./manifest.js").ApplicationManifest;
69
+ status?: string;
70
+ } | undefined>;
71
+ }): AuthoritativeApplicationContract;
72
+ /** A source is executable evidence only while it attests the current contract. */
73
+ export declare function sourceIsEligible(source: ApplicationSourceConnection, authoritativeFingerprint: string): boolean;
74
+ /**
75
+ * Establishes and maintains source connections against durable authority.
76
+ *
77
+ * Every transition is derived from verification evidence; no caller may assert
78
+ * a connected source directly.
79
+ */
80
+ export declare class ApplicationSourceOperations {
81
+ #private;
82
+ private readonly store;
83
+ private readonly authority;
84
+ private readonly now;
85
+ constructor(store: ApplicationSourceStore, authority: AuthoritativeApplicationContract, now?: () => string);
86
+ /** Connect a new source: attest the contract, then derive coverage. */
87
+ connect(applicationId: string, observation: RepositorySourceObservation): Promise<ApplicationSourceConnection>;
88
+ /**
89
+ * Re-attest an existing source, for example after a contract revision.
90
+ *
91
+ * The source identity is immutable: re-attestation may change the ref, the
92
+ * commit, the attested contract and the coverage, never the repository.
93
+ */
94
+ reattest(applicationId: string, sourceId: string, observation: RepositorySourceObservation): Promise<ApplicationSourceConnection>;
95
+ /** Remove a source from implementation eligibility; history stays intact. */
96
+ disconnect(applicationId: string, sourceId: string): Promise<ApplicationSourceConnection>;
97
+ /**
98
+ * Mark attestations of superseded contract revisions stale.
99
+ *
100
+ * A contract revision never silently promotes an old attestation: the source
101
+ * must reconnect/re-attest before it is eligible again.
102
+ */
103
+ refresh(applicationId: string): Promise<ApplicationSourceConnection[]>;
104
+ /** Sources that may currently supply an implementation. */
105
+ eligible(applicationId: string): Promise<ApplicationSourceConnection[]>;
106
+ get: (applicationId: string, sourceId: string) => Promise<ApplicationSourceConnection | undefined>;
107
+ list: (applicationId?: string) => Promise<ApplicationSourceConnection[]>;
108
+ }
109
+ //# sourceMappingURL=application-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-source.d.ts","sourceRoot":"","sources":["../src/application-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,gCAAgC,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAA2B,KAAK,2BAA2B,EAA2B,KAAK,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAE9J,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,cAAc,GAAG,QAAQ,CAAC;AAEpG,qEAAqE;AACrE,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC;IAClC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,Q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AA2D;IACrD,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,EAAE,CAAC;IAK7E,GAAG,GAAI,eAAe,MAAM,EAAE,UAAU,MAAM,sDAA6C;IAC3F,IAAI,GAAI,gBAAgB,MAAM,4CAAoC;CA6CnE"}
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Application Source Connections (F6)
3
+ *
4
+ * A source is an external repository that *implements* part of an application
5
+ * AppBoundry already owns. A source connection therefore:
6
+ *
7
+ * - references an applicationId but never creates or redefines it,
8
+ * - attests `appboundry.contract.json` against the authoritative fingerprint,
9
+ * - declares implementation coverage that must be a subset of the contract,
10
+ * - carries its own small lifecycle, distinct from the application lifecycle.
11
+ *
12
+ * Multiple sources per application, and multiple sources per capability, are
13
+ * first-class. None of them is a provider identity.
14
+ */
15
+ import { randomUUID } from "node:crypto";
16
+ import { verifySourceObservation } from "./source-verification.js";
17
+ export class ApplicationSourceConflictError extends Error {
18
+ constructor(id) {
19
+ super(`Concurrent application source update rejected for "${id}"`);
20
+ this.name = "ApplicationSourceConflictError";
21
+ }
22
+ }
23
+ /** Reference in-memory authority, used where FeltDB is not available. */
24
+ export class MemoryApplicationSourceStore {
25
+ #records = new Map();
26
+ async get(applicationId, sourceId) {
27
+ const found = this.#records.get(`${applicationId}:${sourceId}`);
28
+ return found && structuredClone(found);
29
+ }
30
+ async put(record, expectedSequence) {
31
+ const key = `${record.applicationId}:${record.id}`;
32
+ if (this.#records.get(key)?.sequence !== expectedSequence)
33
+ throw new ApplicationSourceConflictError(record.id);
34
+ this.#records.set(key, structuredClone(record));
35
+ }
36
+ async list(applicationId) {
37
+ return [...this.#records.values()]
38
+ .filter((record) => !applicationId || record.applicationId === applicationId)
39
+ .map((record) => structuredClone(record))
40
+ .sort((left, right) => left.id.localeCompare(right.id));
41
+ }
42
+ }
43
+ /**
44
+ * The authoritative contract of a registered application.
45
+ *
46
+ * AppBoundry owns the application identity and its contract; a source may only
47
+ * reference them. A retired application has no authoritative contract, so no
48
+ * source can attest one.
49
+ */
50
+ export function registeredApplicationContract(registry) {
51
+ return {
52
+ async get(applicationId) {
53
+ const state = await registry.get(applicationId);
54
+ if (!state || state.status === "retired")
55
+ return undefined;
56
+ return { fingerprint: state.fingerprint, manifest: state.manifest };
57
+ }
58
+ };
59
+ }
60
+ /** A source is executable evidence only while it attests the current contract. */
61
+ export function sourceIsEligible(source, authoritativeFingerprint) {
62
+ return source.status === "connected" && source.contractFingerprint === authoritativeFingerprint;
63
+ }
64
+ /**
65
+ * Establishes and maintains source connections against durable authority.
66
+ *
67
+ * Every transition is derived from verification evidence; no caller may assert
68
+ * a connected source directly.
69
+ */
70
+ export class ApplicationSourceOperations {
71
+ store;
72
+ authority;
73
+ now;
74
+ constructor(store, authority, now = () => new Date().toISOString()) {
75
+ this.store = store;
76
+ this.authority = authority;
77
+ this.now = now;
78
+ }
79
+ /** Connect a new source: attest the contract, then derive coverage. */
80
+ async connect(applicationId, observation) {
81
+ const authoritative = await this.#authoritative(applicationId);
82
+ const at = this.now();
83
+ const verification = verifySourceObservation(applicationId, observation, authoritative, at);
84
+ const record = this.#record(`src_${randomUUID()}`, applicationId, verification, 1, at, at);
85
+ await this.store.put(record);
86
+ return record;
87
+ }
88
+ /**
89
+ * Re-attest an existing source, for example after a contract revision.
90
+ *
91
+ * The source identity is immutable: re-attestation may change the ref, the
92
+ * commit, the attested contract and the coverage, never the repository.
93
+ */
94
+ async reattest(applicationId, sourceId, observation) {
95
+ const current = await this.#required(applicationId, sourceId);
96
+ if (current.status === "disconnected")
97
+ throw new Error("A disconnected source must be reconnected as a new source");
98
+ if (current.repositoryIdentity !== observation.repositoryIdentity)
99
+ throw new Error("Re-attestation cannot change source identity");
100
+ const authoritative = await this.#authoritative(applicationId);
101
+ const at = this.now();
102
+ const verification = verifySourceObservation(applicationId, observation, authoritative, at);
103
+ const next = this.#record(sourceId, applicationId, verification, current.sequence + 1, current.createdAt, at);
104
+ await this.store.put(next, current.sequence);
105
+ return next;
106
+ }
107
+ /** Remove a source from implementation eligibility; history stays intact. */
108
+ async disconnect(applicationId, sourceId) {
109
+ const current = await this.#required(applicationId, sourceId);
110
+ if (current.status === "disconnected")
111
+ return current;
112
+ const at = this.now();
113
+ const next = { ...current, status: "disconnected", sequence: current.sequence + 1, disconnectedAt: at };
114
+ await this.store.put(next, current.sequence);
115
+ return next;
116
+ }
117
+ /**
118
+ * Mark attestations of superseded contract revisions stale.
119
+ *
120
+ * A contract revision never silently promotes an old attestation: the source
121
+ * must reconnect/re-attest before it is eligible again.
122
+ */
123
+ async refresh(applicationId) {
124
+ const authoritative = await this.#authoritative(applicationId);
125
+ const refreshed = [];
126
+ for (const source of await this.store.list(applicationId)) {
127
+ if (source.status !== "connected" || source.contractFingerprint === authoritative.fingerprint) {
128
+ refreshed.push(source);
129
+ continue;
130
+ }
131
+ const next = {
132
+ ...source,
133
+ status: "stale",
134
+ sequence: source.sequence + 1,
135
+ reasons: [`CONTRACT_MISMATCH: attested ${source.contractFingerprint} but the authoritative contract is ${authoritative.fingerprint}`]
136
+ };
137
+ await this.store.put(next, source.sequence);
138
+ refreshed.push(next);
139
+ }
140
+ return refreshed;
141
+ }
142
+ /** Sources that may currently supply an implementation. */
143
+ async eligible(applicationId) {
144
+ const authoritative = await this.#authoritative(applicationId);
145
+ return (await this.store.list(applicationId)).filter((source) => sourceIsEligible(source, authoritative.fingerprint));
146
+ }
147
+ get = (applicationId, sourceId) => this.store.get(applicationId, sourceId);
148
+ list = (applicationId) => this.store.list(applicationId);
149
+ #record(id, applicationId, verification, sequence, createdAt, at) {
150
+ const status = verification.verified ? "connected" : "failed";
151
+ return {
152
+ id,
153
+ applicationId,
154
+ sourceType: "repository",
155
+ repositoryIdentity: verification.repositoryIdentity,
156
+ ...(verification.ref ? { ref: verification.ref } : {}),
157
+ ...(verification.verifiedCommitSha ? { verifiedCommitSha: verification.verifiedCommitSha } : {}),
158
+ contractFingerprint: verification.attestation?.observedFingerprint ?? "",
159
+ ...(verification.contract ? { contractRevision: verification.contract.contractRevision } : {}),
160
+ // A source that failed attestation carries no coverage: an unattested
161
+ // repository must never become an eligible implementation.
162
+ coveredCapabilities: verification.verified ? verification.coverage.covered : [],
163
+ rejectedCapabilities: verification.coverage.undeclared,
164
+ status,
165
+ sequence,
166
+ createdAt,
167
+ ...(verification.verified ? { verifiedAt: at } : {}),
168
+ ...(verification.attestation ? { attestation: verification.attestation } : {}),
169
+ failures: verification.failures,
170
+ reasons: verification.reasons
171
+ };
172
+ }
173
+ async #authoritative(applicationId) {
174
+ const authoritative = await this.authority.get(applicationId);
175
+ if (!authoritative)
176
+ throw new Error(`Unknown application "${applicationId}"`);
177
+ return authoritative;
178
+ }
179
+ async #required(applicationId, sourceId) {
180
+ const found = await this.store.get(applicationId, sourceId);
181
+ if (!found)
182
+ throw new Error(`Unknown application source "${sourceId}"`);
183
+ return found;
184
+ }
185
+ }
186
+ //# sourceMappingURL=application-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-source.js","sourceRoot":"","sources":["../src/application-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,uBAAuB,EAA6F,MAAM,0BAA0B,CAAC;AAoC9J,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACvD,YAAY,EAAU;QACpB,KAAK,CAAC,sDAAsD,EAAE,GAAG,CAAC,CAAC;QACnE,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC/C,CAAC;CACF;AAED,yEAAyE;AACzE,MAAM,OAAO,4BAA4B;IAC9B,QAAQ,GAAG,IAAI,GAAG,EAAuC,CAAC;IACnE,KAAK,CAAC,GAAG,CAAC,aAAqB,EAAE,QAAgB;QAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,aAAa,IAAI,QAAQ,EAAE,CAAC,CAAC;QAChE,OAAO,KAAK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