@elaraai/e3-core 0.0.2-beta.9 → 1.0.0
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 +4 -0
- package/README.md +74 -35
- 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/api-compat.spec.d.ts +6 -0
- package/dist/src/dataflow/api-compat.spec.d.ts.map +1 -0
- package/dist/src/dataflow/api-compat.spec.js +182 -0
- package/dist/src/dataflow/api-compat.spec.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 +729 -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/InMemoryStateStore.spec.d.ts +6 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.spec.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.spec.js +114 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.spec.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/steps.spec.d.ts +6 -0
- package/dist/src/dataflow/steps.spec.d.ts.map +1 -0
- package/dist/src/dataflow/steps.spec.js +343 -0
- package/dist/src/dataflow/steps.spec.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-orchestration.spec.d.ts +6 -0
- package/dist/src/dataflow-orchestration.spec.d.ts.map +1 -0
- package/dist/src/dataflow-orchestration.spec.js +1025 -0
- package/dist/src/dataflow-orchestration.spec.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/dataflow.spec.d.ts +6 -0
- package/dist/src/dataflow.spec.d.ts.map +1 -0
- package/dist/src/dataflow.spec.js +663 -0
- package/dist/src/dataflow.spec.js.map +1 -0
- 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/errors.spec.d.ts +6 -0
- package/dist/src/errors.spec.d.ts.map +1 -0
- package/dist/src/errors.spec.js +276 -0
- package/dist/src/errors.spec.js.map +1 -0
- 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 +113 -481
- package/dist/src/executions.js.map +1 -1
- package/dist/src/executions.spec.d.ts +6 -0
- package/dist/src/executions.spec.d.ts.map +1 -0
- package/dist/src/executions.spec.js +387 -0
- package/dist/src/executions.spec.js.map +1 -0
- package/dist/src/formats.d.ts +18 -2
- package/dist/src/formats.d.ts.map +1 -1
- package/dist/src/formats.js +34 -2
- package/dist/src/formats.js.map +1 -1
- package/dist/src/gc.spec.d.ts +6 -0
- package/dist/src/gc.spec.d.ts.map +1 -0
- package/dist/src/gc.spec.js +512 -0
- package/dist/src/gc.spec.js.map +1 -0
- package/dist/src/index.d.ts +20 -10
- 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 +7 -53
- package/dist/src/objects.d.ts.map +1 -1
- package/dist/src/objects.js +13 -232
- package/dist/src/objects.js.map +1 -1
- package/dist/src/objects.spec.d.ts +6 -0
- package/dist/src/objects.spec.d.ts.map +1 -0
- package/dist/src/objects.spec.js +247 -0
- package/dist/src/objects.spec.js.map +1 -0
- package/dist/src/packages.d.ts +41 -14
- package/dist/src/packages.d.ts.map +1 -1
- package/dist/src/packages.js +151 -89
- package/dist/src/packages.js.map +1 -1
- package/dist/src/packages.spec.d.ts +6 -0
- package/dist/src/packages.spec.d.ts.map +1 -0
- package/dist/src/packages.spec.js +324 -0
- package/dist/src/packages.spec.js.map +1 -0
- 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/InMemoryRepoStore.spec.d.ts +6 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.spec.d.ts.map +1 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.spec.js +187 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.spec.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 +364 -0
- package/dist/src/storage/local/LocalLockService.js.map +1 -0
- package/dist/src/storage/local/LocalLockService.spec.d.ts +6 -0
- package/dist/src/storage/local/LocalLockService.spec.d.ts.map +1 -0
- package/dist/src/storage/local/LocalLockService.spec.js +148 -0
- package/dist/src/storage/local/LocalLockService.spec.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/LocalRepoStore.spec.d.ts +6 -0
- package/dist/src/storage/local/LocalRepoStore.spec.d.ts.map +1 -0
- package/dist/src/storage/local/LocalRepoStore.spec.js +255 -0
- package/dist/src/storage/local/LocalRepoStore.spec.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/storage/local/repository.spec.d.ts +6 -0
- package/dist/src/storage/local/repository.spec.d.ts.map +1 -0
- package/dist/src/storage/local/repository.spec.js +186 -0
- package/dist/src/storage/local/repository.spec.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/tasks.spec.d.ts +6 -0
- package/dist/src/tasks.spec.d.ts.map +1 -0
- package/dist/src/tasks.spec.js +105 -0
- package/dist/src/tasks.spec.js.map +1 -0
- 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 +75 -0
- package/dist/src/transfer/InMemoryTransferBackend.d.ts.map +1 -0
- package/dist/src/transfer/InMemoryTransferBackend.js +211 -0
- package/dist/src/transfer/InMemoryTransferBackend.js.map +1 -0
- package/dist/src/transfer/index.d.ts +9 -0
- package/dist/src/transfer/index.d.ts.map +1 -0
- package/dist/src/transfer/index.js +11 -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/process.d.ts +55 -0
- package/dist/src/transfer/process.d.ts.map +1 -0
- package/dist/src/transfer/process.js +144 -0
- package/dist/src/transfer/process.js.map +1 -0
- package/dist/src/transfer/types.d.ts +106 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/transfer/types.js +61 -0
- package/dist/src/transfer/types.js.map +1 -0
- package/dist/src/trees.d.ts +102 -63
- package/dist/src/trees.d.ts.map +1 -1
- package/dist/src/trees.js +319 -479
- package/dist/src/trees.js.map +1 -1
- package/dist/src/trees.spec.d.ts +6 -0
- package/dist/src/trees.spec.d.ts.map +1 -0
- package/dist/src/trees.spec.js +635 -0
- package/dist/src/trees.spec.js.map +1 -0
- 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 +46 -60
- package/dist/src/workspaceStatus.js.map +1 -1
- package/dist/src/workspaces.d.ts +46 -47
- package/dist/src/workspaces.d.ts.map +1 -1
- package/dist/src/workspaces.js +281 -221
- package/dist/src/workspaces.js.map +1 -1
- package/dist/src/workspaces.spec.d.ts +6 -0
- package/dist/src/workspaces.spec.d.ts.map +1 -0
- package/dist/src/workspaces.spec.js +273 -0
- package/dist/src/workspaces.spec.js.map +1 -0
- package/package.json +15 -15
- 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,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { describe, it, beforeEach, afterEach } from 'node:test';
|
|
6
|
+
import assert from 'node:assert';
|
|
7
|
+
import { readFileSync } from 'node:fs';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { computeHash } from './objects.js';
|
|
10
|
+
import { objectWrite, objectWriteStream, objectRead, objectExists, } from './storage/local/LocalObjectStore.js';
|
|
11
|
+
import { objectPath, objectAbbrev } from './storage/local/localHelpers.js';
|
|
12
|
+
import { ObjectNotFoundError } from './errors.js';
|
|
13
|
+
import { createTestRepo, removeTestRepo } from './test-helpers.js';
|
|
14
|
+
describe('objects', () => {
|
|
15
|
+
let testRepo;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
testRepo = createTestRepo();
|
|
18
|
+
});
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
removeTestRepo(testRepo);
|
|
21
|
+
});
|
|
22
|
+
describe('computeHash', () => {
|
|
23
|
+
it('computes correct SHA256 hash', () => {
|
|
24
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
25
|
+
const hash = computeHash(data);
|
|
26
|
+
// Expected hash for [1, 2, 3]
|
|
27
|
+
assert.strictEqual(hash, '039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81');
|
|
28
|
+
});
|
|
29
|
+
it('returns same hash for same data', () => {
|
|
30
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
31
|
+
const hash1 = computeHash(data);
|
|
32
|
+
const hash2 = computeHash(data);
|
|
33
|
+
assert.strictEqual(hash1, hash2);
|
|
34
|
+
});
|
|
35
|
+
it('returns different hash for different data', () => {
|
|
36
|
+
const data1 = new Uint8Array([1, 2, 3]);
|
|
37
|
+
const data2 = new Uint8Array([1, 2, 4]);
|
|
38
|
+
const hash1 = computeHash(data1);
|
|
39
|
+
const hash2 = computeHash(data2);
|
|
40
|
+
assert.notStrictEqual(hash1, hash2);
|
|
41
|
+
});
|
|
42
|
+
it('handles empty data', () => {
|
|
43
|
+
const data = new Uint8Array([]);
|
|
44
|
+
const hash = computeHash(data);
|
|
45
|
+
// SHA256 hash of empty data
|
|
46
|
+
assert.strictEqual(hash, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
|
|
47
|
+
});
|
|
48
|
+
it('handles large data', () => {
|
|
49
|
+
const data = new Uint8Array(1024 * 1024); // 1MB of zeros
|
|
50
|
+
const hash = computeHash(data);
|
|
51
|
+
assert.strictEqual(typeof hash, 'string');
|
|
52
|
+
assert.strictEqual(hash.length, 64); // SHA256 produces 64 hex chars
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('objectWrite', () => {
|
|
56
|
+
it('stores and returns hash', async () => {
|
|
57
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
58
|
+
const hash = await objectWrite(testRepo, data);
|
|
59
|
+
assert.strictEqual(hash, '039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81');
|
|
60
|
+
});
|
|
61
|
+
it('creates correct directory structure', async () => {
|
|
62
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
63
|
+
const hash = await objectWrite(testRepo, data);
|
|
64
|
+
const dirName = hash.slice(0, 2);
|
|
65
|
+
const fileName = hash.slice(2) + '.beast2';
|
|
66
|
+
const filePath = join(testRepo, 'objects', dirName, fileName);
|
|
67
|
+
const stored = readFileSync(filePath);
|
|
68
|
+
assert.deepStrictEqual(new Uint8Array(stored), data);
|
|
69
|
+
});
|
|
70
|
+
it('deduplicates identical data', async () => {
|
|
71
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
72
|
+
const hash1 = await objectWrite(testRepo, data);
|
|
73
|
+
const hash2 = await objectWrite(testRepo, data);
|
|
74
|
+
assert.strictEqual(hash1, hash2);
|
|
75
|
+
// Verify only one file exists
|
|
76
|
+
const dirName = hash1.slice(0, 2);
|
|
77
|
+
const fileName = hash1.slice(2) + '.beast2';
|
|
78
|
+
const filePath = join(testRepo, 'objects', dirName, fileName);
|
|
79
|
+
const stored = readFileSync(filePath);
|
|
80
|
+
assert.deepStrictEqual(new Uint8Array(stored), data);
|
|
81
|
+
});
|
|
82
|
+
it('handles concurrent writes to same hash', async () => {
|
|
83
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
84
|
+
// Concurrent writes
|
|
85
|
+
const [hash1, hash2, hash3] = await Promise.all([
|
|
86
|
+
objectWrite(testRepo, data),
|
|
87
|
+
objectWrite(testRepo, data),
|
|
88
|
+
objectWrite(testRepo, data),
|
|
89
|
+
]);
|
|
90
|
+
assert.strictEqual(hash1, hash2);
|
|
91
|
+
assert.strictEqual(hash2, hash3);
|
|
92
|
+
// Verify data is correct
|
|
93
|
+
const dirName = hash1.slice(0, 2);
|
|
94
|
+
const fileName = hash1.slice(2) + '.beast2';
|
|
95
|
+
const filePath = join(testRepo, 'objects', dirName, fileName);
|
|
96
|
+
const stored = readFileSync(filePath);
|
|
97
|
+
assert.deepStrictEqual(new Uint8Array(stored), data);
|
|
98
|
+
});
|
|
99
|
+
it('stores empty data', async () => {
|
|
100
|
+
const data = new Uint8Array([]);
|
|
101
|
+
const hash = await objectWrite(testRepo, data);
|
|
102
|
+
assert.strictEqual(hash, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
|
|
103
|
+
});
|
|
104
|
+
it('stores large data', async () => {
|
|
105
|
+
const data = new Uint8Array(1024 * 1024); // 1MB
|
|
106
|
+
data.fill(42);
|
|
107
|
+
const hash = await objectWrite(testRepo, data);
|
|
108
|
+
const loaded = await objectRead(testRepo, hash);
|
|
109
|
+
assert.deepStrictEqual(new Uint8Array(loaded), data);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
describe('objectWriteStream', () => {
|
|
113
|
+
it('stores stream and returns hash', async () => {
|
|
114
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
115
|
+
const stream = new ReadableStream({
|
|
116
|
+
start(controller) {
|
|
117
|
+
controller.enqueue(data);
|
|
118
|
+
controller.close();
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
const hash = await objectWriteStream(testRepo, stream);
|
|
122
|
+
assert.strictEqual(hash, '039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81');
|
|
123
|
+
});
|
|
124
|
+
it('stores chunked stream correctly', async () => {
|
|
125
|
+
const chunk1 = new Uint8Array([1, 2]);
|
|
126
|
+
const chunk2 = new Uint8Array([3]);
|
|
127
|
+
const stream = new ReadableStream({
|
|
128
|
+
start(controller) {
|
|
129
|
+
controller.enqueue(chunk1);
|
|
130
|
+
controller.enqueue(chunk2);
|
|
131
|
+
controller.close();
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
const hash = await objectWriteStream(testRepo, stream);
|
|
135
|
+
const loaded = await objectRead(testRepo, hash);
|
|
136
|
+
// Should reconstruct [1, 2, 3]
|
|
137
|
+
assert.deepStrictEqual(new Uint8Array(loaded), new Uint8Array([1, 2, 3]));
|
|
138
|
+
});
|
|
139
|
+
it('deduplicates stream with existing object', async () => {
|
|
140
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
141
|
+
// Store via regular objectWrite first
|
|
142
|
+
const hash1 = await objectWrite(testRepo, data);
|
|
143
|
+
// Store same data via stream
|
|
144
|
+
const stream = new ReadableStream({
|
|
145
|
+
start(controller) {
|
|
146
|
+
controller.enqueue(data);
|
|
147
|
+
controller.close();
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
const hash2 = await objectWriteStream(testRepo, stream);
|
|
151
|
+
assert.strictEqual(hash1, hash2);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
describe('objectRead', () => {
|
|
155
|
+
it('loads stored object', async () => {
|
|
156
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
157
|
+
const hash = await objectWrite(testRepo, data);
|
|
158
|
+
const loaded = await objectRead(testRepo, hash);
|
|
159
|
+
assert.deepStrictEqual(new Uint8Array(loaded), data);
|
|
160
|
+
});
|
|
161
|
+
it('throws on non-existent hash', async () => {
|
|
162
|
+
const fakeHash = 'a'.repeat(64);
|
|
163
|
+
await assert.rejects(async () => await objectRead(testRepo, fakeHash), ObjectNotFoundError);
|
|
164
|
+
});
|
|
165
|
+
it('round-trips correctly', async () => {
|
|
166
|
+
const original = new Uint8Array([7, 8, 9, 10, 11]);
|
|
167
|
+
const hash = await objectWrite(testRepo, original);
|
|
168
|
+
const loaded = await objectRead(testRepo, hash);
|
|
169
|
+
assert.deepStrictEqual(new Uint8Array(loaded), original);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
describe('objectExists', () => {
|
|
173
|
+
it('returns true for existing object', async () => {
|
|
174
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
175
|
+
const hash = await objectWrite(testRepo, data);
|
|
176
|
+
const exists = await objectExists(testRepo, hash);
|
|
177
|
+
assert.strictEqual(exists, true);
|
|
178
|
+
});
|
|
179
|
+
it('returns false for non-existent object', async () => {
|
|
180
|
+
const fakeHash = 'a'.repeat(64);
|
|
181
|
+
const exists = await objectExists(testRepo, fakeHash);
|
|
182
|
+
assert.strictEqual(exists, false);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
describe('objectPath', () => {
|
|
186
|
+
it('returns correct path', () => {
|
|
187
|
+
const hash = '039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81';
|
|
188
|
+
const path = objectPath(testRepo, hash);
|
|
189
|
+
assert.ok(path.endsWith('objects/03/9058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81.beast2'));
|
|
190
|
+
});
|
|
191
|
+
it('matches actual stored location', async () => {
|
|
192
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
193
|
+
const hash = await objectWrite(testRepo, data);
|
|
194
|
+
const path = objectPath(testRepo, hash);
|
|
195
|
+
const stored = readFileSync(path);
|
|
196
|
+
assert.deepStrictEqual(new Uint8Array(stored), data);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
describe('objectAbbrev', () => {
|
|
200
|
+
it('returns minLength for single object', async () => {
|
|
201
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
202
|
+
const hash = await objectWrite(testRepo, data);
|
|
203
|
+
const abbrevLen = await objectAbbrev(testRepo, hash);
|
|
204
|
+
assert.strictEqual(abbrevLen, 4); // default minLength
|
|
205
|
+
});
|
|
206
|
+
it('respects custom minLength', async () => {
|
|
207
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
208
|
+
const hash = await objectWrite(testRepo, data);
|
|
209
|
+
const abbrevLen = await objectAbbrev(testRepo, hash, 8);
|
|
210
|
+
assert.strictEqual(abbrevLen, 8);
|
|
211
|
+
});
|
|
212
|
+
it('returns minLength for non-existent hash', async () => {
|
|
213
|
+
const fakeHash = 'a'.repeat(64);
|
|
214
|
+
const abbrevLen = await objectAbbrev(testRepo, fakeHash);
|
|
215
|
+
assert.strictEqual(abbrevLen, 4);
|
|
216
|
+
});
|
|
217
|
+
it('increases length when objects share prefix', async () => {
|
|
218
|
+
// Store multiple objects - some may share prefix characters
|
|
219
|
+
const hashes = [];
|
|
220
|
+
for (let i = 0; i < 100; i++) {
|
|
221
|
+
const data = new Uint8Array([i, i + 1, i + 2, i + 3]);
|
|
222
|
+
const hash = await objectWrite(testRepo, data);
|
|
223
|
+
hashes.push(hash);
|
|
224
|
+
}
|
|
225
|
+
// For each hash, verify abbrev length is sufficient
|
|
226
|
+
for (const hash of hashes) {
|
|
227
|
+
const abbrevLen = await objectAbbrev(testRepo, hash);
|
|
228
|
+
const prefix = hash.slice(0, abbrevLen);
|
|
229
|
+
// Count how many hashes share this prefix
|
|
230
|
+
const matching = hashes.filter((h) => h.startsWith(prefix));
|
|
231
|
+
assert.strictEqual(matching.length, 1, `Prefix ${prefix} should be unique`);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
it('returns full length when all chars needed', async () => {
|
|
235
|
+
// This is hard to test naturally, but we can verify the logic
|
|
236
|
+
// by checking that length increases appropriately
|
|
237
|
+
const data1 = new Uint8Array([1, 2, 3]);
|
|
238
|
+
const hash1 = await objectWrite(testRepo, data1);
|
|
239
|
+
// Store object with same first 2 chars (same directory)
|
|
240
|
+
// Finding a collision is hard, so we just verify the function works
|
|
241
|
+
const abbrevLen = await objectAbbrev(testRepo, hash1);
|
|
242
|
+
assert.ok(abbrevLen >= 4);
|
|
243
|
+
assert.ok(abbrevLen <= hash1.length);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
//# sourceMappingURL=objects.spec.js.map
|
|
@@ -0,0 +1 @@
|
|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StorageBackend } from './storage/interfaces.js';
|
|
6
7
|
/**
|
|
7
8
|
* Result of importing a package
|
|
8
9
|
*/
|
|
@@ -12,65 +13,81 @@ export interface PackageImportResult {
|
|
|
12
13
|
packageHash: string;
|
|
13
14
|
objectCount: number;
|
|
14
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Options for package import
|
|
18
|
+
*/
|
|
19
|
+
export interface PackageImportOptions {
|
|
20
|
+
/** Called after each object is written. Can be used for progress reporting. */
|
|
21
|
+
onProgress?: (progress: {
|
|
22
|
+
objectsProcessed: number;
|
|
23
|
+
}) => Promise<void>;
|
|
24
|
+
}
|
|
15
25
|
/**
|
|
16
26
|
* Import a package from a .zip file into the repository.
|
|
17
27
|
*
|
|
18
28
|
* Extracts objects to `objects/`, creates ref at `packages/<name>/<version>`.
|
|
19
29
|
*
|
|
20
|
-
* @param
|
|
30
|
+
* @param storage - Storage backend
|
|
31
|
+
* @param repo - Repository identifier
|
|
21
32
|
* @param zipPath - Path to the .zip package file
|
|
33
|
+
* @param options - Optional import options (e.g. progress callback)
|
|
22
34
|
* @returns Import result with package name, version, and stats
|
|
23
35
|
*/
|
|
24
|
-
export declare function packageImport(
|
|
36
|
+
export declare function packageImport(storage: StorageBackend, repo: string, zipPath: string, options?: PackageImportOptions): Promise<PackageImportResult>;
|
|
25
37
|
/**
|
|
26
38
|
* Remove a package ref from the repository.
|
|
27
39
|
*
|
|
28
40
|
* Objects remain until gc is run.
|
|
29
41
|
*
|
|
30
|
-
* @param
|
|
42
|
+
* @param storage - Storage backend
|
|
43
|
+
* @param repo - Repository identifier
|
|
31
44
|
* @param name - Package name
|
|
32
45
|
* @param version - Package version
|
|
33
46
|
* @throws {PackageNotFoundError} If package doesn't exist
|
|
34
47
|
*/
|
|
35
|
-
export declare function packageRemove(
|
|
48
|
+
export declare function packageRemove(storage: StorageBackend, repo: string, name: string, version: string): Promise<void>;
|
|
36
49
|
/**
|
|
37
50
|
* List all installed packages.
|
|
38
51
|
*
|
|
39
|
-
* @param
|
|
52
|
+
* @param storage - Storage backend
|
|
53
|
+
* @param repo - Repository identifier
|
|
40
54
|
* @returns Array of (name, version) pairs
|
|
41
55
|
*/
|
|
42
|
-
export declare function packageList(
|
|
56
|
+
export declare function packageList(storage: StorageBackend, repo: string): Promise<Array<{
|
|
43
57
|
name: string;
|
|
44
58
|
version: string;
|
|
45
59
|
}>>;
|
|
46
60
|
/**
|
|
47
61
|
* Get the latest version of a package.
|
|
48
62
|
*
|
|
49
|
-
* @param
|
|
63
|
+
* @param storage - Storage backend
|
|
64
|
+
* @param repo - Repository identifier
|
|
50
65
|
* @param name - Package name
|
|
51
66
|
* @returns Latest version string, or undefined if package not found
|
|
52
67
|
*/
|
|
53
|
-
export declare function packageGetLatestVersion(
|
|
68
|
+
export declare function packageGetLatestVersion(storage: StorageBackend, repo: string, name: string): Promise<string | undefined>;
|
|
54
69
|
/**
|
|
55
70
|
* Resolve a package to its PackageObject hash.
|
|
56
71
|
*
|
|
57
|
-
* @param
|
|
72
|
+
* @param storage - Storage backend
|
|
73
|
+
* @param repo - Repository identifier
|
|
58
74
|
* @param name - Package name
|
|
59
75
|
* @param version - Package version
|
|
60
76
|
* @returns PackageObject hash
|
|
61
77
|
* @throws {PackageNotFoundError} If package doesn't exist
|
|
62
78
|
*/
|
|
63
|
-
export declare function packageResolve(
|
|
79
|
+
export declare function packageResolve(storage: StorageBackend, repo: string, name: string, version: string): Promise<string>;
|
|
64
80
|
/**
|
|
65
81
|
* Read and parse a PackageObject.
|
|
66
82
|
*
|
|
67
|
-
* @param
|
|
83
|
+
* @param storage - Storage backend
|
|
84
|
+
* @param repo - Repository identifier
|
|
68
85
|
* @param name - Package name
|
|
69
86
|
* @param version - Package version
|
|
70
87
|
* @returns Parsed PackageObject
|
|
71
88
|
* @throws {PackageNotFoundError} If package doesn't exist
|
|
72
89
|
*/
|
|
73
|
-
export declare function packageRead(
|
|
90
|
+
export declare function packageRead(storage: StorageBackend, repo: string, name: string, version: string): Promise<PackageObject>;
|
|
74
91
|
/**
|
|
75
92
|
* Result of exporting a package
|
|
76
93
|
*/
|
|
@@ -78,16 +95,26 @@ export interface PackageExportResult {
|
|
|
78
95
|
packageHash: string;
|
|
79
96
|
objectCount: number;
|
|
80
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Options for package export
|
|
100
|
+
*/
|
|
101
|
+
export interface PackageExportOptions {
|
|
102
|
+
/** Called after each object is added. Can be used for progress reporting. */
|
|
103
|
+
onProgress?: (progress: {
|
|
104
|
+
objectsProcessed: number;
|
|
105
|
+
}) => Promise<void>;
|
|
106
|
+
}
|
|
81
107
|
/**
|
|
82
108
|
* Export a package to a .zip file.
|
|
83
109
|
*
|
|
84
110
|
* Collects the package object and all transitively referenced objects.
|
|
85
111
|
*
|
|
86
|
-
* @param
|
|
112
|
+
* @param storage - Storage backend
|
|
113
|
+
* @param repo - Repository identifier
|
|
87
114
|
* @param name - Package name
|
|
88
115
|
* @param version - Package version
|
|
89
116
|
* @param zipPath - Path to write the .zip file
|
|
90
117
|
* @returns Export result with package hash and object count
|
|
91
118
|
*/
|
|
92
|
-
export declare function packageExport(
|
|
119
|
+
export declare function packageExport(storage: StorageBackend, repo: string, name: string, version: string, zipPath: string, options?: PackageExportOptions): Promise<PackageExportResult>;
|
|
93
120
|
//# sourceMappingURL=packages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packages.d.ts","sourceRoot":"","sources":["../../src/packages.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"packages.d.ts","sourceRoot":"","sources":["../../src/packages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,mBAAmB,CAAC;AAKnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MA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