alink-cli 0.7.2 → 0.7.4
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 +3 -6
- package/bin/agentlink-account.js +133 -0
- package/bin/agentlink.js +95 -12
- package/dist/Config-Bj2ZPCsP.mjs +1221 -0
- package/dist/Config-Bj2ZPCsP.mjs.map +1 -0
- package/dist/NodeHttpServer-BGJlR_Kf.mjs +826 -0
- package/dist/NodeHttpServer-BGJlR_Kf.mjs.map +1 -0
- package/dist/NodeServices-DDZTiw5K.mjs +1984 -0
- package/dist/NodeServices-DDZTiw5K.mjs.map +1 -0
- package/dist/NodeSocket-08w4osAf.mjs +11198 -0
- package/dist/NodeSocket-08w4osAf.mjs.map +1 -0
- package/dist/NodeSqliteClient-Byu521pt.mjs +578 -0
- package/dist/NodeSqliteClient-Byu521pt.mjs.map +1 -0
- package/dist/Schema-B3i-HrZQ.mjs +40423 -0
- package/dist/Schema-B3i-HrZQ.mjs.map +1 -0
- package/dist/SqlClient-DcM69ZvI.mjs +1554 -0
- package/dist/SqlClient-DcM69ZvI.mjs.map +1 -0
- package/dist/bin.mjs +47577 -26766
- package/dist/bin.mjs.map +1 -1
- package/package.json +4 -3
- package/dist/NodeSqliteClient-BUlNQAY0.mjs +0 -191
- package/dist/NodeSqliteClient-BUlNQAY0.mjs.map +0 -1
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { B as Union, Cs as void_, D as String, Da as as, Es as withFiber, Ga as die, Io as orDie, Ot as optional, Qa as flatMap, Qd as hasProperty, So as map, Xo as scope, Ya as fail, _ as Natural, _c as Scope, bs as uninterruptibleMask, c as Defect, ed as get, gf as identity, gs as try_, id as getUnsafe, j as TaggedErrorClass, ki as make$1, lo as gen, ns as succeed, rc as effect, sr as die$1, ss as tap, su as minutes, ta as getCurrent, to as fn, uc as provide, vc as addFinalizer, ya as acquireUseRelease } from "./Schema-B3i-HrZQ.mjs";
|
|
4
|
+
import { h as unwrap } from "./Config-Bj2ZPCsP.mjs";
|
|
5
|
+
import { a as makeCompilerSqlite, d as make$2, i as defaultTransforms, n as SqlClient, o as layer$1, r as make$3, s as get$1, t as SafeIntegers } from "./SqlClient-DcM69ZvI.mjs";
|
|
6
|
+
import * as NodeSqlite from "node:sqlite";
|
|
7
|
+
//#region ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=a18f963109656ddbeb2a99ca45f942ecf54830986259eb01ce6a970421c9c6a9/node_modules/effect/dist/unstable/sql/SqlError.js
|
|
8
|
+
/**
|
|
9
|
+
* Defines structured failures for SQL clients and driver integrations.
|
|
10
|
+
*
|
|
11
|
+
* `SqlError` wraps the different reasons a SQL operation can fail, such as
|
|
12
|
+
* connection, authentication, authorization, syntax, constraint, or transaction
|
|
13
|
+
* problems. Each reason keeps the original cause, optional message and
|
|
14
|
+
* operation metadata, and whether retrying may succeed. This module also
|
|
15
|
+
* includes schemas, guards, a SQLite error classifier, and the
|
|
16
|
+
* `ResultLengthMismatch` error used by ordered batched SQL resolvers.
|
|
17
|
+
*
|
|
18
|
+
* @since 4.0.0
|
|
19
|
+
*/
|
|
20
|
+
const TypeId$1 = "~effect/sql/SqlError";
|
|
21
|
+
const ReasonTypeId = "~effect/sql/SqlError/Reason";
|
|
22
|
+
const ReasonFields = {
|
|
23
|
+
cause: /*#__PURE__*/ Defect(),
|
|
24
|
+
message: /*#__PURE__*/ optional(String),
|
|
25
|
+
operation: /*#__PURE__*/ optional(String)
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* SQL error reason for connection or open failures; marked retryable.
|
|
29
|
+
*
|
|
30
|
+
* @category errors
|
|
31
|
+
* @since 4.0.0
|
|
32
|
+
*/
|
|
33
|
+
var ConnectionError = class extends TaggedErrorClass("effect/sql/SqlError/ConnectionError")("ConnectionError", ReasonFields) {
|
|
34
|
+
/**
|
|
35
|
+
* Marks this value as a structured SQL error reason for runtime guards.
|
|
36
|
+
*
|
|
37
|
+
* @since 4.0.0
|
|
38
|
+
*/
|
|
39
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
40
|
+
/**
|
|
41
|
+
* Indicates whether retrying the failed SQL operation may succeed.
|
|
42
|
+
*
|
|
43
|
+
* @since 4.0.0
|
|
44
|
+
*/
|
|
45
|
+
get isRetryable() {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* SQL error reason for authentication failures such as invalid credentials; not
|
|
51
|
+
* marked retryable.
|
|
52
|
+
*
|
|
53
|
+
* @category errors
|
|
54
|
+
* @since 4.0.0
|
|
55
|
+
*/
|
|
56
|
+
var AuthenticationError = class extends TaggedErrorClass("effect/sql/SqlError/AuthenticationError")("AuthenticationError", ReasonFields) {
|
|
57
|
+
/**
|
|
58
|
+
* Marks this value as a structured SQL error reason for runtime guards.
|
|
59
|
+
*
|
|
60
|
+
* @since 4.0.0
|
|
61
|
+
*/
|
|
62
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
63
|
+
/**
|
|
64
|
+
* Indicates whether retrying the failed SQL operation may succeed.
|
|
65
|
+
*
|
|
66
|
+
* @since 4.0.0
|
|
67
|
+
*/
|
|
68
|
+
get isRetryable() {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* SQL error reason for authorization or permission failures; not marked
|
|
74
|
+
* retryable.
|
|
75
|
+
*
|
|
76
|
+
* @category errors
|
|
77
|
+
* @since 4.0.0
|
|
78
|
+
*/
|
|
79
|
+
var AuthorizationError = class extends TaggedErrorClass("effect/sql/SqlError/AuthorizationError")("AuthorizationError", ReasonFields) {
|
|
80
|
+
/**
|
|
81
|
+
* Marks this value as a structured SQL error reason for runtime guards.
|
|
82
|
+
*
|
|
83
|
+
* @since 4.0.0
|
|
84
|
+
*/
|
|
85
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
86
|
+
/**
|
|
87
|
+
* Indicates whether retrying the failed SQL operation may succeed.
|
|
88
|
+
*
|
|
89
|
+
* @since 4.0.0
|
|
90
|
+
*/
|
|
91
|
+
get isRetryable() {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* SQL error reason for invalid SQL syntax; not marked retryable.
|
|
97
|
+
*
|
|
98
|
+
* @category errors
|
|
99
|
+
* @since 4.0.0
|
|
100
|
+
*/
|
|
101
|
+
var SqlSyntaxError = class extends TaggedErrorClass("effect/sql/SqlError/SqlSyntaxError")("SqlSyntaxError", ReasonFields) {
|
|
102
|
+
/**
|
|
103
|
+
* Marks this value as a structured SQL error reason for runtime guards.
|
|
104
|
+
*
|
|
105
|
+
* @since 4.0.0
|
|
106
|
+
*/
|
|
107
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
108
|
+
/**
|
|
109
|
+
* Indicates whether retrying the failed SQL operation may succeed.
|
|
110
|
+
*
|
|
111
|
+
* @since 4.0.0
|
|
112
|
+
*/
|
|
113
|
+
get isRetryable() {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const UniqueViolationFields = {
|
|
118
|
+
...ReasonFields,
|
|
119
|
+
constraint: String
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* SQL error reason for a unique constraint violation, including the violated
|
|
123
|
+
* constraint identifier; not marked retryable.
|
|
124
|
+
*
|
|
125
|
+
* @category errors
|
|
126
|
+
* @since 4.0.0
|
|
127
|
+
*/
|
|
128
|
+
var UniqueViolation = class extends TaggedErrorClass("effect/sql/SqlError/UniqueViolation")("UniqueViolation", UniqueViolationFields) {
|
|
129
|
+
/**
|
|
130
|
+
* Marks this value as a structured SQL error reason for runtime guards.
|
|
131
|
+
*
|
|
132
|
+
* @since 4.0.0
|
|
133
|
+
*/
|
|
134
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
135
|
+
/**
|
|
136
|
+
* Indicates whether retrying the failed SQL operation may succeed.
|
|
137
|
+
*
|
|
138
|
+
* @since 4.0.0
|
|
139
|
+
*/
|
|
140
|
+
get isRetryable() {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* SQL error reason for a non-unique constraint violation; not marked retryable.
|
|
146
|
+
*
|
|
147
|
+
* @category errors
|
|
148
|
+
* @since 4.0.0
|
|
149
|
+
*/
|
|
150
|
+
var ConstraintError = class extends TaggedErrorClass("effect/sql/SqlError/ConstraintError")("ConstraintError", ReasonFields) {
|
|
151
|
+
/**
|
|
152
|
+
* Marks this value as a structured SQL error reason for runtime guards.
|
|
153
|
+
*
|
|
154
|
+
* @since 4.0.0
|
|
155
|
+
*/
|
|
156
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
157
|
+
/**
|
|
158
|
+
* Indicates whether retrying the failed SQL operation may succeed.
|
|
159
|
+
*
|
|
160
|
+
* @since 4.0.0
|
|
161
|
+
*/
|
|
162
|
+
get isRetryable() {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* SQL error reason for a database deadlock; marked retryable.
|
|
168
|
+
*
|
|
169
|
+
* @category errors
|
|
170
|
+
* @since 4.0.0
|
|
171
|
+
*/
|
|
172
|
+
var DeadlockError = class extends TaggedErrorClass("effect/sql/SqlError/DeadlockError")("DeadlockError", ReasonFields) {
|
|
173
|
+
/**
|
|
174
|
+
* Marks this value as a structured SQL error reason for runtime guards.
|
|
175
|
+
*
|
|
176
|
+
* @since 4.0.0
|
|
177
|
+
*/
|
|
178
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
179
|
+
/**
|
|
180
|
+
* Indicates whether retrying the failed SQL operation may succeed.
|
|
181
|
+
*
|
|
182
|
+
* @since 4.0.0
|
|
183
|
+
*/
|
|
184
|
+
get isRetryable() {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* SQL error reason for a transaction serialization or isolation conflict;
|
|
190
|
+
* marked retryable.
|
|
191
|
+
*
|
|
192
|
+
* @category errors
|
|
193
|
+
* @since 4.0.0
|
|
194
|
+
*/
|
|
195
|
+
var SerializationError = class extends TaggedErrorClass("effect/sql/SqlError/SerializationError")("SerializationError", ReasonFields) {
|
|
196
|
+
/**
|
|
197
|
+
* Marks this value as a structured SQL error reason for runtime guards.
|
|
198
|
+
*
|
|
199
|
+
* @since 4.0.0
|
|
200
|
+
*/
|
|
201
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
202
|
+
/**
|
|
203
|
+
* Indicates whether retrying the failed SQL operation may succeed.
|
|
204
|
+
*
|
|
205
|
+
* @since 4.0.0
|
|
206
|
+
*/
|
|
207
|
+
get isRetryable() {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* SQL error reason for timing out while waiting on a database lock; marked
|
|
213
|
+
* retryable.
|
|
214
|
+
*
|
|
215
|
+
* @category errors
|
|
216
|
+
* @since 4.0.0
|
|
217
|
+
*/
|
|
218
|
+
var LockTimeoutError = class extends TaggedErrorClass("effect/sql/SqlError/LockTimeoutError")("LockTimeoutError", ReasonFields) {
|
|
219
|
+
/**
|
|
220
|
+
* Marks this value as a structured SQL error reason for runtime guards.
|
|
221
|
+
*
|
|
222
|
+
* @since 4.0.0
|
|
223
|
+
*/
|
|
224
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
225
|
+
/**
|
|
226
|
+
* Indicates whether retrying the failed SQL operation may succeed.
|
|
227
|
+
*
|
|
228
|
+
* @since 4.0.0
|
|
229
|
+
*/
|
|
230
|
+
get isRetryable() {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* SQL error reason for a statement or query timeout; marked retryable.
|
|
236
|
+
*
|
|
237
|
+
* @category errors
|
|
238
|
+
* @since 4.0.0
|
|
239
|
+
*/
|
|
240
|
+
var StatementTimeoutError = class extends TaggedErrorClass("effect/sql/SqlError/StatementTimeoutError")("StatementTimeoutError", ReasonFields) {
|
|
241
|
+
/**
|
|
242
|
+
* Marks this value as a structured SQL error reason for runtime guards.
|
|
243
|
+
*
|
|
244
|
+
* @since 4.0.0
|
|
245
|
+
*/
|
|
246
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
247
|
+
/**
|
|
248
|
+
* Indicates whether retrying the failed SQL operation may succeed.
|
|
249
|
+
*
|
|
250
|
+
* @since 4.0.0
|
|
251
|
+
*/
|
|
252
|
+
get isRetryable() {
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* SQL error reason for an unclassified database failure; not marked retryable.
|
|
258
|
+
*
|
|
259
|
+
* @category errors
|
|
260
|
+
* @since 4.0.0
|
|
261
|
+
*/
|
|
262
|
+
var UnknownError = class extends TaggedErrorClass("effect/sql/SqlError/UnknownError")("UnknownError", ReasonFields) {
|
|
263
|
+
/**
|
|
264
|
+
* Marks this value as a structured SQL error reason for runtime guards.
|
|
265
|
+
*
|
|
266
|
+
* @since 4.0.0
|
|
267
|
+
*/
|
|
268
|
+
[ReasonTypeId] = ReasonTypeId;
|
|
269
|
+
/**
|
|
270
|
+
* Indicates whether retrying the failed SQL operation may succeed.
|
|
271
|
+
*
|
|
272
|
+
* @since 4.0.0
|
|
273
|
+
*/
|
|
274
|
+
get isRetryable() {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Schema for encoding and decoding SQL error reasons.
|
|
280
|
+
*
|
|
281
|
+
* @category schemas
|
|
282
|
+
* @since 4.0.0
|
|
283
|
+
*/
|
|
284
|
+
const SqlErrorReason = /*#__PURE__*/ Union([
|
|
285
|
+
ConnectionError,
|
|
286
|
+
AuthenticationError,
|
|
287
|
+
AuthorizationError,
|
|
288
|
+
SqlSyntaxError,
|
|
289
|
+
UniqueViolation,
|
|
290
|
+
ConstraintError,
|
|
291
|
+
DeadlockError,
|
|
292
|
+
SerializationError,
|
|
293
|
+
LockTimeoutError,
|
|
294
|
+
StatementTimeoutError,
|
|
295
|
+
UnknownError
|
|
296
|
+
]);
|
|
297
|
+
/**
|
|
298
|
+
* Error wrapper for SQL failures whose `message`, `cause`, and `isRetryable`
|
|
299
|
+
* values are derived from its `SqlErrorReason`.
|
|
300
|
+
*
|
|
301
|
+
* @category errors
|
|
302
|
+
* @since 4.0.0
|
|
303
|
+
*/
|
|
304
|
+
var SqlError = class extends TaggedErrorClass("effect/sql/SqlError")("SqlError", { reason: SqlErrorReason }) {
|
|
305
|
+
/**
|
|
306
|
+
* Marks this value as the top-level SQL error wrapper for runtime guards.
|
|
307
|
+
*
|
|
308
|
+
* @since 4.0.0
|
|
309
|
+
*/
|
|
310
|
+
[TypeId$1] = TypeId$1;
|
|
311
|
+
/**
|
|
312
|
+
* Exposes the structured SQL reason as the JavaScript error cause.
|
|
313
|
+
*
|
|
314
|
+
* @since 4.0.0
|
|
315
|
+
*/
|
|
316
|
+
cause = this.reason;
|
|
317
|
+
/**
|
|
318
|
+
* Uses the reason message when present, otherwise falls back to the reason tag.
|
|
319
|
+
*
|
|
320
|
+
* @since 4.0.0
|
|
321
|
+
*/
|
|
322
|
+
get message() {
|
|
323
|
+
return this.reason.message || this.reason._tag;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Delegates retryability to the underlying SQL error reason.
|
|
327
|
+
*
|
|
328
|
+
* @since 4.0.0
|
|
329
|
+
*/
|
|
330
|
+
get isRetryable() {
|
|
331
|
+
return this.reason.isRetryable;
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
const sqliteCodeFromCause = (cause) => {
|
|
335
|
+
if (!hasProperty(cause, "code")) return;
|
|
336
|
+
const code = cause.code;
|
|
337
|
+
return typeof code === "string" || typeof code === "number" ? code : void 0;
|
|
338
|
+
};
|
|
339
|
+
const sqliteNumericCodeFromCause = (cause) => {
|
|
340
|
+
const code = sqliteCodeFromCause(cause);
|
|
341
|
+
if (typeof code === "number") return code;
|
|
342
|
+
if (!hasProperty(cause, "errno")) return;
|
|
343
|
+
const errno = cause.errno;
|
|
344
|
+
return typeof errno === "number" ? errno : void 0;
|
|
345
|
+
};
|
|
346
|
+
const matchesSqliteNumericCode = (cause, expected) => {
|
|
347
|
+
if (sqliteCodeFromCause(cause) === expected) return true;
|
|
348
|
+
if (!hasProperty(cause, "errno")) return false;
|
|
349
|
+
return cause.errno === expected;
|
|
350
|
+
};
|
|
351
|
+
const matchesSqliteCode = (code, expected) => code === expected || code.startsWith(expected + "_");
|
|
352
|
+
const UNKNOWN_CONSTRAINT = "unknown";
|
|
353
|
+
const SQLITE_CONSTRAINT_UNIQUE = "SQLITE_CONSTRAINT_UNIQUE";
|
|
354
|
+
const SQLITE_CONSTRAINT_UNIQUE_CODE = 2067;
|
|
355
|
+
const normalizeConstraintIdentifier = (identifier) => {
|
|
356
|
+
if (typeof identifier !== "string") return UNKNOWN_CONSTRAINT;
|
|
357
|
+
const trimmed = identifier.trim();
|
|
358
|
+
return trimmed.length === 0 ? UNKNOWN_CONSTRAINT : trimmed;
|
|
359
|
+
};
|
|
360
|
+
const sqliteUniqueConstraintFromCause = (cause) => {
|
|
361
|
+
if (hasProperty(cause, "constraint")) return normalizeConstraintIdentifier(cause.constraint);
|
|
362
|
+
if (!hasProperty(cause, "message")) return UNKNOWN_CONSTRAINT;
|
|
363
|
+
const message = cause.message;
|
|
364
|
+
if (typeof message !== "string") return UNKNOWN_CONSTRAINT;
|
|
365
|
+
const index = message.indexOf("UNIQUE constraint failed:");
|
|
366
|
+
return index === -1 ? UNKNOWN_CONSTRAINT : normalizeConstraintIdentifier(message.slice(index + 25));
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Classifies a native SQLite error cause into a `SqlErrorReason` using its
|
|
370
|
+
* `code` or `errno`, with optional message and operation metadata.
|
|
371
|
+
*
|
|
372
|
+
* @category converting
|
|
373
|
+
* @since 4.0.0
|
|
374
|
+
*/
|
|
375
|
+
const classifySqliteError = (cause, { message, operation } = {}) => {
|
|
376
|
+
const props = {
|
|
377
|
+
cause,
|
|
378
|
+
message,
|
|
379
|
+
operation
|
|
380
|
+
};
|
|
381
|
+
const code = sqliteCodeFromCause(cause);
|
|
382
|
+
const numericCode = sqliteNumericCodeFromCause(cause);
|
|
383
|
+
if (code === SQLITE_CONSTRAINT_UNIQUE || matchesSqliteNumericCode(cause, SQLITE_CONSTRAINT_UNIQUE_CODE)) return new UniqueViolation({
|
|
384
|
+
...props,
|
|
385
|
+
constraint: sqliteUniqueConstraintFromCause(cause)
|
|
386
|
+
});
|
|
387
|
+
if (typeof code === "string") {
|
|
388
|
+
if (matchesSqliteCode(code, "SQLITE_AUTH")) return new AuthenticationError(props);
|
|
389
|
+
if (matchesSqliteCode(code, "SQLITE_PERM")) return new AuthorizationError(props);
|
|
390
|
+
if (matchesSqliteCode(code, "SQLITE_CONSTRAINT")) return new ConstraintError(props);
|
|
391
|
+
if (matchesSqliteCode(code, "SQLITE_BUSY") || matchesSqliteCode(code, "SQLITE_LOCKED")) return new LockTimeoutError(props);
|
|
392
|
+
if (matchesSqliteCode(code, "SQLITE_CANTOPEN")) return new ConnectionError(props);
|
|
393
|
+
}
|
|
394
|
+
if (typeof numericCode === "number") switch (numericCode & 255) {
|
|
395
|
+
case 23: return new AuthenticationError(props);
|
|
396
|
+
case 3: return new AuthorizationError(props);
|
|
397
|
+
case 19: return new ConstraintError(props);
|
|
398
|
+
case 5:
|
|
399
|
+
case 6: return new LockTimeoutError(props);
|
|
400
|
+
case 14: return new ConnectionError(props);
|
|
401
|
+
default: return new UnknownError(props);
|
|
402
|
+
}
|
|
403
|
+
return new UnknownError(props);
|
|
404
|
+
};
|
|
405
|
+
TaggedErrorClass("effect/sql/ResultLengthMismatch")("ResultLengthMismatch", {
|
|
406
|
+
expected: Natural,
|
|
407
|
+
actual: Natural
|
|
408
|
+
});
|
|
409
|
+
//#endregion
|
|
410
|
+
//#region src/persistence/NodeSqliteClient.ts
|
|
411
|
+
/**
|
|
412
|
+
* Port of `@effect/sql-sqlite-node` that uses the native `node:sqlite`
|
|
413
|
+
* bindings instead of `better-sqlite3`.
|
|
414
|
+
*
|
|
415
|
+
* @module SqliteClient
|
|
416
|
+
*/
|
|
417
|
+
const ATTR_DB_SYSTEM_NAME = "db.system.name";
|
|
418
|
+
const TypeId = "~local/sqlite-node/SqliteClient";
|
|
419
|
+
var UnsupportedNodeSqliteVersionError = class extends TaggedErrorClass()("UnsupportedNodeSqliteVersionError", {
|
|
420
|
+
nodeVersion: String,
|
|
421
|
+
requirement: String
|
|
422
|
+
}) {
|
|
423
|
+
get message() {
|
|
424
|
+
return `Node.js ${this.nodeVersion} is missing required node:sqlite APIs. Upgrade to ${this.requirement}.`;
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
var UnsupportedNodeSqliteOperationError = class extends TaggedErrorClass()("UnsupportedNodeSqliteOperationError", {}) {
|
|
428
|
+
get message() {
|
|
429
|
+
return "Node SQLite does not support executeStream.";
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* Verify that the current Node.js version includes the `node:sqlite` APIs
|
|
434
|
+
* used by `NodeSqliteClient` — specifically `StatementSync.columns()` (added
|
|
435
|
+
* in Node 22.16.0 / 23.11.0).
|
|
436
|
+
*
|
|
437
|
+
* @see https://github.com/nodejs/node/pull/57490
|
|
438
|
+
*/
|
|
439
|
+
const checkNodeSqliteCompat = () => {
|
|
440
|
+
const parts = process.versions.node.split(".").map(Number);
|
|
441
|
+
const major = parts[0] ?? 0;
|
|
442
|
+
const minor = parts[1] ?? 0;
|
|
443
|
+
if (!(major === 22 && minor >= 16 || major === 23 && minor >= 11 || major >= 24)) return die(new UnsupportedNodeSqliteVersionError({
|
|
444
|
+
nodeVersion: process.versions.node,
|
|
445
|
+
requirement: "Node.js >=22.16, >=23.11, or >=24"
|
|
446
|
+
}));
|
|
447
|
+
return void_;
|
|
448
|
+
};
|
|
449
|
+
const makeWithDatabase = fn("makeWithDatabase")(function* (options, openDatabase) {
|
|
450
|
+
yield* checkNodeSqliteCompat();
|
|
451
|
+
const compiler = makeCompilerSqlite(options.transformQueryNames);
|
|
452
|
+
const transformRows = options.transformResultNames ? defaultTransforms(options.transformResultNames).array : void 0;
|
|
453
|
+
const makeConnection = gen(function* () {
|
|
454
|
+
const scope$1 = yield* scope;
|
|
455
|
+
const db = yield* try_({
|
|
456
|
+
try: openDatabase,
|
|
457
|
+
catch: (cause) => new SqlError({ reason: classifySqliteError(cause, {
|
|
458
|
+
message: "Failed to open database",
|
|
459
|
+
operation: "open"
|
|
460
|
+
}) })
|
|
461
|
+
});
|
|
462
|
+
yield* addFinalizer(scope$1, try_({
|
|
463
|
+
try: () => db.close(),
|
|
464
|
+
catch: (cause) => new SqlError({ reason: classifySqliteError(cause, {
|
|
465
|
+
message: "Failed to close database",
|
|
466
|
+
operation: "close"
|
|
467
|
+
}) })
|
|
468
|
+
}).pipe(orDie));
|
|
469
|
+
const statementReaderCache = /* @__PURE__ */ new WeakMap();
|
|
470
|
+
const hasRows = (statement) => {
|
|
471
|
+
const cached = statementReaderCache.get(statement);
|
|
472
|
+
if (cached !== void 0) return cached;
|
|
473
|
+
const value = statement.columns().length > 0;
|
|
474
|
+
statementReaderCache.set(statement, value);
|
|
475
|
+
return value;
|
|
476
|
+
};
|
|
477
|
+
const prepare = (sql) => try_({
|
|
478
|
+
try: () => db.prepare(sql),
|
|
479
|
+
catch: (cause) => new SqlError({ reason: classifySqliteError(cause, {
|
|
480
|
+
message: "Failed to prepare statement",
|
|
481
|
+
operation: "prepare"
|
|
482
|
+
}) })
|
|
483
|
+
});
|
|
484
|
+
const prepareCache = yield* make$2({
|
|
485
|
+
capacity: options.prepareCacheSize ?? 200,
|
|
486
|
+
timeToLive: options.prepareCacheTTL ?? minutes(10),
|
|
487
|
+
lookup: prepare
|
|
488
|
+
});
|
|
489
|
+
const runStatement = (statement, params, raw) => withFiber((fiber) => {
|
|
490
|
+
try {
|
|
491
|
+
statement.setReadBigInts(Boolean(get(fiber.context, SafeIntegers)));
|
|
492
|
+
if (hasRows(statement)) return succeed(statement.all(...params));
|
|
493
|
+
const result = statement.run(...params);
|
|
494
|
+
return succeed(raw ? result : []);
|
|
495
|
+
} catch (cause) {
|
|
496
|
+
return fail(new SqlError({ reason: classifySqliteError(cause, {
|
|
497
|
+
message: "Failed to execute statement",
|
|
498
|
+
operation: "execute"
|
|
499
|
+
}) }));
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
const run = (sql, params, raw = false) => flatMap(get$1(prepareCache, sql), (s) => runStatement(s, params, raw));
|
|
503
|
+
const runStatementValues = (statement, params) => acquireUseRelease(succeed(statement), (statement) => try_({
|
|
504
|
+
try: () => {
|
|
505
|
+
if (hasRows(statement)) {
|
|
506
|
+
statement.setReturnArrays(true);
|
|
507
|
+
return statement.all(...params);
|
|
508
|
+
}
|
|
509
|
+
statement.run(...params);
|
|
510
|
+
return [];
|
|
511
|
+
},
|
|
512
|
+
catch: (cause) => new SqlError({ reason: classifySqliteError(cause, {
|
|
513
|
+
message: "Failed to execute statement",
|
|
514
|
+
operation: "execute"
|
|
515
|
+
}) })
|
|
516
|
+
}), (statement) => try_({
|
|
517
|
+
try: () => {
|
|
518
|
+
if (hasRows(statement)) statement.setReturnArrays(false);
|
|
519
|
+
},
|
|
520
|
+
catch: (cause) => new SqlError({ reason: classifySqliteError(cause, {
|
|
521
|
+
message: "Failed to reset statement result mode",
|
|
522
|
+
operation: "resetResultMode"
|
|
523
|
+
}) })
|
|
524
|
+
}).pipe(orDie));
|
|
525
|
+
const runValues = (sql, params) => flatMap(get$1(prepareCache, sql), (statement) => runStatementValues(statement, params));
|
|
526
|
+
return identity({
|
|
527
|
+
execute(sql, params, rowTransform) {
|
|
528
|
+
return rowTransform ? map(run(sql, params), rowTransform) : run(sql, params);
|
|
529
|
+
},
|
|
530
|
+
executeRaw(sql, params) {
|
|
531
|
+
return run(sql, params, true);
|
|
532
|
+
},
|
|
533
|
+
executeValues(sql, params) {
|
|
534
|
+
return runValues(sql, params);
|
|
535
|
+
},
|
|
536
|
+
executeValuesUnprepared(sql, params) {
|
|
537
|
+
return flatMap(prepare(sql), (statement) => runStatementValues(statement, params ?? []));
|
|
538
|
+
},
|
|
539
|
+
executeUnprepared(sql, params, rowTransform) {
|
|
540
|
+
const effect = prepare(sql).pipe(flatMap((statement) => runStatement(statement, params ?? [], false)));
|
|
541
|
+
return rowTransform ? map(effect, rowTransform) : effect;
|
|
542
|
+
},
|
|
543
|
+
executeStream(_sql, _params) {
|
|
544
|
+
return die$1(new UnsupportedNodeSqliteOperationError());
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
});
|
|
548
|
+
const semaphore = yield* make$1(1);
|
|
549
|
+
const connection = yield* makeConnection;
|
|
550
|
+
return yield* make$3({
|
|
551
|
+
acquirer: semaphore.withPermits(1)(succeed(connection)),
|
|
552
|
+
compiler,
|
|
553
|
+
transactionAcquirer: uninterruptibleMask((restore) => {
|
|
554
|
+
const scope = getUnsafe(getCurrent().context, Scope);
|
|
555
|
+
return as(tap(restore(semaphore.take(1)), () => addFinalizer(scope, semaphore.release(1))), connection);
|
|
556
|
+
}),
|
|
557
|
+
spanAttributes: [...options.spanAttributes ? Object.entries(options.spanAttributes) : [], [ATTR_DB_SYSTEM_NAME, "sqlite"]],
|
|
558
|
+
transformRows
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
const make = (options) => makeWithDatabase(options, () => new NodeSqlite.DatabaseSync(options.filename, {
|
|
562
|
+
readOnly: options.readonly ?? false,
|
|
563
|
+
allowExtension: options.allowExtension ?? false
|
|
564
|
+
}));
|
|
565
|
+
const makeMemory = (config = {}) => makeWithDatabase({
|
|
566
|
+
...config,
|
|
567
|
+
filename: ":memory:",
|
|
568
|
+
readonly: false
|
|
569
|
+
}, () => {
|
|
570
|
+
return new NodeSqlite.DatabaseSync(":memory:", { allowExtension: config.allowExtension ?? false });
|
|
571
|
+
});
|
|
572
|
+
const layerConfig = (config) => effect(SqlClient, unwrap(config).pipe(flatMap(make))).pipe(provide(layer$1));
|
|
573
|
+
const layer = (config) => effect(SqlClient, make(config)).pipe(provide(layer$1));
|
|
574
|
+
const layerMemory = (config = {}) => effect(SqlClient, makeMemory(config)).pipe(provide(layer$1));
|
|
575
|
+
//#endregion
|
|
576
|
+
export { TypeId, UnsupportedNodeSqliteOperationError, UnsupportedNodeSqliteVersionError, layer, layerConfig, layerMemory };
|
|
577
|
+
|
|
578
|
+
//# sourceMappingURL=NodeSqliteClient-Byu521pt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeSqliteClient-Byu521pt.mjs","names":["TypeId","Schema.String","Schema.TaggedErrorClass","Predicate.hasProperty","Schema.Natural","Schema.TaggedErrorClass","Schema.String","Effect.die","Effect.void","Effect.fn","Statement.makeCompilerSqlite","Statement.defaultTransforms","Effect.gen","scope","Effect.scope","Effect.try","Scope.addFinalizer","Effect.orDie","Cache.make","Duration.minutes","Effect.withFiber","Context.get","Client.SafeIntegers","Effect.succeed","Effect.fail","Effect.flatMap","Cache.get","Effect.acquireUseRelease","Effect.map","Stream.die","Semaphore.make","Effect.uninterruptibleMask","Fiber.getCurrent","Context.getUnsafe","Scope.Scope","Effect.as","Effect.tap","Client.make","Layer.effect","Client.SqlClient","Config.unwrap","Layer.provide","Reactivity.layer"],"sources":["../../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=a18f963109656ddbeb2a99ca45f942ecf54830986259eb01ce6a970421c9c6a9/node_modules/effect/dist/unstable/sql/SqlError.js","../src/persistence/NodeSqliteClient.ts"],"sourcesContent":["/**\n * Defines structured failures for SQL clients and driver integrations.\n *\n * `SqlError` wraps the different reasons a SQL operation can fail, such as\n * connection, authentication, authorization, syntax, constraint, or transaction\n * problems. Each reason keeps the original cause, optional message and\n * operation metadata, and whether retrying may succeed. This module also\n * includes schemas, guards, a SQLite error classifier, and the\n * `ResultLengthMismatch` error used by ordered batched SQL resolvers.\n *\n * @since 4.0.0\n */\nimport * as Predicate from \"../../Predicate.js\";\nimport * as Schema from \"../../Schema.js\";\nconst TypeId = \"~effect/sql/SqlError\";\nconst ReasonTypeId = \"~effect/sql/SqlError/Reason\";\nconst ReasonFields = {\n cause: /*#__PURE__*/Schema.Defect(),\n message: /*#__PURE__*/Schema.optional(Schema.String),\n operation: /*#__PURE__*/Schema.optional(Schema.String)\n};\n/**\n * SQL error reason for connection or open failures; marked retryable.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class ConnectionError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError/ConnectionError\")(\"ConnectionError\", ReasonFields) {\n /**\n * Marks this value as a structured SQL error reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n /**\n * Indicates whether retrying the failed SQL operation may succeed.\n *\n * @since 4.0.0\n */\n get isRetryable() {\n return true;\n }\n}\n/**\n * SQL error reason for authentication failures such as invalid credentials; not\n * marked retryable.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class AuthenticationError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError/AuthenticationError\")(\"AuthenticationError\", ReasonFields) {\n /**\n * Marks this value as a structured SQL error reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n /**\n * Indicates whether retrying the failed SQL operation may succeed.\n *\n * @since 4.0.0\n */\n get isRetryable() {\n return false;\n }\n}\n/**\n * SQL error reason for authorization or permission failures; not marked\n * retryable.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class AuthorizationError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError/AuthorizationError\")(\"AuthorizationError\", ReasonFields) {\n /**\n * Marks this value as a structured SQL error reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n /**\n * Indicates whether retrying the failed SQL operation may succeed.\n *\n * @since 4.0.0\n */\n get isRetryable() {\n return false;\n }\n}\n/**\n * SQL error reason for invalid SQL syntax; not marked retryable.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class SqlSyntaxError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError/SqlSyntaxError\")(\"SqlSyntaxError\", ReasonFields) {\n /**\n * Marks this value as a structured SQL error reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n /**\n * Indicates whether retrying the failed SQL operation may succeed.\n *\n * @since 4.0.0\n */\n get isRetryable() {\n return false;\n }\n}\nconst UniqueViolationFields = {\n ...ReasonFields,\n constraint: Schema.String\n};\n/**\n * SQL error reason for a unique constraint violation, including the violated\n * constraint identifier; not marked retryable.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class UniqueViolation extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError/UniqueViolation\")(\"UniqueViolation\", UniqueViolationFields) {\n /**\n * Marks this value as a structured SQL error reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n /**\n * Indicates whether retrying the failed SQL operation may succeed.\n *\n * @since 4.0.0\n */\n get isRetryable() {\n return false;\n }\n}\n/**\n * SQL error reason for a non-unique constraint violation; not marked retryable.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class ConstraintError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError/ConstraintError\")(\"ConstraintError\", ReasonFields) {\n /**\n * Marks this value as a structured SQL error reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n /**\n * Indicates whether retrying the failed SQL operation may succeed.\n *\n * @since 4.0.0\n */\n get isRetryable() {\n return false;\n }\n}\n/**\n * SQL error reason for a database deadlock; marked retryable.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class DeadlockError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError/DeadlockError\")(\"DeadlockError\", ReasonFields) {\n /**\n * Marks this value as a structured SQL error reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n /**\n * Indicates whether retrying the failed SQL operation may succeed.\n *\n * @since 4.0.0\n */\n get isRetryable() {\n return true;\n }\n}\n/**\n * SQL error reason for a transaction serialization or isolation conflict;\n * marked retryable.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class SerializationError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError/SerializationError\")(\"SerializationError\", ReasonFields) {\n /**\n * Marks this value as a structured SQL error reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n /**\n * Indicates whether retrying the failed SQL operation may succeed.\n *\n * @since 4.0.0\n */\n get isRetryable() {\n return true;\n }\n}\n/**\n * SQL error reason for timing out while waiting on a database lock; marked\n * retryable.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class LockTimeoutError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError/LockTimeoutError\")(\"LockTimeoutError\", ReasonFields) {\n /**\n * Marks this value as a structured SQL error reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n /**\n * Indicates whether retrying the failed SQL operation may succeed.\n *\n * @since 4.0.0\n */\n get isRetryable() {\n return true;\n }\n}\n/**\n * SQL error reason for a statement or query timeout; marked retryable.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class StatementTimeoutError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError/StatementTimeoutError\")(\"StatementTimeoutError\", ReasonFields) {\n /**\n * Marks this value as a structured SQL error reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n /**\n * Indicates whether retrying the failed SQL operation may succeed.\n *\n * @since 4.0.0\n */\n get isRetryable() {\n return true;\n }\n}\n/**\n * SQL error reason for an unclassified database failure; not marked retryable.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class UnknownError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError/UnknownError\")(\"UnknownError\", ReasonFields) {\n /**\n * Marks this value as a structured SQL error reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n /**\n * Indicates whether retrying the failed SQL operation may succeed.\n *\n * @since 4.0.0\n */\n get isRetryable() {\n return false;\n }\n}\n/**\n * Schema for encoding and decoding SQL error reasons.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const SqlErrorReason = /*#__PURE__*/Schema.Union([ConnectionError, AuthenticationError, AuthorizationError, SqlSyntaxError, UniqueViolation, ConstraintError, DeadlockError, SerializationError, LockTimeoutError, StatementTimeoutError, UnknownError]);\n/**\n * Error wrapper for SQL failures whose `message`, `cause`, and `isRetryable`\n * values are derived from its `SqlErrorReason`.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class SqlError extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/SqlError\")(\"SqlError\", {\n reason: SqlErrorReason\n}) {\n /**\n * Marks this value as the top-level SQL error wrapper for runtime guards.\n *\n * @since 4.0.0\n */\n [TypeId] = TypeId;\n /**\n * Exposes the structured SQL reason as the JavaScript error cause.\n *\n * @since 4.0.0\n */\n cause = this.reason;\n /**\n * Uses the reason message when present, otherwise falls back to the reason tag.\n *\n * @since 4.0.0\n */\n get message() {\n return this.reason.message || this.reason._tag;\n }\n /**\n * Delegates retryability to the underlying SQL error reason.\n *\n * @since 4.0.0\n */\n get isRetryable() {\n return this.reason.isRetryable;\n }\n}\n/**\n * Returns `true` when a value is a `SqlError`.\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isSqlError = u => Predicate.hasProperty(u, TypeId);\n/**\n * Returns `true` when a value is a `SqlErrorReason`.\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isSqlErrorReason = u => Predicate.hasProperty(u, ReasonTypeId);\nconst sqliteCodeFromCause = cause => {\n if (!Predicate.hasProperty(cause, \"code\")) {\n return undefined;\n }\n const code = cause.code;\n return typeof code === \"string\" || typeof code === \"number\" ? code : undefined;\n};\nconst sqliteNumericCodeFromCause = cause => {\n const code = sqliteCodeFromCause(cause);\n if (typeof code === \"number\") {\n return code;\n }\n if (!Predicate.hasProperty(cause, \"errno\")) {\n return undefined;\n }\n const errno = cause.errno;\n return typeof errno === \"number\" ? errno : undefined;\n};\nconst matchesSqliteNumericCode = (cause, expected) => {\n const code = sqliteCodeFromCause(cause);\n if (code === expected) {\n return true;\n }\n if (!Predicate.hasProperty(cause, \"errno\")) {\n return false;\n }\n return cause.errno === expected;\n};\nconst matchesSqliteCode = (code, expected) => code === expected || code.startsWith(expected + \"_\");\nconst UNKNOWN_CONSTRAINT = \"unknown\";\nconst SQLITE_CONSTRAINT_UNIQUE = \"SQLITE_CONSTRAINT_UNIQUE\";\nconst SQLITE_CONSTRAINT_UNIQUE_CODE = 2067;\nconst normalizeConstraintIdentifier = identifier => {\n if (typeof identifier !== \"string\") {\n return UNKNOWN_CONSTRAINT;\n }\n const trimmed = identifier.trim();\n return trimmed.length === 0 ? UNKNOWN_CONSTRAINT : trimmed;\n};\nconst sqliteUniqueConstraintFromCause = cause => {\n if (Predicate.hasProperty(cause, \"constraint\")) {\n return normalizeConstraintIdentifier(cause.constraint);\n }\n if (!Predicate.hasProperty(cause, \"message\")) {\n return UNKNOWN_CONSTRAINT;\n }\n const message = cause.message;\n if (typeof message !== \"string\") {\n return UNKNOWN_CONSTRAINT;\n }\n const prefix = \"UNIQUE constraint failed:\";\n const index = message.indexOf(prefix);\n return index === -1 ? UNKNOWN_CONSTRAINT : normalizeConstraintIdentifier(message.slice(index + prefix.length));\n};\n/**\n * Classifies a native SQLite error cause into a `SqlErrorReason` using its\n * `code` or `errno`, with optional message and operation metadata.\n *\n * @category converting\n * @since 4.0.0\n */\nexport const classifySqliteError = (cause, {\n message,\n operation\n} = {}) => {\n const props = {\n cause,\n message,\n operation\n };\n const code = sqliteCodeFromCause(cause);\n const numericCode = sqliteNumericCodeFromCause(cause);\n if (code === SQLITE_CONSTRAINT_UNIQUE || matchesSqliteNumericCode(cause, SQLITE_CONSTRAINT_UNIQUE_CODE)) {\n return new UniqueViolation({\n ...props,\n constraint: sqliteUniqueConstraintFromCause(cause)\n });\n }\n if (typeof code === \"string\") {\n if (matchesSqliteCode(code, \"SQLITE_AUTH\")) {\n return new AuthenticationError(props);\n }\n if (matchesSqliteCode(code, \"SQLITE_PERM\")) {\n return new AuthorizationError(props);\n }\n if (matchesSqliteCode(code, \"SQLITE_CONSTRAINT\")) {\n return new ConstraintError(props);\n }\n if (matchesSqliteCode(code, \"SQLITE_BUSY\") || matchesSqliteCode(code, \"SQLITE_LOCKED\")) {\n return new LockTimeoutError(props);\n }\n if (matchesSqliteCode(code, \"SQLITE_CANTOPEN\")) {\n return new ConnectionError(props);\n }\n }\n if (typeof numericCode === \"number\") {\n const code = numericCode & 0xff;\n switch (code) {\n case 23:\n return new AuthenticationError(props);\n case 3:\n return new AuthorizationError(props);\n case 19:\n return new ConstraintError(props);\n case 5:\n case 6:\n return new LockTimeoutError(props);\n case 14:\n return new ConnectionError(props);\n default:\n return new UnknownError(props);\n }\n }\n return new UnknownError(props);\n};\n/**\n * Error raised when an ordered batched SQL resolver receives a different number\n * of result rows than requests.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class ResultLengthMismatch extends /*#__PURE__*/Schema.TaggedErrorClass(\"effect/sql/ResultLengthMismatch\")(\"ResultLengthMismatch\", {\n expected: Schema.Natural,\n actual: Schema.Natural\n}) {\n /**\n * Explains the mismatch between expected and actual batched SQL result counts.\n *\n * @since 4.0.0\n */\n get message() {\n return `Expected ${this.expected} results but got ${this.actual}`;\n }\n}\n//# sourceMappingURL=SqlError.js.map","/**\n * Port of `@effect/sql-sqlite-node` that uses the native `node:sqlite`\n * bindings instead of `better-sqlite3`.\n *\n * @module SqliteClient\n */\nimport * as NodeSqlite from \"node:sqlite\";\n\nimport * as Cache from \"effect/Cache\";\nimport * as Config from \"effect/Config\";\nimport * as Duration from \"effect/Duration\";\nimport * as Effect from \"effect/Effect\";\nimport * as Fiber from \"effect/Fiber\";\nimport { identity } from \"effect/Function\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport * as Scope from \"effect/Scope\";\nimport * as Semaphore from \"effect/Semaphore\";\nimport * as Context from \"effect/Context\";\nimport * as Stream from \"effect/Stream\";\nimport * as Reactivity from \"effect/unstable/reactivity/Reactivity\";\nimport * as Client from \"effect/unstable/sql/SqlClient\";\nimport type { Connection } from \"effect/unstable/sql/SqlConnection\";\nimport { SqlError, classifySqliteError } from \"effect/unstable/sql/SqlError\";\nimport * as Statement from \"effect/unstable/sql/Statement\";\n\nconst ATTR_DB_SYSTEM_NAME = \"db.system.name\";\n\nexport const TypeId: TypeId = \"~local/sqlite-node/SqliteClient\";\n\nexport type TypeId = \"~local/sqlite-node/SqliteClient\";\n\nexport interface SqliteClientConfig {\n readonly filename: string;\n readonly readonly?: boolean | undefined;\n readonly allowExtension?: boolean | undefined;\n readonly prepareCacheSize?: number | undefined;\n readonly prepareCacheTTL?: Duration.Input | undefined;\n readonly spanAttributes?: Record<string, unknown> | undefined;\n readonly transformResultNames?: ((str: string) => string) | undefined;\n readonly transformQueryNames?: ((str: string) => string) | undefined;\n}\n\nexport interface SqliteMemoryClientConfig extends Omit<\n SqliteClientConfig,\n \"filename\" | \"readonly\"\n> {}\n\nexport class UnsupportedNodeSqliteVersionError extends Schema.TaggedErrorClass<UnsupportedNodeSqliteVersionError>()(\n \"UnsupportedNodeSqliteVersionError\",\n {\n nodeVersion: Schema.String,\n requirement: Schema.String,\n },\n) {\n override get message(): string {\n return `Node.js ${this.nodeVersion} is missing required node:sqlite APIs. Upgrade to ${this.requirement}.`;\n }\n}\n\nexport class UnsupportedNodeSqliteOperationError extends Schema.TaggedErrorClass<UnsupportedNodeSqliteOperationError>()(\n \"UnsupportedNodeSqliteOperationError\",\n {},\n) {\n override get message(): string {\n return \"Node SQLite does not support executeStream.\";\n }\n}\n\n/**\n * Verify that the current Node.js version includes the `node:sqlite` APIs\n * used by `NodeSqliteClient` — specifically `StatementSync.columns()` (added\n * in Node 22.16.0 / 23.11.0).\n *\n * @see https://github.com/nodejs/node/pull/57490\n */\nconst checkNodeSqliteCompat = () => {\n const parts = process.versions.node.split(\".\").map(Number);\n const major = parts[0] ?? 0;\n const minor = parts[1] ?? 0;\n const supported = (major === 22 && minor >= 16) || (major === 23 && minor >= 11) || major >= 24;\n\n if (!supported) {\n return Effect.die(\n new UnsupportedNodeSqliteVersionError({\n nodeVersion: process.versions.node,\n requirement: \"Node.js >=22.16, >=23.11, or >=24\",\n }),\n );\n }\n return Effect.void;\n};\n\nconst makeWithDatabase = Effect.fn(\"makeWithDatabase\")(function* (\n options: SqliteClientConfig,\n openDatabase: () => NodeSqlite.DatabaseSync,\n): Effect.fn.Return<Client.SqlClient, SqlError, Scope.Scope | Reactivity.Reactivity> {\n yield* checkNodeSqliteCompat();\n\n const compiler = Statement.makeCompilerSqlite(options.transformQueryNames);\n const transformRows = options.transformResultNames\n ? Statement.defaultTransforms(options.transformResultNames).array\n : undefined;\n\n const makeConnection = Effect.gen(function* () {\n const scope = yield* Effect.scope;\n const db = yield* Effect.try({\n try: openDatabase,\n catch: (cause) =>\n new SqlError({\n reason: classifySqliteError(cause, {\n message: \"Failed to open database\",\n operation: \"open\",\n }),\n }),\n });\n yield* Scope.addFinalizer(\n scope,\n Effect.try({\n try: () => db.close(),\n catch: (cause) =>\n new SqlError({\n reason: classifySqliteError(cause, {\n message: \"Failed to close database\",\n operation: \"close\",\n }),\n }),\n }).pipe(Effect.orDie),\n );\n\n const statementReaderCache = new WeakMap<NodeSqlite.StatementSync, boolean>();\n const hasRows = (statement: NodeSqlite.StatementSync): boolean => {\n const cached = statementReaderCache.get(statement);\n if (cached !== undefined) {\n return cached;\n }\n const value = statement.columns().length > 0;\n statementReaderCache.set(statement, value);\n return value;\n };\n\n const prepare = (sql: string) =>\n Effect.try({\n try: () => db.prepare(sql),\n catch: (cause) =>\n new SqlError({\n reason: classifySqliteError(cause, {\n message: \"Failed to prepare statement\",\n operation: \"prepare\",\n }),\n }),\n });\n\n const prepareCache = yield* Cache.make({\n capacity: options.prepareCacheSize ?? 200,\n timeToLive: options.prepareCacheTTL ?? Duration.minutes(10),\n lookup: prepare,\n });\n\n const runStatement = (\n statement: NodeSqlite.StatementSync,\n params: ReadonlyArray<unknown>,\n raw: boolean,\n ) =>\n Effect.withFiber<ReadonlyArray<any>, SqlError>((fiber) => {\n try {\n statement.setReadBigInts(Boolean(Context.get(fiber.context, Client.SafeIntegers)));\n if (hasRows(statement)) {\n return Effect.succeed(statement.all(...(params as any)));\n }\n const result = statement.run(...(params as any));\n return Effect.succeed(raw ? (result as unknown as ReadonlyArray<any>) : []);\n } catch (cause) {\n return Effect.fail(\n new SqlError({\n reason: classifySqliteError(cause, {\n message: \"Failed to execute statement\",\n operation: \"execute\",\n }),\n }),\n );\n }\n });\n\n const run = (sql: string, params: ReadonlyArray<unknown>, raw = false) =>\n Effect.flatMap(Cache.get(prepareCache, sql), (s) => runStatement(s, params, raw));\n\n const runStatementValues = (\n statement: NodeSqlite.StatementSync,\n params: ReadonlyArray<unknown>,\n ) =>\n Effect.acquireUseRelease(\n Effect.succeed(statement),\n (statement) =>\n Effect.try({\n try: () => {\n if (hasRows(statement)) {\n statement.setReturnArrays(true);\n // Safe to cast to array after we've setReturnArrays(true)\n return statement.all(...(params as any)) as unknown as ReadonlyArray<\n ReadonlyArray<unknown>\n >;\n }\n statement.run(...(params as any));\n return [];\n },\n catch: (cause) =>\n new SqlError({\n reason: classifySqliteError(cause, {\n message: \"Failed to execute statement\",\n operation: \"execute\",\n }),\n }),\n }),\n (statement) =>\n Effect.try({\n try: () => {\n if (hasRows(statement)) {\n statement.setReturnArrays(false);\n }\n },\n catch: (cause) =>\n new SqlError({\n reason: classifySqliteError(cause, {\n message: \"Failed to reset statement result mode\",\n operation: \"resetResultMode\",\n }),\n }),\n }).pipe(Effect.orDie),\n );\n\n const runValues = (sql: string, params: ReadonlyArray<unknown>) =>\n Effect.flatMap(Cache.get(prepareCache, sql), (statement) =>\n runStatementValues(statement, params),\n );\n\n return identity<Connection>({\n execute(sql, params, rowTransform) {\n return rowTransform ? Effect.map(run(sql, params), rowTransform) : run(sql, params);\n },\n executeRaw(sql, params) {\n return run(sql, params, true);\n },\n executeValues(sql, params) {\n return runValues(sql, params);\n },\n executeValuesUnprepared(sql, params) {\n return Effect.flatMap(prepare(sql), (statement) =>\n runStatementValues(statement, params ?? []),\n );\n },\n executeUnprepared(sql, params, rowTransform) {\n const effect = prepare(sql).pipe(\n Effect.flatMap((statement) => runStatement(statement, params ?? [], false)),\n );\n return rowTransform ? Effect.map(effect, rowTransform) : effect;\n },\n executeStream(_sql, _params) {\n return Stream.die(new UnsupportedNodeSqliteOperationError());\n },\n });\n });\n\n const semaphore = yield* Semaphore.make(1);\n const connection = yield* makeConnection;\n\n const acquirer = semaphore.withPermits(1)(Effect.succeed(connection));\n const transactionAcquirer = Effect.uninterruptibleMask((restore) => {\n const fiber = Fiber.getCurrent()!;\n const scope = Context.getUnsafe(fiber.context, Scope.Scope);\n return Effect.as(\n Effect.tap(restore(semaphore.take(1)), () => Scope.addFinalizer(scope, semaphore.release(1))),\n connection,\n );\n });\n\n return yield* Client.make({\n acquirer,\n compiler,\n transactionAcquirer,\n spanAttributes: [\n ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []),\n [ATTR_DB_SYSTEM_NAME, \"sqlite\"],\n ],\n transformRows,\n });\n});\n\nconst make = (\n options: SqliteClientConfig,\n): Effect.Effect<Client.SqlClient, SqlError, Scope.Scope | Reactivity.Reactivity> =>\n makeWithDatabase(\n options,\n () =>\n new NodeSqlite.DatabaseSync(options.filename, {\n readOnly: options.readonly ?? false,\n allowExtension: options.allowExtension ?? false,\n }),\n );\n\nconst makeMemory = (\n config: SqliteMemoryClientConfig = {},\n): Effect.Effect<Client.SqlClient, SqlError, Scope.Scope | Reactivity.Reactivity> =>\n makeWithDatabase(\n {\n ...config,\n filename: \":memory:\",\n readonly: false,\n },\n () => {\n const database = new NodeSqlite.DatabaseSync(\":memory:\", {\n allowExtension: config.allowExtension ?? false,\n });\n return database;\n },\n );\n\nexport const layerConfig = (\n config: Config.Wrap<SqliteClientConfig>,\n): Layer.Layer<Client.SqlClient, Config.ConfigError | SqlError> =>\n Layer.effect(Client.SqlClient, Config.unwrap(config).pipe(Effect.flatMap(make))).pipe(\n Layer.provide(Reactivity.layer),\n );\n\nexport const layer = (config: SqliteClientConfig): Layer.Layer<Client.SqlClient, SqlError> =>\n Layer.effect(Client.SqlClient, make(config)).pipe(Layer.provide(Reactivity.layer));\n\nexport const layerMemory = (\n config: SqliteMemoryClientConfig = {},\n): Layer.Layer<Client.SqlClient, SqlError> =>\n Layer.effect(Client.SqlClient, makeMemory(config)).pipe(Layer.provide(Reactivity.layer));\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;AAcA,MAAMA,WAAS;AACf,MAAM,eAAe;AACrB,MAAM,eAAe;CACnB,OAAoB,qBAAc;CAClC,SAAsB,uBAAgBC,MAAa;CACnD,WAAwB,uBAAgBA,MAAa;AACvD;;;;;;;AAOA,IAAa,kBAAb,cAAkDC,iBAAwB,qCAAqC,CAAC,CAAC,mBAAmB,YAAY,CAAC,CAAC;;;;;;CAMhJ,CAAC,gBAAgB;;;;;;CAMjB,IAAI,cAAc;EAChB,OAAO;CACT;AACF;;;;;;;;AAQA,IAAa,sBAAb,cAAsDA,iBAAwB,yCAAyC,CAAC,CAAC,uBAAuB,YAAY,CAAC,CAAC;;;;;;CAM5J,CAAC,gBAAgB;;;;;;CAMjB,IAAI,cAAc;EAChB,OAAO;CACT;AACF;;;;;;;;AAQA,IAAa,qBAAb,cAAqDA,iBAAwB,wCAAwC,CAAC,CAAC,sBAAsB,YAAY,CAAC,CAAC;;;;;;CAMzJ,CAAC,gBAAgB;;;;;;CAMjB,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