@elaraai/e3-api-client 0.0.2-beta.5 → 0.0.2-beta.50

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.
Files changed (50) hide show
  1. package/README.md +2 -2
  2. package/dist/src/datasets.d.ts +73 -4
  3. package/dist/src/datasets.d.ts.map +1 -1
  4. package/dist/src/datasets.js +194 -19
  5. package/dist/src/datasets.js.map +1 -1
  6. package/dist/src/executions.d.ts +74 -11
  7. package/dist/src/executions.d.ts.map +1 -1
  8. package/dist/src/executions.js +184 -36
  9. package/dist/src/executions.js.map +1 -1
  10. package/dist/src/http.d.ts +67 -12
  11. package/dist/src/http.d.ts.map +1 -1
  12. package/dist/src/http.js +168 -34
  13. package/dist/src/http.js.map +1 -1
  14. package/dist/src/index.d.ts +9 -6
  15. package/dist/src/index.d.ts.map +1 -1
  16. package/dist/src/index.js +11 -5
  17. package/dist/src/index.js.map +1 -1
  18. package/dist/src/packages.d.ts +32 -27
  19. package/dist/src/packages.d.ts.map +1 -1
  20. package/dist/src/packages.js +175 -39
  21. package/dist/src/packages.js.map +1 -1
  22. package/dist/src/platform.d.ts +553 -1343
  23. package/dist/src/platform.d.ts.map +1 -1
  24. package/dist/src/platform.js +123 -915
  25. package/dist/src/platform.js.map +1 -1
  26. package/dist/src/repos.d.ts +16 -0
  27. package/dist/src/repos.d.ts.map +1 -0
  28. package/dist/src/repos.js +19 -0
  29. package/dist/src/repos.js.map +1 -0
  30. package/dist/src/repository.d.ts +67 -5
  31. package/dist/src/repository.d.ts.map +1 -1
  32. package/dist/src/repository.js +94 -10
  33. package/dist/src/repository.js.map +1 -1
  34. package/dist/src/tasks.d.ts +25 -3
  35. package/dist/src/tasks.d.ts.map +1 -1
  36. package/dist/src/tasks.js +29 -8
  37. package/dist/src/tasks.js.map +1 -1
  38. package/dist/src/types.d.ts +755 -1251
  39. package/dist/src/types.d.ts.map +1 -1
  40. package/dist/src/types.js +62 -453
  41. package/dist/src/types.js.map +1 -1
  42. package/dist/src/util.d.ts +21 -0
  43. package/dist/src/util.d.ts.map +1 -0
  44. package/dist/src/util.js +26 -0
  45. package/dist/src/util.js.map +1 -0
  46. package/dist/src/workspaces.d.ts +51 -9
  47. package/dist/src/workspaces.d.ts.map +1 -1
  48. package/dist/src/workspaces.js +87 -26
  49. package/dist/src/workspaces.js.map +1 -1
  50. 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/.e3', objectCount: 42n, packageCount: 3n, workspaceCount: 2n }
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 init`, `e3 run`, `e3 logs` commands for managing and monitoring tasks
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
 
@@ -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<Uint8Array>;
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 datasetSet(url: string, workspace: string, path: TreePath, data: Uint8Array): Promise<void>;
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,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAOnF;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,UAAU,CAAC,CAkBrB;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,U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;;;;;;;;;;;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"}
@@ -2,31 +2,48 @@
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 { get, unwrap } from './http.js';
5
+ import { ArrayType, NullType, StringType, decodeBeast2For, encodeBeast2For } from '@elaraai/east';
6
+ import { BEAST2_CONTENT_TYPE } from '@elaraai/e3-types';
7
+ import { computeHash } from './util.js';
8
+ import { ApiError, fetchWithAuth, get } from './http.js';
9
+ import { ResponseType, DatasetStatusDetailType, ListEntryType, TransferUploadRequestType, TransferUploadResponseType, TransferDoneResponseType, } from './types.js';
10
+ function datasetEndpoint(repo, workspace, path) {
11
+ let endpoint = `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets`;
12
+ if (path.length > 0) {
13
+ const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
14
+ endpoint = `${endpoint}/${pathStr}`;
15
+ }
16
+ return endpoint;
17
+ }
7
18
  /**
8
19
  * List field names at root of workspace dataset tree.
9
20
  *
10
21
  * @param url - Base URL of the e3 API server
22
+ * @param repo - Repository name
11
23
  * @param workspace - Workspace name
24
+ * @param options - Request options including auth token
12
25
  * @returns Array of field names at root
26
+ * @throws {ApiError} On application-level errors
27
+ * @throws {AuthError} On 401 Unauthorized
13
28
  */
14
- export async function datasetList(url, workspace) {
15
- const response = await get(url, `/api/workspaces/${encodeURIComponent(workspace)}/list`, ArrayType(StringType));
16
- return unwrap(response);
29
+ export async function datasetList(url, repo, workspace, options) {
30
+ return get(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets`, ArrayType(StringType), options);
17
31
  }
