@elaraai/east-node-io 0.0.1-beta.1 → 0.0.1-beta.3
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/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/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 +7 -7
|
@@ -0,0 +1,373 @@
|
|
|
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 { BlobType, StringType, IntegerType, NullType } from "@elaraai/east";
|
|
14
|
+
import type { PlatformFunction } from "@elaraai/east/internal";
|
|
15
|
+
/**
|
|
16
|
+
* Uploads an object to S3.
|
|
17
|
+
*
|
|
18
|
+
* Uploads binary data to an S3 bucket with the specified key (path).
|
|
19
|
+
* Overwrites existing objects with the same key.
|
|
20
|
+
*
|
|
21
|
+
* This is a platform function for the East language, enabling S3 object storage
|
|
22
|
+
* operations in East programs running on Node.js.
|
|
23
|
+
*
|
|
24
|
+
* @param config - S3 configuration
|
|
25
|
+
* @param key - Object key (path) in the bucket
|
|
26
|
+
* @param data - Binary data to upload
|
|
27
|
+
* @returns Null on success
|
|
28
|
+
*
|
|
29
|
+
* @throws {EastError} When upload fails due to:
|
|
30
|
+
* - Invalid bucket name (location: "s3_put_object")
|
|
31
|
+
* - Authentication failure (location: "s3_put_object")
|
|
32
|
+
* - Network errors (location: "s3_put_object")
|
|
33
|
+
* - Permission denied (location: "s3_put_object")
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { East, StringType, BlobType } from "@elaraai/east";
|
|
38
|
+
* import { Storage } from "@elaraai/east-node-io";
|
|
39
|
+
*
|
|
40
|
+
* const uploadFile = East.function([StringType, BlobType], StringType, ($, filename, data) => {
|
|
41
|
+
* const config = $.let({
|
|
42
|
+
* region: "us-east-1",
|
|
43
|
+
* bucket: "my-bucket",
|
|
44
|
+
* accessKeyId: East.some("AKIAIOSFODNN7EXAMPLE"),
|
|
45
|
+
* secretAccessKey: East.some("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
|
|
46
|
+
* endpoint: East.none(),
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // Upload the file
|
|
50
|
+
* $(Storage.S3.putObject(config, filename, data));
|
|
51
|
+
*
|
|
52
|
+
* // Generate presigned URL for sharing
|
|
53
|
+
* return Storage.S3.presignUrl(config, filename, 3600n);
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* const compiled = East.compileAsync(uploadFile.toIR(), Storage.S3.Implementation);
|
|
57
|
+
* const url = await compiled("report.pdf", pdfBlob);
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* - Supports S3 and S3-compatible services (MinIO, DigitalOcean Spaces, etc.)
|
|
62
|
+
* - Uses AWS SDK v3 for S3 operations
|
|
63
|
+
* - All operations are asynchronous (use East.compileAsync)
|
|
64
|
+
*/
|
|
65
|
+
export declare const s3_put_object: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StructType<{
|
|
66
|
+
region: StringType;
|
|
67
|
+
bucket: StringType;
|
|
68
|
+
accessKeyId: import("@elaraai/east").OptionType<StringType>;
|
|
69
|
+
secretAccessKey: import("@elaraai/east").OptionType<StringType>;
|
|
70
|
+
endpoint: import("@elaraai/east").OptionType<StringType>;
|
|
71
|
+
}>, StringType, BlobType], NullType>;
|
|
72
|
+
/**
|
|
73
|
+
* Downloads an object from S3.
|
|
74
|
+
*
|
|
75
|
+
* Retrieves binary data from an S3 bucket by key (path).
|
|
76
|
+
* Returns the object data as a Blob (Uint8Array).
|
|
77
|
+
*
|
|
78
|
+
* This is a platform function for the East language, enabling S3 object storage
|
|
79
|
+
* operations in East programs running on Node.js.
|
|
80
|
+
*
|
|
81
|
+
* @param config - S3 configuration
|
|
82
|
+
* @param key - Object key (path) in the bucket
|
|
83
|
+
* @returns Binary data as Blob
|
|
84
|
+
*
|
|
85
|
+
* @throws {EastError} When download fails due to:
|
|
86
|
+
* - Object not found (location: "s3_get_object")
|
|
87
|
+
* - Invalid bucket name (location: "s3_get_object")
|
|
88
|
+
* - Authentication failure (location: "s3_get_object")
|
|
89
|
+
* - Network errors (location: "s3_get_object")
|
|
90
|
+
* - Permission denied (location: "s3_get_object")
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* import { East, StringType, BlobType } from "@elaraai/east";
|
|
95
|
+
* import { Storage } from "@elaraai/east-node-io";
|
|
96
|
+
*
|
|
97
|
+
* const downloadFile = East.function([StringType], BlobType, ($, filename) => {
|
|
98
|
+
* const config = $.let({
|
|
99
|
+
* region: "us-east-1",
|
|
100
|
+
* bucket: "my-bucket",
|
|
101
|
+
* accessKeyId: East.none(),
|
|
102
|
+
* secretAccessKey: East.none(),
|
|
103
|
+
* endpoint: East.none(),
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* return Storage.S3.getObject(config, filename);
|
|
107
|
+
* });
|
|
108
|
+
*
|
|
109
|
+
* const compiled = East.compileAsync(downloadFile.toIR(), Storage.S3.Implementation);
|
|
110
|
+
* const pdfData = await compiled("report.pdf"); // Returns Uint8Array
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @remarks
|
|
114
|
+
* - Returns Uint8Array (BlobType) containing raw binary data
|
|
115
|
+
* - Use decodeUtf8() to convert text files to strings
|
|
116
|
+
* - Streams large objects automatically
|
|
117
|
+
*/
|
|
118
|
+
export declare const s3_get_object: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StructType<{
|
|
119
|
+
region: StringType;
|
|
120
|
+
bucket: StringType;
|
|
121
|
+
accessKeyId: import("@elaraai/east").OptionType<StringType>;
|
|
122
|
+
secretAccessKey: import("@elaraai/east").OptionType<StringType>;
|
|
123
|
+
endpoint: import("@elaraai/east").OptionType<StringType>;
|
|
124
|
+
}>, StringType], BlobType>;
|
|
125
|
+
/**
|
|
126
|
+
* Retrieves object metadata from S3 without downloading the file.
|
|
127
|
+
*
|
|
128
|
+
* Gets metadata for an S3 object including size, ETag (hash), last modified time,
|
|
129
|
+
* and content type. This is useful for checking if a file has changed without
|
|
130
|
+
* downloading it by comparing ETags.
|
|
131
|
+
*
|
|
132
|
+
* This is a platform function for the East language, enabling S3 object storage
|
|
133
|
+
* operations in East programs running on Node.js.
|
|
134
|
+
*
|
|
135
|
+
* @param config - S3 configuration
|
|
136
|
+
* @param key - Object key (path) in the bucket
|
|
137
|
+
* @returns Object metadata including ETag, size, and timestamps
|
|
138
|
+
*
|
|
139
|
+
* @throws {EastError} When metadata retrieval fails due to:
|
|
140
|
+
* - Object not found (location: "s3_head_object")
|
|
141
|
+
* - Invalid bucket name (location: "s3_head_object")
|
|
142
|
+
* - Authentication failure (location: "s3_head_object")
|
|
143
|
+
* - Network errors (location: "s3_head_object")
|
|
144
|
+
* - Permission denied (location: "s3_head_object")
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* import { East, StringType } from "@elaraai/east";
|
|
149
|
+
* import { Storage } from "@elaraai/east-node-io";
|
|
150
|
+
*
|
|
151
|
+
* const checkFileChanged = East.function([StringType, StringType], BooleanType, ($, filename, localEtag) => {
|
|
152
|
+
* const config = $.let({
|
|
153
|
+
* region: "us-east-1",
|
|
154
|
+
* bucket: "my-bucket",
|
|
155
|
+
* accessKeyId: East.none(),
|
|
156
|
+
* secretAccessKey: East.none(),
|
|
157
|
+
* endpoint: East.none(),
|
|
158
|
+
* });
|
|
159
|
+
*
|
|
160
|
+
* const metadata = $.let(Storage.S3.headObject(config, filename));
|
|
161
|
+
*
|
|
162
|
+
* return $.match(metadata.etag, {
|
|
163
|
+
* some: ($, remoteEtag) => remoteEtag.notEqual(localEtag),
|
|
164
|
+
* none: ($) => East.value(true), // File changed if no ETag available
|
|
165
|
+
* });
|
|
166
|
+
* });
|
|
167
|
+
*
|
|
168
|
+
* const compiled = East.compileAsync(checkFileChanged.toIR(), Storage.S3.Implementation);
|
|
169
|
+
* const changed = await compiled("report.pdf", '"abc123def456"'); // ETags include quotes
|
|
170
|
+
* if (changed) {
|
|
171
|
+
* // Download the file since it changed
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @remarks
|
|
176
|
+
* - ETag is typically an MD5 hash (for simple uploads) or composite hash (for multipart uploads)
|
|
177
|
+
* - ETags include surrounding quotes (e.g., '"abc123"')
|
|
178
|
+
* - Much faster than downloading the entire file
|
|
179
|
+
* - Use this to implement efficient sync/caching logic
|
|
180
|
+
*/
|
|
181
|
+
export declare const s3_head_object: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StructType<{
|
|
182
|
+
region: StringType;
|
|
183
|
+
bucket: StringType;
|
|
184
|
+
accessKeyId: import("@elaraai/east").OptionType<StringType>;
|
|
185
|
+
secretAccessKey: import("@elaraai/east").OptionType<StringType>;
|
|
186
|
+
endpoint: import("@elaraai/east").OptionType<StringType>;
|
|
187
|
+
}>, StringType], import("@elaraai/east").StructType<{
|
|
188
|
+
key: StringType;
|
|
189
|
+
size: IntegerType;
|
|
190
|
+
lastModified: import("@elaraai/east").DateTimeType;
|
|
191
|
+
contentType: import("@elaraai/east").OptionType<StringType>;
|
|
192
|
+
etag: import("@elaraai/east").OptionType<StringType>;
|
|
193
|
+
}>>;
|
|
194
|
+
/**
|
|
195
|
+
* Deletes an object from S3.
|
|
196
|
+
*
|
|
197
|
+
* Removes an object from an S3 bucket by key (path).
|
|
198
|
+
* Succeeds even if the object doesn't exist (idempotent).
|
|
199
|
+
*
|
|
200
|
+
* This is a platform function for the East language, enabling S3 object storage
|
|
201
|
+
* operations in East programs running on Node.js.
|
|
202
|
+
*
|
|
203
|
+
* @param config - S3 configuration
|
|
204
|
+
* @param key - Object key (path) to delete
|
|
205
|
+
* @returns Null on success
|
|
206
|
+
*
|
|
207
|
+
* @throws {EastError} When deletion fails due to:
|
|
208
|
+
* - Invalid bucket name (location: "s3_delete_object")
|
|
209
|
+
* - Authentication failure (location: "s3_delete_object")
|
|
210
|
+
* - Network errors (location: "s3_delete_object")
|
|
211
|
+
* - Permission denied (location: "s3_delete_object")
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* import { East, StringType, NullType } from "@elaraai/east";
|
|
216
|
+
* import { Storage } from "@elaraai/east-node-io";
|
|
217
|
+
*
|
|
218
|
+
* const deleteFile = East.function([StringType], NullType, ($, filename) => {
|
|
219
|
+
* const config = $.let({
|
|
220
|
+
* region: "us-east-1",
|
|
221
|
+
* bucket: "my-bucket",
|
|
222
|
+
* accessKeyId: East.none(),
|
|
223
|
+
* secretAccessKey: East.none(),
|
|
224
|
+
* endpoint: East.none(),
|
|
225
|
+
* });
|
|
226
|
+
*
|
|
227
|
+
* return Storage.S3.deleteObject(config, filename);
|
|
228
|
+
* });
|
|
229
|
+
*
|
|
230
|
+
* const compiled = East.compileAsync(deleteFile.toIR(), Storage.S3.Implementation);
|
|
231
|
+
* await compiled("old-report.pdf");
|
|
232
|
+
* ```
|
|
233
|
+
*
|
|
234
|
+
* @remarks
|
|
235
|
+
* - Idempotent: succeeds even if object doesn't exist
|
|
236
|
+
* - Does not delete versioned objects (only current version)
|
|
237
|
+
*/
|
|
238
|
+
export declare const s3_delete_object: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StructType<{
|
|
239
|
+
region: StringType;
|
|
240
|
+
bucket: StringType;
|
|
241
|
+
accessKeyId: import("@elaraai/east").OptionType<StringType>;
|
|
242
|
+
secretAccessKey: import("@elaraai/east").OptionType<StringType>;
|
|
243
|
+
endpoint: import("@elaraai/east").OptionType<StringType>;
|
|
244
|
+
}>, StringType], NullType>;
|
|
245
|
+
/**
|
|
246
|
+
* Lists objects in an S3 bucket with a prefix.
|
|
247
|
+
*
|
|
248
|
+
* Retrieves metadata for objects matching a prefix, with pagination support.
|
|
249
|
+
* Returns up to `maxKeys` objects per request.
|
|
250
|
+
*
|
|
251
|
+
* This is a platform function for the East language, enabling S3 object storage
|
|
252
|
+
* operations in East programs running on Node.js.
|
|
253
|
+
*
|
|
254
|
+
* @param config - S3 configuration
|
|
255
|
+
* @param prefix - Prefix to filter objects (empty string for all objects)
|
|
256
|
+
* @param maxKeys - Maximum number of objects to return (1-1000)
|
|
257
|
+
* @returns List result with objects and pagination info
|
|
258
|
+
*
|
|
259
|
+
* @throws {EastError} When listing fails due to:
|
|
260
|
+
* - Invalid bucket name (location: "s3_list_objects")
|
|
261
|
+
* - Authentication failure (location: "s3_list_objects")
|
|
262
|
+
* - Network errors (location: "s3_list_objects")
|
|
263
|
+
* - Permission denied (location: "s3_list_objects")
|
|
264
|
+
* - Invalid maxKeys value (location: "s3_list_objects")
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```ts
|
|
268
|
+
* import { East, StringType, ArrayType } from "@elaraai/east";
|
|
269
|
+
* import { Storage, S3ObjectMetadataType } from "@elaraai/east-node-io";
|
|
270
|
+
*
|
|
271
|
+
* const listReports = East.function([], ArrayType(S3ObjectMetadataType), ($) => {
|
|
272
|
+
* const config = $.let({
|
|
273
|
+
* region: "us-east-1",
|
|
274
|
+
* bucket: "my-bucket",
|
|
275
|
+
* accessKeyId: East.none(),
|
|
276
|
+
* secretAccessKey: East.none(),
|
|
277
|
+
* endpoint: East.none(),
|
|
278
|
+
* });
|
|
279
|
+
*
|
|
280
|
+
* const result = $.let(Storage.S3.listObjects(config, "reports/", 100n));
|
|
281
|
+
* return result.objects;
|
|
282
|
+
* });
|
|
283
|
+
*
|
|
284
|
+
* const compiled = East.compileAsync(listReports.toIR(), Storage.S3.Implementation);
|
|
285
|
+
* const reports = await compiled();
|
|
286
|
+
* ```
|
|
287
|
+
*
|
|
288
|
+
* @remarks
|
|
289
|
+
* - Returns objects sorted by key (lexicographically)
|
|
290
|
+
* - Use continuationToken from result to fetch next page
|
|
291
|
+
* - maxKeys is clamped to 1-1000 range
|
|
292
|
+
*/
|
|
293
|
+
export declare const s3_list_objects: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StructType<{
|
|
294
|
+
region: StringType;
|
|
295
|
+
bucket: StringType;
|
|
296
|
+
accessKeyId: import("@elaraai/east").OptionType<StringType>;
|
|
297
|
+
secretAccessKey: import("@elaraai/east").OptionType<StringType>;
|
|
298
|
+
endpoint: import("@elaraai/east").OptionType<StringType>;
|
|
299
|
+
}>, StringType, IntegerType], import("@elaraai/east").StructType<{
|
|
300
|
+
objects: import("@elaraai/east").ArrayType<import("@elaraai/east").StructType<{
|
|
301
|
+
key: StringType;
|
|
302
|
+
size: IntegerType;
|
|
303
|
+
lastModified: import("@elaraai/east").DateTimeType;
|
|
304
|
+
contentType: import("@elaraai/east").OptionType<StringType>;
|
|
305
|
+
etag: import("@elaraai/east").OptionType<StringType>;
|
|
306
|
+
}>>;
|
|
307
|
+
isTruncated: import("@elaraai/east").BooleanType;
|
|
308
|
+
continuationToken: import("@elaraai/east").OptionType<StringType>;
|
|
309
|
+
}>>;
|
|
310
|
+
/**
|
|
311
|
+
* Generates a presigned URL for temporary access to an S3 object.
|
|
312
|
+
*
|
|
313
|
+
* Creates a signed URL that grants temporary access to an object without
|
|
314
|
+
* requiring AWS credentials. Useful for sharing files or client-side uploads.
|
|
315
|
+
*
|
|
316
|
+
* This is a platform function for the East language, enabling S3 object storage
|
|
317
|
+
* operations in East programs running on Node.js.
|
|
318
|
+
*
|
|
319
|
+
* @param config - S3 configuration
|
|
320
|
+
* @param key - Object key (path) in the bucket
|
|
321
|
+
* @param expiresIn - URL expiration time in seconds (1-604800)
|
|
322
|
+
* @returns Presigned URL as string
|
|
323
|
+
*
|
|
324
|
+
* @throws {EastError} When URL generation fails due to:
|
|
325
|
+
* - Invalid bucket name (location: "s3_presign_url")
|
|
326
|
+
* - Invalid expiration time (location: "s3_presign_url")
|
|
327
|
+
* - Missing credentials (location: "s3_presign_url")
|
|
328
|
+
* - Network errors (location: "s3_presign_url")
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* import { East, StringType } from "@elaraai/east";
|
|
333
|
+
* import { Storage } from "@elaraai/east-node-io";
|
|
334
|
+
*
|
|
335
|
+
* const shareFile = East.function([StringType], StringType, ($, filename) => {
|
|
336
|
+
* const config = $.let({
|
|
337
|
+
* region: "us-east-1",
|
|
338
|
+
* bucket: "my-bucket",
|
|
339
|
+
* accessKeyId: East.some("AKIAIOSFODNN7EXAMPLE"),
|
|
340
|
+
* secretAccessKey: East.some("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
|
|
341
|
+
* endpoint: East.none(),
|
|
342
|
+
* });
|
|
343
|
+
*
|
|
344
|
+
* // Generate URL valid for 1 hour
|
|
345
|
+
* return Storage.S3.presignUrl(config, filename, 3600n);
|
|
346
|
+
* });
|
|
347
|
+
*
|
|
348
|
+
* const compiled = East.compileAsync(shareFile.toIR(), Storage.S3.Implementation);
|
|
349
|
+
* const url = await compiled("report.pdf");
|
|
350
|
+
* console.log(`Share this link: ${url}`);
|
|
351
|
+
* ```
|
|
352
|
+
*
|
|
353
|
+
* @remarks
|
|
354
|
+
* - URL expires after `expiresIn` seconds
|
|
355
|
+
* - Requires credentials (cannot use default AWS credential chain)
|
|
356
|
+
* - Works with S3-compatible services
|
|
357
|
+
* - Maximum expiration: 7 days (604800 seconds)
|
|
358
|
+
*/
|
|
359
|
+
export declare const s3_presign_url: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StructType<{
|
|
360
|
+
region: StringType;
|
|
361
|
+
bucket: StringType;
|
|
362
|
+
accessKeyId: import("@elaraai/east").OptionType<StringType>;
|
|
363
|
+
secretAccessKey: import("@elaraai/east").OptionType<StringType>;
|
|
364
|
+
endpoint: import("@elaraai/east").OptionType<StringType>;
|
|
365
|
+
}>, StringType, IntegerType], StringType>;
|
|
366
|
+
/**
|
|
367
|
+
* Node.js implementation of S3 platform functions.
|
|
368
|
+
*
|
|
369
|
+
* Provides the runtime implementations for S3 operations using AWS SDK v3.
|
|
370
|
+
* Pass this to East.compileAsync() to enable S3 functionality.
|
|
371
|
+
*/
|
|
372
|
+
export declare const S3Impl: PlatformFunction[];
|
|
373
|
+
//# sourceMappingURL=s3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../src/storage/s3.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAQ,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAW,MAAM,eAAe,CAAC;AAE3F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AA8C/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,aAAa;;;;;;oCAAsF,CAAC;AAEjH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,aAAa;;;;;;0BAA4E,CAAC;AACvG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;GAAyF,CAAC;AAErH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,gBAAgB;;;;;;0BAA+E,CAAC;AAE7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;GAAmG,CAAC;AAEhI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,eAAO,MAAM,cAAc;;;;;;yCAA4F,CAAC;AAExH;;;;;GAKG;AACH,eAAO,MAAM,MAAM,EAAE,gBAAgB,EA0LpC,CAAC"}
|