@elaraai/east-node-io 0.0.1-beta.1 → 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.
Files changed (114) hide show
  1. package/dist/compression/gzip.d.ts +108 -0
  2. package/dist/compression/gzip.d.ts.map +1 -0
  3. package/dist/compression/gzip.js +153 -0
  4. package/dist/compression/gzip.js.map +1 -0
  5. package/dist/compression/index.d.ts +308 -0
  6. package/dist/compression/index.d.ts.map +1 -0
  7. package/dist/compression/index.js +289 -0
  8. package/dist/compression/index.js.map +1 -0
  9. package/dist/compression/tar.d.ts +115 -0
  10. package/dist/compression/tar.d.ts.map +1 -0
  11. package/dist/compression/tar.js +254 -0
  12. package/dist/compression/tar.js.map +1 -0
  13. package/dist/compression/types.d.ts +124 -0
  14. package/dist/compression/types.d.ts.map +1 -0
  15. package/dist/compression/types.js +106 -0
  16. package/dist/compression/types.js.map +1 -0
  17. package/dist/compression/zip.d.ts +121 -0
  18. package/dist/compression/zip.d.ts.map +1 -0
  19. package/dist/compression/zip.js +200 -0
  20. package/dist/compression/zip.js.map +1 -0
  21. package/dist/connection/index.d.ts +78 -0
  22. package/dist/connection/index.d.ts.map +1 -0
  23. package/dist/connection/index.js +134 -0
  24. package/dist/connection/index.js.map +1 -0
  25. package/dist/format/csv.d.ts +210 -0
  26. package/dist/format/csv.d.ts.map +1 -0
  27. package/dist/format/csv.js +729 -0
  28. package/dist/format/csv.js.map +1 -0
  29. package/dist/format/index.d.ts +641 -0
  30. package/dist/format/index.d.ts.map +1 -0
  31. package/dist/format/index.js +463 -0
  32. package/dist/format/index.js.map +1 -0
  33. package/dist/format/types.d.ts +176 -0
  34. package/dist/format/types.d.ts.map +1 -0
  35. package/dist/format/types.js +122 -0
  36. package/dist/format/types.js.map +1 -0
  37. package/dist/format/xlsx.d.ts +178 -0
  38. package/dist/format/xlsx.d.ts.map +1 -0
  39. package/dist/format/xlsx.js +313 -0
  40. package/dist/format/xlsx.js.map +1 -0
  41. package/dist/format/xml.d.ts +302 -0
  42. package/dist/format/xml.d.ts.map +1 -0
  43. package/dist/format/xml.js +602 -0
  44. package/dist/format/xml.js.map +1 -0
  45. package/dist/index.d.ts +25 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +32 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/nosql/index.d.ts +503 -0
  50. package/dist/nosql/index.d.ts.map +1 -0
  51. package/dist/nosql/index.js +483 -0
  52. package/dist/nosql/index.js.map +1 -0
  53. package/dist/nosql/mongodb.d.ts +306 -0
  54. package/dist/nosql/mongodb.d.ts.map +1 -0
  55. package/dist/nosql/mongodb.js +552 -0
  56. package/dist/nosql/mongodb.js.map +1 -0
  57. package/dist/nosql/redis.d.ts +268 -0
  58. package/dist/nosql/redis.d.ts.map +1 -0
  59. package/dist/nosql/redis.js +371 -0
  60. package/dist/nosql/redis.js.map +1 -0
  61. package/dist/nosql/types.d.ts +70 -0
  62. package/dist/nosql/types.d.ts.map +1 -0
  63. package/dist/nosql/types.js +79 -0
  64. package/dist/nosql/types.js.map +1 -0
  65. package/dist/sql/index.d.ts +777 -0
  66. package/dist/sql/index.d.ts.map +1 -0
  67. package/dist/sql/index.js +515 -0
  68. package/dist/sql/index.js.map +1 -0
  69. package/dist/sql/mysql.d.ts +238 -0
  70. package/dist/sql/mysql.d.ts.map +1 -0
  71. package/dist/sql/mysql.js +396 -0
  72. package/dist/sql/mysql.js.map +1 -0
  73. package/dist/sql/postgres.d.ts +237 -0
  74. package/dist/sql/postgres.d.ts.map +1 -0
  75. package/dist/sql/postgres.js +381 -0
  76. package/dist/sql/postgres.js.map +1 -0
  77. package/dist/sql/sqlite.d.ts +217 -0
  78. package/dist/sql/sqlite.d.ts.map +1 -0
  79. package/dist/sql/sqlite.js +366 -0
  80. package/dist/sql/sqlite.js.map +1 -0
  81. package/dist/sql/types.d.ts +205 -0
  82. package/dist/sql/types.d.ts.map +1 -0
  83. package/dist/sql/types.js +175 -0
  84. package/dist/sql/types.js.map +1 -0
  85. package/dist/storage/index.d.ts +304 -0
  86. package/dist/storage/index.d.ts.map +1 -0
  87. package/dist/storage/index.js +234 -0
  88. package/dist/storage/index.js.map +1 -0
  89. package/dist/storage/s3.d.ts +373 -0
  90. package/dist/storage/s3.d.ts.map +1 -0
  91. package/dist/storage/s3.js +502 -0
  92. package/dist/storage/s3.js.map +1 -0
  93. package/dist/storage/types.d.ts +117 -0
  94. package/dist/storage/types.d.ts.map +1 -0
  95. package/dist/storage/types.js +94 -0
  96. package/dist/storage/types.js.map +1 -0
  97. package/dist/transfer/ftp.d.ts +333 -0
  98. package/dist/transfer/ftp.d.ts.map +1 -0
  99. package/dist/transfer/ftp.js +437 -0
  100. package/dist/transfer/ftp.js.map +1 -0
  101. package/dist/transfer/index.d.ts +456 -0
  102. package/dist/transfer/index.d.ts.map +1 -0
  103. package/dist/transfer/index.js +414 -0
  104. package/dist/transfer/index.js.map +1 -0
  105. package/dist/transfer/sftp.d.ts +333 -0
  106. package/dist/transfer/sftp.d.ts.map +1 -0
  107. package/dist/transfer/sftp.js +436 -0
  108. package/dist/transfer/sftp.js.map +1 -0
  109. package/dist/transfer/types.d.ts +108 -0
  110. package/dist/transfer/types.d.ts.map +1 -0
  111. package/dist/transfer/types.js +110 -0
  112. package/dist/transfer/types.js.map +1 -0
  113. package/dist/tsconfig.tsbuildinfo +1 -0
  114. package/package.json +6 -6
