@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.
- 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 +6 -6
|
@@ -0,0 +1,483 @@
|
|
|
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 individual modules
|
|
14
|
+
export * from "./redis.js";
|
|
15
|
+
export * from "./mongodb.js";
|
|
16
|
+
// Export public types (not ConnectionHandleType to avoid conflict with SQL module)
|
|
17
|
+
export { RedisConfigType, MongoConfigType, BsonValueType, MongoFindOptionsType } from "./types.js";
|
|
18
|
+
// Import for grouped exports
|
|
19
|
+
import { redis_connect, redis_get, redis_set, redis_setex, redis_del, redis_close, redis_close_all, RedisImpl } from "./redis.js";
|
|
20
|
+
import { mongodb_connect, mongodb_find_one, mongodb_find_many, mongodb_insert_one, mongodb_update_one, mongodb_delete_one, mongodb_close, BsonDocumentType, MongoDBImpl } from "./mongodb.js";
|
|
21
|
+
import { RedisConfigType, MongoConfigType, BsonValueType, MongoFindOptionsType } from "./types.js";
|
|
22
|
+
/**
|
|
23
|
+
* NoSQL database platform functions.
|
|
24
|
+
*
|
|
25
|
+
* Provides Redis and MongoDB operations for East programs with type-safe
|
|
26
|
+
* caching and document storage capabilities.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { East, StringType, OptionType, variant } from "@elaraai/east";
|
|
31
|
+
* import { NoSQL } from "@elaraai/east-node-io";
|
|
32
|
+
*
|
|
33
|
+
* const cacheExample = East.function([StringType], OptionType(StringType), ($, key) => {
|
|
34
|
+
* const config = $.let({
|
|
35
|
+
* host: "localhost",
|
|
36
|
+
* port: 6379n,
|
|
37
|
+
* password: variant('none', null),
|
|
38
|
+
* db: variant('none', null),
|
|
39
|
+
* keyPrefix: variant('none', null),
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* const conn = $.let(NoSQL.Redis.connect(config));
|
|
43
|
+
* const value = $.let(NoSQL.Redis.get(conn, key));
|
|
44
|
+
* $(NoSQL.Redis.close(conn));
|
|
45
|
+
*
|
|
46
|
+
* $.return(value);
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // All NoSQL operations are async
|
|
50
|
+
* const compiled = East.compileAsync(cacheExample.toIR(), NoSQL.Redis.Implementation);
|
|
51
|
+
* await compiled("user:42");
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export const NoSQL = {
|
|
55
|
+
/**
|
|
56
|
+
* Redis key-value store operations.
|
|
57
|
+
*
|
|
58
|
+
* Provides platform functions for Redis caching and data storage,
|
|
59
|
+
* supporting get, set, delete, and expiration operations.
|
|
60
|
+
*/
|
|
61
|
+
Redis: {
|
|
62
|
+
/**
|
|
63
|
+
* Connects to a Redis server.
|
|
64
|
+
*
|
|
65
|
+
* Creates a connection to a Redis server and returns an
|
|
66
|
+
* opaque handle for use in key-value operations.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const getValue = East.function([StringType], OptionType(StringType), ($, key) => {
|
|
71
|
+
* const config = $.let({
|
|
72
|
+
* host: "localhost",
|
|
73
|
+
* port: 6379n,
|
|
74
|
+
* password: variant('none', null),
|
|
75
|
+
* db: variant('none', null),
|
|
76
|
+
* keyPrefix: variant('none', null),
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* const conn = $.let(NoSQL.Redis.connect(config));
|
|
80
|
+
* const value = $.let(NoSQL.Redis.get(conn, key));
|
|
81
|
+
* $(NoSQL.Redis.close(conn));
|
|
82
|
+
* $.return(value);
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* const compiled = East.compileAsync(getValue.toIR(), NoSQL.Redis.Implementation);
|
|
86
|
+
* await compiled("user:42"); // Some("Alice") or None
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
connect: redis_connect,
|
|
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
|
+
get: redis_get,
|
|
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
|
+
set: redis_set,
|
|
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
|
+
setex: redis_setex,
|
|
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
|
+
delete: redis_del,
|
|
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
|
+
close: redis_close,
|
|
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
|
+
closeAll: redis_close_all,
|
|
246
|
+
/**
|
|
247
|
+
* Node.js implementation of Redis platform functions.
|
|
248
|
+
*
|
|
249
|
+
* Pass this to East.compileAsync() to enable Redis operations.
|
|
250
|
+
*/
|
|
251
|
+
Implementation: RedisImpl,
|
|
252
|
+
/**
|
|
253
|
+
* Type definitions for Redis operations.
|
|
254
|
+
*/
|
|
255
|
+
Types: {
|
|
256
|
+
/**
|
|
257
|
+
* Redis connection configuration type.
|
|
258
|
+
*/
|
|
259
|
+
Config: RedisConfigType,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
/**
|
|
263
|
+
* MongoDB document database operations.
|
|
264
|
+
*
|
|
265
|
+
* Provides platform functions for MongoDB document storage,
|
|
266
|
+
* supporting find, insert, update, and delete operations.
|
|
267
|
+
*/
|
|
268
|
+
MongoDB: {
|
|
269
|
+
/**
|
|
270
|
+
* Connects to a MongoDB server.
|
|
271
|
+
*
|
|
272
|
+
* Creates a connection to a MongoDB database and returns an
|
|
273
|
+
* opaque handle for use in document operations.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```ts
|
|
277
|
+
* const findUser = East.function([StringType], OptionType(BsonDocumentType), ($, username) => {
|
|
278
|
+
* const config = $.let({
|
|
279
|
+
* uri: "mongodb://localhost:27017",
|
|
280
|
+
* database: "myapp",
|
|
281
|
+
* collection: "users",
|
|
282
|
+
* });
|
|
283
|
+
*
|
|
284
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
285
|
+
* const query = $.let(new Map([["username", variant('String', username)]]), BsonDocumentType);
|
|
286
|
+
* const result = $.let(NoSQL.MongoDB.findOne(conn, query));
|
|
287
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
288
|
+
* $.return(result);
|
|
289
|
+
* });
|
|
290
|
+
*
|
|
291
|
+
* const compiled = East.compileAsync(findUser.toIR(), NoSQL.MongoDB.Implementation);
|
|
292
|
+
* await compiled("alice"); // variant('some', document) or variant('none', null)
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
connect: mongodb_connect,
|
|
296
|
+
/**
|
|
297
|
+
* Finds a single document in MongoDB.
|
|
298
|
+
*
|
|
299
|
+
* Searches for a document matching the query object.
|
|
300
|
+
* Returns None if no document is found.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* const findUser = East.function([StringType], OptionType(BsonDocumentType), ($, username) => {
|
|
305
|
+
* const config = $.let({
|
|
306
|
+
* uri: "mongodb://localhost:27017",
|
|
307
|
+
* database: "myapp",
|
|
308
|
+
* collection: "users",
|
|
309
|
+
* });
|
|
310
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
311
|
+
* const query = $.let(new Map([["username", variant('String', username)]]), BsonDocumentType);
|
|
312
|
+
* const result = $.let(NoSQL.MongoDB.findOne(conn, query));
|
|
313
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
314
|
+
* $.return(result);
|
|
315
|
+
* });
|
|
316
|
+
*
|
|
317
|
+
* const compiled = East.compileAsync(findUser.toIR(), NoSQL.MongoDB.Implementation);
|
|
318
|
+
* await compiled("alice"); // variant('some', document) or variant('none', null)
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
findOne: mongodb_find_one,
|
|
322
|
+
/**
|
|
323
|
+
* Finds multiple documents in MongoDB.
|
|
324
|
+
*
|
|
325
|
+
* Searches for documents matching the query object with optional
|
|
326
|
+
* limit and skip for pagination.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
* const findUsers = East.function([], ArrayType(BsonDocumentType), $ => {
|
|
331
|
+
* const config = $.let({
|
|
332
|
+
* uri: "mongodb://localhost:27017",
|
|
333
|
+
* database: "myapp",
|
|
334
|
+
* collection: "users",
|
|
335
|
+
* });
|
|
336
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
337
|
+
* const query = $.let(new Map(), BsonDocumentType);
|
|
338
|
+
* const options = $.let({ limit: variant('some',10n), skip: variant('none', null) });
|
|
339
|
+
* const result = $.let(NoSQL.MongoDB.findMany(conn, query, options));
|
|
340
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
341
|
+
* $.return(result);
|
|
342
|
+
* });
|
|
343
|
+
*
|
|
344
|
+
* const compiled = East.compileAsync(findUsers.toIR(), NoSQL.MongoDB.Implementation);
|
|
345
|
+
* await compiled(); // [doc1, doc2, ...]
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
findMany: mongodb_find_many,
|
|
349
|
+
/**
|
|
350
|
+
* Inserts a document into MongoDB.
|
|
351
|
+
*
|
|
352
|
+
* Inserts a new document into the collection.
|
|
353
|
+
* Returns the inserted document's _id as a string.
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```ts
|
|
357
|
+
* const createUser = East.function([StringType, StringType], StringType, ($, username, email) => {
|
|
358
|
+
* const config = $.let({
|
|
359
|
+
* uri: "mongodb://localhost:27017",
|
|
360
|
+
* database: "myapp",
|
|
361
|
+
* collection: "users",
|
|
362
|
+
* });
|
|
363
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
364
|
+
* const doc = $.let(new Map([
|
|
365
|
+
* ["username", variant('String', username)],
|
|
366
|
+
* ["email", variant('String', email)],
|
|
367
|
+
* ]), BsonDocumentType);
|
|
368
|
+
* const id = $.let(NoSQL.MongoDB.insertOne(conn, doc));
|
|
369
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
370
|
+
* $.return(id);
|
|
371
|
+
* });
|
|
372
|
+
*
|
|
373
|
+
* const compiled = East.compileAsync(createUser.toIR(), NoSQL.MongoDB.Implementation);
|
|
374
|
+
* await compiled("alice", "alice@example.com"); // "507f1f77bcf86cd799439011"
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
insertOne: mongodb_insert_one,
|
|
378
|
+
/**
|
|
379
|
+
* Updates a document in MongoDB.
|
|
380
|
+
*
|
|
381
|
+
* Updates a single document matching the query with the update operations.
|
|
382
|
+
* Returns the number of documents modified (0 or 1).
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```ts
|
|
386
|
+
* const updateUser = East.function([StringType, StringType], IntegerType, ($, username, newEmail) => {
|
|
387
|
+
* const config = $.let({
|
|
388
|
+
* uri: "mongodb://localhost:27017",
|
|
389
|
+
* database: "myapp",
|
|
390
|
+
* collection: "users",
|
|
391
|
+
* });
|
|
392
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
393
|
+
* const query = $.let(new Map([["username", variant('String', username)]]), BsonDocumentType);
|
|
394
|
+
* const update = $.let(new Map([["email", variant('String', newEmail)]]), BsonDocumentType);
|
|
395
|
+
* const modified = $.let(NoSQL.MongoDB.updateOne(conn, query, update));
|
|
396
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
397
|
+
* $.return(modified);
|
|
398
|
+
* });
|
|
399
|
+
*
|
|
400
|
+
* const compiled = East.compileAsync(updateUser.toIR(), NoSQL.MongoDB.Implementation);
|
|
401
|
+
* await compiled("alice", "newemail@example.com"); // 1n (updated) or 0n (not found)
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
updateOne: mongodb_update_one,
|
|
405
|
+
/**
|
|
406
|
+
* Deletes a document from MongoDB.
|
|
407
|
+
*
|
|
408
|
+
* Deletes a single document matching the query object.
|
|
409
|
+
* Returns the number of documents deleted (0 or 1).
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* ```ts
|
|
413
|
+
* const deleteUser = East.function([StringType], IntegerType, ($, username) => {
|
|
414
|
+
* const config = $.let({
|
|
415
|
+
* uri: "mongodb://localhost:27017",
|
|
416
|
+
* database: "myapp",
|
|
417
|
+
* collection: "users",
|
|
418
|
+
* });
|
|
419
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
420
|
+
* const query = $.let(new Map([["username", variant('String', username)]]), BsonDocumentType);
|
|
421
|
+
* const deleted = $.let(NoSQL.MongoDB.deleteOne(conn, query));
|
|
422
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
423
|
+
* $.return(deleted);
|
|
424
|
+
* });
|
|
425
|
+
*
|
|
426
|
+
* const compiled = East.compileAsync(deleteUser.toIR(), NoSQL.MongoDB.Implementation);
|
|
427
|
+
* await compiled("alice"); // 1n (deleted) or 0n (not found)
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
deleteOne: mongodb_delete_one,
|
|
431
|
+
/**
|
|
432
|
+
* Closes the MongoDB connection.
|
|
433
|
+
*
|
|
434
|
+
* Closes the connection and releases all resources.
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```ts
|
|
438
|
+
* const cleanup = East.function([], NullType, $ => {
|
|
439
|
+
* const config = $.let({
|
|
440
|
+
* uri: "mongodb://localhost:27017",
|
|
441
|
+
* database: "myapp",
|
|
442
|
+
* collection: "users",
|
|
443
|
+
* });
|
|
444
|
+
* const conn = $.let(NoSQL.MongoDB.connect(config));
|
|
445
|
+
* // ... do work ...
|
|
446
|
+
* $(NoSQL.MongoDB.close(conn));
|
|
447
|
+
* });
|
|
448
|
+
*
|
|
449
|
+
* const compiled = East.compileAsync(cleanup.toIR(), NoSQL.MongoDB.Implementation);
|
|
450
|
+
* await compiled();
|
|
451
|
+
* ```
|
|
452
|
+
*/
|
|
453
|
+
close: mongodb_close,
|
|
454
|
+
/**
|
|
455
|
+
* Node.js implementation of MongoDB platform functions.
|
|
456
|
+
*
|
|
457
|
+
* Pass this to East.compileAsync() to enable MongoDB operations.
|
|
458
|
+
*/
|
|
459
|
+
Implementation: MongoDBImpl,
|
|
460
|
+
/**
|
|
461
|
+
* Type definitions for MongoDB operations.
|
|
462
|
+
*/
|
|
463
|
+
Types: {
|
|
464
|
+
/**
|
|
465
|
+
* MongoDB connection configuration type.
|
|
466
|
+
*/
|
|
467
|
+
Config: MongoConfigType,
|
|
468
|
+
/**
|
|
469
|
+
* BSON value type (recursive type for MongoDB values).
|
|
470
|
+
*/
|
|
471
|
+
BsonValue: BsonValueType,
|
|
472
|
+
/**
|
|
473
|
+
* BSON document type (dictionary of string keys to BSON values).
|
|
474
|
+
*/
|
|
475
|
+
BsonDocument: BsonDocumentType,
|
|
476
|
+
/**
|
|
477
|
+
* MongoDB find operation options type.
|
|
478
|
+
*/
|
|
479
|
+
FindOptions: MongoFindOptionsType,
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nosql/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,4BAA4B;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAE7B,mFAAmF;AACnF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEnG,6BAA6B;AAC7B,OAAO,EACH,aAAa,EACb,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,eAAe,EACf,SAAS,EACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACH,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEnG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACjB;;;;;OAKG;IACH,KAAK,EAAE;QACH;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;QACH,OAAO,EAAE,aAAa;QAEtB;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;QACH,GAAG,EAAE,SAAS;QAEd;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;QACH,GAAG,EAAE,SAAS;QAEd;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;QACH,KAAK,EAAE,WAAW;QAElB;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;QACH,MAAM,EAAE,SAAS;QAEjB;;;;;;;;;;;;;;;;;;;;;;;WAuBG;QACH,KAAK,EAAE,WAAW;QAElB;;;;;;;;;;;;;;;;;;;;;WAqBG;QACH,QAAQ,EAAE,eAAe;QAEzB;;;;WAIG;QACH,cAAc,EAAE,SAAS;QAEzB;;WAEG;QACH,KAAK,EAAE;YACH;;eAEG;YACH,MAAM,EAAE,eAAe;SAC1B;KACJ;IAED;;;;;OAKG;IACH,OAAO,EAAE;QACL;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;QACH,OAAO,EAAE,eAAe;QAExB;;;;;;;;;;;;;;;;;;;;;;;;WAwBG;QACH,OAAO,EAAE,gBAAgB;QAEzB;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;QACH,QAAQ,EAAE,iBAAiB;QAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;WA2BG;QACH,SAAS,EAAE,kBAAkB;QAE7B;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;QACH,SAAS,EAAE,kBAAkB;QAE7B;;;;;;;;;;;;;;;;;;;;;;;;WAwBG;QACH,SAAS,EAAE,kBAAkB;QAE7B;;;;;;;;;;;;;;;;;;;;;WAqBG;QACH,KAAK,EAAE,aAAa;QAEpB;;;;WAIG;QACH,cAAc,EAAE,WAAW;QAE3B;;WAEG;QACH,KAAK,EAAE;YACH;;eAEG;YACH,MAAM,EAAE,eAAe;YAEvB;;eAEG;YACH,SAAS,EAAE,aAAa;YAExB;;eAEG;YACH,YAAY,EAAE,gBAAgB;YAE9B;;eAEG;YACH,WAAW,EAAE,oBAAoB;SACpC;KACJ;CACK,CAAC"}
|