@elaraai/east-node-io 0.0.1-beta.1 → 0.0.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/compression/gzip.d.ts +108 -0
  2. package/dist/compression/gzip.d.ts.map +1 -0
  3. package/dist/compression/gzip.js +153 -0
  4. package/dist/compression/gzip.js.map +1 -0
  5. package/dist/compression/index.d.ts +308 -0
  6. package/dist/compression/index.d.ts.map +1 -0
  7. package/dist/compression/index.js +289 -0
  8. package/dist/compression/index.js.map +1 -0
  9. package/dist/compression/tar.d.ts +115 -0
  10. package/dist/compression/tar.d.ts.map +1 -0
  11. package/dist/compression/tar.js +254 -0
  12. package/dist/compression/tar.js.map +1 -0
  13. package/dist/compression/types.d.ts +124 -0
  14. package/dist/compression/types.d.ts.map +1 -0
  15. package/dist/compression/types.js +106 -0
  16. package/dist/compression/types.js.map +1 -0
  17. package/dist/compression/zip.d.ts +121 -0
  18. package/dist/compression/zip.d.ts.map +1 -0
  19. package/dist/compression/zip.js +200 -0
  20. package/dist/compression/zip.js.map +1 -0
  21. package/dist/connection/index.d.ts +78 -0
  22. package/dist/connection/index.d.ts.map +1 -0
  23. package/dist/connection/index.js +134 -0
  24. package/dist/connection/index.js.map +1 -0
  25. package/dist/format/csv.d.ts +210 -0
  26. package/dist/format/csv.d.ts.map +1 -0
  27. package/dist/format/csv.js +729 -0
  28. package/dist/format/csv.js.map +1 -0
  29. package/dist/format/index.d.ts +641 -0
  30. package/dist/format/index.d.ts.map +1 -0
  31. package/dist/format/index.js +463 -0
  32. package/dist/format/index.js.map +1 -0
  33. package/dist/format/types.d.ts +176 -0
  34. package/dist/format/types.d.ts.map +1 -0
  35. package/dist/format/types.js +122 -0
  36. package/dist/format/types.js.map +1 -0
  37. package/dist/format/xlsx.d.ts +178 -0
  38. package/dist/format/xlsx.d.ts.map +1 -0
  39. package/dist/format/xlsx.js +313 -0
  40. package/dist/format/xlsx.js.map +1 -0
  41. package/dist/format/xml.d.ts +302 -0
  42. package/dist/format/xml.d.ts.map +1 -0
  43. package/dist/format/xml.js +602 -0
  44. package/dist/format/xml.js.map +1 -0
  45. package/dist/index.d.ts +25 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +32 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/nosql/index.d.ts +503 -0
  50. package/dist/nosql/index.d.ts.map +1 -0
  51. package/dist/nosql/index.js +483 -0
  52. package/dist/nosql/index.js.map +1 -0
  53. package/dist/nosql/mongodb.d.ts +306 -0
  54. package/dist/nosql/mongodb.d.ts.map +1 -0
  55. package/dist/nosql/mongodb.js +552 -0
  56. package/dist/nosql/mongodb.js.map +1 -0
  57. package/dist/nosql/redis.d.ts +268 -0
  58. package/dist/nosql/redis.d.ts.map +1 -0
  59. package/dist/nosql/redis.js +371 -0
  60. package/dist/nosql/redis.js.map +1 -0
  61. package/dist/nosql/types.d.ts +70 -0
  62. package/dist/nosql/types.d.ts.map +1 -0
  63. package/dist/nosql/types.js +79 -0
  64. package/dist/nosql/types.js.map +1 -0
  65. package/dist/sql/index.d.ts +777 -0
  66. package/dist/sql/index.d.ts.map +1 -0
  67. package/dist/sql/index.js +515 -0
  68. package/dist/sql/index.js.map +1 -0
  69. package/dist/sql/mysql.d.ts +238 -0
  70. package/dist/sql/mysql.d.ts.map +1 -0
  71. package/dist/sql/mysql.js +396 -0
  72. package/dist/sql/mysql.js.map +1 -0
  73. package/dist/sql/postgres.d.ts +237 -0
  74. package/dist/sql/postgres.d.ts.map +1 -0
  75. package/dist/sql/postgres.js +381 -0
  76. package/dist/sql/postgres.js.map +1 -0
  77. package/dist/sql/sqlite.d.ts +217 -0
  78. package/dist/sql/sqlite.d.ts.map +1 -0
  79. package/dist/sql/sqlite.js +366 -0
  80. package/dist/sql/sqlite.js.map +1 -0
  81. package/dist/sql/types.d.ts +205 -0
  82. package/dist/sql/types.d.ts.map +1 -0
  83. package/dist/sql/types.js +175 -0
  84. package/dist/sql/types.js.map +1 -0
  85. package/dist/storage/index.d.ts +304 -0
  86. package/dist/storage/index.d.ts.map +1 -0
  87. package/dist/storage/index.js +234 -0
  88. package/dist/storage/index.js.map +1 -0
  89. package/dist/storage/s3.d.ts +373 -0
  90. package/dist/storage/s3.d.ts.map +1 -0
  91. package/dist/storage/s3.js +502 -0
  92. package/dist/storage/s3.js.map +1 -0
  93. package/dist/storage/types.d.ts +117 -0
  94. package/dist/storage/types.d.ts.map +1 -0
  95. package/dist/storage/types.js +94 -0
  96. package/dist/storage/types.js.map +1 -0
  97. package/dist/transfer/ftp.d.ts +333 -0
  98. package/dist/transfer/ftp.d.ts.map +1 -0
  99. package/dist/transfer/ftp.js +437 -0
  100. package/dist/transfer/ftp.js.map +1 -0
  101. package/dist/transfer/index.d.ts +456 -0
  102. package/dist/transfer/index.d.ts.map +1 -0
  103. package/dist/transfer/index.js +414 -0
  104. package/dist/transfer/index.js.map +1 -0
  105. package/dist/transfer/sftp.d.ts +333 -0
  106. package/dist/transfer/sftp.d.ts.map +1 -0
  107. package/dist/transfer/sftp.js +436 -0
  108. package/dist/transfer/sftp.js.map +1 -0
  109. package/dist/transfer/types.d.ts +108 -0
  110. package/dist/transfer/types.d.ts.map +1 -0
  111. package/dist/transfer/types.js +110 -0
  112. package/dist/transfer/types.js.map +1 -0
  113. package/dist/tsconfig.tsbuildinfo +1 -0
  114. package/package.json +6 -6
