@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.
- package/LICENSE.md +54 -0
- package/README.md +395 -2
- package/dist/src/app.d.ts +91 -0
- package/dist/src/app.d.ts.map +1 -0
- package/dist/src/app.js +112 -0
- package/dist/src/app.js.map +1 -0
- package/dist/src/bridge/bridge.spec.d.ts +6 -0
- package/dist/src/bridge/bridge.spec.d.ts.map +1 -0
- package/dist/src/bridge/bridge.spec.js +56 -0
- package/dist/src/bridge/bridge.spec.js.map +1 -0
- package/dist/src/bridge/page.d.ts +149 -0
- package/dist/src/bridge/page.d.ts.map +1 -0
- package/dist/src/bridge/page.js +328 -0
- package/dist/src/bridge/page.js.map +1 -0
- package/dist/src/bridge/protocol.d.ts +181 -0
- package/dist/src/bridge/protocol.d.ts.map +1 -0
- package/dist/src/bridge/protocol.js +113 -0
- package/dist/src/bridge/protocol.js.map +1 -0
- package/dist/src/bridge/worker.d.ts +124 -0
- package/dist/src/bridge/worker.d.ts.map +1 -0
- package/dist/src/bridge/worker.js +185 -0
- package/dist/src/bridge/worker.js.map +1 -0
- package/dist/src/browser/bridge.page.d.ts +12 -0
- package/dist/src/browser/bridge.page.d.ts.map +1 -0
- package/dist/src/browser/bridge.page.js +79 -0
- package/dist/src/browser/bridge.page.js.map +1 -0
- package/dist/src/browser/bridge.spec.d.ts +6 -0
- package/dist/src/browser/bridge.spec.d.ts.map +1 -0
- package/dist/src/browser/bridge.spec.js +105 -0
- package/dist/src/browser/bridge.spec.js.map +1 -0
- package/dist/src/browser/bridge.worker.d.ts +6 -0
- package/dist/src/browser/bridge.worker.d.ts.map +1 -0
- package/dist/src/browser/bridge.worker.js +35 -0
- package/dist/src/browser/bridge.worker.js.map +1 -0
- package/dist/src/browser/compliance.d.ts +68 -0
- package/dist/src/browser/compliance.d.ts.map +1 -0
- package/dist/src/browser/compliance.js +30 -0
- package/dist/src/browser/compliance.js.map +1 -0
- package/dist/src/browser/compliance.page.d.ts +6 -0
- package/dist/src/browser/compliance.page.d.ts.map +1 -0
- package/dist/src/browser/compliance.page.js +204 -0
- package/dist/src/browser/compliance.page.js.map +1 -0
- package/dist/src/browser/compliance.spec.d.ts +6 -0
- package/dist/src/browser/compliance.spec.d.ts.map +1 -0
- package/dist/src/browser/compliance.spec.js +147 -0
- package/dist/src/browser/compliance.spec.js.map +1 -0
- package/dist/src/browser/e3-api-1.spec.d.ts +6 -0
- package/dist/src/browser/e3-api-1.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-api-1.spec.js +12 -0
- package/dist/src/browser/e3-api-1.spec.js.map +1 -0
- package/dist/src/browser/e3-api-2.spec.d.ts +6 -0
- package/dist/src/browser/e3-api-2.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-api-2.spec.js +12 -0
- package/dist/src/browser/e3-api-2.spec.js.map +1 -0
- package/dist/src/browser/e3-api-3.spec.d.ts +6 -0
- package/dist/src/browser/e3-api-3.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-api-3.spec.js +12 -0
- package/dist/src/browser/e3-api-3.spec.js.map +1 -0
- package/dist/src/browser/e3-api-parts.spec.d.ts +6 -0
- package/dist/src/browser/e3-api-parts.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-api-parts.spec.js +45 -0
- package/dist/src/browser/e3-api-parts.spec.js.map +1 -0
- package/dist/src/browser/e3-api.d.ts +28 -0
- package/dist/src/browser/e3-api.d.ts.map +1 -0
- package/dist/src/browser/e3-api.js +144 -0
- package/dist/src/browser/e3-api.js.map +1 -0
- package/dist/src/browser/e3-client.worker.d.ts +6 -0
- package/dist/src/browser/e3-client.worker.d.ts.map +1 -0
- package/dist/src/browser/e3-client.worker.js +19 -0
- package/dist/src/browser/e3-client.worker.js.map +1 -0
- package/dist/src/browser/e3-forward.d.ts +27 -0
- package/dist/src/browser/e3-forward.d.ts.map +1 -0
- package/dist/src/browser/e3-forward.js +81 -0
- package/dist/src/browser/e3-forward.js.map +1 -0
- package/dist/src/browser/e3-forward.spec.d.ts +6 -0
- package/dist/src/browser/e3-forward.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-forward.spec.js +84 -0
- package/dist/src/browser/e3-forward.spec.js.map +1 -0
- package/dist/src/browser/e3-port.worker.d.ts +6 -0
- package/dist/src/browser/e3-port.worker.d.ts.map +1 -0
- package/dist/src/browser/e3-port.worker.js +21 -0
- package/dist/src/browser/e3-port.worker.js.map +1 -0
- package/dist/src/browser/e3-unit.worker.d.ts +6 -0
- package/dist/src/browser/e3-unit.worker.d.ts.map +1 -0
- package/dist/src/browser/e3-unit.worker.js +18 -0
- package/dist/src/browser/e3-unit.worker.js.map +1 -0
- package/dist/src/browser/e3-wire.d.ts +43 -0
- package/dist/src/browser/e3-wire.d.ts.map +1 -0
- package/dist/src/browser/e3-wire.js +32 -0
- package/dist/src/browser/e3-wire.js.map +1 -0
- package/dist/src/browser/e3.page.d.ts +21 -0
- package/dist/src/browser/e3.page.d.ts.map +1 -0
- package/dist/src/browser/e3.page.js +119 -0
- package/dist/src/browser/e3.page.js.map +1 -0
- package/dist/src/browser/e3.spec.d.ts +6 -0
- package/dist/src/browser/e3.spec.d.ts.map +1 -0
- package/dist/src/browser/e3.spec.js +358 -0
- package/dist/src/browser/e3.spec.js.map +1 -0
- package/dist/src/browser/e3.worker.d.ts +6 -0
- package/dist/src/browser/e3.worker.d.ts.map +1 -0
- package/dist/src/browser/e3.worker.js +38 -0
- package/dist/src/browser/e3.worker.js.map +1 -0
- package/dist/src/browser/harness.d.ts +175 -0
- package/dist/src/browser/harness.d.ts.map +1 -0
- package/dist/src/browser/harness.js +375 -0
- package/dist/src/browser/harness.js.map +1 -0
- package/dist/src/browser/page.d.ts +47 -0
- package/dist/src/browser/page.d.ts.map +1 -0
- package/dist/src/browser/page.js +47 -0
- package/dist/src/browser/page.js.map +1 -0
- package/dist/src/browser/repository.page.d.ts +85 -0
- package/dist/src/browser/repository.page.d.ts.map +1 -0
- package/dist/src/browser/repository.page.js +271 -0
- package/dist/src/browser/repository.page.js.map +1 -0
- package/dist/src/browser/runner.page.d.ts +6 -0
- package/dist/src/browser/runner.page.d.ts.map +1 -0
- package/dist/src/browser/runner.page.js +62 -0
- package/dist/src/browser/runner.page.js.map +1 -0
- package/dist/src/browser/runner.spec.d.ts +6 -0
- package/dist/src/browser/runner.spec.d.ts.map +1 -0
- package/dist/src/browser/runner.spec.js +46 -0
- package/dist/src/browser/runner.spec.js.map +1 -0
- package/dist/src/browser/storage.page.d.ts +6 -0
- package/dist/src/browser/storage.page.d.ts.map +1 -0
- package/dist/src/browser/storage.page.js +289 -0
- package/dist/src/browser/storage.page.js.map +1 -0
- package/dist/src/browser/storage.spec.d.ts +6 -0
- package/dist/src/browser/storage.spec.d.ts.map +1 -0
- package/dist/src/browser/storage.spec.js +211 -0
- package/dist/src/browser/storage.spec.js.map +1 -0
- package/dist/src/browser/unit.worker.d.ts +6 -0
- package/dist/src/browser/unit.worker.d.ts.map +1 -0
- package/dist/src/browser/unit.worker.js +17 -0
- package/dist/src/browser/unit.worker.js.map +1 -0
- package/dist/src/execution/WebTaskRunner.d.ts +159 -0
- package/dist/src/execution/WebTaskRunner.d.ts.map +1 -0
- package/dist/src/execution/WebTaskRunner.js +581 -0
- package/dist/src/execution/WebTaskRunner.js.map +1 -0
- package/dist/src/execution/WebTaskRunner.spec.d.ts +6 -0
- package/dist/src/execution/WebTaskRunner.spec.d.ts.map +1 -0
- package/dist/src/execution/WebTaskRunner.spec.js +91 -0
- package/dist/src/execution/WebTaskRunner.spec.js.map +1 -0
- package/dist/src/execution/e3-platform.d.ts +41 -0
- package/dist/src/execution/e3-platform.d.ts.map +1 -0
- package/dist/src/execution/e3-platform.js +52 -0
- package/dist/src/execution/e3-platform.js.map +1 -0
- package/dist/src/execution/in-process.d.ts +32 -0
- package/dist/src/execution/in-process.d.ts.map +1 -0
- package/dist/src/execution/in-process.js +89 -0
- package/dist/src/execution/in-process.js.map +1 -0
- package/dist/src/execution/pool.d.ts +172 -0
- package/dist/src/execution/pool.d.ts.map +1 -0
- package/dist/src/execution/pool.js +352 -0
- package/dist/src/execution/pool.js.map +1 -0
- package/dist/src/execution/pool.spec.d.ts +6 -0
- package/dist/src/execution/pool.spec.d.ts.map +1 -0
- package/dist/src/execution/pool.spec.js +252 -0
- package/dist/src/execution/pool.spec.js.map +1 -0
- package/dist/src/execution/protocol.d.ts +108 -0
- package/dist/src/execution/protocol.d.ts.map +1 -0
- package/dist/src/execution/protocol.js +27 -0
- package/dist/src/execution/protocol.js.map +1 -0
- package/dist/src/execution/unit-server.d.ts +131 -0
- package/dist/src/execution/unit-server.d.ts.map +1 -0
- package/dist/src/execution/unit-server.js +142 -0
- package/dist/src/execution/unit-server.js.map +1 -0
- package/dist/src/index.d.ts +39 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +37 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.spec.d.ts +6 -0
- package/dist/src/index.spec.d.ts.map +1 -0
- package/dist/src/index.spec.js +212 -0
- package/dist/src/index.spec.js.map +1 -0
- package/dist/src/node.d.ts +12 -0
- package/dist/src/node.d.ts.map +1 -0
- package/dist/src/node.js +12 -0
- package/dist/src/node.js.map +1 -0
- package/dist/src/storage/WebStateStore.d.ts +64 -0
- package/dist/src/storage/WebStateStore.d.ts.map +1 -0
- package/dist/src/storage/WebStateStore.js +237 -0
- package/dist/src/storage/WebStateStore.js.map +1 -0
- package/dist/src/storage/WebStorage.d.ts +225 -0
- package/dist/src/storage/WebStorage.d.ts.map +1 -0
- package/dist/src/storage/WebStorage.js +1462 -0
- package/dist/src/storage/WebStorage.js.map +1 -0
- package/dist/src/storage/adapters.d.ts +610 -0
- package/dist/src/storage/adapters.d.ts.map +1 -0
- package/dist/src/storage/adapters.js +246 -0
- package/dist/src/storage/adapters.js.map +1 -0
- package/dist/src/storage/indexeddb.d.ts +93 -0
- package/dist/src/storage/indexeddb.d.ts.map +1 -0
- package/dist/src/storage/indexeddb.js +384 -0
- package/dist/src/storage/indexeddb.js.map +1 -0
- package/dist/src/storage/indexeddb.spec.d.ts +6 -0
- package/dist/src/storage/indexeddb.spec.d.ts.map +1 -0
- package/dist/src/storage/indexeddb.spec.js +77 -0
- package/dist/src/storage/indexeddb.spec.js.map +1 -0
- package/dist/src/storage/memory.d.ts +275 -0
- package/dist/src/storage/memory.d.ts.map +1 -0
- package/dist/src/storage/memory.js +724 -0
- package/dist/src/storage/memory.js.map +1 -0
- package/dist/src/storage/memory.spec.d.ts +6 -0
- package/dist/src/storage/memory.spec.d.ts.map +1 -0
- package/dist/src/storage/memory.spec.js +71 -0
- package/dist/src/storage/memory.spec.js.map +1 -0
- package/dist/src/storage/node-files.d.ts +38 -0
- package/dist/src/storage/node-files.d.ts.map +1 -0
- package/dist/src/storage/node-files.js +148 -0
- package/dist/src/storage/node-files.js.map +1 -0
- package/dist/src/storage/node-files.spec.d.ts +6 -0
- package/dist/src/storage/node-files.spec.d.ts.map +1 -0
- package/dist/src/storage/node-files.spec.js +40 -0
- package/dist/src/storage/node-files.spec.js.map +1 -0
- package/dist/src/storage/opfs.d.ts +145 -0
- package/dist/src/storage/opfs.d.ts.map +1 -0
- package/dist/src/storage/opfs.js +514 -0
- package/dist/src/storage/opfs.js.map +1 -0
- package/dist/src/storage/opfs.spec.d.ts +6 -0
- package/dist/src/storage/opfs.spec.d.ts.map +1 -0
- package/dist/src/storage/opfs.spec.js +51 -0
- package/dist/src/storage/opfs.spec.js.map +1 -0
- package/dist/src/storage/record-keys.d.ts +78 -0
- package/dist/src/storage/record-keys.d.ts.map +1 -0
- package/dist/src/storage/record-keys.js +71 -0
- package/dist/src/storage/record-keys.js.map +1 -0
- package/dist/src/storage/stores.spec.d.ts +6 -0
- package/dist/src/storage/stores.spec.d.ts.map +1 -0
- package/dist/src/storage/stores.spec.js +326 -0
- package/dist/src/storage/stores.spec.js.map +1 -0
- package/dist/src/storage/web-locks.d.ts +103 -0
- package/dist/src/storage/web-locks.d.ts.map +1 -0
- package/dist/src/storage/web-locks.js +228 -0
- package/dist/src/storage/web-locks.js.map +1 -0
- package/dist/src/testing/adapter-contract.d.ts +116 -0
- package/dist/src/testing/adapter-contract.d.ts.map +1 -0
- package/dist/src/testing/adapter-contract.js +769 -0
- package/dist/src/testing/adapter-contract.js.map +1 -0
- package/dist/src/testing/assert.d.ts +75 -0
- package/dist/src/testing/assert.d.ts.map +1 -0
- package/dist/src/testing/assert.js +146 -0
- package/dist/src/testing/assert.js.map +1 -0
- package/dist/src/testing/assert.spec.d.ts +6 -0
- package/dist/src/testing/assert.spec.d.ts.map +1 -0
- package/dist/src/testing/assert.spec.js +62 -0
- package/dist/src/testing/assert.spec.js.map +1 -0
- package/dist/src/testing/bridge-contract.d.ts +55 -0
- package/dist/src/testing/bridge-contract.d.ts.map +1 -0
- package/dist/src/testing/bridge-contract.js +376 -0
- package/dist/src/testing/bridge-contract.js.map +1 -0
- package/dist/src/testing/bridge-handler.d.ts +35 -0
- package/dist/src/testing/bridge-handler.d.ts.map +1 -0
- package/dist/src/testing/bridge-handler.js +108 -0
- package/dist/src/testing/bridge-handler.js.map +1 -0
- package/dist/src/testing/callers.d.ts +29 -0
- package/dist/src/testing/callers.d.ts.map +1 -0
- package/dist/src/testing/callers.js +24 -0
- package/dist/src/testing/callers.js.map +1 -0
- package/dist/src/testing/e3-fixtures.d.ts +38 -0
- package/dist/src/testing/e3-fixtures.d.ts.map +1 -0
- package/dist/src/testing/e3-fixtures.js +126 -0
- package/dist/src/testing/e3-fixtures.js.map +1 -0
- package/dist/src/testing/hold-platform.d.ts +33 -0
- package/dist/src/testing/hold-platform.d.ts.map +1 -0
- package/dist/src/testing/hold-platform.js +41 -0
- package/dist/src/testing/hold-platform.js.map +1 -0
- package/dist/src/testing/runner-cases.d.ts +112 -0
- package/dist/src/testing/runner-cases.d.ts.map +1 -0
- package/dist/src/testing/runner-cases.js +959 -0
- package/dist/src/testing/runner-cases.js.map +1 -0
- package/dist/src/testing/runner-fixtures.d.ts +13 -0
- package/dist/src/testing/runner-fixtures.d.ts.map +1 -0
- package/dist/src/testing/runner-fixtures.js +173 -0
- package/dist/src/testing/runner-fixtures.js.map +1 -0
- package/dist/src/testing/test-platform.d.ts +73 -0
- package/dist/src/testing/test-platform.d.ts.map +1 -0
- package/dist/src/testing/test-platform.js +143 -0
- package/dist/src/testing/test-platform.js.map +1 -0
- package/dist/src/transfer/WebTransferBackend.d.ts +780 -0
- package/dist/src/transfer/WebTransferBackend.d.ts.map +1 -0
- package/dist/src/transfer/WebTransferBackend.js +1140 -0
- package/dist/src/transfer/WebTransferBackend.js.map +1 -0
- package/dist/src/transfer/WebTransferBackend.spec.d.ts +6 -0
- package/dist/src/transfer/WebTransferBackend.spec.d.ts.map +1 -0
- package/dist/src/transfer/WebTransferBackend.spec.js +582 -0
- package/dist/src/transfer/WebTransferBackend.spec.js.map +1 -0
- package/dist/src/transfer/endpoints.d.ts +46 -0
- package/dist/src/transfer/endpoints.d.ts.map +1 -0
- package/dist/src/transfer/endpoints.js +157 -0
- package/dist/src/transfer/endpoints.js.map +1 -0
- package/dist/src/units.d.ts +51 -0
- package/dist/src/units.d.ts.map +1 -0
- package/dist/src/units.js +74 -0
- package/dist/src/units.js.map +1 -0
- package/dist/src/worker.d.ts +126 -0
- package/dist/src/worker.d.ts.map +1 -0
- package/dist/src/worker.js +186 -0
- package/dist/src/worker.js.map +1 -0
- package/dist/src/worker.spec.d.ts +6 -0
- package/dist/src/worker.spec.d.ts.map +1 -0
- package/dist/src/worker.spec.js +195 -0
- package/dist/src/worker.spec.js.map +1 -0
- package/package.json +76 -3
package/dist/src/app.js
ADDED
|
@@ -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":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAwE,MAAM,2BAA2B,CAAC;AAC5H,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,mBAAmB,EACnB,2BAA2B,EAC3B,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,6BAA6B,EAC7B,2BAA2B,EAC3B,qBAAqB,GAGtB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAoDjE;;;;;GAKG;AACH,SAAS,YAAY,CAAC,IAAY;IAChC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,YAAY,CAAC,KAAkB;IAC7C,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,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 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,MA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,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"}
|