@elaraai/east-node-io 0.0.1-beta.8 → 1.0.0

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 (180) hide show
  1. package/CLA.md +1 -1
  2. package/CONTRIBUTING.md +3 -3
  3. package/LICENSE.md +31 -0
  4. package/README.md +56 -19
  5. package/dist/{compression → src/compression}/gzip.d.ts +1 -1
  6. package/dist/src/compression/gzip.d.ts.map +1 -0
  7. package/dist/{compression → src/compression}/gzip.js +3 -3
  8. package/dist/src/compression/gzip.js.map +1 -0
  9. package/dist/{compression → src/compression}/index.d.ts +16 -16
  10. package/dist/src/compression/index.d.ts.map +1 -0
  11. package/dist/src/compression/index.js.map +1 -0
  12. package/dist/{compression → src/compression}/tar.d.ts +2 -2
  13. package/dist/src/compression/tar.d.ts.map +1 -0
  14. package/dist/{compression → src/compression}/tar.js +7 -7
  15. package/dist/src/compression/tar.js.map +1 -0
  16. package/dist/{compression → src/compression}/types.d.ts +10 -10
  17. package/dist/src/compression/types.d.ts.map +1 -0
  18. package/dist/src/compression/types.js.map +1 -0
  19. package/dist/{compression → src/compression}/zip.d.ts +3 -3
  20. package/dist/src/compression/zip.d.ts.map +1 -0
  21. package/dist/{compression → src/compression}/zip.js +4 -4
  22. package/dist/src/compression/zip.js.map +1 -0
  23. package/dist/src/connection/index.d.ts.map +1 -0
  24. package/dist/{connection → src/connection}/index.js +2 -2
  25. package/dist/src/connection/index.js.map +1 -0
  26. package/dist/{format → src/format}/index.d.ts +77 -77
  27. package/dist/src/format/index.d.ts.map +1 -0
  28. package/dist/src/format/index.js.map +1 -0
  29. package/dist/{format → src/format}/types.d.ts +53 -53
  30. package/dist/src/format/types.d.ts.map +1 -0
  31. package/dist/src/format/types.js.map +1 -0
  32. package/dist/{format → src/format}/xlsx.d.ts +20 -20
  33. package/dist/src/format/xlsx.d.ts.map +1 -0
  34. package/dist/{format → src/format}/xlsx.js +6 -6
  35. package/dist/src/format/xlsx.js.map +1 -0
  36. package/dist/{format → src/format}/xml.d.ts +54 -54
  37. package/dist/src/format/xml.d.ts.map +1 -0
  38. package/dist/{format → src/format}/xml.js +14 -14
  39. package/dist/src/format/xml.js.map +1 -0
  40. package/dist/src/index.d.ts.map +1 -0
  41. package/dist/src/index.js.map +1 -0
  42. package/dist/{nosql → src/nosql}/index.d.ts +20 -20
  43. package/dist/src/nosql/index.d.ts.map +1 -0
  44. package/dist/src/nosql/index.js.map +1 -0
  45. package/dist/{nosql → src/nosql}/mongodb.d.ts +5 -5
  46. package/dist/src/nosql/mongodb.d.ts.map +1 -0
  47. package/dist/{nosql → src/nosql}/mongodb.js +8 -8
  48. package/dist/src/nosql/mongodb.js.map +1 -0
  49. package/dist/{nosql → src/nosql}/redis.d.ts +5 -5
  50. package/dist/src/nosql/redis.d.ts.map +1 -0
  51. package/dist/{nosql → src/nosql}/redis.js +6 -6
  52. package/dist/src/nosql/redis.js.map +1 -0
  53. package/dist/{nosql → src/nosql}/types.d.ts +10 -10
  54. package/dist/src/nosql/types.d.ts.map +1 -0
  55. package/dist/src/nosql/types.js.map +1 -0
  56. package/dist/src/platform.d.ts.map +1 -0
  57. package/dist/{platform.js → src/platform.js} +2 -0
  58. package/dist/src/platform.js.map +1 -0
  59. package/dist/src/sql/access.d.ts +243 -0
  60. package/dist/src/sql/access.d.ts.map +1 -0
  61. package/dist/src/sql/access.js +427 -0
  62. package/dist/src/sql/access.js.map +1 -0
  63. package/dist/src/sql/index.d.ts +1112 -0
  64. package/dist/src/sql/index.d.ts.map +1 -0
  65. package/dist/{sql → src/sql}/index.js +296 -4
  66. package/dist/src/sql/index.js.map +1 -0
  67. package/dist/{sql → src/sql}/mysql.d.ts +110 -32
  68. package/dist/src/sql/mysql.d.ts.map +1 -0
  69. package/dist/{sql → src/sql}/mysql.js +207 -6
  70. package/dist/src/sql/mysql.js.map +1 -0
  71. package/dist/{sql → src/sql}/postgres.d.ts +110 -32
  72. package/dist/src/sql/postgres.d.ts.map +1 -0
  73. package/dist/{sql → src/sql}/postgres.js +199 -6
  74. package/dist/src/sql/postgres.js.map +1 -0
  75. package/dist/{sql → src/sql}/sqlite.d.ts +108 -30
  76. package/dist/src/sql/sqlite.d.ts.map +1 -0
  77. package/dist/{sql → src/sql}/sqlite.js +209 -6
  78. package/dist/src/sql/sqlite.js.map +1 -0
  79. package/dist/src/sql/types.d.ts +269 -0
  80. package/dist/src/sql/types.d.ts.map +1 -0
  81. package/dist/{sql → src/sql}/types.js +65 -1
  82. package/dist/src/sql/types.js.map +1 -0
  83. package/dist/{storage → src/storage}/index.d.ts +63 -63
  84. package/dist/src/storage/index.d.ts.map +1 -0
  85. package/dist/{storage → src/storage}/index.js +1 -1
  86. package/dist/src/storage/index.js.map +1 -0
  87. package/dist/{storage → src/storage}/s3.d.ts +56 -49
  88. package/dist/src/storage/s3.d.ts.map +1 -0
  89. package/dist/{storage → src/storage}/s3.js +24 -15
  90. package/dist/src/storage/s3.js.map +1 -0
  91. package/dist/{storage → src/storage}/types.d.ts +18 -18
  92. package/dist/src/storage/types.d.ts.map +1 -0
  93. package/dist/src/storage/types.js.map +1 -0
  94. package/dist/{transfer → src/transfer}/ftp.d.ts +10 -10
  95. package/dist/src/transfer/ftp.d.ts.map +1 -0
  96. package/dist/{transfer → src/transfer}/ftp.js +6 -6
  97. package/dist/src/transfer/ftp.js.map +1 -0
  98. package/dist/{transfer → src/transfer}/index.d.ts +40 -40
  99. package/dist/src/transfer/index.d.ts.map +1 -0
  100. package/dist/src/transfer/index.js.map +1 -0
  101. package/dist/{transfer → src/transfer}/sftp.d.ts +10 -10
  102. package/dist/src/transfer/sftp.d.ts.map +1 -0
  103. package/dist/{transfer → src/transfer}/sftp.js +6 -6
  104. package/dist/src/transfer/sftp.js.map +1 -0
  105. package/dist/{transfer → src/transfer}/types.d.ts +15 -15
  106. package/dist/src/transfer/types.d.ts.map +1 -0
  107. package/dist/src/transfer/types.js.map +1 -0
  108. package/package.json +37 -53
  109. package/dist/compression/gzip.d.ts.map +0 -1
  110. package/dist/compression/gzip.js.map +0 -1
  111. package/dist/compression/index.d.ts.map +0 -1
  112. package/dist/compression/index.js.map +0 -1
  113. package/dist/compression/tar.d.ts.map +0 -1
  114. package/dist/compression/tar.js.map +0 -1
  115. package/dist/compression/types.d.ts.map +0 -1
  116. package/dist/compression/types.js.map +0 -1
  117. package/dist/compression/zip.d.ts.map +0 -1
  118. package/dist/compression/zip.js.map +0 -1
  119. package/dist/connection/index.d.ts.map +0 -1
  120. package/dist/connection/index.js.map +0 -1
  121. package/dist/format/index.d.ts.map +0 -1
  122. package/dist/format/index.js.map +0 -1
  123. package/dist/format/types.d.ts.map +0 -1
  124. package/dist/format/types.js.map +0 -1
  125. package/dist/format/xlsx.d.ts.map +0 -1
  126. package/dist/format/xlsx.js.map +0 -1
  127. package/dist/format/xml.d.ts.map +0 -1
  128. package/dist/format/xml.js.map +0 -1
  129. package/dist/index.d.ts.map +0 -1
  130. package/dist/index.js.map +0 -1
  131. package/dist/nosql/index.d.ts.map +0 -1
  132. package/dist/nosql/index.js.map +0 -1
  133. package/dist/nosql/mongodb.d.ts.map +0 -1
  134. package/dist/nosql/mongodb.js.map +0 -1
  135. package/dist/nosql/redis.d.ts.map +0 -1
  136. package/dist/nosql/redis.js.map +0 -1
  137. package/dist/nosql/types.d.ts.map +0 -1
  138. package/dist/nosql/types.js.map +0 -1
  139. package/dist/platform.d.ts.map +0 -1
  140. package/dist/platform.js.map +0 -1
  141. package/dist/sql/index.d.ts +0 -777
  142. package/dist/sql/index.d.ts.map +0 -1
  143. package/dist/sql/index.js.map +0 -1
  144. package/dist/sql/mysql.d.ts.map +0 -1
  145. package/dist/sql/mysql.js.map +0 -1
  146. package/dist/sql/postgres.d.ts.map +0 -1
  147. package/dist/sql/postgres.js.map +0 -1
  148. package/dist/sql/sqlite.d.ts.map +0 -1
  149. package/dist/sql/sqlite.js.map +0 -1
  150. package/dist/sql/types.d.ts +0 -205
  151. package/dist/sql/types.d.ts.map +0 -1
  152. package/dist/sql/types.js.map +0 -1
  153. package/dist/storage/index.d.ts.map +0 -1
  154. package/dist/storage/index.js.map +0 -1
  155. package/dist/storage/s3.d.ts.map +0 -1
  156. package/dist/storage/s3.js.map +0 -1
  157. package/dist/storage/types.d.ts.map +0 -1
  158. package/dist/storage/types.js.map +0 -1
  159. package/dist/transfer/ftp.d.ts.map +0 -1
  160. package/dist/transfer/ftp.js.map +0 -1
  161. package/dist/transfer/index.d.ts.map +0 -1
  162. package/dist/transfer/index.js.map +0 -1
  163. package/dist/transfer/sftp.d.ts.map +0 -1
  164. package/dist/transfer/sftp.js.map +0 -1
  165. package/dist/transfer/types.d.ts.map +0 -1
  166. package/dist/transfer/types.js.map +0 -1
  167. package/dist/tsconfig.tsbuildinfo +0 -1
  168. /package/dist/{compression → src/compression}/index.js +0 -0
  169. /package/dist/{compression → src/compression}/types.js +0 -0
  170. /package/dist/{connection → src/connection}/index.d.ts +0 -0
  171. /package/dist/{format → src/format}/index.js +0 -0
  172. /package/dist/{format → src/format}/types.js +0 -0
  173. /package/dist/{index.d.ts → src/index.d.ts} +0 -0
  174. /package/dist/{index.js → src/index.js} +0 -0
  175. /package/dist/{nosql → src/nosql}/index.js +0 -0
  176. /package/dist/{nosql → src/nosql}/types.js +0 -0
  177. /package/dist/{platform.d.ts → src/platform.d.ts} +0 -0
  178. /package/dist/{storage → src/storage}/types.js +0 -0
  179. /package/dist/{transfer → src/transfer}/index.js +0 -0
  180. /package/dist/{transfer → src/transfer}/types.js +0 -0
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * @packageDocumentation
12
12
  */
