@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
|
@@ -0,0 +1,780 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* `WebTransferBackend`: e3's transfer backend in a browser — the uploads and
|
|
7
|
+
* downloads a client sends and fetches, and the jobs that outlast a request,
|
|
8
|
+
* kept beside a {@link WebStorage}'s repositories.
|
|
9
|
+
*
|
|
10
|
+
* Every record is an East value, in beast2, in the storage's records adapter:
|
|
11
|
+
* IndexedDB in a browser, so a job one tab started is polled from another, as
|
|
12
|
+
* a request may reach any instance of a server. What a job stages — an
|
|
13
|
+
* upload's parts, a package's zip, an export's zip — is blobs of the storage's
|
|
14
|
+
* blobs adapter, OPFS files in a browser, under the repository, so its
|
|
15
|
+
* removal takes them. Every job runs through e3-core's shared handlers, on the
|
|
16
|
+
* {@link TaskRunner} the host gives each repository.
|
|
17
|
+
*
|
|
18
|
+
* A job, and an upload's commit, records the session that runs it — the
|
|
19
|
+
* tab's, as `WebStorage`'s lock holders do — until it ends. What a tab that
|
|
20
|
+
* closed left unfinished is never run again: the next tab records it failed,
|
|
21
|
+
* naming why, and removes what it staged, since the client that knew it was
|
|
22
|
+
* in the tab that closed, and the repository may have changed since. What a
|
|
23
|
+
* tab that lives runs is left to it.
|
|
24
|
+
*
|
|
25
|
+
* @packageDocumentation
|
|
26
|
+
*/
|
|
27
|
+
import { DateTimeType, IntegerType, OptionType, StringType, StructType, type option, type ValueTypeOf } from '@elaraai/east';
|
|
28
|
+
import { type DatasetCommitStatus, type DatasetDownloadStore, type DatasetPartUpload, type DatasetUpload, type DatasetUploadStore, type PackageExport, type PackageExportStore, type PackageImport, type PackageImportStore, type RepoGcJob, type RepoGcStore, type SplitCallJob, type SplitCallStore, type TaskRunner, type TransferBackend, type WorkspaceDeployJob, type WorkspaceDeployStore } from '@elaraai/e3-core/portable';
|
|
29
|
+
import type { BlobsAdapter, ByteSource, LocksAdapter, RecordKey, RecordsAdapter } from '../storage/adapters.js';
|
|
30
|
+
import { type TransferKind, type WebStorage } from '../storage/WebStorage.js';
|
|
31
|
+
export type { TransferKind } from '../storage/WebStorage.js';
|
|
32
|
+
/** A job: the job as e3-core's stores keep it, the session that runs it until
|
|
33
|
+
* it ends, and when it ended. */
|
|
34
|
+
declare const ImportRecordType: StructType<{
|
|
35
|
+
readonly job: StructType<{
|
|
36
|
+
readonly repo: StringType;
|
|
37
|
+
readonly size: IntegerType;
|
|
38
|
+
readonly status: import("@elaraai/east").VariantType<{
|
|
39
|
+
readonly created: import("@elaraai/east").NullType;
|
|
40
|
+
readonly uploaded: import("@elaraai/east").NullType;
|
|
41
|
+
readonly processing: import("@elaraai/east").VariantType<{
|
|
42
|
+
readonly pending: import("@elaraai/east").NullType;
|
|
43
|
+
readonly downloading: import("@elaraai/east").NullType;
|
|
44
|
+
readonly importing: StructType<{
|
|
45
|
+
readonly objectsProcessed: IntegerType;
|
|
46
|
+
}>;
|
|
47
|
+
}>;
|
|
48
|
+
readonly completed: StructType<{
|
|
49
|
+
readonly name: StringType;
|
|
50
|
+
readonly version: StringType;
|
|
51
|
+
readonly packageHash: StringType;
|
|
52
|
+
readonly objectCount: IntegerType;
|
|
53
|
+
}>;
|
|
54
|
+
readonly failed: StructType<{
|
|
55
|
+
readonly message: StringType;
|
|
56
|
+
}>;
|
|
57
|
+
}>;
|
|
58
|
+
readonly createdAt: DateTimeType;
|
|
59
|
+
}>;
|
|
60
|
+
readonly owner: OptionType<StringType>;
|
|
61
|
+
readonly finishedAt: OptionType<DateTimeType>;
|
|
62
|
+
}>;
|
|
63
|
+
type ImportRecord = ValueTypeOf<typeof ImportRecordType>;
|
|
64
|
+
declare const DeployRecordType: StructType<{
|
|
65
|
+
readonly job: StructType<{
|
|
66
|
+
readonly repo: StringType;
|
|
67
|
+
readonly workspace: StringType;
|
|
68
|
+
readonly packageName: StringType;
|
|
69
|
+
readonly packageVersion: StringType;
|
|
70
|
+
readonly schema: import("@elaraai/east").VariantType<{
|
|
71
|
+
readonly migrate: import("@elaraai/east").NullType;
|
|
72
|
+
readonly fail: import("@elaraai/east").NullType;
|
|
73
|
+
readonly reset: import("@elaraai/east").NullType;
|
|
74
|
+
}>;
|
|
75
|
+
readonly allowDropRecords: import("@elaraai/east").BooleanType;
|
|
76
|
+
readonly plan: import("@elaraai/east").BooleanType;
|
|
77
|
+
readonly status: import("@elaraai/east").VariantType<{
|
|
78
|
+
readonly processing: import("@elaraai/east").VariantType<{
|
|
79
|
+
readonly pending: import("@elaraai/east").NullType;
|
|
80
|
+
readonly deploying: OptionType<StructType<{
|
|
81
|
+
readonly package: StructType<{
|
|
82
|
+
readonly name: StringType;
|
|
83
|
+
readonly version: StringType;
|
|
84
|
+
}>;
|
|
85
|
+
readonly startedAt: DateTimeType;
|
|
86
|
+
readonly files: import("@elaraai/east").ArrayType<StructType<{
|
|
87
|
+
readonly path: StringType;
|
|
88
|
+
readonly step: import("@elaraai/east").VariantType<{
|
|
89
|
+
readonly waiting: import("@elaraai/east").NullType;
|
|
90
|
+
readonly hashing: import("@elaraai/east").NullType;
|
|
91
|
+
readonly taking_in: StructType<{
|
|
92
|
+
readonly pieces: IntegerType;
|
|
93
|
+
readonly done: IntegerType;
|
|
94
|
+
}>;
|
|
95
|
+
readonly done: import("@elaraai/east").VariantType<{
|
|
96
|
+
readonly known: import("@elaraai/east").NullType;
|
|
97
|
+
readonly carried: import("@elaraai/east").NullType;
|
|
98
|
+
readonly taken: import("@elaraai/east").ArrayType<StringType>;
|
|
99
|
+
}>;
|
|
100
|
+
}>;
|
|
101
|
+
readonly bytes: IntegerType;
|
|
102
|
+
readonly total: IntegerType;
|
|
103
|
+
}>>;
|
|
104
|
+
readonly records: import("@elaraai/east").ArrayType<StructType<{
|
|
105
|
+
readonly plan: StructType<{
|
|
106
|
+
readonly record: StringType;
|
|
107
|
+
readonly action: import("@elaraai/east").VariantType<{
|
|
108
|
+
readonly mint: import("@elaraai/east").NullType;
|
|
109
|
+
readonly keep: StructType<{
|
|
110
|
+
readonly deploy: import("@elaraai/east").BooleanType;
|
|
111
|
+
}>;
|
|
112
|
+
readonly migrate: StructType<{
|
|
113
|
+
readonly steps: import("@elaraai/east").ArrayType<StringType>;
|
|
114
|
+
}>;
|
|
115
|
+
readonly reset: StructType<{
|
|
116
|
+
readonly reason: StringType;
|
|
117
|
+
}>;
|
|
118
|
+
readonly drop: import("@elaraai/east").NullType;
|
|
119
|
+
readonly refused: StructType<{
|
|
120
|
+
readonly reason: StringType;
|
|
121
|
+
}>;
|
|
122
|
+
}>;
|
|
123
|
+
}>;
|
|
124
|
+
readonly indexes: import("@elaraai/east").ArrayType<StringType>;
|
|
125
|
+
readonly step: import("@elaraai/east").VariantType<{
|
|
126
|
+
readonly waiting: import("@elaraai/east").NullType;
|
|
127
|
+
readonly migrating: StructType<{
|
|
128
|
+
readonly name: StringType;
|
|
129
|
+
readonly step: IntegerType;
|
|
130
|
+
readonly steps: IntegerType;
|
|
131
|
+
}>;
|
|
132
|
+
readonly indexing: StructType<{
|
|
133
|
+
readonly index: StringType;
|
|
134
|
+
readonly build: IntegerType;
|
|
135
|
+
readonly builds: IntegerType;
|
|
136
|
+
}>;
|
|
137
|
+
readonly done: import("@elaraai/east").NullType;
|
|
138
|
+
}>;
|
|
139
|
+
}>>;
|
|
140
|
+
}>>;
|
|
141
|
+
}>;
|
|
142
|
+
readonly completed: StructType<{
|
|
143
|
+
readonly records: import("@elaraai/east").ArrayType<StructType<{
|
|
144
|
+
readonly record: StringType;
|
|
145
|
+
readonly action: import("@elaraai/east").VariantType<{
|
|
146
|
+
readonly mint: import("@elaraai/east").NullType;
|
|
147
|
+
readonly keep: StructType<{
|
|
148
|
+
readonly deploy: import("@elaraai/east").BooleanType;
|
|
149
|
+
}>;
|
|
150
|
+
readonly migrate: StructType<{
|
|
151
|
+
readonly steps: import("@elaraai/east").ArrayType<StringType>;
|
|
152
|
+
}>;
|
|
153
|
+
readonly reset: StructType<{
|
|
154
|
+
readonly reason: StringType;
|
|
155
|
+
}>;
|
|
156
|
+
readonly drop: import("@elaraai/east").NullType;
|
|
157
|
+
readonly refused: StructType<{
|
|
158
|
+
readonly reason: StringType;
|
|
159
|
+
}>;
|
|
160
|
+
}>;
|
|
161
|
+
}>>;
|
|
162
|
+
readonly indexes: import("@elaraai/east").ArrayType<StructType<{
|
|
163
|
+
readonly record: StringType;
|
|
164
|
+
readonly index: StringType;
|
|
165
|
+
readonly action: import("@elaraai/east").VariantType<{
|
|
166
|
+
readonly build: import("@elaraai/east").NullType;
|
|
167
|
+
readonly drop: import("@elaraai/east").NullType;
|
|
168
|
+
readonly keep: import("@elaraai/east").NullType;
|
|
169
|
+
}>;
|
|
170
|
+
}>>;
|
|
171
|
+
readonly warnings: import("@elaraai/east").ArrayType<StringType>;
|
|
172
|
+
}>;
|
|
173
|
+
readonly failed: StructType<{
|
|
174
|
+
readonly message: StringType;
|
|
175
|
+
}>;
|
|
176
|
+
}>;
|
|
177
|
+
readonly createdAt: DateTimeType;
|
|
178
|
+
}>;
|
|
179
|
+
readonly owner: OptionType<StringType>;
|
|
180
|
+
readonly finishedAt: OptionType<DateTimeType>;
|
|
181
|
+
}>;
|
|
182
|
+
type DeployRecord = ValueTypeOf<typeof DeployRecordType>;
|
|
183
|
+
declare const GcRecordType: StructType<{
|
|
184
|
+
readonly job: StructType<{
|
|
185
|
+
readonly repo: StringType;
|
|
186
|
+
readonly request: StructType<{
|
|
187
|
+
readonly dryRun: import("@elaraai/east").BooleanType;
|
|
188
|
+
readonly minAge: OptionType<IntegerType>;
|
|
189
|
+
readonly keepRuns: OptionType<IntegerType>;
|
|
190
|
+
readonly keepDays: OptionType<IntegerType>;
|
|
191
|
+
}>;
|
|
192
|
+
readonly status: StructType<{
|
|
193
|
+
readonly status: import("@elaraai/east").VariantType<{
|
|
194
|
+
readonly running: import("@elaraai/east").NullType;
|
|
195
|
+
readonly succeeded: import("@elaraai/east").NullType;
|
|
196
|
+
readonly failed: import("@elaraai/east").NullType;
|
|
197
|
+
}>;
|
|
198
|
+
readonly stats: OptionType<StructType<{
|
|
199
|
+
readonly deletedObjects: IntegerType;
|
|
200
|
+
readonly deletedPartials: IntegerType;
|
|
201
|
+
readonly retainedObjects: IntegerType;
|
|
202
|
+
readonly skippedYoung: IntegerType;
|
|
203
|
+
readonly bytesFreed: IntegerType;
|
|
204
|
+
readonly deletedRuns: IntegerType;
|
|
205
|
+
readonly deletedExecutions: IntegerType;
|
|
206
|
+
}>>;
|
|
207
|
+
readonly error: OptionType<StringType>;
|
|
208
|
+
}>;
|
|
209
|
+
readonly createdAt: DateTimeType;
|
|
210
|
+
}>;
|
|
211
|
+
readonly owner: OptionType<StringType>;
|
|
212
|
+
readonly finishedAt: OptionType<DateTimeType>;
|
|
213
|
+
}>;
|
|
214
|
+
type GcRecord = ValueTypeOf<typeof GcRecordType>;
|
|
215
|
+
declare const SplitRecordType: StructType<{
|
|
216
|
+
readonly job: StructType<{
|
|
217
|
+
readonly repo: StringType;
|
|
218
|
+
readonly workspace: StringType;
|
|
219
|
+
readonly task: StringType;
|
|
220
|
+
readonly inputs: import("@elaraai/east").ArrayType<StringType>;
|
|
221
|
+
readonly objects: import("@elaraai/east").ArrayType<IntegerType>;
|
|
222
|
+
readonly then: OptionType<StringType>;
|
|
223
|
+
readonly limits: StructType<{
|
|
224
|
+
readonly timeoutMs: IntegerType;
|
|
225
|
+
readonly maxResultBytes: IntegerType;
|
|
226
|
+
readonly maxLogBytes: IntegerType;
|
|
227
|
+
}>;
|
|
228
|
+
readonly read: import("@elaraai/east").ArrayType<StructType<{
|
|
229
|
+
readonly path: import("@elaraai/east").ArrayType<import("@elaraai/east").VariantType<{
|
|
230
|
+
readonly field: StringType;
|
|
231
|
+
}>>;
|
|
232
|
+
readonly hash: StringType;
|
|
233
|
+
}>>;
|
|
234
|
+
readonly explain: import("@elaraai/east").BooleanType;
|
|
235
|
+
readonly platformFree: import("@elaraai/east").BooleanType;
|
|
236
|
+
readonly status: import("@elaraai/east").VariantType<{
|
|
237
|
+
readonly processing: OptionType<StructType<{
|
|
238
|
+
readonly phase: import("@elaraai/east").VariantType<{
|
|
239
|
+
readonly combine: import("@elaraai/east").NullType;
|
|
240
|
+
readonly merge: import("@elaraai/east").NullType;
|
|
241
|
+
readonly partition: import("@elaraai/east").NullType;
|
|
242
|
+
}>;
|
|
243
|
+
readonly done: IntegerType;
|
|
244
|
+
readonly units: IntegerType;
|
|
245
|
+
}>>;
|
|
246
|
+
readonly completed: StructType<{
|
|
247
|
+
readonly outcome: import("@elaraai/east").VariantType<{
|
|
248
|
+
readonly failed: StructType<{
|
|
249
|
+
readonly exitCode: IntegerType;
|
|
250
|
+
}>;
|
|
251
|
+
readonly invalid: StructType<{
|
|
252
|
+
readonly diagnostics: import("@elaraai/east").ArrayType<StructType<{
|
|
253
|
+
readonly message: StringType;
|
|
254
|
+
readonly filename: OptionType<StringType>;
|
|
255
|
+
readonly line: OptionType<IntegerType>;
|
|
256
|
+
readonly column: OptionType<IntegerType>;
|
|
257
|
+
}>>;
|
|
258
|
+
}>;
|
|
259
|
+
readonly success: StructType<{
|
|
260
|
+
readonly value: StringType;
|
|
261
|
+
}>;
|
|
262
|
+
readonly timed_out: StructType<{
|
|
263
|
+
readonly ms: IntegerType;
|
|
264
|
+
}>;
|
|
265
|
+
readonly too_large: StructType<{
|
|
266
|
+
readonly bytes: IntegerType;
|
|
267
|
+
readonly limit: IntegerType;
|
|
268
|
+
}>;
|
|
269
|
+
}>;
|
|
270
|
+
readonly output: OptionType<StringType>;
|
|
271
|
+
readonly stdout: StringType;
|
|
272
|
+
readonly stderr: StringType;
|
|
273
|
+
readonly stdoutTruncated: import("@elaraai/east").BooleanType;
|
|
274
|
+
readonly stderrTruncated: import("@elaraai/east").BooleanType;
|
|
275
|
+
}>;
|
|
276
|
+
readonly planned: StructType<{
|
|
277
|
+
readonly pieces: IntegerType;
|
|
278
|
+
readonly over: IntegerType;
|
|
279
|
+
readonly bytes: IntegerType;
|
|
280
|
+
}>;
|
|
281
|
+
readonly failed: StructType<{
|
|
282
|
+
readonly message: StringType;
|
|
283
|
+
}>;
|
|
284
|
+
}>;
|
|
285
|
+
readonly createdAt: DateTimeType;
|
|
286
|
+
}>;
|
|
287
|
+
readonly owner: OptionType<StringType>;
|
|
288
|
+
readonly finishedAt: OptionType<DateTimeType>;
|
|
289
|
+
}>;
|
|
290
|
+
type SplitRecord = ValueTypeOf<typeof SplitRecordType>;
|
|
291
|
+
/** An export: the job, and how many rounds of its zip are written. The
|
|
292
|
+
* checkpoint a round goes on from is the job's own, in memory: a progress
|
|
293
|
+
* report writes the record, and the checkpoint grows with the zip. */
|
|
294
|
+
declare const ExportRecordType: StructType<{
|
|
295
|
+
readonly job: StructType<{
|
|
296
|
+
readonly repo: StringType;
|
|
297
|
+
readonly name: StringType;
|
|
298
|
+
readonly version: StringType;
|
|
299
|
+
readonly workspace: OptionType<StringType>;
|
|
300
|
+
readonly status: import("@elaraai/east").VariantType<{
|
|
301
|
+
readonly processing: import("@elaraai/east").VariantType<{
|
|
302
|
+
readonly pending: import("@elaraai/east").NullType;
|
|
303
|
+
readonly exporting: StructType<{
|
|
304
|
+
readonly objectsProcessed: IntegerType;
|
|
305
|
+
}>;
|
|
306
|
+
readonly uploading: import("@elaraai/east").NullType;
|
|
307
|
+
}>;
|
|
308
|
+
readonly completed: StructType<{
|
|
309
|
+
readonly size: IntegerType;
|
|
310
|
+
}>;
|
|
311
|
+
readonly failed: StructType<{
|
|
312
|
+
readonly message: StringType;
|
|
313
|
+
}>;
|
|
314
|
+
}>;
|
|
315
|
+
readonly createdAt: DateTimeType;
|
|
316
|
+
}>;
|
|
317
|
+
readonly owner: OptionType<StringType>;
|
|
318
|
+
readonly finishedAt: OptionType<DateTimeType>;
|
|
319
|
+
/** How many rounds of the zip are written, each a blob */
|
|
320
|
+
readonly rounds: IntegerType;
|
|
321
|
+
}>;
|
|
322
|
+
type ExportRecord = ValueTypeOf<typeof ExportRecordType>;
|
|
323
|
+
/** How a kind of record is written and read. */
|
|
324
|
+
interface RecordForm<T> {
|
|
325
|
+
readonly encode: (value: T) => Uint8Array;
|
|
326
|
+
readonly decode: (bytes: Uint8Array) => T;
|
|
327
|
+
}
|
|
328
|
+
/** The part size a dataset upload is planned with unless the host sets one:
|
|
329
|
+
* 8 MiB, since a part crosses between the page and its e3 worker whole. */
|
|
330
|
+
export declare const DEFAULT_WEB_PART_BYTES: number;
|
|
331
|
+
/** The most bytes of a zip an export round writes before it stops at the
|
|
332
|
+
* next entry: 16 MiB unless the host sets it. */
|
|
333
|
+
export declare const DEFAULT_EXPORT_ROUND_BYTES: number;
|
|
334
|
+
/** How long a finished job's status and a finished commit's stay readable for
|
|
335
|
+
* a poll, as the local server keeps a split call's, unless the host sets
|
|
336
|
+
* it: ten minutes. */
|
|
337
|
+
export declare const DEFAULT_RESULT_TTL_MS: number;
|
|
338
|
+
/** How long a record nothing finished or fetched is kept, with what it
|
|
339
|
+
* staged, unless the host sets it: a day. */
|
|
340
|
+
export declare const DEFAULT_RECORD_RETENTION_MS: number;
|
|
341
|
+
/** How often a live tab forgets what is past its retention, unless the host
|
|
342
|
+
* sets it: every ten minutes. */
|
|
343
|
+
export declare const DEFAULT_RETENTION_INTERVAL_MS: number;
|
|
344
|
+
/** How long what finished, and what did not, is kept. */
|
|
345
|
+
interface Retention {
|
|
346
|
+
readonly resultTtlMs: number;
|
|
347
|
+
readonly recordMs: number;
|
|
348
|
+
readonly intervalMs: number;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* What every store of a {@link WebTransferBackend} runs over.
|
|
352
|
+
*/
|
|
353
|
+
interface TransferHost {
|
|
354
|
+
/** The records: every store's records */
|
|
355
|
+
readonly records: RecordsAdapter;
|
|
356
|
+
/** The blobs: what the stores stage */
|
|
357
|
+
readonly blobs: BlobsAdapter;
|
|
358
|
+
/** This tab's session, which owns each job its backend runs */
|
|
359
|
+
readonly locks: LocksAdapter;
|
|
360
|
+
/** The storage the jobs run over */
|
|
361
|
+
readonly storage: WebStorage;
|
|
362
|
+
/** Each repository's runner */
|
|
363
|
+
readonly getRunner: (repo: string) => TaskRunner;
|
|
364
|
+
/** How long what finished, and what did not, is kept */
|
|
365
|
+
readonly retention: Retention;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* The jobs this worker runs, or is taking: a job asked to run while it runs,
|
|
369
|
+
* or is being taken, here starts nothing new.
|
|
370
|
+
*/
|
|
371
|
+
declare class Running {
|
|
372
|
+
private readonly jobs;
|
|
373
|
+
/** Whether a job runs, or is being taken, here. */
|
|
374
|
+
has(kind: TransferKind, id: string): boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Reserves a job for this worker, at once.
|
|
377
|
+
*
|
|
378
|
+
* @returns Whether it was free to reserve: not when it runs, or is being
|
|
379
|
+
* taken, here already
|
|
380
|
+
*/
|
|
381
|
+
reserve(kind: TransferKind, id: string): boolean;
|
|
382
|
+
/** Lets a job go, once it has ended or was not taken. */
|
|
383
|
+
release(kind: TransferKind, id: string): void;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Dataset uploads: each part staged as a blob, and committed as the object the
|
|
387
|
+
* staged bytes hash to.
|
|
388
|
+
*
|
|
389
|
+
* @remarks
|
|
390
|
+
* A part is staged whole, in the blob of its number, so a part sent again
|
|
391
|
+
* replaces itself, and parts arrive in any order. The commit copies every part
|
|
392
|
+
* into one buffer of the upload's size, checking each is there at its planned
|
|
393
|
+
* size, hashes the bytes once, and stores them as the object they hash to —
|
|
394
|
+
* refused, with nothing written, when that is not the upload's hash — then
|
|
395
|
+
* adopts that object (`datasetAdoptObject`): a collection is taken in by
|
|
396
|
+
* intake units on the repository's runner, as the local server's `object`
|
|
397
|
+
* commit takes one in.
|
|
398
|
+
*/
|
|
399
|
+
declare class WebDatasetUploadStore implements DatasetUploadStore {
|
|
400
|
+
private readonly host;
|
|
401
|
+
private readonly partBytes;
|
|
402
|
+
/** The commits this worker runs, or is taking, by upload: a commit asked
|
|
403
|
+
* for while one runs here is answered by it */
|
|
404
|
+
private readonly commits;
|
|
405
|
+
constructor(host: TransferHost, partBytes: bigint);
|
|
406
|
+
private key;
|
|
407
|
+
create(id: string, record: DatasetUpload): Promise<void>;
|
|
408
|
+
get(id: string): Promise<DatasetUpload | null>;
|
|
409
|
+
/**
|
|
410
|
+
* Forgets an upload: its record and every part it staged.
|
|
411
|
+
*
|
|
412
|
+
* @param id - The upload's id
|
|
413
|
+
*/
|
|
414
|
+
delete(id: string): Promise<void>;
|
|
415
|
+
createParts(id: string, _record: DatasetUpload): Promise<bigint>;
|
|
416
|
+
getPartBytes(id: string): Promise<bigint | null>;
|
|
417
|
+
getPartUpload(id: string, _record: DatasetUpload, part: number): Promise<DatasetPartUpload>;
|
|
418
|
+
/**
|
|
419
|
+
* Stages one part of an upload, replacing any it staged before.
|
|
420
|
+
*
|
|
421
|
+
* @param id - The upload's id
|
|
422
|
+
* @param repo - The repository the upload is for
|
|
423
|
+
* @param part - The part's number, from 1
|
|
424
|
+
* @param bytes - The part's bytes, whole or a chunk at a time
|
|
425
|
+
* @returns The part's size, as staged
|
|
426
|
+
*/
|
|
427
|
+
stagePart(id: string, repo: string, part: number, bytes: ByteSource): Promise<number>;
|
|
428
|
+
/**
|
|
429
|
+
* Commits an upload, or answers how its commit stands.
|
|
430
|
+
*
|
|
431
|
+
* @remarks
|
|
432
|
+
* A commit asked for while one runs here is answered by it, and it is
|
|
433
|
+
* registered as it is asked for, so a poll from then on hears it under
|
|
434
|
+
* way. One a tab that lives runs is answered as it stands. One a tab that
|
|
435
|
+
* closed left is recorded failed, naming why, and what it staged removed:
|
|
436
|
+
* it is never run again.
|
|
437
|
+
*/
|
|
438
|
+
commit(id: string, record: DatasetUpload): Promise<DatasetCommitStatus>;
|
|
439
|
+
/** Runs a commit here, or answers how it stands; never rejects. */
|
|
440
|
+
private commitOnce;
|
|
441
|
+
/**
|
|
442
|
+
* Records a commit no tab will finish failed, and removes what it staged.
|
|
443
|
+
*
|
|
444
|
+
* @returns The commit's status, as recorded
|
|
445
|
+
*/
|
|
446
|
+
private abandon;
|
|
447
|
+
/**
|
|
448
|
+
* How an upload's commit stands: as its record says, or under way while it
|
|
449
|
+
* is being taken here, before its record says so; `null` before one is
|
|
450
|
+
* asked for.
|
|
451
|
+
*/
|
|
452
|
+
getCommitStatus(id: string): Promise<DatasetCommitStatus | null>;
|
|
453
|
+
/**
|
|
454
|
+
* Checks the staged parts are the upload's bytes, and points the upload's
|
|
455
|
+
* dataset at them; never rejects.
|
|
456
|
+
*
|
|
457
|
+
* @remarks
|
|
458
|
+
* The parts are copied, in order, into one buffer of the upload's size, each
|
|
459
|
+
* checked against its planned range, and the bytes are hashed once: they are
|
|
460
|
+
* stored as the object they hash to only when that is the upload's hash, so
|
|
461
|
+
* a store holds no object of bytes no one asked for. A collection's object
|
|
462
|
+
* is then taken in by intake units, how far they have got written to the
|
|
463
|
+
* upload's record as they go.
|
|
464
|
+
*/
|
|
465
|
+
private verifyAndAdopt;
|
|
466
|
+
/**
|
|
467
|
+
* Records the commits closed tabs left failed, and forgets what is past its
|
|
468
|
+
* retention: a finished commit's answer once a poll has had a while to read
|
|
469
|
+
* it, and an upload no one committed, with what each staged.
|
|
470
|
+
*/
|
|
471
|
+
sweep(now: number): Promise<void>;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Download URLs: each names an object of a repository's, which e3-web's own
|
|
475
|
+
* byte endpoint serves from the object store, once.
|
|
476
|
+
*/
|
|
477
|
+
declare class WebDatasetDownloadStore implements DatasetDownloadStore {
|
|
478
|
+
private readonly host;
|
|
479
|
+
constructor(host: TransferHost);
|
|
480
|
+
getDownloadUrl(repo: string, hash: string): Promise<string>;
|
|
481
|
+
get(id: string): Promise<{
|
|
482
|
+
repo: string;
|
|
483
|
+
hash: string;
|
|
484
|
+
} | null>;
|
|
485
|
+
delete(id: string): Promise<void>;
|
|
486
|
+
/** Forgets the download URLs no one fetched within the retention. */
|
|
487
|
+
sweep(now: number): Promise<void>;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* What a job store shares: its records, the session that runs each job until
|
|
491
|
+
* it ends, the jobs a closed tab left, recorded failed, and retention.
|
|
492
|
+
*
|
|
493
|
+
* @typeParam J - The job, as e3-core's store interface has it
|
|
494
|
+
* @typeParam R - Its record: the job, the session running it, and when it
|
|
495
|
+
* ended
|
|
496
|
+
*/
|
|
497
|
+
declare abstract class JobStore<J extends {
|
|
498
|
+
readonly repo: string;
|
|
499
|
+
readonly createdAt: Date;
|
|
500
|
+
readonly status: unknown;
|
|
501
|
+
}, R extends {
|
|
502
|
+
readonly job: J;
|
|
503
|
+
readonly owner: option<string>;
|
|
504
|
+
readonly finishedAt: option<Date>;
|
|
505
|
+
}> {
|
|
506
|
+
protected readonly host: TransferHost;
|
|
507
|
+
protected readonly running: Running;
|
|
508
|
+
private readonly kind;
|
|
509
|
+
private readonly form;
|
|
510
|
+
constructor(host: TransferHost, running: Running, kind: TransferKind, form: RecordForm<R>);
|
|
511
|
+
protected key(id: string): RecordKey;
|
|
512
|
+
/** A new job's record, run by a session or by none. */
|
|
513
|
+
protected abstract fresh(job: J, owner: option<string>): R;
|
|
514
|
+
/** A record with its job in a new status: once the status is its end,
|
|
515
|
+
* run by no session and ended now. */
|
|
516
|
+
protected abstract withStatus(id: string, record: R, status: J['status'], ended: boolean): R;
|
|
517
|
+
/** A record run by a session, or by none. */
|
|
518
|
+
protected abstract withOwner(record: R, owner: option<string>): R;
|
|
519
|
+
/** Whether a job's status is its end. */
|
|
520
|
+
protected abstract finished(status: J['status']): boolean;
|
|
521
|
+
/** Whether a job's status is its failure. */
|
|
522
|
+
protected abstract failed(status: J['status']): boolean;
|
|
523
|
+
/** A job's failure, naming why. */
|
|
524
|
+
protected abstract failure(message: string): J['status'];
|
|
525
|
+
/** Runs a job, to its end. */
|
|
526
|
+
protected abstract work(id: string, record: R): Promise<void>;
|
|
527
|
+
/** How long a finished job's record stays readable: the result TTL, unless
|
|
528
|
+
* a kind keeps it longer. */
|
|
529
|
+
protected resultTtl(): number;
|
|
530
|
+
/** Removes what a job staged: once it has failed, or its record goes. */
|
|
531
|
+
protected discard(_id: string, _record: R): Promise<void>;
|
|
532
|
+
/** A job's record, or `null`. */
|
|
533
|
+
protected record(id: string): Promise<R | null>;
|
|
534
|
+
/** Files a job, owned by this tab's session until it ends: a job created
|
|
535
|
+
* ended is no one's. */
|
|
536
|
+
create(id: string, job: J): Promise<void>;
|
|
537
|
+
get(id: string): Promise<J | null>;
|
|
538
|
+
/**
|
|
539
|
+
* Records a job's status: one that ends it is run by no session after, and
|
|
540
|
+
* one that fails it removes what it staged.
|
|
541
|
+
*
|
|
542
|
+
* @throws {Error} When there is no such job
|
|
543
|
+
*/
|
|
544
|
+
updateStatus(id: string, status: J['status']): Promise<void>;
|
|
545
|
+
delete(id: string): Promise<void>;
|
|
546
|
+
/**
|
|
547
|
+
* Runs a job in this worker, in the background, unless it runs here
|
|
548
|
+
* already, has ended, or a tab that lives runs it. One a tab that closed
|
|
549
|
+
* left is recorded failed, naming why: it is never run again.
|
|
550
|
+
*
|
|
551
|
+
* @remarks
|
|
552
|
+
* The job is reserved for this worker as it is asked for, before anything
|
|
553
|
+
* is awaited, so a job asked to run twice at once runs once.
|
|
554
|
+
*
|
|
555
|
+
* @param id - The job's id
|
|
556
|
+
* @param repo - The repository the route named, which must be the job's
|
|
557
|
+
* @throws {Error} When the repository started no such job
|
|
558
|
+
*/
|
|
559
|
+
execute(id: string, repo: string): Promise<void>;
|
|
560
|
+
/** Runs a job to its end: one that ends without recording how is recorded
|
|
561
|
+
* failed, so no tab takes it for running. */
|
|
562
|
+
private run;
|
|
563
|
+
/** Records a job no tab will finish failed, naming why, and removes what
|
|
564
|
+
* it staged. */
|
|
565
|
+
private abandon;
|
|
566
|
+
/**
|
|
567
|
+
* Records the jobs closed tabs left failed, and forgets the jobs that ended
|
|
568
|
+
* longer ago than their retention, and the records that do not decode, with
|
|
569
|
+
* what each staged.
|
|
570
|
+
*
|
|
571
|
+
* @remarks
|
|
572
|
+
* A job no tab runs and none will — one this tab filed and never ran, say —
|
|
573
|
+
* is recorded failed once it is older than the record retention.
|
|
574
|
+
*/
|
|
575
|
+
sweep(now: number): Promise<void>;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Package imports: the zip a client uploads is staged as a blob, and the job
|
|
579
|
+
* reads it as a {@link ZipSource}, by ranges where it lies.
|
|
580
|
+
*/
|
|
581
|
+
declare class WebPackageImportStore extends JobStore<PackageImport, ImportRecord> implements PackageImportStore {
|
|
582
|
+
constructor(host: TransferHost, running: Running);
|
|
583
|
+
protected fresh(job: PackageImport, owner: option<string>): ImportRecord;
|
|
584
|
+
protected withStatus(_id: string, record: ImportRecord, status: PackageImport['status'], ended: boolean): ImportRecord;
|
|
585
|
+
protected withOwner(record: ImportRecord, owner: option<string>): ImportRecord;
|
|
586
|
+
protected finished(status: PackageImport['status']): boolean;
|
|
587
|
+
protected failed(status: PackageImport['status']): boolean;
|
|
588
|
+
protected failure(message: string): PackageImport['status'];
|
|
589
|
+
protected discard(id: string, record: ImportRecord): Promise<void>;
|
|
590
|
+
getUploadUrl(id: string, _repo: string): Promise<string>;
|
|
591
|
+
/**
|
|
592
|
+
* Stages an import's zip, whole, and marks the import uploaded.
|
|
593
|
+
*
|
|
594
|
+
* @param id - The import's id
|
|
595
|
+
* @param repo - The repository the import is for
|
|
596
|
+
* @param bytes - The zip's bytes, whole or a chunk at a time
|
|
597
|
+
* @returns The zip's size, as staged
|
|
598
|
+
*/
|
|
599
|
+
stageZip(id: string, repo: string, bytes: ByteSource): Promise<number>;
|
|
600
|
+
protected work(id: string, record: ImportRecord): Promise<void>;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Package and workspace exports: the job writes its zip through e3-core's
|
|
604
|
+
* portable sink a round at a time, each round's bytes a blob, and the next
|
|
605
|
+
* round goes on from the checkpoint the last one stopped at.
|
|
606
|
+
*
|
|
607
|
+
* @remarks
|
|
608
|
+
* A round stops at the first entry after it has written its share of bytes,
|
|
609
|
+
* and the worker answers what waits — a page's requests — before the next.
|
|
610
|
+
* A workspace's export holds the workspace's lock across its rounds, as the
|
|
611
|
+
* shared handler asks of a caller that runs one job over several calls, so
|
|
612
|
+
* nothing changes the workspace between them. The last round's blob is
|
|
613
|
+
* counted with the job's completion, in one write. The download serves the
|
|
614
|
+
* rounds' blobs in order: the zip an export never stopped writes. An export
|
|
615
|
+
* that fails removes its rounds.
|
|
616
|
+
*/
|
|
617
|
+
declare class WebPackageExportStore extends JobStore<PackageExport, ExportRecord> implements PackageExportStore {
|
|
618
|
+
private readonly roundBytes;
|
|
619
|
+
/** The round each export running here writes, which its completion
|
|
620
|
+
* counts */
|
|
621
|
+
private readonly writing;
|
|
622
|
+
constructor(host: TransferHost, running: Running, roundBytes: number);
|
|
623
|
+
protected fresh(job: PackageExport, owner: option<string>): ExportRecord;
|
|
624
|
+
protected withStatus(id: string, record: ExportRecord, status: PackageExport['status'], ended: boolean): ExportRecord;
|
|
625
|
+
protected withOwner(record: ExportRecord, owner: option<string>): ExportRecord;
|
|
626
|
+
protected finished(status: PackageExport['status']): boolean;
|
|
627
|
+
protected failed(status: PackageExport['status']): boolean;
|
|
628
|
+
protected failure(message: string): PackageExport['status'];
|
|
629
|
+
protected discard(id: string, record: ExportRecord): Promise<void>;
|
|
630
|
+
getDownloadUrl(id: string, _repo: string): Promise<string>;
|
|
631
|
+
/**
|
|
632
|
+
* The zip of a completed export: its rounds' blobs, in order.
|
|
633
|
+
*
|
|
634
|
+
* @param id - The export's id
|
|
635
|
+
* @returns The zip, or `null` when the export has not completed, or what it
|
|
636
|
+
* wrote is gone
|
|
637
|
+
*/
|
|
638
|
+
zipOf(id: string): Promise<Uint8Array | null>;
|
|
639
|
+
/**
|
|
640
|
+
* How many rounds of its zip an export has written.
|
|
641
|
+
*
|
|
642
|
+
* @param id - The export's id
|
|
643
|
+
* @returns Its rounds, or `null` for no such export
|
|
644
|
+
*/
|
|
645
|
+
progressOf(id: string): Promise<{
|
|
646
|
+
rounds: number;
|
|
647
|
+
} | null>;
|
|
648
|
+
protected work(id: string, record: ExportRecord): Promise<void>;
|
|
649
|
+
}
|
|
650
|
+
/** Workspace deploys: run through the shared handler, on the repository's
|
|
651
|
+
* runner. */
|
|
652
|
+
declare class WebWorkspaceDeployStore extends JobStore<WorkspaceDeployJob, DeployRecord> implements WorkspaceDeployStore {
|
|
653
|
+
constructor(host: TransferHost, running: Running);
|
|
654
|
+
protected fresh(job: WorkspaceDeployJob, owner: option<string>): DeployRecord;
|
|
655
|
+
protected withStatus(_id: string, record: DeployRecord, status: WorkspaceDeployJob['status'], ended: boolean): DeployRecord;
|
|
656
|
+
protected withOwner(record: DeployRecord, owner: option<string>): DeployRecord;
|
|
657
|
+
protected finished(status: WorkspaceDeployJob['status']): boolean;
|
|
658
|
+
protected failed(status: WorkspaceDeployJob['status']): boolean;
|
|
659
|
+
protected failure(message: string): WorkspaceDeployJob['status'];
|
|
660
|
+
protected work(id: string, record: DeployRecord): Promise<void>;
|
|
661
|
+
}
|
|
662
|
+
/** Repository gc: run through the shared handler, its history's prune taking
|
|
663
|
+
* the repository's runner's judgement of what still runs. */
|
|
664
|
+
declare class WebRepoGcStore extends JobStore<RepoGcJob, GcRecord> implements RepoGcStore {
|
|
665
|
+
constructor(host: TransferHost, running: Running);
|
|
666
|
+
protected fresh(job: RepoGcJob, owner: option<string>): GcRecord;
|
|
667
|
+
protected withStatus(_id: string, record: GcRecord, status: RepoGcJob['status'], ended: boolean): GcRecord;
|
|
668
|
+
protected withOwner(record: GcRecord, owner: option<string>): GcRecord;
|
|
669
|
+
protected finished(status: RepoGcJob['status']): boolean;
|
|
670
|
+
protected failed(status: RepoGcJob['status']): boolean;
|
|
671
|
+
protected failure(message: string): RepoGcJob['status'];
|
|
672
|
+
protected work(id: string, record: GcRecord): Promise<void>;
|
|
673
|
+
}
|
|
674
|
+
/** Split calls: run through the shared handler, on the repository's runner,
|
|
675
|
+
* and forgotten a while after they finish, as the local server forgets
|
|
676
|
+
* them. */
|
|
677
|
+
declare class WebSplitCallStore extends JobStore<SplitCallJob, SplitRecord> implements SplitCallStore {
|
|
678
|
+
constructor(host: TransferHost, running: Running);
|
|
679
|
+
protected fresh(job: SplitCallJob, owner: option<string>): SplitRecord;
|
|
680
|
+
protected withStatus(_id: string, record: SplitRecord, status: SplitCallJob['status'], ended: boolean): SplitRecord;
|
|
681
|
+
protected withOwner(record: SplitRecord, owner: option<string>): SplitRecord;
|
|
682
|
+
protected finished(status: SplitCallJob['status']): boolean;
|
|
683
|
+
protected failed(status: SplitCallJob['status']): boolean;
|
|
684
|
+
protected failure(message: string): SplitCallJob['status'];
|
|
685
|
+
protected work(id: string, record: SplitRecord): Promise<void>;
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* How a {@link WebTransferBackend} keeps its transfers and runs its jobs.
|
|
689
|
+
*/
|
|
690
|
+
export interface WebTransferBackendOptions {
|
|
691
|
+
/** The storage whose repositories the transfers are of: its records keep
|
|
692
|
+
* the transfers', its blobs what they stage, and its session owns each job
|
|
693
|
+
* the backend runs */
|
|
694
|
+
readonly storage: WebStorage;
|
|
695
|
+
/** Each repository's runner: what a deploy's migrations and index builds,
|
|
696
|
+
* a commit's intake units and a split call's units run on, and whose
|
|
697
|
+
* judgement of what still runs gc's history prune takes */
|
|
698
|
+
readonly getRunner: (repo: string) => TaskRunner;
|
|
699
|
+
/** The size of every part of a dataset upload but the last:
|
|
700
|
+
* {@link DEFAULT_WEB_PART_BYTES} unless set */
|
|
701
|
+
readonly partBytes?: number;
|
|
702
|
+
/** The most bytes of a zip an export round writes before it stops:
|
|
703
|
+
* {@link DEFAULT_EXPORT_ROUND_BYTES} unless set */
|
|
704
|
+
readonly exportRoundBytes?: number;
|
|
705
|
+
/**
|
|
706
|
+
* How long what finished stays readable ({@link DEFAULT_RESULT_TTL_MS}),
|
|
707
|
+
* how long what nothing finished or fetched is kept
|
|
708
|
+
* ({@link DEFAULT_RECORD_RETENTION_MS}), and how often a live tab forgets
|
|
709
|
+
* what is past both ({@link DEFAULT_RETENTION_INTERVAL_MS}), each in
|
|
710
|
+
* milliseconds, unless set
|
|
711
|
+
*/
|
|
712
|
+
readonly retention?: {
|
|
713
|
+
readonly resultTtlMs?: number;
|
|
714
|
+
readonly recordMs?: number;
|
|
715
|
+
readonly intervalMs?: number;
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* e3's {@link TransferBackend} in a browser: uploads staged in the storage's
|
|
720
|
+
* blobs, downloads served from its object store, and every job — import,
|
|
721
|
+
* export, deploy, gc, split call — run in this worker through e3-core's shared
|
|
722
|
+
* handlers, its status in the storage's records.
|
|
723
|
+
*
|
|
724
|
+
* @remarks
|
|
725
|
+
* Its URLs are e3-web's own byte endpoints (`createWebDataEndpoints`),
|
|
726
|
+
* root-relative, which the routes resolve against the request's origin.
|
|
727
|
+
* Every job and commit records this tab's session until it ends; {@link start}
|
|
728
|
+
* records what closed tabs left failed — never running it again — and forgets
|
|
729
|
+
* what is past its retention, and goes on doing so while the tab lives.
|
|
730
|
+
*
|
|
731
|
+
* @example
|
|
732
|
+
* ```ts
|
|
733
|
+
* const storage = await openWebStorage();
|
|
734
|
+
* const transfer = new WebTransferBackend({ storage, getRunner });
|
|
735
|
+
* await transfer.start();
|
|
736
|
+
* // …
|
|
737
|
+
* await transfer.close();
|
|
738
|
+
* ```
|
|
739
|
+
*/
|
|
740
|
+
export declare class WebTransferBackend implements TransferBackend {
|
|
741
|
+
readonly datasetUpload: WebDatasetUploadStore;
|
|
742
|
+
readonly datasetDownload: WebDatasetDownloadStore;
|
|
743
|
+
readonly packageImport: WebPackageImportStore;
|
|
744
|
+
readonly packageExport: WebPackageExportStore;
|
|
745
|
+
readonly workspaceDeploy: WebWorkspaceDeployStore;
|
|
746
|
+
readonly repoGc: WebRepoGcStore;
|
|
747
|
+
readonly splitCall: WebSplitCallStore;
|
|
748
|
+
private readonly retention;
|
|
749
|
+
private timer;
|
|
750
|
+
private sweeping;
|
|
751
|
+
private closed;
|
|
752
|
+
/**
|
|
753
|
+
* @param options - The storage, each repository's runner, the part size,
|
|
754
|
+
* the export rounds' size and the retention
|
|
755
|
+
* @throws {RangeError} When a size is not a whole number of bytes greater
|
|
756
|
+
* than zero, or a retention not a whole number of milliseconds greater
|
|
757
|
+
* than zero
|
|
758
|
+
*/
|
|
759
|
+
constructor(options: WebTransferBackendOptions);
|
|
760
|
+
/**
|
|
761
|
+
* Starts the backend: records what closed tabs left — every job, and every
|
|
762
|
+
* upload's commit, whose session has ended — failed, naming why, and
|
|
763
|
+
* removes what it staged, so nothing a closed tab began runs again over a
|
|
764
|
+
* repository that may have changed since; and forgets what finished longer
|
|
765
|
+
* ago than the result TTL, or that nothing finished or fetched within the
|
|
766
|
+
* record retention, with what it staged. It goes on doing so, every
|
|
767
|
+
* retention interval, while the tab lives, until {@link close}.
|
|
768
|
+
*
|
|
769
|
+
* @remarks
|
|
770
|
+
* A job or a commit a tab that lives runs is left to it.
|
|
771
|
+
*/
|
|
772
|
+
start(): Promise<void>;
|
|
773
|
+
/** One pass over every store: one at a time, a pass asked for while one
|
|
774
|
+
* runs answered by it. */
|
|
775
|
+
private sweep;
|
|
776
|
+
/** Stops the backend's own work: the retention it goes on doing while the
|
|
777
|
+
* tab lives. What its jobs do stops with the tab. */
|
|
778
|
+
close(): Promise<void>;
|
|
779
|
+
}
|
|
780
|
+
//# sourceMappingURL=WebTransferBackend.d.ts.map
|