@@ -0,0 +1,237 @@
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
+ * PostgreSQL platform functions for East Node IO.
7
+ *
8
+ * Provides PostgreSQL database operations for East programs, including
9
+ * connection pooling and parameterized query execution.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import { BlobType, BooleanType, DateTimeType, FloatType, IntegerType, NullType, StringType as EastStringType } from "@elaraai/east";
14
+ import type { PlatformFunction } from "@elaraai/east/internal";
15
+ import { StringType } from './types.js';
16
+ /**
17
+ * Connects to a PostgreSQL database.
18
+ *
19
+ * Creates a connection pool to a PostgreSQL database and returns an
20
+ * opaque handle for use in queries. The connection pool is managed
21
+ * automatically and supports concurrent queries.
22
+ *
23
+ * This is a platform function for the East language, enabling PostgreSQL database
24
+ * operations in East programs running on Node.js.
25
+ *
26
+ * @param config - PostgreSQL connection configuration
27
+ * @returns Connection handle (opaque string)
28
+ *
29
+ * @throws {EastError} When connection fails due to:
30
+ * - Network errors (location: "postgres_connect")
31
+ * - Authentication failures (location: "postgres_connect")
32
+ * - Invalid configuration (location: "postgres_connect")
33
+ * - Database does not exist (location: "postgres_connect")
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { East, StringType, IntegerType } from "@elaraai/east";
38
+ * import { SQL } from "@elaraai/east-node-io";
39
+ *
40
+ * const getUserById = East.function([IntegerType], NullType, ($, userId) => {
41
+ * const config = $.let({
42
+ * host: "localhost",
43
+ * port: 5432n,
44
+ * database: "myapp",
45
+ * user: "postgres",
46
+ * password: "secret",
47
+ * ssl: variant('none', null),
48
+ * maxConnections: variant('none', null),
49
+ * });
50
+ *
51
+ * const conn = $.let(SQL.Postgres.connect(config));
52
+ * $(SQL.Postgres.query(
53
+ * conn,
54
+ * "SELECT name FROM users WHERE id = $1",
55
+ * [variant('Integer', userId)]
56
+ * ));
57
+ * $(SQL.Postgres.close(conn));
58
+ * $.return(null);
59
+ * });
60
+ *
61
+ * const compiled = East.compileAsync(getUserById.toIR(), SQL.Postgres.Implementation);
62
+ * await compiled(42n);
63
+ * ```
64
+ *
65
+ * @remarks
66
+ * - Uses connection pooling for better performance
67
+ * - Default pool size is 10 connections
68
+ * - All queries are asynchronous
69
+ * - Connections are automatically returned to the pool after queries
70
+ */
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>;
79
+ }>], EastStringType>;
80
+ /**
81
+ * Executes a SQL query with parameterized values.
82
+ *
83
+ * Runs a SQL query against a PostgreSQL database with parameter binding for
84
+ * safe, injection-free queries. Returns rows as dictionaries mapping column
85
+ * names to typed values, along with metadata about affected rows.
86
+ *
87
+ * This is a platform function for the East language, enabling SQL database
88
+ * operations in East programs running on Node.js.
89
+ *
90
+ * @param handle - Connection handle from postgres_connect()
91
+ * @param sql - SQL query string with $1, $2, etc. placeholders
92
+ * @param params - Query parameters as SqlParameterType array
93
+ * @returns Query results with rows and metadata
94
+ *
95
+ * @throws {EastError} When query fails due to:
96
+ * - Invalid connection handle (location: "postgres_query")
97
+ * - SQL syntax errors (location: "postgres_query")
98
+ * - Connection timeout (location: "postgres_query")
99
+ * - Parameter type mismatch (location: "postgres_query")
100
+ * - Constraint violations (location: "postgres_query")
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * import { East, IntegerType, NullType, variant } from "@elaraai/east";
105
+ * import { SQL } from "@elaraai/east-node-io";
106
+ *
107
+ * const insertUser = East.function([IntegerType], NullType, ($, userId) => {
108
+ * const config = $.let({
109
+ * host: "localhost",
110
+ * port: 5432n,
111
+ * database: "myapp",
112
+ * user: "postgres",
113
+ * password: "secret",
114
+ * ssl: variant('none', null),
115
+ * maxConnections: variant('none', null),
116
+ * });
117
+ * const conn = $.let(SQL.Postgres.connect(config));
118
+ * const result = $.let(SQL.Postgres.query(
119
+ * conn,
120
+ * "INSERT INTO users (name, email) VALUES ($1, $2) RETURNING id",
121
+ * [variant('String', "Alice"), variant('String', "alice@example.com")]
122
+ * ));
123
+ * $(SQL.Postgres.close(conn));
124
+ * return $.return(null);
125
+ * });
126
+ *
127
+ * const compiled = East.compileAsync(insertUser.toIR(), SQL.Postgres.Implementation);
128
+ * await compiled(42n);
129
+ * ```
130
+ *
131
+ * @remarks
132
+ * - Uses $1, $2, $3, etc. for parameter placeholders
133
+ * - NULL values map to {tag: "null", value: {}}
134
+ * - All queries are asynchronous
135
+ * - Parameters prevent SQL injection attacks
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;
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;
155
+ }>>>;
156
+ }>;
157
+ insert: import("@elaraai/east").StructType<{
158
+ rowsAffected: IntegerType;
159
+ lastInsertId: import("@elaraai/east").OptionType<IntegerType>;
160
+ }>;
161
+ update: import("@elaraai/east").StructType<{
162
+ rowsAffected: IntegerType;
163
+ }>;
164
+ delete: import("@elaraai/east").StructType<{
165
+ rowsAffected: IntegerType;
166
+ }>;
167
+ }>>;
168
+ /**
169
+ * Closes a PostgreSQL connection pool.
170
+ *
171
+ * Closes the connection pool and releases all resources.
172
+ * All active connections are terminated gracefully.
173
+ *
174
+ * @param handle - Connection handle from postgres_connect()
175
+ *
176
+ * @throws {EastError} When handle is invalid (location: "postgres_close")
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * import { East, NullType, variant } from "@elaraai/east";
181
+ * import { SQL } from "@elaraai/east-node-io";
182
+ *
183
+ * const cleanup = East.function([], NullType, $ => {
184
+ * const config = $.let({
185
+ * host: "localhost",
186
+ * port: 5432n,
187
+ * database: "myapp",
188
+ * user: "postgres",
189
+ * password: "secret",
190
+ * ssl: variant('none', null),
191
+ * maxConnections: variant('none', null),
192
+ * });
193
+ * const conn = $.let(SQL.Postgres.connect(config));
194
+ * // ... do work ...
195
+ * $(SQL.Postgres.close(conn));
196
+ * return $.return(null);
197
+ * });
198
+ *
199
+ * const compiled = East.compileAsync(cleanup.toIR(), SQL.Postgres.Implementation);
200
+ * await compiled();
201
+ * ```
202
+ */
203
+ export declare const postgres_close: import("@elaraai/east").AsyncPlatformDefinition<[EastStringType], NullType>;
204
+ /**
205
+ * Closes all PostgreSQL connections.
206
+ *
207
+ * Closes all active PostgreSQL connection pools and releases all resources.
208
+ * Useful for test cleanup to ensure all connections are closed.
209
+ *
210
+ * @returns Null on success
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * import { East, NullType } from "@elaraai/east";
215
+ * import { SQL } from "@elaraai/east-node-io";
216
+ *
217
+ * const cleanupAll = East.function([], NullType, $ => {
218
+ * // ... test code that may have left connections open ...
219
+ * $(SQL.Postgres.closeAll());
220
+ * return $.return(null);
221
+ * });
222
+ *
223
+ * const compiled = East.compileAsync(cleanupAll.toIR(), SQL.Postgres.Implementation);
224
+ * await compiled();
225
+ * ```
226
+ *
227
+ * @internal
228
+ */
229
+ export declare const postgres_close_all: import("@elaraai/east").AsyncPlatformDefinition<[], NullType>;
230
+ /**
231
+ * Node.js implementation of PostgreSQL platform functions.
232
+ *
233
+ * Provides the runtime implementations for PostgreSQL operations.
234
+ * Pass this to East.compileAsync() to enable PostgreSQL functionality.
235
+ */
236
+ export declare const PostgresImpl: PlatformFunction[];
237
+ //# sourceMappingURL=postgres.d.ts.map
@@ -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,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAQ,SAAS,EAAE,WAAW,EAAoB,QAAQ,EAAa,UAAU,IAAI,cAAc,EAAW,MAAM,eAAe,CAAC;AAEhL,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,OAAO,EAKH,UAAU,EAEb,MAAM,YAAY,CAAC;AA4BpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;oBAAqF,CAAC;AAEnH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6G,CAAC;AAEzI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,cAAc,6EAAyE,CAAC;AAErG;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,kBAAkB,+DAAyD,CAAC;AAkFzF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,gBAAgB,EAoI1C,CAAC"}
@@ -0,0 +1,381 @@
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
+ * PostgreSQL platform functions for East Node IO.
7
+ *
8
+ * Provides PostgreSQL database operations for East programs, including
9
+ * connection pooling and parameterized query execution.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import { BlobType, BooleanType, DateTimeType, East, FloatType, IntegerType, isValueOf, match, NullType, SortedMap, StringType as EastStringType, variant } from "@elaraai/east";
14
+ import { EastError } from "@elaraai/east/internal";
15
+ import pg from 'pg';
16
+ import { createHandle, getConnection, closeHandle, closeAllHandles } from '../connection/index.js';
17
+ import { PostgresConfigType, ConnectionHandleType, SqlParametersType, SqlResultType, StringType, SqlParameterType } from './types.js';
18
+ /**
19
+ * Connects to a PostgreSQL database.
20
+ *
21
+ * Creates a connection pool to a PostgreSQL database and returns an
22
+ * opaque handle for use in queries. The connection pool is managed
23
+ * automatically and supports concurrent queries.
24
+ *
25
+ * This is a platform function for the East language, enabling PostgreSQL database
26
+ * operations in East programs running on Node.js.
27
+ *
28
+ * @param config - PostgreSQL connection configuration
29
+ * @returns Connection handle (opaque string)
30
+ *
31
+ * @throws {EastError} When connection fails due to:
32
+ * - Network errors (location: "postgres_connect")
33
+ * - Authentication failures (location: "postgres_connect")
34
+ * - Invalid configuration (location: "postgres_connect")
35
+ * - Database does not exist (location: "postgres_connect")
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { East, StringType, IntegerType } from "@elaraai/east";
40
+ * import { SQL } from "@elaraai/east-node-io";
41
+ *
42
+ * const getUserById = East.function([IntegerType], NullType, ($, userId) => {
43
+ * const config = $.let({
44
+ * host: "localhost",
45
+ * port: 5432n,
46
+ * database: "myapp",
47
+ * user: "postgres",
48
+ * password: "secret",
49
+ * ssl: variant('none', null),
50
+ * maxConnections: variant('none', null),
51
+ * });
52
+ *
53
+ * const conn = $.let(SQL.Postgres.connect(config));
54
+ * $(SQL.Postgres.query(
55
+ * conn,
56
+ * "SELECT name FROM users WHERE id = $1",
57
+ * [variant('Integer', userId)]
58
+ * ));
59
+ * $(SQL.Postgres.close(conn));
60
+ * $.return(null);
61
+ * });
62
+ *
63
+ * const compiled = East.compileAsync(getUserById.toIR(), SQL.Postgres.Implementation);
64
+ * await compiled(42n);
65
+ * ```
66
+ *
67
+ * @remarks
68
+ * - Uses connection pooling for better performance
69
+ * - Default pool size is 10 connections
70
+ * - All queries are asynchronous
71
+ * - Connections are automatically returned to the pool after queries
72
+ */
73
+ export const postgres_connect = East.asyncPlatform("postgres_connect", [PostgresConfigType], ConnectionHandleType);
74
+ /**
75
+ * Executes a SQL query with parameterized values.
76
+ *
77
+ * Runs a SQL query against a PostgreSQL database with parameter binding for
78
+ * safe, injection-free queries. Returns rows as dictionaries mapping column
79
+ * names to typed values, along with metadata about affected rows.
80
+ *
81
+ * This is a platform function for the East language, enabling SQL database
82
+ * operations in East programs running on Node.js.
83
+ *
84
+ * @param handle - Connection handle from postgres_connect()
85
+ * @param sql - SQL query string with $1, $2, etc. placeholders
86
+ * @param params - Query parameters as SqlParameterType array
87
+ * @returns Query results with rows and metadata
88
+ *
89
+ * @throws {EastError} When query fails due to:
90
+ * - Invalid connection handle (location: "postgres_query")
91
+ * - SQL syntax errors (location: "postgres_query")
92
+ * - Connection timeout (location: "postgres_query")
93
+ * - Parameter type mismatch (location: "postgres_query")
94
+ * - Constraint violations (location: "postgres_query")
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * import { East, IntegerType, NullType, variant } from "@elaraai/east";
99
+ * import { SQL } from "@elaraai/east-node-io";
100
+ *
101
+ * const insertUser = East.function([IntegerType], NullType, ($, userId) => {
102
+ * const config = $.let({
103
+ * host: "localhost",
104
+ * port: 5432n,
105
+ * database: "myapp",
106
+ * user: "postgres",
107
+ * password: "secret",
108
+ * ssl: variant('none', null),
109
+ * maxConnections: variant('none', null),
110
+ * });
111
+ * const conn = $.let(SQL.Postgres.connect(config));
112
+ * const result = $.let(SQL.Postgres.query(
113
+ * conn,
114
+ * "INSERT INTO users (name, email) VALUES ($1, $2) RETURNING id",
115
+ * [variant('String', "Alice"), variant('String', "alice@example.com")]
116
+ * ));
117
+ * $(SQL.Postgres.close(conn));
118
+ * return $.return(null);
119
+ * });
120
+ *
121
+ * const compiled = East.compileAsync(insertUser.toIR(), SQL.Postgres.Implementation);
122
+ * await compiled(42n);
123
+ * ```
124
+ *
125
+ * @remarks
126
+ * - Uses $1, $2, $3, etc. for parameter placeholders
127
+ * - NULL values map to {tag: "null", value: {}}
128
+ * - All queries are asynchronous
129
+ * - Parameters prevent SQL injection attacks
130
+ */
131
+ export const postgres_query = East.asyncPlatform("postgres_query", [ConnectionHandleType, StringType, SqlParametersType], SqlResultType);
132
+ /**
133
+ * Closes a PostgreSQL connection pool.
134
+ *
135
+ * Closes the connection pool and releases all resources.
136
+ * All active connections are terminated gracefully.
137
+ *
138
+ * @param handle - Connection handle from postgres_connect()
139
+ *
140
+ * @throws {EastError} When handle is invalid (location: "postgres_close")
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * import { East, NullType, variant } from "@elaraai/east";
145
+ * import { SQL } from "@elaraai/east-node-io";
146
+ *
147
+ * const cleanup = East.function([], NullType, $ => {
148
+ * const config = $.let({
149
+ * host: "localhost",
150
+ * port: 5432n,
151
+ * database: "myapp",
152
+ * user: "postgres",
153
+ * password: "secret",
154
+ * ssl: variant('none', null),
155
+ * maxConnections: variant('none', null),
156
+ * });
157
+ * const conn = $.let(SQL.Postgres.connect(config));
158
+ * // ... do work ...
159
+ * $(SQL.Postgres.close(conn));
160
+ * return $.return(null);
161
+ * });
162
+ *
163
+ * const compiled = East.compileAsync(cleanup.toIR(), SQL.Postgres.Implementation);
164
+ * await compiled();
165
+ * ```
166
+ */
167
+ export const postgres_close = East.asyncPlatform("postgres_close", [ConnectionHandleType], NullType);
168
+ /**
169
+ * Closes all PostgreSQL connections.
170
+ *
171
+ * Closes all active PostgreSQL connection pools and releases all resources.
172
+ * Useful for test cleanup to ensure all connections are closed.
173
+ *
174
+ * @returns Null on success
175
+ *
176
+ * @example
177
+ * ```ts
178
+ * import { East, NullType } from "@elaraai/east";
179
+ * import { SQL } from "@elaraai/east-node-io";
180
+ *
181
+ * const cleanupAll = East.function([], NullType, $ => {
182
+ * // ... test code that may have left connections open ...
183
+ * $(SQL.Postgres.closeAll());
184
+ * return $.return(null);
185
+ * });
186
+ *
187
+ * const compiled = East.compileAsync(cleanupAll.toIR(), SQL.Postgres.Implementation);
188
+ * await compiled();
189
+ * ```
190
+ *
191
+ * @internal
192
+ */
193
+ export const postgres_close_all = East.asyncPlatform("postgres_close_all", [], NullType);
194
+ /**
195
+ * Converts East SQL parameter to native JavaScript value.
196
+ *
197
+ * @param param - East SQL parameter variant
198
+ * @returns JavaScript value for PostgreSQL binding
199
+ * @internal
200
+ */
201
+ function convertParamToNative(param) {
202
+ return match(param, {
203
+ String: (value) => value,
204
+ Integer: (value) => Number(value), // PostgreSQL client handles numbers
205
+ Float: (value) => value,
206
+ Boolean: (value) => value,
207
+ Null: (value) => value,
208
+ Blob: (value) => Buffer.from(value), // Convert Uint8Array to Buffer
209
+ DateTime: (value) => value, // Pass Date object directly to PostgreSQL
210
+ });
211
+ }
212
+ /**
213
+ * Converts native JavaScript value to East SQL parameter variant.
214
+ *
215
+ * @param value - Native JavaScript value from PostgreSQL
216
+ * @param columnOid - PostgreSQL column OID from field metadata
217
+ * @returns East SQL parameter variant
218
+ * @internal
219
+ */
220
+ function convertNativeToParam(value, columnOid) {
221
+ if (isValueOf(value, NullType)) {
222
+ return variant('Null', null);
223
+ }
224
+ else if (((columnOid === null) &&
225
+ isValueOf(value, BooleanType)) || ((columnOid === 16) && // bool
226
+ isValueOf(value, BooleanType))) {
227
+ return variant('Boolean', value);
228
+ }
229
+ else if (((columnOid === null) &&
230
+ isValueOf(value, IntegerType)) || ((columnOid === 20 || columnOid === 21 || columnOid === 23) && // int8, int2, int4
231
+ (isValueOf(value, IntegerType) || isValueOf(value, FloatType)))) {
232
+ return variant('Integer', BigInt(value));
233
+ }
234
+ else if ((columnOid === 700 || columnOid === 701 || columnOid === 1700 || columnOid === null) && // float4, float8, numeric
235
+ isValueOf(value, FloatType)) {
236
+ return variant('Float', value);
237
+ }
238
+ else if ((columnOid === 25 || columnOid === 1042 || columnOid === 1043 || columnOid === null) && // text, bpchar, varchar
239
+ isValueOf(value, EastStringType)) {
240
+ return variant('String', value);
241
+ }
242
+ else if (((columnOid === null) &&
243
+ isValueOf(value, DateTimeType)) || ((columnOid === 1082 || columnOid === 1083 || columnOid === 1114 || columnOid === 1184) && // date, time, timestamp, timestamptz
244
+ isValueOf(value, DateTimeType))) {
245
+ return variant('DateTime', value);
246
+ }
247
+ else if ((columnOid === 17 || columnOid === null) && // bytea
248
+ isValueOf(value, BlobType)) {
249
+ return variant('Blob', value);
250
+ }
251
+ else {
252
+ return variant('Null', null);
253
+ }
254
+ }
255
+ /**
256
+ * Node.js implementation of PostgreSQL platform functions.
257
+ *
258
+ * Provides the runtime implementations for PostgreSQL operations.
259
+ * Pass this to East.compileAsync() to enable PostgreSQL functionality.
260
+ */
261
+ export const PostgresImpl = [
262
+ postgres_connect.implement(async (config) => {
263
+ try {
264
+ const poolConfig = {
265
+ host: config.host,
266
+ port: Number(config.port),
267
+ database: config.database,
268
+ user: config.user,
269
+ password: config.password,
270
+ };
271
+ // Handle optional SSL
272
+ if (config.ssl?.type === 'some' && config.ssl.value) {
273
+ poolConfig.ssl = { rejectUnauthorized: false };
274
+ }
275
+ // Handle optional max connections
276
+ if (config.maxConnections?.type === 'some') {
277
+ poolConfig.max = Number(config.maxConnections.value);
278
+ }
279
+ const pool = new pg.Pool(poolConfig);
280
+ // Test the connection
281
+ const client = await pool.connect();
282
+ client.release();
283
+ return createHandle(pool, async () => {
284
+ await pool.end();
285
+ });
286
+ }
287
+ catch (err) {
288
+ throw new EastError(`PostgreSQL connection failed: ${err.message}`, {
289
+ location: { filename: "postgres_connect", line: 0n, column: 0n },
290
+ cause: err
291
+ });
292
+ }
293
+ }),
294
+ postgres_query.implement(async (handle, sql, params) => {
295
+ try {
296
+ const pool = getConnection(handle);
297
+ // Convert East parameters to native values
298
+ const nativeParams = params.map(convertParamToNative);
299
+ // Execute the query
300
+ const result = await pool.query(sql, nativeParams);
301
+ // Validate result structure
302
+ if (!result || typeof result !== 'object') {
303
+ throw new EastError('Invalid result from PostgreSQL query', {
304
+ location: { filename: "postgres_query", line: 0n, column: 0n }
305
+ });
306
+ }
307
+ if (!Array.isArray(result.rows)) {
308
+ throw new EastError('PostgreSQL query result missing rows array', {
309
+ location: { filename: "postgres_query", line: 0n, column: 0n }
310
+ });
311
+ }
312
+ // PostgreSQL provides a `command` field indicating query type
313
+ const command = result.command?.toUpperCase();
314
+ if (command === 'SELECT') {
315
+ // Get column metadata for type information
316
+ const columnOidMap = new Map();
317
+ if (result.fields) {
318
+ for (const field of result.fields) {
319
+ columnOidMap.set(field.name, field.dataTypeID);
320
+ }
321
+ }
322
+ // Convert rows to East format (SortedMap objects)
323
+ const eastRows = result.rows.map((row) => {
324
+ const eastRow = new SortedMap();
325
+ for (const [key, value] of Object.entries(row)) {
326
+ const columnOid = columnOidMap.get(key) || null;
327
+ eastRow.set(key, convertNativeToParam(value, columnOid));
328
+ }
329
+ return eastRow;
330
+ });
331
+ return variant('select', { rows: eastRows });
332
+ }
333
+ else if (command === 'INSERT') {
334
+ return variant('insert', {
335
+ rowsAffected: BigInt(result.rowCount ?? 0),
336
+ lastInsertId: variant('none', null) // PostgreSQL doesn't provide lastInsertId automatically
337
+ });
338
+ }
339
+ else if (command === 'UPDATE') {
340
+ return variant('update', {
341
+ rowsAffected: BigInt(result.rowCount ?? 0)
342
+ });
343
+ }
344
+ else if (command === 'DELETE') {
345
+ return variant('delete', {
346
+ rowsAffected: BigInt(result.rowCount ?? 0)
347
+ });
348
+ }
349
+ else {
350
+ // For other commands (CREATE, DROP, ALTER, etc.), return as select with empty rows
351
+ // This maintains compatibility with DDL statements
352
+ return variant('select', { rows: [] });
353
+ }
354
+ }
355
+ catch (err) {
356
+ throw new EastError(`PostgreSQL query failed: ${err.message}`, {
357
+ location: { filename: "postgres_query", line: 0n, column: 0n },
358
+ cause: err
359
+ });
360
+ }
361
+ }),
362
+ postgres_close.implement(async (handle) => {
363
+ try {
364
+ const pool = getConnection(handle);
365
+ await pool.end();
366
+ closeHandle(handle);
367
+ return null;
368
+ }
369
+ catch (err) {
370
+ throw new EastError(`PostgreSQL close failed: ${err.message}`, {
371
+ location: { filename: "postgres_close", line: 0n, column: 0n },
372
+ cause: err
373
+ });
374
+ }
375
+ }),
376
+ postgres_close_all.implement(async () => {
377
+ await closeAllHandles();
378
+ return null;
379
+ }),
380
+ ];
381
+ //# sourceMappingURL=postgres.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres.js","sourceRoot":"","sources":["../../src/sql/postgres.ts"],"names":[],"mappings":"AAAA;;;GAGG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