tradeblocks-mcp 2.2.4 → 2.2.6
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 +22 -1
- package/dist/{chunk-O6FQQRJV.js → chunk-FIKAXL2L.js} +35 -17
- package/dist/chunk-FIKAXL2L.js.map +1 -0
- package/dist/{sync-AAV7BGOE.js → sync-2TUYF36I.js} +6 -2
- package/dist/test-exports.js +1 -1
- package/package.json +1 -1
- package/server/{chunk-TDKK4QFM.js → chunk-IBEPOZZK.js} +35 -17
- package/server/chunk-IBEPOZZK.js.map +1 -0
- package/server/index.js +32 -7
- package/server/index.js.map +1 -1
- package/server/{sync-T6GEBPJ7.js → sync-37YJXJVW.js} +6 -2
- package/dist/chunk-O6FQQRJV.js.map +0 -1
- package/server/chunk-TDKK4QFM.js.map +0 -1
- /package/dist/{sync-AAV7BGOE.js.map → sync-2TUYF36I.js.map} +0 -0
- /package/server/{sync-T6GEBPJ7.js.map → sync-37YJXJVW.js.map} +0 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deleteSyncMetadata,
|
|
3
3
|
getAllSyncedBlockIds,
|
|
4
|
+
getBlocksDir,
|
|
4
5
|
getSyncMetadata,
|
|
5
6
|
hashFileContent,
|
|
7
|
+
setBlocksDir,
|
|
6
8
|
syncAllBlocks,
|
|
7
9
|
syncBlock,
|
|
8
10
|
upsertSyncMetadata
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FIKAXL2L.js";
|
|
10
12
|
import "./chunk-MIVAK2ZU.js";
|
|
11
13
|
import "./chunk-PWM4JHGO.js";
|
|
12
14
|
import "./chunk-KRHCV4RF.js";
|
|
@@ -15,10 +17,12 @@ import "./chunk-5WRI5ZAA.js";
|
|
|
15
17
|
export {
|
|
16
18
|
deleteSyncMetadata,
|
|
17
19
|
getAllSyncedBlockIds,
|
|
20
|
+
getBlocksDir,
|
|
18
21
|
getSyncMetadata,
|
|
19
22
|
hashFileContent,
|
|
23
|
+
setBlocksDir,
|
|
20
24
|
syncAllBlocks,
|
|
21
25
|
syncBlock,
|
|
22
26
|
upsertSyncMetadata
|
|
23
27
|
};
|
|
24
|
-
//# sourceMappingURL=sync-
|
|
28
|
+
//# sourceMappingURL=sync-2TUYF36I.js.map
|
package/dist/test-exports.js
CHANGED
package/package.json
CHANGED
|
@@ -808,14 +808,18 @@ async function getConnection(dataDir) {
|
|
|
808
808
|
if (isLockError(errorMessage)) {
|
|
809
809
|
const recovered = await tryRecoverLockByTerminatingStaleProcess(errorMessage, dbPath, forceRecovery);
|
|
810
810
|
if (recovered) {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
811
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
812
|
+
await new Promise((r) => setTimeout(r, 500 * (attempt + 1)));
|
|
813
|
+
try {
|
|
814
|
+
return await openReadWriteConnection(dbPath, threads, memoryLimit);
|
|
815
|
+
} catch (retryError) {
|
|
816
|
+
const retryMsg = retryError instanceof Error ? retryError.message : String(retryError);
|
|
817
|
+
if (attempt < 2 && isLockError(retryMsg)) continue;
|
|
818
|
+
resetConnectionState();
|
|
819
|
+
throw new Error(
|
|
820
|
+
`Failed to initialize DuckDB at ${dbPath} after lock recovery: ${retryMsg}`
|
|
821
|
+
);
|
|
822
|
+
}
|
|
819
823
|
}
|
|
820
824
|
}
|
|
821
825
|
}
|
|
@@ -858,8 +862,8 @@ async function closeConnection() {
|
|
|
858
862
|
async function upgradeToReadWrite(dataDir, options) {
|
|
859
863
|
if (connectionMode === "read_write" && connection) return connection;
|
|
860
864
|
await closeConnection();
|
|
861
|
-
const maxRetries =
|
|
862
|
-
const retryDelayMs =
|
|
865
|
+
const maxRetries = 4;
|
|
866
|
+
const retryDelayMs = 1e3;
|
|
863
867
|
let lastError = null;
|
|
864
868
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
865
869
|
try {
|
|
@@ -26300,13 +26304,16 @@ async function detectBlockChanges(conn, baseDir) {
|
|
|
26300
26304
|
const folderNames = /* @__PURE__ */ new Set();
|
|
26301
26305
|
for (const entry of entries) {
|
|
26302
26306
|
if (!entry.isDirectory()) continue;
|
|
26303
|
-
if (entry.name.startsWith(".")) continue;
|
|
26304
|
-
if (entry.name
|
|
26307
|
+
if (entry.name.startsWith(".") || entry.name.startsWith("_")) continue;
|
|
26308
|
+
if (entry.name.includes(".")) continue;
|
|
26305
26309
|
const blockId = entry.name;
|
|
26306
26310
|
folderNames.add(blockId);
|
|
26307
26311
|
const blockPath = path4.join(baseDir, blockId);
|
|
26308
26312
|
if (!syncedBlockIds.has(blockId)) {
|
|
26309
|
-
|
|
26313
|
+
const tradelog = await findTradelogFile(blockPath);
|
|
26314
|
+
if (tradelog) {
|
|
26315
|
+
toSync.push(blockId);
|
|
26316
|
+
}
|
|
26310
26317
|
continue;
|
|
26311
26318
|
}
|
|
26312
26319
|
const tradelogFilename = await findTradelogFile(blockPath);
|
|
@@ -26365,11 +26372,19 @@ async function cleanupDeletedBlocks(conn, deletedBlockIds) {
|
|
|
26365
26372
|
}
|
|
26366
26373
|
|
|
26367
26374
|
// src/sync/index.ts
|
|
26375
|
+
var _blocksDir = null;
|
|
26376
|
+
function setBlocksDir(dir) {
|
|
26377
|
+
_blocksDir = dir;
|
|
26378
|
+
}
|
|
26379
|
+
function getBlocksDir(baseDir) {
|
|
26380
|
+
return _blocksDir ?? baseDir;
|
|
26381
|
+
}
|
|
26368
26382
|
async function syncAllBlocks(baseDir) {
|
|
26369
26383
|
const conn = await getConnection(baseDir);
|
|
26384
|
+
const blocksDir = getBlocksDir(baseDir);
|
|
26370
26385
|
const results = [];
|
|
26371
26386
|
const errors = [];
|
|
26372
|
-
const { toSync, toDelete } = await detectBlockChanges(conn,
|
|
26387
|
+
const { toSync, toDelete } = await detectBlockChanges(conn, blocksDir);
|
|
26373
26388
|
for (const blockId of toDelete) {
|
|
26374
26389
|
try {
|
|
26375
26390
|
await cleanupDeletedBlocks(conn, [blockId]);
|
|
@@ -26380,7 +26395,7 @@ async function syncAllBlocks(baseDir) {
|
|
|
26380
26395
|
}
|
|
26381
26396
|
}
|
|
26382
26397
|
for (const blockId of toSync) {
|
|
26383
|
-
const blockPath = path5.join(
|
|
26398
|
+
const blockPath = path5.join(blocksDir, blockId);
|
|
26384
26399
|
const result = await syncBlockInternal(conn, blockId, blockPath);
|
|
26385
26400
|
results.push(result);
|
|
26386
26401
|
if (result.status === "error" && result.error) {
|
|
@@ -26398,7 +26413,8 @@ async function syncAllBlocks(baseDir) {
|
|
|
26398
26413
|
}
|
|
26399
26414
|
async function syncBlock(blockId, baseDir) {
|
|
26400
26415
|
const conn = await getConnection(baseDir);
|
|
26401
|
-
const
|
|
26416
|
+
const blocksDir = getBlocksDir(baseDir);
|
|
26417
|
+
const blockPath = path5.join(blocksDir, blockId);
|
|
26402
26418
|
try {
|
|
26403
26419
|
await fs6.access(blockPath);
|
|
26404
26420
|
} catch {
|
|
@@ -26467,6 +26483,8 @@ export {
|
|
|
26467
26483
|
deleteSyncMetadata,
|
|
26468
26484
|
getAllSyncedBlockIds,
|
|
26469
26485
|
upsertMarketImportMetadata,
|
|
26486
|
+
setBlocksDir,
|
|
26487
|
+
getBlocksDir,
|
|
26470
26488
|
syncAllBlocks,
|
|
26471
26489
|
syncBlock
|
|
26472
26490
|
};
|
|
@@ -26481,4 +26499,4 @@ decimal.js/decimal.mjs:
|
|
|
26481
26499
|
* MIT Licence
|
|
26482
26500
|
*)
|
|
26483
26501
|
*/
|
|
26484
|
-
//# sourceMappingURL=chunk-
|
|
26502
|
+
//# sourceMappingURL=chunk-IBEPOZZK.js.map
|