@ckirg/corelib 0.1.22
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/LICENSE +21 -0
- package/README.md +228 -0
- package/dist/RequestUnlimited-CLB36IJX.js +27 -0
- package/dist/browser.d.ts +6 -0
- package/dist/browser.js +75 -0
- package/dist/bun-LDGTNQBK.js +41 -0
- package/dist/chunk-2DF4ADYX.js +9 -0
- package/dist/chunk-BAVE2JXI.js +207 -0
- package/dist/chunk-HOOAMOFY.js +120 -0
- package/dist/chunk-HPE2XSTW.js +202 -0
- package/dist/chunk-PESRDNPD.js +876 -0
- package/dist/cloudflare-IOVZ3QEK.js +102 -0
- package/dist/deno-MVIUW5GX.js +41 -0
- package/dist/flight-recorder-BCSVZvWQ.d.ts +92 -0
- package/dist/gcp-TRX5BADQ.js +39 -0
- package/dist/index.d.ts +879 -0
- package/dist/index.js +975 -0
- package/dist/lambda-CQXJKGN5.js +32 -0
- package/dist/node-6V4FDE5Z.js +41 -0
- package/dist/utils-Q4C2EEPD.js +42 -0
- package/package.json +62 -0
- package/scripts/postinstall.js +74 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,975 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigManager,
|
|
3
|
+
RequestResponseSerialize,
|
|
4
|
+
RequestUnlimited,
|
|
5
|
+
endPoint,
|
|
6
|
+
endPoints
|
|
7
|
+
} from "./chunk-PESRDNPD.js";
|
|
8
|
+
import {
|
|
9
|
+
Utils,
|
|
10
|
+
existsSync,
|
|
11
|
+
getAllEnv,
|
|
12
|
+
getCwd,
|
|
13
|
+
getDirname,
|
|
14
|
+
getEnv,
|
|
15
|
+
getMode,
|
|
16
|
+
getPlatform,
|
|
17
|
+
getRequire,
|
|
18
|
+
getTempDir,
|
|
19
|
+
includeExcludeCron,
|
|
20
|
+
loggers_default,
|
|
21
|
+
readTextFileSync,
|
|
22
|
+
sleep
|
|
23
|
+
} from "./chunk-BAVE2JXI.js";
|
|
24
|
+
import {
|
|
25
|
+
nextCid
|
|
26
|
+
} from "./chunk-2DF4ADYX.js";
|
|
27
|
+
import {
|
|
28
|
+
SysInfo,
|
|
29
|
+
detectRuntime,
|
|
30
|
+
getSysInfo
|
|
31
|
+
} from "./chunk-HPE2XSTW.js";
|
|
32
|
+
|
|
33
|
+
// src/core/index.ts
|
|
34
|
+
import { serializeError } from "serialize-error";
|
|
35
|
+
var _createRequire;
|
|
36
|
+
if (typeof __EDGE_RUNTIME__ === "undefined" || !__EDGE_RUNTIME__) {
|
|
37
|
+
_createRequire = (await import("module")).createRequire;
|
|
38
|
+
}
|
|
39
|
+
var coreLogger = loggers_default.child({ section: "Core" });
|
|
40
|
+
var runtime = detectRuntime();
|
|
41
|
+
var _require;
|
|
42
|
+
var getRequire2 = () => {
|
|
43
|
+
if (!_require) {
|
|
44
|
+
const isNodeLike = [
|
|
45
|
+
"node",
|
|
46
|
+
"bun",
|
|
47
|
+
"deno",
|
|
48
|
+
"aws-lambda",
|
|
49
|
+
"gcp-cloudrun"
|
|
50
|
+
].includes(runtime);
|
|
51
|
+
if (_createRequire && isNodeLike && typeof import.meta !== "undefined" && import.meta.url) {
|
|
52
|
+
_require = _createRequire(import.meta.url);
|
|
53
|
+
} else {
|
|
54
|
+
_require = (path) => {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`require("${path}") is not available in this runtime (${runtime}).`
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return _require;
|
|
62
|
+
};
|
|
63
|
+
async function loadFFI() {
|
|
64
|
+
coreLogger.trace("loadFFI: start", { runtime });
|
|
65
|
+
if (runtime === "cloudflare") {
|
|
66
|
+
coreLogger.trace("loadFFI: skipped (edge runtime)", { runtime });
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const binaryName = "corelib-rust.node";
|
|
70
|
+
const pathsToTry = [];
|
|
71
|
+
let path;
|
|
72
|
+
try {
|
|
73
|
+
path = getRequire2()("node:path");
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
77
|
+
try {
|
|
78
|
+
const url = new URL(import.meta.url);
|
|
79
|
+
if (url.protocol === "file:") {
|
|
80
|
+
const { fileURLToPath } = getRequire2()("node:url");
|
|
81
|
+
const moduleFile = fileURLToPath(import.meta.url);
|
|
82
|
+
const moduleDir = path ? path.dirname(moduleFile) : "";
|
|
83
|
+
if (moduleDir && path) {
|
|
84
|
+
pathsToTry.push(
|
|
85
|
+
path.resolve(moduleDir, binaryName),
|
|
86
|
+
path.resolve(moduleDir, "..", binaryName),
|
|
87
|
+
path.resolve(moduleDir, "..", "..", binaryName)
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
pathsToTry.push(new URL(`./${binaryName}`, import.meta.url).pathname);
|
|
92
|
+
}
|
|
93
|
+
} catch (_e) {
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const cwd = process.cwd();
|
|
98
|
+
if (path) {
|
|
99
|
+
pathsToTry.push(
|
|
100
|
+
path.resolve(cwd, binaryName),
|
|
101
|
+
// same dir (unlikely but possible)
|
|
102
|
+
path.resolve(cwd, "..", binaryName),
|
|
103
|
+
// parent dir (standard for dist/ -> root)
|
|
104
|
+
path.resolve(cwd, "..", "..", binaryName),
|
|
105
|
+
// grandparent dir (standard for src/core/ -> root)
|
|
106
|
+
path.resolve(cwd, "ts-core", binaryName),
|
|
107
|
+
path.resolve(cwd, "..", "ts-core", binaryName)
|
|
108
|
+
);
|
|
109
|
+
} else {
|
|
110
|
+
pathsToTry.push(`./${binaryName}`, `../${binaryName}`);
|
|
111
|
+
}
|
|
112
|
+
} catch (_e) {
|
|
113
|
+
}
|
|
114
|
+
coreLogger.trace("loadFFI: candidates", { paths: pathsToTry });
|
|
115
|
+
let libPath;
|
|
116
|
+
try {
|
|
117
|
+
const { existsSync: existsSync2 } = getRequire2()("node:fs");
|
|
118
|
+
libPath = [...new Set(pathsToTry)].find((p) => p && existsSync2(p));
|
|
119
|
+
} catch (_e) {
|
|
120
|
+
}
|
|
121
|
+
coreLogger.trace("loadFFI: resolved", { found: libPath != null, libPath });
|
|
122
|
+
if (!libPath) {
|
|
123
|
+
coreLogger.warn(
|
|
124
|
+
`Could not find ${binaryName}. FFI features will be disabled.`
|
|
125
|
+
);
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
return getRequire2()(libPath);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
coreLogger.error(`Failed to load FFI from ${libPath}`, {
|
|
132
|
+
error: serializeError(error)
|
|
133
|
+
});
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
var FFI_PROMISE_KEY = "__ckir_corelib_coreFFI_promise__";
|
|
138
|
+
var _ffiGlobal = globalThis;
|
|
139
|
+
if (!_ffiGlobal[FFI_PROMISE_KEY]) {
|
|
140
|
+
_ffiGlobal[FFI_PROMISE_KEY] = loadFFI();
|
|
141
|
+
}
|
|
142
|
+
var coreFFI = await _ffiGlobal[FFI_PROMISE_KEY];
|
|
143
|
+
function isFfiAvailable() {
|
|
144
|
+
return coreFFI !== null;
|
|
145
|
+
}
|
|
146
|
+
function logAndDouble(msg, value) {
|
|
147
|
+
if (typeof coreFFI === "object" && coreFFI !== null && "logAndDouble" in coreFFI && typeof coreFFI.logAndDouble === "function") {
|
|
148
|
+
return coreFFI.logAndDouble(msg, value);
|
|
149
|
+
}
|
|
150
|
+
throw new Error("FFI not loaded or incompatible");
|
|
151
|
+
}
|
|
152
|
+
function getVersion() {
|
|
153
|
+
if (typeof coreFFI === "object" && coreFFI !== null && "getVersion" in coreFFI && typeof coreFFI.getVersion === "function") {
|
|
154
|
+
return coreFFI.getVersion();
|
|
155
|
+
}
|
|
156
|
+
throw new Error("FFI not loaded or incompatible");
|
|
157
|
+
}
|
|
158
|
+
var Core = {
|
|
159
|
+
/**
|
|
160
|
+
* Checks if FFI is available.
|
|
161
|
+
*/
|
|
162
|
+
isFfiAvailable,
|
|
163
|
+
/**
|
|
164
|
+
* Gets the native library version.
|
|
165
|
+
*/
|
|
166
|
+
getVersion,
|
|
167
|
+
/**
|
|
168
|
+
* Calls the native log and double function.
|
|
169
|
+
*/
|
|
170
|
+
logAndDouble,
|
|
171
|
+
/**
|
|
172
|
+
* Runs a core task or simply logs the current runtime status.
|
|
173
|
+
* @param {string} [task] - Optional task name to log.
|
|
174
|
+
* @param {Record<string, unknown>} [options] - Optional options for the task.
|
|
175
|
+
*/
|
|
176
|
+
run: (task, options) => {
|
|
177
|
+
coreLogger.info(`Running on ${runtime}. FFI: ${isFfiAvailable()}`);
|
|
178
|
+
if (task) {
|
|
179
|
+
coreLogger.info(`Task: ${task}`, options);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// src/database/postgres/postgres-db.ts
|
|
185
|
+
import { serializeError as serializeError4 } from "serialize-error";
|
|
186
|
+
|
|
187
|
+
// src/database/core/result.ts
|
|
188
|
+
import { serializeError as serializeError2 } from "serialize-error";
|
|
189
|
+
var wrapSuccess = (value, details) => ({
|
|
190
|
+
status: "success",
|
|
191
|
+
value,
|
|
192
|
+
details
|
|
193
|
+
});
|
|
194
|
+
var wrapError = (error) => ({
|
|
195
|
+
status: "error",
|
|
196
|
+
reason: serializeError2(error)
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// src/database/core/transaction-context.ts
|
|
200
|
+
import { serializeError as serializeError3 } from "serialize-error";
|
|
201
|
+
var transactionLogger = loggers_default.child({ section: "TransactionContext" });
|
|
202
|
+
var runtime2 = detectRuntime();
|
|
203
|
+
async function loadAsyncLocalStorage() {
|
|
204
|
+
try {
|
|
205
|
+
if (runtime2 === "deno") {
|
|
206
|
+
const { AsyncLocalStorage: AsyncLocalStorage2 } = await import("async_hooks");
|
|
207
|
+
return new AsyncLocalStorage2();
|
|
208
|
+
}
|
|
209
|
+
const { AsyncLocalStorage } = await import("async_hooks");
|
|
210
|
+
return new AsyncLocalStorage();
|
|
211
|
+
} catch (e) {
|
|
212
|
+
transactionLogger.error("Failed to load AsyncLocalStorage", {
|
|
213
|
+
error: serializeError3(e)
|
|
214
|
+
});
|
|
215
|
+
return void 0;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
var transactionStorage = await loadAsyncLocalStorage();
|
|
219
|
+
function getActiveTransaction() {
|
|
220
|
+
return transactionStorage?.getStore()?.driver;
|
|
221
|
+
}
|
|
222
|
+
function getActiveTxId() {
|
|
223
|
+
return transactionStorage?.getStore()?.txId;
|
|
224
|
+
}
|
|
225
|
+
async function runInTransaction(driver, txId, callback) {
|
|
226
|
+
if (!transactionStorage) {
|
|
227
|
+
return callback();
|
|
228
|
+
}
|
|
229
|
+
return transactionStorage.run({ driver, txId }, callback);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// src/database/redact.ts
|
|
233
|
+
var STRING_CAP = 256;
|
|
234
|
+
var TRUNC_KEEP = 64;
|
|
235
|
+
var ARRAY_CAP = 64;
|
|
236
|
+
var SECRET_KEY = /pass|secret|token|auth|key|cred/i;
|
|
237
|
+
var JWT = /^eyJ[\w-]+\.[\w-]+\.[\w-]+$/;
|
|
238
|
+
var LONG_HEX = /^[0-9a-f]{32,}$/i;
|
|
239
|
+
var LONG_B64 = /^[A-Za-z0-9+/_=-]{40,}$/;
|
|
240
|
+
function defaultRedactor(value) {
|
|
241
|
+
if (value === null || value === void 0) return value;
|
|
242
|
+
const t = typeof value;
|
|
243
|
+
if (t === "number" || t === "boolean" || t === "bigint") return value;
|
|
244
|
+
if (t === "string") {
|
|
245
|
+
const s = value;
|
|
246
|
+
if (JWT.test(s) || LONG_HEX.test(s) || LONG_B64.test(s)) {
|
|
247
|
+
return `<redacted:len=${s.length}>`;
|
|
248
|
+
}
|
|
249
|
+
if (s.length > STRING_CAP) {
|
|
250
|
+
return `${s.slice(0, TRUNC_KEEP)}\u2026(len=${s.length})`;
|
|
251
|
+
}
|
|
252
|
+
return s;
|
|
253
|
+
}
|
|
254
|
+
return "<redacted:object>";
|
|
255
|
+
}
|
|
256
|
+
function redactParams(params, redactor) {
|
|
257
|
+
if (params == null) return void 0;
|
|
258
|
+
if (Array.isArray(params)) {
|
|
259
|
+
const capped = params.slice(0, ARRAY_CAP).map((v) => redactor(v));
|
|
260
|
+
return params.length > ARRAY_CAP ? [...capped, `\u2026(+${params.length - ARRAY_CAP} more)`] : capped;
|
|
261
|
+
}
|
|
262
|
+
const out = {};
|
|
263
|
+
for (const [k, v] of Object.entries(params)) {
|
|
264
|
+
out[k] = SECRET_KEY.test(k) ? "<redacted:key>" : redactor(v);
|
|
265
|
+
}
|
|
266
|
+
return out;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/database/postgres/postgres-driver.ts
|
|
270
|
+
var PostgresDriver = class {
|
|
271
|
+
constructor(config) {
|
|
272
|
+
this.config = config;
|
|
273
|
+
}
|
|
274
|
+
config;
|
|
275
|
+
// Typed after dynamic import; null until connect() is called
|
|
276
|
+
client = null;
|
|
277
|
+
async connect() {
|
|
278
|
+
if (this.client) return;
|
|
279
|
+
const sql = (await import("postgres")).default;
|
|
280
|
+
this.client = sql(this.config.url, {
|
|
281
|
+
max: this.config.maxConnections,
|
|
282
|
+
ssl: this.config.ssl,
|
|
283
|
+
connect_timeout: this.config.timeoutMs ? this.config.timeoutMs / 1e3 : void 0
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
async disconnect() {
|
|
287
|
+
if (this.client) {
|
|
288
|
+
await this.client.end();
|
|
289
|
+
this.client = null;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
async query(sql, params) {
|
|
293
|
+
try {
|
|
294
|
+
const queryParams = Array.isArray(params) ? params : params ? Object.values(params) : [];
|
|
295
|
+
const client = this.client;
|
|
296
|
+
if (!client) throw new Error("Not connected");
|
|
297
|
+
const res = await client.unsafe(sql, queryParams);
|
|
298
|
+
return wrapSuccess({
|
|
299
|
+
rows: res,
|
|
300
|
+
affectedRows: res.count
|
|
301
|
+
});
|
|
302
|
+
} catch (e) {
|
|
303
|
+
return wrapError(e);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
async prepare(sql) {
|
|
307
|
+
try {
|
|
308
|
+
return wrapSuccess({
|
|
309
|
+
execute: async (params) => {
|
|
310
|
+
try {
|
|
311
|
+
const queryParams = Array.isArray(params) ? params : params ? Object.values(params) : [];
|
|
312
|
+
const prepClient = this.client;
|
|
313
|
+
if (!prepClient) throw new Error("Not connected");
|
|
314
|
+
const res = await prepClient.unsafe(sql, queryParams);
|
|
315
|
+
return wrapSuccess({
|
|
316
|
+
rows: res,
|
|
317
|
+
affectedRows: res.count
|
|
318
|
+
});
|
|
319
|
+
} catch (e) {
|
|
320
|
+
return wrapError(e);
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
close: async () => {
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
} catch (e) {
|
|
327
|
+
return wrapError(e);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
async beginTransaction() {
|
|
331
|
+
await this.client?.unsafe("BEGIN");
|
|
332
|
+
}
|
|
333
|
+
async commitTransaction() {
|
|
334
|
+
await this.client?.unsafe("COMMIT");
|
|
335
|
+
}
|
|
336
|
+
async rollbackTransaction() {
|
|
337
|
+
await this.client?.unsafe("ROLLBACK");
|
|
338
|
+
}
|
|
339
|
+
async stream(sql, params, onRow) {
|
|
340
|
+
try {
|
|
341
|
+
const queryParams = Array.isArray(params) ? params : params ? Object.values(params) : [];
|
|
342
|
+
const client = this.client;
|
|
343
|
+
if (!client) throw new Error("Not connected");
|
|
344
|
+
for await (const row of client.unsafe(sql, queryParams).cursor()) {
|
|
345
|
+
onRow(row);
|
|
346
|
+
}
|
|
347
|
+
return wrapSuccess(void 0);
|
|
348
|
+
} catch (e) {
|
|
349
|
+
return wrapError(e);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
// src/database/postgres/postgres-db.ts
|
|
355
|
+
var PostgresDb = class {
|
|
356
|
+
constructor(config) {
|
|
357
|
+
this.config = config;
|
|
358
|
+
this.driver = new PostgresDriver(config);
|
|
359
|
+
}
|
|
360
|
+
config;
|
|
361
|
+
driver;
|
|
362
|
+
/**
|
|
363
|
+
* Executes a single SQL query.
|
|
364
|
+
* Joins active transaction if called within a transaction block.
|
|
365
|
+
*/
|
|
366
|
+
async query(sql, params) {
|
|
367
|
+
const qid = nextCid();
|
|
368
|
+
const txDriver = getActiveTransaction();
|
|
369
|
+
const activeDriver = txDriver || this.driver;
|
|
370
|
+
const startedAt = performance.now();
|
|
371
|
+
const traceId = this.config.getTraceId?.();
|
|
372
|
+
const txId = getActiveTxId();
|
|
373
|
+
const corr = {
|
|
374
|
+
...traceId != null ? { traceId } : {},
|
|
375
|
+
...txId != null ? { txId } : {}
|
|
376
|
+
};
|
|
377
|
+
this.config.logger?.trace("query: exec", {
|
|
378
|
+
qid,
|
|
379
|
+
...corr,
|
|
380
|
+
sql,
|
|
381
|
+
hasParams: params != null,
|
|
382
|
+
nested: txDriver != null,
|
|
383
|
+
// Params logged ONLY when the project opted in with a redactor (default: off).
|
|
384
|
+
...this.config.paramRedactor && params != null ? { params: redactParams(params, this.config.paramRedactor) } : {}
|
|
385
|
+
});
|
|
386
|
+
try {
|
|
387
|
+
if (!txDriver) {
|
|
388
|
+
await activeDriver.connect();
|
|
389
|
+
}
|
|
390
|
+
const result = await activeDriver.query(sql, params);
|
|
391
|
+
const durationMs = performance.now() - startedAt;
|
|
392
|
+
if (result.status === "error") {
|
|
393
|
+
this.config.logger?.trace("query: error", {
|
|
394
|
+
qid,
|
|
395
|
+
...corr,
|
|
396
|
+
durationMs,
|
|
397
|
+
errorMsg: result.reason?.message ?? "unknown error"
|
|
398
|
+
});
|
|
399
|
+
this.config.logger?.error("Query execution failed", {
|
|
400
|
+
sql,
|
|
401
|
+
reason: result.reason
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
if (result.status === "success") {
|
|
405
|
+
this.config.logger?.trace("query: ok", {
|
|
406
|
+
qid,
|
|
407
|
+
...corr,
|
|
408
|
+
durationMs,
|
|
409
|
+
rows: result.value?.rows?.length ?? 0,
|
|
410
|
+
affectedRows: result.value?.affectedRows ?? 0,
|
|
411
|
+
lastInsertId: result.value?.lastInsertId
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
return result;
|
|
415
|
+
} catch (e) {
|
|
416
|
+
const durationMs = performance.now() - startedAt;
|
|
417
|
+
this.config.logger?.trace("query: error", {
|
|
418
|
+
qid,
|
|
419
|
+
...corr,
|
|
420
|
+
durationMs,
|
|
421
|
+
errorMsg: e instanceof Error ? e.message : String(e)
|
|
422
|
+
});
|
|
423
|
+
this.config.logger?.error("Query catastrophic failure", {
|
|
424
|
+
sql,
|
|
425
|
+
error: serializeError4(e)
|
|
426
|
+
});
|
|
427
|
+
return wrapError(e);
|
|
428
|
+
} finally {
|
|
429
|
+
if (!txDriver && this.config.mode === "stateless") {
|
|
430
|
+
await activeDriver.disconnect();
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Disconnects from the database.
|
|
436
|
+
*/
|
|
437
|
+
async disconnect() {
|
|
438
|
+
await this.driver.disconnect();
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Executes operations within a transaction using AsyncLocalStorage for context.
|
|
442
|
+
*/
|
|
443
|
+
async transaction(callback) {
|
|
444
|
+
const existingDriver = getActiveTransaction();
|
|
445
|
+
const driver = existingDriver || this.driver;
|
|
446
|
+
const isNested = !!existingDriver;
|
|
447
|
+
const txId = nextCid();
|
|
448
|
+
const savepointName = `sp_${Date.now()}_${Math.floor(Math.random() * 1e3)}`;
|
|
449
|
+
this.config.logger?.trace("tx: begin", { txId, isNested });
|
|
450
|
+
try {
|
|
451
|
+
await driver.connect();
|
|
452
|
+
if (isNested) {
|
|
453
|
+
const spResult = await driver.query(`SAVEPOINT ${savepointName}`);
|
|
454
|
+
if (spResult.status === "error") {
|
|
455
|
+
throw new Error(
|
|
456
|
+
`Failed to create savepoint: ${JSON.stringify(spResult.reason)}`
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
await driver.beginTransaction();
|
|
461
|
+
}
|
|
462
|
+
return await runInTransaction(driver, txId, async () => {
|
|
463
|
+
const result = await callback();
|
|
464
|
+
if (result.status === "success") {
|
|
465
|
+
if (isNested) {
|
|
466
|
+
await driver.query(`RELEASE SAVEPOINT ${savepointName}`);
|
|
467
|
+
} else {
|
|
468
|
+
await driver.commitTransaction();
|
|
469
|
+
}
|
|
470
|
+
this.config.logger?.trace("tx: commit", { txId, isNested });
|
|
471
|
+
} else {
|
|
472
|
+
this.config.logger?.warn("Transaction rollback initiated", {
|
|
473
|
+
txId,
|
|
474
|
+
reason: result.reason,
|
|
475
|
+
isNested
|
|
476
|
+
});
|
|
477
|
+
if (isNested) {
|
|
478
|
+
await driver.query(`ROLLBACK TO SAVEPOINT ${savepointName}`);
|
|
479
|
+
} else {
|
|
480
|
+
await driver.rollbackTransaction();
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return result;
|
|
484
|
+
});
|
|
485
|
+
} catch (e) {
|
|
486
|
+
this.config.logger?.error("Transaction failed due to exception", {
|
|
487
|
+
error: serializeError4(e),
|
|
488
|
+
isNested
|
|
489
|
+
});
|
|
490
|
+
try {
|
|
491
|
+
if (isNested) {
|
|
492
|
+
await driver.query(`ROLLBACK TO SAVEPOINT ${savepointName}`);
|
|
493
|
+
} else {
|
|
494
|
+
await driver.rollbackTransaction();
|
|
495
|
+
}
|
|
496
|
+
} catch (rollbackErr) {
|
|
497
|
+
this.config.logger?.error("Failed to rollback transaction", {
|
|
498
|
+
error: serializeError4(rollbackErr)
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
return wrapError(e);
|
|
502
|
+
} finally {
|
|
503
|
+
if (!isNested && this.config.mode === "stateless") {
|
|
504
|
+
await driver.disconnect();
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// src/database/sqlite/sqlite-db.ts
|
|
511
|
+
import { serializeError as serializeError5 } from "serialize-error";
|
|
512
|
+
|
|
513
|
+
// src/database/sqlite/sqlite-driver.ts
|
|
514
|
+
var SqliteDriver = class {
|
|
515
|
+
constructor(config) {
|
|
516
|
+
this.config = config;
|
|
517
|
+
}
|
|
518
|
+
config;
|
|
519
|
+
// Typed after dynamic import; null until connect() is called
|
|
520
|
+
client = null;
|
|
521
|
+
async connect() {
|
|
522
|
+
if (this.client) return;
|
|
523
|
+
const { createClient } = await import("@libsql/client");
|
|
524
|
+
this.client = createClient({
|
|
525
|
+
url: this.config.url,
|
|
526
|
+
authToken: this.config.authToken
|
|
527
|
+
});
|
|
528
|
+
const isLocalFile = /^file:|\.db($|\?)|^\.{0,2}\//.test(this.config.url);
|
|
529
|
+
if (this.config.journalMode && isLocalFile) {
|
|
530
|
+
await this.client.execute(
|
|
531
|
+
`PRAGMA journal_mode=${this.config.journalMode}`
|
|
532
|
+
);
|
|
533
|
+
if (this.config.synchronous) {
|
|
534
|
+
await this.client.execute(
|
|
535
|
+
`PRAGMA synchronous=${this.config.synchronous}`
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
async disconnect() {
|
|
541
|
+
if (this.client) {
|
|
542
|
+
await this.client.close();
|
|
543
|
+
this.client = null;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
async query(sql, params) {
|
|
547
|
+
try {
|
|
548
|
+
if (!this.client) throw new Error("Not connected");
|
|
549
|
+
const res = await this.client.execute({ sql, args: params || [] });
|
|
550
|
+
return wrapSuccess({
|
|
551
|
+
rows: res.rows,
|
|
552
|
+
affectedRows: Number(res.rowsAffected),
|
|
553
|
+
lastInsertId: res.lastInsertRowid?.toString()
|
|
554
|
+
});
|
|
555
|
+
} catch (e) {
|
|
556
|
+
return wrapError(e);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
async prepare(sql) {
|
|
560
|
+
try {
|
|
561
|
+
if (!this.client?.prepare) {
|
|
562
|
+
throw new Error(
|
|
563
|
+
"prepare() is not supported by this @libsql/client instance"
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
const stmt = this.client.prepare(sql);
|
|
567
|
+
return wrapSuccess({
|
|
568
|
+
execute: async (params) => {
|
|
569
|
+
try {
|
|
570
|
+
const res = await stmt.execute(params || []);
|
|
571
|
+
return wrapSuccess({
|
|
572
|
+
rows: res.rows,
|
|
573
|
+
affectedRows: Number(res.rowsAffected),
|
|
574
|
+
lastInsertId: res.lastInsertRowid?.toString()
|
|
575
|
+
});
|
|
576
|
+
} catch (e) {
|
|
577
|
+
return wrapError(e);
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
close: async () => await stmt.close()
|
|
581
|
+
});
|
|
582
|
+
} catch (e) {
|
|
583
|
+
return wrapError(e);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
async beginTransaction() {
|
|
587
|
+
await this.client?.execute("BEGIN");
|
|
588
|
+
}
|
|
589
|
+
async commitTransaction() {
|
|
590
|
+
await this.client?.execute("COMMIT");
|
|
591
|
+
}
|
|
592
|
+
async rollbackTransaction() {
|
|
593
|
+
await this.client?.execute("ROLLBACK");
|
|
594
|
+
}
|
|
595
|
+
async stream(sql, params, onRow) {
|
|
596
|
+
try {
|
|
597
|
+
if (!this.client?.prepare) {
|
|
598
|
+
throw new Error(
|
|
599
|
+
"stream() via prepare() is not supported by this @libsql/client instance"
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
const stmt = this.client.prepare(sql);
|
|
603
|
+
const cursor = await stmt.raw(params || []);
|
|
604
|
+
for (const row of cursor) {
|
|
605
|
+
onRow(row);
|
|
606
|
+
}
|
|
607
|
+
await stmt.close();
|
|
608
|
+
return wrapSuccess(void 0);
|
|
609
|
+
} catch (e) {
|
|
610
|
+
return wrapError(e);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
// src/database/sqlite/sqlite-db.ts
|
|
616
|
+
var SqliteDb = class {
|
|
617
|
+
constructor(config) {
|
|
618
|
+
this.config = config;
|
|
619
|
+
this.driver = new SqliteDriver(config);
|
|
620
|
+
}
|
|
621
|
+
config;
|
|
622
|
+
driver;
|
|
623
|
+
/**
|
|
624
|
+
* Executes a single SQL query.
|
|
625
|
+
* Joins active transaction if called within a transaction block.
|
|
626
|
+
*/
|
|
627
|
+
async query(sql, params) {
|
|
628
|
+
const qid = nextCid();
|
|
629
|
+
const txDriver = getActiveTransaction();
|
|
630
|
+
const activeDriver = txDriver || this.driver;
|
|
631
|
+
const startedAt = performance.now();
|
|
632
|
+
const traceId = this.config.getTraceId?.();
|
|
633
|
+
const txId = getActiveTxId();
|
|
634
|
+
const corr = {
|
|
635
|
+
...traceId != null ? { traceId } : {},
|
|
636
|
+
...txId != null ? { txId } : {}
|
|
637
|
+
};
|
|
638
|
+
this.config.logger?.trace("query: exec", {
|
|
639
|
+
qid,
|
|
640
|
+
...corr,
|
|
641
|
+
sql,
|
|
642
|
+
hasParams: params != null,
|
|
643
|
+
nested: txDriver != null,
|
|
644
|
+
// Params logged ONLY when the project opted in with a redactor (default: off).
|
|
645
|
+
...this.config.paramRedactor && params != null ? { params: redactParams(params, this.config.paramRedactor) } : {}
|
|
646
|
+
});
|
|
647
|
+
try {
|
|
648
|
+
if (!txDriver) {
|
|
649
|
+
await activeDriver.connect();
|
|
650
|
+
}
|
|
651
|
+
const result = await activeDriver.query(sql, params);
|
|
652
|
+
const durationMs = performance.now() - startedAt;
|
|
653
|
+
if (result.status === "error") {
|
|
654
|
+
this.config.logger?.trace("query: error", {
|
|
655
|
+
qid,
|
|
656
|
+
...corr,
|
|
657
|
+
durationMs,
|
|
658
|
+
errorMsg: result.reason?.message ?? "unknown error"
|
|
659
|
+
});
|
|
660
|
+
this.config.logger?.error("Query execution failed", {
|
|
661
|
+
sql,
|
|
662
|
+
reason: result.reason
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
if (result.status === "success") {
|
|
666
|
+
this.config.logger?.trace("query: ok", {
|
|
667
|
+
qid,
|
|
668
|
+
...corr,
|
|
669
|
+
durationMs,
|
|
670
|
+
rows: result.value?.rows?.length ?? 0,
|
|
671
|
+
affectedRows: result.value?.affectedRows ?? 0,
|
|
672
|
+
lastInsertId: result.value?.lastInsertId
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
return result;
|
|
676
|
+
} catch (e) {
|
|
677
|
+
const durationMs = performance.now() - startedAt;
|
|
678
|
+
this.config.logger?.trace("query: error", {
|
|
679
|
+
qid,
|
|
680
|
+
...corr,
|
|
681
|
+
durationMs,
|
|
682
|
+
errorMsg: e instanceof Error ? e.message : String(e)
|
|
683
|
+
});
|
|
684
|
+
this.config.logger?.error("Query catastrophic failure", {
|
|
685
|
+
sql,
|
|
686
|
+
error: serializeError5(e)
|
|
687
|
+
});
|
|
688
|
+
return wrapError(e);
|
|
689
|
+
} finally {
|
|
690
|
+
if (!txDriver && this.config.mode === "stateless") {
|
|
691
|
+
await activeDriver.disconnect();
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Disconnects from the database.
|
|
697
|
+
*/
|
|
698
|
+
async disconnect() {
|
|
699
|
+
await this.driver.disconnect();
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Executes operations within a transaction using AsyncLocalStorage for context.
|
|
703
|
+
*/
|
|
704
|
+
async transaction(callback) {
|
|
705
|
+
const existingDriver = getActiveTransaction();
|
|
706
|
+
const driver = existingDriver || this.driver;
|
|
707
|
+
const isNested = !!existingDriver;
|
|
708
|
+
const txId = nextCid();
|
|
709
|
+
const savepointName = `sp_${Date.now()}_${Math.floor(Math.random() * 1e3)}`;
|
|
710
|
+
this.config.logger?.trace("tx: begin", { txId, isNested });
|
|
711
|
+
try {
|
|
712
|
+
await driver.connect();
|
|
713
|
+
if (isNested) {
|
|
714
|
+
const spResult = await driver.query(`SAVEPOINT ${savepointName}`);
|
|
715
|
+
if (spResult.status === "error") {
|
|
716
|
+
throw new Error(
|
|
717
|
+
`Failed to create savepoint: ${JSON.stringify(spResult.reason)}`
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
} else {
|
|
721
|
+
await driver.beginTransaction();
|
|
722
|
+
}
|
|
723
|
+
return await runInTransaction(driver, txId, async () => {
|
|
724
|
+
const result = await callback();
|
|
725
|
+
if (result.status === "success") {
|
|
726
|
+
if (isNested) {
|
|
727
|
+
await driver.query(`RELEASE SAVEPOINT ${savepointName}`);
|
|
728
|
+
} else {
|
|
729
|
+
await driver.commitTransaction();
|
|
730
|
+
}
|
|
731
|
+
this.config.logger?.trace("tx: commit", { txId, isNested });
|
|
732
|
+
} else {
|
|
733
|
+
this.config.logger?.warn("Transaction rollback initiated", {
|
|
734
|
+
txId,
|
|
735
|
+
reason: result.reason,
|
|
736
|
+
isNested
|
|
737
|
+
});
|
|
738
|
+
if (isNested) {
|
|
739
|
+
await driver.query(`ROLLBACK TO SAVEPOINT ${savepointName}`);
|
|
740
|
+
} else {
|
|
741
|
+
await driver.rollbackTransaction();
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
return result;
|
|
745
|
+
});
|
|
746
|
+
} catch (e) {
|
|
747
|
+
this.config.logger?.error("Transaction failed due to exception", {
|
|
748
|
+
error: serializeError5(e),
|
|
749
|
+
isNested
|
|
750
|
+
});
|
|
751
|
+
try {
|
|
752
|
+
if (isNested) {
|
|
753
|
+
await driver.query(`ROLLBACK TO SAVEPOINT ${savepointName}`);
|
|
754
|
+
} else {
|
|
755
|
+
await driver.rollbackTransaction();
|
|
756
|
+
}
|
|
757
|
+
} catch (rollbackErr) {
|
|
758
|
+
this.config.logger?.error("Failed to rollback transaction", {
|
|
759
|
+
error: serializeError5(rollbackErr)
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
return wrapError(e);
|
|
763
|
+
} finally {
|
|
764
|
+
if (!isNested && this.config.mode === "stateless") {
|
|
765
|
+
await driver.disconnect();
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
// src/database/core/errors.ts
|
|
772
|
+
import { serializeError as serializeError6 } from "serialize-error";
|
|
773
|
+
function handleDbError(logger, message, error) {
|
|
774
|
+
const serialized = serializeError6(error);
|
|
775
|
+
logger.error(message, { error: serialized });
|
|
776
|
+
return serialized;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// src/database/index.ts
|
|
780
|
+
async function createDatabase(config) {
|
|
781
|
+
if (config.dialect === "postgres") {
|
|
782
|
+
return new PostgresDb(config);
|
|
783
|
+
}
|
|
784
|
+
return new SqliteDb(config);
|
|
785
|
+
}
|
|
786
|
+
var DatabaseSection = {
|
|
787
|
+
/**
|
|
788
|
+
* Current status of the database section.
|
|
789
|
+
*/
|
|
790
|
+
status: "active",
|
|
791
|
+
/**
|
|
792
|
+
* Reference to the default Database implementation (SqliteDb).
|
|
793
|
+
*/
|
|
794
|
+
Database: SqliteDb,
|
|
795
|
+
/**
|
|
796
|
+
* Factory function to create a database instance.
|
|
797
|
+
*/
|
|
798
|
+
createDatabase
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
// src/retrieve/RequestProxied.ts
|
|
802
|
+
import { serializeError as serializeError7 } from "serialize-error";
|
|
803
|
+
var requestProxiedLogger = loggers_default.child({ section: "RequestProxied" });
|
|
804
|
+
var RequestProxied = class {
|
|
805
|
+
activeProxies;
|
|
806
|
+
failureStreaks = /* @__PURE__ */ new Map();
|
|
807
|
+
currentIndex = 0;
|
|
808
|
+
/**
|
|
809
|
+
* @param proxies - Array of proxy base URLs (e.g. ["https://proxy1...", "https://proxy2..."]).
|
|
810
|
+
* At least one proxy is required. The array is cloned internally.
|
|
811
|
+
* @throws Error if no proxies are provided.
|
|
812
|
+
*/
|
|
813
|
+
constructor(proxies) {
|
|
814
|
+
if (!Array.isArray(proxies) || proxies.length === 0) {
|
|
815
|
+
throw new Error("RequestProxied: at least one proxy URL is required");
|
|
816
|
+
}
|
|
817
|
+
this.activeProxies = [...proxies];
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Builds the final proxy URL using the URL constructor.
|
|
821
|
+
* Guarantees correct query string handling (? vs &) and URL encoding of the original target.
|
|
822
|
+
*/
|
|
823
|
+
buildProxyUrl(proxyBase, suffix = "", targetUrl) {
|
|
824
|
+
const baseWithSlash = proxyBase.endsWith("/") ? proxyBase : `${proxyBase}/`;
|
|
825
|
+
const urlObj = new URL(suffix, baseWithSlash);
|
|
826
|
+
const targetStr = typeof targetUrl === "string" ? targetUrl : targetUrl instanceof URL ? targetUrl.toString() : targetUrl.url;
|
|
827
|
+
urlObj.searchParams.set("url", targetStr);
|
|
828
|
+
return urlObj.toString();
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Records a successful request for a proxy (resets failure streak).
|
|
832
|
+
*/
|
|
833
|
+
trackSuccess(proxyBase) {
|
|
834
|
+
this.failureStreaks.set(proxyBase, 0);
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Records a failure for a proxy.
|
|
838
|
+
* After 3 consecutive failures the proxy is permanently removed from the active list for this session.
|
|
839
|
+
*/
|
|
840
|
+
trackFailure(proxyBase) {
|
|
841
|
+
const streak = (this.failureStreaks.get(proxyBase) ?? 0) + 1;
|
|
842
|
+
this.failureStreaks.set(proxyBase, streak);
|
|
843
|
+
if (streak >= 3) {
|
|
844
|
+
this.activeProxies = this.activeProxies.filter((p) => p !== proxyBase);
|
|
845
|
+
this.failureStreaks.delete(proxyBase);
|
|
846
|
+
if (this.currentIndex >= this.activeProxies.length) {
|
|
847
|
+
this.currentIndex = 0;
|
|
848
|
+
}
|
|
849
|
+
requestProxiedLogger.warn("Proxy removed after 3 consecutive failures", {
|
|
850
|
+
proxy: proxyBase
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Makes a single proxied HTTP request with full fallback.
|
|
856
|
+
*
|
|
857
|
+
* @param url - Original target URL (same as RequestUnlimited).
|
|
858
|
+
* @param suffix - Optional path to append to the proxy base (default "").
|
|
859
|
+
* @param options - Ky options passed through to RequestUnlimited (headers, method, body, etc.).
|
|
860
|
+
*/
|
|
861
|
+
async endPoint(url, suffix = "", options = {}) {
|
|
862
|
+
if (this.activeProxies.length === 0) {
|
|
863
|
+
requestProxiedLogger.error("No active proxies left");
|
|
864
|
+
return {
|
|
865
|
+
status: "error",
|
|
866
|
+
reason: serializeError7(new Error("No active proxies left"))
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
let attempts = 0;
|
|
870
|
+
const _startIndex = this.currentIndex;
|
|
871
|
+
const targetStr = typeof url === "string" ? url : url instanceof URL ? url.toString() : url.url;
|
|
872
|
+
while (attempts < this.activeProxies.length) {
|
|
873
|
+
const proxyBase = this.activeProxies[this.currentIndex % this.activeProxies.length];
|
|
874
|
+
const proxyUrl = this.buildProxyUrl(proxyBase, suffix, targetStr);
|
|
875
|
+
this.currentIndex = (this.currentIndex + 1) % this.activeProxies.length;
|
|
876
|
+
const result = await endPoint(proxyUrl, options);
|
|
877
|
+
if (result.status === "success") {
|
|
878
|
+
this.trackSuccess(proxyBase);
|
|
879
|
+
return result;
|
|
880
|
+
}
|
|
881
|
+
this.trackFailure(proxyBase);
|
|
882
|
+
attempts++;
|
|
883
|
+
}
|
|
884
|
+
requestProxiedLogger.error("All proxies failed", {
|
|
885
|
+
originalUrl: targetStr
|
|
886
|
+
});
|
|
887
|
+
return {
|
|
888
|
+
status: "error",
|
|
889
|
+
reason: serializeError7(new Error("All proxies failed"))
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Makes parallel proxied requests with explicit round-robin load balancing.
|
|
894
|
+
*
|
|
895
|
+
* Each original URL is assigned to a proxy via round-robin.
|
|
896
|
+
* The constructed proxy URLs are then passed to RequestUnlimited.endPoints (parallelism + retries handled there).
|
|
897
|
+
*
|
|
898
|
+
* Note: failure tracking / auto-removal is currently only implemented for endPoint().
|
|
899
|
+
* endPoints uses the current activeProxies snapshot at call time.
|
|
900
|
+
*
|
|
901
|
+
* @param urls - Array of original target URLs.
|
|
902
|
+
* @param suffix - Optional suffix applied to every proxy (default "").
|
|
903
|
+
* @param options - Ky options applied to all requests.
|
|
904
|
+
*/
|
|
905
|
+
async endPoints(urls, suffix = "", options = {}) {
|
|
906
|
+
if (this.activeProxies.length === 0 || urls.length === 0) {
|
|
907
|
+
const noProxiesReason = serializeError7(new Error("No active proxies"));
|
|
908
|
+
return urls.map(() => ({
|
|
909
|
+
status: "error",
|
|
910
|
+
reason: noProxiesReason
|
|
911
|
+
}));
|
|
912
|
+
}
|
|
913
|
+
const proxyUrls = [];
|
|
914
|
+
for (let i = 0; i < urls.length; i++) {
|
|
915
|
+
const proxyBase = this.activeProxies[i % this.activeProxies.length];
|
|
916
|
+
const target = urls[i];
|
|
917
|
+
const targetStr = typeof target === "string" ? target : target instanceof URL ? target.toString() : target.url;
|
|
918
|
+
proxyUrls.push(this.buildProxyUrl(proxyBase, suffix, targetStr));
|
|
919
|
+
}
|
|
920
|
+
return await endPoints(proxyUrls, options);
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
|
|
924
|
+
// src/retrieve/index.ts
|
|
925
|
+
var retrieveLogger = loggers_default.child({ section: "Retrieve" });
|
|
926
|
+
var Retrieve = {
|
|
927
|
+
run: () => retrieveLogger.info(`Running on ${detectRuntime()}`)
|
|
928
|
+
};
|
|
929
|
+
export {
|
|
930
|
+
ConfigManager,
|
|
931
|
+
Core,
|
|
932
|
+
DatabaseSection,
|
|
933
|
+
PostgresDb,
|
|
934
|
+
PostgresDriver,
|
|
935
|
+
RequestProxied,
|
|
936
|
+
RequestResponseSerialize,
|
|
937
|
+
RequestUnlimited,
|
|
938
|
+
Retrieve,
|
|
939
|
+
SqliteDb,
|
|
940
|
+
SqliteDriver,
|
|
941
|
+
SysInfo,
|
|
942
|
+
Utils,
|
|
943
|
+
coreFFI,
|
|
944
|
+
createDatabase,
|
|
945
|
+
defaultRedactor,
|
|
946
|
+
detectRuntime,
|
|
947
|
+
endPoint,
|
|
948
|
+
endPoints,
|
|
949
|
+
existsSync,
|
|
950
|
+
getActiveTransaction,
|
|
951
|
+
getActiveTxId,
|
|
952
|
+
getAllEnv,
|
|
953
|
+
getCwd,
|
|
954
|
+
getDirname,
|
|
955
|
+
getEnv,
|
|
956
|
+
getMode,
|
|
957
|
+
getPlatform,
|
|
958
|
+
getRequire,
|
|
959
|
+
getSysInfo,
|
|
960
|
+
getTempDir,
|
|
961
|
+
getVersion,
|
|
962
|
+
handleDbError,
|
|
963
|
+
includeExcludeCron,
|
|
964
|
+
isFfiAvailable,
|
|
965
|
+
logAndDouble,
|
|
966
|
+
loggers_default as logger,
|
|
967
|
+
nextCid,
|
|
968
|
+
readTextFileSync,
|
|
969
|
+
redactParams,
|
|
970
|
+
runInTransaction,
|
|
971
|
+
sleep,
|
|
972
|
+
transactionStorage,
|
|
973
|
+
wrapError,
|
|
974
|
+
wrapSuccess
|
|
975
|
+
};
|