@elaraai/e3-web 0.0.0-stage → 1.0.85

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 (303) hide show
  1. package/LICENSE.md +54 -0
  2. package/README.md +395 -2
  3. package/dist/src/app.d.ts +91 -0
  4. package/dist/src/app.d.ts.map +1 -0
  5. package/dist/src/app.js +112 -0
  6. package/dist/src/app.js.map +1 -0
  7. package/dist/src/bridge/bridge.spec.d.ts +6 -0
  8. package/dist/src/bridge/bridge.spec.d.ts.map +1 -0
  9. package/dist/src/bridge/bridge.spec.js +56 -0
  10. package/dist/src/bridge/bridge.spec.js.map +1 -0
  11. package/dist/src/bridge/page.d.ts +149 -0
  12. package/dist/src/bridge/page.d.ts.map +1 -0
  13. package/dist/src/bridge/page.js +328 -0
  14. package/dist/src/bridge/page.js.map +1 -0
  15. package/dist/src/bridge/protocol.d.ts +181 -0
  16. package/dist/src/bridge/protocol.d.ts.map +1 -0
  17. package/dist/src/bridge/protocol.js +113 -0
  18. package/dist/src/bridge/protocol.js.map +1 -0
  19. package/dist/src/bridge/worker.d.ts +124 -0
  20. package/dist/src/bridge/worker.d.ts.map +1 -0
  21. package/dist/src/bridge/worker.js +185 -0
  22. package/dist/src/bridge/worker.js.map +1 -0
  23. package/dist/src/browser/bridge.page.d.ts +12 -0
  24. package/dist/src/browser/bridge.page.d.ts.map +1 -0
  25. package/dist/src/browser/bridge.page.js +79 -0
  26. package/dist/src/browser/bridge.page.js.map +1 -0
  27. package/dist/src/browser/bridge.spec.d.ts +6 -0
  28. package/dist/src/browser/bridge.spec.d.ts.map +1 -0
  29. package/dist/src/browser/bridge.spec.js +105 -0
  30. package/dist/src/browser/bridge.spec.js.map +1 -0
  31. package/dist/src/browser/bridge.worker.d.ts +6 -0
  32. package/dist/src/browser/bridge.worker.d.ts.map +1 -0
  33. package/dist/src/browser/bridge.worker.js +35 -0
  34. package/dist/src/browser/bridge.worker.js.map +1 -0
  35. package/dist/src/browser/compliance.d.ts +68 -0
  36. package/dist/src/browser/compliance.d.ts.map +1 -0
  37. package/dist/src/browser/compliance.js +30 -0
  38. package/dist/src/browser/compliance.js.map +1 -0
  39. package/dist/src/browser/compliance.page.d.ts +6 -0
  40. package/dist/src/browser/compliance.page.d.ts.map +1 -0
  41. package/dist/src/browser/compliance.page.js +204 -0
  42. package/dist/src/browser/compliance.page.js.map +1 -0
  43. package/dist/src/browser/compliance.spec.d.ts +6 -0
  44. package/dist/src/browser/compliance.spec.d.ts.map +1 -0
  45. package/dist/src/browser/compliance.spec.js +147 -0
  46. package/dist/src/browser/compliance.spec.js.map +1 -0
  47. package/dist/src/browser/e3-api-1.spec.d.ts +6 -0
  48. package/dist/src/browser/e3-api-1.spec.d.ts.map +1 -0
  49. package/dist/src/browser/e3-api-1.spec.js +12 -0
  50. package/dist/src/browser/e3-api-1.spec.js.map +1 -0
  51. package/dist/src/browser/e3-api-2.spec.d.ts +6 -0
  52. package/dist/src/browser/e3-api-2.spec.d.ts.map +1 -0
  53. package/dist/src/browser/e3-api-2.spec.js +12 -0
  54. package/dist/src/browser/e3-api-2.spec.js.map +1 -0
  55. package/dist/src/browser/e3-api-3.spec.d.ts +6 -0
  56. package/dist/src/browser/e3-api-3.spec.d.ts.map +1 -0
  57. package/dist/src/browser/e3-api-3.spec.js +12 -0
  58. package/dist/src/browser/e3-api-3.spec.js.map +1 -0
  59. package/dist/src/browser/e3-api-parts.spec.d.ts +6 -0
  60. package/dist/src/browser/e3-api-parts.spec.d.ts.map +1 -0
  61. package/dist/src/browser/e3-api-parts.spec.js +45 -0
  62. package/dist/src/browser/e3-api-parts.spec.js.map +1 -0
  63. package/dist/src/browser/e3-api.d.ts +28 -0
  64. package/dist/src/browser/e3-api.d.ts.map +1 -0
  65. package/dist/src/browser/e3-api.js +144 -0
  66. package/dist/src/browser/e3-api.js.map +1 -0
  67. package/dist/src/browser/e3-client.worker.d.ts +6 -0
  68. package/dist/src/browser/e3-client.worker.d.ts.map +1 -0
  69. package/dist/src/browser/e3-client.worker.js +19 -0
  70. package/dist/src/browser/e3-client.worker.js.map +1 -0
  71. package/dist/src/browser/e3-forward.d.ts +27 -0
  72. package/dist/src/browser/e3-forward.d.ts.map +1 -0
  73. package/dist/src/browser/e3-forward.js +81 -0
  74. package/dist/src/browser/e3-forward.js.map +1 -0
  75. package/dist/src/browser/e3-forward.spec.d.ts +6 -0
  76. package/dist/src/browser/e3-forward.spec.d.ts.map +1 -0
  77. package/dist/src/browser/e3-forward.spec.js +84 -0
  78. package/dist/src/browser/e3-forward.spec.js.map +1 -0
  79. package/dist/src/browser/e3-port.worker.d.ts +6 -0
  80. package/dist/src/browser/e3-port.worker.d.ts.map +1 -0
  81. package/dist/src/browser/e3-port.worker.js +21 -0
  82. package/dist/src/browser/e3-port.worker.js.map +1 -0
  83. package/dist/src/browser/e3-unit.worker.d.ts +6 -0
  84. package/dist/src/browser/e3-unit.worker.d.ts.map +1 -0
  85. package/dist/src/browser/e3-unit.worker.js +18 -0
  86. package/dist/src/browser/e3-unit.worker.js.map +1 -0
  87. package/dist/src/browser/e3-wire.d.ts +43 -0
  88. package/dist/src/browser/e3-wire.d.ts.map +1 -0
  89. package/dist/src/browser/e3-wire.js +32 -0
  90. package/dist/src/browser/e3-wire.js.map +1 -0
  91. package/dist/src/browser/e3.page.d.ts +21 -0
  92. package/dist/src/browser/e3.page.d.ts.map +1 -0
  93. package/dist/src/browser/e3.page.js +119 -0
  94. package/dist/src/browser/e3.page.js.map +1 -0
  95. package/dist/src/browser/e3.spec.d.ts +6 -0
  96. package/dist/src/browser/e3.spec.d.ts.map +1 -0
  97. package/dist/src/browser/e3.spec.js +358 -0
  98. package/dist/src/browser/e3.spec.js.map +1 -0
  99. package/dist/src/browser/e3.worker.d.ts +6 -0
  100. package/dist/src/browser/e3.worker.d.ts.map +1 -0
  101. package/dist/src/browser/e3.worker.js +38 -0
  102. package/dist/src/browser/e3.worker.js.map +1 -0
  103. package/dist/src/browser/harness.d.ts +175 -0
  104. package/dist/src/browser/harness.d.ts.map +1 -0
  105. package/dist/src/browser/harness.js +375 -0
  106. package/dist/src/browser/harness.js.map +1 -0
  107. package/dist/src/browser/page.d.ts +47 -0
  108. package/dist/src/browser/page.d.ts.map +1 -0
  109. package/dist/src/browser/page.js +47 -0
  110. package/dist/src/browser/page.js.map +1 -0
  111. package/dist/src/browser/repository.page.d.ts +85 -0
  112. package/dist/src/browser/repository.page.d.ts.map +1 -0
  113. package/dist/src/browser/repository.page.js +271 -0
  114. package/dist/src/browser/repository.page.js.map +1 -0
  115. package/dist/src/browser/runner.page.d.ts +6 -0
  116. package/dist/src/browser/runner.page.d.ts.map +1 -0
  117. package/dist/src/browser/runner.page.js +62 -0
  118. package/dist/src/browser/runner.page.js.map +1 -0
  119. package/dist/src/browser/runner.spec.d.ts +6 -0
  120. package/dist/src/browser/runner.spec.d.ts.map +1 -0
  121. package/dist/src/browser/runner.spec.js +46 -0
  122. package/dist/src/browser/runner.spec.js.map +1 -0
  123. package/dist/src/browser/storage.page.d.ts +6 -0
  124. package/dist/src/browser/storage.page.d.ts.map +1 -0
  125. package/dist/src/browser/storage.page.js +289 -0
  126. package/dist/src/browser/storage.page.js.map +1 -0
  127. package/dist/src/browser/storage.spec.d.ts +6 -0
  128. package/dist/src/browser/storage.spec.d.ts.map +1 -0
  129. package/dist/src/browser/storage.spec.js +211 -0
  130. package/dist/src/browser/storage.spec.js.map +1 -0
  131. package/dist/src/browser/unit.worker.d.ts +6 -0
  132. package/dist/src/browser/unit.worker.d.ts.map +1 -0
  133. package/dist/src/browser/unit.worker.js +17 -0
  134. package/dist/src/browser/unit.worker.js.map +1 -0
  135. package/dist/src/execution/WebTaskRunner.d.ts +159 -0
  136. package/dist/src/execution/WebTaskRunner.d.ts.map +1 -0
  137. package/dist/src/execution/WebTaskRunner.js +581 -0
  138. package/dist/src/execution/WebTaskRunner.js.map +1 -0
  139. package/dist/src/execution/WebTaskRunner.spec.d.ts +6 -0
  140. package/dist/src/execution/WebTaskRunner.spec.d.ts.map +1 -0
  141. package/dist/src/execution/WebTaskRunner.spec.js +91 -0
  142. package/dist/src/execution/WebTaskRunner.spec.js.map +1 -0
  143. package/dist/src/execution/e3-platform.d.ts +41 -0
  144. package/dist/src/execution/e3-platform.d.ts.map +1 -0
  145. package/dist/src/execution/e3-platform.js +52 -0
  146. package/dist/src/execution/e3-platform.js.map +1 -0
  147. package/dist/src/execution/in-process.d.ts +32 -0
  148. package/dist/src/execution/in-process.d.ts.map +1 -0
  149. package/dist/src/execution/in-process.js +89 -0
  150. package/dist/src/execution/in-process.js.map +1 -0
  151. package/dist/src/execution/pool.d.ts +172 -0
  152. package/dist/src/execution/pool.d.ts.map +1 -0
  153. package/dist/src/execution/pool.js +352 -0
  154. package/dist/src/execution/pool.js.map +1 -0
  155. package/dist/src/execution/pool.spec.d.ts +6 -0
  156. package/dist/src/execution/pool.spec.d.ts.map +1 -0
  157. package/dist/src/execution/pool.spec.js +252 -0
  158. package/dist/src/execution/pool.spec.js.map +1 -0
  159. package/dist/src/execution/protocol.d.ts +108 -0
  160. package/dist/src/execution/protocol.d.ts.map +1 -0
  161. package/dist/src/execution/protocol.js +27 -0
  162. package/dist/src/execution/protocol.js.map +1 -0
  163. package/dist/src/execution/unit-server.d.ts +131 -0
  164. package/dist/src/execution/unit-server.d.ts.map +1 -0
  165. package/dist/src/execution/unit-server.js +142 -0
  166. package/dist/src/execution/unit-server.js.map +1 -0
  167. package/dist/src/index.d.ts +39 -0
  168. package/dist/src/index.d.ts.map +1 -0
  169. package/dist/src/index.js +37 -0
  170. package/dist/src/index.js.map +1 -0
  171. package/dist/src/index.spec.d.ts +6 -0
  172. package/dist/src/index.spec.d.ts.map +1 -0
  173. package/dist/src/index.spec.js +212 -0
  174. package/dist/src/index.spec.js.map +1 -0
  175. package/dist/src/node.d.ts +12 -0
  176. package/dist/src/node.d.ts.map +1 -0
  177. package/dist/src/node.js +12 -0
  178. package/dist/src/node.js.map +1 -0
  179. package/dist/src/storage/WebStateStore.d.ts +64 -0
  180. package/dist/src/storage/WebStateStore.d.ts.map +1 -0
  181. package/dist/src/storage/WebStateStore.js +237 -0
  182. package/dist/src/storage/WebStateStore.js.map +1 -0
  183. package/dist/src/storage/WebStorage.d.ts +225 -0
  184. package/dist/src/storage/WebStorage.d.ts.map +1 -0
  185. package/dist/src/storage/WebStorage.js +1462 -0
  186. package/dist/src/storage/WebStorage.js.map +1 -0
  187. package/dist/src/storage/adapters.d.ts +610 -0
  188. package/dist/src/storage/adapters.d.ts.map +1 -0
  189. package/dist/src/storage/adapters.js +246 -0
  190. package/dist/src/storage/adapters.js.map +1 -0
  191. package/dist/src/storage/indexeddb.d.ts +93 -0
  192. package/dist/src/storage/indexeddb.d.ts.map +1 -0
  193. package/dist/src/storage/indexeddb.js +384 -0
  194. package/dist/src/storage/indexeddb.js.map +1 -0
  195. package/dist/src/storage/indexeddb.spec.d.ts +6 -0
  196. package/dist/src/storage/indexeddb.spec.d.ts.map +1 -0
  197. package/dist/src/storage/indexeddb.spec.js +77 -0
  198. package/dist/src/storage/indexeddb.spec.js.map +1 -0
  199. package/dist/src/storage/memory.d.ts +275 -0
  200. package/dist/src/storage/memory.d.ts.map +1 -0
  201. package/dist/src/storage/memory.js +724 -0
  202. package/dist/src/storage/memory.js.map +1 -0
  203. package/dist/src/storage/memory.spec.d.ts +6 -0
  204. package/dist/src/storage/memory.spec.d.ts.map +1 -0
  205. package/dist/src/storage/memory.spec.js +71 -0
  206. package/dist/src/storage/memory.spec.js.map +1 -0
  207. package/dist/src/storage/node-files.d.ts +38 -0
  208. package/dist/src/storage/node-files.d.ts.map +1 -0
  209. package/dist/src/storage/node-files.js +148 -0
  210. package/dist/src/storage/node-files.js.map +1 -0
  211. package/dist/src/storage/node-files.spec.d.ts +6 -0
  212. package/dist/src/storage/node-files.spec.d.ts.map +1 -0
  213. package/dist/src/storage/node-files.spec.js +40 -0
  214. package/dist/src/storage/node-files.spec.js.map +1 -0
  215. package/dist/src/storage/opfs.d.ts +145 -0
  216. package/dist/src/storage/opfs.d.ts.map +1 -0
  217. package/dist/src/storage/opfs.js +514 -0
  218. package/dist/src/storage/opfs.js.map +1 -0
  219. package/dist/src/storage/opfs.spec.d.ts +6 -0
  220. package/dist/src/storage/opfs.spec.d.ts.map +1 -0
  221. package/dist/src/storage/opfs.spec.js +51 -0
  222. package/dist/src/storage/opfs.spec.js.map +1 -0
  223. package/dist/src/storage/record-keys.d.ts +78 -0
  224. package/dist/src/storage/record-keys.d.ts.map +1 -0
  225. package/dist/src/storage/record-keys.js +71 -0
  226. package/dist/src/storage/record-keys.js.map +1 -0
  227. package/dist/src/storage/stores.spec.d.ts +6 -0
  228. package/dist/src/storage/stores.spec.d.ts.map +1 -0
  229. package/dist/src/storage/stores.spec.js +326 -0
  230. package/dist/src/storage/stores.spec.js.map +1 -0
  231. package/dist/src/storage/web-locks.d.ts +103 -0
  232. package/dist/src/storage/web-locks.d.ts.map +1 -0
  233. package/dist/src/storage/web-locks.js +228 -0
  234. package/dist/src/storage/web-locks.js.map +1 -0
  235. package/dist/src/testing/adapter-contract.d.ts +116 -0
  236. package/dist/src/testing/adapter-contract.d.ts.map +1 -0
  237. package/dist/src/testing/adapter-contract.js +769 -0
  238. package/dist/src/testing/adapter-contract.js.map +1 -0
  239. package/dist/src/testing/assert.d.ts +75 -0
  240. package/dist/src/testing/assert.d.ts.map +1 -0
  241. package/dist/src/testing/assert.js +146 -0
  242. package/dist/src/testing/assert.js.map +1 -0
  243. package/dist/src/testing/assert.spec.d.ts +6 -0
  244. package/dist/src/testing/assert.spec.d.ts.map +1 -0
  245. package/dist/src/testing/assert.spec.js +62 -0
  246. package/dist/src/testing/assert.spec.js.map +1 -0
  247. package/dist/src/testing/bridge-contract.d.ts +55 -0
  248. package/dist/src/testing/bridge-contract.d.ts.map +1 -0
  249. package/dist/src/testing/bridge-contract.js +376 -0
  250. package/dist/src/testing/bridge-contract.js.map +1 -0
  251. package/dist/src/testing/bridge-handler.d.ts +35 -0
  252. package/dist/src/testing/bridge-handler.d.ts.map +1 -0
  253. package/dist/src/testing/bridge-handler.js +108 -0
  254. package/dist/src/testing/bridge-handler.js.map +1 -0
  255. package/dist/src/testing/callers.d.ts +29 -0
  256. package/dist/src/testing/callers.d.ts.map +1 -0
  257. package/dist/src/testing/callers.js +24 -0
  258. package/dist/src/testing/callers.js.map +1 -0
  259. package/dist/src/testing/e3-fixtures.d.ts +38 -0
  260. package/dist/src/testing/e3-fixtures.d.ts.map +1 -0
  261. package/dist/src/testing/e3-fixtures.js +126 -0
  262. package/dist/src/testing/e3-fixtures.js.map +1 -0
  263. package/dist/src/testing/hold-platform.d.ts +33 -0
  264. package/dist/src/testing/hold-platform.d.ts.map +1 -0
  265. package/dist/src/testing/hold-platform.js +41 -0
  266. package/dist/src/testing/hold-platform.js.map +1 -0
  267. package/dist/src/testing/runner-cases.d.ts +112 -0
  268. package/dist/src/testing/runner-cases.d.ts.map +1 -0
  269. package/dist/src/testing/runner-cases.js +959 -0
  270. package/dist/src/testing/runner-cases.js.map +1 -0
  271. package/dist/src/testing/runner-fixtures.d.ts +13 -0
  272. package/dist/src/testing/runner-fixtures.d.ts.map +1 -0
  273. package/dist/src/testing/runner-fixtures.js +173 -0
  274. package/dist/src/testing/runner-fixtures.js.map +1 -0
  275. package/dist/src/testing/test-platform.d.ts +73 -0
  276. package/dist/src/testing/test-platform.d.ts.map +1 -0
  277. package/dist/src/testing/test-platform.js +143 -0
  278. package/dist/src/testing/test-platform.js.map +1 -0
  279. package/dist/src/transfer/WebTransferBackend.d.ts +780 -0
  280. package/dist/src/transfer/WebTransferBackend.d.ts.map +1 -0
  281. package/dist/src/transfer/WebTransferBackend.js +1140 -0
  282. package/dist/src/transfer/WebTransferBackend.js.map +1 -0
  283. package/dist/src/transfer/WebTransferBackend.spec.d.ts +6 -0
  284. package/dist/src/transfer/WebTransferBackend.spec.d.ts.map +1 -0
  285. package/dist/src/transfer/WebTransferBackend.spec.js +582 -0
  286. package/dist/src/transfer/WebTransferBackend.spec.js.map +1 -0
  287. package/dist/src/transfer/endpoints.d.ts +46 -0
  288. package/dist/src/transfer/endpoints.d.ts.map +1 -0
  289. package/dist/src/transfer/endpoints.js +157 -0
  290. package/dist/src/transfer/endpoints.js.map +1 -0
  291. package/dist/src/units.d.ts +51 -0
  292. package/dist/src/units.d.ts.map +1 -0
  293. package/dist/src/units.js +74 -0
  294. package/dist/src/units.js.map +1 -0
  295. package/dist/src/worker.d.ts +126 -0
  296. package/dist/src/worker.d.ts.map +1 -0
  297. package/dist/src/worker.js +186 -0
  298. package/dist/src/worker.js.map +1 -0
  299. package/dist/src/worker.spec.d.ts +6 -0
  300. package/dist/src/worker.spec.d.ts.map +1 -0
  301. package/dist/src/worker.spec.js +195 -0
  302. package/dist/src/worker.spec.js.map +1 -0
  303. package/package.json +76 -3
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * e3's API in the e3 worker: {@link createWebApp}, the Hono app `serveE3`
7
+ * answers `e3.fetch` with. It mounts every route factory of e3-api-server's
8
+ * portable entry in multi-repository mode, in the order the local server
9
+ * mounts them, over e3-web's seams, beside e3-web's own byte endpoints.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import { Hono } from 'hono';
14
+ import { checkName } from '@elaraai/e3-core/portable';
15
+ import { createDatasetRoutes, createExecutionRoutes, createObjectRoutes, createOneShotRoutes, createPackageFunctionRoutes, createPackageRoutes, createPackageTransferRoutes, createRepositoriesRoutes, createRepositoryGate, createRepositoryRoutes, createTaskRoutes, createTransferRoutes, createWorkspaceFunctionRoutes, createWorkspaceRecordRoutes, createWorkspaceRoutes, } from '@elaraai/e3-api-server/portable';
16
+ import { createWebDataEndpoints } from './transfer/endpoints.js';
17
+ /**
18
+ * The repository a request names, as WebStorage's stores take it: its name,
19
+ * once it is one.
20
+ *
21
+ * @throws {Error} When the name is not a repository's name: a path, say
22
+ */
23
+ function repositoryOf(repo) {
24
+ checkName('repository', repo);
25
+ return repo;
26
+ }
27
+ /**
28
+ * Creates e3's API over e3-web's seams.
29
+ *
30
+ * @remarks
31
+ * The routes are e3-api-server's own, mounted as the local server mounts them
32
+ * over many repositories, so an e3 in a page answers every request as the
33
+ * local server does:
34
+ * - e3-web's byte endpoints, at `/api/uploads` and `/api/downloads`, ahead of
35
+ * any identity: their URLs are capabilities;
36
+ * - who calls ({@link WebAppSeams.identify}), set on each request to a
37
+ * repository, and a caller it does not know answered 401;
38
+ * - the gate every request to a repository passes, which applies the
39
+ * upgrades it owes in the request, as an in-page request has no time
40
+ * limit; and the repositories' own routes;
41
+ * - a repository's status, gc, packages and their transfer, workspaces,
42
+ * datasets and their transfer, tasks, functions and one-shot with its split
43
+ * calls under the host's `access`, records, the dataflow, and objects.
44
+ *
45
+ * @param seams - The storage, transfers, runners, orchestrator and state
46
+ * store the routes run over, and who may run what
47
+ * @returns The app, whose `fetch` answers each request
48
+ */
49
+ export function createWebApp(seams) {
50
+ const { storage, transfer, getRunner, orchestrator, stateStore, width, access, identify, commitWaitMs } = seams;
51
+ const app = new Hono();
52
+ // The byte endpoints: the transfer's id in their URL is their capability,
53
+ // so they are answered ahead of who calls, as the local server's are.
54
+ const data = createWebDataEndpoints(transfer, storage);
55
+ app.route('/api/uploads', data.uploads);
56
+ app.route('/api/downloads', data.downloads);
57
+ // Who calls, set where a server's auth sets it: a caller it does not know
58
+ // is answered as e3-api-server's auth middleware answers one.
59
+ if (identify !== undefined) {
60
+ app.use('/api/repos/:repo/*', async (c, next) => {
61
+ let identity;
62
+ try {
63
+ identity = await identify(c.req.raw);
64
+ }
65
+ catch (err) {
66
+ return new Response(`Unauthorized: ${err instanceof Error ? err.message : 'Invalid token'}`, { status: 401 });
67
+ }
68
+ if (identity === null || identity === undefined) {
69
+ const bearer = c.req.header('authorization')?.startsWith('Bearer ') === true;
70
+ return new Response(bearer ? 'Unauthorized: Invalid token' : 'Unauthorized: Missing Bearer token', { status: 401 });
71
+ }
72
+ c.set('identity', identity);
73
+ await next();
74
+ });
75
+ }
76
+ // The repositories, and the gate every request to one passes.
77
+ app.use('/api/repos/:repo/*', createRepositoryGate(storage, repositoryOf));
78
+ app.route('/api/repos', createRepositoriesRoutes(storage));
79
+ // A repository's status, record and gc.
80
+ app.route('/api/repos/:repo', createRepositoryRoutes(storage, repositoryOf, transfer));
81
+ // Packages, and their import and export as jobs.
82
+ const packageTransfer = createPackageTransferRoutes(storage, repositoryOf, transfer);
83
+ app.route('/api/repos/:repo', packageTransfer.repoApi);
84
+ app.route('/api/repos/:repo/packages', packageTransfer.pkgApi);
85
+ app.route('/api/repos/:repo/packages', createPackageRoutes(storage, repositoryOf));
86
+ app.route('/api/repos/:repo/packages/:pkg/:version/functions', createPackageFunctionRoutes(storage, repositoryOf, getRunner, { access }));
87
+ // Workspaces, and their deploys and exports as jobs.
88
+ app.route('/api/repos/:repo/workspaces', createWorkspaceRoutes(storage, repositoryOf, transfer, getRunner));
89
+ // Datasets, and their uploads.
90
+ const datasetTransfer = createTransferRoutes(storage, repositoryOf, transfer, {
91
+ ...(commitWaitMs !== undefined && { commitWaitMs }),
92
+ });
93
+ app.route('/api/repos/:repo/workspaces/:ws/datasets', datasetTransfer.api);
94
+ app.route('/api/repos/:repo/workspaces/:ws/datasets', createDatasetRoutes(storage, repositoryOf, transfer));
95
+ // Tasks, functions, one-shot and its split calls, and records.
96
+ app.route('/api/repos/:repo/workspaces/:ws/tasks', createTaskRoutes(storage, repositoryOf));
97
+ app.route('/api/repos/:repo/workspaces/:ws/functions', createWorkspaceFunctionRoutes(storage, repositoryOf, getRunner, { access }));
98
+ app.route('/api/repos/:repo/workspaces/:ws/one-shot', createOneShotRoutes(storage, repositoryOf, transfer, getRunner, { access }));
99
+ app.route('/api/repos/:repo/workspaces/:ws/records', createWorkspaceRecordRoutes(storage, repositoryOf, getRunner));
100
+ // The dataflow: run, polled and cancelled through the orchestrator, whose
101
+ // runs keep their state in the store.
102
+ app.route('/api/repos/:repo/workspaces/:ws/dataflow', createExecutionRoutes(storage, repositoryOf, {
103
+ getRunner,
104
+ getOrchestrator: () => orchestrator,
105
+ getStateStore: () => stateStore,
106
+ width,
107
+ }));
108
+ // Objects by hash: a large one is answered by download URL.
109
+ app.route('/api/repos/:repo/objects', createObjectRoutes(storage, repositoryOf, transfer));
110
+ return app;
111
+ }
112
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=bridge.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.spec.d.ts","sourceRoot":"","sources":["../../../src/bridge/bridge.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * `e3.fetch` over a `MessageChannel`, held to its contract: the page's side
7
+ * (`createWebE3`) at one port and the worker's side (`serveBridge`) at the
8
+ * other, in process, the worker answering with the contract's plain handler.
9
+ * The Chromium spec (`browser/bridge.spec.ts`) holds a dedicated worker to the
10
+ * same contract.
11
+ */
12
+ import { describe, it } from 'node:test';
13
+ import { randomUUID } from 'node:crypto';
14
+ import { openWebStorage } from '../storage/WebStorage.js';
15
+ import { runAdapterCase } from '../testing/adapter-contract.js';
16
+ import { bridgeContract, recordPosts } from '../testing/bridge-contract.js';
17
+ import { contractBoot, contractWorker } from '../testing/bridge-handler.js';
18
+ import { serveBridge } from './worker.js';
19
+ const setup = (cleanup) => Promise.resolve({
20
+ // Node has no IndexedDB: openWebStorage refuses it, as a browser without one.
21
+ missing: 'IndexedDB',
22
+ start: (boot) => {
23
+ const { port1, port2 } = new MessageChannel();
24
+ const worker = contractWorker(port2);
25
+ serveBridge(contractBoot(boot, worker, async () => {
26
+ await (await openWebStorage({ name: `e3-web-bridge-${randomUUID()}` })).close();
27
+ }), worker.endpoint);
28
+ // Closing one port closes the channel, and both its ports.
29
+ cleanup(() => port1.close());
30
+ return { endpoint: port1, posted: recordPosts(port1), kill: () => port2.close() };
31
+ },
32
+ persistAsks: () => {
33
+ // Node has no storage manager: one in its place grants each ask, as a
34
+ // browser that keeps the origin's storage does.
35
+ const answers = [];
36
+ Object.defineProperty(navigator, 'storage', {
37
+ configurable: true,
38
+ value: {
39
+ persist: () => {
40
+ answers.push(true);
41
+ return Promise.resolve(true);
42
+ },
43
+ persisted: () => Promise.resolve(answers.length > 0),
44
+ },
45
+ });
46
+ cleanup(() => {
47
+ Reflect.deleteProperty(navigator, 'storage');
48
+ });
49
+ return answers;
50
+ },
51
+ });
52
+ describe('e3.fetch over a MessageChannel', () => {
53
+ for (const bridgeCase of bridgeContract)
54
+ it(bridgeCase.name, () => runAdapterCase(bridgeCase, setup));
55
+ });
56
+ //# sourceMappingURL=bridge.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.spec.js","sourceRoot":"","sources":["../../../src/bridge/bridge.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAqB,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,WAAW,EAAoB,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,KAAK,GAA8B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;IACpE,8EAA8E;IAC9E,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;QACd,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,cAAc,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QACrC,WAAW,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,CAAC,MAAM,cAAc,CAAC,EAAE,IAAI,EAAE,iBAAiB,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;QAClF,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QACrB,2DAA2D;QAC3D,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC7B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;IACpF,CAAC;IACD,WAAW,EAAE,GAAG,EAAE;QAChB,sEAAsE;QACtE,gDAAgD;QAChD,MAAM,OAAO,GAAc,EAAE,CAAC;QAC9B,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE;YAC1C,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE;gBACL,OAAO,EAAE,GAAG,EAAE;oBACZ,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACnB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC/B,CAAC;gBACD,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;aACrD;SACF,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,EAAE;YACX,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC,CAAC;AAEH,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,KAAK,MAAM,UAAU,IAAI,cAAc;QAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;AACxG,CAAC,CAAC,CAAC"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * The e3 a page runs in its e3 worker: the URL and the `fetch` e3's client and
7
+ * e3-ui-components are given, so every request they make is answered by the
8
+ * worker, in the page.
9
+ */
10
+ export interface WebE3 {
11
+ /**
12
+ * `https://e3-web.invalid`: the URL e3's client and e3-ui-components are
13
+ * given, which only {@link WebE3.fetch} answers. Its origin is reserved, so
14
+ * a request that bypasses `e3.fetch` fails at once rather than reaching the
15
+ * network.
16
+ */
17
+ readonly apiUrl: string;
18
+ /**
19
+ * Answers a request in the e3 worker, with the global `fetch`'s signature:
20
+ * the `fetch` of e3-api-client's `RequestOptions` and e3-ui-components'
21
+ * `E3Config`.
22
+ *
23
+ * @remarks
24
+ * - It posts the request's method, URL, every header and its body to the
25
+ * worker, and resolves to a `Response` made of the worker's answer. Each
26
+ * body crosses whole, as an `ArrayBuffer` transferred rather than copied;
27
+ * the caller's own body is copied once, as `fetch` copies it, and never
28
+ * taken from it.
29
+ * - It answers only {@link WebE3.apiUrl}'s origin: a request to any other
30
+ * is refused with a `TypeError` naming that origin, and nothing is posted.
31
+ * - The request's signal aborts it: the promise rejects with the signal's
32
+ * reason, an `AbortError` unless the caller gave another, and the signal
33
+ * of the `Request` the worker's handler was given aborts.
34
+ * - A request the worker answers with no response — its handler threw —
35
+ * rejects with a `TypeError` carrying what failed, as `fetch` rejects a
36
+ * network failure. An error the app answers with a response, a 500 say,
37
+ * resolves to that response.
38
+ * - Once the worker has stopped, failed or been closed, every request
39
+ * pending rejects with a `TypeError` saying which, and every later one is
40
+ * refused with it.
41
+ * - It follows no redirect: a redirect the worker answers is the response.
42
+ */
43
+ readonly fetch: typeof globalThis.fetch;
44
+ /**
45
+ * Whether the browser keeps the worker's repositories through storage
46
+ * pressure, rather than evicting them as it may evict an origin's storage
47
+ * that is not persisted.
48
+ *
49
+ * @remarks
50
+ * When the worker keeps repositories past the page, `createWebE3` asks
51
+ * `navigator.storage.persist()` — only a page can ask it — and this is the
52
+ * answer. With `requestPersistence: false` it does not ask, and this is
53
+ * `navigator.storage.persisted()`'s answer. A worker that keeps nothing past
54
+ * the page is never persisted, and a browser that has no storage manager,
55
+ * or refuses the question, is taken to keep nothing.
56
+ */
57
+ readonly persisted: boolean;
58
+ /**
59
+ * Closes the e3 worker: terminates it, or, over a port, tells the e3 at its
60
+ * other end that the page has closed — which closes it — and closes the
61
+ * port. Every request pending rejects with a `TypeError` naming the close,
62
+ * and every later one is refused with it. Closing it again does nothing.
63
+ */
64
+ close(): void;
65
+ }
66
+ /**
67
+ * How {@link createWebE3} connects.
68
+ */
69
+ export interface WebE3Options {
70
+ /**
71
+ * Whether to ask the browser to keep the worker's repositories through
72
+ * storage pressure (`navigator.storage.persist()`), when the worker keeps
73
+ * them: `true` unless given. An app that asks at a moment of its own
74
+ * choosing gives `false` — Firefox asks its user, and `createWebE3` would
75
+ * wait on the answer.
76
+ */
77
+ readonly requestPersistence?: boolean;
78
+ }
79
+ /**
80
+ * How a connection is made: {@link WebE3Options}, and whether the page holds
81
+ * a lifeline over a port.
82
+ *
83
+ * @internal
84
+ */
85
+ export interface ConnectOptions extends WebE3Options {
86
+ /**
87
+ * Whether the page, connecting over a port, holds a lifeline the e3 at the
88
+ * other end waits on to learn the page has gone: `true` unless given. A unit
89
+ * worker's connection to its e3 worker holds none: the pool that started
90
+ * the unit worker ends the e3's side as it lets the worker go.
91
+ */
92
+ readonly lifeline?: boolean;
93
+ }
94
+ /**
95
+ * Connects a page to its e3 worker, once the worker has booted.
96
+ *
97
+ * The worker runs e3 itself — its storage, its runner and its API — and this
98
+ * gives the page {@link WebE3.fetch}, which the worker answers, and
99
+ * {@link WebE3.apiUrl}, the URL e3's client and e3-ui-components are given
100
+ * with it. No request reaches the network.
101
+ *
102
+ * @param worker - The e3 worker: a dedicated worker running e3, or a port to
103
+ * one. It is the connection's from now on, and {@link WebE3.close} closes it
104
+ * @param options - Whether to ask the browser to keep the repositories
105
+ * @returns The e3, once the worker says it is ready
106
+ *
107
+ * @throws {Error} When the worker does not start: its boot failed — a
108
+ * browser API it needs is missing, say, which the message names — or it
109
+ * failed or stopped before it was ready. The worker is closed.
110
+ *
111
+ * @remarks
112
+ * - The page says hello, and the worker answers whether it is ready, and
113
+ * whether it keeps repositories past the page, however long ago it booted:
114
+ * a page may connect at any time. When it keeps them, the page asks the
115
+ * browser to keep them ({@link WebE3.persisted}).
116
+ * - The page learns that the worker has stopped — terminated by other code,
117
+ * or closed by itself, which no event tells it — through a Web Lock the
118
+ * worker holds while it lives; an `error` or `messageerror` event of the
119
+ * worker, or its port's closing, ends the connection too. Each fails every
120
+ * request pending, naming what happened, and refuses every later one.
121
+ * - Over a port, the page holds a Web Lock of its own while it is connected,
122
+ * which the e3 at the other end waits on: the e3 closes once the page has
123
+ * gone — its tab closed — as it does when {@link WebE3.close} tells it.
124
+ * - A body crosses between the page and the worker whole, as an
125
+ * `ArrayBuffer` transferred rather than copied.
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * import { createWebE3 } from '@elaraai/e3-web';
130
+ * import { repoList } from '@elaraai/e3-api-client';
131
+ *
132
+ * const e3 = await createWebE3(new Worker(new URL('./e3.worker.ts', import.meta.url), { type: 'module' }));
133
+ * const repos = await repoList(e3.apiUrl, { token: null, fetch: e3.fetch });
134
+ * ```
135
+ */
136
+ export declare function createWebE3(worker: Worker | MessagePort, options?: WebE3Options): Promise<WebE3>;
137
+ /**
138
+ * Connects to an e3 worker: {@link createWebE3}, with whether the page holds
139
+ * a lifeline over a port.
140
+ *
141
+ * @param worker - The e3 worker, or a port to one
142
+ * @param options - Whether to ask the browser to keep the repositories, and
143
+ * whether to hold a lifeline
144
+ * @returns The e3, once the worker says it is ready
145
+ * @throws {Error} As {@link createWebE3} throws
146
+ * @internal
147
+ */
148
+ export declare function connectWebE3(worker: Worker | MessagePort, options?: ConnectOptions): Promise<WebE3>;
149
+ //# sourceMappingURL=page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/bridge/page.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH;;;;GAIG;AACH,MAAM,WAAW,KAAK;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACxC;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B;;;;;OAKG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CACvC;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAyQD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,CAEpG;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,CAU7G"}