@@ -0,0 +1,333 @@
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 { BlobType, ArrayType, NullType } from "@elaraai/east";
14
+ import type { PlatformFunction } from "@elaraai/east/internal";
15
+ import { StringType } from "./types.js";
16
+ /**
17
+ * Connects to an SFTP server.
18
+ *
19
+ * Creates a connection to an SFTP server and returns an opaque handle
20
+ * for use in file transfer operations.
21
+ *
22
+ * This is a platform function for the East language, enabling SFTP file transfer
23
+ * operations in East programs running on Node.js.
24
+ *
25
+ * @param config - SFTP connection configuration
26
+ * @returns Connection handle (opaque string)
27
+ *
28
+ * @throws {EastError} When connection fails due to:
29
+ * - Invalid hostname or port (location: "sftp_connect")
30
+ * - Authentication failure (location: "sftp_connect")
31
+ * - Network errors (location: "sftp_connect")
32
+ * - SSH key errors (location: "sftp_connect")
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * import { East, StringType, BlobType } from "@elaraai/east";
37
+ * import { Transfer } from "@elaraai/east-node-io";
38
+ *
39
+ * const uploadToSftp = East.function([StringType, BlobType], NullType, ($, filename, data) => {
40
+ * const config = $.let({
41
+ * host: "sftp.example.com",
42
+ * port: 22n,
43
+ * username: "user",
44
+ * password: East.some("password"),
45
+ * privateKey: East.none(),
46
+ * });
47
+ *
48
+ * const conn = $.let(Transfer.SFTP.connect(config));
49
+ * $(Transfer.SFTP.put(conn, filename, data));
50
+ * $(Transfer.SFTP.close(conn));
51
+ * });
52
+ *
53
+ * const compiled = East.compileAsync(uploadToSftp.toIR(), Transfer.SFTP.Implementation);
54
+ * await compiled("file.txt", fileData);
55
+ * ```
56
+ *
57
+ * @remarks
58
+ * - Supports password and private key authentication
59
+ * - Connection is maintained until explicitly closed
60
+ * - All operations are asynchronous (use East.compileAsync)
61
+ */
62
+ export declare const sftp_connect: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StructType<{
63
+ host: StringType;
64
+ port: import("@elaraai/east").IntegerType;
65
+ username: StringType;
66
+ password: import("@elaraai/east").OptionType<StringType>;
67
+ privateKey: import("@elaraai/east").OptionType<StringType>;
68
+ }>], StringType>;
69
+ /**
70
+ * Uploads a file to an SFTP server.
71
+ *
72
+ * Uploads binary data to the SFTP server at the specified remote path.
73
+ * Overwrites existing files with the same path.
74
+ *
75
+ * This is a platform function for the East language, enabling SFTP file transfer
76
+ * operations in East programs running on Node.js.
77
+ *
78
+ * @param handle - Connection handle from sftp_connect()
79
+ * @param remotePath - Remote file path on the SFTP server
80
+ * @param data - Binary data to upload
81
+ * @returns Null on success
82
+ *
83
+ * @throws {EastError} When upload fails due to:
84
+ * - Invalid connection handle (location: "sftp_put")
85
+ * - Permission denied (location: "sftp_put")
86
+ * - Invalid remote path (location: "sftp_put")
87
+ * - Network errors (location: "sftp_put")
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * import { East, StringType, BlobType, NullType, variant } from "@elaraai/east";
92
+ * import { Transfer } from "@elaraai/east-node-io";
93
+ *
94
+ * const uploadFile = East.function([StringType, BlobType], NullType, ($, filename, data) => {
95
+ * const config = $.let({
96
+ * host: "sftp.example.com",
97
+ * port: 22n,
98
+ * username: "user",
99
+ * password: variant('some', "password"),
100
+ * privateKey: variant('none', null),
101
+ * });
102
+ * const conn = $.let(Transfer.SFTP.connect(config));
103
+ * $(Transfer.SFTP.put(conn, `/uploads/${filename}`, data));
104
+ * $(Transfer.SFTP.close(conn));
105
+ * return $.return(null);
106
+ * });
107
+ *
108
+ * const compiled = East.compileAsync(uploadFile.toIR(), Transfer.SFTP.Implementation);
109
+ * await compiled("file.txt", fileData);
110
+ * ```
111
+ *
112
+ * @remarks
113
+ * - Creates parent directories if they don't exist
114
+ * - Overwrites existing files
115
+ * - Binary mode transfer
116
+ */
117
+ export declare const sftp_put: import("@elaraai/east").AsyncPlatformDefinition<[StringType, StringType, BlobType], NullType>;
118
+ /**
119
+ * Downloads a file from an SFTP server.
120
+ *
121
+ * Retrieves binary data from the SFTP server at the specified remote path.
122
+ * Returns the file data as a Blob (Uint8Array).
123
+ *
124
+ * This is a platform function for the East language, enabling SFTP file transfer
125
+ * operations in East programs running on Node.js.
126
+ *
127
+ * @param handle - Connection handle from sftp_connect()
128
+ * @param remotePath - Remote file path on the SFTP server
129
+ * @returns Binary data as Blob
130
+ *
131
+ * @throws {EastError} When download fails due to:
132
+ * - Invalid connection handle (location: "sftp_get")
133
+ * - File not found (location: "sftp_get")
134
+ * - Permission denied (location: "sftp_get")
135
+ * - Network errors (location: "sftp_get")
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * import { East, StringType, BlobType, variant } from "@elaraai/east";
140
+ * import { Transfer } from "@elaraai/east-node-io";
141
+ *
142
+ * const downloadFile = East.function([StringType], BlobType, ($, filename) => {
143
+ * const config = $.let({
144
+ * host: "sftp.example.com",
145
+ * port: 22n,
146
+ * username: "user",
147
+ * password: variant('some', "password"),
148
+ * privateKey: variant('none', null),
149
+ * });
150
+ * const conn = $.let(Transfer.SFTP.connect(config));
151
+ * const data = $.let(Transfer.SFTP.get(conn, `/downloads/${filename}`));
152
+ * $(Transfer.SFTP.close(conn));
153
+ * return $.return(data);
154
+ * });
155
+ *
156
+ * const compiled = East.compileAsync(downloadFile.toIR(), Transfer.SFTP.Implementation);
157
+ * const fileData = await compiled("file.txt"); // Returns Uint8Array
158
+ * ```
159
+ *
160
+ * @remarks
161
+ * - Binary mode transfer
162
+ * - Entire file is loaded into memory
163
+ */
164
+ export declare const sftp_get: import("@elaraai/east").AsyncPlatformDefinition<[StringType, StringType], BlobType>;
165
+ /**
166
+ * Lists files in an SFTP directory.
167
+ *
168
+ * Retrieves a list of files and directories at the specified remote path.
169
+ * Returns metadata for each file including name, size, and modification time.
170
+ *
171
+ * This is a platform function for the East language, enabling SFTP file transfer
172
+ * operations in East programs running on Node.js.
173
+ *
174
+ * @param handle - Connection handle from sftp_connect()
175
+ * @param remotePath - Remote directory path on the SFTP server
176
+ * @returns Array of file information metadata
177
+ *
178
+ * @throws {EastError} When listing fails due to:
179
+ * - Invalid connection handle (location: "sftp_list")
180
+ * - Directory not found (location: "sftp_list")
181
+ * - Permission denied (location: "sftp_list")
182
+ * - Network errors (location: "sftp_list")
183
+ *
184
+ * @example
185
+ * ```ts
186
+ * import { East, StringType, ArrayType, variant } from "@elaraai/east";
187
+ * import { Transfer } from "@elaraai/east-node-io";
188
+ *
189
+ * const listFiles = East.function([StringType], ArrayType(Transfer.SFTP.Types.FileInfo), ($, remotePath) => {
190
+ * const config = $.let({
191
+ * host: "sftp.example.com",
192
+ * port: 22n,
193
+ * username: "user",
194
+ * password: variant('some', "password"),
195
+ * privateKey: variant('none', null),
196
+ * });
197
+ * const conn = $.let(Transfer.SFTP.connect(config));
198
+ * const files = $.let(Transfer.SFTP.list(conn, remotePath));
199
+ * $(Transfer.SFTP.close(conn));
200
+ * return $.return(files);
201
+ * });
202
+ *
203
+ * const compiled = East.compileAsync(listFiles.toIR(), Transfer.SFTP.Implementation);
204
+ * const uploads = await compiled("/uploads"); // [{name: "file.txt", size: 1024n, ...}, ...]
205
+ * ```
206
+ *
207
+ * @remarks
208
+ * - Returns both files and directories
209
+ * - Use isDirectory field to distinguish between files and directories
210
+ */
211
+ export declare const sftp_list: import("@elaraai/east").AsyncPlatformDefinition<[StringType, StringType], ArrayType<import("@elaraai/east").StructType<{
212
+ name: StringType;
213
+ path: StringType;
214
+ size: import("@elaraai/east").IntegerType;
215
+ isDirectory: import("@elaraai/east").BooleanType;
216
+ modifiedTime: StringType;
217
+ }>>>;
218
+ /**
219
+ * Deletes a file from an SFTP server.
220
+ *
221
+ * Removes a file from the SFTP server at the specified remote path.
222
+ * Does not delete directories.
223
+ *
224
+ * This is a platform function for the East language, enabling SFTP file transfer
225
+ * operations in East programs running on Node.js.
226
+ *
227
+ * @param handle - Connection handle from sftp_connect()
228
+ * @param remotePath - Remote file path to delete
229
+ * @returns Null on success
230
+ *
231
+ * @throws {EastError} When deletion fails due to:
232
+ * - Invalid connection handle (location: "sftp_delete")
233
+ * - File not found (location: "sftp_delete")
234
+ * - Permission denied (location: "sftp_delete")
235
+ * - Network errors (location: "sftp_delete")
236
+ *
237
+ * @example
238
+ * ```ts
239
+ * import { East, StringType, NullType, variant } from "@elaraai/east";
240
+ * import { Transfer } from "@elaraai/east-node-io";
241
+ *
242
+ * const deleteFile = East.function([StringType], NullType, ($, filename) => {
243
+ * const config = $.let({
244
+ * host: "sftp.example.com",
245
+ * port: 22n,
246
+ * username: "user",
247
+ * password: variant('some', "password"),
248
+ * privateKey: variant('none', null),
249
+ * });
250
+ * const conn = $.let(Transfer.SFTP.connect(config));
251
+ * $(Transfer.SFTP.delete(conn, `/uploads/${filename}`));
252
+ * $(Transfer.SFTP.close(conn));
253
+ * return $.return(null);
254
+ * });
255
+ *
256
+ * const compiled = East.compileAsync(deleteFile.toIR(), Transfer.SFTP.Implementation);
257
+ * await compiled("old-file.txt");
258
+ * ```
259
+ *
260
+ * @remarks
261
+ * - Only deletes files, not directories
262
+ * - Throws error if file doesn't exist
263
+ */
264
+ export declare const sftp_delete: import("@elaraai/east").AsyncPlatformDefinition<[StringType, StringType], NullType>;
265
+ /**
266
+ * Closes an SFTP connection.
267
+ *
268
+ * Closes the SFTP connection and releases all resources.
269
+ * The handle becomes invalid after this operation.
270
+ *
271
+ * @param handle - Connection handle from sftp_connect()
272
+ * @returns Null on success
273
+ *
274
+ * @throws {EastError} When handle is invalid (location: "sftp_close")
275
+ *
276
+ * @example
277
+ * ```ts
278
+ * import { East, NullType, variant } from "@elaraai/east";
279
+ * import { Transfer } from "@elaraai/east-node-io";
280
+ *
281
+ * const cleanup = East.function([], NullType, $ => {
282
+ * const config = $.let({
283
+ * host: "sftp.example.com",
284
+ * port: 22n,
285
+ * username: "user",
286
+ * password: variant('some', "password"),
287
+ * privateKey: variant('none', null),
288
+ * });
289
+ * const conn = $.let(Transfer.SFTP.connect(config));
290
+ * // ... do work ...
291
+ * $(Transfer.SFTP.close(conn));
292
+ * return $.return(null);
293
+ * });
294
+ *
295
+ * const compiled = East.compileAsync(cleanup.toIR(), Transfer.SFTP.Implementation);
296
+ * await compiled();
297
+ * ```
298
+ */
299
+ export declare const sftp_close: import("@elaraai/east").AsyncPlatformDefinition<[StringType], NullType>;
300
+ /**
301
+ * Closes all SFTP connections.
302
+ *
303
+ * Closes all active SFTP connections and releases all resources.
304
+ * Useful for test cleanup to ensure all connections are closed.
305
+ *
306
+ * @returns Null on success
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * import { East, NullType } from "@elaraai/east";
311
+ * import { Transfer } from "@elaraai/east-node-io";
312
+ *
313
+ * const cleanupAll = East.function([], NullType, $ => {
314
+ * // ... test code that may have left connections open ...
315
+ * $(Transfer.SFTP.closeAll());
316
+ * return $.return(null);
317
+ * });
318
+ *
319
+ * const compiled = East.compileAsync(cleanupAll.toIR(), Transfer.SFTP.Implementation);
320
+ * await compiled();
321
+ * ```
322
+ *
323
+ * @internal
324
+ */
325
+ export declare const sftp_close_all: import("@elaraai/east").AsyncPlatformDefinition<[], NullType>;
326
+ /**
327
+ * Node.js implementation of SFTP platform functions.
328
+ *
329
+ * Provides the runtime implementations for SFTP operations using ssh2-sftp-client.
330
+ * Pass this to East.compileAsync() to enable SFTP functionality.
331
+ */
332
+ export declare const SftpImpl: PlatformFunction[];
333
+ //# sourceMappingURL=sftp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sftp.d.ts","sourceRoot":"","sources":["../../src/transfer/sftp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAQ,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAK/D,OAAO,EAAwC,UAAU,EAAgB,MAAM,YAAY,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,YAAY;;;;;;gBAA6E,CAAC;AAEvG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,eAAO,MAAM,QAAQ,+FAAyF,CAAC;AAE/G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,QAAQ,qFAA+E,CAAC;AAErG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,SAAS;;;;;;IAA+F,CAAC;AAEtH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,WAAW,qFAAkF,CAAC;AAE3G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,UAAU,yEAAqE,CAAC;AAE7F;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,cAAc,+DAAqD,CAAC;AAEjF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,gBAAgB,EAuItC,CAAC"}