@elaraai/e3-api-client 0.0.2-beta.3 → 0.0.2-beta.30

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 (46) hide show
  1. package/README.md +2 -2
  2. package/dist/src/datasets.d.ts +31 -4
  3. package/dist/src/datasets.d.ts.map +1 -1
  4. package/dist/src/datasets.js +51 -11
  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 +169 -36
  9. package/dist/src/executions.js.map +1 -1
  10. package/dist/src/http.d.ts +53 -12
  11. package/dist/src/http.d.ts.map +1 -1
  12. package/dist/src/http.js +104 -28
  13. package/dist/src/http.js.map +1 -1
  14. package/dist/src/index.d.ts +8 -5
  15. package/dist/src/index.d.ts.map +1 -1
  16. package/dist/src/index.js +10 -4
  17. package/dist/src/index.js.map +1 -1
  18. package/dist/src/packages.d.ts +26 -5
  19. package/dist/src/packages.d.ts.map +1 -1
  20. package/dist/src/packages.js +31 -16
  21. package/dist/src/packages.js.map +1 -1
  22. package/dist/src/platform.d.ts +523 -1333
  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 +1182 -706
  39. package/dist/src/types.d.ts.map +1 -1
  40. package/dist/src/types.js +192 -2
  41. package/dist/src/types.js.map +1 -1
  42. package/dist/src/workspaces.d.ts +36 -7
  43. package/dist/src/workspaces.d.ts.map +1 -1
  44. package/dist/src/workspaces.js +43 -22
  45. package/dist/src/workspaces.js.map +1 -1
  46. 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 DatasetListItem } 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,35 @@ 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<Uint8Array>;
35
47
  /**
36
48
  * Set a dataset value from raw BEAST2 bytes.
37
49
  *
38
50
  * @param url - Base URL of the e3 API server
51
+ * @param repo - Repository name
39
52
  * @param workspace - Workspace name
40
53
  * @param path - Path to the dataset (e.g., ['inputs', 'config'])
41
54
  * @param data - Raw BEAST2 encoded value
55
+ * @param options - Request options including auth token
42
56
  */
43
- export declare function datasetSet(url: string, workspace: string, path: TreePath, data: Uint8Array): Promise<void>;
57
+ export declare function datasetSet(url: string, repo: string, workspace: string, path: TreePath, data: Uint8Array, options: RequestOptions): Promise<void>;
58
+ /**
59
+ * List all datasets recursively under a path (flat list).
60
+ *
61
+ * @param url - Base URL of the e3 API server
62
+ * @param repo - Repository name
63
+ * @param workspace - Workspace name
64
+ * @param path - Starting path (empty for root)
65
+ * @param options - Request options including auth token
66
+ * @returns Array of dataset items with path, type, hash, and size
67
+ * @throws {ApiError} On application-level errors
68
+ * @throws {AuthError} On 401 Unauthorized
69
+ */
70
+ export declare function datasetListRecursive(url: string, repo: string, workspace: string, path: TreePath, options: RequestOptions): Promise<DatasetListItem[]>;
44
71
  //# 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;;;;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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,eAAe,EAAE,CAAC,CAS5B"}
@@ -3,30 +3,37 @@
3
3
  * Licensed under BSL 1.1. See LICENSE for details.
4
4
  */
5
5
  import { ArrayType, StringType } from '@elaraai/east';
6
- import { get, unwrap } from './http.js';
6
+ import { get } from './http.js';
7
+ import { DatasetListItemType } from './types.js';
7
8
  /**
8
9
  * List field names at root of workspace dataset tree.
9
10
  *
10
11
  * @param url - Base URL of the e3 API server
12
+ * @param repo - Repository name
11
13
  * @param workspace - Workspace name
14
+ * @param options - Request options including auth token
12
15
  * @returns Array of field names at root
16
+ * @throws {ApiError} On application-level errors
17
+ * @throws {AuthError} On 401 Unauthorized
13
18
  */
