@elaraai/east-node-io 0.0.1-beta.1 → 0.0.1-beta.10
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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sql/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAGH,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAkC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,GAAG;IACZ;;;;OAIG;;QAEC;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA4BG;;;;;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAGH;;;;;;;;;;;;;;;;;;;;;;WAsBG;;QAGH;;;;;;;;;;;;;;;;;;;;;WAqBG;;QAGH;;;;WAIG;;QAGH;;WAEG;;YAEC;;eAEG;;;;;;YAGH;;eAEG;;;;;;;;;;YAGH;;eAEG;;;;;;;;;;YAGH;;eAEG;;;;;;;;;;YAGH;;eAEG;;;;;;;;;;;;;;;;;;;;;;;;;;IAKX;;;;OAIG;;QAEC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAgCG;;;;;;;;;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA8BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;;QAGH;;;;;;;;;;;;;;;;;;;;;WAqBG;;QAGH;;;;WAIG;;QAGH;;WAEG;;YAEC;;eAEG;;;;;;;;;;YAGH;;eAEG;;;;;;;;;;YAGH;;eAEG;;;;;;;;;;YAGH;;eAEG;;;;;;;;;;YAGH;;eAEG;;;;;;;;;;;;;;;;;;;;;;;;;;IAKX;;;;OAIG;;QAEC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAgCG;;;;;;;;;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA8BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAGH;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;;QAGH;;;;;;;;;;;;;;;;;;;;;WAqBG;;QAGH;;;;WAIG;;QAGH;;WAEG;;YAEC;;eAEG;;;;;;;;;;YAGH;;eAEG;;;;;;;;;;YAGH;;eAEG;;;;;;;;;;YAGH;;eAEG;;;;;;;;;;YAGH;;eAEG;;;;;;;;;;;;;;;;;;;;;;;;;;CAIL,CAAC"}
|
|
@@ -0,0 +1,515 @@
|
|
|
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
|
+
* SQL database platform functions.
|
|
7
|
+
*
|
|
8
|
+
* Provides type-safe SQL database operations for East programs, supporting
|
|
9
|
+
* SQLite, PostgreSQL, and MySQL with connection pooling and parameterized queries.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
// Export individual modules
|
|
14
|
+
export * from "./sqlite.js";
|
|
15
|
+
export * from "./postgres.js";
|
|
16
|
+
export * from "./mysql.js";
|
|
17
|
+
export * from "./types.js";
|
|
18
|
+
// Import for grouped exports
|
|
19
|
+
import { sqlite_connect, sqlite_query, sqlite_close, sqlite_close_all, SqliteImpl } from "./sqlite.js";
|
|
20
|
+
import { postgres_connect, postgres_query, postgres_close, postgres_close_all, PostgresImpl } from "./postgres.js";
|
|
21
|
+
import { mysql_connect, mysql_query, mysql_close, mysql_close_all, MySqlImpl } from "./mysql.js";
|
|
22
|
+
import { SqliteConfigType, PostgresConfigType, MySqlConfigType, SqlParameterType, SqlParametersType, SqlRowType, SqlResultType } from "./types.js";
|
|
23
|
+
/**
|
|
24
|
+
* SQL database platform functions.
|
|
25
|
+
*
|
|
26
|
+
* Provides type-safe SQL database operations for East programs, supporting
|
|
27
|
+
* SQLite, PostgreSQL, and MySQL with connection pooling and parameterized queries.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { East, StringType, IntegerType, NullType, variant } from "@elaraai/east";
|
|
32
|
+
* import { SQL } from "@elaraai/east-node-io";
|
|
33
|
+
*
|
|
34
|
+
* const getUserName = East.function([IntegerType], NullType, ($, userId) => {
|
|
35
|
+
* const config = $.let({
|
|
36
|
+
* host: "localhost",
|
|
37
|
+
* port: 5432n,
|
|
38
|
+
* database: "myapp",
|
|
39
|
+
* user: "postgres",
|
|
40
|
+
* password: "secret",
|
|
41
|
+
* ssl: variant('none', null),
|
|
42
|
+
* maxConnections: variant('none', null),
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* const conn = $.let(SQL.Postgres.connect(config));
|
|
46
|
+
* $(SQL.Postgres.query(
|
|
47
|
+
* conn,
|
|
48
|
+
* "SELECT name FROM users WHERE id = $1",
|
|
49
|
+
* [variant('Integer', userId)]
|
|
50
|
+
* ));
|
|
51
|
+
* $(SQL.Postgres.close(conn));
|
|
52
|
+
* $.return(null);
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* // All SQL operations are async
|
|
56
|
+
* const compiled = East.compileAsync(getUserName.toIR(), SQL.Postgres.Implementation);
|
|
57
|
+
* await compiled(42n);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export const SQL = {
|
|
61
|
+
/**
|
|
62
|
+
* SQLite database operations.
|
|
63
|
+
*
|
|
64
|
+
* Provides platform functions for SQLite, a serverless embedded SQL database.
|
|
65
|
+
*/
|
|
66
|
+
SQLite: {
|
|
67
|
+
/**
|
|
68
|
+
* Opens a SQLite database connection.
|
|
69
|
+
*
|
|
70
|
+
* Creates a connection to a SQLite database file or in-memory database
|
|
71
|
+
* and returns an opaque handle for use in queries.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const getUser = East.function([IntegerType], NullType, ($, userId) => {
|
|
76
|
+
* const config = $.let({
|
|
77
|
+
* path: "./mydb.sqlite",
|
|
78
|
+
* readOnly: variant('none', null),
|
|
79
|
+
* memory: variant('none', null),
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* const conn = $.let(SQL.SQLite.connect(config));
|
|
83
|
+
* $(SQL.SQLite.query(
|
|
84
|
+
* conn,
|
|
85
|
+
* "SELECT name FROM users WHERE id = ?",
|
|
86
|
+
* [variant('Integer', userId)]
|
|
87
|
+
* ));
|
|
88
|
+
* $(SQL.SQLite.close(conn));
|
|
89
|
+
* $.return(null);
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* const compiled = East.compileAsync(getUser.toIR(), SQL.SQLite.Implementation);
|
|
93
|
+
* await compiled(42n);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
connect: sqlite_connect,
|
|
97
|
+
/**
|
|
98
|
+
* Executes a SQL query with parameters.
|
|
99
|
+
*
|
|
100
|
+
* Runs a SQL query with parameter binding using ? placeholders.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* const getUser = East.function([IntegerType], NullType, ($, userId) => {
|
|
105
|
+
* const config = $.let({
|
|
106
|
+
* path: "./mydb.sqlite",
|
|
107
|
+
* readOnly: variant('none', null),
|
|
108
|
+
* memory: variant('none', null),
|
|
109
|
+
* });
|
|
110
|
+
* const conn = $.let(SQL.SQLite.connect(config));
|
|
111
|
+
* $(SQL.SQLite.query(
|
|
112
|
+
* conn,
|
|
113
|
+
* "SELECT name FROM users WHERE id = ?",
|
|
114
|
+
* [variant('Integer', userId)]
|
|
115
|
+
* ));
|
|
116
|
+
* $(SQL.SQLite.close(conn));
|
|
117
|
+
* $.return(null);
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* const compiled = East.compileAsync(getUser.toIR(), SQL.SQLite.Implementation);
|
|
121
|
+
* await compiled(42n);
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
query: sqlite_query,
|
|
125
|
+
/**
|
|
126
|
+
* Closes the SQLite database connection.
|
|
127
|
+
*
|
|
128
|
+
* Releases all resources associated with the connection.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* const cleanup = East.function([], NullType, $ => {
|
|
133
|
+
* const config = $.let({
|
|
134
|
+
* path: "./mydb.sqlite",
|
|
135
|
+
* readOnly: variant('none', null),
|
|
136
|
+
* memory: variant('none', null),
|
|
137
|
+
* });
|
|
138
|
+
* const conn = $.let(SQL.SQLite.connect(config));
|
|
139
|
+
* // ... do work ...
|
|
140
|
+
* $(SQL.SQLite.close(conn));
|
|
141
|
+
* $.return(null);
|
|
142
|
+
* });
|
|
143
|
+
*
|
|
144
|
+
* const compiled = East.compileAsync(cleanup.toIR(), SQL.SQLite.Implementation);
|
|
145
|
+
* await compiled();
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
close: sqlite_close,
|
|
149
|
+
/**
|
|
150
|
+
* Closes all SQLite connections.
|
|
151
|
+
*
|
|
152
|
+
* Closes all active SQLite connections and releases all resources.
|
|
153
|
+
* Useful for test cleanup to ensure all connections are closed.
|
|
154
|
+
*
|
|
155
|
+
* @returns Null on success
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* const cleanupAll = East.function([], NullType, $ => {
|
|
160
|
+
* // ... test code that may have left connections open ...
|
|
161
|
+
* $(SQL.SQLite.closeAll());
|
|
162
|
+
* return $.return(null);
|
|
163
|
+
* });
|
|
164
|
+
*
|
|
165
|
+
* const compiled = East.compileAsync(cleanupAll.toIR(), SQL.SQLite.Implementation);
|
|
166
|
+
* await compiled();
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @internal
|
|
170
|
+
*/
|
|
171
|
+
closeAll: sqlite_close_all,
|
|
172
|
+
/**
|
|
173
|
+
* Node.js implementation of SQLite platform functions.
|
|
174
|
+
*
|
|
175
|
+
* Pass this to East.compileAsync() to enable SQLite operations.
|
|
176
|
+
*/
|
|
177
|
+
Implementation: SqliteImpl,
|
|
178
|
+
/**
|
|
179
|
+
* Type definitions for SQLite operations.
|
|
180
|
+
*/
|
|
181
|
+
Types: {
|
|
182
|
+
/**
|
|
183
|
+
* SQLite connection configuration type.
|
|
184
|
+
*/
|
|
185
|
+
Config: SqliteConfigType,
|
|
186
|
+
/**
|
|
187
|
+
* SQL query parameter value type.
|
|
188
|
+
*/
|
|
189
|
+
Parameter: SqlParameterType,
|
|
190
|
+
/**
|
|
191
|
+
* Array of SQL query parameters.
|
|
192
|
+
*/
|
|
193
|
+
Parameters: SqlParametersType,
|
|
194
|
+
/**
|
|
195
|
+
* SQL query result row type.
|
|
196
|
+
*/
|
|
197
|
+
Row: SqlRowType,
|
|
198
|
+
/**
|
|
199
|
+
* SQL query execution result type.
|
|
200
|
+
*/
|
|
201
|
+
Result: SqlResultType,
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
/**
|
|
205
|
+
* PostgreSQL database operations.
|
|
206
|
+
*
|
|
207
|
+
* Provides platform functions for PostgreSQL with connection pooling.
|
|
208
|
+
*/
|
|
209
|
+
Postgres: {
|
|
210
|
+
/**
|
|
211
|
+
* Connects to a PostgreSQL database.
|
|
212
|
+
*
|
|
213
|
+
* Creates a connection pool to a PostgreSQL database and returns an
|
|
214
|
+
* opaque handle for use in queries.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* const getUser = East.function([IntegerType], NullType, ($, userId) => {
|
|
219
|
+
* const config = $.let({
|
|
220
|
+
* host: "localhost",
|
|
221
|
+
* port: 5432n,
|
|
222
|
+
* database: "myapp",
|
|
223
|
+
* user: "postgres",
|
|
224
|
+
* password: "secret",
|
|
225
|
+
* ssl: variant('none', null),
|
|
226
|
+
* maxConnections: variant('none', null),
|
|
227
|
+
* });
|
|
228
|
+
*
|
|
229
|
+
* const conn = $.let(SQL.Postgres.connect(config));
|
|
230
|
+
* $(SQL.Postgres.query(
|
|
231
|
+
* conn,
|
|
232
|
+
* "SELECT name FROM users WHERE id = $1",
|
|
233
|
+
* [variant('Integer', userId)]
|
|
234
|
+
* ));
|
|
235
|
+
* $(SQL.Postgres.close(conn));
|
|
236
|
+
* $.return(null);
|
|
237
|
+
* });
|
|
238
|
+
*
|
|
239
|
+
* const compiled = East.compileAsync(getUser.toIR(), SQL.Postgres.Implementation);
|
|
240
|
+
* await compiled(42n);
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
connect: postgres_connect,
|
|
244
|
+
/**
|
|
245
|
+
* Executes a SQL query with parameters.
|
|
246
|
+
*
|
|
247
|
+
* Runs a SQL query with parameter binding using $1, $2, etc. placeholders.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```ts
|
|
251
|
+
* const getUser = East.function([IntegerType], NullType, ($, userId) => {
|
|
252
|
+
* const config = $.let({
|
|
253
|
+
* host: "localhost",
|
|
254
|
+
* port: 5432n,
|
|
255
|
+
* database: "myapp",
|
|
256
|
+
* user: "postgres",
|
|
257
|
+
* password: "secret",
|
|
258
|
+
* ssl: variant('none', null),
|
|
259
|
+
* maxConnections: variant('none', null),
|
|
260
|
+
* });
|
|
261
|
+
* const conn = $.let(SQL.Postgres.connect(config));
|
|
262
|
+
* $(SQL.Postgres.query(
|
|
263
|
+
* conn,
|
|
264
|
+
* "SELECT name FROM users WHERE id = $1",
|
|
265
|
+
* [variant('Integer', userId)]
|
|
266
|
+
* ));
|
|
267
|
+
* $(SQL.Postgres.close(conn));
|
|
268
|
+
* $.return(null);
|
|
269
|
+
* });
|
|
270
|
+
*
|
|
271
|
+
* const compiled = East.compileAsync(getUser.toIR(), SQL.Postgres.Implementation);
|
|
272
|
+
* await compiled(42n);
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
query: postgres_query,
|
|
276
|
+
/**
|
|
277
|
+
* Closes the PostgreSQL connection pool.
|
|
278
|
+
*
|
|
279
|
+
* Terminates all connections and releases all resources.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* const cleanup = East.function([], NullType, $ => {
|
|
284
|
+
* const config = $.let({
|
|
285
|
+
* host: "localhost",
|
|
286
|
+
* port: 5432n,
|
|
287
|
+
* database: "myapp",
|
|
288
|
+
* user: "postgres",
|
|
289
|
+
* password: "secret",
|
|
290
|
+
* ssl: variant('none', null),
|
|
291
|
+
* maxConnections: variant('none', null),
|
|
292
|
+
* });
|
|
293
|
+
* const conn = $.let(SQL.Postgres.connect(config));
|
|
294
|
+
* // ... do work ...
|
|
295
|
+
* $(SQL.Postgres.close(conn));
|
|
296
|
+
* $.return(null);
|
|
297
|
+
* });
|
|
298
|
+
*
|
|
299
|
+
* const compiled = East.compileAsync(cleanup.toIR(), SQL.Postgres.Implementation);
|
|
300
|
+
* await compiled();
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
close: postgres_close,
|
|
304
|
+
/**
|
|
305
|
+
* Closes all PostgreSQL connections.
|
|
306
|
+
*
|
|
307
|
+
* Closes all active PostgreSQL connection pools and releases all resources.
|
|
308
|
+
* Useful for test cleanup to ensure all connections are closed.
|
|
309
|
+
*
|
|
310
|
+
* @returns Null on success
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```ts
|
|
314
|
+
* const cleanupAll = East.function([], NullType, $ => {
|
|
315
|
+
* // ... test code that may have left connections open ...
|
|
316
|
+
* $(SQL.Postgres.closeAll());
|
|
317
|
+
* return $.return(null);
|
|
318
|
+
* });
|
|
319
|
+
*
|
|
320
|
+
* const compiled = East.compileAsync(cleanupAll.toIR(), SQL.Postgres.Implementation);
|
|
321
|
+
* await compiled();
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* @internal
|
|
325
|
+
*/
|
|
326
|
+
closeAll: postgres_close_all,
|
|
327
|
+
/**
|
|
328
|
+
* Node.js implementation of PostgreSQL platform functions.
|
|
329
|
+
*
|
|
330
|
+
* Pass this to East.compileAsync() to enable PostgreSQL operations.
|
|
331
|
+
*/
|
|
332
|
+
Implementation: PostgresImpl,
|
|
333
|
+
/**
|
|
334
|
+
* Type definitions for PostgreSQL operations.
|
|
335
|
+
*/
|
|
336
|
+
Types: {
|
|
337
|
+
/**
|
|
338
|
+
* PostgreSQL connection configuration type.
|
|
339
|
+
*/
|
|
340
|
+
Config: PostgresConfigType,
|
|
341
|
+
/**
|
|
342
|
+
* SQL query parameter value type.
|
|
343
|
+
*/
|
|
344
|
+
Parameter: SqlParameterType,
|
|
345
|
+
/**
|
|
346
|
+
* Array of SQL query parameters.
|
|
347
|
+
*/
|
|
348
|
+
Parameters: SqlParametersType,
|
|
349
|
+
/**
|
|
350
|
+
* SQL query result row type.
|
|
351
|
+
*/
|
|
352
|
+
Row: SqlRowType,
|
|
353
|
+
/**
|
|
354
|
+
* SQL query execution result type.
|
|
355
|
+
*/
|
|
356
|
+
Result: SqlResultType,
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
/**
|
|
360
|
+
* MySQL database operations.
|
|
361
|
+
*
|
|
362
|
+
* Provides platform functions for MySQL with connection pooling.
|
|
363
|
+
*/
|
|
364
|
+
MySQL: {
|
|
365
|
+
/**
|
|
366
|
+
* Connects to a MySQL database.
|
|
367
|
+
*
|
|
368
|
+
* Creates a connection pool to a MySQL database and returns an
|
|
369
|
+
* opaque handle for use in queries.
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```ts
|
|
373
|
+
* const getUser = East.function([IntegerType], NullType, ($, userId) => {
|
|
374
|
+
* const config = $.let({
|
|
375
|
+
* host: "localhost",
|
|
376
|
+
* port: 3306n,
|
|
377
|
+
* database: "myapp",
|
|
378
|
+
* user: "root",
|
|
379
|
+
* password: "secret",
|
|
380
|
+
* ssl: variant('none', null),
|
|
381
|
+
* maxConnections: variant('none', null),
|
|
382
|
+
* });
|
|
383
|
+
*
|
|
384
|
+
* const conn = $.let(SQL.MySQL.connect(config));
|
|
385
|
+
* $(SQL.MySQL.query(
|
|
386
|
+
* conn,
|
|
387
|
+
* "SELECT name FROM users WHERE id = ?",
|
|
388
|
+
* [variant('Integer', userId)]
|
|
389
|
+
* ));
|
|
390
|
+
* $(SQL.MySQL.close(conn));
|
|
391
|
+
* $.return(null);
|
|
392
|
+
* });
|
|
393
|
+
*
|
|
394
|
+
* const compiled = East.compileAsync(getUser.toIR(), SQL.MySQL.Implementation);
|
|
395
|
+
* await compiled(42n);
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
398
|
+
connect: mysql_connect,
|
|
399
|
+
/**
|
|
400
|
+
* Executes a SQL query with parameters.
|
|
401
|
+
*
|
|
402
|
+
* Runs a SQL query with parameter binding using ? placeholders.
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```ts
|
|
406
|
+
* const getUser = East.function([IntegerType], NullType, ($, userId) => {
|
|
407
|
+
* const config = $.let({
|
|
408
|
+
* host: "localhost",
|
|
409
|
+
* port: 3306n,
|
|
410
|
+
* database: "myapp",
|
|
411
|
+
* user: "root",
|
|
412
|
+
* password: "secret",
|
|
413
|
+
* ssl: variant('none', null),
|
|
414
|
+
* maxConnections: variant('none', null),
|
|
415
|
+
* });
|
|
416
|
+
* const conn = $.let(SQL.MySQL.connect(config));
|
|
417
|
+
* $(SQL.MySQL.query(
|
|
418
|
+
* conn,
|
|
419
|
+
* "SELECT name FROM users WHERE id = ?",
|
|
420
|
+
* [variant('Integer', userId)]
|
|
421
|
+
* ));
|
|
422
|
+
* $(SQL.MySQL.close(conn));
|
|
423
|
+
* $.return(null);
|
|
424
|
+
* });
|
|
425
|
+
*
|
|
426
|
+
* const compiled = East.compileAsync(getUser.toIR(), SQL.MySQL.Implementation);
|
|
427
|
+
* await compiled(42n);
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
query: mysql_query,
|
|
431
|
+
/**
|
|
432
|
+
* Closes the MySQL connection pool.
|
|
433
|
+
*
|
|
434
|
+
* Terminates all connections and releases all resources.
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```ts
|
|
438
|
+
* const cleanup = East.function([], NullType, $ => {
|
|
439
|
+
* const config = $.let({
|
|
440
|
+
* host: "localhost",
|
|
441
|
+
* port: 3306n,
|
|
442
|
+
* database: "myapp",
|
|
443
|
+
* user: "root",
|
|
444
|
+
* password: "secret",
|
|
445
|
+
* ssl: variant('none', null),
|
|
446
|
+
* maxConnections: variant('none', null),
|
|
447
|
+
* });
|
|
448
|
+
* const conn = $.let(SQL.MySQL.connect(config));
|
|
449
|
+
* // ... do work ...
|
|
450
|
+
* $(SQL.MySQL.close(conn));
|
|
451
|
+
* $.return(null);
|
|
452
|
+
* });
|
|
453
|
+
*
|
|
454
|
+
* const compiled = East.compileAsync(cleanup.toIR(), SQL.MySQL.Implementation);
|
|
455
|
+
* await compiled();
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
close: mysql_close,
|
|
459
|
+
/**
|
|
460
|
+
* Closes all MySQL connections.
|
|
461
|
+
*
|
|
462
|
+
* Closes all active MySQL connection pools and releases all resources.
|
|
463
|
+
* Useful for test cleanup to ensure all connections are closed.
|
|
464
|
+
*
|
|
465
|
+
* @returns Null on success
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
* ```ts
|
|
469
|
+
* const cleanupAll = East.function([], NullType, $ => {
|
|
470
|
+
* // ... test code that may have left connections open ...
|
|
471
|
+
* $(SQL.MySQL.closeAll());
|
|
472
|
+
* return $.return(null);
|
|
473
|
+
* });
|
|
474
|
+
*
|
|
475
|
+
* const compiled = East.compileAsync(cleanupAll.toIR(), SQL.MySQL.Implementation);
|
|
476
|
+
* await compiled();
|
|
477
|
+
* ```
|
|
478
|
+
*
|
|
479
|
+
* @internal
|
|
480
|
+
*/
|
|
481
|
+
closeAll: mysql_close_all,
|
|
482
|
+
/**
|
|
483
|
+
* Node.js implementation of MySQL platform functions.
|
|
484
|
+
*
|
|
485
|
+
* Pass this to East.compileAsync() to enable MySQL operations.
|
|
486
|
+
*/
|
|
487
|
+
Implementation: MySqlImpl,
|
|
488
|
+
/**
|
|
489
|
+
* Type definitions for MySQL operations.
|
|
490
|
+
*/
|
|
491
|
+
Types: {
|
|
492
|
+
/**
|
|
493
|
+
* MySQL connection configuration type.
|
|
494
|
+
*/
|
|
495
|
+
Config: MySqlConfigType,
|
|
496
|
+
/**
|
|
497
|
+
* SQL query parameter value type.
|
|
498
|
+
*/
|
|
499
|
+
Parameter: SqlParameterType,
|
|
500
|
+
/**
|
|
501
|
+
* Array of SQL query parameters.
|
|
502
|
+
*/
|
|
503
|
+
Parameters: SqlParametersType,
|
|
504
|
+
/**
|
|
505
|
+
* SQL query result row type.
|
|
506
|
+
*/
|
|
507
|
+
Row: SqlRowType,
|
|
508
|
+
/**
|
|
509
|
+
* SQL query execution result type.
|
|
510
|
+
*/
|
|
511
|
+
Result: SqlResultType,
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
};
|
|
515
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sql/index.ts"],"names":[],"mappings":"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"}
|