@elaraai/e3-api-server 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 +156 -0
- package/dist/src/beast2.d.ts +20 -0
- package/dist/src/beast2.d.ts.map +1 -0
- package/dist/src/beast2.js +47 -0
- package/dist/src/beast2.js.map +1 -0
- package/dist/src/cli.d.ts +7 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +34 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/errors.d.ts +10 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +73 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.d.ts +13 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +13 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/routes/datasets.d.ts +7 -0
- package/dist/src/routes/datasets.d.ts.map +1 -0
- package/dist/src/routes/datasets.js +98 -0
- package/dist/src/routes/datasets.js.map +1 -0
- package/dist/src/routes/executions.d.ts +7 -0
- package/dist/src/routes/executions.d.ts.map +1 -0
- package/dist/src/routes/executions.js +303 -0
- package/dist/src/routes/executions.js.map +1 -0
- package/dist/src/routes/packages.d.ts +7 -0
- package/dist/src/routes/packages.d.ts.map +1 -0
- package/dist/src/routes/packages.js +124 -0
- package/dist/src/routes/packages.js.map +1 -0
- package/dist/src/routes/repository.d.ts +7 -0
- package/dist/src/routes/repository.d.ts.map +1 -0
- package/dist/src/routes/repository.js +67 -0
- package/dist/src/routes/repository.js.map +1 -0
- package/dist/src/routes/tasks.d.ts +7 -0
- package/dist/src/routes/tasks.d.ts.map +1 -0
- package/dist/src/routes/tasks.js +58 -0
- package/dist/src/routes/tasks.js.map +1 -0
- package/dist/src/routes/workspaces.d.ts +7 -0
- package/dist/src/routes/workspaces.d.ts.map +1 -0
- package/dist/src/routes/workspaces.js +133 -0
- package/dist/src/routes/workspaces.js.map +1 -0
- package/dist/src/server.d.ts +37 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +83 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/types.d.ts +1310 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +471 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +25 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +27 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +53 -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-server
|
|
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,156 @@
|
|
|
1
|
+
# @elaraai/e3-api-server
|
|
2
|
+
|
|
3
|
+
HTTP server for e3 repositories.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @elaraai/e3-api-server
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
REST API server exposing e3-core operations over HTTP. Uses BEAST2 binary serialization for efficient request/response encoding.
|
|
14
|
+
|
|
15
|
+
## CLI Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Start server on default port 3000
|
|
19
|
+
e3-api-server /path/to/.e3
|
|
20
|
+
|
|
21
|
+
# Custom port and host
|
|
22
|
+
e3-api-server /path/to/.e3 --port 8080 --host 0.0.0.0
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Programmatic Usage
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { createServer } from '@elaraai/e3-api-server';
|
|
29
|
+
|
|
30
|
+
const server = createServer({
|
|
31
|
+
repo: '/path/to/.e3',
|
|
32
|
+
port: 3000,
|
|
33
|
+
host: 'localhost',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await server.start();
|
|
37
|
+
console.log(`Server listening on port ${server.port}`);
|
|
38
|
+
|
|
39
|
+
// Graceful shutdown
|
|
40
|
+
await server.stop();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API Endpoints
|
|
44
|
+
|
|
45
|
+
### Repository
|
|
46
|
+
|
|
47
|
+
| Method | Endpoint | Description |
|
|
48
|
+
|--------|----------|-------------|
|
|
49
|
+
| GET | `/api/status` | Repository status (path, object/package/workspace counts) |
|
|
50
|
+
| POST | `/api/gc` | Garbage collection |
|
|
51
|
+
|
|
52
|
+
### Packages
|
|
53
|
+
|
|
54
|
+
| Method | Endpoint | Description |
|
|
55
|
+
|--------|----------|-------------|
|
|
56
|
+
| GET | `/api/packages` | List all packages |
|
|
57
|
+
| GET | `/api/packages/:name/:version` | Get package details |
|
|
58
|
+
| POST | `/api/packages` | Import package (zip body) |
|
|
59
|
+
| GET | `/api/packages/:name/:version/export` | Export package as zip |
|
|
60
|
+
| DELETE | `/api/packages/:name/:version` | Remove package |
|
|
61
|
+
|
|
62
|
+
### Workspaces
|
|
63
|
+
|
|
64
|
+
| Method | Endpoint | Description |
|
|
65
|
+
|--------|----------|-------------|
|
|
66
|
+
| GET | `/api/workspaces` | List all workspaces |
|
|
67
|
+
| POST | `/api/workspaces` | Create workspace |
|
|
68
|
+
| GET | `/api/workspaces/:ws` | Get workspace info |
|
|
69
|
+
| GET | `/api/workspaces/:ws/status` | Get workspace status (datasets, tasks, summary) |
|
|
70
|
+
| POST | `/api/workspaces/:ws/deploy` | Deploy package to workspace |
|
|
71
|
+
| DELETE | `/api/workspaces/:ws` | Remove workspace |
|
|
72
|
+
|
|
73
|
+
### Datasets
|
|
74
|
+
|
|
75
|
+
| Method | Endpoint | Description |
|
|
76
|
+
|--------|----------|-------------|
|
|
77
|
+
| GET | `/api/workspaces/:ws/list` | List root dataset fields |
|
|
78
|
+
| GET | `/api/workspaces/:ws/list/*path` | List nested dataset fields |
|
|
79
|
+
| GET | `/api/workspaces/:ws/get/*path` | Get dataset value (BEAST2) |
|
|
80
|
+
| PUT | `/api/workspaces/:ws/set/*path` | Set dataset value (BEAST2) |
|
|
81
|
+
|
|
82
|
+
### Tasks
|
|
83
|
+
|
|
84
|
+
| Method | Endpoint | Description |
|
|
85
|
+
|--------|----------|-------------|
|
|
86
|
+
| GET | `/api/workspaces/:ws/tasks` | List tasks |
|
|
87
|
+
| GET | `/api/workspaces/:ws/tasks/:task` | Get task details |
|
|
88
|
+
|
|
89
|
+
### Execution
|
|
90
|
+
|
|
91
|
+
| Method | Endpoint | Description |
|
|
92
|
+
|--------|----------|-------------|
|
|
93
|
+
| POST | `/api/workspaces/:ws/start` | Start dataflow (non-blocking) |
|
|
94
|
+
| POST | `/api/workspaces/:ws/execute` | Execute dataflow (blocking, returns result) |
|
|
95
|
+
| GET | `/api/workspaces/:ws/graph` | Get dependency graph |
|
|
96
|
+
| GET | `/api/workspaces/:ws/logs/:task` | Read task logs |
|
|
97
|
+
|
|
98
|
+
## Request/Response Format
|
|
99
|
+
|
|
100
|
+
All requests and responses use BEAST2 binary encoding with `Content-Type: application/beast2`.
|
|
101
|
+
|
|
102
|
+
Response bodies are wrapped in a variant type:
|
|
103
|
+
- `{ type: 'success', value: <result> }` - Operation succeeded
|
|
104
|
+
- `{ type: 'error', value: <error> }` - Operation failed
|
|
105
|
+
|
|
106
|
+
Error variants include:
|
|
107
|
+
- `workspace_not_found` - Workspace doesn't exist
|
|
108
|
+
- `workspace_not_deployed` - No package deployed to workspace
|
|
109
|
+
- `workspace_locked` - Workspace is locked by another process
|
|
110
|
+
- `package_not_found` - Package doesn't exist
|
|
111
|
+
- `package_exists` - Package already exists
|
|
112
|
+
- `dataset_not_found` - Dataset path doesn't exist
|
|
113
|
+
- `task_not_found` - Task doesn't exist
|
|
114
|
+
- `internal` - Internal server error
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
BSL 1.1. See [LICENSE.md](./LICENSE.md).
|
|
119
|
+
|
|
120
|
+
### Ecosystem
|
|
121
|
+
|
|
122
|
+
- **[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.
|
|
123
|
+
- [@elaraai/east-node-std](https://www.npmjs.com/package/@elaraai/east-node-std): Filesystem, console, HTTP fetch, crypto, random distributions, timestamps
|
|
124
|
+
- [@elaraai/east-node-io](https://www.npmjs.com/package/@elaraai/east-node-io): SQLite, PostgreSQL, MySQL, MongoDB, S3, FTP, SFTP
|
|
125
|
+
- [@elaraai/east-node-cli](https://www.npmjs.com/package/@elaraai/east-node-cli): CLI for running East IR programs in Node.js
|
|
126
|
+
|
|
127
|
+
- **[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.
|
|
128
|
+
- [@elaraai/east-py-datascience](https://www.npmjs.com/package/@elaraai/east-py-datascience): TypeScript types for optimization, gradient boosting, neural networks, explainability
|
|
129
|
+
|
|
130
|
+
- **[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.
|
|
131
|
+
- [@elaraai/east-ui](https://www.npmjs.com/package/@elaraai/east-ui): 50+ typed UI components for layouts, forms, charts, tables, dialogs
|
|
132
|
+
- [@elaraai/east-ui-components](https://www.npmjs.com/package/@elaraai/east-ui-components): React renderer with Chakra UI styling
|
|
133
|
+
|
|
134
|
+
- **[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.
|
|
135
|
+
- [@elaraai/e3](https://www.npmjs.com/package/@elaraai/e3): SDK for authoring e3 packages with typed tasks and pipelines
|
|
136
|
+
- [@elaraai/e3-core](https://www.npmjs.com/package/@elaraai/e3-core): Git-like object store, task queue, result caching
|
|
137
|
+
- [@elaraai/e3-types](https://www.npmjs.com/package/@elaraai/e3-types): Shared type definitions for e3 packages
|
|
138
|
+
- [@elaraai/e3-cli](https://www.npmjs.com/package/@elaraai/e3-cli): `e3 init`, `e3 run`, `e3 logs` commands for managing and monitoring tasks
|
|
139
|
+
- [@elaraai/e3-api-client](https://www.npmjs.com/package/@elaraai/e3-api-client): HTTP client for remote e3 servers
|
|
140
|
+
- [@elaraai/e3-api-server](https://www.npmjs.com/package/@elaraai/e3-api-server): REST API server for e3 repositories
|
|
141
|
+
|
|
142
|
+
## Links
|
|
143
|
+
|
|
144
|
+
- [East Language](https://github.com/elaraai/east)
|
|
145
|
+
- [East Python Runtime](https://github.com/elaraai/east-py)
|
|
146
|
+
- [Elara AI](https://elaraai.com/)
|
|
147
|
+
- [Issues](https://github.com/elaraai/e3/issues)
|
|
148
|
+
- support@elara.ai
|
|
149
|
+
|
|
150
|
+
## About Elara
|
|
151
|
+
|
|
152
|
+
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.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
*Developed by [Elara AI Pty Ltd](https://elaraai.com/)*
|
|
@@ -0,0 +1,20 @@
|
|
|
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 type { Context } from 'hono';
|
|
7
|
+
import { type Error } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Decode BEAST2 request body.
|
|
10
|
+
*/
|
|
11
|
+
export declare function decodeBody<T extends EastType>(c: Context, type: T): Promise<ValueTypeOf<T>>;
|
|
12
|
+
/**
|
|
13
|
+
* Send BEAST2 success response.
|
|
14
|
+
*/
|
|
15
|
+
export declare function sendSuccess<T extends EastType>(c: Context, type: T, value: ValueTypeOf<T>): Response;
|
|
16
|
+
/**
|
|
17
|
+
* Send BEAST2 error response.
|
|
18
|
+
*/
|
|
19
|
+
export declare function sendError<T extends EastType>(c: Context, type: T, error: Error): Response;
|
|
20
|
+
//# sourceMappingURL=beast2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beast2.d.ts","sourceRoot":"","sources":["../../src/beast2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAgB,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtD;;GAEG;AACH,wBAAsB,UAAU,CAAC,CAAC,SAAS,QAAQ,EACjD,CAAC,EAAE,OAAO,EACV,IAAI,EAAE,CAAC,GACN,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CASzB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,QAAQ,EAC5C,CAAC,EAAE,OAAO,EACV,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GACpB,QAAQ,CAWV;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,QAAQ,EAC1C,CAAC,EAAE,OAAO,EACV,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,KAAK,GACX,QAAQ,CAWV"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { encodeBeast2For, decodeBeast2For, variant } from '@elaraai/east';
|
|
6
|
+
import { ResponseType } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Decode BEAST2 request body.
|
|
9
|
+
*/
|
|
10
|
+
export async function decodeBody(c, type) {
|
|
11
|
+
const contentType = c.req.header('content-type');
|
|
12
|
+
if (contentType !== 'application/beast2') {
|
|
13
|
+
throw new Error(`Expected Content-Type: application/beast2, got ${contentType}`);
|
|
14
|
+
}
|
|
15
|
+
const buffer = await c.req.arrayBuffer();
|
|
16
|
+
const decode = decodeBeast2For(type);
|
|
17
|
+
return decode(new Uint8Array(buffer));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Send BEAST2 success response.
|
|
21
|
+
*/
|
|
22
|
+
export function sendSuccess(c, type, value) {
|
|
23
|
+
const responseType = ResponseType(type);
|
|
24
|
+
const encode = encodeBeast2For(responseType);
|
|
25
|
+
const body = encode(variant('success', value));
|
|
26
|
+
return new Response(body, {
|
|
27
|
+
status: 200,
|
|
28
|
+
headers: {
|
|
29
|
+
'Content-Type': 'application/beast2',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Send BEAST2 error response.
|
|
35
|
+
*/
|
|
36
|
+
export function sendError(c, type, error) {
|
|
37
|
+
const responseType = ResponseType(type);
|
|
38
|
+
const encode = encodeBeast2For(responseType);
|
|
39
|
+
const body = encode(variant('error', error));
|
|
40
|
+
return new Response(body, {
|
|
41
|
+
status: 200,
|
|
42
|
+
headers: {
|
|
43
|
+
'Content-Type': 'application/beast2',
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=beast2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beast2.js","sourceRoot":"","sources":["../../src/beast2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG1E,OAAO,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,KAA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F,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG"}
|
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
4
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import { createServer } from './server.js';
|
|
8
|
+
const program = new Command();
|
|
9
|
+
program
|
|
10
|
+
.name('e3-api-server')
|
|
11
|
+
.description('HTTP server for e3 repositories')
|
|
12
|
+
.version('0.0.1-beta.0')
|
|
13
|
+
.argument('<repo>', 'Path to e3 repository')
|
|
14
|
+
.option('-p, --port <port>', 'HTTP port', '3000')
|
|
15
|
+
.option('-H, --host <host>', 'Bind address', 'localhost')
|
|
16
|
+
.action(async (repo, options) => {
|
|
17
|
+
const server = await createServer({
|
|
18
|
+
repo,
|
|
19
|
+
port: parseInt(options.port, 10),
|
|
20
|
+
host: options.host,
|
|
21
|
+
});
|
|
22
|
+
await server.start();
|
|
23
|
+
console.log(`e3-api-server listening on http://${options.host}:${server.port}`);
|
|
24
|
+
// Handle shutdown signals
|
|
25
|
+
const shutdown = async () => {
|
|
26
|
+
console.log('\nShutting down...');
|
|
27
|
+
await server.stop();
|
|
28
|
+
process.exit(0);
|
|
29
|
+
};
|
|
30
|
+
process.on('SIGINT', () => void shutdown());
|
|
31
|
+
process.on('SIGTERM', () => void shutdown());
|
|
32
|
+
});
|
|
33
|
+
program.parse();
|
|
34
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,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,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import type { Error } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Convert an e3-core error to an API error variant.
|
|
8
|
+
*/
|
|
9
|
+
export declare function errorToVariant(err: unknown): Error;
|
|
10
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkBH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CA+DlD"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { variant, some, none } from '@elaraai/east';
|
|
6
|
+
import { WorkspaceNotFoundError, WorkspaceNotDeployedError, WorkspaceExistsError, WorkspaceLockError, PackageNotFoundError, PackageExistsError, PackageInvalidError, DatasetNotFoundError, TaskNotFoundError, ObjectNotFoundError, DataflowError, DataflowAbortedError, PermissionDeniedError, } from '@elaraai/e3-core';
|
|
7
|
+
/**
|
|
8
|
+
* Convert an e3-core error to an API error variant.
|
|
9
|
+
*/
|
|
10
|
+
export function errorToVariant(err) {
|
|
11
|
+
if (err instanceof WorkspaceNotFoundError) {
|
|
12
|
+
return variant('workspace_not_found', { workspace: err.workspace });
|
|
13
|
+
}
|
|
14
|
+
if (err instanceof WorkspaceNotDeployedError) {
|
|
15
|
+
return variant('workspace_not_deployed', { workspace: err.workspace });
|
|
16
|
+
}
|
|
17
|
+
if (err instanceof WorkspaceExistsError) {
|
|
18
|
+
return variant('workspace_exists', { workspace: err.workspace });
|
|
19
|
+
}
|
|
20
|
+
if (err instanceof WorkspaceLockError) {
|
|
21
|
+
return variant('workspace_locked', {
|
|
22
|
+
workspace: err.workspace,
|
|
23
|
+
holder: err.holder
|
|
24
|
+
? variant('known', {
|
|
25
|
+
pid: BigInt(err.holder.pid),
|
|
26
|
+
acquiredAt: err.holder.acquiredAt,
|
|
27
|
+
bootId: err.holder.bootId ? some(err.holder.bootId) : none,
|
|
28
|
+
command: err.holder.command ? some(err.holder.command) : none,
|
|
29
|
+
})
|
|
30
|
+
: variant('unknown', null),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (err instanceof PackageNotFoundError) {
|
|
34
|
+
return variant('package_not_found', {
|
|
35
|
+
packageName: err.packageName,
|
|
36
|
+
version: err.version ? some(err.version) : none,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (err instanceof PackageExistsError) {
|
|
40
|
+
return variant('package_exists', {
|
|
41
|
+
packageName: err.packageName,
|
|
42
|
+
version: err.version,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (err instanceof PackageInvalidError) {
|
|
46
|
+
return variant('package_invalid', { reason: err.message });
|
|
47
|
+
}
|
|
48
|
+
if (err instanceof DatasetNotFoundError) {
|
|
49
|
+
return variant('dataset_not_found', {
|
|
50
|
+
workspace: err.workspace,
|
|
51
|
+
path: err.path,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (err instanceof TaskNotFoundError) {
|
|
55
|
+
return variant('task_not_found', { task: err.task });
|
|
56
|
+
}
|
|
57
|
+
if (err instanceof ObjectNotFoundError) {
|
|
58
|
+
return variant('object_not_found', { hash: err.hash });
|
|
59
|
+
}
|
|
60
|
+
if (err instanceof DataflowError) {
|
|
61
|
+
return variant('dataflow_error', { message: err.message });
|
|
62
|
+
}
|
|
63
|
+
if (err instanceof DataflowAbortedError) {
|
|
64
|
+
return variant('dataflow_aborted', null);
|
|
65
|
+
}
|
|
66
|
+
if (err instanceof PermissionDeniedError) {
|
|
67
|
+
return variant('permission_denied', { path: err.path });
|
|
68
|
+
}
|
|
69
|
+
// Fallback for unknown errors
|
|
70
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
71
|
+
return variant('internal', { message });
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAG1B;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,GAAY;IACzC,IAAI,GAAG,YAAY,sBAAsB,EAAE,CAAC;QAC1C,OAAO,OAAO,CAAC,qBAAqB,EAAE,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,GAAG,YAAY,yBAAyB,EAAE,CAAC;QAC7C,OAAO,OAAO,CAAC,wBAAwB,EAAE,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,GAAG,YAAY,oBAAoB,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,kBAAkB,EAAE,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,IAAI,GAAG,YAAY,kBAAkB,EAAE,CAAC;QACtC,OAAO,OAAO,CAAC,kBAAkB,E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|
|
5
|
+
/**
|
|
6
|
+
* e3-api-server: HTTP server exposing e3-core operations
|
|
7
|
+
*
|
|
8
|
+
* Provides a REST API with BEAST2 serialization for remote access to e3 repositories.
|
|
9
|
+
* Stateless design - clients poll /status endpoint to track execution progress.
|
|
10
|
+
*/
|
|
11
|
+
export { createServer, type ServerConfig, type Server } from './server.js';
|
|
12
|
+
export { ApiTypes } from './types.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* e3-api-server: HTTP server exposing e3-core operations
|
|
7
|
+
*
|
|
8
|
+
* Provides a REST API with BEAST2 serialization for remote access to e3 repositories.
|
|
9
|
+
* Stateless design - clients poll /status endpoint to track execution progress.
|
|
10
|
+
*/
|
|
11
|
+
export { createServer } from './server.js';
|
|
12
|
+
export { ApiTypes } from './types.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAkC,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { Hono } from 'hono';
|
|
6
|
+
export declare function createDatasetRoutes(repoPath: string): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
7
|
+
//# sourceMappingURL=datasets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasets.d.ts","sourceRoot":"","sources":["../../../src/routes/datasets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAa5B,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,8EA8FnD"}
|
|
@@ -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 { Hono } from 'hono';
|
|
6
|
+
import { NullType, ArrayType, StringType, decodeBeast2 } from '@elaraai/east';
|
|
7
|
+
import { urlPathToTreePath } from '@elaraai/e3-types';
|
|
8
|
+
import { workspaceListTree, workspaceGetDatasetHash, workspaceSetDataset, objectRead, } from '@elaraai/e3-core';
|
|
9
|
+
import { sendSuccess, sendError } from '../beast2.js';
|
|
10
|
+
import { errorToVariant } from '../errors.js';
|
|
11
|
+
import { extractWildcardPath } from '../utils.js';
|
|
12
|
+
export function createDatasetRoutes(repoPath) {
|
|
13
|
+
const app = new Hono();
|
|
14
|
+
// GET /list - List field names at root (e3 list <repo> <ws>)
|
|
15
|
+
app.get('/list', async (c) => {
|
|
16
|
+
try {
|
|
17
|
+
const workspace = c.req.param('ws');
|
|
18
|
+
if (!workspace) {
|
|
19
|
+
return sendError(c, ArrayType(StringType), errorToVariant(new Error('Missing workspace parameter')));
|
|
20
|
+
}
|
|
21
|
+
const fields = await workspaceListTree(repoPath, workspace, []);
|
|
22
|
+
return sendSuccess(c, ArrayType(StringType), fields);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
return sendError(c, ArrayType(StringType), errorToVariant(err));
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
// GET /list/* - List field names at path (e3 list <repo> <ws.path>)
|
|
29
|
+
app.get('/list/*', async (c) => {
|
|
30
|
+
try {
|
|
31
|
+
const workspace = c.req.param('ws');
|
|
32
|
+
if (!workspace) {
|
|
33
|
+
return sendError(c, ArrayType(StringType), errorToVariant(new Error('Missing workspace parameter')));
|
|
34
|
+
}
|
|
35
|
+
const pathStr = extractWildcardPath(c.req.path, /^\/api\/workspaces\/[^/]+\/list\//);
|
|
36
|
+
const treePath = urlPathToTreePath(pathStr);
|
|
37
|
+
const fields = await workspaceListTree(repoPath, workspace, treePath);
|
|
38
|
+
return sendSuccess(c, ArrayType(StringType), fields);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
return sendError(c, ArrayType(StringType), errorToVariant(err));
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
// GET /get/* - Get dataset value as raw BEAST2 (e3 get <repo> <ws.path>)
|
|
45
|
+
app.get('/get/*', async (c) => {
|
|
46
|
+
try {
|
|
47
|
+
const workspace = c.req.param('ws');
|
|
48
|
+
if (!workspace) {
|
|
49
|
+
return sendError(c, NullType, errorToVariant(new Error('Missing workspace parameter')));
|
|
50
|
+
}
|
|
51
|
+
const pathStr = extractWildcardPath(c.req.path, /^\/api\/workspaces\/[^/]+\/get\//);
|
|
52
|
+
const treePath = urlPathToTreePath(pathStr);
|
|
53
|
+
if (treePath.length === 0) {
|
|
54
|
+
return sendError(c, NullType, errorToVariant(new Error('Path required for get')));
|
|
55
|
+
}
|
|
56
|
+
const { refType, hash } = await workspaceGetDatasetHash(repoPath, workspace, treePath);
|
|
57
|
+
if (refType === 'unassigned') {
|
|
58
|
+
return sendError(c, NullType, errorToVariant(new Error('Dataset is unassigned (pending task output)')));
|
|
59
|
+
}
|
|
60
|
+
if (refType === 'null' || !hash) {
|
|
61
|
+
return sendError(c, NullType, errorToVariant(new Error('Dataset is null')));
|
|
62
|
+
}
|
|
63
|
+
// Return raw BEAST2 bytes directly from object store
|
|
64
|
+
const data = await objectRead(repoPath, hash);
|
|
65
|
+
return new Response(data, {
|
|
66
|
+
status: 200,
|
|
67
|
+
headers: { 'Content-Type': 'application/beast2' },
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
return sendError(c, NullType, errorToVariant(err));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
// PUT /set/* - Set dataset value from raw BEAST2 (e3 set <repo> <ws.path>)
|
|
75
|
+
app.put('/set/*', async (c) => {
|
|
76
|
+
try {
|
|
77
|
+
const workspace = c.req.param('ws');
|
|
78
|
+
if (!workspace) {
|
|
79
|
+
return sendError(c, NullType, errorToVariant(new Error('Missing workspace parameter')));
|
|
80
|
+
}
|
|
81
|
+
const pathStr = extractWildcardPath(c.req.path, /^\/api\/workspaces\/[^/]+\/set\//);
|
|
82
|
+
const treePath = urlPathToTreePath(pathStr);
|
|
83
|
+
if (treePath.length === 0) {
|
|
84
|
+
return sendError(c, NullType, errorToVariant(new Error('Path required for set')));
|
|
85
|
+
}
|
|
86
|
+
// Body is raw BEAST2 - decode to get type and value
|
|
87
|
+
const buffer = await c.req.arrayBuffer();
|
|
88
|
+
const { type, value } = decodeBeast2(new Uint8Array(buffer));
|
|
89
|
+
await workspaceSetDataset(repoPath, workspace, treePath, value, type);
|
|
90
|
+
return sendSuccess(c, NullType, null);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
return sendError(c, NullType, errorToVariant(err));
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return app;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=datasets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datas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AAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { Hono } from 'hono';
|
|
6
|
+
export declare function createExecutionRoutes(repoPath: string): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
7
|
+
//# sourceMappingURL=executions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executions.d.ts","sourceRoot":"","sources":["../../../src/routes/executions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAgM5B,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,8EAgKrD"}
|