13
- import { BlobType, BooleanType, DateTimeType, East, FloatType, IntegerType, isValueOf, match, NullType, SortedMap, StringType as EastStringType, variant } from "@elaraai/east";
13
+ import { ArrayType, BlobType, BooleanType, DateTimeType, East, FloatType, IntegerType, isTypeValueEqual, isValueOf, match, NullType, OptionType, SortedMap, StringType as EastStringType, toEastTypeValue, variant } from "@elaraai/east";
14
14
  import { EastError } from "@elaraai/east/internal";
15
15
  import mysql from 'mysql2/promise';
16
16
  import { createHandle, getConnection, closeHandle, closeAllHandles } from '../connection/index.js';
@@ -130,6 +130,76 @@ export const mysql_connect = East.asyncPlatform("mysql_connect", [MySqlConfigTyp
130
130
  * - Returns lastInsertId for INSERT operations
131
131
  */
132
132
  export const mysql_query = East.asyncPlatform("mysql_query", [ConnectionHandleType, StringType, SqlParametersType], SqlResultType);
133
+ /**
134
+ * Executes a SELECT query with user-defined return type.
135
+ *
136
+ * Runs a SELECT query against a MySQL database with parameter binding and
137
+ * returns results as an array of typed rows. The return type is generic,
138
+ * allowing users to specify the expected row structure for type-safe access.
139
+ *
140
+ * This is a generic platform function for the East language, enabling type-safe
141
+ * SELECT queries in East programs running on Node.js.
142
+ *
143
+ * @typeParam T - The expected row type for query results
144
+ * @param handle - Connection handle from mysql_connect()
145
+ * @param sql - SQL SELECT query string with ? placeholders
146
+ * @param params - Query parameters as SqlParameterType array
147
+ * @returns Array of rows matching the specified type T
148
+ *
149
+ * @throws {EastError} When query fails due to:
150
+ * - Invalid connection handle (location: "mysql_select")
151
+ * - SQL syntax errors (location: "mysql_select")
152
+ * - Query is not a SELECT (location: "mysql_select")
153
+ * - Type coercion failure (location: "mysql_select")
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * import { East, NullType, StructType, StringType, IntegerType, variant } from "@elaraai/east";
158
+ * import { SQL } from "@elaraai/east-node-io";
159
+ *
160
+ * // Define the expected row type
161
+ * const UserRowType = StructType({
162
+ * id: IntegerType,
163
+ * name: StringType,
164
+ * email: StringType,
165
+ * });
166
+ *
167
+ * const queryUsers = East.function([], NullType, ($) => {
168
+ * const config = $.let({
169
+ * host: "localhost",
170
+ * port: 3306n,
171
+ * database: "myapp",
172
+ * user: "root",
173
+ * password: "secret",
174
+ * ssl: variant('none', null),
175
+ * maxConnections: variant('none', null),
176
+ * });
177
+ *
178
+ * const conn = $.let(SQL.MySQL.connect(config));
179
+ *
180
+ * // Query with typed results - returns Array<UserRowType>
181
+ * const users = $.let(SQL.MySQL.select([UserRowType], conn,
182
+ * "SELECT id, name, email FROM users WHERE active = ?",
183
+ * [variant('Boolean', true)]
184
+ * ));
185
+ * // users is typed as Array<{ id: bigint, name: string, email: string }>
186
+ *
187
+ * $(SQL.MySQL.close(conn));
188
+ * $.return(null);
189
+ * });
190
+ *
191
+ * const compiled = East.compileAsync(queryUsers.toIR(), SQL.MySQL.Implementation);
192
+ * await compiled();
193
+ * ```
194
+ *
195
+ * @remarks
196
+ * - Only SELECT queries are supported (use mysql_query for INSERT/UPDATE/DELETE)
197
+ * - Uses ? for parameter placeholders
198
+ * - Row type T should match the structure of selected columns
199
+ * - All MySQL data types are mapped to appropriate East types
200
+ * - NULL values are preserved in the result
201
+ */
202
+ export const mysql_select = East.asyncGenericPlatform("mysql_select", ["T"], [ConnectionHandleType, StringType, SqlParametersType], ArrayType("T"));
133
203
  /**
134
204
  * Closes a MySQL connection pool.
135
205
  *
@@ -292,7 +362,7 @@ export const MySqlImpl = [
292
362
  }
293
363
  catch (err) {
294
364
  throw new EastError(`MySQL connection failed: ${err.message}`, {
295
- location: { filename: "mysql_connect", line: 0n, column: 0n },
365
+ location: [{ filename: "mysql_connect", line: 0n, column: 0n }],
296
366
  cause: err
297
367
  });
298
368
  }
@@ -330,7 +400,7 @@ export const MySqlImpl = [
330
400
  // Validate ResultSetHeader structure
331
401
  if (typeof result.affectedRows !== 'number') {
332
402
  throw new EastError('MySQL ResultSetHeader missing affectedRows', {
333
- location: { filename: "mysql_query", line: 0n, column: 0n }
403
+ location: [{ filename: "mysql_query", line: 0n, column: 0n }]
334
404
  });
335
405
  }
336
406
  // Determine query type from SQL
@@ -363,13 +433,144 @@ export const MySqlImpl = [
363
433
  else {
364
434
  // Unexpected result type
365
435
  throw new EastError(`Unexpected result type from MySQL query: ${typeof rows}`, {
366
- location: { filename: "mysql_query", line: 0n, column: 0n }
436
+ location: [{ filename: "mysql_query", line: 0n, column: 0n }]
367
437
  });
368
438
  }
369
439
  }
370
440
  catch (err) {
371
441
  throw new EastError(`MySQL query failed: ${err.message}`, {
372
- location: { filename: "mysql_query", line: 0n, column: 0n },
442
+ location: [{ filename: "mysql_query", line: 0n, column: 0n }],
443
+ cause: err
444
+ });
445
+ }
446
+ }),
447
+ mysql_select.implement((T) => async (...args) => {
448
+ const handle = args[0];
449
+ const sql = args[1];
450
+ const params = args[2];
451
+ const rowType = T;
452
+ try {
453
+ const pool = getConnection(handle);
454
+ // Validate row type is a Struct
455
+ if (rowType.type !== 'Struct') {
456
+ throw new EastError(`Expected row type must be a Struct, got ${rowType.type}`, { location: [{ filename: "mysql_select", line: 0n, column: 0n }] });
457
+ }
458
+ // Convert East parameters to native values
459
+ const nativeParams = params.map(convertParamToNative);
460
+ // Execute the query
461
+ const [rawRows, fields] = await pool.query(sql, nativeParams);
462
+ // Verify this is a SELECT query (SELECT has fields array with entries)
463
+ if (!Array.isArray(rawRows) || fields.length === 0) {
464
+ throw new EastError('mysql_select only supports SELECT queries. Use mysql_query for INSERT/UPDATE/DELETE.', {
465
+ location: [{ filename: "mysql_select", line: 0n, column: 0n }]
466
+ });
467
+ }
468
+ // Get column metadata
469
+ const columnMetaMap = new Map();
470
+ for (const field of fields) {
471
+ columnMetaMap.set(field.name, { fieldType: field.type });
472
+ }
473
+ // Validate field types and determine which are OptionTypes
474
+ // Note: T is EastTypeValue (IR format), not EastType (runtime format)
475
+ const structTypeValue = rowType;
476
+ const fieldInfo = new Map();
477
+ for (const field of structTypeValue.value) {
478
+ const fieldName = field.name;
479
+ const fieldType = field.type;
480
+ const colMeta = columnMetaMap.get(fieldName);
481
+ if (!colMeta) {
482
+ throw new EastError(`Column '${fieldName}' not found in query result`, { location: [{ filename: "mysql_select", line: 0n, column: 0n }] });
483
+ }
484
+ // Determine expected base type from MySQL field type
485
+ let expectedBaseType;
486
+ const ft = colMeta.fieldType;
487
+ if (ft === 1 || ft === 16) { // TINY (as boolean), BIT
488
+ expectedBaseType = BooleanType;
489
+ }
490
+ else if (ft === 2 || ft === 3 || ft === 8 || ft === 9 || ft === 13) { // SHORT, LONG, LONGLONG, INT24, YEAR
491
+ expectedBaseType = IntegerType;
492
+ }
493
+ else if (ft === 0 || ft === 4 || ft === 5 || ft === 246) { // DECIMAL, FLOAT, DOUBLE, NEWDECIMAL
494
+ expectedBaseType = FloatType;
495
+ }
496
+ else if (ft === 253 || ft === 254) { // VARCHAR, STRING (CHAR)
497
+ expectedBaseType = EastStringType;
498
+ }
499
+ else if (ft === 7 || ft === 10 || ft === 11 || ft === 12) { // TIMESTAMP, DATE, TIME, DATETIME
500
+ expectedBaseType = DateTimeType;
501
+ }
502
+ else if (ft === 252) { // BLOB or TEXT (both use 252!)
503
+ // Field type 252 is ambiguous - used for both TEXT and BLOB
504
+ // Check if user expects String (TEXT) or Blob
505
+ const isString = isTypeValueEqual(fieldType, toEastTypeValue(EastStringType));
506
+ const isStringOption = isTypeValueEqual(fieldType, toEastTypeValue(OptionType(EastStringType)));
507
+ const isBlob = isTypeValueEqual(fieldType, toEastTypeValue(BlobType));
508
+ const isBlobOption = isTypeValueEqual(fieldType, toEastTypeValue(OptionType(BlobType)));
509
+ if (isString || isStringOption) {
510
+ expectedBaseType = EastStringType;
511
+ }
512
+ else if (isBlob || isBlobOption) {
513
+ expectedBaseType = BlobType;
514
+ }
515
+ else {
516
+ throw new EastError(`Type mismatch for column '${fieldName}': MySQL field type 252 (TEXT/BLOB), got ${fieldType.type} but expected String, Blob, OptionType(String), or OptionType(Blob)`, { location: [{ filename: "mysql_select", line: 0n, column: 0n }] });
517
+ }
518
+ fieldInfo.set(fieldName, { isOption: isStringOption || isBlobOption, expectedBaseType });
519
+ continue;
520
+ }
521
+ else {
522
+ // Unknown field type - skip type validation, rely on isValueOf later
523
+ fieldInfo.set(fieldName, { isOption: false, expectedBaseType: IntegerType });
524
+ continue;
525
+ }
526
+ // Check if field type matches base type or OptionType(base type)
527
+ const isBase = isTypeValueEqual(fieldType, toEastTypeValue(expectedBaseType));
528
+ const isOption = isTypeValueEqual(fieldType, toEastTypeValue(OptionType(expectedBaseType)));
529
+ if (!isBase && !isOption) {
530
+ throw new EastError(`Type mismatch for column '${fieldName}': MySQL field type ${ft}, got ${fieldType.type} but expected ${expectedBaseType.type} or OptionType(${expectedBaseType.type})`, { location: [{ filename: "mysql_select", line: 0n, column: 0n }] });
531
+ }
532
+ fieldInfo.set(fieldName, { isOption, expectedBaseType });
533
+ }
534
+ // Convert values based on column metadata and handle nulls
535
+ const rows = rawRows.map((row, rowIndex) => {
536
+ const converted = {};
537
+ for (const [key, value] of Object.entries(row)) {
538
+ const info = fieldInfo.get(key);
539
+ const colMeta = columnMetaMap.get(key);
540
+ const ft = colMeta?.fieldType;
541
+ if (value === null) {
542
+ if (info?.isOption) {
543
+ converted[key] = variant('none', null);
544
+ }
545
+ else {
546
+ throw new EastError(`null value at row[${rowIndex}] for required field '${key}' - use OptionType(${info?.expectedBaseType.type ?? 'T'}) for nullable columns`, { location: [{ filename: "mysql_select", line: 0n, column: 0n }] });
547
+ }
548
+ }
549
+ else {
550
+ // Convert based on field type
551
+ let convertedValue;
552
+ if (ft === 2 || ft === 3 || ft === 8 || ft === 9 || ft === 13) { // SHORT, LONG, LONGLONG, INT24, YEAR
553
+ convertedValue = BigInt(value);
554
+ }
555
+ else if (ft === 252 && Buffer.isBuffer(value)) { // BLOB
556
+ convertedValue = new Uint8Array(value);
557
+ }
558
+ else {
559
+ convertedValue = value;
560
+ }
561
+ converted[key] = info?.isOption ? variant('some', convertedValue) : convertedValue;
562
+ }
563
+ }
564
+ return converted;
565
+ });
566
+ // Type validation is already done field-by-field above during column metadata validation
567
+ return rows;
568
+ }
569
+ catch (err) {
570
+ if (err instanceof EastError)
571
+ throw err;
572
+ throw new EastError(`MySQL select failed: ${err.message}`, {
573
+ location: [{ filename: "mysql_select", line: 0n, column: 0n }],
373
574
  cause: err
374
575
  });
375
576
  }
@@ -383,7 +584,7 @@ export const MySqlImpl = [
383
584
  }
384
585
  catch (err) {
385
586
  throw new EastError(`MySQL close failed: ${err.message}`, {
386
- location: { filename: "mysql_close", line: 0n, column: 0n },
587
+ location: [{ filename: "mysql_close", line: 0n, column: 0n }],
387
588
  cause: err
388
589
  });
389
590
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql.js","sourceRoot":"","sources":["../../../src/sql/mysql.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,IAAI,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG1O,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACnG,OAAO,EACH,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,gBAAgB,EACnB,MAAM,YAAY,CAAC;AA+BpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC,eAAe,CAAC,EAAE,oBAAoB,CAAC,CAAC;AAE1G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC,oBAAoB,EAAE,UAAU,EAAE,iBAAiB,CAAC,EAAE,aAAa,CAAC,CAAC;AAEnI;;;;;;;;;;;;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AAE,EAAE;gBACvD,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;gBAC9D,KAAK,EAAE,GAAG;aACb,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC;IAEF,WAAW,CAAC,SAAS,CAAC,KAAK,EAAE,MAAgD,EAAE,EAAE;QAC7E,IAAI,CAAC;YACD,MAAM,IAAI,GAAG,aAAa,CAAa,MAAM,CAAC,CAAC;YAC/C,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YACjB,WAAW,CAAC,MAAM,CAAC,CAAC;YACpB,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,MAAM,IAAI,SAAS,CAAC,uBAAuB,GAAG,CAAC,OAAO,EAAE,EAAE;gBACtD,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;gBAC7D,KAAK,EAAE,GAAG;aACb,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC;IAEF,eAAe,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,eAAe,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;CACL,CAAC"}
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * @packageDocumentation
12
12
  */
13
- import { BlobType, BooleanType, DateTimeType, FloatType, IntegerType, NullType, StringType as EastStringType } from "@elaraai/east";
13
+ import { ArrayType, BlobType, BooleanType, DateTimeType, FloatType, IntegerType, NullType, OptionType, StringType as EastStringType } from "@elaraai/east";
14
14
  import type { PlatformFunction } from "@elaraai/east/internal";
15
15
  import { StringType } from './types.js';
16
16
  /**
@@ -69,13 +69,13 @@ import { StringType } from './types.js';
69
69
  * - Connections are automatically returned to the pool after queries
70
70
  */
71
71
  export declare const postgres_connect: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StructType<{
72
- host: EastStringType;
73
- port: IntegerType;
74
- database: EastStringType;
75
- user: EastStringType;
76
- password: EastStringType;
77
- ssl: import("@elaraai/east").OptionType<BooleanType>;
78
- maxConnections: import("@elaraai/east").OptionType<IntegerType>;
72
+ readonly host: EastStringType;
73
+ readonly port: IntegerType;
74
+ readonly database: EastStringType;
75
+ readonly user: EastStringType;
76
+ readonly password: EastStringType;
77
+ readonly ssl: OptionType<BooleanType>;
78
+ readonly maxConnections: OptionType<IntegerType>;
79
79
  }>], EastStringType>;
80
80
  /**
81
81
  * Executes a SQL query with parameterized values.
@@ -134,37 +134,115 @@ export declare const postgres_connect: import("@elaraai/east").AsyncPlatformDefi
134
134
  * - All queries are asynchronous
135
135
  * - Parameters prevent SQL injection attacks
136
136
  */
137
- export declare const postgres_query: import("@elaraai/east").AsyncPlatformDefinition<[EastStringType, EastStringType, import("@elaraai/east").ArrayType<import("@elaraai/east").VariantType<{
138
- Null: NullType;
139
- Boolean: BooleanType;
140
- Integer: IntegerType;
141
- Float: FloatType;
142
- String: StringType;
143
- DateTime: DateTimeType;
144
- Blob: BlobType;
137
+ export declare const postgres_query: import("@elaraai/east").AsyncPlatformDefinition<[EastStringType, EastStringType, ArrayType<import("@elaraai/east").VariantType<{
138
+ readonly Null: NullType;
139
+ readonly Boolean: BooleanType;
140
+ readonly Integer: IntegerType;
141
+ readonly Float: FloatType;
142
+ readonly String: StringType;
143
+ readonly DateTime: DateTimeType;
144
+ readonly Blob: BlobType;
145
145
  }>>], import("@elaraai/east").VariantType<{
146
- select: import("@elaraai/east").StructType<{
147
- rows: import("@elaraai/east").ArrayType<import("@elaraai/east").DictType<EastStringType, import("@elaraai/east").VariantType<{
148
- Null: NullType;
149
- Boolean: BooleanType;
150
- Integer: IntegerType;
151
- Float: FloatType;
152
- String: StringType;
153
- DateTime: DateTimeType;
154
- Blob: BlobType;
146
+ readonly select: import("@elaraai/east").StructType<{
147
+ readonly rows: ArrayType<import("@elaraai/east").DictType<EastStringType, import("@elaraai/east").VariantType<{
148
+ readonly Null: NullType;
149
+ readonly Boolean: BooleanType;
150
+ readonly Integer: IntegerType;
151
+ readonly Float: FloatType;
152
+ readonly String: StringType;
153
+ readonly DateTime: DateTimeType;
154
+ readonly Blob: BlobType;
155
155
  }>>>;
156
156
  }>;
157
- insert: import("@elaraai/east").StructType<{
158
- rowsAffected: IntegerType;
159
- lastInsertId: import("@elaraai/east").OptionType<IntegerType>;
157
+ readonly insert: import("@elaraai/east").StructType<{
158
+ readonly rowsAffected: IntegerType;
159
+ readonly lastInsertId: OptionType<IntegerType>;
160
160
  }>;
161
- update: import("@elaraai/east").StructType<{
162
- rowsAffected: IntegerType;
161
+ readonly update: import("@elaraai/east").StructType<{
162
+ readonly rowsAffected: IntegerType;
163
163
  }>;
164
- delete: import("@elaraai/east").StructType<{
165
- rowsAffected: IntegerType;
164
+ readonly delete: import("@elaraai/east").StructType<{
165
+ readonly rowsAffected: IntegerType;
166
166
  }>;
167
167
  }>>;
168
+ /**
169
+ * Executes a SELECT query with user-defined return type.
170
+ *
171
+ * Runs a SELECT query against a PostgreSQL database with parameter binding and
172
+ * returns results as an array of typed rows. The return type is generic,
173
+ * allowing users to specify the expected row structure for type-safe access.
174
+ *
175
+ * This is a generic platform function for the East language, enabling type-safe
176
+ * SELECT queries in East programs running on Node.js.
177
+ *
178
+ * @typeParam T - The expected row type for query results
179
+ * @param handle - Connection handle from postgres_connect()
180
+ * @param sql - SQL SELECT query string with $1, $2, etc. placeholders
181
+ * @param params - Query parameters as SqlParameterType array
182
+ * @returns Array of rows matching the specified type T
183
+ *
184
+ * @throws {EastError} When query fails due to:
185
+ * - Invalid connection handle (location: "postgres_select")
186
+ * - SQL syntax errors (location: "postgres_select")
187
+ * - Query is not a SELECT (location: "postgres_select")
188
+ * - Type coercion failure (location: "postgres_select")
189
+ *
190
+ * @example
191
+ * ```ts
192
+ * import { East, NullType, StructType, StringType, IntegerType, variant } from "@elaraai/east";
193
+ * import { SQL } from "@elaraai/east-node-io";
194
+ *
195
+ * // Define the expected row type
196
+ * const UserRowType = StructType({
197
+ * id: IntegerType,
198
+ * name: StringType,
199
+ * email: StringType,
200
+ * });
201
+ *
202
+ * const queryUsers = East.function([], NullType, ($) => {
203
+ * const config = $.let({
204
+ * host: "localhost",
205
+ * port: 5432n,
206
+ * database: "myapp",
207
+ * user: "postgres",
208
+ * password: "secret",
209
+ * ssl: variant('none', null),
210
+ * maxConnections: variant('none', null),
211
+ * });
212
+ *
213
+ * const conn = $.let(SQL.Postgres.connect(config));
214
+ *
215
+ * // Query with typed results - returns Array<UserRowType>
216
+ * const users = $.let(SQL.Postgres.select([UserRowType], conn,
217
+ * "SELECT id, name, email FROM users WHERE active = $1",
218
+ * [variant('Boolean', true)]
219
+ * ));
220
+ * // users is typed as Array<{ id: bigint, name: string, email: string }>
221
+ *
222
+ * $(SQL.Postgres.close(conn));
223
+ * $.return(null);
224
+ * });
225
+ *
226
+ * const compiled = East.compileAsync(queryUsers.toIR(), SQL.Postgres.Implementation);
227
+ * await compiled();
228
+ * ```
229
+ *
230
+ * @remarks
231
+ * - Only SELECT queries are supported (use postgres_query for INSERT/UPDATE/DELETE)
232
+ * - Uses $1, $2, $3, etc. for parameter placeholders
233
+ * - Row type T should match the structure of selected columns
234
+ * - All PostgreSQL data types are mapped to appropriate East types
235
+ * - NULL values are preserved in the result
236
+ */
237
+ export declare const postgres_select: import("@elaraai/east").AsyncGenericPlatformDefinition<readonly ["T"], readonly [EastStringType, EastStringType, ArrayType<import("@elaraai/east").VariantType<{
238
+ readonly Null: NullType;
239
+ readonly Boolean: BooleanType;
240
+ readonly Integer: IntegerType;
241
+ readonly Float: FloatType;
242
+ readonly String: StringType;
243
+ readonly DateTime: DateTimeType;
244
+ readonly Blob: BlobType;
245
+ }>>], ArrayType<"T">>;
168
246
  /**
169
247
  * Closes a PostgreSQL connection pool.
170
248
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../src/sql/postgres.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAQ,SAAS,EAAE,WAAW,EAAsC,QAAQ,EAAE,UAAU,EAAa,UAAU,IAAI,cAAc,EAA4B,MAAM,eAAe,CAAC;AAE1O,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI9E,OAAO,EAKH,UAAU,EAEb,MAAM,YAAY,CAAC;AA4BpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;oBAAqF,CAAC;AAEnH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6G,CAAC;AAEzI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,eAAO,MAAM,eAAe;;;;;;;;qBAK3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,cAAc,6EAAyE,CAAC;AAErG;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,kBAAkB,+DAAyD,CAAC;AAkFzF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,gBAAgB,EAiR1C,CAAC"}