@elaraai/e3 1.0.78 → 1.0.80
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 +11 -2
- package/dist/src/browser.d.ts +5 -4
- package/dist/src/browser.d.ts.map +1 -1
- package/dist/src/browser.js +3 -2
- package/dist/src/browser.js.map +1 -1
- package/dist/src/dataset-file.d.ts +17 -19
- package/dist/src/dataset-file.d.ts.map +1 -1
- package/dist/src/dataset-file.js +26 -45
- package/dist/src/dataset-file.js.map +1 -1
- package/dist/src/export.d.ts +2 -3
- package/dist/src/export.d.ts.map +1 -1
- package/dist/src/export.js +150 -80
- package/dist/src/export.js.map +1 -1
- package/dist/src/export.spec.js +177 -57
- package/dist/src/export.spec.js.map +1 -1
- package/dist/src/function.spec.js +29 -58
- package/dist/src/function.spec.js.map +1 -1
- package/dist/src/functions-link.spec.js +19 -17
- package/dist/src/functions-link.spec.js.map +1 -1
- package/dist/src/index.d.ts +56 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/input.d.ts +8 -5
- package/dist/src/input.d.ts.map +1 -1
- package/dist/src/input.js +8 -5
- package/dist/src/input.js.map +1 -1
- package/dist/src/migration.d.ts +172 -0
- package/dist/src/migration.d.ts.map +1 -0
- package/dist/src/migration.js +108 -0
- package/dist/src/migration.js.map +1 -0
- package/dist/src/migration.spec.d.ts +6 -0
- package/dist/src/migration.spec.d.ts.map +1 -0
- package/dist/src/migration.spec.js +197 -0
- package/dist/src/migration.spec.js.map +1 -0
- package/dist/src/mutation-programs.spec.d.ts +6 -0
- package/dist/src/mutation-programs.spec.d.ts.map +1 -0
- package/dist/src/mutation-programs.spec.js +310 -0
- package/dist/src/mutation-programs.spec.js.map +1 -0
- package/dist/src/mutation.d.ts +117 -9
- package/dist/src/mutation.d.ts.map +1 -1
- package/dist/src/mutation.js +104 -46
- package/dist/src/mutation.js.map +1 -1
- package/dist/src/open-beast-link.spec.js +10 -8
- package/dist/src/open-beast-link.spec.js.map +1 -1
- package/dist/src/output.d.ts +117 -0
- package/dist/src/output.d.ts.map +1 -0
- package/dist/src/output.js +119 -0
- package/dist/src/output.js.map +1 -0
- package/dist/src/package.d.ts +7 -5
- package/dist/src/package.d.ts.map +1 -1
- package/dist/src/package.js +98 -8
- package/dist/src/package.js.map +1 -1
- package/dist/src/package.spec.d.ts +6 -0
- package/dist/src/package.spec.d.ts.map +1 -0
- package/dist/src/package.spec.js +16 -0
- package/dist/src/package.spec.js.map +1 -0
- package/dist/src/record-guards.d.ts +41 -0
- package/dist/src/record-guards.d.ts.map +1 -0
- package/dist/src/record-guards.js +44 -0
- package/dist/src/record-guards.js.map +1 -0
- package/dist/src/record-index.d.ts +129 -0
- package/dist/src/record-index.d.ts.map +1 -0
- package/dist/src/record-index.js +144 -0
- package/dist/src/record-index.js.map +1 -0
- package/dist/src/record-index.spec.d.ts +6 -0
- package/dist/src/record-index.spec.d.ts.map +1 -0
- package/dist/src/record-index.spec.js +160 -0
- package/dist/src/record-index.spec.js.map +1 -0
- package/dist/src/record-programs.d.ts +128 -0
- package/dist/src/record-programs.d.ts.map +1 -0
- package/dist/src/record-programs.js +480 -0
- package/dist/src/record-programs.js.map +1 -0
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/record.js +2 -0
- package/dist/src/record.js.map +1 -1
- package/dist/src/record.spec.js +71 -13
- package/dist/src/record.spec.js.map +1 -1
- package/dist/src/runner.d.ts +6 -9
- package/dist/src/runner.d.ts.map +1 -1
- package/dist/src/runner.js +9 -25
- package/dist/src/runner.js.map +1 -1
- package/dist/src/runner.spec.js +16 -34
- package/dist/src/runner.spec.js.map +1 -1
- package/dist/src/sha256.d.ts +4 -3
- package/dist/src/sha256.d.ts.map +1 -1
- package/dist/src/sha256.js +20 -17
- package/dist/src/sha256.js.map +1 -1
- package/dist/src/sha256.spec.js +10 -0
- package/dist/src/sha256.spec.js.map +1 -1
- package/dist/src/task.d.ts +116 -251
- package/dist/src/task.d.ts.map +1 -1
- package/dist/src/task.js +169 -435
- package/dist/src/task.js.map +1 -1
- package/dist/src/task.spec.js +174 -489
- package/dist/src/task.spec.js.map +1 -1
- package/dist/src/types.d.ts +215 -23
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -55,9 +55,18 @@ This creates a package with:
|
|
|
55
55
|
|
|
56
56
|
- `e3.input(name, type, variant('value', default))` - Define an input dataset
|
|
57
57
|
- `e3.task(name, inputs, fn)` - Define a task with East function
|
|
58
|
-
- `e3.
|
|
58
|
+
- `e3.streamTask(name, { inputs, output }, fn)` - Define a task that emits its output instead of returning it; `fn` receives the inputs, then `emit`
|
|
59
|
+
- `e3.output.array(T)`, `set(T)`, `dict(K, V, { merge? })`, `fold(T, { zero, combine })` - The output kinds a stream task emits into: what `emit` takes, and how the parts of the output combine
|
|
60
|
+
- `e3.partition(dataset, { by? })` - Mark a stream task's input as one its work may be split over, a piece at a time, in parallel
|
|
61
|
+
- `e3.record(name, type, initialValue)` - Define a record: state written only through its mutations, each an audited commit
|
|
62
|
+
- `e3.mutation.reduce(name, record, fn)`, `edit(name, record, fn)`, `patch(record, name?)` - Define a record's mutations: a reducer over the whole state, a body writing through an `edit` capability, or a patch a client sends
|
|
63
|
+
- `e3.recordIndex(name, record, { key | keys, value? })` - Define a second collection over a Dict record, in another order
|
|
64
|
+
- `e3.migration.value`, `rows`, `rekey(name, record, fn, { after? })` - Define the steps a deploy runs when a package changes a record's type
|
|
65
|
+
- `e3.package(name, version, ...items)` - Create a package (dependencies collected automatically)
|
|
59
66
|
- `e3.export(pkg, path)` - Export package to zip file
|
|
60
67
|
|
|
68
|
+
The [user guide](https://github.com/elaraai/east-workspace/blob/main/libs/e3/USAGE.md) covers the rest of the SDK, the CLI and setting up a project.
|
|
69
|
+
|
|
61
70
|
|
|
62
71
|
## Claude Code plugin
|
|
63
72
|
|
|
@@ -113,7 +122,7 @@ Dual AGPL-3.0 / Commercial. See [LICENSE.md](./LICENSE.md).
|
|
|
113
122
|
- [@elaraai/e3](https://www.npmjs.com/package/@elaraai/e3): SDK for authoring e3 packages with typed tasks and pipelines
|
|
114
123
|
- [@elaraai/e3-core](https://www.npmjs.com/package/@elaraai/e3-core): Object store, dataflow orchestrator, execution state
|
|
115
124
|
- [@elaraai/e3-types](https://www.npmjs.com/package/@elaraai/e3-types): Shared type definitions for e3 packages
|
|
116
|
-
- [@elaraai/e3-cli](https://www.npmjs.com/package/@elaraai/e3-cli): `e3 repo`, `e3 package`, `e3 workspace`, `e3
|
|
125
|
+
- [@elaraai/e3-cli](https://www.npmjs.com/package/@elaraai/e3-cli): `e3 repo`, `e3 package`, `e3 workspace`, `e3 dataflow run`, `e3 watch`, `e3 task logs` commands
|
|
117
126
|
- [@elaraai/e3-api-client](https://www.npmjs.com/package/@elaraai/e3-api-client): HTTP client for remote e3 repositories
|
|
118
127
|
- [@elaraai/e3-api-server](https://www.npmjs.com/package/@elaraai/e3-api-server): REST API server for e3 repositories
|
|
119
128
|
- [@elaraai/e3-api-tests](https://www.npmjs.com/package/@elaraai/e3-api-tests): Shared API compliance test suites
|
package/dist/src/browser.d.ts
CHANGED
|
@@ -18,14 +18,15 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @packageDocumentation
|
|
20
20
|
*/
|
|
21
|
-
export type { DataTreeDef, DatasetDef, DatasetsOf, FunctionDef, MutationDef, RecordDef, TaskDef, PackageDef, PackageItem, MergeDatasets, } from './types.js';
|
|
21
|
+
export type { ArrayOutputDef, DataTreeDef, DatasetDef, DatasetsOf, DictOutputDef, FoldOutputDef, FunctionDef, MutationDef, OutputDef, PartitionDef, RecordDef, SetOutputDef, TaskDef, PackageDef, PackageItem, MergeDatasets, } from './types.js';
|
|
22
22
|
export type { Runner, FunctionRunner, Platform, EastPyPlatform, EastNodePlatform, EastCPlatform, } from './runner.js';
|
|
23
|
-
export {
|
|
23
|
+
export { runnerToVariant, DEFAULT_RUNNER } from './runner.js';
|
|
24
24
|
export { input, inputsTree } from './input.js';
|
|
25
25
|
export { record, recordsTree } from './record.js';
|
|
26
26
|
export { mutation } from './mutation.js';
|
|
27
|
-
export { task, customTask,
|
|
28
|
-
export type {
|
|
27
|
+
export { task, customTask, streamTask, partition, tasksTree } from './task.js';
|
|
28
|
+
export type { StreamTaskSpec } from './task.js';
|
|
29
|
+
export { output } from './output.js';
|
|
29
30
|
export { function_ } from './function.js';
|
|
30
31
|
export { package_ as package } from './package.js';
|
|
31
32
|
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH,YAAY,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,MAAM,EACN,cAAc,EACd,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH,YAAY,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,OAAO,EACP,UAAU,EACV,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,MAAM,EACN,cAAc,EACd,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI9D,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/E,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/src/browser.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
3
|
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
|
-
export {
|
|
5
|
+
export { runnerToVariant, DEFAULT_RUNNER } from './runner.js';
|
|
6
6
|
// Authoring builders + their singleton trees — all browser-safe (they build
|
|
7
7
|
// in-memory East IR; only `export_`/`sha256` touch node:fs, and are omitted).
|
|
8
8
|
export { input, inputsTree } from './input.js';
|
|
9
9
|
export { record, recordsTree } from './record.js';
|
|
10
10
|
export { mutation } from './mutation.js';
|
|
11
|
-
export { task, customTask,
|
|
11
|
+
export { task, customTask, streamTask, partition, tasksTree } from './task.js';
|
|
12
|
+
export { output } from './output.js';
|
|
12
13
|
export { function_ } from './function.js';
|
|
13
14
|
export { package_ as package } from './package.js';
|
|
14
15
|
//# sourceMappingURL=browser.js.map
|
package/dist/src/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+CH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE9D,4EAA4E;AAC5E,8EAA8E;AAC9E,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE/E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -10,10 +10,6 @@ export interface DatasetFileHeader {
|
|
|
10
10
|
readonly size: number;
|
|
11
11
|
/** The root type the header declares. */
|
|
12
12
|
readonly typeValue: EastTypeValue;
|
|
13
|
-
/** Segment count, for a collection root; `null` otherwise. */
|
|
14
|
-
readonly segments: number | null;
|
|
15
|
-
/** Element count (pairs for a Dict), for a collection root; `null` otherwise. */
|
|
16
|
-
readonly rows: number | null;
|
|
17
13
|
}
|
|
18
14
|
/**
|
|
19
15
|
* Thrown when a delivered file's header does not match the type its
|
|
@@ -30,35 +26,37 @@ export declare class DatasetFileTypeMismatchError extends Error {
|
|
|
30
26
|
constructor(file: string, mismatch: DatasetTypeMismatch);
|
|
31
27
|
}
|
|
32
28
|
/**
|
|
33
|
-
* Read a beast2 file's declared type and
|
|
34
|
-
*
|
|
29
|
+
* Read a beast2 file's declared type and check it against the type its
|
|
30
|
+
* destination declares.
|
|
35
31
|
*
|
|
36
32
|
* @remarks
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
33
|
+
* The check a delivery gets before anything reads its body. The store takes
|
|
34
|
+
* one in through its door, which reads a collection a frame at a time in
|
|
35
|
+
* whatever layout it was written — indexed or not, cut by the rule or batched
|
|
36
|
+
* by its writer — but refuses a frame over `@elaraai/east`'s `RUN_MAX_BYTES`,
|
|
37
|
+
* or a v4 blob over it, which is what a whole-value encode of a large
|
|
38
|
+
* collection writes. This check cannot see that: the refusal comes when the
|
|
39
|
+
* door reads the file, after a local adoption has hashed it or a remote set
|
|
40
|
+
* has uploaded it.
|
|
42
41
|
*
|
|
43
42
|
* @param file - Path to the delivered file
|
|
44
43
|
* @param subject - How to name the destination in an error, e.g. `input 'table'`
|
|
45
44
|
* @param declared - The type the destination declares
|
|
46
|
-
* @returns The file's size
|
|
45
|
+
* @returns The file's size and wire type
|
|
47
46
|
* @throws {DatasetFileTypeMismatchError} When the header's type is not the
|
|
48
47
|
* declared type
|
|
49
|
-
* @throws {Error} When the file is missing
|
|
50
|
-
* collection with no index or with cross-segment aliasing
|
|
48
|
+
* @throws {Error} When the file is missing or is not a beast2 container
|
|
51
49
|
*/
|
|
52
50
|
export declare function readDatasetFileHeader(file: string, subject: string, declared: EastType | EastTypeValue): DatasetFileHeader;
|
|
53
51
|
/**
|
|
54
52
|
* Read the root type a beast2 file's header declares, without reading the file.
|
|
55
53
|
*
|
|
56
54
|
* @remarks
|
|
57
|
-
* Any container version, indexed or not
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
55
|
+
* Any container version, indexed or not, with no declared type to check it
|
|
56
|
+
* against: what a caller reads to learn what a file holds — the positional
|
|
57
|
+
* `e3 dataset set` before it decodes one, the store before it takes a task's
|
|
58
|
+
* output. {@link readDatasetFileHeader} checks a delivery against the type its
|
|
59
|
+
* destination declares.
|
|
62
60
|
*
|
|
63
61
|
* @param file - Path to the file
|
|
64
62
|
* @returns The root type the file's header declares
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataset-file.d.ts","sourceRoot":"","sources":["../../src/dataset-file.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoBH,OAAO,
|
|
1
|
+
{"version":3,"file":"dataset-file.d.ts","sourceRoot":"","sources":["../../src/dataset-file.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoBH,OAAO,EAKL,KAAK,QAAQ,EACb,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE/E,oDAAoD;AACpD,MAAM,WAAW,iBAAiB;IAChC,qBAAqB;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;CACnC;AAED;;;;;;;;GAQG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;aAEnC,IAAI,EAAE,MAAM;aACZ,QAAQ,EAAE,mBAAmB;gBAD7B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,mBAAmB;CAKhD;AAoBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,GAAG,aAAa,GACjC,iBAAiB,CAgCnB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAO/D"}
|
package/dist/src/dataset-file.js
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* checked twice: once at EXPORT, against the type the package declares, so a
|
|
10
10
|
* schema drift is a build error at the developer's desk; and again at DEPLOY,
|
|
11
11
|
* on the machine that actually has the file. Both checks are this function, so
|
|
12
|
-
* both report a mismatch identically — and both cost
|
|
13
|
-
* than the gigabytes the file may hold.
|
|
12
|
+
* both report a mismatch identically — and both cost one read of the file's
|
|
13
|
+
* head rather than the gigabytes the file may hold.
|
|
14
14
|
*
|
|
15
15
|
* It lives in `@elaraai/e3` (not `e3-core`) because the export path is here and
|
|
16
16
|
* `e3-core` depends on this package, not the other way round. It is Node-only
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
* @packageDocumentation
|
|
20
20
|
*/
|
|
21
21
|
import { closeSync, fstatSync, openSync, readSync, statSync } from 'node:fs';
|
|
22
|
-
import { isVariant,
|
|
23
|
-
import { checkDatasetType
|
|
22
|
+
import { isVariant, readBeast2HeaderType, toEastTypeValue, } from '@elaraai/east';
|
|
23
|
+
import { checkDatasetType } from '@elaraai/e3-types';
|
|
24
24
|
/**
|
|
25
25
|
* Thrown when a delivered file's header does not match the type its
|
|
26
26
|
* destination declares.
|
|
@@ -59,24 +59,26 @@ function fileRangeReader(fd, size) {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* Read a beast2 file's declared type and
|
|
63
|
-
*
|
|
62
|
+
* Read a beast2 file's declared type and check it against the type its
|
|
63
|
+
* destination declares.
|
|
64
64
|
*
|
|
65
65
|
* @remarks
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
66
|
+
* The check a delivery gets before anything reads its body. The store takes
|
|
67
|
+
* one in through its door, which reads a collection a frame at a time in
|
|
68
|
+
* whatever layout it was written — indexed or not, cut by the rule or batched
|
|
69
|
+
* by its writer — but refuses a frame over `@elaraai/east`'s `RUN_MAX_BYTES`,
|
|
70
|
+
* or a v4 blob over it, which is what a whole-value encode of a large
|
|
71
|
+
* collection writes. This check cannot see that: the refusal comes when the
|
|
72
|
+
* door reads the file, after a local adoption has hashed it or a remote set
|
|
73
|
+
* has uploaded it.
|
|
71
74
|
*
|
|
72
75
|
* @param file - Path to the delivered file
|
|
73
76
|
* @param subject - How to name the destination in an error, e.g. `input 'table'`
|
|
74
77
|
* @param declared - The type the destination declares
|
|
75
|
-
* @returns The file's size
|
|
78
|
+
* @returns The file's size and wire type
|
|
76
79
|
* @throws {DatasetFileTypeMismatchError} When the header's type is not the
|
|
77
80
|
* declared type
|
|
78
|
-
* @throws {Error} When the file is missing
|
|
79
|
-
* collection with no index or with cross-segment aliasing
|
|
81
|
+
* @throws {Error} When the file is missing or is not a beast2 container
|
|
80
82
|
*/
|
|
81
83
|
export function readDatasetFileHeader(file, subject, declared) {
|
|
82
84
|
let stats;
|
|
@@ -93,41 +95,20 @@ export function readDatasetFileHeader(file, subject, declared) {
|
|
|
93
95
|
throw new Error(`${subject}: ${file} is not a file`);
|
|
94
96
|
const fd = openSync(file, 'r');
|
|
95
97
|
try {
|
|
96
|
-
const reader = fileRangeReader(fd, stats.size);
|
|
97
98
|
const declaredValue = isVariant(declared)
|
|
98
99
|
? declared
|
|
99
100
|
: toEastTypeValue(declared);
|
|
100
101
|
let typeValue;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (isCollectionRoot(declaredValue)) {
|
|
104
|
-
let extents;
|
|
105
|
-
try {
|
|
106
|
-
extents = readBeast2Extents(reader);
|
|
107
|
-
}
|
|
108
|
-
catch (err) {
|
|
109
|
-
throw new Error(`${subject}: ${file} is not a readable indexed beast2 collection — ${err instanceof Error ? err.message : String(err)}`);
|
|
110
|
-
}
|
|
111
|
-
if (!extents.selfContained) {
|
|
112
|
-
throw new Error(`${subject}: ${file} has cross-segment aliasing — a dataset's segments must decode ` +
|
|
113
|
-
`independently, so partitions and paged reads can address them`);
|
|
114
|
-
}
|
|
115
|
-
typeValue = extents.typeValue;
|
|
116
|
-
segments = extents.offsets.length;
|
|
117
|
-
rows = extents.elementCount;
|
|
102
|
+
try {
|
|
103
|
+
typeValue = readBeast2HeaderType(fileRangeReader(fd, stats.size));
|
|
118
104
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
typeValue = readBeast2HeaderType(reader);
|
|
122
|
-
}
|
|
123
|
-
catch (err) {
|
|
124
|
-
throw new Error(`${subject}: ${file} is not a readable beast2 container — ${err instanceof Error ? err.message : String(err)}`);
|
|
125
|
-
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
throw new Error(`${subject}: ${file} is not a readable beast2 container — ${err instanceof Error ? err.message : String(err)}`);
|
|
126
107
|
}
|
|
127
108
|
const mismatch = checkDatasetType(subject, file, declaredValue, typeValue);
|
|
128
109
|
if (mismatch)
|
|
129
110
|
throw new DatasetFileTypeMismatchError(file, mismatch);
|
|
130
|
-
return { size: stats.size, typeValue
|
|
111
|
+
return { size: stats.size, typeValue };
|
|
131
112
|
}
|
|
132
113
|
finally {
|
|
133
114
|
closeSync(fd);
|
|
@@ -137,11 +118,11 @@ export function readDatasetFileHeader(file, subject, declared) {
|
|
|
137
118
|
* Read the root type a beast2 file's header declares, without reading the file.
|
|
138
119
|
*
|
|
139
120
|
* @remarks
|
|
140
|
-
* Any container version, indexed or not
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
121
|
+
* Any container version, indexed or not, with no declared type to check it
|
|
122
|
+
* against: what a caller reads to learn what a file holds — the positional
|
|
123
|
+
* `e3 dataset set` before it decodes one, the store before it takes a task's
|
|
124
|
+
* output. {@link readDatasetFileHeader} checks a delivery against the type its
|
|
125
|
+
* destination declares.
|
|
145
126
|
*
|
|
146
127
|
* @param file - Path to the file
|
|
147
128
|
* @returns The root type the file's header declares
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataset-file.js","sourceRoot":"","sources":["../../src/dataset-file.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EACL,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"dataset-file.js","sourceRoot":"","sources":["../../src/dataset-file.ts"],"names":[],"mappings":"AAAA;;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AO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;IACzC,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC;QACH,OAAO,oBAAoB,CAAC,eAAe,CAAC,EAAE,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACvE,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC;AACH,CAAC"}
|
package/dist/src/export.d.ts
CHANGED
|
@@ -11,9 +11,8 @@ import { type ResolveEvent } from './functions-resolve.js';
|
|
|
11
11
|
* Exports a package to a .zip bundle.
|
|
12
12
|
*
|
|
13
13
|
* The bundle can be imported into an e3 repository using `e3 package import`.
|
|
14
|
-
* It contains all objects needed for the package, plus
|
|
15
|
-
* `packages/<name>/<version
|
|
16
|
-
* reference files in `data/`.
|
|
14
|
+
* It contains all objects needed for the package, plus the package ref at
|
|
15
|
+
* `packages/<name>/<version>.beast2`, as a repository keeps one.
|
|
17
16
|
*
|
|
18
17
|
* @param pkg - The package to export
|
|
19
18
|
* @param outputPath - Path to write the .zip file
|
package/dist/src/export.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/export.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/export.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAmL,KAAK,gBAAgB,EAAqB,MAAM,eAAe,CAAC;AAK1P,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,YAAY,CAAC;AAE1D,OAAO,EAA8C,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACzG,OAAO,EAAqE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAM9H;;;;;;;;;;;;;;;GAeG;AACH;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG,YAAY,CAAC,GAAG,CAAC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG,YAAY,CAAC,CAAC;AAExG,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC5B,8GAA8G;IAC9G,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,gBAAgB,CAAC,CAAC;CAC9C;AAGD,wBAAsB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAuZ3I;AAuCD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKrE"}
|