@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.
- 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 +194 -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 +67 -12
- package/dist/src/http.d.ts.map +1 -1
- package/dist/src/http.js +168 -34
- package/dist/src/http.js.map +1 -1
- package/dist/src/index.d.ts +9 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/packages.d.ts +32 -27
- package/dist/src/packages.d.ts.map +1 -1
- package/dist/src/packages.js +175 -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 +755 -1251
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +62 -453
- package/dist/src/types.js.map +1 -1
- package/dist/src/util.d.ts +21 -0
- package/dist/src/util.d.ts.map +1 -0
- package/dist/src/util.js +26 -0
- package/dist/src/util.js.map +1 -0
- package/dist/src/workspaces.d.ts +51 -9
- package/dist/src/workspaces.d.ts.map +1 -1
- package/dist/src/workspaces.js +87 -26
- package/dist/src/workspaces.js.map +1 -1
- package/package.json +4 -4
package/dist/src/util.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Calculate SHA256 hash of data for content-addressed transfers.
|
|
7
|
+
*
|
|
8
|
+
* This is a browser-safe version using the Web Crypto API (crypto.subtle),
|
|
9
|
+
* which is available in both Node.js (>=15) and all modern browsers.
|
|
10
|
+
*
|
|
11
|
+
* The canonical sync implementation lives in @elaraai/e3-core (objects.ts)
|
|
12
|
+
* but uses Node.js `crypto.createHash` which is not available in browser
|
|
13
|
+
* environments. This async version produces identical SHA-256 output and
|
|
14
|
+
* is used here because e3-api-client must be browser-compatible (used by
|
|
15
|
+
* e3-ui-components in webview builds).
|
|
16
|
+
*
|
|
17
|
+
* @param data - Data to hash
|
|
18
|
+
* @returns SHA256 hash as a hex string
|
|
19
|
+
*/
|
|
20
|
+
export async function computeHash(data) {
|
|
21
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
|
|
22
|
+
return Array.from(new Uint8Array(hashBuffer))
|
|
23
|
+
.map(b => b.toString(16).padStart(2, '0'))
|
|
24
|
+
.join('');
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAgB;IAChD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/D,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC;SAC1C,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SACzC,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
|
package/dist/src/workspaces.d.ts
CHANGED
|
@@ -2,62 +2,104 @@
|
|
|
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 WorkspaceState } from '@elaraai/e3-types';
|
|
5
|
+
import { type WorkspaceState, type PackageExportProgress } from '@elaraai/e3-types';
|
|
6
6
|
import type { WorkspaceInfo, WorkspaceStatusResult } from './types.js';
|
|
7
|
+
import { type RequestOptions } from './http.js';
|
|
7
8
|
/**
|
|
8
9
|
* List all workspaces in the repository.
|
|
9
10
|
*
|
|
10
11
|
* @param url - Base URL of the e3 API server
|
|
12
|
+
* @param repo - Repository name
|
|
13
|
+
* @param options - Request options including auth token
|
|
11
14
|
* @returns Array of workspace info
|
|
15
|
+
* @throws {ApiError} On application-level errors
|
|
16
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
12
17
|
*/
|
|
13
|
-
export declare function workspaceList(url: string): Promise<WorkspaceInfo[]>;
|
|
18
|
+
export declare function workspaceList(url: string, repo: string, options: RequestOptions): Promise<WorkspaceInfo[]>;
|
|
14
19
|
/**
|
|
15
20
|
* Create a new empty workspace.
|
|
16
21
|
*
|
|
17
22
|
* @param url - Base URL of the e3 API server
|
|
23
|
+
* @param repo - Repository name
|
|
18
24
|
* @param name - Workspace name
|
|
25
|
+
* @param options - Request options including auth token
|
|
19
26
|
* @returns Created workspace info
|
|
27
|
+
* @throws {ApiError} On application-level errors
|
|
28
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
20
29
|
*/
|
|
21
|
-
export declare function workspaceCreate(url: string, name: string): Promise<WorkspaceInfo>;
|
|
30
|
+
export declare function workspaceCreate(url: string, repo: string, name: string, options: RequestOptions): Promise<WorkspaceInfo>;
|
|
22
31
|
/**
|
|
23
32
|
* Get workspace state (deployed package info and current root hash).
|
|
24
33
|
*
|
|
25
34
|
* @param url - Base URL of the e3 API server
|
|
35
|
+
* @param repo - Repository name
|
|
26
36
|
* @param name - Workspace name
|
|
37
|
+
* @param options - Request options including auth token
|
|
27
38
|
* @returns Workspace state
|
|
39
|
+
* @throws {ApiError} On application-level errors
|
|
40
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
28
41
|
*/
|
|
29
|
-
export declare function workspaceGet(url: string, name: string): Promise<WorkspaceState>;
|
|
42
|
+
export declare function workspaceGet(url: string, repo: string, name: string, options: RequestOptions): Promise<WorkspaceState>;
|
|
30
43
|
/**
|
|
31
44
|
* Get comprehensive workspace status including datasets, tasks, and lock info.
|
|
32
45
|
*
|
|
33
46
|
* Use this to poll for execution progress after calling dataflowStart().
|
|
34
47
|
*
|
|
35
48
|
* @param url - Base URL of the e3 API server
|
|
49
|
+
* @param repo - Repository name
|
|
36
50
|
* @param name - Workspace name
|
|
51
|
+
* @param options - Request options including auth token
|
|
37
52
|
* @returns Workspace status with datasets, tasks, and summary
|
|
53
|
+
* @throws {ApiError} On application-level errors
|
|
54
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
38
55
|
*/
|
|
39
|
-
export declare function workspaceStatus(url: string, name: string): Promise<WorkspaceStatusResult>;
|
|
56
|
+
export declare function workspaceStatus(url: string, repo: string, name: string, options: RequestOptions): Promise<WorkspaceStatusResult>;
|
|
40
57
|
/**
|
|
41
58
|
* Remove a workspace.
|
|
42
59
|
*
|
|
43
60
|
* @param url - Base URL of the e3 API server
|
|
61
|
+
* @param repo - Repository name
|
|
44
62
|
* @param name - Workspace name
|
|
63
|
+
* @param options - Request options including auth token
|
|
64
|
+
* @throws {ApiError} On application-level errors
|
|
65
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
45
66
|
*/
|
|
46
|
-
export declare function workspaceRemove(url: string, name: string): Promise<void>;
|
|
67
|
+
export declare function workspaceRemove(url: string, repo: string, name: string, options: RequestOptions): Promise<void>;
|
|
47
68
|
/**
|
|
48
69
|
* Deploy a package to a workspace.
|
|
49
70
|
*
|
|
50
71
|
* @param url - Base URL of the e3 API server
|
|
72
|
+
* @param repo - Repository name
|
|
51
73
|
* @param name - Workspace name
|
|
52
74
|
* @param packageRef - Package reference (name or name@version)
|
|
75
|
+
* @param options - Request options including auth token
|
|
76
|
+
* @throws {ApiError} On application-level errors
|
|
77
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
53
78
|
*/
|
|
54
|
-
export declare function workspaceDeploy(url: string, name: string, packageRef: string): Promise<void>;
|
|
79
|
+
export declare function workspaceDeploy(url: string, repo: string, name: string, packageRef: string, options: RequestOptions): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Options for workspace export progress reporting.
|
|
82
|
+
*/
|
|
83
|
+
export interface WorkspaceExportOptions {
|
|
84
|
+
name?: string;
|
|
85
|
+
version?: string;
|
|
86
|
+
onProgress?: (progress: PackageExportProgress) => void;
|
|
87
|
+
onDownloadProgress?: (downloaded: number, total: number) => void;
|
|
88
|
+
signal?: AbortSignal;
|
|
89
|
+
}
|
|
55
90
|
/**
|
|
56
91
|
* Export workspace as a package zip archive.
|
|
57
92
|
*
|
|
93
|
+
* Uses the async transfer protocol: POST to trigger → poll for progress → download.
|
|
94
|
+
*
|
|
58
95
|
* @param url - Base URL of the e3 API server
|
|
59
|
-
* @param
|
|
96
|
+
* @param repo - Repository name
|
|
97
|
+
* @param workspace - Workspace name
|
|
98
|
+
* @param options - Request options including auth token
|
|
99
|
+
* @param exportOptions - Optional progress callbacks
|
|
60
100
|
* @returns Zip archive as bytes
|
|
101
|
+
* @throws {ApiError} On application-level errors
|
|
102
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
61
103
|
*/
|
|
62
|
-
export declare function workspaceExport(url: string,
|
|
104
|
+
export declare function workspaceExport(url: string, repo: string, workspace: string, options: RequestOptions, exportOptions?: WorkspaceExportOptions): Promise<Uint8Array>;
|
|
63
105
|
//# sourceMappingURL=workspaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../../src/workspaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../../src/workspaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEL,KAAK,cAAc,EAEnB,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAUvE,OAAO,EAA8D,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAG5G;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAEhH;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAS9H;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAO5H;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAOtI;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAOrH;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACvD,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,cAAc,EACvB,aAAa,CAAC,EAAE,sBAAsB,GACrC,OAAO,CAAC,UAAU,CAAC,CA0CrB"}
|
package/dist/src/workspaces.js
CHANGED
|
@@ -2,41 +2,52 @@
|
|
|
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,
|
|
6
|
-
import { WorkspaceStateType } from '@elaraai/e3-types';
|
|
7
|
-
import { WorkspaceInfoType, WorkspaceCreateRequestType, WorkspaceDeployRequestType, WorkspaceStatusResultType, } from './types.js';
|
|
8
|
-
import {
|
|
5
|
+
import { ArrayType, NullType, encodeBeast2For, decodeBeast2For, some, none } from '@elaraai/east';
|
|
6
|
+
import { WorkspaceStateType, PackageJobResponseType, } from '@elaraai/e3-types';
|
|
7
|
+
import { WorkspaceInfoType, WorkspaceCreateRequestType, WorkspaceDeployRequestType, WorkspaceStatusResultType, WorkspaceExportRequestType, ResponseType, } from './types.js';
|
|
8
|
+
import { BEAST2_CONTENT_TYPE } from '@elaraai/e3-types';
|
|
9
|
+
import { get, post, del, fetchWithAuth, fetchWithProgress, ApiError } from './http.js';
|
|
10
|
+
import { pollExport } from './packages.js';
|
|
9
11
|
/**
|
|
10
12
|
* List all workspaces in the repository.
|
|
11
13
|
*
|
|
12
14
|
* @param url - Base URL of the e3 API server
|
|
15
|
+
* @param repo - Repository name
|
|
16
|
+
* @param options - Request options including auth token
|
|
13
17
|
* @returns Array of workspace info
|
|
18
|
+
* @throws {ApiError} On application-level errors
|
|
19
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
14
20
|
*/
|
|
15
|
-
export async function workspaceList(url) {
|
|
16
|
-
|
|
17
|
-
return unwrap(response);
|
|
21
|
+
export async function workspaceList(url, repo, options) {
|
|
22
|
+
return get(url, `/repos/${encodeURIComponent(repo)}/workspaces`, ArrayType(WorkspaceInfoType), options);
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
25
|
* Create a new empty workspace.
|
|
21
26
|
*
|
|
22
27
|
* @param url - Base URL of the e3 API server
|
|
28
|
+
* @param repo - Repository name
|
|
23
29
|
* @param name - Workspace name
|
|
30
|
+
* @param options - Request options including auth token
|
|
24
31
|
* @returns Created workspace info
|
|
32
|
+
* @throws {ApiError} On application-level errors
|
|
33
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
25
34
|
*/
|
|
26
|
-
export async function workspaceCreate(url, name) {
|
|
27
|
-
|
|
28
|
-
return unwrap(response);
|
|
35
|
+
export async function workspaceCreate(url, repo, name, options) {
|
|
36
|
+
return post(url, `/repos/${encodeURIComponent(repo)}/workspaces`, { name }, WorkspaceCreateRequestType, WorkspaceInfoType, options);
|
|
29
37
|
}
|
|
30
38
|
/**
|
|
31
39
|
* Get workspace state (deployed package info and current root hash).
|
|
32
40
|
*
|
|
33
41
|
* @param url - Base URL of the e3 API server
|
|
42
|
+
* @param repo - Repository name
|
|
34
43
|
* @param name - Workspace name
|
|
44
|
+
* @param options - Request options including auth token
|
|
35
45
|
* @returns Workspace state
|
|
46
|
+
* @throws {ApiError} On application-level errors
|
|
47
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
36
48
|
*/
|
|
37
|
-
export async function workspaceGet(url, name) {
|
|
38
|
-
|
|
39
|
-
return unwrap(response);
|
|
49
|
+
export async function workspaceGet(url, repo, name, options) {
|
|
50
|
+
return get(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(name)}`, WorkspaceStateType, options);
|
|
40
51
|
}
|
|
41
52
|
/**
|
|
42
53
|
* Get comprehensive workspace status including datasets, tasks, and lock info.
|
|
@@ -44,43 +55,93 @@ export async function workspaceGet(url, name) {
|
|
|
44
55
|
* Use this to poll for execution progress after calling dataflowStart().
|
|
45
56
|
*
|
|
46
57
|
* @param url - Base URL of the e3 API server
|
|
58
|
+
* @param repo - Repository name
|
|
47
59
|
* @param name - Workspace name
|
|
60
|
+
* @param options - Request options including auth token
|
|
48
61
|
* @returns Workspace status with datasets, tasks, and summary
|
|
62
|
+
* @throws {ApiError} On application-level errors
|
|
63
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
49
64
|
*/
|
|
50
|
-
export async function workspaceStatus(url, name) {
|
|
51
|
-
|
|
52
|
-
return unwrap(response);
|
|
65
|
+
export async function workspaceStatus(url, repo, name, options) {
|
|
66
|
+
return get(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(name)}/status`, WorkspaceStatusResultType, options);
|
|
53
67
|
}
|
|
54
68
|
/**
|
|
55
69
|
* Remove a workspace.
|
|
56
70
|
*
|
|
57
71
|
* @param url - Base URL of the e3 API server
|
|
72
|
+
* @param repo - Repository name
|
|
58
73
|
* @param name - Workspace name
|
|
74
|
+
* @param options - Request options including auth token
|
|
75
|
+
* @throws {ApiError} On application-level errors
|
|
76
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
59
77
|
*/
|
|
60
|
-
export async function workspaceRemove(url, name) {
|
|
61
|
-
|
|
62
|
-
unwrap(response);
|
|
78
|
+
export async function workspaceRemove(url, repo, name, options) {
|
|
79
|
+
await del(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(name)}`, NullType, options);
|
|
63
80
|
}
|
|
64
81
|
/**
|
|
65
82
|
* Deploy a package to a workspace.
|
|
66
83
|
*
|
|
67
84
|
* @param url - Base URL of the e3 API server
|
|
85
|
+
* @param repo - Repository name
|
|
68
86
|
* @param name - Workspace name
|
|
69
87
|
* @param packageRef - Package reference (name or name@version)
|
|
88
|
+
* @param options - Request options including auth token
|
|
89
|
+
* @throws {ApiError} On application-level errors
|
|
90
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
70
91
|
*/
|
|
71
|
-
export async function workspaceDeploy(url, name, packageRef) {
|
|
72
|
-
|
|
73
|
-
unwrap(response);
|
|
92
|
+
export async function workspaceDeploy(url, repo, name, packageRef, options) {
|
|
93
|
+
await post(url, `/repos/${encodeURIComponent(repo)}/workspaces/${encodeURIComponent(name)}/deploy`, { packageRef }, WorkspaceDeployRequestType, NullType, options);
|
|
74
94
|
}
|
|
75
95
|
/**
|
|
76
96
|
* Export workspace as a package zip archive.
|
|
77
97
|
*
|
|
98
|
+
* Uses the async transfer protocol: POST to trigger → poll for progress → download.
|
|
99
|
+
*
|
|
78
100
|
* @param url - Base URL of the e3 API server
|
|
79
|
-
* @param
|
|
101
|
+
* @param repo - Repository name
|
|
102
|
+
* @param workspace - Workspace name
|
|
103
|
+
* @param options - Request options including auth token
|
|
104
|
+
* @param exportOptions - Optional progress callbacks
|
|
80
105
|
* @returns Zip archive as bytes
|
|
106
|
+
* @throws {ApiError} On application-level errors
|
|
107
|
+
* @throws {AuthError} On 401 Unauthorized
|
|
81
108
|
*/
|
|
82
|
-
export async function workspaceExport(url,
|
|
83
|
-
const
|
|
84
|
-
|
|
109
|
+
export async function workspaceExport(url, repo, workspace, options, exportOptions) {
|
|
110
|
+
const repoEncoded = encodeURIComponent(repo);
|
|
111
|
+
const wsEncoded = encodeURIComponent(workspace);
|
|
112
|
+
const signal = exportOptions?.signal;
|
|
113
|
+
// 1. Trigger workspace export
|
|
114
|
+
const encodeReq = encodeBeast2For(WorkspaceExportRequestType);
|
|
115
|
+
const body = encodeReq({
|
|
116
|
+
name: exportOptions?.name ? some(exportOptions.name) : none,
|
|
117
|
+
version: exportOptions?.version ? some(exportOptions.version) : none,
|
|
118
|
+
});
|
|
119
|
+
const triggerRes = await fetchWithAuth(`${url}/api/repos/${repoEncoded}/workspaces/${wsEncoded}/export`, {
|
|
120
|
+
method: 'POST',
|
|
121
|
+
headers: {
|
|
122
|
+
'Content-Type': BEAST2_CONTENT_TYPE,
|
|
123
|
+
'Accept': BEAST2_CONTENT_TYPE,
|
|
124
|
+
},
|
|
125
|
+
body,
|
|
126
|
+
signal,
|
|
127
|
+
}, options);
|
|
128
|
+
if (!triggerRes.ok)
|
|
129
|
+
throw new Error(`Workspace export failed: ${triggerRes.status} ${triggerRes.statusText}`);
|
|
130
|
+
const triggerBuffer = new Uint8Array(await triggerRes.arrayBuffer());
|
|
131
|
+
const decodeTrigger = decodeBeast2For(ResponseType(PackageJobResponseType));
|
|
132
|
+
const triggerResult = decodeTrigger(triggerBuffer);
|
|
133
|
+
if (triggerResult.type === 'error')
|
|
134
|
+
throw new ApiError(triggerResult.value.type, triggerResult.value.value);
|
|
135
|
+
// 2. Poll for result
|
|
136
|
+
const status = await pollExport(url, repoEncoded, triggerResult.value.id, options, exportOptions?.onProgress, signal);
|
|
137
|
+
if (status.type === 'failed') {
|
|
138
|
+
throw new Error(`Workspace export failed: ${status.value.message}`);
|
|
139
|
+
}
|
|
140
|
+
if (status.type !== 'completed') {
|
|
141
|
+
throw new Error('Unexpected job status');
|
|
142
|
+
}
|
|
143
|
+
const { downloadUrl } = status.value;
|
|
144
|
+
// 3. Download zip (no auth — URL may be a presigned S3 URL)
|
|
145
|
+
return fetchWithProgress(downloadUrl, exportOptions?.onDownloadProgress, signal);
|
|
85
146
|
}
|
|
86
147
|
//# sourceMappingURL=workspaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../src/workspaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../src/workspaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAClG,OAAO,EACL,kBAAkB,EAElB,sBAAsB,GAEvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,0BAA0B,EAC1B,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,aAAa,EAAE,iBAAiB,EAAE,QAAQ,EAAuB,MAAM,WAAW,CAAC;AAC5G,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAW,EAAE,IAAY,EAAE,OAAuB;IACpF,OAAO,GAAG,CAAC,GAAG,EAAE,UAAU,kBAAkB,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,iBAAiB,CAA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AM,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;IACrE,MAAM,aAAa,GAAG,eAAe,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAC5E,MAAM,aAAa,GAAG,aAAa,CAAC,aAAa,CAA2G,CAAC;IAC7J,IAAI,aAAa,CAAC,IAAI,KAAK,OAAO;QAAE,MAAM,IAAI,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAE5G,qBAAqB;IACrB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAEtH,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;IAErC,4DAA4D;IAC5D,OAAO,iBAAiB,CAAC,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAC;AACnF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elaraai/e3-api-client",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.50",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "East Execution Engine API Client - TypeScript client library for e3 API server",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"directory": "packages/e3-api-client"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@elaraai/e3-types": "
|
|
39
|
+
"@elaraai/e3-types": "beta"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@elaraai/east": "
|
|
42
|
+
"@elaraai/east": "beta"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@elaraai/east-node-std": "
|
|
45
|
+
"@elaraai/east-node-std": "beta",
|
|
46
46
|
"@types/node": "^22.0.0",
|
|
47
47
|
"@typescript-eslint/eslint-plugin": "^8.47.0",
|
|
48
48
|
"@typescript-eslint/parser": "^8.47.0",
|