@elaraai/e3-core 0.0.2-beta.4 → 0.0.2-beta.40
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/README.md +25 -22
- package/dist/src/dataflow/api-compat.d.ts +90 -0
- package/dist/src/dataflow/api-compat.d.ts.map +1 -0
- package/dist/src/dataflow/api-compat.js +139 -0
- package/dist/src/dataflow/api-compat.js.map +1 -0
- package/dist/src/dataflow/index.d.ts +18 -0
- package/dist/src/dataflow/index.d.ts.map +1 -0
- package/dist/src/dataflow/index.js +23 -0
- package/dist/src/dataflow/index.js.map +1 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts +76 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts.map +1 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.js +695 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.js.map +1 -0
- package/dist/src/dataflow/orchestrator/index.d.ts +12 -0
- package/dist/src/dataflow/orchestrator/index.d.ts.map +1 -0
- package/dist/src/dataflow/orchestrator/index.js +12 -0
- package/dist/src/dataflow/orchestrator/index.js.map +1 -0
- package/dist/src/dataflow/orchestrator/interfaces.d.ts +163 -0
- package/dist/src/dataflow/orchestrator/interfaces.d.ts.map +1 -0
- package/dist/src/dataflow/orchestrator/interfaces.js +52 -0
- package/dist/src/dataflow/orchestrator/interfaces.js.map +1 -0
- package/dist/src/dataflow/state-store/FileStateStore.d.ts +67 -0
- package/dist/src/dataflow/state-store/FileStateStore.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/FileStateStore.js +300 -0
- package/dist/src/dataflow/state-store/FileStateStore.js.map +1 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.d.ts +42 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.js +229 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.js.map +1 -0
- package/dist/src/dataflow/state-store/index.d.ts +13 -0
- package/dist/src/dataflow/state-store/index.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/index.js +13 -0
- package/dist/src/dataflow/state-store/index.js.map +1 -0
- package/dist/src/dataflow/state-store/interfaces.d.ts +159 -0
- package/dist/src/dataflow/state-store/interfaces.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/interfaces.js +6 -0
- package/dist/src/dataflow/state-store/interfaces.js.map +1 -0
- package/dist/src/dataflow/steps.d.ts +222 -0
- package/dist/src/dataflow/steps.d.ts.map +1 -0
- package/dist/src/dataflow/steps.js +707 -0
- package/dist/src/dataflow/steps.js.map +1 -0
- package/dist/src/dataflow/types.d.ts +127 -0
- package/dist/src/dataflow/types.d.ts.map +1 -0
- package/dist/src/dataflow/types.js +7 -0
- package/dist/src/dataflow/types.js.map +1 -0
- package/dist/src/dataflow.d.ts +113 -38
- package/dist/src/dataflow.d.ts.map +1 -1
- package/dist/src/dataflow.js +269 -416
- package/dist/src/dataflow.js.map +1 -1
- package/dist/src/dataset-refs.d.ts +124 -0
- package/dist/src/dataset-refs.d.ts.map +1 -0
- package/dist/src/dataset-refs.js +319 -0
- package/dist/src/dataset-refs.js.map +1 -0
- package/dist/src/errors.d.ts +39 -9
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +51 -8
- package/dist/src/errors.js.map +1 -1
- package/dist/src/execution/LocalTaskRunner.d.ts +73 -0
- package/dist/src/execution/LocalTaskRunner.d.ts.map +1 -0
- package/dist/src/execution/LocalTaskRunner.js +399 -0
- package/dist/src/execution/LocalTaskRunner.js.map +1 -0
- package/dist/src/execution/MockTaskRunner.d.ts +49 -0
- package/dist/src/execution/MockTaskRunner.d.ts.map +1 -0
- package/dist/src/execution/MockTaskRunner.js +54 -0
- package/dist/src/execution/MockTaskRunner.js.map +1 -0
- package/dist/src/execution/index.d.ts +16 -0
- package/dist/src/execution/index.d.ts.map +1 -0
- package/dist/src/execution/index.js +8 -0
- package/dist/src/execution/index.js.map +1 -0
- package/dist/src/execution/interfaces.d.ts +246 -0
- package/dist/src/execution/interfaces.d.ts.map +1 -0
- package/dist/src/execution/interfaces.js +6 -0
- package/dist/src/execution/interfaces.js.map +1 -0
- package/dist/src/execution/processHelpers.d.ts +20 -0
- package/dist/src/execution/processHelpers.d.ts.map +1 -0
- package/dist/src/execution/processHelpers.js +62 -0
- package/dist/src/execution/processHelpers.js.map +1 -0
- package/dist/src/executions.d.ts +71 -104
- package/dist/src/executions.d.ts.map +1 -1
- package/dist/src/executions.js +110 -476
- package/dist/src/executions.js.map +1 -1
- package/dist/src/index.d.ts +19 -9
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +48 -18
- package/dist/src/index.js.map +1 -1
- package/dist/src/objects.d.ts +8 -51
- package/dist/src/objects.d.ts.map +1 -1
- package/dist/src/objects.js +13 -230
- package/dist/src/objects.js.map +1 -1
- package/dist/src/packages.d.ts +22 -14
- package/dist/src/packages.d.ts.map +1 -1
- package/dist/src/packages.js +134 -88
- package/dist/src/packages.js.map +1 -1
- package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts +35 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts.map +1 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.js +107 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.js.map +1 -0
- package/dist/src/storage/in-memory/InMemoryStorage.d.ts +139 -0
- package/dist/src/storage/in-memory/InMemoryStorage.d.ts.map +1 -0
- package/dist/src/storage/in-memory/InMemoryStorage.js +439 -0
- package/dist/src/storage/in-memory/InMemoryStorage.js.map +1 -0
- package/dist/src/storage/in-memory/index.d.ts +12 -0
- package/dist/src/storage/in-memory/index.d.ts.map +1 -0
- package/dist/src/storage/in-memory/index.js +12 -0
- package/dist/src/storage/in-memory/index.js.map +1 -0
- package/dist/src/storage/index.d.ts +18 -0
- package/dist/src/storage/index.d.ts.map +1 -0
- package/dist/src/storage/index.js +10 -0
- package/dist/src/storage/index.js.map +1 -0
- package/dist/src/storage/interfaces.d.ts +581 -0
- package/dist/src/storage/interfaces.d.ts.map +1 -0
- package/dist/src/storage/interfaces.js +6 -0
- package/dist/src/storage/interfaces.js.map +1 -0
- package/dist/src/storage/local/LocalBackend.d.ts +56 -0
- package/dist/src/storage/local/LocalBackend.d.ts.map +1 -0
- package/dist/src/storage/local/LocalBackend.js +145 -0
- package/dist/src/storage/local/LocalBackend.js.map +1 -0
- package/dist/src/storage/local/LocalDatasetRefStore.d.ts +22 -0
- package/dist/src/storage/local/LocalDatasetRefStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalDatasetRefStore.js +118 -0
- package/dist/src/storage/local/LocalDatasetRefStore.js.map +1 -0
- package/dist/src/storage/local/LocalLockService.d.ts +111 -0
- package/dist/src/storage/local/LocalLockService.d.ts.map +1 -0
- package/dist/src/storage/local/LocalLockService.js +355 -0
- package/dist/src/storage/local/LocalLockService.js.map +1 -0
- package/dist/src/storage/local/LocalLogStore.d.ts +23 -0
- package/dist/src/storage/local/LocalLogStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalLogStore.js +66 -0
- package/dist/src/storage/local/LocalLogStore.js.map +1 -0
- package/dist/src/storage/local/LocalObjectStore.d.ts +55 -0
- package/dist/src/storage/local/LocalObjectStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalObjectStore.js +300 -0
- package/dist/src/storage/local/LocalObjectStore.js.map +1 -0
- package/dist/src/storage/local/LocalRefStore.d.ts +50 -0
- package/dist/src/storage/local/LocalRefStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalRefStore.js +337 -0
- package/dist/src/storage/local/LocalRefStore.js.map +1 -0
- package/dist/src/storage/local/LocalRepoStore.d.ts +55 -0
- package/dist/src/storage/local/LocalRepoStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalRepoStore.js +365 -0
- package/dist/src/storage/local/LocalRepoStore.js.map +1 -0
- package/dist/src/storage/local/gc.d.ts +92 -0
- package/dist/src/storage/local/gc.d.ts.map +1 -0
- package/dist/src/storage/local/gc.js +377 -0
- package/dist/src/storage/local/gc.js.map +1 -0
- package/dist/src/storage/local/index.d.ts +18 -0
- package/dist/src/storage/local/index.d.ts.map +1 -0
- package/dist/src/storage/local/index.js +18 -0
- package/dist/src/storage/local/index.js.map +1 -0
- package/dist/src/storage/local/localHelpers.d.ts +25 -0
- package/dist/src/storage/local/localHelpers.d.ts.map +1 -0
- package/dist/src/storage/local/localHelpers.js +69 -0
- package/dist/src/storage/local/localHelpers.js.map +1 -0
- package/dist/src/{repository.d.ts → storage/local/repository.d.ts} +8 -4
- package/dist/src/storage/local/repository.d.ts.map +1 -0
- package/dist/src/{repository.js → storage/local/repository.js} +31 -29
- package/dist/src/storage/local/repository.js.map +1 -0
- package/dist/src/tasks.d.ts +16 -10
- package/dist/src/tasks.d.ts.map +1 -1
- package/dist/src/tasks.js +35 -41
- package/dist/src/tasks.js.map +1 -1
- package/dist/src/test-helpers.d.ts +5 -4
- package/dist/src/test-helpers.d.ts.map +1 -1
- package/dist/src/test-helpers.js +9 -21
- package/dist/src/test-helpers.js.map +1 -1
- package/dist/src/transfer/InMemoryTransferBackend.d.ts +66 -0
- package/dist/src/transfer/InMemoryTransferBackend.d.ts.map +1 -0
- package/dist/src/transfer/InMemoryTransferBackend.js +166 -0
- package/dist/src/transfer/InMemoryTransferBackend.js.map +1 -0
- package/dist/src/transfer/index.d.ts +8 -0
- package/dist/src/transfer/index.d.ts.map +1 -0
- package/dist/src/transfer/index.js +9 -0
- package/dist/src/transfer/index.js.map +1 -0
- package/dist/src/transfer/interfaces.d.ts +103 -0
- package/dist/src/transfer/interfaces.d.ts.map +1 -0
- package/dist/src/transfer/interfaces.js +6 -0
- package/dist/src/transfer/interfaces.js.map +1 -0
- package/dist/src/transfer/types.d.ts +79 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/transfer/types.js +58 -0
- package/dist/src/transfer/types.js.map +1 -0
- package/dist/src/trees.d.ts +147 -59
- package/dist/src/trees.d.ts.map +1 -1
- package/dist/src/trees.js +372 -419
- package/dist/src/trees.js.map +1 -1
- package/dist/src/uuid.d.ts +26 -0
- package/dist/src/uuid.d.ts.map +1 -0
- package/dist/src/uuid.js +80 -0
- package/dist/src/uuid.js.map +1 -0
- package/dist/src/workspaceStatus.d.ts +6 -4
- package/dist/src/workspaceStatus.d.ts.map +1 -1
- package/dist/src/workspaceStatus.js +43 -49
- package/dist/src/workspaceStatus.js.map +1 -1
- package/dist/src/workspaces.d.ts +35 -47
- package/dist/src/workspaces.d.ts.map +1 -1
- package/dist/src/workspaces.js +194 -156
- package/dist/src/workspaces.js.map +1 -1
- package/package.json +4 -4
- package/dist/src/gc.d.ts +0 -54
- package/dist/src/gc.d.ts.map +0 -1
- package/dist/src/gc.js +0 -233
- package/dist/src/gc.js.map +0 -1
- package/dist/src/repository.d.ts.map +0 -1
- package/dist/src/repository.js.map +0 -1
- package/dist/src/workspaceLock.d.ts +0 -67
- package/dist/src/workspaceLock.d.ts.map +0 -1
- package/dist/src/workspaceLock.js +0 -217
- package/dist/src/workspaceLock.js.map +0 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs/promises';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { LocalObjectStore } from './LocalObjectStore.js';
|
|
8
|
+
import { LocalRefStore } from './LocalRefStore.js';
|
|
9
|
+
import { LocalLockService } from './LocalLockService.js';
|
|
10
|
+
import { LocalLogStore } from './LocalLogStore.js';
|
|
11
|
+
import { LocalRepoStore } from './LocalRepoStore.js';
|
|
12
|
+
import { LocalDatasetRefStore } from './LocalDatasetRefStore.js';
|
|
13
|
+
import { RepoNotFoundError } from '../../errors.js';
|
|
14
|
+
/**
|
|
15
|
+
* Thrown when a local repository directory is not found or is missing required structure.
|
|
16
|
+
* This is an internal error for LocalStorage — external consumers see RepoNotFoundError.
|
|
17
|
+
*/
|
|
18
|
+
class RepoDirNotFoundError extends RepoNotFoundError {
|
|
19
|
+
path;
|
|
20
|
+
constructor(path) {
|
|
21
|
+
super(path);
|
|
22
|
+
this.path = path;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Local filesystem implementation of StorageBackend.
|
|
27
|
+
*
|
|
28
|
+
* This combines the local implementations of all storage interfaces,
|
|
29
|
+
* providing a complete backend for local e3 repositories.
|
|
30
|
+
*
|
|
31
|
+
* The `repo` parameter passed to each method is the path to the e3 repository directory.
|
|
32
|
+
* This allows a single LocalStorage instance to be used for multiple repositories.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { LocalStorage } from '@elaraai/e3-core';
|
|
37
|
+
*
|
|
38
|
+
* const storage = new LocalStorage();
|
|
39
|
+
* const repo = '/path/to/repo';
|
|
40
|
+
*
|
|
41
|
+
* // Use the backend with storage-agnostic functions
|
|
42
|
+
* const hash = await storage.objects.write(repo, data);
|
|
43
|
+
* const packages = await storage.refs.packageList(repo);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export class LocalStorage {
|
|
47
|
+
/** Content-addressed object storage */
|
|
48
|
+
objects;
|
|
49
|
+
/** Mutable reference storage */
|
|
50
|
+
refs;
|
|
51
|
+
/** Distributed locking service */
|
|
52
|
+
locks;
|
|
53
|
+
/** Execution log storage */
|
|
54
|
+
logs;
|
|
55
|
+
/** Repository lifecycle management */
|
|
56
|
+
repos;
|
|
57
|
+
/** Per-dataset reference storage (reactive dataflow) */
|
|
58
|
+
datasets;
|
|
59
|
+
/**
|
|
60
|
+
* Create a new LocalStorage instance.
|
|
61
|
+
*
|
|
62
|
+
* @param reposDir - Optional parent directory containing repositories.
|
|
63
|
+
* Required for repo lifecycle operations (repos.*).
|
|
64
|
+
* If not provided, repos.* methods will throw.
|
|
65
|
+
*/
|
|
66
|
+
constructor(reposDir) {
|
|
67
|
+
this.objects = new LocalObjectStore();
|
|
68
|
+
this.refs = new LocalRefStore();
|
|
69
|
+
this.locks = new LocalLockService();
|
|
70
|
+
this.logs = new LocalLogStore();
|
|
71
|
+
this.datasets = new LocalDatasetRefStore();
|
|
72
|
+
// repos requires reposDir for multi-repo operations
|
|
73
|
+
// If not provided, create a RepoStore that throws on all operations
|
|
74
|
+
this.repos = reposDir
|
|
75
|
+
? new LocalRepoStore(reposDir, this.refs, this.datasets)
|
|
76
|
+
: new NoOpRepoStore();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Validate that a repository exists and is properly structured.
|
|
80
|
+
* @param repo - Path to the e3 repository directory
|
|
81
|
+
* @throws {RepoNotFoundError} If repository doesn't exist or is invalid
|
|
82
|
+
*/
|
|
83
|
+
async validateRepository(repo) {
|
|
84
|
+
const requiredDirs = ['objects', 'packages', 'workspaces', 'executions'];
|
|
85
|
+
for (const dir of requiredDirs) {
|
|
86
|
+
try {
|
|
87
|
+
await fs.access(path.join(repo, dir));
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
throw new RepoDirNotFoundError(repo);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Re-export as LocalBackend for backwards compatibility during migration
|
|
96
|
+
export { LocalStorage as LocalBackend };
|
|
97
|
+
/**
|
|
98
|
+
* No-op implementation of RepoStore that throws on all operations.
|
|
99
|
+
* Used when LocalStorage is created without a reposDir.
|
|
100
|
+
*/
|
|
101
|
+
class NoOpRepoStore {
|
|
102
|
+
error() {
|
|
103
|
+
throw new Error('RepoStore operations require reposDir to be configured');
|
|
104
|
+
}
|
|
105
|
+
list() {
|
|
106
|
+
return this.error();
|
|
107
|
+
}
|
|
108
|
+
exists(_repo) {
|
|
109
|
+
return this.error();
|
|
110
|
+
}
|
|
111
|
+
getMetadata(_repo) {
|
|
112
|
+
return this.error();
|
|
113
|
+
}
|
|
114
|
+
create(_repo) {
|
|
115
|
+
return this.error();
|
|
116
|
+
}
|
|
117
|
+
setStatus(_repo, _status, _expected) {
|
|
118
|
+
return this.error();
|
|
119
|
+
}
|
|
120
|
+
remove(_repo) {
|
|
121
|
+
return this.error();
|
|
122
|
+
}
|
|
123
|
+
deleteRefsBatch(_repo, _cursor) {
|
|
124
|
+
return this.error();
|
|
125
|
+
}
|
|
126
|
+
deleteObjectsBatch(_repo, _cursor) {
|
|
127
|
+
return this.error();
|
|
128
|
+
}
|
|
129
|
+
gcScanPackageRoots(_repo, _cursor) {
|
|
130
|
+
return this.error();
|
|
131
|
+
}
|
|
132
|
+
gcScanWorkspaceRoots(_repo, _cursor) {
|
|
133
|
+
return this.error();
|
|
134
|
+
}
|
|
135
|
+
gcScanExecutionRoots(_repo, _cursor) {
|
|
136
|
+
return this.error();
|
|
137
|
+
}
|
|
138
|
+
gcScanObjects(_repo, _cursor) {
|
|
139
|
+
return this.error();
|
|
140
|
+
}
|
|
141
|
+
gcDeleteObjects(_repo, _hashes) {
|
|
142
|
+
return this.error();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=LocalBackend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalBackend.js","sourceRoot":"","sources":["../../../../src/storage/local/LocalBackend.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,oBAAoB,E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AC;IAED,oBAAoB,CAAC,KAAa,EAAE,OAAiB;QACnD,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,aAAa,CAAC,KAAa,EAAE,OAAiB;QAC5C,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,eAAe,CAAC,KAAa,EAAE,OAAiB;QAC9C,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { type DatasetRef } from '@elaraai/e3-types';
|
|
6
|
+
import type { DatasetRefStore } from '../interfaces.js';
|
|
7
|
+
export declare class LocalDatasetRefStore implements DatasetRefStore {
|
|
8
|
+
/**
|
|
9
|
+
* Get the filesystem path for a dataset ref file.
|
|
10
|
+
*/
|
|
11
|
+
private refPath;
|
|
12
|
+
read(repo: string, ws: string, datasetPath: string): Promise<DatasetRef | null>;
|
|
13
|
+
write(repo: string, ws: string, datasetPath: string, ref: DatasetRef): Promise<void>;
|
|
14
|
+
list(repo: string, ws: string): Promise<string[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Recursively walk a directory collecting .ref file paths.
|
|
17
|
+
*/
|
|
18
|
+
private walkDir;
|
|
19
|
+
remove(repo: string, ws: string, datasetPath: string): Promise<void>;
|
|
20
|
+
removeAll(repo: string, ws: string): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=LocalDatasetRefStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalDatasetRefStore.d.ts","sourceRoot":"","sources":["../../../../src/storage/local/LocalDatasetRefStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKxD,qBAAa,oBAAqB,YAAW,eAAe;IAC1D;;OAEG;IACH,OAAO,CAAC,OAAO;IAIT,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAY/E,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBpF,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAcvD;;OAEG;YACW,OAAO;IAgBf,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUpE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CASzD"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Local filesystem implementation of DatasetRefStore.
|
|
7
|
+
*
|
|
8
|
+
* Stores per-dataset refs as .ref files in the workspace data directory:
|
|
9
|
+
* workspaces/<ws>/data/<path>.ref
|
|
10
|
+
*
|
|
11
|
+
* Each .ref file contains a beast2-encoded DatasetRef variant.
|
|
12
|
+
* Writes are atomic (write to .partial, then rename).
|
|
13
|
+
*/
|
|
14
|
+
import * as fs from 'fs/promises';
|
|
15
|
+
import * as path from 'path';
|
|
16
|
+
import { encodeBeast2For, decodeBeast2For } from '@elaraai/east';
|
|
17
|
+
import { DatasetRefType } from '@elaraai/e3-types';
|
|
18
|
+
const encodeRef = encodeBeast2For(DatasetRefType);
|
|
19
|
+
const decodeRef = decodeBeast2For(DatasetRefType);
|
|
20
|
+
export class LocalDatasetRefStore {
|
|
21
|
+
/**
|
|
22
|
+
* Get the filesystem path for a dataset ref file.
|
|
23
|
+
*/
|
|
24
|
+
refPath(repo, ws, datasetPath) {
|
|
25
|
+
return path.join(repo, 'workspaces', ws, 'data', `${datasetPath}.ref`);
|
|
26
|
+
}
|
|
27
|
+
async read(repo, ws, datasetPath) {
|
|
28
|
+
const filePath = this.refPath(repo, ws, datasetPath);
|
|
29
|
+
try {
|
|
30
|
+
const data = await fs.readFile(filePath);
|
|
31
|
+
if (data.length === 0)
|
|
32
|
+
return null;
|
|
33
|
+
return decodeRef(data);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
if (err.code === 'ENOENT')
|
|
37
|
+
return null;
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async write(repo, ws, datasetPath, ref) {
|
|
42
|
+
const filePath = this.refPath(repo, ws, datasetPath);
|
|
43
|
+
const dir = path.dirname(filePath);
|
|
44
|
+
await fs.mkdir(dir, { recursive: true });
|
|
45
|
+
// Atomic write: write to unique staging file, then rename
|
|
46
|
+
// Use random suffix to avoid collisions with concurrent writes
|
|
47
|
+
const randomSuffix = Math.random().toString(36).slice(2, 10);
|
|
48
|
+
const stagingPath = `${filePath}.${Date.now()}.${randomSuffix}.partial`;
|
|
49
|
+
const data = encodeRef(ref);
|
|
50
|
+
await fs.writeFile(stagingPath, data);
|
|
51
|
+
try {
|
|
52
|
+
await fs.rename(stagingPath, filePath);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
// Clean up staging file on failure
|
|
56
|
+
try {
|
|
57
|
+
await fs.unlink(stagingPath);
|
|
58
|
+
}
|
|
59
|
+
catch { /* ignore */ }
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async list(repo, ws) {
|
|
64
|
+
const dataDir = path.join(repo, 'workspaces', ws, 'data');
|
|
65
|
+
const paths = [];
|
|
66
|
+
try {
|
|
67
|
+
await this.walkDir(dataDir, dataDir, paths);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
if (err.code === 'ENOENT')
|
|
71
|
+
return [];
|
|
72
|
+
throw err;
|
|
73
|
+
}
|
|
74
|
+
return paths;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Recursively walk a directory collecting .ref file paths.
|
|
78
|
+
*/
|
|
79
|
+
async walkDir(baseDir, currentDir, results) {
|
|
80
|
+
const entries = await fs.readdir(currentDir, { withFileTypes: true });
|
|
81
|
+
for (const entry of entries) {
|
|
82
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
83
|
+
if (entry.isDirectory()) {
|
|
84
|
+
await this.walkDir(baseDir, fullPath, results);
|
|
85
|
+
}
|
|
86
|
+
else if (entry.name.endsWith('.ref') && !entry.name.includes('.partial')) {
|
|
87
|
+
// Convert filesystem path back to dataset path
|
|
88
|
+
// Remove base dir prefix, leading separator, and .ref suffix
|
|
89
|
+
const relative = path.relative(baseDir, fullPath);
|
|
90
|
+
const datasetPath = relative.slice(0, -4); // remove .ref
|
|
91
|
+
results.push(datasetPath);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async remove(repo, ws, datasetPath) {
|
|
96
|
+
const filePath = this.refPath(repo, ws, datasetPath);
|
|
97
|
+
try {
|
|
98
|
+
await fs.unlink(filePath);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
if (err.code === 'ENOENT')
|
|
102
|
+
return; // Already removed
|
|
103
|
+
throw err;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async removeAll(repo, ws) {
|
|
107
|
+
const dataDir = path.join(repo, 'workspaces', ws, 'data');
|
|
108
|
+
try {
|
|
109
|
+
await fs.rm(dataDir, { recursive: true, force: true });
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
if (err.code === 'ENOENT')
|
|
113
|
+
return; // Already removed
|
|
114
|
+
throw err;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=LocalDatasetRefStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalDatasetRefStore.js","sourceRoot":"","sources":["../../../../src/storage/local/LocalDatasetRefStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,cAAc,EAAmB,MAAM,mBAAmB,CAAC;AAGpE,MAAM,SAAS,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;AAElD,MAAM,OAAO,oBAAoB;IAC/B;;OAEG;IACK,OAAO,CAAC,IAAY,EAAE,EAAU,EAAE,WAAmB;QAC3D,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,WAAW,MAAM,CAAC,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,EAAU,EAAE,WAAmB;QACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QACrD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACzC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YACnC,O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AAC,CAAC,CAAC,cAAc;gBACzD,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,EAAU,EAAE,WAAmB;QACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QACrD,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ;gBAAE,OAAO,CAAC,kBAAkB;YACrD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAY,EAAE,EAAU;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ;gBAAE,OAAO,CAAC,kBAAkB;YACrD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { type LockState, type LockOperation } from '@elaraai/e3-types';
|
|
6
|
+
import { type LockHolderInfo } from '../../errors.js';
|
|
7
|
+
import type { LockHandle, LockService } from '../interfaces.js';
|
|
8
|
+
/**
|
|
9
|
+
* Handle to a held workspace lock.
|
|
10
|
+
* Call release() when done to free the lock.
|
|
11
|
+
*/
|
|
12
|
+
export interface WorkspaceLockHandle {
|
|
13
|
+
/** The resource (workspace name) this lock is for - compatible with LockHandle */
|
|
14
|
+
readonly resource: string;
|
|
15
|
+
/** The workspace name this lock is for */
|
|
16
|
+
readonly workspace: string;
|
|
17
|
+
/** Path to the lock file */
|
|
18
|
+
readonly lockPath: string;
|
|
19
|
+
/** Release the lock. Safe to call multiple times. */
|
|
20
|
+
release(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Options for acquiring a workspace lock.
|
|
24
|
+
*/
|
|
25
|
+
export interface AcquireLockOptions {
|
|
26
|
+
/**
|
|
27
|
+
* If true, wait for the lock to become available instead of failing immediately.
|
|
28
|
+
* Default: false (fail fast if locked)
|
|
29
|
+
*/
|
|
30
|
+
wait?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Timeout in milliseconds when wait=true. Default: 30000 (30 seconds)
|
|
33
|
+
*/
|
|
34
|
+
timeout?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Lock mode: 'shared' allows concurrent shared holders, 'exclusive' is mutually exclusive.
|
|
37
|
+
* Default: 'exclusive'
|
|
38
|
+
*/
|
|
39
|
+
mode?: 'shared' | 'exclusive';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the lock file path for a workspace.
|
|
43
|
+
*/
|
|
44
|
+
export declare function workspaceLockPath(repoPath: string, workspace: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Convert LockState to LockHolderInfo for error display.
|
|
47
|
+
*/
|
|
48
|
+
export declare function lockStateToHolderInfo(state: LockState): LockHolderInfo;
|
|
49
|
+
/**
|
|
50
|
+
* Check if a lock holder is still alive.
|
|
51
|
+
* @param holderStr - East text-encoded holder string
|
|
52
|
+
*/
|
|
53
|
+
export declare function isLockHolderAlive(holderStr: string): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Acquire an exclusive lock on a workspace.
|
|
56
|
+
*
|
|
57
|
+
* Uses Linux flock() for kernel-managed locking. The lock is automatically
|
|
58
|
+
* released when the process exits (even on crash/kill).
|
|
59
|
+
*
|
|
60
|
+
* @param repoPath - Path to e3 repository
|
|
61
|
+
* @param workspace - Workspace name to lock
|
|
62
|
+
* @param operation - What operation is acquiring the lock
|
|
63
|
+
* @param options - Lock acquisition options
|
|
64
|
+
* @returns Lock handle - call release() when done
|
|
65
|
+
* @throws {WorkspaceLockError} If workspace is locked by another process
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const lock = await acquireWorkspaceLock(repoPath, 'production', { type: 'dataflow', value: null });
|
|
70
|
+
* try {
|
|
71
|
+
* await dataflowExecute(repoPath, 'production', { lock });
|
|
72
|
+
* } finally {
|
|
73
|
+
* await lock.release();
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function acquireWorkspaceLock(repoPath: string, workspace: string, operation: LockOperation, options?: AcquireLockOptions): Promise<WorkspaceLockHandle>;
|
|
78
|
+
/**
|
|
79
|
+
* Get the lock state for a workspace.
|
|
80
|
+
*
|
|
81
|
+
* @param repoPath - Path to e3 repository
|
|
82
|
+
* @param workspace - Workspace name to check
|
|
83
|
+
* @returns Lock state if locked, null if not locked
|
|
84
|
+
*/
|
|
85
|
+
export declare function getWorkspaceLockState(repoPath: string, workspace: string): Promise<LockState | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Get lock holder info for a workspace (for backwards compatibility).
|
|
88
|
+
*
|
|
89
|
+
* @param repoPath - Path to e3 repository
|
|
90
|
+
* @param workspace - Workspace name to check
|
|
91
|
+
* @returns Lock holder info if locked, null if not locked
|
|
92
|
+
* @deprecated Use getWorkspaceLockState for full lock information
|
|
93
|
+
*/
|
|
94
|
+
export declare function getWorkspaceLockHolder(repoPath: string, workspace: string): Promise<LockHolderInfo | null>;
|
|
95
|
+
/**
|
|
96
|
+
* Local filesystem implementation of LockService.
|
|
97
|
+
*
|
|
98
|
+
* Uses flock() for kernel-managed locking with lock state
|
|
99
|
+
* stored in beast2 format using LockStateType.
|
|
100
|
+
* The `repo` parameter is the path to the e3 repository directory.
|
|
101
|
+
*/
|
|
102
|
+
export declare class LocalLockService implements LockService {
|
|
103
|
+
acquire(repo: string, resource: string, operation: LockOperation, options?: {
|
|
104
|
+
wait?: boolean;
|
|
105
|
+
timeout?: number;
|
|
106
|
+
mode?: 'shared' | 'exclusive';
|
|
107
|
+
}): Promise<LockHandle | null>;
|
|
108
|
+
getState(repo: string, resource: string): Promise<LockState | null>;
|
|
109
|
+
isHolderAlive(holder: string): Promise<boolean>;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=LocalLockService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalLockService.d.ts","sourceRoot":"","sources":["../../../../src/storage/local/LocalLockService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH,OAAO,EAAoC,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACzG,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAkChE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,4BAA4B;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qDAAqD;IACrD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,OAAO,CA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