18
32
  /**
19
33
  * List field names at a path in workspace dataset tree.
20
34
  *
21
35
  * @param url - Base URL of the e3 API server
36
+ * @param repo - Repository name
22
37
  * @param workspace - Workspace name
23
38
  * @param path - Path to the dataset (e.g., ['inputs', 'config'])
39
+ * @param options - Request options including auth token
24
40
  * @returns Array of field names at path
41
+ * @throws {ApiError} On application-level errors
42
+ * @throws {AuthError} On 401 Unauthorized
25
43
  */
26
- export async function datasetListAt(url, workspace, path) {
44
+ export async function datasetListAt(url, repo, workspace, path, options) {
27
45
  const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
28
- const response = await get(url, `/api/workspaces/${encodeURIComponent(workspace)}/list/${pathStr}`, ArrayType(StringType));
29
- return unwrap(response);
46
+ return get(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets/${pathStr}?list=true`, ArrayType(StringType), options);
30
47
  }
31
48
  /**
32
49
  * Get a dataset value as raw BEAST2 bytes.
@@ -35,43 +52,201 @@ export async function datasetListAt(url, workspace, path) {
35
52
  * Use decodeBeast2 or decodeBeast2For to decode with the appropriate type.
36
53
  *
37
54
  * @param url - Base URL of the e3 API server
55
+ * @param repo - Repository name
38
56
  * @param workspace - Workspace name
39
57
  * @param path - Path to the dataset (e.g., ['inputs', 'config'])
58
+ * @param options - Request options including auth token
40
59
  * @returns Raw BEAST2 bytes
41
60
  */
42
- export async function datasetGet(url, workspace, path) {
61
+ export async function datasetGet(url, repo, workspace, path, options) {
43
62
  const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
44
- const response = await fetch(`${url}/api/workspaces/${encodeURIComponent(workspace)}/get/${pathStr}`, {
63
+ const response = await fetchWithAuth(`${url}/api/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets/${pathStr}`, {
45
64
  method: 'GET',
46
- headers: {
47
- 'Accept': 'application/beast2',
48
- },
49
- });
65
+ headers: { 'Accept': BEAST2_CONTENT_TYPE },
66
+ }, options);
50
67
  if (!response.ok) {
51
68
  throw new Error(`Failed to get dataset: ${response.status} ${response.statusText}`);
52
69
  }
70
+ // Handle redirect response — server returns JSON with download URL for large datasets
71
+ const contentType = response.headers.get('Content-Type') ?? '';
72
+ if (contentType.includes('application/json')) {
73
+ const body = await response.json();
74
+ const redirectResponse = await fetch(body.url, {
75
+ method: 'GET',
76
+ headers: { 'Accept': BEAST2_CONTENT_TYPE },
77
+ });
78
+ if (!redirectResponse.ok) {
79
+ throw new Error(`Failed to get dataset (download): ${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
+ }
53
87
  const buffer = await response.arrayBuffer();
54
- return new Uint8Array(buffer);
88
+ const data = new Uint8Array(buffer);
89
+ const hash = response.headers.get('X-Content-SHA256') ?? '';
90
+ const size = parseInt(response.headers.get('Content-Length') ?? '0', 10);
91
+ return { data, hash, size };
55
92
  }
93
+ const SIZE_THRESHOLD = 1 * 1024 * 1024; // 1 MB
56
94
  /**
57
95
  * Set a dataset value from raw BEAST2 bytes.
58
96
  *
97
+ * For payloads > 1MB, uses a transfer flow (init → upload → complete) to
98
+ * avoid inline body size limits. For smaller payloads, uses inline PUT.
99
+ *
59
100
  * @param url - Base URL of the e3 API server
101
+ * @param repo - Repository name
60
102
  * @param workspace - Workspace name
61
103
  * @param path - Path to the dataset (e.g., ['inputs', 'config'])
62
104
  * @param data - Raw BEAST2 encoded value
105
+ * @param options - Request options including auth token
63
106
  */
64
- export async function datasetSet(url, workspace, path, data) {
107
+ export async function datasetSet(url, repo, workspace, path, data, options) {
108
+ if (data.byteLength > SIZE_THRESHOLD) {
109
+ return datasetSetTransfer(url, repo, workspace, path, data, options);
110
+ }
65
111
  const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
66
- const response = await fetch(`${url}/api/workspaces/${encodeURIComponent(workspace)}/set/${pathStr}`, {
112
+ const response = await fetchWithAuth(`${url}/api/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets/${pathStr}`, {
67
113
  method: 'PUT',
68
114
  headers: {
69
- 'Content-Type': 'application/beast2',
115
+ 'Content-Type': BEAST2_CONTENT_TYPE,
116
+ 'Accept': BEAST2_CONTENT_TYPE,
70
117
  },
71
118
  body: data,
72
- });
119
+ }, options);
73
120
  if (!response.ok) {
74
121
  throw new Error(`Failed to set dataset: ${response.status} ${response.statusText}`);
75
122
  }
123
+ // Decode BEAST2 response to check for application-level errors
124
+ const buffer = await response.arrayBuffer();
125
+ const decode = decodeBeast2For(ResponseType(NullType));
126
+ const result = decode(new Uint8Array(buffer));
127
+ if (result.type === 'error') {
128
+ throw new ApiError(result.value.type, result.value.value);
129
+ }
130
+ }
131
+ /**
132
+ * Set a large dataset using the transfer flow (init → upload → complete).
133
+ */
134
+ async function datasetSetTransfer(url, repo, workspace, path, data, options) {
135
+ const hash = await computeHash(data);
136
+ const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
137
+ const repoEncoded = encodeURIComponent(repo);
138
+ const wsEncoded = encodeURIComponent(workspace);
139
+ // 1. Init transfer (BEAST2 request/response)
140
+ const encodeInit = encodeBeast2For(TransferUploadRequestType);
141
+ const initRes = await fetchWithAuth(`${url}/api/repos/${repoEncoded}/workspaces/${wsEncoded}/datasets/${pathStr}/upload`, {
142
+ method: 'POST',
143
+ headers: {
144
+ 'Content-Type': BEAST2_CONTENT_TYPE,
145
+ 'Accept': BEAST2_CONTENT_TYPE,
146
+ },
147
+ body: encodeInit({ hash, size: BigInt(data.byteLength) }),
148
+ }, options);
149
+ if (!initRes.ok) {
150
+ throw new Error(`Transfer init failed: ${initRes.status} ${initRes.statusText}`);
151
+ }
152
+ const initBuffer = new Uint8Array(await initRes.arrayBuffer());
153
+ const decodeInit = decodeBeast2For(ResponseType(TransferUploadResponseType));
154
+ const initResult = decodeInit(initBuffer);
155
+ if (initResult.type === 'error') {
156
+ throw new ApiError(initResult.value.type, initResult.value.value);
157
+ }
158
+ const init = initResult.value;
159
+ // Dedup — object already exists, ref updated
160
+ if (init.type === 'completed')
161
+ return;
162
+ // 2. Upload to staging (no auth — URL may be a presigned S3 URL)
163
+ const uploadRes = await fetch(init.value.uploadUrl, {
164
+ method: 'PUT',
165
+ headers: {
166
+ 'Content-Type': BEAST2_CONTENT_TYPE,
167
+ 'Accept': BEAST2_CONTENT_TYPE,
168
+ },
169
+ body: data,
170
+ });
171
+ if (!uploadRes.ok) {
172
+ throw new Error(`Transfer upload failed: ${uploadRes.status} ${uploadRes.statusText}`);
173
+ }
174
+ // 3. Commit — server verifies hash + updates ref (BEAST2 response)
175
+ const commitRes = await fetchWithAuth(`${url}/api/repos/${repoEncoded}/workspaces/${wsEncoded}/datasets/${pathStr}/upload/${init.value.id}`, {
176
+ method: 'POST',
177
+ headers: { 'Accept': BEAST2_CONTENT_TYPE },
178
+ }, options);
179
+ if (!commitRes.ok) {
180
+ throw new Error(`Transfer commit failed: ${commitRes.status} ${commitRes.statusText}`);
181
+ }
182
+ const commitBuffer = new Uint8Array(await commitRes.arrayBuffer());
183
+ const decodeDone = decodeBeast2For(ResponseType(TransferDoneResponseType));
184
+ const commitResult = decodeDone(commitBuffer);
185
+ if (commitResult.type === 'error') {
186
+ throw new ApiError(commitResult.value.type, commitResult.value.value);
187
+ }
188
+ if (commitResult.value.type === 'error') {
189
+ throw new Error(`Transfer failed: ${commitResult.value.value.message}`);
190
+ }
191
+ }
192
+ /**
193
+ * List all entries recursively under a path (flat list of datasets and trees).
194
+ *
195
+ * @param url - Base URL of the e3 API server
196
+ * @param repo - Repository name
197
+ * @param workspace - Workspace name
198
+ * @param path - Starting path (empty for root)
199
+ * @param options - Request options including auth token
200
+ * @returns Array of list entries (dataset or tree variants) with path, type, hash, and size
201
+ * @throws {ApiError} On application-level errors
202
+ * @throws {AuthError} On 401 Unauthorized
203
+ */
204
+ export async function datasetListRecursive(url, repo, workspace, path, options) {
205
+ const endpoint = `${datasetEndpoint(repo, workspace, path)}?list=true&recursive=true&status=true`;
206
+ return get(url, endpoint, ArrayType(ListEntryType), options);
207
+ }
208
+ /**
209
+ * List all descendant dataset paths recursively (paths only, no types/status).
210
+ *
211
+ * @param url - Base URL of the e3 API server
212
+ * @param repo - Repository name
213
+ * @param workspace - Workspace name
214
+ * @param path - Starting path (empty for root)
215
+ * @param options - Request options including auth token
216
+ * @returns Array of dataset path strings
217
+ */
218
+ export async function datasetListRecursivePaths(url, repo, workspace, path, options) {
219
+ const endpoint = `${datasetEndpoint(repo, workspace, path)}?list=true&recursive=true`;
220
+ return get(url, endpoint, ArrayType(StringType), options);
221
+ }
222
+ /**
223
+ * List immediate children with type, hash, and size details.
224
+ *
225
+ * @param url - Base URL of the e3 API server
226
+ * @param repo - Repository name
227
+ * @param workspace - Workspace name
228
+ * @param path - Path to list (empty for root)
229
+ * @param options - Request options including auth token
230
+ * @returns Array of list entries (dataset or tree variants) with path, type, hash, and size
231
+ */
232
+ export async function datasetListWithStatus(url, repo, workspace, path, options) {
233
+ const endpoint = `${datasetEndpoint(repo, workspace, path)}?list=true&status=true`;
234
+ return get(url, endpoint, ArrayType(ListEntryType), options);
235
+ }
236
+ /**
237
+ * Get status detail for a single dataset.
238
+ *
239
+ * @param url - Base URL of the e3 API server
240
+ * @param repo - Repository name
241
+ * @param workspace - Workspace name
242
+ * @param path - Path to the dataset
243
+ * @param options - Request options including auth token
244
+ * @returns Dataset status detail including path, type, refType, hash, and size
245
+ * @throws {ApiError} On application-level errors
246
+ * @throws {AuthError} On 401 Unauthorized
247
+ */
248
+ export async function datasetGetStatus(url, repo, workspace, path, options) {
249
+ const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
250
+ return get(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets/${pathStr}?status=true`, DatasetStatusDetailType, options);
76
251
  }
77
252
  //# sourceMappingURL=datasets.js.map
@@ -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;AAEtD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW,EAAE,SAAiB;IAC9D,MAAM,QAAQ,GAAG,MAAM,GAAG,CACxB,GAAG,EACH,mBAAmB,kBAAkB,CAAC,SAAS,CAAC,OAAO,EACvD,SAAS,CAAC,UAAU,CAAC,CACtB,CAAC;IACF,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,K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B;IAEvB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,OAAO,GAAG,CACR,GAAG,EACH,UAAU,kBAAkB,CAAC,IAAI,CAAC,eAAe,kBAAkB,CAAC,SAAS,CAAC,aAAa,OAAO,cAAc,EAChH,uBAAuB,EACvB,OAAO,CACR,CAAC;AACJ,CAAC"}
@@ -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 workspaceStatus() to poll for progress.
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 options - Execution options
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 dataflowStart(url: string, workspace: string, options?: DataflowOptions): Promise<void>;
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 (blocking).
43
+ * Execute dataflow on a workspace with client-side polling.
30
44
  *
31
- * Waits for execution to complete and returns the result.
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 options - Execution options
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?: DataflowOptions): Promise<DataflowResult>;
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 options - Log reading options
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 taskLogs(url: string, workspace: string, task: string, options?: LogOptions): Promise<LogChunk>;
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;AAS1E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B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