14
- export async function datasetList(url, workspace) {
15
- const response = await get(url, `/api/workspaces/${encodeURIComponent(workspace)}/list`, ArrayType(StringType));
16
- return unwrap(response);
19
+ export async function datasetList(url, repo, workspace, options) {
20
+ return get(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets`, ArrayType(StringType), options);
17
21
  }
18
22
  /**
19
23
  * List field names at a path in workspace dataset tree.
20
24
  *
21
25
  * @param url - Base URL of the e3 API server
26
+ * @param repo - Repository name
22
27
  * @param workspace - Workspace name
23
28
  * @param path - Path to the dataset (e.g., ['inputs', 'config'])
29
+ * @param options - Request options including auth token
24
30
  * @returns Array of field names at path
31
+ * @throws {ApiError} On application-level errors
32
+ * @throws {AuthError} On 401 Unauthorized
25
33
  */
26
- export async function datasetListAt(url, workspace, path) {
34
+ export async function datasetListAt(url, repo, workspace, path, options) {
27
35
  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);
36
+ return get(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets/${pathStr}?list=true`, ArrayType(StringType), options);
30
37
  }
31
38
  /**
32
39
  * Get a dataset value as raw BEAST2 bytes.
@@ -35,18 +42,24 @@ export async function datasetListAt(url, workspace, path) {
35
42
  * Use decodeBeast2 or decodeBeast2For to decode with the appropriate type.
36
43
  *
37
44
  * @param url - Base URL of the e3 API server
45
+ * @param repo - Repository name
38
46
  * @param workspace - Workspace name
39
47
  * @param path - Path to the dataset (e.g., ['inputs', 'config'])
48
+ * @param options - Request options including auth token
40
49
  * @returns Raw BEAST2 bytes
41
50
  */
42
- export async function datasetGet(url, workspace, path) {
51
+ export async function datasetGet(url, repo, workspace, path, options) {
43
52
  const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
44
- const response = await fetch(`${url}/api/workspaces/${encodeURIComponent(workspace)}/get/${pathStr}`, {
53
+ const response = await fetch(`${url}/api/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets/${pathStr}`, {
45
54
  method: 'GET',
46
55
  headers: {
47
56
  'Accept': 'application/beast2',
57
+ 'Authorization': `Bearer ${options.token}`,
48
58
  },
49
59
  });
60
+ if (response.status === 401) {
61
+ throw new Error(`Authentication failed: ${await response.text()}`);
62
+ }
50
63
  if (!response.ok) {
51
64
  throw new Error(`Failed to get dataset: ${response.status} ${response.statusText}`);
52
65
  }
@@ -57,21 +70,48 @@ export async function datasetGet(url, workspace, path) {
57
70
  * Set a dataset value from raw BEAST2 bytes.
58
71
  *
59
72
  * @param url - Base URL of the e3 API server
73
+ * @param repo - Repository name
60
74
  * @param workspace - Workspace name
61
75
  * @param path - Path to the dataset (e.g., ['inputs', 'config'])
62
76
  * @param data - Raw BEAST2 encoded value
77
+ * @param options - Request options including auth token
63
78
  */
64
- export async function datasetSet(url, workspace, path, data) {
79
+ export async function datasetSet(url, repo, workspace, path, data, options) {
65
80
  const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
66
- const response = await fetch(`${url}/api/workspaces/${encodeURIComponent(workspace)}/set/${pathStr}`, {
81
+ const response = await fetch(`${url}/api/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets/${pathStr}`, {
67
82
  method: 'PUT',
68
83
  headers: {
69
84
  'Content-Type': 'application/beast2',
85
+ 'Authorization': `Bearer ${options.token}`,
70
86
  },
71
87
  body: data,
72
88
  });
89
+ if (response.status === 401) {
90
+ throw new Error(`Authentication failed: ${await response.text()}`);
91
+ }
73
92
  if (!response.ok) {
74
93
  throw new Error(`Failed to set dataset: ${response.status} ${response.statusText}`);
75
94
  }
76
95
  }
96
+ /**
97
+ * List all datasets recursively under a path (flat list).
98
+ *
99
+ * @param url - Base URL of the e3 API server
100
+ * @param repo - Repository name
101
+ * @param workspace - Workspace name
102
+ * @param path - Starting path (empty for root)
103
+ * @param options - Request options including auth token
104
+ * @returns Array of dataset items with path, type, hash, and size
105
+ * @throws {ApiError} On application-level errors
106
+ * @throws {AuthError} On 401 Unauthorized
107
+ */
108
+ export async function datasetListRecursive(url, repo, workspace, path, options) {
109
+ let endpoint = `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/datasets`;
110
+ if (path.length > 0) {
111
+ const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
112
+ endpoint = `${endpoint}/${pathStr}`;
113
+ }
114
+ endpoint = `${endpoint}?recursive=true`;
115
+ return get(url, endpoint, ArrayType(DatasetListItemType), options);
116
+ }
77
117
  //# 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,K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,EAAE,CAAC,CAAC;IACtF,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,GAAW,EACX,IAAY,EACZ,SAAiB,EACjB,IAAc,EACd,OAAuB;IAEvB,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,QAAQ,GAAG,GAAG,QAAQ,iBAAiB,CAAC;IAExC,OAAO,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,SAAS,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC,CAAC;AACrE,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,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;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,cAAc,CAAC,CAazB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC,CAOxB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC7B,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAC5B,GAAG,EAAE,MAAM,EACX,SAA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SE for details.
4
4
  */
5
- import { NullType, none, some } from '@elaraai/east';
6
- import { LogChunkType, DataflowRequestType, DataflowGraphType, DataflowResultType, } from './types.js';
7
- import { get, post, unwrap } from './http.js';
5
+ import { NullType, none, some, variant } from '@elaraai/east';
6
+ import { LogChunkType, DataflowRequestType, DataflowGraphType, DataflowExecutionStateType, } from './types.js';
7
+ import { get, post } from './http.js';
8
8
  /**
9
9
  * Start dataflow execution on a workspace (non-blocking).
10
10
  *
11
11
  * Returns immediately after spawning execution in background.
12
- * Use workspaceStatus() to poll for progress.
12
+ * Use dataflowExecutePoll() to poll for progress.
13
13
  *
14
14
  * @param url - Base URL of the e3 API server
15
+ * @param repo - Repository name
15
16
  * @param workspace - Workspace name
16
- * @param options - Execution options
17
+ * @param dataflowOptions - Execution options
18
+ * @param options - Request options including auth token
19
+ * @throws {ApiError} On application-level errors
20
+ * @throws {AuthError} On 401 Unauthorized
17
21
  */
18
- export async function dataflowStart(url, workspace, options = {}) {
19
- const response = await post(url, `/api/workspaces/${encodeURIComponent(workspace)}/start`, {
20
- concurrency: options.concurrency != null ? some(BigInt(options.concurrency)) : none,
21
- force: options.force ?? false,
22
- filter: options.filter != null ? some(options.filter) : none,
23
- }, DataflowRequestType, NullType);
24
- unwrap(response);
22
+ export async function dataflowExecuteLaunch(url, repo, workspace, dataflowOptions = {}, options) {
23
+ await post(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/dataflow`, {
24
+ concurrency: dataflowOptions.concurrency != null ? some(BigInt(dataflowOptions.concurrency)) : none,
25
+ force: dataflowOptions.force ?? false,
26
+ filter: dataflowOptions.filter != null ? some(dataflowOptions.filter) : none,
27
+ }, DataflowRequestType, NullType, options);
25
28
  }
26
29
  /**
27
- * Execute dataflow on a workspace (blocking).
30
+ * Build DataflowResult from DataflowExecutionState.
28
31
  *
29
- * Waits for execution to complete and returns the result.
32
+ * Converts events into task execution results.
33
+ */
34
+ function buildDataflowResult(state) {
35
+ const tasks = [];
36
+ // Process events to build task results
37
+ // Events are: start, complete, cached, failed, error, input_unavailable
38
+ for (const event of state.events) {
39
+ switch (event.type) {
40
+ case 'complete':
41
+ tasks.push({
42
+ name: event.value.task,
43
+ cached: false,
44
+ state: variant('success', null),
45
+ duration: event.value.duration,
46
+ });
47
+ break;
48
+ case 'cached':
49
+ tasks.push({
50
+ name: event.value.task,
51
+ cached: true,
52
+ state: variant('success', null),
53
+ duration: 0,
54
+ });
55
+ break;
56
+ case 'failed':
57
+ tasks.push({
58
+ name: event.value.task,
59
+ cached: false,
60
+ state: variant('failed', { exitCode: event.value.exitCode }),
61
+ duration: event.value.duration,
62
+ });
63
+ break;
64
+ case 'error':
65
+ tasks.push({
66
+ name: event.value.task,
67
+ cached: false,
68
+ state: variant('error', { message: event.value.message }),
69
+ duration: 0,
70
+ });
71
+ break;
72
+ case 'input_unavailable':
73
+ tasks.push({
74
+ name: event.value.task,
75
+ cached: false,
76
+ state: variant('skipped', null),
77
+ duration: 0,
78
+ });
79
+ break;
80
+ // 'start' events don't create task results - they're tracked separately
81
+ }
82
+ }
83
+ // Get summary from state or calculate from tasks
84
+ const summary = state.summary.type === 'some' ? state.summary.value : {
85
+ executed: BigInt(tasks.filter(t => !t.cached && t.state.type === 'success').length),
86
+ cached: BigInt(tasks.filter(t => t.cached).length),
87
+ failed: BigInt(tasks.filter(t => t.state.type === 'failed' || t.state.type === 'error').length),
88
+ skipped: BigInt(tasks.filter(t => t.state.type === 'skipped').length),
89
+ duration: 0,
90
+ };
91
+ return {
92
+ success: state.status.type === 'completed',
93
+ executed: summary.executed,
94
+ cached: summary.cached,
95
+ failed: summary.failed,
96
+ skipped: summary.skipped,
97
+ tasks,
98
+ duration: summary.duration,
99
+ };
100
+ }
101
+ /**
102
+ * Execute dataflow on a workspace with client-side polling.
103
+ *
104
+ * Starts execution, polls until complete, and returns the result.
30
105
  *
31
106
  * @param url - Base URL of the e3 API server
107
+ * @param repo - Repository name
32
108
  * @param workspace - Workspace name
33
- * @param options - Execution options
109
+ * @param dataflowOptions - Execution options
110
+ * @param options - Request options including auth token
111
+ * @param pollOptions - Polling configuration
34
112
  * @returns Dataflow execution result
35
113
  */
36
- export async function dataflowExecute(url, workspace, options = {}) {
37
- const response = await post(url, `/api/workspaces/${encodeURIComponent(workspace)}/execute`, {
38
- concurrency: options.concurrency != null ? some(BigInt(options.concurrency)) : none,
39
- force: options.force ?? false,
40
- filter: options.filter != null ? some(options.filter) : none,
41
- }, DataflowRequestType, DataflowResultType);
42
- return unwrap(response);
114
+ export async function dataflowExecute(url, repo, workspace, dataflowOptions = {}, options, pollOptions = {}) {
115
+ const { pollInterval = 500, timeout = 300000 } = pollOptions;
116
+ // Start execution
117
+ await dataflowExecuteLaunch(url, repo, workspace, dataflowOptions, options);
118
+ // Poll until complete
119
+ const startTime = Date.now();
120
+ while (Date.now() - startTime < timeout) {
121
+ const state = await dataflowExecutePoll(url, repo, workspace, {}, options);
122
+ if (state.status.type === 'completed' || state.status.type === 'failed' || state.status.type === 'aborted') {
123
+ return buildDataflowResult(state);
124
+ }
125
+ await new Promise(r => setTimeout(r, pollInterval));
126
+ }
127
+ throw new Error('Dataflow execution timed out');
43
128
  }
129
+ // Backward compatibility alias
130
+ export { dataflowExecuteLaunch as dataflowStart };
44
131
  /**
45
132
  * Get the dependency graph for a workspace.
46
133
  *
47
134
  * @param url - Base URL of the e3 API server
135
+ * @param repo - Repository name
48
136
  * @param workspace - Workspace name
137
+ * @param options - Request options including auth token
49
138
  * @returns Dataflow graph with tasks and dependencies
139
+ * @throws {ApiError} On application-level errors
140
+ * @throws {AuthError} On 401 Unauthorized
50
141
  */
51
- export async function dataflowGraph(url, workspace) {
52
- const response = await get(url, `/api/workspaces/${encodeURIComponent(workspace)}/graph`, DataflowGraphType);
53
- return unwrap(response);
142
+ export async function dataflowGraph(url, repo, workspace, options) {
143
+ return get(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/dataflow/graph`, DataflowGraphType, options);
54
144
  }
55
145
  /**
56
146
  * Read task logs from a workspace.
57
147
  *
58
148
  * @param url - Base URL of the e3 API server
149
+ * @param repo - Repository name
59
150
  * @param workspace - Workspace name
60
151
  * @param task - Task name
61
- * @param options - Log reading options
152
+ * @param logOptions - Log reading options
153
+ * @param options - Request options including auth token
62
154
  * @returns Log chunk with data and metadata
155
+ * @throws {ApiError} On application-level errors
156
+ * @throws {AuthError} On 401 Unauthorized
157
+ */
158
+ export async function taskLogs(url, repo, workspace, task, logOptions = {}, options) {
159
+ const params = new URLSearchParams();
160
+ if (logOptions.stream)
161
+ params.set('stream', logOptions.stream);
162
+ if (logOptions.offset != null)
163
+ params.set('offset', String(logOptions.offset));
164
+ if (logOptions.limit != null)
165
+ params.set('limit', String(logOptions.limit));
166
+ const query = params.toString();
167
+ const path = `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/dataflow/logs/${encodeURIComponent(task)}${query ? `?${query}` : ''}`;
168
+ return get(url, path, LogChunkType, options);
169
+ }
170
+ /**
171
+ * Get dataflow execution state (for polling).
172
+ *
173
+ * Returns the current execution state including events for progress tracking.
174
+ * Use offset/limit for pagination of events.
175
+ *
176
+ * @param url - Base URL of the e3 API server
177
+ * @param repo - Repository name
178
+ * @param workspace - Workspace name
179
+ * @param stateOptions - Pagination options for events
180
+ * @param options - Request options including auth token
181
+ * @returns Execution state with events and summary
182
+ * @throws {ApiError} On application-level errors
183
+ * @throws {AuthError} On 401 Unauthorized
63
184
  */
64
- export async function taskLogs(url, workspace, task, options = {}) {
185
+ export async function dataflowExecutePoll(url, repo, workspace, stateOptions = {}, options) {
65
186
  const params = new URLSearchParams();
66
- if (options.stream)
67
- params.set('stream', options.stream);
68
- if (options.offset != null)
69
- params.set('offset', String(options.offset));
70
- if (options.limit != null)
71
- params.set('limit', String(options.limit));
187
+ if (stateOptions.offset != null)
188
+ params.set('offset', String(stateOptions.offset));
189
+ if (stateOptions.limit != null)
190
+ params.set('limit', String(stateOptions.limit));
72
191
  const query = params.toString();
73
- const path = `/api/workspaces/${encodeURIComponent(workspace)}/logs/${encodeURIComponent(task)}${query ? `?${query}` : ''}`;
74
- const response = await get(url, path, LogChunkType);
75
- return unwrap(response);
192
+ const path = `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/dataflow/execution${query ? `?${query}` : ''}`;
193
+ return get(url, path, DataflowExecutionStateType, options);
194
+ }
195
+ // Backward compatibility alias
196
+ export { dataflowExecutePoll as dataflowExecution };
197
+ /**
198
+ * Cancel a running dataflow execution.
199
+ *
200
+ * @param url - Base URL of the API server
201
+ * @param repo - Repository name
202
+ * @param workspace - Workspace name
203
+ * @param options - Request options (token, etc.)
204
+ * @throws {ApiError} If cancellation fails or no execution is running
205
+ * @throws {AuthError} On 401 Unauthorized
206
+ */
207
+ export async function dataflowCancel(url, repo, workspace, options) {
208
+ await post(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(workspace)}/dataflow/cancel`, null, NullType, NullType, options);
76
209
  }
77
210
  //# sourceMappingURL=executions.js.map