@elaraai/east-node-std 0.0.1-beta.3 → 0.0.1-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.
- package/README.md +29 -2
- package/dist/console.js +3 -3
- package/dist/console.js.map +1 -1
- package/dist/crypto.js +4 -4
- package/dist/crypto.js.map +1 -1
- package/dist/fetch.d.ts +129 -79
- package/dist/fetch.d.ts.map +1 -1
- package/dist/fetch.js +76 -6
- package/dist/fetch.js.map +1 -1
- package/dist/fs.js +8 -8
- package/dist/fs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/parallel.d.ts +141 -0
- package/dist/parallel.d.ts.map +1 -0
- package/dist/parallel.js +263 -0
- package/dist/parallel.js.map +1 -0
- package/dist/path.js +5 -5
- package/dist/path.js.map +1 -1
- package/dist/platform.d.ts +15 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +15 -0
- package/dist/platform.js.map +1 -0
- package/dist/random.js +12 -12
- package/dist/random.js.map +1 -1
- package/dist/test.d.ts +14 -1
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +33 -524
- package/dist/test.js.map +1 -1
- package/dist/time.js +2 -2
- package/dist/time.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -7
package/README.md
CHANGED
|
@@ -123,13 +123,40 @@ Dual-licensed:
|
|
|
123
123
|
- **Open Source**: [AGPL-3.0](LICENSE.md) - Free for open source use
|
|
124
124
|
- **Commercial**: Available for proprietary use - contact support@elara.ai
|
|
125
125
|
|
|
126
|
+
|
|
127
|
+
### Ecosystem
|
|
128
|
+
|
|
129
|
+
- **[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.
|
|
130
|
+
- [@elaraai/east-node-std](https://www.npmjs.com/package/@elaraai/east-node-std): Filesystem, console, HTTP fetch, crypto, random distributions, timestamps
|
|
131
|
+
- [@elaraai/east-node-io](https://www.npmjs.com/package/@elaraai/east-node-io): SQLite, PostgreSQL, MySQL, MongoDB, S3, FTP, SFTP
|
|
132
|
+
- [@elaraai/east-node-cli](https://www.npmjs.com/package/@elaraai/east-node-cli): CLI for running East IR programs in Node.js
|
|
133
|
+
|
|
134
|
+
- **[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.
|
|
135
|
+
- [@elaraai/east-py-datascience](https://www.npmjs.com/package/@elaraai/east-py-datascience): TypeScript types for optimization, gradient boosting, neural networks, explainability
|
|
136
|
+
|
|
137
|
+
- **[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.
|
|
138
|
+
- [@elaraai/east-ui](https://www.npmjs.com/package/@elaraai/east-ui): 50+ typed UI components for layouts, forms, charts, tables, dialogs
|
|
139
|
+
- [@elaraai/east-ui-components](https://www.npmjs.com/package/@elaraai/east-ui-components): React renderer with Chakra UI styling
|
|
140
|
+
|
|
141
|
+
- **[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.
|
|
142
|
+
- [@elaraai/e3](https://www.npmjs.com/package/@elaraai/e3): SDK for authoring e3 packages with typed tasks and pipelines
|
|
143
|
+
- [@elaraai/e3-core](https://www.npmjs.com/package/@elaraai/e3-core): Git-like object store, task queue, result caching
|
|
144
|
+
- [@elaraai/e3-types](https://www.npmjs.com/package/@elaraai/e3-types): Shared type definitions for e3 packages
|
|
145
|
+
- [@elaraai/e3-cli](https://www.npmjs.com/package/@elaraai/e3-cli): `e3 init`, `e3 run`, `e3 logs` commands for managing and monitoring tasks
|
|
146
|
+
- [@elaraai/e3-api-client](https://www.npmjs.com/package/@elaraai/e3-api-client): HTTP client for remote e3 servers
|
|
147
|
+
- [@elaraai/e3-api-server](https://www.npmjs.com/package/@elaraai/e3-api-server): REST API server for e3 repositories
|
|
148
|
+
|
|
126
149
|
## Links
|
|
127
150
|
|
|
128
151
|
- **Website**: [https://elaraai.com/](https://elaraai.com/)
|
|
129
152
|
- **East Repository**: [https://github.com/elaraai/East](https://github.com/elaraai/East)
|
|
130
|
-
- **Issues**: [https://github.com/elaraai/
|
|
153
|
+
- **Issues**: [https://github.com/elaraai/east-node/issues](https://github.com/elaraai/east-node/issues)
|
|
131
154
|
- **Email**: support@elara.ai
|
|
132
155
|
|
|
156
|
+
## About Elara
|
|
157
|
+
|
|
158
|
+
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.
|
|
159
|
+
|
|
133
160
|
---
|
|
134
161
|
|
|
135
|
-
*Developed by [Elara AI Pty Ltd](https://elaraai.com/)
|
|
162
|
+
*Developed by [Elara AI Pty Ltd](https://elaraai.com/)*
|
package/dist/console.js
CHANGED
|
@@ -84,7 +84,7 @@ const ConsoleImpl = [
|
|
|
84
84
|
}
|
|
85
85
|
catch (err) {
|
|
86
86
|
throw new EastError(`Failed to write to stdout: ${err.message}`, {
|
|
87
|
-
location: { filename: "console_log", line: 0n, column: 0n },
|
|
87
|
+
location: [{ filename: "console_log", line: 0n, column: 0n }],
|
|
88
88
|
cause: err
|
|
89
89
|
});
|
|
90
90
|
}
|
|
@@ -95,7 +95,7 @@ const ConsoleImpl = [
|
|
|
95
95
|
}
|
|
96
96
|
catch (err) {
|
|
97
97
|
throw new EastError(`Failed to write to stderr: ${err.message}`, {
|
|
98
|
-
location: { filename: "console_error", line: 0n, column: 0n },
|
|
98
|
+
location: [{ filename: "console_error", line: 0n, column: 0n }],
|
|
99
99
|
cause: err
|
|
100
100
|
});
|
|
101
101
|
}
|
|
@@ -106,7 +106,7 @@ const ConsoleImpl = [
|
|
|
106
106
|
}
|
|
107
107
|
catch (err) {
|
|
108
108
|
throw new EastError(`Failed to write to stdout: ${err.message}`, {
|
|
109
|
-
location: { filename: "console_write", line: 0n, column: 0n },
|
|
109
|
+
location: [{ filename: "console_write", line: 0n, column: 0n }],
|
|
110
110
|
cause: err
|
|
111
111
|
});
|
|
112
112
|
}
|
package/dist/console.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.js","sourceRoot":"","sources":["../src/console.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAC;AAEpF;;;;GAIG;AACH,MAAM,WAAW,GAAuB;IACpC,WAAW,CAAC,SAAS,CAAC,CAAC,GAAW,EAAE,EAAE;QAClC,IAAI,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;QAAC,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AIG;IACH,cAAc,EAAE,WAAW;CACrB,CAAC;AAEX,qCAAqC;AACrC,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB;;;;;;;;;;;;;;;;;;GAkBG"}
|
package/dist/crypto.js
CHANGED
|
@@ -108,7 +108,7 @@ const CryptoImpl = [
|
|
|
108
108
|
}
|
|
109
109
|
catch (err) {
|
|
110
110
|
throw new EastError(`Failed to generate random bytes: ${err.message}`, {
|
|
111
|
-
location: { filename: "crypto_random_bytes", line: 0n, column: 0n },
|
|
111
|
+
location: [{ filename: "crypto_random_bytes", line: 0n, column: 0n }],
|
|
112
112
|
cause: err
|
|
113
113
|
});
|
|
114
114
|
}
|
|
@@ -119,7 +119,7 @@ const CryptoImpl = [
|
|
|
119
119
|
}
|
|
120
120
|
catch (err) {
|
|
121
121
|
throw new EastError(`Failed to compute SHA-256 hash: ${err.message}`, {
|
|
122
|
-
location: { filename: "crypto_hash_sha256", line: 0n, column: 0n },
|
|
122
|
+
location: [{ filename: "crypto_hash_sha256", line: 0n, column: 0n }],
|
|
123
123
|
cause: err
|
|
124
124
|
});
|
|
125
125
|
}
|
|
@@ -130,7 +130,7 @@ const CryptoImpl = [
|
|
|
130
130
|
}
|
|
131
131
|
catch (err) {
|
|
132
132
|
throw new EastError(`Failed to compute SHA-256 hash: ${err.message}`, {
|
|
133
|
-
location: { filename: "crypto_hash_sha256_bytes", line: 0n, column: 0n },
|
|
133
|
+
location: [{ filename: "crypto_hash_sha256_bytes", line: 0n, column: 0n }],
|
|
134
134
|
cause: err
|
|
135
135
|
});
|
|
136
136
|
}
|
|
@@ -141,7 +141,7 @@ const CryptoImpl = [
|
|
|
141
141
|
}
|
|
142
142
|
catch (err) {
|
|
143
143
|
throw new EastError(`Failed to generate UUID: ${err.message}`, {
|
|
144
|
-
location: { filename: "crypto_uuid", line: 0n, column: 0n },
|
|
144
|
+
location: [{ filename: "crypto_uuid", line: 0n, column: 0n }],
|
|
145
145
|
cause: err
|
|
146
146
|
});
|
|
147
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S,CAAC,GAAG,EAAE;QACvB,IAAI,CAAC;YACD,OAAO,UAAU,EAAE,CAAC;QACxB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,MAAM,IAAI,SAAS,CAAC,4BAA4B,GAAG,CAAC,OAAO,EAAE,EAAE;gBAC3D,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;gBAC7D,KAAK,EAAE,GAAG;aACb,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC;CACL,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,WAAW,EAAE,mBAAmB;IAEhC;;;;;;;;;;;;;;;;;;OAkBG;IACH,UAAU,EAAE,kBAAkB;IAE9B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,EAAE,wBAAwB;IAEzC;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,EAAE,WAAW;IAEjB;;;;OAIG;IACH,cAAc,EAAE,UAAU;CACpB,CAAC;AAEX,qCAAqC;AACrC,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/fetch.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
3
|
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
|
-
import { StringType, IntegerType, BooleanType, DictType, OptionType, VariantType, NullType, StructType } from "@elaraai/east";
|
|
5
|
+
import { StringType, IntegerType, BooleanType, DictType, OptionType, VariantType, NullType, StructType, BlobType } from "@elaraai/east";
|
|
6
6
|
import type { PlatformFunction } from "@elaraai/east/internal";
|
|
7
7
|
/**
|
|
8
8
|
* HTTP method variant type.
|
|
@@ -11,13 +11,13 @@ import type { PlatformFunction } from "@elaraai/east/internal";
|
|
|
11
11
|
* Supports standard HTTP methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS.
|
|
12
12
|
*/
|
|
13
13
|
export declare const FetchMethod: VariantType<{
|
|
14
|
-
GET: NullType;
|
|
15
|
-
POST: NullType;
|
|
16
|
-
PUT: NullType;
|
|
17
|
-
DELETE: NullType;
|
|
18
|
-
PATCH: NullType;
|
|
19
|
-
HEAD: NullType;
|
|
20
|
-
OPTIONS: NullType;
|
|
14
|
+
readonly GET: NullType;
|
|
15
|
+
readonly POST: NullType;
|
|
16
|
+
readonly PUT: NullType;
|
|
17
|
+
readonly DELETE: NullType;
|
|
18
|
+
readonly PATCH: NullType;
|
|
19
|
+
readonly HEAD: NullType;
|
|
20
|
+
readonly OPTIONS: NullType;
|
|
21
21
|
}>;
|
|
22
22
|
/**
|
|
23
23
|
* HTTP request configuration structure.
|
|
@@ -26,18 +26,18 @@ export declare const FetchMethod: VariantType<{
|
|
|
26
26
|
* headers, and optional body content.
|
|
27
27
|
*/
|
|
28
28
|
export declare const FetchRequestConfig: StructType<{
|
|
29
|
-
url: StringType;
|
|
30
|
-
method: VariantType<{
|
|
31
|
-
GET: NullType;
|
|
32
|
-
POST: NullType;
|
|
33
|
-
PUT: NullType;
|
|
34
|
-
DELETE: NullType;
|
|
35
|
-
PATCH: NullType;
|
|
36
|
-
HEAD: NullType;
|
|
37
|
-
OPTIONS: NullType;
|
|
29
|
+
readonly url: StringType;
|
|
30
|
+
readonly method: VariantType<{
|
|
31
|
+
readonly GET: NullType;
|
|
32
|
+
readonly POST: NullType;
|
|
33
|
+
readonly PUT: NullType;
|
|
34
|
+
readonly DELETE: NullType;
|
|
35
|
+
readonly PATCH: NullType;
|
|
36
|
+
readonly HEAD: NullType;
|
|
37
|
+
readonly OPTIONS: NullType;
|
|
38
38
|
}>;
|
|
39
|
-
headers: DictType<StringType, StringType>;
|
|
40
|
-
body: OptionType<StringType>;
|
|
39
|
+
readonly headers: DictType<StringType, StringType>;
|
|
40
|
+
readonly body: OptionType<StringType>;
|
|
41
41
|
}>;
|
|
42
42
|
/**
|
|
43
43
|
* HTTP response structure.
|
|
@@ -46,11 +46,11 @@ export declare const FetchRequestConfig: StructType<{
|
|
|
46
46
|
* The `ok` field is true for status codes in the 200-299 range.
|
|
47
47
|
*/
|
|
48
48
|
export declare const FetchResponse: StructType<{
|
|
49
|
-
status: IntegerType;
|
|
50
|
-
statusText: StringType;
|
|
51
|
-
headers: DictType<StringType, StringType>;
|
|
52
|
-
body: StringType;
|
|
53
|
-
ok: BooleanType;
|
|
49
|
+
readonly status: IntegerType;
|
|
50
|
+
readonly statusText: StringType;
|
|
51
|
+
readonly headers: DictType<StringType, StringType>;
|
|
52
|
+
readonly body: StringType;
|
|
53
|
+
readonly ok: BooleanType;
|
|
54
54
|
}>;
|
|
55
55
|
/**
|
|
56
56
|
* Performs an HTTP GET request and returns the response body as a string.
|
|
@@ -79,6 +79,34 @@ export declare const FetchResponse: StructType<{
|
|
|
79
79
|
* ```
|
|
80
80
|
*/
|
|
81
81
|
export declare const fetch_get: import("@elaraai/east").AsyncPlatformDefinition<[StringType], StringType>;
|
|
82
|
+
/**
|
|
83
|
+
* Performs an HTTP GET request and returns the response body as binary data.
|
|
84
|
+
*
|
|
85
|
+
* Makes a simple GET request to the specified URL and returns the response body
|
|
86
|
+
* as raw bytes (Blob/Uint8Array). Useful for downloading binary files like images,
|
|
87
|
+
* PDFs, or database files.
|
|
88
|
+
* Throws an error if the response status is not in the 200-299 range.
|
|
89
|
+
*
|
|
90
|
+
* This is a platform function for the East language, enabling binary HTTP GET requests
|
|
91
|
+
* in East programs running on Node.js.
|
|
92
|
+
*
|
|
93
|
+
* @param url - The URL to fetch (must be a valid HTTP/HTTPS URL)
|
|
94
|
+
* @returns The response body as binary data (Blob)
|
|
95
|
+
*
|
|
96
|
+
* @throws {EastError} When request fails:
|
|
97
|
+
* - Invalid URL
|
|
98
|
+
* - Network error
|
|
99
|
+
* - Non-2xx HTTP status code
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const downloadFile = East.function([], BlobType, $ => {
|
|
104
|
+
* const data = $.let(Fetch.getBytes("https://example.com/file.bin"));
|
|
105
|
+
* return data;
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare const fetch_get_bytes: import("@elaraai/east").AsyncPlatformDefinition<[StringType], BlobType>;
|
|
82
110
|
/**
|
|
83
111
|
* Performs an HTTP POST request with a string body.
|
|
84
112
|
*
|
|
@@ -138,24 +166,24 @@ export declare const fetch_post: import("@elaraai/east").AsyncPlatformDefinition
|
|
|
138
166
|
* ```
|
|
139
167
|
*/
|
|
140
168
|
export declare const fetch_request: import("@elaraai/east").AsyncPlatformDefinition<[StructType<{
|
|
141
|
-
url: StringType;
|
|
142
|
-
method: VariantType<{
|
|
143
|
-
GET: NullType;
|
|
144
|
-
POST: NullType;
|
|
145
|
-
PUT: NullType;
|
|
146
|
-
DELETE: NullType;
|
|
147
|
-
PATCH: NullType;
|
|
148
|
-
HEAD: NullType;
|
|
149
|
-
OPTIONS: NullType;
|
|
169
|
+
readonly url: StringType;
|
|
170
|
+
readonly method: VariantType<{
|
|
171
|
+
readonly GET: NullType;
|
|
172
|
+
readonly POST: NullType;
|
|
173
|
+
readonly PUT: NullType;
|
|
174
|
+
readonly DELETE: NullType;
|
|
175
|
+
readonly PATCH: NullType;
|
|
176
|
+
readonly HEAD: NullType;
|
|
177
|
+
readonly OPTIONS: NullType;
|
|
150
178
|
}>;
|
|
151
|
-
headers: DictType<StringType, StringType>;
|
|
152
|
-
body: OptionType<StringType>;
|
|
179
|
+
readonly headers: DictType<StringType, StringType>;
|
|
180
|
+
readonly body: OptionType<StringType>;
|
|
153
181
|
}>], StructType<{
|
|
154
|
-
status: IntegerType;
|
|
155
|
-
statusText: StringType;
|
|
156
|
-
headers: DictType<StringType, StringType>;
|
|
157
|
-
body: StringType;
|
|
158
|
-
ok: BooleanType;
|
|
182
|
+
readonly status: IntegerType;
|
|
183
|
+
readonly statusText: StringType;
|
|
184
|
+
readonly headers: DictType<StringType, StringType>;
|
|
185
|
+
readonly body: StringType;
|
|
186
|
+
readonly ok: BooleanType;
|
|
159
187
|
}>>;
|
|
160
188
|
/**
|
|
161
189
|
* Node.js implementation of fetch platform functions.
|
|
@@ -204,6 +232,28 @@ export declare const Fetch: {
|
|
|
204
232
|
* ```
|
|
205
233
|
*/
|
|
206
234
|
readonly get: import("@elaraai/east").AsyncPlatformDefinition<[StringType], StringType>;
|
|
235
|
+
/**
|
|
236
|
+
* Performs an HTTP GET request and returns the response body as binary data.
|
|
237
|
+
*
|
|
238
|
+
* Makes a simple GET request to the specified URL and returns the response body
|
|
239
|
+
* as raw bytes (Blob/Uint8Array). Useful for downloading binary files.
|
|
240
|
+
* Throws an error if the response status is not in the 200-299 range.
|
|
241
|
+
*
|
|
242
|
+
* @param url - The URL to fetch
|
|
243
|
+
* @returns The response body as binary data (Blob)
|
|
244
|
+
* @throws {EastError} When request fails or status is not 2xx
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* const downloadFile = East.function([], BlobType, $ => {
|
|
249
|
+
* return Fetch.getBytes("https://example.com/file.bin");
|
|
250
|
+
* });
|
|
251
|
+
*
|
|
252
|
+
* const compiled = await East.compileAsync(downloadFile.toIR(), Fetch.Implementation);
|
|
253
|
+
* await compiled(); // Returns: binary data as Uint8Array
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
readonly getBytes: import("@elaraai/east").AsyncPlatformDefinition<[StringType], BlobType>;
|
|
207
257
|
/**
|
|
208
258
|
* Performs an HTTP POST request with a string body.
|
|
209
259
|
*
|
|
@@ -255,24 +305,24 @@ export declare const Fetch: {
|
|
|
255
305
|
* ```
|
|
256
306
|
*/
|
|
257
307
|
readonly request: import("@elaraai/east").AsyncPlatformDefinition<[StructType<{
|
|
258
|
-
url: StringType;
|
|
259
|
-
method: VariantType<{
|
|
260
|
-
GET: NullType;
|
|
261
|
-
POST: NullType;
|
|
262
|
-
PUT: NullType;
|
|
263
|
-
DELETE: NullType;
|
|
264
|
-
PATCH: NullType;
|
|
265
|
-
HEAD: NullType;
|
|
266
|
-
OPTIONS: NullType;
|
|
308
|
+
readonly url: StringType;
|
|
309
|
+
readonly method: VariantType<{
|
|
310
|
+
readonly GET: NullType;
|
|
311
|
+
readonly POST: NullType;
|
|
312
|
+
readonly PUT: NullType;
|
|
313
|
+
readonly DELETE: NullType;
|
|
314
|
+
readonly PATCH: NullType;
|
|
315
|
+
readonly HEAD: NullType;
|
|
316
|
+
readonly OPTIONS: NullType;
|
|
267
317
|
}>;
|
|
268
|
-
headers: DictType<StringType, StringType>;
|
|
269
|
-
body: OptionType<StringType>;
|
|
318
|
+
readonly headers: DictType<StringType, StringType>;
|
|
319
|
+
readonly body: OptionType<StringType>;
|
|
270
320
|
}>], StructType<{
|
|
271
|
-
status: IntegerType;
|
|
272
|
-
statusText: StringType;
|
|
273
|
-
headers: DictType<StringType, StringType>;
|
|
274
|
-
body: StringType;
|
|
275
|
-
ok: BooleanType;
|
|
321
|
+
readonly status: IntegerType;
|
|
322
|
+
readonly statusText: StringType;
|
|
323
|
+
readonly headers: DictType<StringType, StringType>;
|
|
324
|
+
readonly body: StringType;
|
|
325
|
+
readonly ok: BooleanType;
|
|
276
326
|
}>>;
|
|
277
327
|
/**
|
|
278
328
|
* Node.js implementation of fetch platform functions.
|
|
@@ -288,40 +338,40 @@ export declare const Fetch: {
|
|
|
288
338
|
* HTTP method variant type (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS).
|
|
289
339
|
*/
|
|
290
340
|
readonly Method: VariantType<{
|
|
291
|
-
GET: NullType;
|
|
292
|
-
POST: NullType;
|
|
293
|
-
PUT: NullType;
|
|
294
|
-
DELETE: NullType;
|
|
295
|
-
PATCH: NullType;
|
|
296
|
-
HEAD: NullType;
|
|
297
|
-
OPTIONS: NullType;
|
|
341
|
+
readonly GET: NullType;
|
|
342
|
+
readonly POST: NullType;
|
|
343
|
+
readonly PUT: NullType;
|
|
344
|
+
readonly DELETE: NullType;
|
|
345
|
+
readonly PATCH: NullType;
|
|
346
|
+
readonly HEAD: NullType;
|
|
347
|
+
readonly OPTIONS: NullType;
|
|
298
348
|
}>;
|
|
299
349
|
/**
|
|
300
350
|
* HTTP request configuration structure.
|
|
301
351
|
*/
|
|
302
352
|
readonly RequestConfig: StructType<{
|
|
303
|
-
url: StringType;
|
|
304
|
-
method: VariantType<{
|
|
305
|
-
GET: NullType;
|
|
306
|
-
POST: NullType;
|
|
307
|
-
PUT: NullType;
|
|
308
|
-
DELETE: NullType;
|
|
309
|
-
PATCH: NullType;
|
|
310
|
-
HEAD: NullType;
|
|
311
|
-
OPTIONS: NullType;
|
|
353
|
+
readonly url: StringType;
|
|
354
|
+
readonly method: VariantType<{
|
|
355
|
+
readonly GET: NullType;
|
|
356
|
+
readonly POST: NullType;
|
|
357
|
+
readonly PUT: NullType;
|
|
358
|
+
readonly DELETE: NullType;
|
|
359
|
+
readonly PATCH: NullType;
|
|
360
|
+
readonly HEAD: NullType;
|
|
361
|
+
readonly OPTIONS: NullType;
|
|
312
362
|
}>;
|
|
313
|
-
headers: DictType<StringType, StringType>;
|
|
314
|
-
body: OptionType<StringType>;
|
|
363
|
+
readonly headers: DictType<StringType, StringType>;
|
|
364
|
+
readonly body: OptionType<StringType>;
|
|
315
365
|
}>;
|
|
316
366
|
/**
|
|
317
367
|
* HTTP response structure.
|
|
318
368
|
*/
|
|
319
369
|
readonly Response: StructType<{
|
|
320
|
-
status: IntegerType;
|
|
321
|
-
statusText: StringType;
|
|
322
|
-
headers: DictType<StringType, StringType>;
|
|
323
|
-
body: StringType;
|
|
324
|
-
ok: BooleanType;
|
|
370
|
+
readonly status: IntegerType;
|
|
371
|
+
readonly statusText: StringType;
|
|
372
|
+
readonly headers: DictType<StringType, StringType>;
|
|
373
|
+
readonly body: StringType;
|
|
374
|
+
readonly ok: BooleanType;
|
|
325
375
|
}>;
|
|
326
376
|
};
|
|
327
377
|
};
|
package/dist/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAQ,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAA+B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAQ,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAA+B,MAAM,eAAe,CAAC;AAC3K,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;;;;GAKG;AACH,eAAO,MAAM,WAAW;;;;;;;;EAQtB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;EAK7B,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;EAMxB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,SAAS,2EAA4D,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,eAAe,yEAAgE,CAAC;AAE7F;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,UAAU,uFAAyE,CAAC;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;GAA2E,CAAC;AAEtG;;;;GAIG;AACH,QAAA,MAAM,SAAS,EAAE,gBAAgB,EAiGhC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,KAAK;IACd;;;;;;;;;;;;;;;;;;;OAmBG;;IAGH;;;;;;;;;;;;;;;;;;;;OAoBG;;IAGH;;;;;;;;;;;;;;;;;;;;;OAqBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;;;;;;;;;;;;;;;;;;;;;IAGH;;;;OAIG;;IAGH;;OAEG;;QAEC;;WAEG;;;;;;;;;;QAGH;;WAEG;;;;;;;;;;;;;;;QAGH;;WAEG;;;;;;;;;CAGD,CAAC;AAGX,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/fetch.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
3
|
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
|
-
import { East, StringType, IntegerType, BooleanType, DictType, OptionType, VariantType, NullType, StructType, SortedMap } from "@elaraai/east";
|
|
5
|
+
import { East, StringType, IntegerType, BooleanType, DictType, OptionType, VariantType, NullType, StructType, BlobType, SortedMap } from "@elaraai/east";
|
|
6
6
|
import { EastError } from "@elaraai/east/internal";
|
|
7
7
|
/**
|
|
8
8
|
* HTTP method variant type.
|
|
@@ -71,6 +71,34 @@ export const FetchResponse = StructType({
|
|
|
71
71
|
* ```
|
|
72
72
|
*/
|
|
73
73
|
export const fetch_get = East.asyncPlatform("fetch_get", [StringType], StringType);
|
|
74
|
+
/**
|
|
75
|
+
* Performs an HTTP GET request and returns the response body as binary data.
|
|
76
|
+
*
|
|
77
|
+
* Makes a simple GET request to the specified URL and returns the response body
|
|
78
|
+
* as raw bytes (Blob/Uint8Array). Useful for downloading binary files like images,
|
|
79
|
+
* PDFs, or database files.
|
|
80
|
+
* Throws an error if the response status is not in the 200-299 range.
|
|
81
|
+
*
|
|
82
|
+
* This is a platform function for the East language, enabling binary HTTP GET requests
|
|
83
|
+
* in East programs running on Node.js.
|
|
84
|
+
*
|
|
85
|
+
* @param url - The URL to fetch (must be a valid HTTP/HTTPS URL)
|
|
86
|
+
* @returns The response body as binary data (Blob)
|
|
87
|
+
*
|
|
88
|
+
* @throws {EastError} When request fails:
|
|
89
|
+
* - Invalid URL
|
|
90
|
+
* - Network error
|
|
91
|
+
* - Non-2xx HTTP status code
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* const downloadFile = East.function([], BlobType, $ => {
|
|
96
|
+
* const data = $.let(Fetch.getBytes("https://example.com/file.bin"));
|
|
97
|
+
* return data;
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export const fetch_get_bytes = East.asyncPlatform("fetch_get_bytes", [StringType], BlobType);
|
|
74
102
|
/**
|
|
75
103
|
* Performs an HTTP POST request with a string body.
|
|
76
104
|
*
|
|
@@ -141,7 +169,7 @@ const FetchImpl = [
|
|
|
141
169
|
const response = await fetch(url);
|
|
142
170
|
if (!response.ok) {
|
|
143
171
|
throw new EastError(`HTTP ${response.status}: ${response.statusText}`, {
|
|
144
|
-
location: { filename: "fetch_get", line: 0n, column: 0n }
|
|
172
|
+
location: [{ filename: "fetch_get", line: 0n, column: 0n }]
|
|
145
173
|
});
|
|
146
174
|
}
|
|
147
175
|
return await response.text();
|
|
@@ -150,7 +178,27 @@ const FetchImpl = [
|
|
|
150
178
|
if (err instanceof EastError)
|
|
151
179
|
throw err;
|
|
152
180
|
throw new EastError(`Failed to fetch ${url}: ${err.message}`, {
|
|
153
|
-
location: { filename: "fetch_get", line: 0n, column: 0n },
|
|
181
|
+
location: [{ filename: "fetch_get", line: 0n, column: 0n }],
|
|
182
|
+
cause: err
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}),
|
|
186
|
+
fetch_get_bytes.implement(async (url) => {
|
|
187
|
+
try {
|
|
188
|
+
const response = await fetch(url);
|
|
189
|
+
if (!response.ok) {
|
|
190
|
+
throw new EastError(`HTTP ${response.status}: ${response.statusText}`, {
|
|
191
|
+
location: [{ filename: "fetch_get_bytes", line: 0n, column: 0n }]
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
195
|
+
return new Uint8Array(arrayBuffer);
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
if (err instanceof EastError)
|
|
199
|
+
throw err;
|
|
200
|
+
throw new EastError(`Failed to fetch ${url}: ${err.message}`, {
|
|
201
|
+
location: [{ filename: "fetch_get_bytes", line: 0n, column: 0n }],
|
|
154
202
|
cause: err
|
|
155
203
|
});
|
|
156
204
|
}
|
|
@@ -166,7 +214,7 @@ const FetchImpl = [
|
|
|
166
214
|
});
|
|
167
215
|
if (!response.ok) {
|
|
168
216
|
throw new EastError(`HTTP ${response.status}: ${response.statusText}`, {
|
|
169
|
-
location: { filename: "fetch_post", line: 0n, column: 0n }
|
|
217
|
+
location: [{ filename: "fetch_post", line: 0n, column: 0n }]
|
|
170
218
|
});
|
|
171
219
|
}
|
|
172
220
|
return await response.text();
|
|
@@ -175,7 +223,7 @@ const FetchImpl = [
|
|
|
175
223
|
if (err instanceof EastError)
|
|
176
224
|
throw err;
|
|
177
225
|
throw new EastError(`Failed to post to ${url}: ${err.message}`, {
|
|
178
|
-
location: { filename: "fetch_post", line: 0n, column: 0n },
|
|
226
|
+
location: [{ filename: "fetch_post", line: 0n, column: 0n }],
|
|
179
227
|
cause: err
|
|
180
228
|
});
|
|
181
229
|
}
|
|
@@ -209,7 +257,7 @@ const FetchImpl = [
|
|
|
209
257
|
}
|
|
210
258
|
catch (err) {
|
|
211
259
|
throw new EastError(`Failed to fetch ${url}: ${err.message}`, {
|
|
212
|
-
location: { filename: "fetch_request", line: 0n, column: 0n },
|
|
260
|
+
location: [{ filename: "fetch_request", line: 0n, column: 0n }],
|
|
213
261
|
cause: err
|
|
214
262
|
});
|
|
215
263
|
}
|
|
@@ -256,6 +304,28 @@ export const Fetch = {
|
|
|
256
304
|
* ```
|
|
257
305
|
*/
|
|
258
306
|
get: fetch_get,
|
|
307
|
+
/**
|
|
308
|
+
* Performs an HTTP GET request and returns the response body as binary data.
|
|
309
|
+
*
|
|
310
|
+
* Makes a simple GET request to the specified URL and returns the response body
|
|
311
|
+
* as raw bytes (Blob/Uint8Array). Useful for downloading binary files.
|
|
312
|
+
* Throws an error if the response status is not in the 200-299 range.
|
|
313
|
+
*
|
|
314
|
+
* @param url - The URL to fetch
|
|
315
|
+
* @returns The response body as binary data (Blob)
|
|
316
|
+
* @throws {EastError} When request fails or status is not 2xx
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```ts
|
|
320
|
+
* const downloadFile = East.function([], BlobType, $ => {
|
|
321
|
+
* return Fetch.getBytes("https://example.com/file.bin");
|
|
322
|
+
* });
|
|
323
|
+
*
|
|
324
|
+
* const compiled = await East.compileAsync(downloadFile.toIR(), Fetch.Implementation);
|
|
325
|
+
* await compiled(); // Returns: binary data as Uint8Array
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
getBytes: fetch_get_bytes,
|
|
259
329
|
/**
|
|
260
330
|
* Performs an HTTP POST request with a string body.
|
|
261
331
|
*
|
package/dist/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAoB,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,UAA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