@elaraai/east-node-io 0.0.1-beta.0 → 0.0.1-beta.2
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/csv.d.ts +210 -0
- package/dist/format/csv.d.ts.map +1 -0
- package/dist/format/csv.js +729 -0
- package/dist/format/csv.js.map +1 -0
- package/dist/format/index.d.ts +641 -0
- package/dist/format/index.d.ts.map +1 -0
- package/dist/format/index.js +463 -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 +8 -8
|
@@ -0,0 +1,436 @@
|
|
|
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
|
+
* SFTP platform functions for East Node IO.
|
|
7
|
+
*
|
|
8
|
+
* Provides SFTP (SSH File Transfer Protocol) operations for East programs,
|
|
9
|
+
* including upload, download, list, and delete operations.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { East, BlobType, ArrayType, NullType } from "@elaraai/east";
|
|
14
|
+
import { EastError } from "@elaraai/east/internal";
|
|
15
|
+
import SftpClient from "ssh2-sftp-client";
|
|
16
|
+
import { createHandle, getConnection, closeHandle, closeAllHandles } from '../connection/index.js';
|
|
17
|
+
import { SftpConfigType, ConnectionHandleType, StringType, FileInfoType } from "./types.js";
|
|
18
|
+
/**
|
|
19
|
+
* Connects to an SFTP server.
|
|
20
|
+
*
|
|
21
|
+
* Creates a connection to an SFTP server and returns an opaque handle
|
|
22
|
+
* for use in file transfer operations.
|
|
23
|
+
*
|
|
24
|
+
* This is a platform function for the East language, enabling SFTP file transfer
|
|
25
|
+
* operations in East programs running on Node.js.
|
|
26
|
+
*
|
|
27
|
+
* @param config - SFTP connection configuration
|
|
28
|
+
* @returns Connection handle (opaque string)
|
|
29
|
+
*
|
|
30
|
+
* @throws {EastError} When connection fails due to:
|
|
31
|
+
* - Invalid hostname or port (location: "sftp_connect")
|
|
32
|
+
* - Authentication failure (location: "sftp_connect")
|
|
33
|
+
* - Network errors (location: "sftp_connect")
|
|
34
|
+
* - SSH key errors (location: "sftp_connect")
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { East, StringType, BlobType } from "@elaraai/east";
|
|
39
|
+
* import { Transfer } from "@elaraai/east-node-io";
|
|
40
|
+
*
|
|
41
|
+
* const uploadToSftp = East.function([StringType, BlobType], NullType, ($, filename, data) => {
|
|
42
|
+
* const config = $.let({
|
|
43
|
+
* host: "sftp.example.com",
|
|
44
|
+
* port: 22n,
|
|
45
|
+
* username: "user",
|
|
46
|
+
* password: East.some("password"),
|
|
47
|
+
* privateKey: East.none(),
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* const conn = $.let(Transfer.SFTP.connect(config));
|
|
51
|
+
* $(Transfer.SFTP.put(conn, filename, data));
|
|
52
|
+
* $(Transfer.SFTP.close(conn));
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* const compiled = East.compileAsync(uploadToSftp.toIR(), Transfer.SFTP.Implementation);
|
|
56
|
+
* await compiled("file.txt", fileData);
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* - Supports password and private key authentication
|
|
61
|
+
* - Connection is maintained until explicitly closed
|
|
62
|
+
* - All operations are asynchronous (use East.compileAsync)
|
|
63
|
+
*/
|
|
64
|
+
export const sftp_connect = East.asyncPlatform("sftp_connect", [SftpConfigType], ConnectionHandleType);
|
|
65
|
+
/**
|
|
66
|
+
* Uploads a file to an SFTP server.
|
|
67
|
+
*
|
|
68
|
+
* Uploads binary data to the SFTP server at the specified remote path.
|
|
69
|
+
* Overwrites existing files with the same path.
|
|
70
|
+
*
|
|
71
|
+
* This is a platform function for the East language, enabling SFTP file transfer
|
|
72
|
+
* operations in East programs running on Node.js.
|
|
73
|
+
*
|
|
74
|
+
* @param handle - Connection handle from sftp_connect()
|
|
75
|
+
* @param remotePath - Remote file path on the SFTP server
|
|
76
|
+
* @param data - Binary data to upload
|
|
77
|
+
* @returns Null on success
|
|
78
|
+
*
|
|
79
|
+
* @throws {EastError} When upload fails due to:
|
|
80
|
+
* - Invalid connection handle (location: "sftp_put")
|
|
81
|
+
* - Permission denied (location: "sftp_put")
|
|
82
|
+
* - Invalid remote path (location: "sftp_put")
|
|
83
|
+
* - Network errors (location: "sftp_put")
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* import { East, StringType, BlobType, NullType, variant } from "@elaraai/east";
|
|
88
|
+
* import { Transfer } from "@elaraai/east-node-io";
|
|
89
|
+
*
|
|
90
|
+
* const uploadFile = East.function([StringType, BlobType], NullType, ($, filename, data) => {
|
|
91
|
+
* const config = $.let({
|
|
92
|
+
* host: "sftp.example.com",
|
|
93
|
+
* port: 22n,
|
|
94
|
+
* username: "user",
|
|
95
|
+
* password: variant('some', "password"),
|
|
96
|
+
* privateKey: variant('none', null),
|
|
97
|
+
* });
|
|
98
|
+
* const conn = $.let(Transfer.SFTP.connect(config));
|
|
99
|
+
* $(Transfer.SFTP.put(conn, `/uploads/${filename}`, data));
|
|
100
|
+
* $(Transfer.SFTP.close(conn));
|
|
101
|
+
* return $.return(null);
|
|
102
|
+
* });
|
|
103
|
+
*
|
|
104
|
+
* const compiled = East.compileAsync(uploadFile.toIR(), Transfer.SFTP.Implementation);
|
|
105
|
+
* await compiled("file.txt", fileData);
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @remarks
|
|
109
|
+
* - Creates parent directories if they don't exist
|
|
110
|
+
* - Overwrites existing files
|
|
111
|
+
* - Binary mode transfer
|
|
112
|
+
*/
|
|
113
|
+
export const sftp_put = East.asyncPlatform("sftp_put", [ConnectionHandleType, StringType, BlobType], NullType);
|
|
114
|
+
/**
|
|
115
|
+
* Downloads a file from an SFTP server.
|
|
116
|
+
*
|
|
117
|
+
* Retrieves binary data from the SFTP server at the specified remote path.
|
|
118
|
+
* Returns the file data as a Blob (Uint8Array).
|
|
119
|
+
*
|
|
120
|
+
* This is a platform function for the East language, enabling SFTP file transfer
|
|
121
|
+
* operations in East programs running on Node.js.
|
|
122
|
+
*
|
|
123
|
+
* @param handle - Connection handle from sftp_connect()
|
|
124
|
+
* @param remotePath - Remote file path on the SFTP server
|
|
125
|
+
* @returns Binary data as Blob
|
|
126
|
+
*
|
|
127
|
+
* @throws {EastError} When download fails due to:
|
|
128
|
+
* - Invalid connection handle (location: "sftp_get")
|
|
129
|
+
* - File not found (location: "sftp_get")
|
|
130
|
+
* - Permission denied (location: "sftp_get")
|
|
131
|
+
* - Network errors (location: "sftp_get")
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* import { East, StringType, BlobType, variant } from "@elaraai/east";
|
|
136
|
+
* import { Transfer } from "@elaraai/east-node-io";
|
|
137
|
+
*
|
|
138
|
+
* const downloadFile = East.function([StringType], BlobType, ($, filename) => {
|
|
139
|
+
* const config = $.let({
|
|
140
|
+
* host: "sftp.example.com",
|
|
141
|
+
* port: 22n,
|
|
142
|
+
* username: "user",
|
|
143
|
+
* password: variant('some', "password"),
|
|
144
|
+
* privateKey: variant('none', null),
|
|
145
|
+
* });
|
|
146
|
+
* const conn = $.let(Transfer.SFTP.connect(config));
|
|
147
|
+
* const data = $.let(Transfer.SFTP.get(conn, `/downloads/${filename}`));
|
|
148
|
+
* $(Transfer.SFTP.close(conn));
|
|
149
|
+
* return $.return(data);
|
|
150
|
+
* });
|
|
151
|
+
*
|
|
152
|
+
* const compiled = East.compileAsync(downloadFile.toIR(), Transfer.SFTP.Implementation);
|
|
153
|
+
* const fileData = await compiled("file.txt"); // Returns Uint8Array
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @remarks
|
|
157
|
+
* - Binary mode transfer
|
|
158
|
+
* - Entire file is loaded into memory
|
|
159
|
+
*/
|
|
160
|
+
export const sftp_get = East.asyncPlatform("sftp_get", [ConnectionHandleType, StringType], BlobType);
|
|
161
|
+
/**
|
|
162
|
+
* Lists files in an SFTP directory.
|
|
163
|
+
*
|
|
164
|
+
* Retrieves a list of files and directories at the specified remote path.
|
|
165
|
+
* Returns metadata for each file including name, size, and modification time.
|
|
166
|
+
*
|
|
167
|
+
* This is a platform function for the East language, enabling SFTP file transfer
|
|
168
|
+
* operations in East programs running on Node.js.
|
|
169
|
+
*
|
|
170
|
+
* @param handle - Connection handle from sftp_connect()
|
|
171
|
+
* @param remotePath - Remote directory path on the SFTP server
|
|
172
|
+
* @returns Array of file information metadata
|
|
173
|
+
*
|
|
174
|
+
* @throws {EastError} When listing fails due to:
|
|
175
|
+
* - Invalid connection handle (location: "sftp_list")
|
|
176
|
+
* - Directory not found (location: "sftp_list")
|
|
177
|
+
* - Permission denied (location: "sftp_list")
|
|
178
|
+
* - Network errors (location: "sftp_list")
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* import { East, StringType, ArrayType, variant } from "@elaraai/east";
|
|
183
|
+
* import { Transfer } from "@elaraai/east-node-io";
|
|
184
|
+
*
|
|
185
|
+
* const listFiles = East.function([StringType], ArrayType(Transfer.SFTP.Types.FileInfo), ($, remotePath) => {
|
|
186
|
+
* const config = $.let({
|
|
187
|
+
* host: "sftp.example.com",
|
|
188
|
+
* port: 22n,
|
|
189
|
+
* username: "user",
|
|
190
|
+
* password: variant('some', "password"),
|
|
191
|
+
* privateKey: variant('none', null),
|
|
192
|
+
* });
|
|
193
|
+
* const conn = $.let(Transfer.SFTP.connect(config));
|
|
194
|
+
* const files = $.let(Transfer.SFTP.list(conn, remotePath));
|
|
195
|
+
* $(Transfer.SFTP.close(conn));
|
|
196
|
+
* return $.return(files);
|
|
197
|
+
* });
|
|
198
|
+
*
|
|
199
|
+
* const compiled = East.compileAsync(listFiles.toIR(), Transfer.SFTP.Implementation);
|
|
200
|
+
* const uploads = await compiled("/uploads"); // [{name: "file.txt", size: 1024n, ...}, ...]
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @remarks
|
|
204
|
+
* - Returns both files and directories
|
|
205
|
+
* - Use isDirectory field to distinguish between files and directories
|
|
206
|
+
*/
|
|
207
|
+
export const sftp_list = East.asyncPlatform("sftp_list", [ConnectionHandleType, StringType], ArrayType(FileInfoType));
|
|
208
|
+
/**
|
|
209
|
+
* Deletes a file from an SFTP server.
|
|
210
|
+
*
|
|
211
|
+
* Removes a file from the SFTP server at the specified remote path.
|
|
212
|
+
* Does not delete directories.
|
|
213
|
+
*
|
|
214
|
+
* This is a platform function for the East language, enabling SFTP file transfer
|
|
215
|
+
* operations in East programs running on Node.js.
|
|
216
|
+
*
|
|
217
|
+
* @param handle - Connection handle from sftp_connect()
|
|
218
|
+
* @param remotePath - Remote file path to delete
|
|
219
|
+
* @returns Null on success
|
|
220
|
+
*
|
|
221
|
+
* @throws {EastError} When deletion fails due to:
|
|
222
|
+
* - Invalid connection handle (location: "sftp_delete")
|
|
223
|
+
* - File not found (location: "sftp_delete")
|
|
224
|
+
* - Permission denied (location: "sftp_delete")
|
|
225
|
+
* - Network errors (location: "sftp_delete")
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* import { East, StringType, NullType, variant } from "@elaraai/east";
|
|
230
|
+
* import { Transfer } from "@elaraai/east-node-io";
|
|
231
|
+
*
|
|
232
|
+
* const deleteFile = East.function([StringType], NullType, ($, filename) => {
|
|
233
|
+
* const config = $.let({
|
|
234
|
+
* host: "sftp.example.com",
|
|
235
|
+
* port: 22n,
|
|
236
|
+
* username: "user",
|
|
237
|
+
* password: variant('some', "password"),
|
|
238
|
+
* privateKey: variant('none', null),
|
|
239
|
+
* });
|
|
240
|
+
* const conn = $.let(Transfer.SFTP.connect(config));
|
|
241
|
+
* $(Transfer.SFTP.delete(conn, `/uploads/${filename}`));
|
|
242
|
+
* $(Transfer.SFTP.close(conn));
|
|
243
|
+
* return $.return(null);
|
|
244
|
+
* });
|
|
245
|
+
*
|
|
246
|
+
* const compiled = East.compileAsync(deleteFile.toIR(), Transfer.SFTP.Implementation);
|
|
247
|
+
* await compiled("old-file.txt");
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @remarks
|
|
251
|
+
* - Only deletes files, not directories
|
|
252
|
+
* - Throws error if file doesn't exist
|
|
253
|
+
*/
|
|
254
|
+
export const sftp_delete = East.asyncPlatform("sftp_delete", [ConnectionHandleType, StringType], NullType);
|
|
255
|
+
/**
|
|
256
|
+
* Closes an SFTP connection.
|
|
257
|
+
*
|
|
258
|
+
* Closes the SFTP connection and releases all resources.
|
|
259
|
+
* The handle becomes invalid after this operation.
|
|
260
|
+
*
|
|
261
|
+
* @param handle - Connection handle from sftp_connect()
|
|
262
|
+
* @returns Null on success
|
|
263
|
+
*
|
|
264
|
+
* @throws {EastError} When handle is invalid (location: "sftp_close")
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```ts
|
|
268
|
+
* import { East, NullType, variant } from "@elaraai/east";
|
|
269
|
+
* import { Transfer } from "@elaraai/east-node-io";
|
|
270
|
+
*
|
|
271
|
+
* const cleanup = East.function([], NullType, $ => {
|
|
272
|
+
* const config = $.let({
|
|
273
|
+
* host: "sftp.example.com",
|
|
274
|
+
* port: 22n,
|
|
275
|
+
* username: "user",
|
|
276
|
+
* password: variant('some', "password"),
|
|
277
|
+
* privateKey: variant('none', null),
|
|
278
|
+
* });
|
|
279
|
+
* const conn = $.let(Transfer.SFTP.connect(config));
|
|
280
|
+
* // ... do work ...
|
|
281
|
+
* $(Transfer.SFTP.close(conn));
|
|
282
|
+
* return $.return(null);
|
|
283
|
+
* });
|
|
284
|
+
*
|
|
285
|
+
* const compiled = East.compileAsync(cleanup.toIR(), Transfer.SFTP.Implementation);
|
|
286
|
+
* await compiled();
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
export const sftp_close = East.asyncPlatform("sftp_close", [ConnectionHandleType], NullType);
|
|
290
|
+
/**
|
|
291
|
+
* Closes all SFTP connections.
|
|
292
|
+
*
|
|
293
|
+
* Closes all active SFTP connections and releases all resources.
|
|
294
|
+
* Useful for test cleanup to ensure all connections are closed.
|
|
295
|
+
*
|
|
296
|
+
* @returns Null on success
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```ts
|
|
300
|
+
* import { East, NullType } from "@elaraai/east";
|
|
301
|
+
* import { Transfer } from "@elaraai/east-node-io";
|
|
302
|
+
*
|
|
303
|
+
* const cleanupAll = East.function([], NullType, $ => {
|
|
304
|
+
* // ... test code that may have left connections open ...
|
|
305
|
+
* $(Transfer.SFTP.closeAll());
|
|
306
|
+
* return $.return(null);
|
|
307
|
+
* });
|
|
308
|
+
*
|
|
309
|
+
* const compiled = East.compileAsync(cleanupAll.toIR(), Transfer.SFTP.Implementation);
|
|
310
|
+
* await compiled();
|
|
311
|
+
* ```
|
|
312
|
+
*
|
|
313
|
+
* @internal
|
|
314
|
+
*/
|
|
315
|
+
export const sftp_close_all = East.asyncPlatform("sftp_close_all", [], NullType);
|
|
316
|
+
/**
|
|
317
|
+
* Node.js implementation of SFTP platform functions.
|
|
318
|
+
*
|
|
319
|
+
* Provides the runtime implementations for SFTP operations using ssh2-sftp-client.
|
|
320
|
+
* Pass this to East.compileAsync() to enable SFTP functionality.
|
|
321
|
+
*/
|
|
322
|
+
export const SftpImpl = [
|
|
323
|
+
sftp_connect.implement(async (config) => {
|
|
324
|
+
try {
|
|
325
|
+
const client = new SftpClient();
|
|
326
|
+
const connectConfig = {
|
|
327
|
+
host: config.host,
|
|
328
|
+
port: Number(config.port),
|
|
329
|
+
username: config.username,
|
|
330
|
+
};
|
|
331
|
+
// Add password if provided
|
|
332
|
+
if (config.password?.type === 'some') {
|
|
333
|
+
connectConfig.password = config.password.value;
|
|
334
|
+
}
|
|
335
|
+
// Add private key if provided
|
|
336
|
+
if (config.privateKey?.type === 'some') {
|
|
337
|
+
connectConfig.privateKey = config.privateKey.value;
|
|
338
|
+
}
|
|
339
|
+
await client.connect(connectConfig);
|
|
340
|
+
return createHandle(client, async () => {
|
|
341
|
+
await client.end();
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
catch (err) {
|
|
345
|
+
throw new EastError(`SFTP connection failed: ${err.message}`, {
|
|
346
|
+
location: { filename: "sftp_connect", line: 0n, column: 0n },
|
|
347
|
+
cause: err
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}),
|
|
351
|
+
sftp_put.implement(async (handle, remotePath, data) => {
|
|
352
|
+
try {
|
|
353
|
+
const client = getConnection(handle);
|
|
354
|
+
// Upload from buffer
|
|
355
|
+
await client.put(Buffer.from(data), remotePath);
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
catch (err) {
|
|
359
|
+
throw new EastError(`SFTP upload failed: ${err.message}`, {
|
|
360
|
+
location: { filename: "sftp_put", line: 0n, column: 0n },
|
|
361
|
+
cause: err
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}),
|
|
365
|
+
sftp_get.implement(async (handle, remotePath) => {
|
|
366
|
+
try {
|
|
367
|
+
const client = getConnection(handle);
|
|
368
|
+
// Download to buffer
|
|
369
|
+
const buffer = await client.get(remotePath);
|
|
370
|
+
if (Buffer.isBuffer(buffer)) {
|
|
371
|
+
return new Uint8Array(buffer);
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
throw new Error('Expected buffer, got stream or other type');
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
catch (err) {
|
|
378
|
+
throw new EastError(`SFTP download failed: ${err.message}`, {
|
|
379
|
+
location: { filename: "sftp_get", line: 0n, column: 0n },
|
|
380
|
+
cause: err
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}),
|
|
384
|
+
sftp_list.implement(async (handle, remotePath) => {
|
|
385
|
+
try {
|
|
386
|
+
const client = getConnection(handle);
|
|
387
|
+
const files = await client.list(remotePath);
|
|
388
|
+
// Convert to East FileInfoType format
|
|
389
|
+
return files.map((file) => ({
|
|
390
|
+
name: file.name,
|
|
391
|
+
path: remotePath + (remotePath.endsWith('/') ? '' : '/') + file.name,
|
|
392
|
+
size: BigInt(file.size),
|
|
393
|
+
isDirectory: file.type === 'd',
|
|
394
|
+
modifiedTime: new Date(file.modifyTime).toISOString(),
|
|
395
|
+
}));
|
|
396
|
+
}
|
|
397
|
+
catch (err) {
|
|
398
|
+
throw new EastError(`SFTP list failed: ${err.message}`, {
|
|
399
|
+
location: { filename: "sftp_list", line: 0n, column: 0n },
|
|
400
|
+
cause: err
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
}),
|
|
404
|
+
sftp_delete.implement(async (handle, remotePath) => {
|
|
405
|
+
try {
|
|
406
|
+
const client = getConnection(handle);
|
|
407
|
+
await client.delete(remotePath);
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
catch (err) {
|
|
411
|
+
throw new EastError(`SFTP delete failed: ${err.message}`, {
|
|
412
|
+
location: { filename: "sftp_delete", line: 0n, column: 0n },
|
|
413
|
+
cause: err
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
}),
|
|
417
|
+
sftp_close.implement(async (handle) => {
|
|
418
|
+
try {
|
|
419
|
+
const client = getConnection(handle);
|
|
420
|
+
await client.end();
|
|
421
|
+
closeHandle(handle);
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
catch (err) {
|
|
425
|
+
throw new EastError(`SFTP close failed: ${err.message}`, {
|
|
426
|
+
location: { filename: "sftp_close", line: 0n, column: 0n },
|
|
427
|
+
cause: err
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
}),
|
|
431
|
+
sftp_close_all.implement(async () => {
|
|
432
|
+
await closeAllHandles();
|
|
433
|
+
return null;
|
|
434
|
+
}),
|
|
435
|
+
];
|
|
436
|
+
//# sourceMappingURL=sftp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sftp.js","sourceRoot":"","sources":["../../src/transfer/sftp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC,cAAc,CAAC,EAAE,oBAAoB,CAAC,CAAC;AAEvG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,oBAAoB,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;AAE/G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAC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AM,CAAC,GAAG,EAAE,CAAC;YACnB,WAAW,CAAC,MAAM,CAAC,CAAC;YACpB,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,MAAM,IAAI,SAAS,CAAC,sBAAsB,GAAG,CAAC,OAAO,EAAE,EAAE;gBACrD,QAAQ,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;gBAC1D,KAAK,EAAE,GAAG;aACb,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC;IAEF,cAAc,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAChC,MAAM,eAAe,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;CACL,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
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 transfer protocol type definitions for East Node IO.
|
|
7
|
+
*
|
|
8
|
+
* Provides East type definitions for FTP and SFTP file transfer operations
|
|
9
|
+
* including configurations and file metadata.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { StructType, OptionType, StringType, IntegerType, BooleanType } from "@elaraai/east";
|
|
14
|
+
export { StringType } from "@elaraai/east";
|
|
15
|
+
/**
|
|
16
|
+
* FTP connection configuration.
|
|
17
|
+
*
|
|
18
|
+
* Configures connection to an FTP or FTPS (FTP over SSL/TLS) server.
|
|
19
|
+
*/
|
|
20
|
+
export declare const FtpConfigType: StructType<{
|
|
21
|
+
/**
|
|
22
|
+
* FTP server hostname or IP address.
|
|
23
|
+
*/
|
|
24
|
+
host: StringType;
|
|
25
|
+
/**
|
|
26
|
+
* FTP server port (typically 21 for FTP, 990 for FTPS).
|
|
27
|
+
*/
|
|
28
|
+
port: IntegerType;
|
|
29
|
+
/**
|
|
30
|
+
* Username for authentication.
|
|
31
|
+
*/
|
|
32
|
+
user: StringType;
|
|
33
|
+
/**
|
|
34
|
+
* Password for authentication.
|
|
35
|
+
*/
|
|
36
|
+
password: StringType;
|
|
37
|
+
/**
|
|
38
|
+
* Use secure FTP (FTPS - FTP over SSL/TLS).
|
|
39
|
+
*/
|
|
40
|
+
secure: BooleanType;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* SFTP connection configuration.
|
|
44
|
+
*
|
|
45
|
+
* Configures connection to an SFTP (SSH File Transfer Protocol) server.
|
|
46
|
+
*/
|
|
47
|
+
export declare const SftpConfigType: StructType<{
|
|
48
|
+
/**
|
|
49
|
+
* SFTP server hostname or IP address.
|
|
50
|
+
*/
|
|
51
|
+
host: StringType;
|
|
52
|
+
/**
|
|
53
|
+
* SFTP server port (typically 22).
|
|
54
|
+
*/
|
|
55
|
+
port: IntegerType;
|
|
56
|
+
/**
|
|
57
|
+
* Username for authentication.
|
|
58
|
+
*/
|
|
59
|
+
username: StringType;
|
|
60
|
+
/**
|
|
61
|
+
* Password for authentication.
|
|
62
|
+
* Optional if using private key authentication.
|
|
63
|
+
*/
|
|
64
|
+
password: OptionType<StringType>;
|
|
65
|
+
/**
|
|
66
|
+
* SSH private key for authentication.
|
|
67
|
+
* Optional if using password authentication.
|
|
68
|
+
*/
|
|
69
|
+
privateKey: OptionType<StringType>;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* File information metadata.
|
|
73
|
+
*
|
|
74
|
+
* Represents metadata about a file or directory on an FTP/SFTP server.
|
|
75
|
+
*/
|
|
76
|
+
export declare const FileInfoType: StructType<{
|
|
77
|
+
/**
|
|
78
|
+
* File or directory name.
|
|
79
|
+
*/
|
|
80
|
+
name: StringType;
|
|
81
|
+
/**
|
|
82
|
+
* Full path to the file or directory.
|
|
83
|
+
*/
|
|
84
|
+
path: StringType;
|
|
85
|
+
/**
|
|
86
|
+
* File size in bytes (0 for directories).
|
|
87
|
+
*/
|
|
88
|
+
size: IntegerType;
|
|
89
|
+
/**
|
|
90
|
+
* Whether this is a directory (true) or file (false).
|
|
91
|
+
*/
|
|
92
|
+
isDirectory: BooleanType;
|
|
93
|
+
/**
|
|
94
|
+
* Last modified timestamp (ISO 8601 format).
|
|
95
|
+
*/
|
|
96
|
+
modifiedTime: StringType;
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* Opaque connection handle type.
|
|
100
|
+
*
|
|
101
|
+
* Represents an active FTP or SFTP connection.
|
|
102
|
+
* Handles are created by connect() functions and used in transfer operations.
|
|
103
|
+
*
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
declare const ConnectionHandleType: StringType;
|
|
107
|
+
export { ConnectionHandleType };
|
|
108
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/transfer/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EACH,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACd,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,aAAa;IACtB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEL,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,cAAc;IACvB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAGH;;;OAGG;;EAEL,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY;IACrB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEL,CAAC;AAEH;;;;;;;GAOG;AACH,QAAA,MAAM,oBAAoB,YAAa,CAAC;AAGxC,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
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 transfer protocol type definitions for East Node IO.
|
|
7
|
+
*
|
|
8
|
+
* Provides East type definitions for FTP and SFTP file transfer operations
|
|
9
|
+
* including configurations and file metadata.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { StructType, OptionType, StringType, IntegerType, BooleanType, } from "@elaraai/east";
|
|
14
|
+
// Re-export StringType for use in other transfer modules
|
|
15
|
+
export { StringType } from "@elaraai/east";
|
|
16
|
+
/**
|
|
17
|
+
* FTP connection configuration.
|
|
18
|
+
*
|
|
19
|
+
* Configures connection to an FTP or FTPS (FTP over SSL/TLS) server.
|
|
20
|
+
*/
|
|
21
|
+
export const FtpConfigType = StructType({
|
|
22
|
+
/**
|
|
23
|
+
* FTP server hostname or IP address.
|
|
24
|
+
*/
|
|
25
|
+
host: StringType,
|
|
26
|
+
/**
|
|
27
|
+
* FTP server port (typically 21 for FTP, 990 for FTPS).
|
|
28
|
+
*/
|
|
29
|
+
port: IntegerType,
|
|
30
|
+
/**
|
|
31
|
+
* Username for authentication.
|
|
32
|
+
*/
|
|
33
|
+
user: StringType,
|
|
34
|
+
/**
|
|
35
|
+
* Password for authentication.
|
|
36
|
+
*/
|
|
37
|
+
password: StringType,
|
|
38
|
+
/**
|
|
39
|
+
* Use secure FTP (FTPS - FTP over SSL/TLS).
|
|
40
|
+
*/
|
|
41
|
+
secure: BooleanType,
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* SFTP connection configuration.
|
|
45
|
+
*
|
|
46
|
+
* Configures connection to an SFTP (SSH File Transfer Protocol) server.
|
|
47
|
+
*/
|
|
48
|
+
export const SftpConfigType = StructType({
|
|
49
|
+
/**
|
|
50
|
+
* SFTP server hostname or IP address.
|
|
51
|
+
*/
|
|
52
|
+
host: StringType,
|
|
53
|
+
/**
|
|
54
|
+
* SFTP server port (typically 22).
|
|
55
|
+
*/
|
|
56
|
+
port: IntegerType,
|
|
57
|
+
/**
|
|
58
|
+
* Username for authentication.
|
|
59
|
+
*/
|
|
60
|
+
username: StringType,
|
|
61
|
+
/**
|
|
62
|
+
* Password for authentication.
|
|
63
|
+
* Optional if using private key authentication.
|
|
64
|
+
*/
|
|
65
|
+
password: OptionType(StringType),
|
|
66
|
+
/**
|
|
67
|
+
* SSH private key for authentication.
|
|
68
|
+
* Optional if using password authentication.
|
|
69
|
+
*/
|
|
70
|
+
privateKey: OptionType(StringType),
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* File information metadata.
|
|
74
|
+
*
|
|
75
|
+
* Represents metadata about a file or directory on an FTP/SFTP server.
|
|
76
|
+
*/
|
|
77
|
+
export const FileInfoType = StructType({
|
|
78
|
+
/**
|
|
79
|
+
* File or directory name.
|
|
80
|
+
*/
|
|
81
|
+
name: StringType,
|
|
82
|
+
/**
|
|
83
|
+
* Full path to the file or directory.
|
|
84
|
+
*/
|
|
85
|
+
path: StringType,
|
|
86
|
+
/**
|
|
87
|
+
* File size in bytes (0 for directories).
|
|
88
|
+
*/
|
|
89
|
+
size: IntegerType,
|
|
90
|
+
/**
|
|
91
|
+
* Whether this is a directory (true) or file (false).
|
|
92
|
+
*/
|
|
93
|
+
isDirectory: BooleanType,
|
|
94
|
+
/**
|
|
95
|
+
* Last modified timestamp (ISO 8601 format).
|
|
96
|
+
*/
|
|
97
|
+
modifiedTime: StringType,
|
|
98
|
+
});
|
|
99
|
+
/**
|
|
100
|
+
* Opaque connection handle type.
|
|
101
|
+
*
|
|
102
|
+
* Represents an active FTP or SFTP connection.
|
|
103
|
+
* Handles are created by connect() functions and used in transfer operations.
|
|
104
|
+
*
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
const ConnectionHandleType = StringType;
|
|
108
|
+
// Export for internal use within transfer module only
|
|
109
|
+
export { ConnectionHandleType };
|
|
110
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/transfer/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EACH,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,GACd,MAAM,eAAe,CAAC;AAEvB,yDAAyD;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;IACpC;;OAEG;IACH,IAAI,EAAE,UAAU;IAEhB;;OAEG;IACH,IAAI,EAAE,WAAW;IAEjB;;OAEG;IACH,IAAI,EAAE,UAAU;IAEhB;;OAEG;IACH,QAAQ,EAAE,UAAU;IAEpB;;OAEG;IACH,MAAM,EAAE,WAAW;CACtB,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;IACrC;;OAEG;IACH,IAAI,EAAE,UAAU;IAEhB;;OAEG;IACH,IAAI,EAAE,WAAW;IAEjB;;OAEG;IACH,QAAQ,EAAE,UAAU;IAEpB;;;OAGG;IACH,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC;IAEhC;;;OAGG;IACH,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC;CACrC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;IACnC;;OAEG;IACH,IAAI,EAAE,UAAU;IAEhB;;OAEG;IACH,IAAI,EAAE,UAAU;IAEhB;;OAEG;IACH,IAAI,EAAE,WAAW;IAEjB;;OAEG;IACH,WA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