@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
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
* East Node IO - I/O platform functions for the East language on Node.js
|
|
7
|
+
*
|
|
8
|
+
* Provides type-safe I/O operations for East programs including:
|
|
9
|
+
* - SQL databases (SQLite, PostgreSQL, MySQL)
|
|
10
|
+
* - Cloud storage (S3)
|
|
11
|
+
* - File transfer (FTP, SFTP)
|
|
12
|
+
* - NoSQL databases (Redis, MongoDB)
|
|
13
|
+
* - File formats (XLSX/Excel, CSV, XML)
|
|
14
|
+
* - Compression (gzip, zip, tar)
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
// Export SQL modules
|
|
19
|
+
export * from "./sql/index.js";
|
|
20
|
+
// Export Storage modules
|
|
21
|
+
export * from "./storage/index.js";
|
|
22
|
+
// Export Transfer modules
|
|
23
|
+
export * from "./transfer/index.js";
|
|
24
|
+
// Export NoSQL modules
|
|
25
|
+
export * from "./nosql/index.js";
|
|
26
|
+
// Export Format modules
|
|
27
|
+
export * from "./format/index.js";
|
|
28
|
+
// Export Compression modules
|
|
29
|
+
export * from "./compression/index.js";
|
|
30
|
+
// Re-export all exports as a nested EastNodeIO namespace (matching East.East pattern)
|
|
31
|
+
export * as EastNodeIO from './index.js';
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAEH,qBAAqB;AACrB,cAAc,gBAAgB,CAAC;AAE/B,yBAAyB;AACzB,cAAc,oBAAoB,CAAC;AAEnC,0BAA0B;AAC1B,cAAc,qBAAqB,CAAC;AAEpC,uBAAuB;AACvB,cAAc,kBAAkB,CAAC;AAEjC,wBAAwB;AACxB,cAAc,mBAAmB,CAAC;AAElC,6BAA6B;AAC7B,cAAc,wBAAwB,CAAC;AAEvC,sFAAsF;AACtF,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,503 @@
|
|
|
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
|
+
* NoSQL database platform functions.
|
|
7
|
+
*
|
|
8
|
+
* Provides Redis and MongoDB operations for East programs,
|
|
9
|
+
* supporting caching and document storage use cases.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
export * from "./redis.js";
|
|
14
|
+
export * from "./mongodb.js";
|
|
15
|
+
export { RedisConfigType, MongoConfigType, BsonValueType, MongoFindOptionsType } from "./types.js";
|
|
16
|
+
/**
|
|
17
|
+
* NoSQL database platform functions.
|
|
18
|
+
*
|
|
19
|
+
* Provides Redis and MongoDB operations for East programs with type-safe
|
|
20
|
+
* caching and document storage capabilities.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { East, StringType, OptionType, variant } from "@elaraai/east";
|
|
25
|
+
* import { NoSQL } from "@elaraai/east-node-io";
|
|
26
|
+
*
|
|
27
|
+
* const cacheExample = East.function([StringType], OptionType(StringType), ($, key) => {
|
|
28
|
+
* const config = $.let({
|
|
29
|
+
* host: "localhost",
|
|
30
|
+
* port: 6379n,
|
|
31
|
+
* password: variant('none', null),
|
|
32
|
+
* db: variant('none', null),
|
|
33
|
+
* keyPrefix: variant('none', null),
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* const conn = $.let(NoSQL.Redis.connect(config));
|
|
37
|
+
* const value = $.let(NoSQL.Redis.get(conn, key));
|
|
38
|
+
* $(NoSQL.Redis.close(conn));
|
|
39
|
+
*
|
|
40
|
+
* $.return(value);
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // All NoSQL operations are async
|
|
44
|
+
* const compiled = East.compileAsync(cacheExample.toIR(), NoSQL.Redis.Implementation);
|
|
45
|
+
* await compiled("user:42");
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const NoSQL: {
|
|
49
|
+
/**
|
|
50
|
+
* Redis key-value store operations.
|
|
51
|
+
*
|
|
52
|
+
* Provides platform functions for Redis caching and data storage,
|
|
53
|
+
* supporting get, set, delete, and expiration operations.
|
|
54
|
+
*/
|
|
55
|
+
readonly Redis: {
|
|
56
|
+
/**
|
|
57
|
+
* Connects to a Redis server.
|
|
58
|
+
*
|
|
59
|
+
* Creates a connection to a Redis server and returns an
|
|
60
|
+
* opaque handle for use in key-value operations.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const getValue = East.function([StringType], OptionType(StringType), ($, key) => {
|
|
65
|
+
* const config = $.let({
|
|
66
|
+
* host: "localhost",
|
|
67
|
+
* port: 6379n,
|
|
68
|
+
* password: variant('none', null),
|
|
69
|
+
* db: variant('none', null),
|
|
70
|
+
* keyPrefix: variant('none', null),
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* const conn = $.let(NoSQL.Redis.connect(config));
|
|
74
|
+
* const value = $.let(NoSQL.Redis.get(conn, key));
|
|
75
|
+
* $(NoSQL.Redis.close(conn));
|
|
76
|
+
* $.return(value);
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* const compiled = East.compileAsync(getValue.toIR(), NoSQL.Redis.Implementation);
|
|
80
|
+
* await compiled("user:42"); // Some("Alice") or None
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
readonly connect: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StructType<{
|
|
84
|
+
host: import("@elaraai/east").StringType;
|
|
85
|
+
port: import("@elaraai/east").IntegerType;
|
|
86
|
+
password: import("@elaraai/east").OptionType<import("@elaraai/east").StringType>;
|
|
87
|
+
db: import("@elaraai/east").OptionType<import("@elaraai/east").IntegerType>;
|
|
88
|
+
keyPrefix: import("@elaraai/east").OptionType<import("@elaraai/east").StringType>;
|
|
89
|
+
}>], import("@elaraai/east").StringType>;
|
|
90
|
+
/**
|
|
91
|
+
* Gets a value by key from Redis.
|
|
92
|
+
*
|
|
93
|
+
* Retrieves the string value associated with the given key.
|
|
94
|
+
* Returns None if the key doesn't exist.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* const getValue = East.function([StringType], OptionType(StringType), ($, key) => {
|
|
99
|
+
* const config = $.let({
|
|
100
|
+
* host: "localhost",
|
|
101
|
+
* port: 6379n,
|
|
102
|
+
* password: variant('none', null),
|
|
103
|
+
* db: variant('none', null),
|
|
104
|
+
* keyPrefix: variant('none', null),
|
|
105
|
+
* });
|
|
106
|
+
* const conn = $.let(NoSQL.Redis.connect(config));
|
|
107
|
+
* const value = $.let(NoSQL.Redis.get(conn, key));
|
|
108
|
+
* $(NoSQL.Redis.close(conn));
|
|
109
|
+
* $.return(value);
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* const compiled = East.compileAsync(getValue.toIR(), NoSQL.Redis.Implementation);
|
|
113
|
+
* await compiled("user:42"); // variant('some', "Alice") or variant('none', null)
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
readonly get: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StringType, import("@elaraai/east").StringType], import("@elaraai/east").OptionType<import("@elaraai/east").StringType>>;
|
|
117
|
+
/**
|
|
118
|
+
* Sets a key-value pair in Redis.
|
|
119
|
+
*
|
|
120
|
+
* Stores a string value associated with the given key.
|
|
121
|
+
* Overwrites existing values.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* const setValue = East.function([StringType, StringType], NullType, ($, key, value) => {
|
|
126
|
+
* const config = $.let({
|
|
127
|
+
* host: "localhost",
|
|
128
|
+
* port: 6379n,
|
|
129
|
+
* password: variant('none', null),
|
|
130
|
+
* db: variant('none', null),
|
|
131
|
+
* keyPrefix: variant('none', null),
|
|
132
|
+
* });
|
|
133
|
+
* const conn = $.let(NoSQL.Redis.connect(config));
|
|
134
|
+
* $(NoSQL.Redis.set(conn, key, value));
|
|
135
|
+
* $(NoSQL.Redis.close(conn));
|
|
136
|
+
* $.return(null);
|
|
137
|
+
* });
|
|
138
|
+
*
|
|
139
|
+
* const compiled = East.compileAsync(setValue.toIR(), NoSQL.Redis.Implementation);
|
|
140
|
+
* await compiled("user:42", "Alice");
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
readonly set: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StringType, import("@elaraai/east").StringType, import("@elaraai/east").StringType], import("@elaraai/east").NullType>;
|
|
144
|
+
/**
|
|
145
|
+
* Sets a key-value pair with expiration in Redis.
|
|
146
|
+
*
|
|
147
|
+
* Stores a string value with a TTL (time-to-live) in seconds.
|
|
148
|
+
* The key will automatically expire after the specified duration.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* const setSession = East.function([StringType, StringType], NullType, ($, sessionId, data) => {
|
|
153
|
+
* const config = $.let({
|
|
154
|
+
* host: "localhost",
|
|
155
|
+
* port: 6379n,
|
|
156
|
+
* password: variant('none', null),
|
|
157
|
+
* db: variant('none', null),
|
|
158
|
+
* keyPrefix: variant('none', null),
|
|
159
|
+
* });
|
|
160
|
+
* const conn = $.let(NoSQL.Redis.connect(config));
|
|
161
|
+
* $(NoSQL.Redis.setex(conn, sessionId, data, 3600n)); // 1 hour TTL
|
|
162
|
+
* $(NoSQL.Redis.close(conn));
|
|
163
|
+
* $.return(null);
|
|
164
|
+
* });
|
|
165
|
+
*
|
|
166
|
+
* const compiled = East.compileAsync(setSession.toIR(), NoSQL.Redis.Implementation);
|
|
167
|
+
* await compiled("session:xyz", "user_data");
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
readonly setex: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StringType, import("@elaraai/east").StringType, import("@elaraai/east").StringType, import("@elaraai/east").IntegerType], import("@elaraai/east").NullType>;
|
|
171
|
+
/**
|
|
172
|
+
* Deletes a key from Redis.
|
|
173
|
+
*
|
|
174
|
+
* Removes the key and its associated value from Redis.
|
|
175
|
+
* Returns the number of keys deleted (0 or 1).
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* const deleteKey = East.function([StringType], IntegerType, ($, key) => {
|
|
180
|
+
* const config = $.let({
|
|
181
|
+
* host: "localhost",
|
|
182
|
+
* port: 6379n,
|
|
183
|
+
* password: variant('none', null),
|
|
184
|
+
* db: variant('none', null),
|
|
185
|
+
* keyPrefix: variant('none', null),
|
|
186
|
+
* });
|
|
187
|
+
* const conn = $.let(NoSQL.Redis.connect(config));
|
|
188
|
+
* const deleted = $.let(NoSQL.Redis.delete(conn, key));
|
|
189
|
+
* $(NoSQL.Redis.close(conn));
|
|
190
|
+
* $.return(deleted);
|
|
191
|
+
* });
|
|
192
|
+
*
|
|
193
|
+
* const compiled = East.compileAsync(deleteKey.toIR(), NoSQL.Redis.Implementation);
|
|
194
|
+
* await compiled("user:42"); // 1n (deleted) or 0n (not found)
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
readonly delete: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StringType, import("@elaraai/east").StringType], import("@elaraai/east").IntegerType>;
|
|
198
|
+
/**
|
|
199
|
+
* Closes the Redis connection.
|
|
200
|
+
*
|
|
201
|
+
* Closes the connection and releases all resources.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* const cleanup = East.function([], NullType, $ => {
|
|
206
|
+
* const config = $.let({
|
|
207
|
+
* host: "localhost",
|
|
208
|
+
* port: 6379n,
|
|
209
|
+
* password: variant('none', null),
|
|
210
|
+
* db: variant('none', null),
|
|
211
|
+
* keyPrefix: variant('none', null),
|
|
212
|
+
* });
|
|
213
|
+
* const conn = $.let(NoSQL.Redis.connect(config));
|
|
214
|
+
* // ... do work ...
|
|
215
|
+
* $(NoSQL.Redis.close(conn));
|
|
216
|
+
* });
|
|
217
|
+
*
|
|
218
|
+
* const compiled = East.compileAsync(cleanup.toIR(), NoSQL.Redis.Implementation);
|
|
219
|
+
* await compiled();
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
readonly close: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StringType], import("@elaraai/east").NullType>;
|
|
223
|
+
/**
|
|
224
|
+
* Closes all Redis connections.
|
|
225
|
+
*
|
|
226
|
+
* Closes all active Redis connections and releases all resources.
|
|
227
|
+
* Useful for test cleanup to ensure all connections are closed.
|
|
228
|
+
*
|
|
229
|
+
* @returns Null on success
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* const cleanupAll = East.function([], NullType, $ => {
|
|
234
|
+
* // ... test code that may have left connections open ...
|
|
235
|
+
* $(NoSQL.Redis.closeAll());
|
|
236
|
+
* return $.return(null);
|
|
237
|
+
* });
|
|
238
|
+
*
|
|
239
|
+
* const compiled = East.compileAsync(cleanupAll.toIR(), NoSQL.Redis.Implementation);
|
|
240
|
+
* await compiled();
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @internal
|
|
244
|
+
*/
|
|
245
|
+
readonly closeAll: import("@elaraai/east").AsyncPlatformDefinition<[], import("@elaraai/east").NullType>;
|
|
246
|
+
/**
|
|
247
|
+
* Node.js implementation of Redis platform functions.
|
|
248
|
+
*
|
|
249
|
+
* Pass this to East.compileAsync() to enable Redis operations.
|
|
250
|
+
*/
|
|
251
|
+
readonly Implementation: import("@elaraai/east/internal").PlatformFunction[];
|
|
252
|
+
/**
|
|
253
|
+
* Type definitions for Redis operations.
|
|
254
|
+
*/
|
|
255
|
+
readonly Types: {
|
|
256
|
+
/**
|
|
257
|
+
* Redis connection configuration type.
|
|
258
|
+
*/
|
|
259
|
+
readonly Config: import("@elaraai/east").StructType<{
|
|
260
|
+
host: import("@elaraai/east").StringType;
|
|
261
|
+
port: import("@elaraai/east").IntegerType;
|
|
262
|
+
password: import("@elaraai/east").OptionType<import("@elaraai/east").StringType>;
|
|
263
|
+
db: import("@elaraai/east").OptionType<import("@elaraai/east").IntegerType>;
|
|
264
|
+
keyPrefix: import("@elaraai/east").OptionType<import("@elaraai/east").StringType>;
|
|
265
|
+
}>;
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* MongoDB document database operations.
|
|
270
|
+
*
|
|
271
|
+
* Provides platform functions for MongoDB document storage,
|
|
272
|
+
* supporting find, insert, update, and delete operations.
|
|
273
|
+
*/
|
|
274
|
+
readonly MongoDB: {
|
|
275
|
+
/**
|
|
276
|
+
* Connects to a MongoDB server.
|
|
277
|
+
*
|
|
278
|
+
* Creates a connection to a MongoDB database and returns an
|
|
279
|
+
* opaque handle for use in document operations.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* const findUser = East.function([StringType], OptionType(BsonDocumentType), ($, username) => {
|
|
284
|
+
* const config = $.let({
|
|
285
|
+
* uri: "mongodb://localhost:27017",
|
|
286
|
+
* database: "myapp",
|
|
287
|
+
* collection: "users",
|
|
288
|
+
* });
|
|
289
|
+
*
|
|
290
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
291
|
+
* const query = $.let(new Map([["username", variant('String', username)]]), BsonDocumentType);
|
|
292
|
+
* const result = $.let(NoSQL.MongoDB.findOne(conn, query));
|
|
293
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
294
|
+
* $.return(result);
|
|
295
|
+
* });
|
|
296
|
+
*
|
|
297
|
+
* const compiled = East.compileAsync(findUser.toIR(), NoSQL.MongoDB.Implementation);
|
|
298
|
+
* await compiled("alice"); // variant('some', document) or variant('none', null)
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
readonly connect: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StructType<{
|
|
302
|
+
uri: import("@elaraai/east").StringType;
|
|
303
|
+
database: import("@elaraai/east").StringType;
|
|
304
|
+
collection: import("@elaraai/east").StringType;
|
|
305
|
+
}>], import("@elaraai/east").StringType>;
|
|
306
|
+
/**
|
|
307
|
+
* Finds a single document in MongoDB.
|
|
308
|
+
*
|
|
309
|
+
* Searches for a document matching the query object.
|
|
310
|
+
* Returns None if no document is found.
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```ts
|
|
314
|
+
* const findUser = East.function([StringType], OptionType(BsonDocumentType), ($, username) => {
|
|
315
|
+
* const config = $.let({
|
|
316
|
+
* uri: "mongodb://localhost:27017",
|
|
317
|
+
* database: "myapp",
|
|
318
|
+
* collection: "users",
|
|
319
|
+
* });
|
|
320
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
321
|
+
* const query = $.let(new Map([["username", variant('String', username)]]), BsonDocumentType);
|
|
322
|
+
* const result = $.let(NoSQL.MongoDB.findOne(conn, query));
|
|
323
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
324
|
+
* $.return(result);
|
|
325
|
+
* });
|
|
326
|
+
*
|
|
327
|
+
* const compiled = East.compileAsync(findUser.toIR(), NoSQL.MongoDB.Implementation);
|
|
328
|
+
* await compiled("alice"); // variant('some', document) or variant('none', null)
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
readonly findOne: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StringType, import("@elaraai/east").DictType<import("@elaraai/east").StringType, import("@elaraai/east").RecursiveType<import("@elaraai/east").EastType>>], import("@elaraai/east").OptionType<import("@elaraai/east").DictType<import("@elaraai/east").StringType, import("@elaraai/east").RecursiveType<import("@elaraai/east").EastType>>>>;
|
|
332
|
+
/**
|
|
333
|
+
* Finds multiple documents in MongoDB.
|
|
334
|
+
*
|
|
335
|
+
* Searches for documents matching the query object with optional
|
|
336
|
+
* limit and skip for pagination.
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```ts
|
|
340
|
+
* const findUsers = East.function([], ArrayType(BsonDocumentType), $ => {
|
|
341
|
+
* const config = $.let({
|
|
342
|
+
* uri: "mongodb://localhost:27017",
|
|
343
|
+
* database: "myapp",
|
|
344
|
+
* collection: "users",
|
|
345
|
+
* });
|
|
346
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
347
|
+
* const query = $.let(new Map(), BsonDocumentType);
|
|
348
|
+
* const options = $.let({ limit: variant('some',10n), skip: variant('none', null) });
|
|
349
|
+
* const result = $.let(NoSQL.MongoDB.findMany(conn, query, options));
|
|
350
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
351
|
+
* $.return(result);
|
|
352
|
+
* });
|
|
353
|
+
*
|
|
354
|
+
* const compiled = East.compileAsync(findUsers.toIR(), NoSQL.MongoDB.Implementation);
|
|
355
|
+
* await compiled(); // [doc1, doc2, ...]
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
readonly findMany: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StringType, import("@elaraai/east").DictType<import("@elaraai/east").StringType, import("@elaraai/east").RecursiveType<import("@elaraai/east").EastType>>, import("@elaraai/east").StructType<{
|
|
359
|
+
limit: import("@elaraai/east").OptionType<import("@elaraai/east").IntegerType>;
|
|
360
|
+
skip: import("@elaraai/east").OptionType<import("@elaraai/east").IntegerType>;
|
|
361
|
+
}>], import("@elaraai/east").ArrayType<import("@elaraai/east").DictType<import("@elaraai/east").StringType, import("@elaraai/east").RecursiveType<import("@elaraai/east").EastType>>>>;
|
|
362
|
+
/**
|
|
363
|
+
* Inserts a document into MongoDB.
|
|
364
|
+
*
|
|
365
|
+
* Inserts a new document into the collection.
|
|
366
|
+
* Returns the inserted document's _id as a string.
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```ts
|
|
370
|
+
* const createUser = East.function([StringType, StringType], StringType, ($, username, email) => {
|
|
371
|
+
* const config = $.let({
|
|
372
|
+
* uri: "mongodb://localhost:27017",
|
|
373
|
+
* database: "myapp",
|
|
374
|
+
* collection: "users",
|
|
375
|
+
* });
|
|
376
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
377
|
+
* const doc = $.let(new Map([
|
|
378
|
+
* ["username", variant('String', username)],
|
|
379
|
+
* ["email", variant('String', email)],
|
|
380
|
+
* ]), BsonDocumentType);
|
|
381
|
+
* const id = $.let(NoSQL.MongoDB.insertOne(conn, doc));
|
|
382
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
383
|
+
* $.return(id);
|
|
384
|
+
* });
|
|
385
|
+
*
|
|
386
|
+
* const compiled = East.compileAsync(createUser.toIR(), NoSQL.MongoDB.Implementation);
|
|
387
|
+
* await compiled("alice", "alice@example.com"); // "507f1f77bcf86cd799439011"
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
readonly insertOne: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StringType, import("@elaraai/east").DictType<import("@elaraai/east").StringType, import("@elaraai/east").RecursiveType<import("@elaraai/east").EastType>>], import("@elaraai/east").StringType>;
|
|
391
|
+
/**
|
|
392
|
+
* Updates a document in MongoDB.
|
|
393
|
+
*
|
|
394
|
+
* Updates a single document matching the query with the update operations.
|
|
395
|
+
* Returns the number of documents modified (0 or 1).
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```ts
|
|
399
|
+
* const updateUser = East.function([StringType, StringType], IntegerType, ($, username, newEmail) => {
|
|
400
|
+
* const config = $.let({
|
|
401
|
+
* uri: "mongodb://localhost:27017",
|
|
402
|
+
* database: "myapp",
|
|
403
|
+
* collection: "users",
|
|
404
|
+
* });
|
|
405
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
406
|
+
* const query = $.let(new Map([["username", variant('String', username)]]), BsonDocumentType);
|
|
407
|
+
* const update = $.let(new Map([["email", variant('String', newEmail)]]), BsonDocumentType);
|
|
408
|
+
* const modified = $.let(NoSQL.MongoDB.updateOne(conn, query, update));
|
|
409
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
410
|
+
* $.return(modified);
|
|
411
|
+
* });
|
|
412
|
+
*
|
|
413
|
+
* const compiled = East.compileAsync(updateUser.toIR(), NoSQL.MongoDB.Implementation);
|
|
414
|
+
* await compiled("alice", "newemail@example.com"); // 1n (updated) or 0n (not found)
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
readonly updateOne: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StringType, import("@elaraai/east").DictType<import("@elaraai/east").StringType, import("@elaraai/east").RecursiveType<import("@elaraai/east").EastType>>, import("@elaraai/east").DictType<import("@elaraai/east").StringType, import("@elaraai/east").RecursiveType<import("@elaraai/east").EastType>>], import("@elaraai/east").IntegerType>;
|
|
418
|
+
/**
|
|
419
|
+
* Deletes a document from MongoDB.
|
|
420
|
+
*
|
|
421
|
+
* Deletes a single document matching the query object.
|
|
422
|
+
* Returns the number of documents deleted (0 or 1).
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```ts
|
|
426
|
+
* const deleteUser = East.function([StringType], IntegerType, ($, username) => {
|
|
427
|
+
* const config = $.let({
|
|
428
|
+
* uri: "mongodb://localhost:27017",
|
|
429
|
+
* database: "myapp",
|
|
430
|
+
* collection: "users",
|
|
431
|
+
* });
|
|
432
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
433
|
+
* const query = $.let(new Map([["username", variant('String', username)]]), BsonDocumentType);
|
|
434
|
+
* const deleted = $.let(NoSQL.MongoDB.deleteOne(conn, query));
|
|
435
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
436
|
+
* $.return(deleted);
|
|
437
|
+
* });
|
|
438
|
+
*
|
|
439
|
+
* const compiled = East.compileAsync(deleteUser.toIR(), NoSQL.MongoDB.Implementation);
|
|
440
|
+
* await compiled("alice"); // 1n (deleted) or 0n (not found)
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
readonly deleteOne: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StringType, import("@elaraai/east").DictType<import("@elaraai/east").StringType, import("@elaraai/east").RecursiveType<import("@elaraai/east").EastType>>], import("@elaraai/east").IntegerType>;
|
|
444
|
+
/**
|
|
445
|
+
* Closes the MongoDB connection.
|
|
446
|
+
*
|
|
447
|
+
* Closes the connection and releases all resources.
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* ```ts
|
|
451
|
+
* const cleanup = East.function([], NullType, $ => {
|
|
452
|
+
* const config = $.let({
|
|
453
|
+
* uri: "mongodb://localhost:27017",
|
|
454
|
+
* database: "myapp",
|
|
455
|
+
* collection: "users",
|
|
456
|
+
* });
|
|
457
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
458
|
+
* // ... do work ...
|
|
459
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
460
|
+
* });
|
|
461
|
+
*
|
|
462
|
+
* const compiled = East.compileAsync(cleanup.toIR(), NoSQL.MongoDB.Implementation);
|
|
463
|
+
* await compiled();
|
|
464
|
+
* ```
|
|
465
|
+
*/
|
|
466
|
+
readonly close: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StringType], import("@elaraai/east").NullType>;
|
|
467
|
+
/**
|
|
468
|
+
* Node.js implementation of MongoDB platform functions.
|
|
469
|
+
*
|
|
470
|
+
* Pass this to East.compileAsync() to enable MongoDB operations.
|
|
471
|
+
*/
|
|
472
|
+
readonly Implementation: import("@elaraai/east/internal").PlatformFunction[];
|
|
473
|
+
/**
|
|
474
|
+
* Type definitions for MongoDB operations.
|
|
475
|
+
*/
|
|
476
|
+
readonly Types: {
|
|
477
|
+
/**
|
|
478
|
+
* MongoDB connection configuration type.
|
|
479
|
+
*/
|
|
480
|
+
readonly Config: import("@elaraai/east").StructType<{
|
|
481
|
+
uri: import("@elaraai/east").StringType;
|
|
482
|
+
database: import("@elaraai/east").StringType;
|
|
483
|
+
collection: import("@elaraai/east").StringType;
|
|
484
|
+
}>;
|
|
485
|
+
/**
|
|
486
|
+
* BSON value type (recursive type for MongoDB values).
|
|
487
|
+
*/
|
|
488
|
+
readonly BsonValue: import("@elaraai/east").RecursiveType<import("@elaraai/east").EastType>;
|
|
489
|
+
/**
|
|
490
|
+
* BSON document type (dictionary of string keys to BSON values).
|
|
491
|
+
*/
|
|
492
|
+
readonly BsonDocument: import("@elaraai/east").DictType<import("@elaraai/east").StringType, import("@elaraai/east").RecursiveType<import("@elaraai/east").EastType>>;
|
|
493
|
+
/**
|
|
494
|
+
* MongoDB find operation options type.
|
|
495
|
+
*/
|
|
496
|
+
readonly FindOptions: import("@elaraai/east").StructType<{
|
|
497
|
+
limit: import("@elaraai/east").OptionType<import("@elaraai/east").IntegerType>;
|
|
498
|
+
skip: import("@elaraai/east").OptionType<import("@elaraai/east").IntegerType>;
|
|
499
|
+
}>;
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
};
|
|
503
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nosql/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAGH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA0BnG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,KAAK;IACd;;;;;OAKG;;QAEC;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;;;;;;;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;;QAGH;;;;;;;;;;;;;;;;;;;;;;;WAuBG;;QAGH;;;;;;;;;;;;;;;;;;;;;WAqBG;;QAGH;;;;WAIG;;QAGH;;WAEG;;YAEC;;eAEG;;;;;;;;;;IAKX;;;;;OAKG;;QAEC;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;;;;;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;WAwBG;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;;;;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;WA2BG;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;WAwBG;;QAGH;;;;;;;;;;;;;;;;;;;;;WAqBG;;QAGH;;;;WAIG;;QAGH;;WAEG;;YAEC;;eAEG;;;;;;YAGH;;eAEG;;YAGH;;eAEG;;YAGH;;eAEG;;;;;;;CAIL,CAAC"}
|