@elaraai/e3-api-client 0.0.2-beta.4 → 0.0.2-beta.41
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 +2 -2
- package/dist/src/datasets.d.ts +73 -4
- package/dist/src/datasets.d.ts.map +1 -1
- package/dist/src/datasets.js +197 -19
- package/dist/src/datasets.js.map +1 -1
- package/dist/src/executions.d.ts +74 -11
- package/dist/src/executions.d.ts.map +1 -1
- package/dist/src/executions.js +184 -36
- package/dist/src/executions.js.map +1 -1
- package/dist/src/http.d.ts +60 -12
- package/dist/src/http.d.ts.map +1 -1
- package/dist/src/http.js +135 -34
- package/dist/src/http.js.map +1 -1
- package/dist/src/index.d.ts +8 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/packages.d.ts +12 -27
- package/dist/src/packages.d.ts.map +1 -1
- package/dist/src/packages.js +139 -39
- package/dist/src/packages.js.map +1 -1
- package/dist/src/platform.d.ts +553 -1343
- package/dist/src/platform.d.ts.map +1 -1
- package/dist/src/platform.js +123 -915
- package/dist/src/platform.js.map +1 -1
- package/dist/src/repos.d.ts +16 -0
- package/dist/src/repos.d.ts.map +1 -0
- package/dist/src/repos.js +19 -0
- package/dist/src/repos.js.map +1 -0
- package/dist/src/repository.d.ts +67 -5
- package/dist/src/repository.d.ts.map +1 -1
- package/dist/src/repository.js +94 -10
- package/dist/src/repository.js.map +1 -1
- package/dist/src/tasks.d.ts +25 -3
- package/dist/src/tasks.d.ts.map +1 -1
- package/dist/src/tasks.js +29 -8
- package/dist/src/tasks.js.map +1 -1
- package/dist/src/types.d.ts +1360 -716
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +235 -2
- package/dist/src/types.js.map +1 -1
- package/dist/src/workspaces.d.ts +36 -7
- package/dist/src/workspaces.d.ts.map +1 -1
- package/dist/src/workspaces.js +43 -22
- package/dist/src/workspaces.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Stateless functions for interacting with an e3 API server. Uses BEAST2 binary se
|
|
|
20
20
|
import { repoStatus, repoGc } from '@elaraai/e3-api-client';
|
|
21
21
|
|
|
22
22
|
const status = await repoStatus('http://localhost:3000');
|
|
23
|
-
// { path: '/path/to
|
|
23
|
+
// { path: '/path/to/repo', objectCount: 42n, packageCount: 3n, workspaceCount: 2n }
|
|
24
24
|
|
|
25
25
|
const gcResult = await repoGc(url, { dryRun: true, minAge: variant('none', null) });
|
|
26
26
|
// { deletedObjects: 0n, retainedObjects: 42n, bytesFreed: 0n, ... }
|
|
@@ -150,7 +150,7 @@ BSL 1.1. See [LICENSE.md](./LICENSE.md).
|
|
|
150
150
|
- [@elaraai/e3](https://www.npmjs.com/package/@elaraai/e3): SDK for authoring e3 packages with typed tasks and pipelines
|
|
151
151
|
- [@elaraai/e3-core](https://www.npmjs.com/package/@elaraai/e3-core): Git-like object store, task queue, result caching
|
|
152
152
|
- [@elaraai/e3-types](https://www.npmjs.com/package/@elaraai/e3-types): Shared type definitions for e3 packages
|
|
153
|
-
- [@elaraai/e3-cli](https://www.npmjs.com/package/@elaraai/e3-cli): `e3
|
|
153
|
+
- [@elaraai/e3-cli](https://www.npmjs.com/package/@elaraai/e3-cli): `e3 repo`, `e3 workspace`, `e3 start`, `e3 logs` commands for managing repositories, workspaces, and tasks
|
|
154
154
|
- [@elaraai/e3-api-client](https://www.npmjs.com/package/@elaraai/e3-api-client): HTTP client for remote e3 servers
|
|
155
155
|
- [@elaraai/e3-api-server](https://www.npmjs.com/package/@elaraai/e3-api-server): REST API server for e3 repositories
|
|
156
156
|
|
package/dist/src/datasets.d.ts
CHANGED
|
@@ -3,23 +3,33 @@
|
|
|
3
3
|
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
5
|
import type { TreePath } from '@elaraai/e3-types';
|
|
6
|
+
import { type RequestOptions } from './http.js';
|
|
7
|
+
import { type ListEntry, type DatasetStatusDetail } from './types.js';
|
|
6
8
|
/**
|
|
7
9
|
* List field names at root of workspace dataset tree.
|
|
8
10
|
*
|
|
9
11
|
* @param url - Base URL of the e3 API server
|
|
12
|
+
* @param repo - Repository name
|
|
10
13
|
* @param workspace - Workspace name
|
|
14
|
+
* @param options - Request options including auth token
|
|
11
15
|
* @returns Array of field names at root
|
|
16
|
+
* @throws {ApiError} On application-level errors
|
|
17
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
12
18
|
*/
|
|
13
|
-
export declare function datasetList(url: string, workspace: string): Promise<string[]>;
|
|
19
|
+
export declare function datasetList(url: string, repo: string, workspace: string, options: RequestOptions): Promise<string[]>;
|
|
14
20
|
/**
|
|
15
21
|
* List field names at a path in workspace dataset tree.
|
|
16
22
|
*
|
|
17
23
|
* @param url - Base URL of the e3 API server
|
|
24
|
+
* @param repo - Repository name
|
|
18
25
|
* @param workspace - Workspace name
|
|
19
26
|
* @param path - Path to the dataset (e.g., ['inputs', 'config'])
|
|
27
|
+
* @param options - Request options including auth token
|
|
20
28
|
* @returns Array of field names at path
|
|
29
|
+
* @throws {ApiError} On application-level errors
|
|
30
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
21
31
|
*/
|
|
22
|
-
export declare function datasetListAt(url: string, workspace: string, path: TreePath): Promise<string[]>;
|
|
32
|
+
export declare function datasetListAt(url: string, repo: string, workspace: string, path: TreePath, options: RequestOptions): Promise<string[]>;
|
|
23
33
|
/**
|
|
24
34
|
* Get a dataset value as raw BEAST2 bytes.
|
|
25
35
|
*
|
|
@@ -27,18 +37,77 @@ export declare function datasetListAt(url: string, workspace: string, path: Tree
|
|
|
27
37
|
* Use decodeBeast2 or decodeBeast2For to decode with the appropriate type.
|
|
28
38
|
*
|
|
29
39
|
* @param url - Base URL of the e3 API server
|
|
40
|
+
* @param repo - Repository name
|
|
30
41
|
* @param workspace - Workspace name
|
|
31
42
|
* @param path - Path to the dataset (e.g., ['inputs', 'config'])
|
|
43
|
+
* @param options - Request options including auth token
|
|
32
44
|
* @returns Raw BEAST2 bytes
|
|
33
45
|
*/
|
|
34
|
-
export declare function datasetGet(url: string, workspace: string, path: TreePath): Promise<
|
|
46
|
+
export declare function datasetGet(url: string, repo: string, workspace: string, path: TreePath, options: RequestOptions): Promise<{
|
|
47
|
+
data: Uint8Array;
|
|
48
|
+
hash: string;
|
|
49
|
+
size: number;
|
|
50
|
+
}>;
|
|
35
51
|
/**
|
|
36
52
|
* Set a dataset value from raw BEAST2 bytes.
|
|
37
53
|
*
|
|
54
|
+
* For payloads > 1MB, uses a transfer flow (init → upload → complete) to
|
|
55
|
+
* avoid inline body size limits. For smaller payloads, uses inline PUT.
|
|
56
|
+
*
|
|
38
57
|
* @param url - Base URL of the e3 API server
|
|
58
|
+
* @param repo - Repository name
|
|
39
59
|
* @param workspace - Workspace name
|
|
40
60
|
* @param path - Path to the dataset (e.g., ['inputs', 'config'])
|
|
41
61
|
* @param data - Raw BEAST2 encoded value
|
|
62
|
+
* @param options - Request options including auth token
|
|
63
|
+
*/
|
|
64
|
+
export declare function datasetSet(url: string, repo: string, workspace: string, path: TreePath, data: Uint8Array, options: RequestOptions): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* List all entries recursively under a path (flat list of datasets and trees).
|
|
67
|
+
*
|
|
68
|
+
* @param url - Base URL of the e3 API server
|
|
69
|
+
* @param repo - Repository name
|
|
70
|
+
* @param workspace - Workspace name
|
|
71
|
+
* @param path - Starting path (empty for root)
|
|
72
|
+
* @param options - Request options including auth token
|
|
73
|
+
* @returns Array of list entries (dataset or tree variants) with path, type, hash, and size
|
|
74
|
+
* @throws {ApiError} On application-level errors
|
|
75
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
76
|
+
*/
|
|
77
|
+
export declare function datasetListRecursive(url: string, repo: string, workspace: string, path: TreePath, options: RequestOptions): Promise<ListEntry[]>;
|
|
78
|
+
/**
|
|
79
|
+
* List all descendant dataset paths recursively (paths only, no types/status).
|
|
80
|
+
*
|
|
81
|
+
* @param url - Base URL of the e3 API server
|
|
82
|
+
* @param repo - Repository name
|
|
83
|
+
* @param workspace - Workspace name
|
|
84
|
+
* @param path - Starting path (empty for root)
|
|
85
|
+
* @param options - Request options including auth token
|
|
86
|
+
* @returns Array of dataset path strings
|
|
87
|
+
*/
|
|
88
|
+
export declare function datasetListRecursivePaths(url: string, repo: string, workspace: string, path: TreePath, options: RequestOptions): Promise<string[]>;
|
|
89
|
+
/**
|
|
90
|
+
* List immediate children with type, hash, and size details.
|
|
91
|
+
*
|
|
92
|
+
* @param url - Base URL of the e3 API server
|
|
93
|
+
* @param repo - Repository name
|
|
94
|
+
* @param workspace - Workspace name
|
|
95
|
+
* @param path - Path to list (empty for root)
|
|
96
|
+
* @param options - Request options including auth token
|
|
97
|
+
* @returns Array of list entries (dataset or tree variants) with path, type, hash, and size
|
|
98
|
+
*/
|
|
99
|
+
export declare function datasetListWithStatus(url: string, repo: string, workspace: string, path: TreePath, options: RequestOptions): Promise<ListEntry[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Get status detail for a single dataset.
|
|
102
|
+
*
|
|
103
|
+
* @param url - Base URL of the e3 API server
|
|
104
|
+
* @param repo - Repository name
|
|
105
|
+
* @param workspace - Workspace name
|
|
106
|
+
* @param path - Path to the dataset
|
|
107
|
+
* @param options - Request options including auth token
|
|
108
|
+
* @returns Dataset status detail including path, type, refType, hash, and size
|
|
109
|
+
* @throws {ApiError} On application-level errors
|
|
110
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
42
111
|
*/
|
|
43
|
-
export declare function
|
|
112
|
+
export declare function datasetGetStatus(url: string, repo: string, workspace: string, path: TreePath, options: RequestOptions): Promise<DatasetStatusDetail>;
|
|
44
113
|
//# sourceMappingURL=datasets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasets.d.ts","sourceRoot":"","sources":["../../src/datasets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,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mFD;;;;;;;;;;;GAWG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,SAAS,EAAE,CAAC,CAGtB;AAED;;;;;;;;;GASG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,MAAM,EAAE,CAAC,CAGnB;AAED;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,SAAS,EAAE,CAAC,CAGtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,mBAAmB,CAAC,CAQ9B"}
|
package/dist/src/datasets.js
CHANGED
|
@@ -2,31 +2,47 @@
|
|
|
2
2
|
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
3
|
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
|
-
import { ArrayType, StringType } from '@elaraai/east';
|
|
6
|
-
import {
|
|
5
|
+
import { ArrayType, NullType, StringType, decodeBeast2For, encodeBeast2For } from '@elaraai/east';
|
|
6
|
+
import { BEAST2_CONTENT_TYPE, computeHash } from '@elaraai/e3-core';
|
|
7
|
+
import { ApiError, fetchWithAuth, get } from './http.js';
|
|
8
|
+
import { ResponseType, DatasetStatusDetailType, ListEntryType, TransferUploadRequestType, TransferUploadResponseType, TransferDoneResponseType, } from './types.js';
|
|
9
|
+
function datasetEndpoint(repo, workspace, path) {
|
|
10
|
+
let endpoint = `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets`;
|
|
11
|
+
if (path.length > 0) {
|
|
12
|
+
const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
|
|
13
|
+
endpoint = `${endpoint}/${pathStr}`;
|
|
14
|
+
}
|
|
15
|
+
return endpoint;
|
|
16
|
+
}
|
|
7
17
|
/**
|
|
8
18
|
* List field names at root of workspace dataset tree.
|
|
9
19
|
*
|
|
10
20
|
* @param url - Base URL of the e3 API server
|
|
21
|
+
* @param repo - Repository name
|
|
11
22
|
* @param workspace - Workspace name
|
|
23
|
+
* @param options - Request options including auth token
|
|
12
24
|
* @returns Array of field names at root
|
|
25
|
+
* @throws {ApiError} On application-level errors
|
|
26
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
13
27
|
*/
|
|
14
|
-
export async function datasetList(url, workspace) {
|
|
15
|
-
|
|
16
|
-
return unwrap(response);
|
|
28
|
+
export async function datasetList(url, repo, workspace, options) {
|
|
29
|
+
return get(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets`, ArrayType(StringType), options);
|
|
17
30
|
}
|
|
18
31
|
/**
|
|
19
32
|
* List field names at a path in workspace dataset tree.
|
|
20
33
|
*
|
|
21
34
|
* @param url - Base URL of the e3 API server
|
|
35
|
+
* @param repo - Repository name
|
|
22
36
|
* @param workspace - Workspace name
|
|
23
37
|
* @param path - Path to the dataset (e.g., ['inputs', 'config'])
|
|
38
|
+
* @param options - Request options including auth token
|
|
24
39
|
* @returns Array of field names at path
|
|
40
|
+
* @throws {ApiError} On application-level errors
|
|
41
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
25
42
|
*/
|
|
26
|
-
export async function datasetListAt(url, workspace, path) {
|
|
43
|
+
export async function datasetListAt(url, repo, workspace, path, options) {
|
|
27
44
|
const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
|
|
28
|
-
|
|
29
|
-
return unwrap(response);
|
|
45
|
+
return get(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets/${pathStr}?list=true`, ArrayType(StringType), options);
|
|
30
46
|
}
|
|
31
47
|
/**
|
|
32
48
|
* Get a dataset value as raw BEAST2 bytes.
|
|
@@ -35,43 +51,205 @@ export async function datasetListAt(url, workspace, path) {
|
|
|
35
51
|
* Use decodeBeast2 or decodeBeast2For to decode with the appropriate type.
|
|
36
52
|
*
|
|
37
53
|
* @param url - Base URL of the e3 API server
|
|
54
|
+
* @param repo - Repository name
|
|
38
55
|
* @param workspace - Workspace name
|
|
39
56
|
* @param path - Path to the dataset (e.g., ['inputs', 'config'])
|
|
57
|
+
* @param options - Request options including auth token
|
|
40
58
|
* @returns Raw BEAST2 bytes
|
|
41
59
|
*/
|
|
42
|
-
export async function datasetGet(url, workspace, path) {
|
|
60
|
+
export async function datasetGet(url, repo, workspace, path, options) {
|
|
43
61
|
const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
|
|
44
|
-
const response = await
|
|
62
|
+
const response = await fetchWithAuth(`${url}/api/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets/${pathStr}`, {
|
|
45
63
|
method: 'GET',
|
|
46
|
-
headers: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
headers: { 'Accept': BEAST2_CONTENT_TYPE },
|
|
65
|
+
redirect: 'manual',
|
|
66
|
+
}, options);
|
|
67
|
+
// Handle 307 redirect — follow WITHOUT auth headers (target is a no-auth data endpoint)
|
|
68
|
+
if (response.status === 307) {
|
|
69
|
+
const location = response.headers.get('Location');
|
|
70
|
+
if (!location)
|
|
71
|
+
throw new Error('307 redirect missing Location header');
|
|
72
|
+
// Resolve relative URLs against the request origin
|
|
73
|
+
const redirectUrl = location.startsWith('/') ? `${url}${location}` : location;
|
|
74
|
+
const redirectResponse = await fetch(redirectUrl, {
|
|
75
|
+
method: 'GET',
|
|
76
|
+
headers: { 'Accept': BEAST2_CONTENT_TYPE },
|
|
77
|
+
});
|
|
78
|
+
if (!redirectResponse.ok) {
|
|
79
|
+
throw new Error(`Failed to get dataset (redirect): ${redirectResponse.status} ${redirectResponse.statusText}`);
|
|
80
|
+
}
|
|
81
|
+
const buffer = await redirectResponse.arrayBuffer();
|
|
82
|
+
const data = new Uint8Array(buffer);
|
|
83
|
+
const hash = redirectResponse.headers.get('X-Content-SHA256') ?? response.headers.get('X-Content-SHA256') ?? '';
|
|
84
|
+
const size = parseInt(redirectResponse.headers.get('Content-Length') ?? response.headers.get('X-Content-Length') ?? '0', 10);
|
|
85
|
+
return { data, hash, size };
|
|
86
|
+
}
|
|
50
87
|
if (!response.ok) {
|
|
51
88
|
throw new Error(`Failed to get dataset: ${response.status} ${response.statusText}`);
|
|
52
89
|
}
|
|
53
90
|
const buffer = await response.arrayBuffer();
|
|
54
|
-
|
|
91
|
+
const data = new Uint8Array(buffer);
|
|
92
|
+
const hash = response.headers.get('X-Content-SHA256') ?? '';
|
|
93
|
+
const size = parseInt(response.headers.get('Content-Length') ?? '0', 10);
|
|
94
|
+
return { data, hash, size };
|
|
55
95
|
}
|
|
96
|
+
const SIZE_THRESHOLD = 1 * 1024 * 1024; // 1 MB
|
|
56
97
|
/**
|
|
57
98
|
* Set a dataset value from raw BEAST2 bytes.
|
|
58
99
|
*
|
|
100
|
+
* For payloads > 1MB, uses a transfer flow (init → upload → complete) to
|
|
101
|
+
* avoid inline body size limits. For smaller payloads, uses inline PUT.
|
|
102
|
+
*
|
|
59
103
|
* @param url - Base URL of the e3 API server
|
|
104
|
+
* @param repo - Repository name
|
|
60
105
|
* @param workspace - Workspace name
|
|
61
106
|
* @param path - Path to the dataset (e.g., ['inputs', 'config'])
|
|
62
107
|
* @param data - Raw BEAST2 encoded value
|
|
108
|
+
* @param options - Request options including auth token
|
|
63
109
|
*/
|
|
64
|
-
export async function datasetSet(url, workspace, path, data) {
|
|
110
|
+
export async function datasetSet(url, repo, workspace, path, data, options) {
|
|
111
|
+
if (data.byteLength > SIZE_THRESHOLD) {
|
|
112
|
+
return datasetSetTransfer(url, repo, workspace, path, data, options);
|
|
113
|
+
}
|
|
65
114
|
const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
|
|
66
|
-
const response = await
|
|
115
|
+
const response = await fetchWithAuth(`${url}/api/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets/${pathStr}`, {
|
|
67
116
|
method: 'PUT',
|
|
68
117
|
headers: {
|
|
69
|
-
'Content-Type':
|
|
118
|
+
'Content-Type': BEAST2_CONTENT_TYPE,
|
|
119
|
+
'Accept': BEAST2_CONTENT_TYPE,
|
|
70
120
|
},
|
|
71
121
|
body: data,
|
|
72
|
-
});
|
|
122
|
+
}, options);
|
|
73
123
|
if (!response.ok) {
|
|
74
124
|
throw new Error(`Failed to set dataset: ${response.status} ${response.statusText}`);
|
|
75
125
|
}
|
|
126
|
+
// Decode BEAST2 response to check for application-level errors
|
|
127
|
+
const buffer = await response.arrayBuffer();
|
|
128
|
+
const decode = decodeBeast2For(ResponseType(NullType));
|
|
129
|
+
const result = decode(new Uint8Array(buffer));
|
|
130
|
+
if (result.type === 'error') {
|
|
131
|
+
throw new ApiError(result.value.type, result.value.value);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Set a large dataset using the transfer flow (init → upload → complete).
|
|
136
|
+
*/
|
|
137
|
+
async function datasetSetTransfer(url, repo, workspace, path, data, options) {
|
|
138
|
+
const hash = computeHash(data);
|
|
139
|
+
const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
|
|
140
|
+
const repoEncoded = encodeURIComponent(repo);
|
|
141
|
+
const wsEncoded = encodeURIComponent(workspace);
|
|
142
|
+
// 1. Init transfer (BEAST2 request/response)
|
|
143
|
+
const encodeInit = encodeBeast2For(TransferUploadRequestType);
|
|
144
|
+
const initRes = await fetchWithAuth(`${url}/api/repos/${repoEncoded}/workspaces/${wsEncoded}/datasets/${pathStr}/upload`, {
|
|
145
|
+
method: 'POST',
|
|
146
|
+
headers: {
|
|
147
|
+
'Content-Type': BEAST2_CONTENT_TYPE,
|
|
148
|
+
'Accept': BEAST2_CONTENT_TYPE,
|
|
149
|
+
},
|
|
150
|
+
body: encodeInit({ hash, size: BigInt(data.byteLength) }),
|
|
151
|
+
}, options);
|
|
152
|
+
if (!initRes.ok) {
|
|
153
|
+
throw new Error(`Transfer init failed: ${initRes.status} ${initRes.statusText}`);
|
|
154
|
+
}
|
|
155
|
+
const initBuffer = new Uint8Array(await initRes.arrayBuffer());
|
|
156
|
+
const decodeInit = decodeBeast2For(ResponseType(TransferUploadResponseType));
|
|
157
|
+
const initResult = decodeInit(initBuffer);
|
|
158
|
+
if (initResult.type === 'error') {
|
|
159
|
+
throw new ApiError(initResult.value.type, initResult.value.value);
|
|
160
|
+
}
|
|
161
|
+
const init = initResult.value;
|
|
162
|
+
// Dedup — object already exists, ref updated
|
|
163
|
+
if (init.type === 'completed')
|
|
164
|
+
return;
|
|
165
|
+
// 2. Upload to staging (no auth — URL may be a presigned S3 URL)
|
|
166
|
+
const uploadRes = await fetch(init.value.uploadUrl, {
|
|
167
|
+
method: 'PUT',
|
|
168
|
+
headers: {
|
|
169
|
+
'Content-Type': BEAST2_CONTENT_TYPE,
|
|
170
|
+
'Accept': BEAST2_CONTENT_TYPE,
|
|
171
|
+
},
|
|
172
|
+
body: data,
|
|
173
|
+
});
|
|
174
|
+
if (!uploadRes.ok) {
|
|
175
|
+
throw new Error(`Transfer upload failed: ${uploadRes.status} ${uploadRes.statusText}`);
|
|
176
|
+
}
|
|
177
|
+
// 3. Commit — server verifies hash + updates ref (BEAST2 response)
|
|
178
|
+
const commitRes = await fetchWithAuth(`${url}/api/repos/${repoEncoded}/workspaces/${wsEncoded}/datasets/${pathStr}/upload/${init.value.id}`, {
|
|
179
|
+
method: 'POST',
|
|
180
|
+
headers: { 'Accept': BEAST2_CONTENT_TYPE },
|
|
181
|
+
}, options);
|
|
182
|
+
if (!commitRes.ok) {
|
|
183
|
+
throw new Error(`Transfer commit failed: ${commitRes.status} ${commitRes.statusText}`);
|
|
184
|
+
}
|
|
185
|
+
const commitBuffer = new Uint8Array(await commitRes.arrayBuffer());
|
|
186
|
+
const decodeDone = decodeBeast2For(ResponseType(TransferDoneResponseType));
|
|
187
|
+
const commitResult = decodeDone(commitBuffer);
|
|
188
|
+
if (commitResult.type === 'error') {
|
|
189
|
+
throw new ApiError(commitResult.value.type, commitResult.value.value);
|
|
190
|
+
}
|
|
191
|
+
if (commitResult.value.type === 'error') {
|
|
192
|
+
throw new Error(`Transfer failed: ${commitResult.value.value.message}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* List all entries recursively under a path (flat list of datasets and trees).
|
|
197
|
+
*
|
|
198
|
+
* @param url - Base URL of the e3 API server
|
|
199
|
+
* @param repo - Repository name
|
|
200
|
+
* @param workspace - Workspace name
|
|
201
|
+
* @param path - Starting path (empty for root)
|
|
202
|
+
* @param options - Request options including auth token
|
|
203
|
+
* @returns Array of list entries (dataset or tree variants) with path, type, hash, and size
|
|
204
|
+
* @throws {ApiError} On application-level errors
|
|
205
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
206
|
+
*/
|
|
207
|
+
export async function datasetListRecursive(url, repo, workspace, path, options) {
|
|
208
|
+
const endpoint = `${datasetEndpoint(repo, workspace, path)}?list=true&recursive=true&status=true`;
|
|
209
|
+
return get(url, endpoint, ArrayType(ListEntryType), options);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* List all descendant dataset paths recursively (paths only, no types/status).
|
|
213
|
+
*
|
|
214
|
+
* @param url - Base URL of the e3 API server
|
|
215
|
+
* @param repo - Repository name
|
|
216
|
+
* @param workspace - Workspace name
|
|
217
|
+
* @param path - Starting path (empty for root)
|
|
218
|
+
* @param options - Request options including auth token
|
|
219
|
+
* @returns Array of dataset path strings
|
|
220
|
+
*/
|
|
221
|
+
export async function datasetListRecursivePaths(url, repo, workspace, path, options) {
|
|
222
|
+
const endpoint = `${datasetEndpoint(repo, workspace, path)}?list=true&recursive=true`;
|
|
223
|
+
return get(url, endpoint, ArrayType(StringType), options);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* List immediate children with type, hash, and size details.
|
|
227
|
+
*
|
|
228
|
+
* @param url - Base URL of the e3 API server
|
|
229
|
+
* @param repo - Repository name
|
|
230
|
+
* @param workspace - Workspace name
|
|
231
|
+
* @param path - Path to list (empty for root)
|
|
232
|
+
* @param options - Request options including auth token
|
|
233
|
+
* @returns Array of list entries (dataset or tree variants) with path, type, hash, and size
|
|
234
|
+
*/
|
|
235
|
+
export async function datasetListWithStatus(url, repo, workspace, path, options) {
|
|
236
|
+
const endpoint = `${datasetEndpoint(repo, workspace, path)}?list=true&status=true`;
|
|
237
|
+
return get(url, endpoint, ArrayType(ListEntryType), options);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Get status detail for a single dataset.
|
|
241
|
+
*
|
|
242
|
+
* @param url - Base URL of the e3 API server
|
|
243
|
+
* @param repo - Repository name
|
|
244
|
+
* @param workspace - Workspace name
|
|
245
|
+
* @param path - Path to the dataset
|
|
246
|
+
* @param options - Request options including auth token
|
|
247
|
+
* @returns Dataset status detail including path, type, refType, hash, and size
|
|
248
|
+
* @throws {ApiError} On application-level errors
|
|
249
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
250
|
+
*/
|
|
251
|
+
export async function datasetGetStatus(url, repo, workspace, path, options) {
|
|
252
|
+
const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
|
|
253
|
+
return get(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets/${pathStr}?status=true`, DatasetStatusDetailType, options);
|
|
76
254
|
}
|
|
77
255
|
//# sourceMappingURL=datasets.js.map
|
package/dist/src/datasets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasets.js","sourceRoot":"","sources":["../../src/datasets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"datasets.js","sourceRoot":"","sources":["../../src/datasets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAElG,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAsC,MAAM,WAAW,CAAC;AAC7F,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,aAAa,EACb,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,GAKzB,MAAM,YAAY,CAAC;AAEpB,SAAS,eAAe,CAAC,IAAY,EAAE,SAAiB,EAAE,IAAc;IACtE,IAAI,QAAQ,GAAG,UAAU,kBAAkB,CAAC,IAAI,CAAC,eAAe,kBAAkB,CAAC,SAAS,CAAC,WAAW,CAAC;IACzG,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrE,QAAQ,GAAG,GAAG,QAAQ,IAAI,OAAO,EAAE,CAAC;IACtC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW,EAAE,IAAY,EAAE,SAAiB,EAAE,OAAuB;IACrG,OA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,SAAS,CAAC,aAAa,OAAO,cAAc,EAChH,uBAAuB,EACvB,OAAO,CACR,CAAC;AACJ,CAAC"}
|
package/dist/src/executions.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
3
|
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
|
-
import type { LogChunk, DataflowGraph, DataflowResult } from './types.js';
|
|
5
|
+
import type { LogChunk, DataflowGraph, DataflowResult, DataflowExecutionState } from './types.js';
|
|
6
|
+
import { type RequestOptions } from './http.js';
|
|
6
7
|
/**
|
|
7
8
|
* Options for starting dataflow execution.
|
|
8
9
|
*/
|
|
@@ -14,36 +15,57 @@ export interface DataflowOptions {
|
|
|
14
15
|
/** Filter to specific task names */
|
|
15
16
|
filter?: string;
|
|
16
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Options for polling during dataflow execution.
|
|
20
|
+
*/
|
|
21
|
+
export interface DataflowPollOptions {
|
|
22
|
+
/** Interval between polls in milliseconds (default: 500) */
|
|
23
|
+
pollInterval?: number;
|
|
24
|
+
/** Maximum time to wait for completion in milliseconds (default: 300000 = 5 minutes) */
|
|
25
|
+
timeout?: number;
|
|
26
|
+
}
|
|
17
27
|
/**
|
|
18
28
|
* Start dataflow execution on a workspace (non-blocking).
|
|
19
29
|
*
|
|
20
30
|
* Returns immediately after spawning execution in background.
|
|
21
|
-
* Use
|
|
31
|
+
* Use dataflowExecutePoll() to poll for progress.
|
|
22
32
|
*
|
|
23
33
|
* @param url - Base URL of the e3 API server
|
|
34
|
+
* @param repo - Repository name
|
|
24
35
|
* @param workspace - Workspace name
|
|
25
|
-
* @param
|
|
36
|
+
* @param dataflowOptions - Execution options
|
|
37
|
+
* @param options - Request options including auth token
|
|
38
|
+
* @throws {ApiError} On application-level errors
|
|
39
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
26
40
|
*/
|
|
27
|
-
export declare function
|
|
41
|
+
export declare function dataflowExecuteLaunch(url: string, repo: string, workspace: string, dataflowOptions: DataflowOptions | undefined, options: RequestOptions): Promise<void>;
|
|
28
42
|
/**
|
|
29
|
-
* Execute dataflow on a workspace
|
|
43
|
+
* Execute dataflow on a workspace with client-side polling.
|
|
30
44
|
*
|
|
31
|
-
*
|
|
45
|
+
* Starts execution, polls until complete, and returns the result.
|
|
32
46
|
*
|
|
33
47
|
* @param url - Base URL of the e3 API server
|
|
48
|
+
* @param repo - Repository name
|
|
34
49
|
* @param workspace - Workspace name
|
|
35
|
-
* @param
|
|
50
|
+
* @param dataflowOptions - Execution options
|
|
51
|
+
* @param options - Request options including auth token
|
|
52
|
+
* @param pollOptions - Polling configuration
|
|
36
53
|
* @returns Dataflow execution result
|
|
37
54
|
*/
|
|
38
|
-
export declare function dataflowExecute(url: string, workspace: string, options?:
|
|
55
|
+
export declare function dataflowExecute(url: string, repo: string, workspace: string, dataflowOptions: DataflowOptions | undefined, options: RequestOptions, pollOptions?: DataflowPollOptions): Promise<DataflowResult>;
|
|
56
|
+
export { dataflowExecuteLaunch as dataflowStart };
|
|
39
57
|
/**
|
|
40
58
|
* Get the dependency graph for a workspace.
|
|
41
59
|
*
|
|
42
60
|
* @param url - Base URL of the e3 API server
|
|
61
|
+
* @param repo - Repository name
|
|
43
62
|
* @param workspace - Workspace name
|
|
63
|
+
* @param options - Request options including auth token
|
|
44
64
|
* @returns Dataflow graph with tasks and dependencies
|
|
65
|
+
* @throws {ApiError} On application-level errors
|
|
66
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
45
67
|
*/
|
|
46
|
-
export declare function dataflowGraph(url: string, workspace: string): Promise<DataflowGraph>;
|
|
68
|
+
export declare function dataflowGraph(url: string, repo: string, workspace: string, options: RequestOptions): Promise<DataflowGraph>;
|
|
47
69
|
/**
|
|
48
70
|
* Options for reading task logs.
|
|
49
71
|
*/
|
|
@@ -59,10 +81,51 @@ export interface LogOptions {
|
|
|
59
81
|
* Read task logs from a workspace.
|
|
60
82
|
*
|
|
61
83
|
* @param url - Base URL of the e3 API server
|
|
84
|
+
* @param repo - Repository name
|
|
62
85
|
* @param workspace - Workspace name
|
|
63
86
|
* @param task - Task name
|
|
64
|
-
* @param
|
|
87
|
+
* @param logOptions - Log reading options
|
|
88
|
+
* @param options - Request options including auth token
|
|
65
89
|
* @returns Log chunk with data and metadata
|
|
90
|
+
* @throws {ApiError} On application-level errors
|
|
91
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
92
|
+
*/
|
|
93
|
+
export declare function taskLogs(url: string, repo: string, workspace: string, task: string, logOptions: LogOptions | undefined, options: RequestOptions): Promise<LogChunk>;
|
|
94
|
+
/**
|
|
95
|
+
* Options for getting execution state.
|
|
96
|
+
*/
|
|
97
|
+
export interface ExecutionStateOptions {
|
|
98
|
+
/** Skip first N events (default: 0) */
|
|
99
|
+
offset?: number;
|
|
100
|
+
/** Maximum events to return (default: all) */
|
|
101
|
+
limit?: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get dataflow execution state (for polling).
|
|
105
|
+
*
|
|
106
|
+
* Returns the current execution state including events for progress tracking.
|
|
107
|
+
* Use offset/limit for pagination of events.
|
|
108
|
+
*
|
|
109
|
+
* @param url - Base URL of the e3 API server
|
|
110
|
+
* @param repo - Repository name
|
|
111
|
+
* @param workspace - Workspace name
|
|
112
|
+
* @param stateOptions - Pagination options for events
|
|
113
|
+
* @param options - Request options including auth token
|
|
114
|
+
* @returns Execution state with events and summary
|
|
115
|
+
* @throws {ApiError} On application-level errors
|
|
116
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
117
|
+
*/
|
|
118
|
+
export declare function dataflowExecutePoll(url: string, repo: string, workspace: string, stateOptions: ExecutionStateOptions | undefined, options: RequestOptions): Promise<DataflowExecutionState>;
|
|
119
|
+
export { dataflowExecutePoll as dataflowExecution };
|
|
120
|
+
/**
|
|
121
|
+
* Cancel a running dataflow execution.
|
|
122
|
+
*
|
|
123
|
+
* @param url - Base URL of the API server
|
|
124
|
+
* @param repo - Repository name
|
|
125
|
+
* @param workspace - Workspace name
|
|
126
|
+
* @param options - Request options (token, etc.)
|
|
127
|
+
* @throws {ApiError} If cancellation fails or no execution is running
|
|
128
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
66
129
|
*/
|
|
67
|
-
export declare function
|
|
130
|
+
export declare function dataflowCancel(url: string, repo: string, workspace: string, options: RequestOptions): Promise<void>;
|
|
68
131
|
//# sourceMappingURL=executions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executions.d.ts","sourceRoot":"","sources":["../../src/executions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"executions.d.ts","sourceRoot":"","sources":["../../src/executions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,sBAAsB,EAAuB,MAAM,YAAY,CAAC;AAOvH,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,eAAe,YAAK,EACrC,OA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