@elaraai/east-node-io 0.0.1-beta.0 → 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 +8 -8
@@ -0,0 +1,217 @@
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
+ * SQLite platform functions for East Node IO.
7
+ *
8
+ * Provides SQLite database operations for East programs, including
9
+ * connection management and parameterized query execution.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import { BlobType, BooleanType, DateTimeType, FloatType, IntegerType, NullType } from "@elaraai/east";
14
+ import type { PlatformFunction } from "@elaraai/east/internal";
15
+ import { StringType } from './types.js';
16
+ /**
17
+ * Connects to a SQLite database.
18
+ *
19
+ * Opens a SQLite database file and returns an opaque handle for use in queries.
20
+ * Supports both file-based and in-memory databases.
21
+ *
22
+ * This is a platform function for the East language, enabling SQLite database
23
+ * operations in East programs running on Node.js.
24
+ *
25
+ * @param config - SQLite connection configuration
26
+ * @returns Connection handle (opaque string)
27
+ *
28
+ * @throws {EastError} When connection fails due to:
29
+ * - Invalid file path (location: "sqlite_connect")
30
+ * - Permission denied (location: "sqlite_connect")
31
+ * - Database file is locked (location: "sqlite_connect")
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * import { East, StringType } from "@elaraai/east";
36
+ * import { SQL } from "@elaraai/east-node-io";
37
+ *
38
+ * const queryUsers = East.function([], NullType, ($) => {
39
+ * const config = $.let({
40
+ * path: "./mydb.sqlite",
41
+ * readOnly: variant('none', null),
42
+ * memory: variant('none', null),
43
+ * });
44
+ *
45
+ * const conn = $.let(SQL.SQLite.connect(config));
46
+ * $(SQL.SQLite.query(
47
+ * conn,
48
+ * "SELECT name FROM users LIMIT 1",
49
+ * []
50
+ * ));
51
+ * $(SQL.SQLite.close(conn));
52
+ * $.return(null);
53
+ * });
54
+ *
55
+ * const compiled = East.compileAsync(queryUsers.toIR(), SQL.SQLite.Implementation);
56
+ * await compiled();
57
+ * ```
58
+ *
59
+ * @remarks
60
+ * - SQLite uses single connection per handle (no connection pooling)
61
+ * - Database file is created if it doesn't exist (unless readOnly is true)
62
+ * - Use path ":memory:" for in-memory database
63
+ * - All queries are synchronous but wrapped in async for consistency
64
+ */
65
+ export declare const sqlite_connect: import("@elaraai/east").AsyncPlatformDefinition<[import("@elaraai/east").StructType<{
66
+ path: StringType;
67
+ readOnly: import("@elaraai/east").OptionType<BooleanType>;
68
+ memory: import("@elaraai/east").OptionType<BooleanType>;
69
+ }>], StringType>;
70
+ /**
71
+ * Executes a SQL query with parameterized values.
72
+ *
73
+ * Runs a SQL query against a SQLite database with parameter binding for
74
+ * safe, injection-free queries. Returns rows as dictionaries mapping column
75
+ * names to typed values, along with metadata about affected rows.
76
+ *
77
+ * This is a platform function for the East language, enabling SQL database
78
+ * operations in East programs running on Node.js.
79
+ *
80
+ * @param handle - Connection handle from sqlite_connect()
81
+ * @param sql - SQL query string with ? placeholders
82
+ * @param params - Query parameters as SqlParameterType array
83
+ * @returns Query results with rows and metadata
84
+ *
85
+ * @throws {EastError} When query fails due to:
86
+ * - Invalid connection handle (location: "sqlite_query")
87
+ * - SQL syntax errors (location: "sqlite_query")
88
+ * - Constraint violations (location: "sqlite_query")
89
+ * - Parameter count mismatch (location: "sqlite_query")
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * import { East, IntegerType, NullType, variant } from "@elaraai/east";
94
+ * import { SQL } from "@elaraai/east-node-io";
95
+ *
96
+ * const insertUser = East.function([IntegerType], NullType, ($, userId) => {
97
+ * const config = $.let({
98
+ * path: "./mydb.sqlite",
99
+ * readOnly: variant('none', null),
100
+ * memory: variant('none', null),
101
+ * });
102
+ * const conn = $.let(SQL.SQLite.connect(config));
103
+ * const result = $.let(SQL.SQLite.query(
104
+ * conn,
105
+ * "INSERT INTO users (name, email) VALUES (?, ?)",
106
+ * [variant('String', "Alice"), variant('String', "alice@example.com")]
107
+ * ));
108
+ * $(SQL.SQLite.close(conn));
109
+ * return $.return(null);
110
+ * });
111
+ *
112
+ * const compiled = East.compileAsync(insertUser.toIR(), SQL.SQLite.Implementation);
113
+ * await compiled(42n);
114
+ * ```
115
+ *
116
+ * @remarks
117
+ * - Uses `?` placeholders for parameters (not $1, $2 like PostgreSQL)
118
+ * - NULL values map to {tag: "null", value: {}}
119
+ * - All queries are synchronous but wrapped in async for consistency
120
+ */
121
+ export declare const sqlite_query: import("@elaraai/east").AsyncPlatformDefinition<[StringType, StringType, import("@elaraai/east").ArrayType<import("@elaraai/east").VariantType<{
122
+ Null: NullType;
123
+ Boolean: BooleanType;
124
+ Integer: IntegerType;
125
+ Float: FloatType;
126
+ String: StringType;
127
+ DateTime: DateTimeType;
128
+ Blob: BlobType;
129
+ }>>], import("@elaraai/east").VariantType<{
130
+ select: import("@elaraai/east").StructType<{
131
+ rows: import("@elaraai/east").ArrayType<import("@elaraai/east").DictType<StringType, import("@elaraai/east").VariantType<{
132
+ Null: NullType;
133
+ Boolean: BooleanType;
134
+ Integer: IntegerType;
135
+ Float: FloatType;
136
+ String: StringType;
137
+ DateTime: DateTimeType;
138
+ Blob: BlobType;
139
+ }>>>;
140
+ }>;
141
+ insert: import("@elaraai/east").StructType<{
142
+ rowsAffected: IntegerType;
143
+ lastInsertId: import("@elaraai/east").OptionType<IntegerType>;
144
+ }>;
145
+ update: import("@elaraai/east").StructType<{
146
+ rowsAffected: IntegerType;
147
+ }>;
148
+ delete: import("@elaraai/east").StructType<{
149
+ rowsAffected: IntegerType;
150
+ }>;
151
+ }>>;
152
+ /**
153
+ * Closes a SQLite database connection.
154
+ *
155
+ * Closes the database connection and releases all resources.
156
+ * The handle becomes invalid after this operation.
157
+ *
158
+ * @param handle - Connection handle from sqlite_connect()
159
+ *
160
+ * @throws {EastError} When handle is invalid (location: "sqlite_close")
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * import { East, NullType, variant } from "@elaraai/east";
165
+ * import { SQL } from "@elaraai/east-node-io";
166
+ *
167
+ * const cleanup = East.function([], NullType, $ => {
168
+ * const config = $.let({
169
+ * path: "./mydb.sqlite",
170
+ * readOnly: variant('none', null),
171
+ * memory: variant('none', null),
172
+ * });
173
+ * const conn = $.let(SQL.SQLite.connect(config));
174
+ * // ... do work ...
175
+ * $(SQL.SQLite.close(conn));
176
+ * return $.return(null);
177
+ * });
178
+ *
179
+ * const compiled = East.compileAsync(cleanup.toIR(), SQL.SQLite.Implementation);
180
+ * await compiled();
181
+ * ```
182
+ */
183
+ export declare const sqlite_close: import("@elaraai/east").AsyncPlatformDefinition<[StringType], NullType>;
184
+ /**
185
+ * Closes all SQLite connections.
186
+ *
187
+ * Closes all active SQLite connections and releases all resources.
188
+ * Useful for test cleanup to ensure all connections are closed.
189
+ *
190
+ * @returns Null on success
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * import { East, NullType } from "@elaraai/east";
195
+ * import { SQL } from "@elaraai/east-node-io";
196
+ *
197
+ * const cleanupAll = East.function([], NullType, $ => {
198
+ * // ... test code that may have left connections open ...
199
+ * $(SQL.SQLite.closeAll());
200
+ * return $.return(null);
201
+ * });
202
+ *
203
+ * const compiled = East.compileAsync(cleanupAll.toIR(), SQL.SQLite.Implementation);
204
+ * await compiled();
205
+ * ```
206
+ *
207
+ * @internal
208
+ */
209
+ export declare const sqlite_close_all: import("@elaraai/east").AsyncPlatformDefinition<[], NullType>;
210
+ /**
211
+ * Node.js implementation of SQLite platform functions.
212
+ *
213
+ * Provides the runtime implementations for SQLite operations.
214
+ * Pass this to East.compileAsync() to enable SQLite functionality.
215
+ */
216
+ export declare const SqliteImpl: PlatformFunction[];
217
+ //# sourceMappingURL=sqlite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/sql/sqlite.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAS,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAQ,SAAS,EAAE,WAAW,EAAa,QAAQ,EAAsB,MAAM,eAAe,CAAC;AAElJ,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,OAAO,EAKH,UAAU,EAEb,MAAM,YAAY,CAAC;AAyBpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,eAAO,MAAM,cAAc;;;;gBAAiF,CAAC;AAE7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA2G,CAAC;AAErI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,YAAY,yEAAuE,CAAC;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,gBAAgB,+DAAuD,CAAC;AAmFrF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,gBAAgB,EAqIxC,CAAC"}
@@ -0,0 +1,366 @@
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
+ * SQLite platform functions for East Node IO.
7
+ *
8
+ * Provides SQLite database operations for East programs, including
9
+ * connection management and parameterized query execution.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import { match, BlobType, BooleanType, DateTimeType, East, FloatType, IntegerType, isValueOf, NullType, SortedMap, variant } from "@elaraai/east";
14
+ import { EastError } from "@elaraai/east/internal";
15
+ import Database from 'better-sqlite3';
16
+ import { createHandle, getConnection, closeHandle, closeAllHandles } from '../connection/index.js';
17
+ import { SqliteConfigType, ConnectionHandleType, SqlParametersType, SqlResultType, StringType, SqlParameterType } from './types.js';
18
+ /**
19
+ * Connects to a SQLite database.
20
+ *
21
+ * Opens a SQLite database file and returns an opaque handle for use in queries.
22
+ * Supports both file-based and in-memory databases.
23
+ *
24
+ * This is a platform function for the East language, enabling SQLite database
25
+ * operations in East programs running on Node.js.
26
+ *
27
+ * @param config - SQLite connection configuration
28
+ * @returns Connection handle (opaque string)
29
+ *
30
+ * @throws {EastError} When connection fails due to:
31
+ * - Invalid file path (location: "sqlite_connect")
32
+ * - Permission denied (location: "sqlite_connect")
33
+ * - Database file is locked (location: "sqlite_connect")
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { East, StringType } from "@elaraai/east";
38
+ * import { SQL } from "@elaraai/east-node-io";
39
+ *
40
+ * const queryUsers = East.function([], NullType, ($) => {
41
+ * const config = $.let({
42
+ * path: "./mydb.sqlite",
43
+ * readOnly: variant('none', null),
44
+ * memory: variant('none', null),
45
+ * });
46
+ *
47
+ * const conn = $.let(SQL.SQLite.connect(config));
48
+ * $(SQL.SQLite.query(
49
+ * conn,
50
+ * "SELECT name FROM users LIMIT 1",
51
+ * []
52
+ * ));
53
+ * $(SQL.SQLite.close(conn));
54
+ * $.return(null);
55
+ * });
56
+ *
57
+ * const compiled = East.compileAsync(queryUsers.toIR(), SQL.SQLite.Implementation);
58
+ * await compiled();
59
+ * ```
60
+ *
61
+ * @remarks
62
+ * - SQLite uses single connection per handle (no connection pooling)
63
+ * - Database file is created if it doesn't exist (unless readOnly is true)
64
+ * - Use path ":memory:" for in-memory database
65
+ * - All queries are synchronous but wrapped in async for consistency
66
+ */
67
+ export const sqlite_connect = East.asyncPlatform("sqlite_connect", [SqliteConfigType], ConnectionHandleType);
68
+ /**
69
+ * Executes a SQL query with parameterized values.
70
+ *
71
+ * Runs a SQL query against a SQLite database with parameter binding for
72
+ * safe, injection-free queries. Returns rows as dictionaries mapping column
73
+ * names to typed values, along with metadata about affected rows.
74
+ *
75
+ * This is a platform function for the East language, enabling SQL database
76
+ * operations in East programs running on Node.js.
77
+ *
78
+ * @param handle - Connection handle from sqlite_connect()
79
+ * @param sql - SQL query string with ? placeholders
80
+ * @param params - Query parameters as SqlParameterType array
81
+ * @returns Query results with rows and metadata
82
+ *
83
+ * @throws {EastError} When query fails due to:
84
+ * - Invalid connection handle (location: "sqlite_query")
85
+ * - SQL syntax errors (location: "sqlite_query")
86
+ * - Constraint violations (location: "sqlite_query")
87
+ * - Parameter count mismatch (location: "sqlite_query")
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * import { East, IntegerType, NullType, variant } from "@elaraai/east";
92
+ * import { SQL } from "@elaraai/east-node-io";
93
+ *
94
+ * const insertUser = East.function([IntegerType], NullType, ($, userId) => {
95
+ * const config = $.let({
96
+ * path: "./mydb.sqlite",
97
+ * readOnly: variant('none', null),
98
+ * memory: variant('none', null),
99
+ * });
100
+ * const conn = $.let(SQL.SQLite.connect(config));
101
+ * const result = $.let(SQL.SQLite.query(
102
+ * conn,
103
+ * "INSERT INTO users (name, email) VALUES (?, ?)",
104
+ * [variant('String', "Alice"), variant('String', "alice@example.com")]
105
+ * ));
106
+ * $(SQL.SQLite.close(conn));
107
+ * return $.return(null);
108
+ * });
109
+ *
110
+ * const compiled = East.compileAsync(insertUser.toIR(), SQL.SQLite.Implementation);
111
+ * await compiled(42n);
112
+ * ```
113
+ *
114
+ * @remarks
115
+ * - Uses `?` placeholders for parameters (not $1, $2 like PostgreSQL)
116
+ * - NULL values map to {tag: "null", value: {}}
117
+ * - All queries are synchronous but wrapped in async for consistency
118
+ */
119
+ export const sqlite_query = East.asyncPlatform("sqlite_query", [ConnectionHandleType, StringType, SqlParametersType], SqlResultType);
120
+ /**
121
+ * Closes a SQLite database connection.
122
+ *
123
+ * Closes the database connection and releases all resources.
124
+ * The handle becomes invalid after this operation.
125
+ *
126
+ * @param handle - Connection handle from sqlite_connect()
127
+ *
128
+ * @throws {EastError} When handle is invalid (location: "sqlite_close")
129
+ *
130
+ * @example
131
+ * ```ts
132
+ * import { East, NullType, variant } from "@elaraai/east";
133
+ * import { SQL } from "@elaraai/east-node-io";
134
+ *
135
+ * const cleanup = East.function([], NullType, $ => {
136
+ * const config = $.let({
137
+ * path: "./mydb.sqlite",
138
+ * readOnly: variant('none', null),
139
+ * memory: variant('none', null),
140
+ * });
141
+ * const conn = $.let(SQL.SQLite.connect(config));
142
+ * // ... do work ...
143
+ * $(SQL.SQLite.close(conn));
144
+ * return $.return(null);
145
+ * });
146
+ *
147
+ * const compiled = East.compileAsync(cleanup.toIR(), SQL.SQLite.Implementation);
148
+ * await compiled();
149
+ * ```
150
+ */
151
+ export const sqlite_close = East.asyncPlatform("sqlite_close", [ConnectionHandleType], NullType);
152
+ /**
153
+ * Closes all SQLite connections.
154
+ *
155
+ * Closes all active SQLite connections and releases all resources.
156
+ * Useful for test cleanup to ensure all connections are closed.
157
+ *
158
+ * @returns Null on success
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * import { East, NullType } from "@elaraai/east";
163
+ * import { SQL } from "@elaraai/east-node-io";
164
+ *
165
+ * const cleanupAll = East.function([], NullType, $ => {
166
+ * // ... test code that may have left connections open ...
167
+ * $(SQL.SQLite.closeAll());
168
+ * return $.return(null);
169
+ * });
170
+ *
171
+ * const compiled = East.compileAsync(cleanupAll.toIR(), SQL.SQLite.Implementation);
172
+ * await compiled();
173
+ * ```
174
+ *
175
+ * @internal
176
+ */
177
+ export const sqlite_close_all = East.asyncPlatform("sqlite_close_all", [], NullType);
178
+ /**
179
+ * Converts East SQL parameter to native JavaScript value.
180
+ *
181
+ * @param param - East SQL parameter variant
182
+ * @returns JavaScript value for SQLite binding
183
+ * @internal
184
+ */
185
+ function convertParamToNative(param) {
186
+ return match(param, {
187
+ String: (value) => value,
188
+ Integer: (value) => Number(value), // Convert BigInt to Number for SQLite
189
+ Float: (value) => value,
190
+ Boolean: (value) => value ? 1 : 0, // SQLite uses 0/1 for booleans
191
+ Null: (value) => value,
192
+ Blob: (value) => Buffer.from(value), // Convert Uint8Array to Buffer
193
+ DateTime: (value) => value.toISOString(), // Store as ISO string
194
+ });
195
+ }
196
+ /**
197
+ * Converts native JavaScript value to East SQL parameter variant.
198
+ *
199
+ * @param value - Native JavaScript value from SQLite
200
+ * @param columnType - SQLite column type from statement metadata
201
+ * @returns East SQL parameter variant
202
+ * @internal
203
+ */
204
+ function convertNativeToParam(value, columnType) {
205
+ if (isValueOf(value, NullType)) {
206
+ return variant('Null', null);
207
+ }
208
+ else if (((columnType === null) &&
209
+ isValueOf(value, BooleanType)) || ((columnType === 'BOOLEAN') &&
210
+ (isValueOf(value, BooleanType) || isValueOf(value, FloatType)))) {
211
+ return variant('Boolean', value ? true : false);
212
+ }
213
+ else if (((columnType === null) &&
214
+ isValueOf(value, IntegerType)) || ((columnType === 'INTEGER' || columnType === 'INT' || columnType === 'TINYINT' || columnType === 'SMALLINT' || columnType === 'MEDIUMINT' || columnType === 'BIGINT' || columnType === 'UNSIGNED BIG INT' || columnType === 'INT2' || columnType === 'INT8') &&
215
+ (isValueOf(value, IntegerType) || isValueOf(value, FloatType)))) {
216
+ return variant('Integer', BigInt(value));
217
+ }
218
+ else if ((columnType === 'REAL' || columnType === 'DOUBLE' || columnType === 'DOUBLE PRECISION' || columnType === 'FLOAT' || columnType === 'NUMERIC' || columnType === 'DECIMAL' || columnType === null) &&
219
+ isValueOf(value, FloatType)) {
220
+ return variant('Float', value);
221
+ }
222
+ else if ((columnType === 'TEXT' || columnType === 'CHARACTER' || columnType === 'VARCHAR' || columnType === 'VARYING CHARACTER' || columnType === 'NCHAR' || columnType === 'NATIVE CHARACTER' || columnType === 'NVARCHAR' || columnType === 'CLOB' || columnType === 'DATE' || columnType === null) &&
223
+ isValueOf(value, StringType)) {
224
+ return variant('String', value);
225
+ }
226
+ else if (((columnType === null) &&
227
+ isValueOf(value, DateTimeType)) || ((columnType === 'DATETIME') &&
228
+ (isValueOf(value, DateTimeType) || isValueOf(value, StringType)))) {
229
+ return variant('DateTime', new Date(value));
230
+ }
231
+ else if ((columnType === 'BLOB' || columnType === null) &&
232
+ isValueOf(value, BlobType)) {
233
+ return variant('Blob', value);
234
+ }
235
+ else {
236
+ return variant('Null', null);
237
+ }
238
+ }
239
+ /**
240
+ * Node.js implementation of SQLite platform functions.
241
+ *
242
+ * Provides the runtime implementations for SQLite operations.
243
+ * Pass this to East.compileAsync() to enable SQLite functionality.
244
+ */
245
+ export const SqliteImpl = [
246
+ sqlite_connect.implement(async (config) => {
247
+ try {
248
+ const path = config.path || ':memory:';
249
+ const readOnly = config.readOnly?.type === 'some' ? config.readOnly.value : false;
250
+ const memory = config.memory?.type === 'some' ? config.memory.value : false;
251
+ const actualPath = memory ? ':memory:' : path;
252
+ const db = new Database(actualPath, {
253
+ readonly: readOnly,
254
+ fileMustExist: readOnly,
255
+ });
256
+ // Enable foreign keys by default
257
+ db.pragma('foreign_keys = ON');
258
+ return await Promise.resolve(createHandle(db, async () => {
259
+ await Promise.resolve(db.close());
260
+ }));
261
+ }
262
+ catch (err) {
263
+ throw new EastError(`SQLite connection failed: ${err.message}`, {
264
+ location: { filename: "sqlite_connect", line: 0n, column: 0n },
265
+ cause: err
266
+ });
267
+ }
268
+ }),
269
+ sqlite_query.implement(async (handle, sql, params) => {
270
+ try {
271
+ const db = await Promise.resolve(getConnection(handle));
272
+ // Convert East parameters to native values
273
+ const nativeParams = params.map(convertParamToNative);
274
+ // Prepare the statement
275
+ const stmt = db.prepare(sql);
276
+ // Use the statement's reader property to determine if it returns rows
277
+ // This is provided by better-sqlite3 and indicates SELECT-type queries
278
+ if (stmt.reader) {
279
+ // For SELECT queries, use all() which returns rows
280
+ const rows = stmt.all(...nativeParams);
281
+ if (!Array.isArray(rows)) {
282
+ throw new EastError('SQLite all() did not return an array', {
283
+ location: { filename: "sqlite_query", line: 0n, column: 0n }
284
+ });
285
+ }
286
+ // Get column metadata for type information
287
+ const columns = stmt.columns();
288
+ const columnTypeMap = new Map();
289
+ for (const col of columns) {
290
+ columnTypeMap.set(col.name, col.type);
291
+ }
292
+ // Convert rows to East format (SortedMap objects)
293
+ const eastRows = rows.map((row) => {
294
+ const eastRow = new SortedMap();
295
+ for (const [key, value] of Object.entries(row)) {
296
+ const columnType = columnTypeMap.get(key) || null;
297
+ eastRow.set(key, convertNativeToParam(value, columnType));
298
+ }
299
+ return eastRow;
300
+ });
301
+ return variant('select', { rows: eastRows });
302
+ }
303
+ else {
304
+ // For INSERT/UPDATE/DELETE, use run() which returns RunResult
305
+ const info = stmt.run(...nativeParams);
306
+ // Validate RunResult structure
307
+ if (typeof info !== 'object' || info === null || !('changes' in info)) {
308
+ throw new EastError('SQLite run() did not return valid RunResult', {
309
+ location: { filename: "sqlite_query", line: 0n, column: 0n }
310
+ });
311
+ }
312
+ // Determine query type from SQL to return the appropriate variant
313
+ const trimmedSql = sql.trim().toUpperCase();
314
+ if (trimmedSql.startsWith('INSERT')) {
315
+ return variant('insert', {
316
+ rowsAffected: BigInt(info.changes),
317
+ lastInsertId: info.lastInsertRowid !== undefined && info.lastInsertRowid !== 0
318
+ ? variant('some', BigInt(info.lastInsertRowid))
319
+ : variant('none', null)
320
+ });
321
+ }
322
+ else if (trimmedSql.startsWith('UPDATE')) {
323
+ return variant('update', {
324
+ rowsAffected: BigInt(info.changes)
325
+ });
326
+ }
327
+ else if (trimmedSql.startsWith('DELETE')) {
328
+ return variant('delete', {
329
+ rowsAffected: BigInt(info.changes)
330
+ });
331
+ }
332
+ else {
333
+ // Other mutating queries (CREATE, DROP, ALTER, etc.) - treat as update
334
+ return variant('update', {
335
+ rowsAffected: BigInt(info.changes)
336
+ });
337
+ }
338
+ }
339
+ }
340
+ catch (err) {
341
+ throw new EastError(`SQLite query failed: ${err.message}`, {
342
+ location: { filename: "sqlite_query", line: 0n, column: 0n },
343
+ cause: err
344
+ });
345
+ }
346
+ }),
347
+ sqlite_close.implement(async (handle) => {
348
+ try {
349
+ const db = await Promise.resolve(getConnection(handle));
350
+ db.close();
351
+ closeHandle(handle);
352
+ return null;
353
+ }
354
+ catch (err) {
355
+ throw new EastError(`SQLite close failed: ${err.message}`, {
356
+ location: { filename: "sqlite_close", line: 0n, column: 0n },
357
+ cause: err
358
+ });
359
+ }
360
+ }),
361
+ sqlite_close_all.implement(async () => {
362
+ await closeAllHandles();
363
+ return null;
364
+ }),
365
+ ];
366
+ //# sourceMappingURL=sqlite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.js","sourceRoot":"","sources":["../../src/sql/sqlite.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGlJ,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,QAAQ,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