@elaraai/e3-api-client 0.0.1-beta.0
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/LICENSE.md +50 -0
- package/README.md +171 -0
- package/dist/src/datasets.d.ts +44 -0
- package/dist/src/datasets.d.ts.map +1 -0
- package/dist/src/datasets.js +77 -0
- package/dist/src/datasets.js.map +1 -0
- package/dist/src/executions.d.ts +68 -0
- package/dist/src/executions.d.ts.map +1 -0
- package/dist/src/executions.js +77 -0
- package/dist/src/executions.js.map +1 -0
- package/dist/src/http.d.ts +42 -0
- package/dist/src/http.d.ts.map +1 -0
- package/dist/src/http.js +98 -0
- package/dist/src/http.js.map +1 -0
- package/dist/src/index.d.ts +19 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +25 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/packages.d.ts +48 -0
- package/dist/src/packages.d.ts.map +1 -0
- package/dist/src/packages.js +65 -0
- package/dist/src/packages.js.map +1 -0
- package/dist/src/repository.d.ts +21 -0
- package/dist/src/repository.d.ts.map +1 -0
- package/dist/src/repository.js +28 -0
- package/dist/src/repository.js.map +1 -0
- package/dist/src/tasks.d.ts +23 -0
- package/dist/src/tasks.d.ts.map +1 -0
- package/dist/src/tasks.js +31 -0
- package/dist/src/tasks.js.map +1 -0
- package/dist/src/types.d.ts +1339 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +517 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/workspaces.d.ts +63 -0
- package/dist/src/workspaces.d.ts.map +1 -0
- package/dist/src/workspaces.js +86 -0
- package/dist/src/workspaces.js.map +1 -0
- package/package.json +45 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Elara AI Pty Ltd
|
|
4
|
+
|
|
5
|
+
## License
|
|
6
|
+
|
|
7
|
+
**Licensor:** Elara AI Pty Ltd
|
|
8
|
+
|
|
9
|
+
**Licensed Work:** @elaraai/e3-api-client
|
|
10
|
+
|
|
11
|
+
**Change Date:** Four years from the date of each release
|
|
12
|
+
|
|
13
|
+
**Change License:** AGPL-3.0
|
|
14
|
+
|
|
15
|
+
## Terms
|
|
16
|
+
|
|
17
|
+
The Licensed Work is provided under the terms of the Business Source License 1.1 as detailed below.
|
|
18
|
+
|
|
19
|
+
### Grant of Rights
|
|
20
|
+
|
|
21
|
+
The Licensor grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work.
|
|
22
|
+
|
|
23
|
+
### Production Use Limitation
|
|
24
|
+
|
|
25
|
+
**"Production Use"** means any use by or on behalf of a for-profit entity, other than for evaluation, testing, or development purposes.
|
|
26
|
+
|
|
27
|
+
Production Use requires a separate commercial license from the Licensor.
|
|
28
|
+
|
|
29
|
+
### Change Date
|
|
30
|
+
|
|
31
|
+
On the Change Date (four years after each release), the Licensed Work will be made available under the Change License (AGPL-3.0).
|
|
32
|
+
|
|
33
|
+
### No Warranty
|
|
34
|
+
|
|
35
|
+
THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. THE LICENSOR DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
36
|
+
|
|
37
|
+
## Commercial Licensing
|
|
38
|
+
|
|
39
|
+
To obtain a commercial license for Production Use, contact:
|
|
40
|
+
|
|
41
|
+
**Email:** support@elara.ai
|
|
42
|
+
**Website:** https://elaraai.com
|
|
43
|
+
|
|
44
|
+
## Governing Law
|
|
45
|
+
|
|
46
|
+
This license is governed by the laws of New South Wales, Australia.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
*Elara AI Pty Ltd*
|
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# @elaraai/e3-api-client
|
|
2
|
+
|
|
3
|
+
TypeScript client library for e3 API servers.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @elaraai/e3-api-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Stateless functions for interacting with an e3 API server. Uses BEAST2 binary serialization for efficient request/response encoding.
|
|
14
|
+
|
|
15
|
+
## API
|
|
16
|
+
|
|
17
|
+
### Repository
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { repoStatus, repoGc } from '@elaraai/e3-api-client';
|
|
21
|
+
|
|
22
|
+
const status = await repoStatus('http://localhost:3000');
|
|
23
|
+
// { path: '/path/to/.e3', objectCount: 42n, packageCount: 3n, workspaceCount: 2n }
|
|
24
|
+
|
|
25
|
+
const gcResult = await repoGc(url, { dryRun: true, minAge: variant('none', null) });
|
|
26
|
+
// { deletedObjects: 0n, retainedObjects: 42n, bytesFreed: 0n, ... }
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Packages
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { packageList, packageImport, packageGet, packageExport, packageRemove } from '@elaraai/e3-api-client';
|
|
33
|
+
|
|
34
|
+
// List all packages
|
|
35
|
+
const packages = await packageList(url);
|
|
36
|
+
// [{ name: 'my-pkg', version: '1.0.0' }, ...]
|
|
37
|
+
|
|
38
|
+
// Import a package from zip bytes
|
|
39
|
+
const result = await packageImport(url, zipBytes);
|
|
40
|
+
// { name: 'my-pkg', version: '1.0.0', packageHash: 'abc123...', objectCount: 5n }
|
|
41
|
+
|
|
42
|
+
// Get package object
|
|
43
|
+
const pkg = await packageGet(url, 'my-pkg', '1.0.0');
|
|
44
|
+
|
|
45
|
+
// Export package as zip
|
|
46
|
+
const zip = await packageExport(url, 'my-pkg', '1.0.0');
|
|
47
|
+
|
|
48
|
+
// Remove package
|
|
49
|
+
await packageRemove(url, 'my-pkg', '1.0.0');
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Workspaces
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { workspaceList, workspaceCreate, workspaceGet, workspaceStatus, workspaceDeploy, workspaceRemove } from '@elaraai/e3-api-client';
|
|
56
|
+
|
|
57
|
+
// Create workspace
|
|
58
|
+
const info = await workspaceCreate(url, 'production');
|
|
59
|
+
// { name: 'production', deployed: false, packageName: null, packageVersion: null }
|
|
60
|
+
|
|
61
|
+
// Deploy package to workspace
|
|
62
|
+
await workspaceDeploy(url, 'production', 'my-pkg@1.0.0');
|
|
63
|
+
|
|
64
|
+
// Get workspace status
|
|
65
|
+
const status = await workspaceStatus(url, 'production');
|
|
66
|
+
// { workspace: 'production', datasets: [...], tasks: [...], summary: { ... } }
|
|
67
|
+
|
|
68
|
+
// List workspaces
|
|
69
|
+
const workspaces = await workspaceList(url);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Datasets
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { datasetList, datasetListAt, datasetGet, datasetSet } from '@elaraai/e3-api-client';
|
|
76
|
+
import { encodeBeast2For, decodeBeast2For, StringType, variant } from '@elaraai/east';
|
|
77
|
+
|
|
78
|
+
// List root fields
|
|
79
|
+
const fields = await datasetList(url, 'production');
|
|
80
|
+
// ['inputs', 'tasks']
|
|
81
|
+
|
|
82
|
+
// List nested fields
|
|
83
|
+
const inputFields = await datasetListAt(url, 'production', [variant('field', 'inputs')]);
|
|
84
|
+
// ['config', 'data']
|
|
85
|
+
|
|
86
|
+
// Get dataset value (raw BEAST2 bytes)
|
|
87
|
+
const path = [variant('field', 'inputs'), variant('field', 'config')];
|
|
88
|
+
const bytes = await datasetGet(url, 'production', path);
|
|
89
|
+
const value = decodeBeast2For(StringType)(bytes);
|
|
90
|
+
|
|
91
|
+
// Set dataset value
|
|
92
|
+
const encoded = encodeBeast2For(StringType)('new value');
|
|
93
|
+
await datasetSet(url, 'production', path, encoded);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Tasks
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { taskList, taskGet } from '@elaraai/e3-api-client';
|
|
100
|
+
|
|
101
|
+
// List tasks
|
|
102
|
+
const tasks = await taskList(url, 'production');
|
|
103
|
+
// [{ name: 'compute', hash: 'abc123...' }, ...]
|
|
104
|
+
|
|
105
|
+
// Get task details
|
|
106
|
+
const task = await taskGet(url, 'production', 'compute');
|
|
107
|
+
// { name: 'compute', hash: '...', commandIr: '...', inputs: [...], output: [...] }
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Execution
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { dataflowStart, dataflowExecute, dataflowGraph, taskLogs } from '@elaraai/e3-api-client';
|
|
114
|
+
|
|
115
|
+
// Start execution (non-blocking)
|
|
116
|
+
await dataflowStart(url, 'production', { force: true });
|
|
117
|
+
|
|
118
|
+
// Execute and wait for result (blocking)
|
|
119
|
+
const result = await dataflowExecute(url, 'production', { force: true });
|
|
120
|
+
// { success: true, executed: 1n, cached: 0n, failed: 0n, tasks: [...], duration: 1.234 }
|
|
121
|
+
|
|
122
|
+
// Get dependency graph
|
|
123
|
+
const graph = await dataflowGraph(url, 'production');
|
|
124
|
+
// { tasks: [{ name: 'compute', inputs: [...], output: '...', dependsOn: [...] }] }
|
|
125
|
+
|
|
126
|
+
// Read task logs
|
|
127
|
+
const logs = await taskLogs(url, 'production', 'compute', { stream: 'stdout' });
|
|
128
|
+
// { data: '...', offset: 0n, size: 1024n, totalSize: 2048n, complete: false }
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
BSL 1.1. See [LICENSE.md](./LICENSE.md).
|
|
134
|
+
|
|
135
|
+
### Ecosystem
|
|
136
|
+
|
|
137
|
+
- **[East Node](https://github.com/elaraai/east-node)**: Node.js platform functions for I/O, databases, and system operations. Connect East programs to filesystems, SQL/NoSQL databases, cloud storage, and network services.
|
|
138
|
+
- [@elaraai/east-node-std](https://www.npmjs.com/package/@elaraai/east-node-std): Filesystem, console, HTTP fetch, crypto, random distributions, timestamps
|
|
139
|
+
- [@elaraai/east-node-io](https://www.npmjs.com/package/@elaraai/east-node-io): SQLite, PostgreSQL, MySQL, MongoDB, S3, FTP, SFTP
|
|
140
|
+
- [@elaraai/east-node-cli](https://www.npmjs.com/package/@elaraai/east-node-cli): CLI for running East IR programs in Node.js
|
|
141
|
+
|
|
142
|
+
- **[East Python](https://github.com/elaraai/east-py)**: Python runtime and platform functions for data science and machine learning. Execute East programs with access to optimization solvers, gradient boosting, neural networks, and model explainability.
|
|
143
|
+
- [@elaraai/east-py-datascience](https://www.npmjs.com/package/@elaraai/east-py-datascience): TypeScript types for optimization, gradient boosting, neural networks, explainability
|
|
144
|
+
|
|
145
|
+
- **[East UI](https://github.com/elaraai/east-ui)**: East types and expressions for building dashboards and interactive layouts. Define UIs as data structures that render consistently across React, web, and other environments.
|
|
146
|
+
- [@elaraai/east-ui](https://www.npmjs.com/package/@elaraai/east-ui): 50+ typed UI components for layouts, forms, charts, tables, dialogs
|
|
147
|
+
- [@elaraai/east-ui-components](https://www.npmjs.com/package/@elaraai/east-ui-components): React renderer with Chakra UI styling
|
|
148
|
+
|
|
149
|
+
- **[e3 - East Execution Engine](https://github.com/elaraai/e3)**: Durable execution engine for running East pipelines at scale. Features Git-like content-addressable storage, automatic memoization, task queuing, and real-time monitoring.
|
|
150
|
+
- [@elaraai/e3](https://www.npmjs.com/package/@elaraai/e3): SDK for authoring e3 packages with typed tasks and pipelines
|
|
151
|
+
- [@elaraai/e3-core](https://www.npmjs.com/package/@elaraai/e3-core): Git-like object store, task queue, result caching
|
|
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
|
|
154
|
+
- [@elaraai/e3-api-client](https://www.npmjs.com/package/@elaraai/e3-api-client): HTTP client for remote e3 servers
|
|
155
|
+
- [@elaraai/e3-api-server](https://www.npmjs.com/package/@elaraai/e3-api-server): REST API server for e3 repositories
|
|
156
|
+
|
|
157
|
+
## Links
|
|
158
|
+
|
|
159
|
+
- [East Language](https://github.com/elaraai/east)
|
|
160
|
+
- [East Python Runtime](https://github.com/elaraai/east-py)
|
|
161
|
+
- [Elara AI](https://elaraai.com/)
|
|
162
|
+
- [Issues](https://github.com/elaraai/e3/issues)
|
|
163
|
+
- support@elara.ai
|
|
164
|
+
|
|
165
|
+
## About Elara
|
|
166
|
+
|
|
167
|
+
East is developed by [Elara AI Pty Ltd](https://elaraai.com/), an AI-powered platform that creates economic digital twins of businesses that optimize performance. Elara combines business objectives, decisions and data to help organizations make data-driven decisions across operations, purchasing, sales and customer engagement, and project and investment planning. East powers the computational layer of Elara solutions, enabling the expression of complex business logic and data in a simple, type-safe and portable language.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
*Developed by [Elara AI Pty Ltd](https://elaraai.com/)*
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import type { TreePath } from '@elaraai/e3-types';
|
|
6
|
+
/**
|
|
7
|
+
* List field names at root of workspace dataset tree.
|
|
8
|
+
*
|
|
9
|
+
* @param url - Base URL of the e3 API server
|
|
10
|
+
* @param workspace - Workspace name
|
|
11
|
+
* @returns Array of field names at root
|
|
12
|
+
*/
|
|
13
|
+
export declare function datasetList(url: string, workspace: string): Promise<string[]>;
|
|
14
|
+
/**
|
|
15
|
+
* List field names at a path in workspace dataset tree.
|
|
16
|
+
*
|
|
17
|
+
* @param url - Base URL of the e3 API server
|
|
18
|
+
* @param workspace - Workspace name
|
|
19
|
+
* @param path - Path to the dataset (e.g., ['inputs', 'config'])
|
|
20
|
+
* @returns Array of field names at path
|
|
21
|
+
*/
|
|
22
|
+
export declare function datasetListAt(url: string, workspace: string, path: TreePath): Promise<string[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Get a dataset value as raw BEAST2 bytes.
|
|
25
|
+
*
|
|
26
|
+
* The returned bytes are raw BEAST2 encoded data from the object store.
|
|
27
|
+
* Use decodeBeast2 or decodeBeast2For to decode with the appropriate type.
|
|
28
|
+
*
|
|
29
|
+
* @param url - Base URL of the e3 API server
|
|
30
|
+
* @param workspace - Workspace name
|
|
31
|
+
* @param path - Path to the dataset (e.g., ['inputs', 'config'])
|
|
32
|
+
* @returns Raw BEAST2 bytes
|
|
33
|
+
*/
|
|
34
|
+
export declare function datasetGet(url: string, workspace: string, path: TreePath): Promise<Uint8Array>;
|
|
35
|
+
/**
|
|
36
|
+
* Set a dataset value from raw BEAST2 bytes.
|
|
37
|
+
*
|
|
38
|
+
* @param url - Base URL of the e3 API server
|
|
39
|
+
* @param workspace - Workspace name
|
|
40
|
+
* @param path - Path to the dataset (e.g., ['inputs', 'config'])
|
|
41
|
+
* @param data - Raw BEAST2 encoded value
|
|
42
|
+
*/
|
|
43
|
+
export declare function datasetSet(url: string, workspace: string, path: TreePath, data: Uint8Array): Promise<void>;
|
|
44
|
+
//# sourceMappingURL=datasets.d.ts.map
|
|
@@ -0,0 +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,UAAU,GACf,OAAO,CAAC,IAAI,CAAC,CAgBf"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { ArrayType, StringType } from '@elaraai/east';
|
|
6
|
+
import { get, unwrap } from './http.js';
|
|
7
|
+
/**
|
|
8
|
+
* List field names at root of workspace dataset tree.
|
|
9
|
+
*
|
|
10
|
+
* @param url - Base URL of the e3 API server
|
|
11
|
+
* @param workspace - Workspace name
|
|
12
|
+
* @returns Array of field names at root
|
|
13
|
+
*/
|
|
14
|
+
export async function datasetList(url, workspace) {
|
|
15
|
+
const response = await get(url, `/api/workspaces/${encodeURIComponent(workspace)}/list`, ArrayType(StringType));
|
|
16
|
+
return unwrap(response);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* List field names at a path in workspace dataset tree.
|
|
20
|
+
*
|
|
21
|
+
* @param url - Base URL of the e3 API server
|
|
22
|
+
* @param workspace - Workspace name
|
|
23
|
+
* @param path - Path to the dataset (e.g., ['inputs', 'config'])
|
|
24
|
+
* @returns Array of field names at path
|
|
25
|
+
*/
|
|
26
|
+
export async function datasetListAt(url, workspace, path) {
|
|
27
|
+
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);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get a dataset value as raw BEAST2 bytes.
|
|
33
|
+
*
|
|
34
|
+
* The returned bytes are raw BEAST2 encoded data from the object store.
|
|
35
|
+
* Use decodeBeast2 or decodeBeast2For to decode with the appropriate type.
|
|
36
|
+
*
|
|
37
|
+
* @param url - Base URL of the e3 API server
|
|
38
|
+
* @param workspace - Workspace name
|
|
39
|
+
* @param path - Path to the dataset (e.g., ['inputs', 'config'])
|
|
40
|
+
* @returns Raw BEAST2 bytes
|
|
41
|
+
*/
|
|
42
|
+
export async function datasetGet(url, workspace, path) {
|
|
43
|
+
const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
|
|
44
|
+
const response = await fetch(`${url}/api/workspaces/${encodeURIComponent(workspace)}/get/${pathStr}`, {
|
|
45
|
+
method: 'GET',
|
|
46
|
+
headers: {
|
|
47
|
+
'Accept': 'application/beast2',
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new Error(`Failed to get dataset: ${response.status} ${response.statusText}`);
|
|
52
|
+
}
|
|
53
|
+
const buffer = await response.arrayBuffer();
|
|
54
|
+
return new Uint8Array(buffer);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Set a dataset value from raw BEAST2 bytes.
|
|
58
|
+
*
|
|
59
|
+
* @param url - Base URL of the e3 API server
|
|
60
|
+
* @param workspace - Workspace name
|
|
61
|
+
* @param path - Path to the dataset (e.g., ['inputs', 'config'])
|
|
62
|
+
* @param data - Raw BEAST2 encoded value
|
|
63
|
+
*/
|
|
64
|
+
export async function datasetSet(url, workspace, path, data) {
|
|
65
|
+
const pathStr = path.map(p => encodeURIComponent(p.value)).join('/');
|
|
66
|
+
const response = await fetch(`${url}/api/workspaces/${encodeURIComponent(workspace)}/set/${pathStr}`, {
|
|
67
|
+
method: 'PUT',
|
|
68
|
+
headers: {
|
|
69
|
+
'Content-Type': 'application/beast2',
|
|
70
|
+
},
|
|
71
|
+
body: data,
|
|
72
|
+
});
|
|
73
|
+
if (!response.ok) {
|
|
74
|
+
throw new Error(`Failed to set dataset: ${response.status} ${response.statusText}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=datasets.js.map
|
|
@@ -0,0 +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,KAAK,UAAU,aAAa,CACjC,GAAW,EACX,SAAiB,EACjB,IAAc;IAEd,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,MAAM,QAAQ,GAAG,MAAM,GAAG,CACxB,GAAG,EACH,mBAAmB,kBAAkB,CAAC,SAAS,CAAC,SAAS,OAAO,EAAE,EAClE,SAAS,CAAC,UAAU,CAAC,CACtB,CAAC;IACF,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;GAUG;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E,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IACtF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import type { LogChunk, DataflowGraph, DataflowResult } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Options for starting dataflow execution.
|
|
8
|
+
*/
|
|
9
|
+
export interface DataflowOptions {
|
|
10
|
+
/** Maximum parallel tasks (default: 4) */
|
|
11
|
+
concurrency?: number;
|
|
12
|
+
/** Force re-execution of all tasks */
|
|
13
|
+
force?: boolean;
|
|
14
|
+
/** Filter to specific task names */
|
|
15
|
+
filter?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Start dataflow execution on a workspace (non-blocking).
|
|
19
|
+
*
|
|
20
|
+
* Returns immediately after spawning execution in background.
|
|
21
|
+
* Use workspaceStatus() to poll for progress.
|
|
22
|
+
*
|
|
23
|
+
* @param url - Base URL of the e3 API server
|
|
24
|
+
* @param workspace - Workspace name
|
|
25
|
+
* @param options - Execution options
|
|
26
|
+
*/
|
|
27
|
+
export declare function dataflowStart(url: string, workspace: string, options?: DataflowOptions): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Execute dataflow on a workspace (blocking).
|
|
30
|
+
*
|
|
31
|
+
* Waits for execution to complete and returns the result.
|
|
32
|
+
*
|
|
33
|
+
* @param url - Base URL of the e3 API server
|
|
34
|
+
* @param workspace - Workspace name
|
|
35
|
+
* @param options - Execution options
|
|
36
|
+
* @returns Dataflow execution result
|
|
37
|
+
*/
|
|
38
|
+
export declare function dataflowExecute(url: string, workspace: string, options?: DataflowOptions): Promise<DataflowResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Get the dependency graph for a workspace.
|
|
41
|
+
*
|
|
42
|
+
* @param url - Base URL of the e3 API server
|
|
43
|
+
* @param workspace - Workspace name
|
|
44
|
+
* @returns Dataflow graph with tasks and dependencies
|
|
45
|
+
*/
|
|
46
|
+
export declare function dataflowGraph(url: string, workspace: string): Promise<DataflowGraph>;
|
|
47
|
+
/**
|
|
48
|
+
* Options for reading task logs.
|
|
49
|
+
*/
|
|
50
|
+
export interface LogOptions {
|
|
51
|
+
/** Which stream to read (default: 'stdout') */
|
|
52
|
+
stream?: 'stdout' | 'stderr';
|
|
53
|
+
/** Byte offset to start from (default: 0) */
|
|
54
|
+
offset?: number;
|
|
55
|
+
/** Maximum bytes to read (default: 65536) */
|
|
56
|
+
limit?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Read task logs from a workspace.
|
|
60
|
+
*
|
|
61
|
+
* @param url - Base URL of the e3 API server
|
|
62
|
+
* @param workspace - Workspace name
|
|
63
|
+
* @param task - Task name
|
|
64
|
+
* @param options - Log reading options
|
|
65
|
+
* @returns Log chunk with data and metadata
|
|
66
|
+
*/
|
|
67
|
+
export declare function taskLogs(url: string, workspace: string, task: string, options?: LogOptions): Promise<LogChunk>;
|
|
68
|
+
//# sourceMappingURL=executions.d.ts.map
|
|
@@ -0,0 +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,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,QAAQ,CAAC,CAWnB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
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';
|
|
8
|
+
/**
|
|
9
|
+
* Start dataflow execution on a workspace (non-blocking).
|
|
10
|
+
*
|
|
11
|
+
* Returns immediately after spawning execution in background.
|
|
12
|
+
* Use workspaceStatus() to poll for progress.
|
|
13
|
+
*
|
|
14
|
+
* @param url - Base URL of the e3 API server
|
|
15
|
+
* @param workspace - Workspace name
|
|
16
|
+
* @param options - Execution options
|
|
17
|
+
*/
|
|
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);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Execute dataflow on a workspace (blocking).
|
|
28
|
+
*
|
|
29
|
+
* Waits for execution to complete and returns the result.
|
|
30
|
+
*
|
|
31
|
+
* @param url - Base URL of the e3 API server
|
|
32
|
+
* @param workspace - Workspace name
|
|
33
|
+
* @param options - Execution options
|
|
34
|
+
* @returns Dataflow execution result
|
|
35
|
+
*/
|
|
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);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the dependency graph for a workspace.
|
|
46
|
+
*
|
|
47
|
+
* @param url - Base URL of the e3 API server
|
|
48
|
+
* @param workspace - Workspace name
|
|
49
|
+
* @returns Dataflow graph with tasks and dependencies
|
|
50
|
+
*/
|
|
51
|
+
export async function dataflowGraph(url, workspace) {
|
|
52
|
+
const response = await get(url, `/api/workspaces/${encodeURIComponent(workspace)}/graph`, DataflowGraphType);
|
|
53
|
+
return unwrap(response);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Read task logs from a workspace.
|
|
57
|
+
*
|
|
58
|
+
* @param url - Base URL of the e3 API server
|
|
59
|
+
* @param workspace - Workspace name
|
|
60
|
+
* @param task - Task name
|
|
61
|
+
* @param options - Log reading options
|
|
62
|
+
* @returns Log chunk with data and metadata
|
|
63
|
+
*/
|
|
64
|
+
export async function taskLogs(url, workspace, task, options = {}) {
|
|
65
|
+
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));
|
|
72
|
+
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);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=executions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executions.js","sourceRoot":"","sources":["../../src/executions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAc9C;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,GAAW,EACX,SAAiB,EACjB,UAA2B,EAAE;IAE7B,MAAM,QAAQ,GAAG,MAAM,IAAI,CACzB,GAAG,EACH,mBAAmB,kBAAkB,CAAC,SAAS,CAAC,QAAQ,EACxD;QACE,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,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AAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,GAAW,EACX,SAAiB,EACjB,IAAY,EACZ,UAAsB,EAAE;IAExB,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,IAAI,OAAO,CAAC,MAAM;QAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI;QAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACzE,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI;QAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAEtE,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAChC,MAAM,IAAI,GAAG,mBAAmB,kBAAkB,CAAC,SAAS,CAAC,SAAS,kBAAkB,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAE5H,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import type { EastType, ValueTypeOf } from '@elaraai/east';
|
|
6
|
+
import { ErrorType } from './types.js';
|
|
7
|
+
export type Response<T> = {
|
|
8
|
+
type: 'success';
|
|
9
|
+
value: T;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'error';
|
|
12
|
+
value: ValueTypeOf<typeof ErrorType>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Make a GET request and decode BEAST2 response.
|
|
16
|
+
*/
|
|
17
|
+
export declare function get<T extends EastType>(url: string, path: string, successType: T): Promise<Response<ValueTypeOf<T>>>;
|
|
18
|
+
/**
|
|
19
|
+
* Make a POST request with BEAST2 body and decode BEAST2 response.
|
|
20
|
+
*/
|
|
21
|
+
export declare function post<Req extends EastType, Res extends EastType>(url: string, path: string, body: ValueTypeOf<Req>, requestType: Req, successType: Res): Promise<Response<ValueTypeOf<Res>>>;
|
|
22
|
+
/**
|
|
23
|
+
* Make a PUT request with BEAST2 body and decode BEAST2 response.
|
|
24
|
+
*/
|
|
25
|
+
export declare function put<Req extends EastType, Res extends EastType>(url: string, path: string, body: ValueTypeOf<Req>, requestType: Req, successType: Res): Promise<Response<ValueTypeOf<Res>>>;
|
|
26
|
+
/**
|
|
27
|
+
* Make a DELETE request and decode BEAST2 response.
|
|
28
|
+
*/
|
|
29
|
+
export declare function del<T extends EastType>(url: string, path: string, successType: T): Promise<Response<ValueTypeOf<T>>>;
|
|
30
|
+
/**
|
|
31
|
+
* Unwrap a response, throwing on error.
|
|
32
|
+
*/
|
|
33
|
+
export declare function unwrap<T>(response: Response<T>): T;
|
|
34
|
+
/**
|
|
35
|
+
* API error with typed error details.
|
|
36
|
+
*/
|
|
37
|
+
export declare class ApiError extends Error {
|
|
38
|
+
readonly code: string;
|
|
39
|
+
readonly details: unknown;
|
|
40
|
+
constructor(code: string, details: unknown);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAgB,SAAS,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,MAAM,QA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,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAMlD;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;aAEf,IAAI,EAAE,MAAM;aACZ,OAAO,EAAE,OAAO;gBADhB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO;CAKnC"}
|
package/dist/src/http.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { encodeBeast2For, decodeBeast2For } from '@elaraai/east';
|
|
6
|
+
import { ResponseType } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Make a GET request and decode BEAST2 response.
|
|
9
|
+
*/
|
|
10
|
+
export async function get(url, path, successType) {
|
|
11
|
+
const response = await fetch(`${url}${path}`, {
|
|
12
|
+
method: 'GET',
|
|
13
|
+
headers: {
|
|
14
|
+
'Accept': 'application/beast2',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
return decodeResponse(response, successType);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Make a POST request with BEAST2 body and decode BEAST2 response.
|
|
21
|
+
*/
|
|
22
|
+
export async function post(url, path, body, requestType, successType) {
|
|
23
|
+
const encode = encodeBeast2For(requestType);
|
|
24
|
+
const response = await fetch(`${url}${path}`, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'application/beast2',
|
|
28
|
+
'Accept': 'application/beast2',
|
|
29
|
+
},
|
|
30
|
+
body: encode(body),
|
|
31
|
+
});
|
|
32
|
+
return decodeResponse(response, successType);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Make a PUT request with BEAST2 body and decode BEAST2 response.
|
|
36
|
+
*/
|
|
37
|
+
export async function put(url, path, body, requestType, successType) {
|
|
38
|
+
const encode = encodeBeast2For(requestType);
|
|
39
|
+
const response = await fetch(`${url}${path}`, {
|
|
40
|
+
method: 'PUT',
|
|
41
|
+
headers: {
|
|
42
|
+
'Content-Type': 'application/beast2',
|
|
43
|
+
'Accept': 'application/beast2',
|
|
44
|
+
},
|
|
45
|
+
body: encode(body),
|
|
46
|
+
});
|
|
47
|
+
return decodeResponse(response, successType);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Make a DELETE request and decode BEAST2 response.
|
|
51
|
+
*/
|
|
52
|
+
export async function del(url, path, successType) {
|
|
53
|
+
const response = await fetch(`${url}${path}`, {
|
|
54
|
+
method: 'DELETE',
|
|
55
|
+
headers: {
|
|
56
|
+
'Accept': 'application/beast2',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
return decodeResponse(response, successType);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Decode a BEAST2 response with the Response wrapper type.
|
|
63
|
+
*/
|
|
64
|
+
async function decodeResponse(response, successType) {
|
|
65
|
+
if (response.status === 400) {
|
|
66
|
+
throw new Error(`Bad request: ${await response.text()}`);
|
|
67
|
+
}
|
|
68
|
+
if (response.status === 415) {
|
|
69
|
+
throw new Error(`Unsupported media type: expected application/beast2`);
|
|
70
|
+
}
|
|
71
|
+
const buffer = await response.arrayBuffer();
|
|
72
|
+
const decode = decodeBeast2For(ResponseType(successType));
|
|
73
|
+
return decode(new Uint8Array(buffer));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Unwrap a response, throwing on error.
|
|
77
|
+
*/
|
|
78
|
+
export function unwrap(response) {
|
|
79
|
+
if (response.type === 'error') {
|
|
80
|
+
const err = response.value;
|
|
81
|
+
throw new ApiError(err.type, err.value);
|
|
82
|
+
}
|
|
83
|
+
return response.value;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* API error with typed error details.
|
|
87
|
+
*/
|
|
88
|
+
export class ApiError extends Error {
|
|
89
|
+
code;
|
|
90
|
+
details;
|
|
91
|
+
constructor(code, details) {
|
|
92
|
+
super(`API error: ${code}`);
|
|
93
|
+
this.code = code;
|
|
94
|
+
this.details = details;
|
|
95
|
+
this.name = 'ApiError';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAa,MAAM,YAAY,CAAC;AAMrD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CACvB,GAAW,EACX,IAAY,EACZ,WAAc;IAEd,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,GAAG,GAAG,IAAI,EAAE,EAAE;QAC5C,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,QAAQ,EAAE,oBAAoB;SAC/B;KACF,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,GAAW,EACX,IAAY,EACZ,IAAsB,EACtB,WAAgB,EAChB,WAAgB;IAEhB,MAAM,MAAM,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,GAAG,GAAG,IAAI,EAAE,EAAE;QAC5C,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,oBAAoB;YACpC,QAAQ,EAAE,oBAAoB;SAC/B;QACD,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;KACnB,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU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