@elaraai/east-node-io 0.0.1-beta.1 → 0.0.1-beta.11
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 +38 -0
- package/dist/compression/gzip.d.ts +108 -0
- package/dist/compression/gzip.d.ts.map +1 -0
- package/dist/compression/gzip.js +153 -0
- package/dist/compression/gzip.js.map +1 -0
- package/dist/compression/index.d.ts +308 -0
- package/dist/compression/index.d.ts.map +1 -0
- package/dist/compression/index.js +289 -0
- package/dist/compression/index.js.map +1 -0
- package/dist/compression/tar.d.ts +115 -0
- package/dist/compression/tar.d.ts.map +1 -0
- package/dist/compression/tar.js +254 -0
- package/dist/compression/tar.js.map +1 -0
- package/dist/compression/types.d.ts +124 -0
- package/dist/compression/types.d.ts.map +1 -0
- package/dist/compression/types.js +106 -0
- package/dist/compression/types.js.map +1 -0
- package/dist/compression/zip.d.ts +121 -0
- package/dist/compression/zip.d.ts.map +1 -0
- package/dist/compression/zip.js +200 -0
- package/dist/compression/zip.js.map +1 -0
- package/dist/connection/index.d.ts +78 -0
- package/dist/connection/index.d.ts.map +1 -0
- package/dist/connection/index.js +134 -0
- package/dist/connection/index.js.map +1 -0
- package/dist/format/index.d.ts +421 -0
- package/dist/format/index.d.ts.map +1 -0
- package/dist/format/index.js +326 -0
- package/dist/format/index.js.map +1 -0
- package/dist/format/types.d.ts +176 -0
- package/dist/format/types.d.ts.map +1 -0
- package/dist/format/types.js +122 -0
- package/dist/format/types.js.map +1 -0
- package/dist/format/xlsx.d.ts +178 -0
- package/dist/format/xlsx.d.ts.map +1 -0
- package/dist/format/xlsx.js +313 -0
- package/dist/format/xlsx.js.map +1 -0
- package/dist/format/xml.d.ts +302 -0
- package/dist/format/xml.d.ts.map +1 -0
- package/dist/format/xml.js +602 -0
- package/dist/format/xml.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/nosql/index.d.ts +503 -0
- package/dist/nosql/index.d.ts.map +1 -0
- package/dist/nosql/index.js +483 -0
- package/dist/nosql/index.js.map +1 -0
- package/dist/nosql/mongodb.d.ts +306 -0
- package/dist/nosql/mongodb.d.ts.map +1 -0
- package/dist/nosql/mongodb.js +552 -0
- package/dist/nosql/mongodb.js.map +1 -0
- package/dist/nosql/redis.d.ts +268 -0
- package/dist/nosql/redis.d.ts.map +1 -0
- package/dist/nosql/redis.js +371 -0
- package/dist/nosql/redis.js.map +1 -0
- package/dist/nosql/types.d.ts +70 -0
- package/dist/nosql/types.d.ts.map +1 -0
- package/dist/nosql/types.js +79 -0
- package/dist/nosql/types.js.map +1 -0
- package/dist/platform.d.ts +12 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +51 -0
- package/dist/platform.js.map +1 -0
- package/dist/sql/index.d.ts +777 -0
- package/dist/sql/index.d.ts.map +1 -0
- package/dist/sql/index.js +515 -0
- package/dist/sql/index.js.map +1 -0
- package/dist/sql/mysql.d.ts +238 -0
- package/dist/sql/mysql.d.ts.map +1 -0
- package/dist/sql/mysql.js +396 -0
- package/dist/sql/mysql.js.map +1 -0
- package/dist/sql/postgres.d.ts +237 -0
- package/dist/sql/postgres.d.ts.map +1 -0
- package/dist/sql/postgres.js +381 -0
- package/dist/sql/postgres.js.map +1 -0
- package/dist/sql/sqlite.d.ts +217 -0
- package/dist/sql/sqlite.d.ts.map +1 -0
- package/dist/sql/sqlite.js +366 -0
- package/dist/sql/sqlite.js.map +1 -0
- package/dist/sql/types.d.ts +205 -0
- package/dist/sql/types.d.ts.map +1 -0
- package/dist/sql/types.js +175 -0
- package/dist/sql/types.js.map +1 -0
- package/dist/storage/index.d.ts +304 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +234 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/s3.d.ts +373 -0
- package/dist/storage/s3.d.ts.map +1 -0
- package/dist/storage/s3.js +502 -0
- package/dist/storage/s3.js.map +1 -0
- package/dist/storage/types.d.ts +117 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +94 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/transfer/ftp.d.ts +333 -0
- package/dist/transfer/ftp.d.ts.map +1 -0
- package/dist/transfer/ftp.js +437 -0
- package/dist/transfer/ftp.js.map +1 -0
- package/dist/transfer/index.d.ts +456 -0
- package/dist/transfer/index.d.ts.map +1 -0
- package/dist/transfer/index.js +414 -0
- package/dist/transfer/index.js.map +1 -0
- package/dist/transfer/sftp.d.ts +333 -0
- package/dist/transfer/sftp.d.ts.map +1 -0
- package/dist/transfer/sftp.js +436 -0
- package/dist/transfer/sftp.js.map +1 -0
- package/dist/transfer/types.d.ts +108 -0
- package/dist/transfer/types.d.ts.map +1 -0
- package/dist/transfer/types.js +110 -0
- package/dist/transfer/types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +17 -9
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* S3 platform functions for East Node IO.
|
|
7
|
+
*
|
|
8
|
+
* Provides S3 and S3-compatible object storage operations for East programs,
|
|
9
|
+
* including upload, download, delete, list, and presigned URL generation.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { East, BlobType, StringType, IntegerType, NullType, variant } from "@elaraai/east";
|
|
14
|
+
import { EastError } from "@elaraai/east/internal";
|
|
15
|
+
import { S3Client, PutObjectCommand, GetObjectCommand, DeleteObjectCommand, ListObjectsV2Command, HeadObjectCommand, } from "@aws-sdk/client-s3";
|
|
16
|
+
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
17
|
+
import { S3ConfigType, S3ListResultType, S3ObjectMetadataType } from "./types.js";
|
|
18
|
+
/**
|
|
19
|
+
* Creates an S3 client from configuration.
|
|
20
|
+
*
|
|
21
|
+
* @param config - S3 configuration
|
|
22
|
+
* @returns Configured S3Client instance
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
function createS3Client(config) {
|
|
26
|
+
const credentials = config.accessKeyId?.type === 'some' && config.secretAccessKey?.type === 'some'
|
|
27
|
+
? {
|
|
28
|
+
accessKeyId: config.accessKeyId.value,
|
|
29
|
+
secretAccessKey: config.secretAccessKey.value,
|
|
30
|
+
}
|
|
31
|
+
: undefined;
|
|
32
|
+
const endpoint = config.endpoint?.type === 'some' ? config.endpoint.value : undefined;
|
|
33
|
+
// Build S3 client config conditionally to satisfy exactOptionalPropertyTypes
|
|
34
|
+
const clientConfig = {
|
|
35
|
+
region: config.region,
|
|
36
|
+
credentials,
|
|
37
|
+
};
|
|
38
|
+
if (endpoint !== undefined) {
|
|
39
|
+
clientConfig.endpoint = endpoint;
|
|
40
|
+
clientConfig.forcePathStyle = true; // Use path-style for S3-compatible services
|
|
41
|
+
}
|
|
42
|
+
return new S3Client(clientConfig);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Uploads an object to S3.
|
|
46
|
+
*
|
|
47
|
+
* Uploads binary data to an S3 bucket with the specified key (path).
|
|
48
|
+
* Overwrites existing objects with the same key.
|
|
49
|
+
*
|
|
50
|
+
* This is a platform function for the East language, enabling S3 object storage
|
|
51
|
+
* operations in East programs running on Node.js.
|
|
52
|
+
*
|
|
53
|
+
* @param config - S3 configuration
|
|
54
|
+
* @param key - Object key (path) in the bucket
|
|
55
|
+
* @param data - Binary data to upload
|
|
56
|
+
* @returns Null on success
|
|
57
|
+
*
|
|
58
|
+
* @throws {EastError} When upload fails due to:
|
|
59
|
+
* - Invalid bucket name (location: "s3_put_object")
|
|
60
|
+
* - Authentication failure (location: "s3_put_object")
|
|
61
|
+
* - Network errors (location: "s3_put_object")
|
|
62
|
+
* - Permission denied (location: "s3_put_object")
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { East, StringType, BlobType } from "@elaraai/east";
|
|
67
|
+
* import { Storage } from "@elaraai/east-node-io";
|
|
68
|
+
*
|
|
69
|
+
* const uploadFile = East.function([StringType, BlobType], StringType, ($, filename, data) => {
|
|
70
|
+
* const config = $.let({
|
|
71
|
+
* region: "us-east-1",
|
|
72
|
+
* bucket: "my-bucket",
|
|
73
|
+
* accessKeyId: East.some("AKIAIOSFODNN7EXAMPLE"),
|
|
74
|
+
* secretAccessKey: East.some("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
|
|
75
|
+
* endpoint: East.none(),
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // Upload the file
|
|
79
|
+
* $(Storage.S3.putObject(config, filename, data));
|
|
80
|
+
*
|
|
81
|
+
* // Generate presigned URL for sharing
|
|
82
|
+
* return Storage.S3.presignUrl(config, filename, 3600n);
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* const compiled = East.compileAsync(uploadFile.toIR(), Storage.S3.Implementation);
|
|
86
|
+
* const url = await compiled("report.pdf", pdfBlob);
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* - Supports S3 and S3-compatible services (MinIO, DigitalOcean Spaces, etc.)
|
|
91
|
+
* - Uses AWS SDK v3 for S3 operations
|
|
92
|
+
* - All operations are asynchronous (use East.compileAsync)
|
|
93
|
+
*/
|
|
94
|
+
export const s3_put_object = East.asyncPlatform("s3_put_object", [S3ConfigType, StringType, BlobType], NullType);
|
|
95
|
+
/**
|
|
96
|
+
* Downloads an object from S3.
|
|
97
|
+
*
|
|
98
|
+
* Retrieves binary data from an S3 bucket by key (path).
|
|
99
|
+
* Returns the object data as a Blob (Uint8Array).
|
|
100
|
+
*
|
|
101
|
+
* This is a platform function for the East language, enabling S3 object storage
|
|
102
|
+
* operations in East programs running on Node.js.
|
|
103
|
+
*
|
|
104
|
+
* @param config - S3 configuration
|
|
105
|
+
* @param key - Object key (path) in the bucket
|
|
106
|
+
* @returns Binary data as Blob
|
|
107
|
+
*
|
|
108
|
+
* @throws {EastError} When download fails due to:
|
|
109
|
+
* - Object not found (location: "s3_get_object")
|
|
110
|
+
* - Invalid bucket name (location: "s3_get_object")
|
|
111
|
+
* - Authentication failure (location: "s3_get_object")
|
|
112
|
+
* - Network errors (location: "s3_get_object")
|
|
113
|
+
* - Permission denied (location: "s3_get_object")
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* import { East, StringType, BlobType } from "@elaraai/east";
|
|
118
|
+
* import { Storage } from "@elaraai/east-node-io";
|
|
119
|
+
*
|
|
120
|
+
* const downloadFile = East.function([StringType], BlobType, ($, filename) => {
|
|
121
|
+
* const config = $.let({
|
|
122
|
+
* region: "us-east-1",
|
|
123
|
+
* bucket: "my-bucket",
|
|
124
|
+
* accessKeyId: East.none(),
|
|
125
|
+
* secretAccessKey: East.none(),
|
|
126
|
+
* endpoint: East.none(),
|
|
127
|
+
* });
|
|
128
|
+
*
|
|
129
|
+
* return Storage.S3.getObject(config, filename);
|
|
130
|
+
* });
|
|
131
|
+
*
|
|
132
|
+
* const compiled = East.compileAsync(downloadFile.toIR(), Storage.S3.Implementation);
|
|
133
|
+
* const pdfData = await compiled("report.pdf"); // Returns Uint8Array
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @remarks
|
|
137
|
+
* - Returns Uint8Array (BlobType) containing raw binary data
|
|
138
|
+
* - Use decodeUtf8() to convert text files to strings
|
|
139
|
+
* - Streams large objects automatically
|
|
140
|
+
*/
|
|
141
|
+
export const s3_get_object = East.asyncPlatform("s3_get_object", [S3ConfigType, StringType], BlobType);
|
|
142
|
+
/**
|
|
143
|
+
* Retrieves object metadata from S3 without downloading the file.
|
|
144
|
+
*
|
|
145
|
+
* Gets metadata for an S3 object including size, ETag (hash), last modified time,
|
|
146
|
+
* and content type. This is useful for checking if a file has changed without
|
|
147
|
+
* downloading it by comparing ETags.
|
|
148
|
+
*
|
|
149
|
+
* This is a platform function for the East language, enabling S3 object storage
|
|
150
|
+
* operations in East programs running on Node.js.
|
|
151
|
+
*
|
|
152
|
+
* @param config - S3 configuration
|
|
153
|
+
* @param key - Object key (path) in the bucket
|
|
154
|
+
* @returns Object metadata including ETag, size, and timestamps
|
|
155
|
+
*
|
|
156
|
+
* @throws {EastError} When metadata retrieval fails due to:
|
|
157
|
+
* - Object not found (location: "s3_head_object")
|
|
158
|
+
* - Invalid bucket name (location: "s3_head_object")
|
|
159
|
+
* - Authentication failure (location: "s3_head_object")
|
|
160
|
+
* - Network errors (location: "s3_head_object")
|
|
161
|
+
* - Permission denied (location: "s3_head_object")
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* import { East, StringType } from "@elaraai/east";
|
|
166
|
+
* import { Storage } from "@elaraai/east-node-io";
|
|
167
|
+
*
|
|
168
|
+
* const checkFileChanged = East.function([StringType, StringType], BooleanType, ($, filename, localEtag) => {
|
|
169
|
+
* const config = $.let({
|
|
170
|
+
* region: "us-east-1",
|
|
171
|
+
* bucket: "my-bucket",
|
|
172
|
+
* accessKeyId: East.none(),
|
|
173
|
+
* secretAccessKey: East.none(),
|
|
174
|
+
* endpoint: East.none(),
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* const metadata = $.let(Storage.S3.headObject(config, filename));
|
|
178
|
+
*
|
|
179
|
+
* return $.match(metadata.etag, {
|
|
180
|
+
* some: ($, remoteEtag) => remoteEtag.notEqual(localEtag),
|
|
181
|
+
* none: ($) => East.value(true), // File changed if no ETag available
|
|
182
|
+
* });
|
|
183
|
+
* });
|
|
184
|
+
*
|
|
185
|
+
* const compiled = East.compileAsync(checkFileChanged.toIR(), Storage.S3.Implementation);
|
|
186
|
+
* const changed = await compiled("report.pdf", '"abc123def456"'); // ETags include quotes
|
|
187
|
+
* if (changed) {
|
|
188
|
+
* // Download the file since it changed
|
|
189
|
+
* }
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* @remarks
|
|
193
|
+
* - ETag is typically an MD5 hash (for simple uploads) or composite hash (for multipart uploads)
|
|
194
|
+
* - ETags include surrounding quotes (e.g., '"abc123"')
|
|
195
|
+
* - Much faster than downloading the entire file
|
|
196
|
+
* - Use this to implement efficient sync/caching logic
|
|
197
|
+
*/
|
|
198
|
+
export const s3_head_object = East.asyncPlatform("s3_head_object", [S3ConfigType, StringType], S3ObjectMetadataType);
|
|
199
|
+
/**
|
|
200
|
+
* Deletes an object from S3.
|
|
201
|
+
*
|
|
202
|
+
* Removes an object from an S3 bucket by key (path).
|
|
203
|
+
* Succeeds even if the object doesn't exist (idempotent).
|
|
204
|
+
*
|
|
205
|
+
* This is a platform function for the East language, enabling S3 object storage
|
|
206
|
+
* operations in East programs running on Node.js.
|
|
207
|
+
*
|
|
208
|
+
* @param config - S3 configuration
|
|
209
|
+
* @param key - Object key (path) to delete
|
|
210
|
+
* @returns Null on success
|
|
211
|
+
*
|
|
212
|
+
* @throws {EastError} When deletion fails due to:
|
|
213
|
+
* - Invalid bucket name (location: "s3_delete_object")
|
|
214
|
+
* - Authentication failure (location: "s3_delete_object")
|
|
215
|
+
* - Network errors (location: "s3_delete_object")
|
|
216
|
+
* - Permission denied (location: "s3_delete_object")
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* import { East, StringType, NullType } from "@elaraai/east";
|
|
221
|
+
* import { Storage } from "@elaraai/east-node-io";
|
|
222
|
+
*
|
|
223
|
+
* const deleteFile = East.function([StringType], NullType, ($, filename) => {
|
|
224
|
+
* const config = $.let({
|
|
225
|
+
* region: "us-east-1",
|
|
226
|
+
* bucket: "my-bucket",
|
|
227
|
+
* accessKeyId: East.none(),
|
|
228
|
+
* secretAccessKey: East.none(),
|
|
229
|
+
* endpoint: East.none(),
|
|
230
|
+
* });
|
|
231
|
+
*
|
|
232
|
+
* return Storage.S3.deleteObject(config, filename);
|
|
233
|
+
* });
|
|
234
|
+
*
|
|
235
|
+
* const compiled = East.compileAsync(deleteFile.toIR(), Storage.S3.Implementation);
|
|
236
|
+
* await compiled("old-report.pdf");
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* @remarks
|
|
240
|
+
* - Idempotent: succeeds even if object doesn't exist
|
|
241
|
+
* - Does not delete versioned objects (only current version)
|
|
242
|
+
*/
|
|
243
|
+
export const s3_delete_object = East.asyncPlatform("s3_delete_object", [S3ConfigType, StringType], NullType);
|
|
244
|
+
/**
|
|
245
|
+
* Lists objects in an S3 bucket with a prefix.
|
|
246
|
+
*
|
|
247
|
+
* Retrieves metadata for objects matching a prefix, with pagination support.
|
|
248
|
+
* Returns up to `maxKeys` objects per request.
|
|
249
|
+
*
|
|
250
|
+
* This is a platform function for the East language, enabling S3 object storage
|
|
251
|
+
* operations in East programs running on Node.js.
|
|
252
|
+
*
|
|
253
|
+
* @param config - S3 configuration
|
|
254
|
+
* @param prefix - Prefix to filter objects (empty string for all objects)
|
|
255
|
+
* @param maxKeys - Maximum number of objects to return (1-1000)
|
|
256
|
+
* @returns List result with objects and pagination info
|
|
257
|
+
*
|
|
258
|
+
* @throws {EastError} When listing fails due to:
|
|
259
|
+
* - Invalid bucket name (location: "s3_list_objects")
|
|
260
|
+
* - Authentication failure (location: "s3_list_objects")
|
|
261
|
+
* - Network errors (location: "s3_list_objects")
|
|
262
|
+
* - Permission denied (location: "s3_list_objects")
|
|
263
|
+
* - Invalid maxKeys value (location: "s3_list_objects")
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```ts
|
|
267
|
+
* import { East, StringType, ArrayType } from "@elaraai/east";
|
|
268
|
+
* import { Storage, S3ObjectMetadataType } from "@elaraai/east-node-io";
|
|
269
|
+
*
|
|
270
|
+
* const listReports = East.function([], ArrayType(S3ObjectMetadataType), ($) => {
|
|
271
|
+
* const config = $.let({
|
|
272
|
+
* region: "us-east-1",
|
|
273
|
+
* bucket: "my-bucket",
|
|
274
|
+
* accessKeyId: East.none(),
|
|
275
|
+
* secretAccessKey: East.none(),
|
|
276
|
+
* endpoint: East.none(),
|
|
277
|
+
* });
|
|
278
|
+
*
|
|
279
|
+
* const result = $.let(Storage.S3.listObjects(config, "reports/", 100n));
|
|
280
|
+
* return result.objects;
|
|
281
|
+
* });
|
|
282
|
+
*
|
|
283
|
+
* const compiled = East.compileAsync(listReports.toIR(), Storage.S3.Implementation);
|
|
284
|
+
* const reports = await compiled();
|
|
285
|
+
* ```
|
|
286
|
+
*
|
|
287
|
+
* @remarks
|
|
288
|
+
* - Returns objects sorted by key (lexicographically)
|
|
289
|
+
* - Use continuationToken from result to fetch next page
|
|
290
|
+
* - maxKeys is clamped to 1-1000 range
|
|
291
|
+
*/
|
|
292
|
+
export const s3_list_objects = East.asyncPlatform("s3_list_objects", [S3ConfigType, StringType, IntegerType], S3ListResultType);
|
|
293
|
+
/**
|
|
294
|
+
* Generates a presigned URL for temporary access to an S3 object.
|
|
295
|
+
*
|
|
296
|
+
* Creates a signed URL that grants temporary access to an object without
|
|
297
|
+
* requiring AWS credentials. Useful for sharing files or client-side uploads.
|
|
298
|
+
*
|
|
299
|
+
* This is a platform function for the East language, enabling S3 object storage
|
|
300
|
+
* operations in East programs running on Node.js.
|
|
301
|
+
*
|
|
302
|
+
* @param config - S3 configuration
|
|
303
|
+
* @param key - Object key (path) in the bucket
|
|
304
|
+
* @param expiresIn - URL expiration time in seconds (1-604800)
|
|
305
|
+
* @returns Presigned URL as string
|
|
306
|
+
*
|
|
307
|
+
* @throws {EastError} When URL generation fails due to:
|
|
308
|
+
* - Invalid bucket name (location: "s3_presign_url")
|
|
309
|
+
* - Invalid expiration time (location: "s3_presign_url")
|
|
310
|
+
* - Missing credentials (location: "s3_presign_url")
|
|
311
|
+
* - Network errors (location: "s3_presign_url")
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```ts
|
|
315
|
+
* import { East, StringType } from "@elaraai/east";
|
|
316
|
+
* import { Storage } from "@elaraai/east-node-io";
|
|
317
|
+
*
|
|
318
|
+
* const shareFile = East.function([StringType], StringType, ($, filename) => {
|
|
319
|
+
* const config = $.let({
|
|
320
|
+
* region: "us-east-1",
|
|
321
|
+
* bucket: "my-bucket",
|
|
322
|
+
* accessKeyId: East.some("AKIAIOSFODNN7EXAMPLE"),
|
|
323
|
+
* secretAccessKey: East.some("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
|
|
324
|
+
* endpoint: East.none(),
|
|
325
|
+
* });
|
|
326
|
+
*
|
|
327
|
+
* // Generate URL valid for 1 hour
|
|
328
|
+
* return Storage.S3.presignUrl(config, filename, 3600n);
|
|
329
|
+
* });
|
|
330
|
+
*
|
|
331
|
+
* const compiled = East.compileAsync(shareFile.toIR(), Storage.S3.Implementation);
|
|
332
|
+
* const url = await compiled("report.pdf");
|
|
333
|
+
* console.log(`Share this link: ${url}`);
|
|
334
|
+
* ```
|
|
335
|
+
*
|
|
336
|
+
* @remarks
|
|
337
|
+
* - URL expires after `expiresIn` seconds
|
|
338
|
+
* - Requires credentials (cannot use default AWS credential chain)
|
|
339
|
+
* - Works with S3-compatible services
|
|
340
|
+
* - Maximum expiration: 7 days (604800 seconds)
|
|
341
|
+
*/
|
|
342
|
+
export const s3_presign_url = East.asyncPlatform("s3_presign_url", [S3ConfigType, StringType, IntegerType], StringType);
|
|
343
|
+
/**
|
|
344
|
+
* Node.js implementation of S3 platform functions.
|
|
345
|
+
*
|
|
346
|
+
* Provides the runtime implementations for S3 operations using AWS SDK v3.
|
|
347
|
+
* Pass this to East.compileAsync() to enable S3 functionality.
|
|
348
|
+
*/
|
|
349
|
+
export const S3Impl = [
|
|
350
|
+
s3_put_object.implement(async (config, key, data) => {
|
|
351
|
+
try {
|
|
352
|
+
const client = createS3Client(config);
|
|
353
|
+
const command = new PutObjectCommand({
|
|
354
|
+
Bucket: config.bucket,
|
|
355
|
+
Key: key,
|
|
356
|
+
Body: data,
|
|
357
|
+
});
|
|
358
|
+
await client.send(command);
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
catch (err) {
|
|
362
|
+
throw new EastError(`S3 putObject failed: ${err.message}`, {
|
|
363
|
+
location: { filename: "s3_put_object", line: 0n, column: 0n },
|
|
364
|
+
cause: err
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}),
|
|
368
|
+
s3_get_object.implement(async (config, key) => {
|
|
369
|
+
try {
|
|
370
|
+
const client = createS3Client(config);
|
|
371
|
+
const command = new GetObjectCommand({
|
|
372
|
+
Bucket: config.bucket,
|
|
373
|
+
Key: key,
|
|
374
|
+
});
|
|
375
|
+
const response = await client.send(command);
|
|
376
|
+
if (!response.Body) {
|
|
377
|
+
throw new Error('Response body is empty');
|
|
378
|
+
}
|
|
379
|
+
// Convert stream to Uint8Array
|
|
380
|
+
const chunks = [];
|
|
381
|
+
for await (const chunk of response.Body) {
|
|
382
|
+
chunks.push(chunk);
|
|
383
|
+
}
|
|
384
|
+
// Concatenate all chunks
|
|
385
|
+
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
386
|
+
const result = new Uint8Array(totalLength);
|
|
387
|
+
let offset = 0;
|
|
388
|
+
for (const chunk of chunks) {
|
|
389
|
+
result.set(chunk, offset);
|
|
390
|
+
offset += chunk.length;
|
|
391
|
+
}
|
|
392
|
+
return result;
|
|
393
|
+
}
|
|
394
|
+
catch (err) {
|
|
395
|
+
throw new EastError(`S3 getObject failed: ${err.message}`, {
|
|
396
|
+
location: { filename: "s3_get_object", line: 0n, column: 0n },
|
|
397
|
+
cause: err
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
}),
|
|
401
|
+
s3_head_object.implement(async (config, key) => {
|
|
402
|
+
try {
|
|
403
|
+
const client = createS3Client(config);
|
|
404
|
+
const command = new HeadObjectCommand({
|
|
405
|
+
Bucket: config.bucket,
|
|
406
|
+
Key: key,
|
|
407
|
+
});
|
|
408
|
+
const response = await client.send(command);
|
|
409
|
+
return {
|
|
410
|
+
key,
|
|
411
|
+
size: BigInt(response.ContentLength || 0),
|
|
412
|
+
lastModified: response.LastModified || new Date(),
|
|
413
|
+
contentType: response.ContentType ? variant('some', response.ContentType) : variant('none', null),
|
|
414
|
+
etag: response.ETag ? variant('some', response.ETag) : variant('none', null),
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
catch (err) {
|
|
418
|
+
throw new EastError(`S3 headObject failed: ${err.message}`, {
|
|
419
|
+
location: { filename: "s3_head_object", line: 0n, column: 0n },
|
|
420
|
+
cause: err
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}),
|
|
424
|
+
s3_delete_object.implement(async (config, key) => {
|
|
425
|
+
try {
|
|
426
|
+
const client = createS3Client(config);
|
|
427
|
+
const command = new DeleteObjectCommand({
|
|
428
|
+
Bucket: config.bucket,
|
|
429
|
+
Key: key,
|
|
430
|
+
});
|
|
431
|
+
await client.send(command);
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
catch (err) {
|
|
435
|
+
throw new EastError(`S3 deleteObject failed: ${err.message}`, {
|
|
436
|
+
location: { filename: "s3_delete_object", line: 0n, column: 0n },
|
|
437
|
+
cause: err
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
}),
|
|
441
|
+
s3_list_objects.implement(async (config, prefix, maxKeys) => {
|
|
442
|
+
try {
|
|
443
|
+
const client = createS3Client(config);
|
|
444
|
+
// Clamp maxKeys to valid range (1-1000)
|
|
445
|
+
const maxKeysNum = Number(maxKeys);
|
|
446
|
+
const clampedMaxKeys = Math.max(1, Math.min(1000, maxKeysNum));
|
|
447
|
+
const command = new ListObjectsV2Command({
|
|
448
|
+
Bucket: config.bucket,
|
|
449
|
+
Prefix: prefix,
|
|
450
|
+
MaxKeys: clampedMaxKeys,
|
|
451
|
+
});
|
|
452
|
+
const response = await client.send(command);
|
|
453
|
+
// Convert S3 objects to East metadata format
|
|
454
|
+
// Note: ContentType is not part of _Object in ListObjectsV2, only in HeadObject/GetObject
|
|
455
|
+
const objects = (response.Contents || []).map((obj) => ({
|
|
456
|
+
key: obj.Key || '',
|
|
457
|
+
size: BigInt(obj.Size || 0),
|
|
458
|
+
lastModified: obj.LastModified || new Date(),
|
|
459
|
+
contentType: variant('none', null), // ListObjectsV2 doesn't include ContentType
|
|
460
|
+
etag: obj.ETag
|
|
461
|
+
? variant('some', obj.ETag)
|
|
462
|
+
: variant('none', null),
|
|
463
|
+
}));
|
|
464
|
+
return {
|
|
465
|
+
objects,
|
|
466
|
+
isTruncated: response.IsTruncated || false,
|
|
467
|
+
continuationToken: response.NextContinuationToken
|
|
468
|
+
? variant('some', response.NextContinuationToken)
|
|
469
|
+
: variant('none', null),
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
catch (err) {
|
|
473
|
+
throw new EastError(`S3 listObjects failed: ${err.message}`, {
|
|
474
|
+
location: { filename: "s3_list_objects", line: 0n, column: 0n },
|
|
475
|
+
cause: err
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
}),
|
|
479
|
+
s3_presign_url.implement(async (config, key, expiresIn) => {
|
|
480
|
+
try {
|
|
481
|
+
const client = createS3Client(config);
|
|
482
|
+
// Clamp expiresIn to valid range (1 second to 7 days)
|
|
483
|
+
const expiresInNum = Number(expiresIn);
|
|
484
|
+
const clampedExpiresIn = Math.max(1, Math.min(604800, expiresInNum));
|
|
485
|
+
const command = new GetObjectCommand({
|
|
486
|
+
Bucket: config.bucket,
|
|
487
|
+
Key: key,
|
|
488
|
+
});
|
|
489
|
+
const url = await getSignedUrl(client, command, {
|
|
490
|
+
expiresIn: clampedExpiresIn,
|
|
491
|
+
});
|
|
492
|
+
return url;
|
|
493
|
+
}
|
|
494
|
+
catch (err) {
|
|
495
|
+
throw new EastError(`S3 presignUrl failed: ${err.message}`, {
|
|
496
|
+
location: { filename: "s3_presign_url", line: 0n, column: 0n },
|
|
497
|
+
cause: err
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
}),
|
|
501
|
+
];
|
|
502
|
+
//# sourceMappingURL=s3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.js","sourceRoot":"","sources":["../../src/storage/s3.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG3F,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EACH,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,GAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElF;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,MAAwC;IAC5D,MAAM,WAAW,GACb,MAAM,CAAC,WAAW,EAAE,IAAI,KAAK,MAAM,IAAI,MAAM,CAAC,eAAe,EAAE,IAAI,KAAK,MAAM;QAC1E,CAAC,CAAC;YACE,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,KAAK;YACrC,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC,KAAK;SAChD;QACD,CAAC,CAAC,SAAS,CAAC;IAEpB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAEtF,6EAA6E;IAC7E,MAAM,YAAY,GAAQ;QACtB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,WAAW;K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AAgB,CAAC;gBACjC,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,GAAG,EAAE,GAAG;aACX,CAAC,CAAC;YAEH,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE;gBAC5C,SAAS,EAAE,gBAAgB;aAC9B,CAAC,CAAC;YAEH,OAAO,GAAG,CAAC;QACf,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,MAAM,IAAI,SAAS,CAAC,yBAAyB,GAAG,CAAC,OAAO,EAAE,EAAE;gBACxD,QAAQ,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;gBAC9D,KAAK,EAAE,GAAG;aACb,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC;CACL,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Shared storage type definitions for East Node IO.
|
|
7
|
+
*
|
|
8
|
+
* Provides East type definitions for S3 and S3-compatible object storage
|
|
9
|
+
* operations including configurations, metadata, and result types.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { StructType, OptionType, ArrayType, StringType, IntegerType, BooleanType, DateTimeType } from "@elaraai/east";
|
|
14
|
+
/**
|
|
15
|
+
* S3 storage configuration.
|
|
16
|
+
*
|
|
17
|
+
* Configures connection to S3 or S3-compatible object storage services
|
|
18
|
+
* (MinIO, DigitalOcean Spaces, etc.).
|
|
19
|
+
*/
|
|
20
|
+
export declare const S3ConfigType: StructType<{
|
|
21
|
+
/**
|
|
22
|
+
* AWS region (e.g., "us-east-1", "eu-west-1").
|
|
23
|
+
*/
|
|
24
|
+
region: StringType;
|
|
25
|
+
/**
|
|
26
|
+
* S3 bucket name.
|
|
27
|
+
*/
|
|
28
|
+
bucket: StringType;
|
|
29
|
+
/**
|
|
30
|
+
* AWS access key ID for authentication.
|
|
31
|
+
* Optional, defaults to AWS credential chain.
|
|
32
|
+
*/
|
|
33
|
+
accessKeyId: OptionType<StringType>;
|
|
34
|
+
/**
|
|
35
|
+
* AWS secret access key for authentication.
|
|
36
|
+
* Optional, defaults to AWS credential chain.
|
|
37
|
+
*/
|
|
38
|
+
secretAccessKey: OptionType<StringType>;
|
|
39
|
+
/**
|
|
40
|
+
* Custom endpoint for S3-compatible services (e.g., "http://localhost:9000" for MinIO).
|
|
41
|
+
* Optional, defaults to AWS S3 endpoint.
|
|
42
|
+
*/
|
|
43
|
+
endpoint: OptionType<StringType>;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* S3 object metadata.
|
|
47
|
+
*
|
|
48
|
+
* Represents metadata about an object stored in S3.
|
|
49
|
+
*/
|
|
50
|
+
export declare const S3ObjectMetadataType: StructType<{
|
|
51
|
+
/**
|
|
52
|
+
* Object key (path) in the bucket.
|
|
53
|
+
*/
|
|
54
|
+
key: StringType;
|
|
55
|
+
/**
|
|
56
|
+
* Object size in bytes.
|
|
57
|
+
*/
|
|
58
|
+
size: IntegerType;
|
|
59
|
+
/**
|
|
60
|
+
* Last modified timestamp as a Date object.
|
|
61
|
+
*/
|
|
62
|
+
lastModified: DateTimeType;
|
|
63
|
+
/**
|
|
64
|
+
* Content type of the object (MIME type).
|
|
65
|
+
* Optional, may be None if not set.
|
|
66
|
+
*/
|
|
67
|
+
contentType: OptionType<StringType>;
|
|
68
|
+
/**
|
|
69
|
+
* ETag of the object (entity tag for versioning/caching).
|
|
70
|
+
* Optional, may be None if not available.
|
|
71
|
+
*/
|
|
72
|
+
etag: OptionType<StringType>;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* S3 list objects result.
|
|
76
|
+
*
|
|
77
|
+
* Contains the result of listing objects in an S3 bucket with pagination support.
|
|
78
|
+
*/
|
|
79
|
+
export declare const S3ListResultType: StructType<{
|
|
80
|
+
/**
|
|
81
|
+
* Array of object metadata for objects matching the prefix.
|
|
82
|
+
*/
|
|
83
|
+
objects: ArrayType<StructType<{
|
|
84
|
+
/**
|
|
85
|
+
* Object key (path) in the bucket.
|
|
86
|
+
*/
|
|
87
|
+
key: StringType;
|
|
88
|
+
/**
|
|
89
|
+
* Object size in bytes.
|
|
90
|
+
*/
|
|
91
|
+
size: IntegerType;
|
|
92
|
+
/**
|
|
93
|
+
* Last modified timestamp as a Date object.
|
|
94
|
+
*/
|
|
95
|
+
lastModified: DateTimeType;
|
|
96
|
+
/**
|
|
97
|
+
* Content type of the object (MIME type).
|
|
98
|
+
* Optional, may be None if not set.
|
|
99
|
+
*/
|
|
100
|
+
contentType: OptionType<StringType>;
|
|
101
|
+
/**
|
|
102
|
+
* ETag of the object (entity tag for versioning/caching).
|
|
103
|
+
* Optional, may be None if not available.
|
|
104
|
+
*/
|
|
105
|
+
etag: OptionType<StringType>;
|
|
106
|
+
}>>;
|
|
107
|
+
/**
|
|
108
|
+
* Whether the result list is truncated (more results available).
|
|
109
|
+
*/
|
|
110
|
+
isTruncated: BooleanType;
|
|
111
|
+
/**
|
|
112
|
+
* Continuation token for fetching next page of results.
|
|
113
|
+
* Optional, None if no more results available.
|
|
114
|
+
*/
|
|
115
|
+
continuationToken: OptionType<StringType>;
|
|
116
|
+
}>;
|
|
117
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/storage/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EACH,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACf,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,eAAO,MAAM,YAAY;IACrB;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;EAEL,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;IAC7B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAGH;;;OAGG;;EAEL,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;IACzB;;OAEG;;QApCH;;WAEG;;QAGH;;WAEG;;QAGH;;WAEG;;QAGH;;;WAGG;;QAGH;;;WAGG;;;IAeH;;OAEG;;IAGH;;;OAGG;;EAEL,CAAC"}
|