@ontos-ai/knowhere-sdk 2.7.0 → 2.7.1
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.
|
@@ -768,15 +768,17 @@ function readObjectVersion(object) {
|
|
|
768
768
|
return { entityTag: object.entityTag, contentLength: object.contentLength };
|
|
769
769
|
}
|
|
770
770
|
function validateCachedResponse(response, marker, signal) {
|
|
771
|
-
if (response.
|
|
771
|
+
if (response.status !== 206 || !response.body)
|
|
772
772
|
rejectResponse(
|
|
773
773
|
response,
|
|
774
|
-
new ArchiveCacheTransportError(
|
|
774
|
+
new ArchiveCacheTransportError(
|
|
775
|
+
`Parsed result archive cache requires a ranged response (HTTP ${response.status}).`
|
|
776
|
+
)
|
|
775
777
|
);
|
|
776
|
-
if (response.
|
|
778
|
+
if (response.headers.get("etag") !== marker.storageEntityTag)
|
|
777
779
|
rejectResponse(
|
|
778
780
|
response,
|
|
779
|
-
new ArchiveCacheTransportError("Parsed result archive cache
|
|
781
|
+
new ArchiveCacheTransportError("Parsed result archive cache response version changed.")
|
|
780
782
|
);
|
|
781
783
|
const range = /^bytes (\d+)-(\d+)\/(\d+)$/.exec(
|
|
782
784
|
response.headers.get("content-range") ?? ""
|
|
@@ -843,7 +845,10 @@ function isPositiveInteger(value) {
|
|
|
843
845
|
}
|
|
844
846
|
|
|
845
847
|
// src/storage/streamed-parsed-document-sync.ts
|
|
846
|
-
import {
|
|
848
|
+
import {
|
|
849
|
+
HttpRangeReader,
|
|
850
|
+
ZipReader
|
|
851
|
+
} from "@zip.js/zip.js";
|
|
847
852
|
async function syncRemoteResultArchive(params) {
|
|
848
853
|
params.signal?.throwIfAborted();
|
|
849
854
|
validateArchiveSyncLimits(params.limits);
|
|
@@ -854,10 +859,14 @@ async function syncRemoteResultArchive(params) {
|
|
|
854
859
|
const checkpointIntervalMs = params.limits?.checkpointIntervalMs ?? 2e3;
|
|
855
860
|
const controller = new AbortController();
|
|
856
861
|
const signal = params.signal ? AbortSignal.any([params.signal, controller.signal]) : controller.signal;
|
|
857
|
-
const
|
|
862
|
+
const openingParams = { ...params, signal };
|
|
858
863
|
const previous = await params.storage.readSyncProgress(params);
|
|
859
|
-
const openedSource = await openArchive(
|
|
864
|
+
const openedSource = await openArchive(openingParams, previous);
|
|
860
865
|
const source = !openedSource.canSkipEntries && previous?.archiveIdentity && previous.archiveDownloadIdentity === openedSource.downloadIdentity ? { ...openedSource, identity: previous.archiveIdentity } : openedSource;
|
|
866
|
+
const transferParams = {
|
|
867
|
+
...openingParams,
|
|
868
|
+
signal: source.signal ?? signal
|
|
869
|
+
};
|
|
861
870
|
const archiveDownloadIdentity = source.isCached ? source.downloadIdentity : previous?.archiveDownloadIdentity;
|
|
862
871
|
const concurrency = source.canSkipEntries ? params.limits?.maxConcurrentFiles ?? 1 : 1;
|
|
863
872
|
const nextEntry = previous?.status === "completed" ? 0 : previous?.nextArchiveEntry ?? 0;
|
|
@@ -1159,6 +1168,50 @@ async function persistArchiveCacheBypass(params, previous) {
|
|
|
1159
1168
|
await params.storage.writeSyncProgress(progress, { signal: params.signal });
|
|
1160
1169
|
return progress;
|
|
1161
1170
|
}
|
|
1171
|
+
var AbortableHttpRangeReader = class extends HttpRangeReader {
|
|
1172
|
+
constructor(url, options, controller) {
|
|
1173
|
+
super(url, options);
|
|
1174
|
+
this.controller = controller;
|
|
1175
|
+
}
|
|
1176
|
+
controller;
|
|
1177
|
+
createReadable(options) {
|
|
1178
|
+
const reader = super.createReadable(options).getReader();
|
|
1179
|
+
const cancellation = this.controller;
|
|
1180
|
+
return new ReadableStream(
|
|
1181
|
+
{
|
|
1182
|
+
async pull(output) {
|
|
1183
|
+
try {
|
|
1184
|
+
const chunk = await reader.read();
|
|
1185
|
+
if (chunk.done) {
|
|
1186
|
+
reader.releaseLock();
|
|
1187
|
+
output.close();
|
|
1188
|
+
} else output.enqueue(chunk.value);
|
|
1189
|
+
} catch (error) {
|
|
1190
|
+
cancellation.abort(error);
|
|
1191
|
+
reader.releaseLock();
|
|
1192
|
+
output.error(error);
|
|
1193
|
+
}
|
|
1194
|
+
},
|
|
1195
|
+
async cancel(reason) {
|
|
1196
|
+
try {
|
|
1197
|
+
await reader.cancel(reason);
|
|
1198
|
+
} finally {
|
|
1199
|
+
reader.releaseLock();
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
},
|
|
1203
|
+
{ highWaterMark: 0 }
|
|
1204
|
+
);
|
|
1205
|
+
}
|
|
1206
|
+
async readUint8Array(index, length) {
|
|
1207
|
+
try {
|
|
1208
|
+
return await super.readUint8Array(index, length);
|
|
1209
|
+
} catch (error) {
|
|
1210
|
+
this.controller.abort(error);
|
|
1211
|
+
throw error;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1162
1215
|
async function openArchiveTransport(params, previous, prepared) {
|
|
1163
1216
|
const resultUrl = prepared?.resultUrl ?? params.resultUrl;
|
|
1164
1217
|
const archiveCacheBypassed = prepared?.archiveCacheBypassed ?? previous?.archiveCacheBypassed;
|
|
@@ -1175,7 +1228,7 @@ async function openArchiveTransport(params, previous, prepared) {
|
|
|
1175
1228
|
const supportsRange = probe.status === 206 && probe.headers.has("content-range");
|
|
1176
1229
|
await probe.body?.cancel();
|
|
1177
1230
|
if (!supportsRange) {
|
|
1178
|
-
const { openSequentialArchive } = await import("./sequential-parsed-document-archive-
|
|
1231
|
+
const { openSequentialArchive } = await import("./sequential-parsed-document-archive-LPXA7W6W.mjs");
|
|
1179
1232
|
const source = await openSequentialArchive(
|
|
1180
1233
|
{ ...params, resultUrl },
|
|
1181
1234
|
identity,
|
|
@@ -1183,32 +1236,43 @@ async function openArchiveTransport(params, previous, prepared) {
|
|
|
1183
1236
|
);
|
|
1184
1237
|
return { ...source, archiveCacheBypassed };
|
|
1185
1238
|
}
|
|
1239
|
+
const rangeController = new AbortController();
|
|
1240
|
+
const rangeSignal = params.signal ? AbortSignal.any([params.signal, rangeController.signal]) : rangeController.signal;
|
|
1186
1241
|
const options = {
|
|
1187
1242
|
forceRangeRequests: true,
|
|
1188
1243
|
preventHeadRequest: true,
|
|
1189
1244
|
// Cached reads already pin a strong ETag and exact lengths; CDN timestamps can drift.
|
|
1190
1245
|
checkResourceChanges: !prepared?.isCached,
|
|
1191
1246
|
fetch: async (input, init) => {
|
|
1192
|
-
let response;
|
|
1193
1247
|
try {
|
|
1194
|
-
response
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1248
|
+
let response;
|
|
1249
|
+
try {
|
|
1250
|
+
response = await fetch(input, { ...init, signal: rangeSignal });
|
|
1251
|
+
} catch (error) {
|
|
1252
|
+
rangeSignal.throwIfAborted();
|
|
1253
|
+
if (prepared?.isCached)
|
|
1254
|
+
throw new ArchiveCacheTransportError(
|
|
1255
|
+
"Parsed result archive cache transport unavailable."
|
|
1256
|
+
);
|
|
1257
|
+
throw error;
|
|
1258
|
+
}
|
|
1259
|
+
if (prepared?.isCached) return prepared.validateResponse(response);
|
|
1260
|
+
if (response.status !== 206) {
|
|
1261
|
+
const error = new Error(
|
|
1262
|
+
`Parsed result Range request failed (HTTP ${response.status}).`
|
|
1200
1263
|
);
|
|
1264
|
+
rangeController.abort(error);
|
|
1265
|
+
await response.body?.cancel(error).catch(() => void 0);
|
|
1266
|
+
throw error;
|
|
1267
|
+
}
|
|
1268
|
+
return prepared ? prepared.validateResponse(response) : response;
|
|
1269
|
+
} catch (error) {
|
|
1270
|
+
rangeController.abort(error);
|
|
1201
1271
|
throw error;
|
|
1202
1272
|
}
|
|
1203
|
-
if (prepared?.isCached) return prepared.validateResponse(response);
|
|
1204
|
-
if (response.status !== 206) {
|
|
1205
|
-
await response.body?.cancel();
|
|
1206
|
-
throw new Error(`Parsed result Range request failed (HTTP ${response.status}).`);
|
|
1207
|
-
}
|
|
1208
|
-
return prepared ? prepared.validateResponse(response) : response;
|
|
1209
1273
|
}
|
|
1210
1274
|
};
|
|
1211
|
-
const reader = new ZipReader(new
|
|
1275
|
+
const reader = new ZipReader(new AbortableHttpRangeReader(resultUrl, options, rangeController), {
|
|
1212
1276
|
useWebWorkers: false,
|
|
1213
1277
|
checkCrc32: true
|
|
1214
1278
|
});
|
|
@@ -1224,6 +1288,7 @@ async function openArchiveTransport(params, previous, prepared) {
|
|
|
1224
1288
|
)
|
|
1225
1289
|
).digest("hex");
|
|
1226
1290
|
return {
|
|
1291
|
+
signal: rangeSignal,
|
|
1227
1292
|
identity: previous?.archiveIdentity === identity ? identity : archiveIdentity,
|
|
1228
1293
|
downloadIdentity: identity,
|
|
1229
1294
|
archiveCacheBypassed,
|
|
@@ -1243,7 +1308,7 @@ async function openArchiveTransport(params, previous, prepared) {
|
|
|
1243
1308
|
path: normalizeResultPath(entry.filename),
|
|
1244
1309
|
contentLength: entry.uncompressedSize,
|
|
1245
1310
|
read: () => {
|
|
1246
|
-
entryRead = readRangeEntry(entry,
|
|
1311
|
+
entryRead = readRangeEntry(entry, rangeSignal, producers);
|
|
1247
1312
|
return entryRead.body;
|
|
1248
1313
|
},
|
|
1249
1314
|
waitForRead: () => entryRead?.completed ?? Promise.resolve()
|
|
@@ -1256,6 +1321,7 @@ async function openArchiveTransport(params, previous, prepared) {
|
|
|
1256
1321
|
}
|
|
1257
1322
|
};
|
|
1258
1323
|
} catch (error) {
|
|
1324
|
+
rangeController.abort(error);
|
|
1259
1325
|
await reader.close();
|
|
1260
1326
|
throw error;
|
|
1261
1327
|
}
|
|
@@ -1267,10 +1333,16 @@ function readRangeEntry(entry, signal, producers) {
|
|
|
1267
1333
|
streamController = controller;
|
|
1268
1334
|
}
|
|
1269
1335
|
});
|
|
1336
|
+
const cancelOutput = () => {
|
|
1337
|
+
streamController?.error(signal?.reason);
|
|
1338
|
+
};
|
|
1339
|
+
signal?.addEventListener("abort", cancelOutput, { once: true });
|
|
1340
|
+
if (signal?.aborted) cancelOutput();
|
|
1270
1341
|
const completed = entry.getData(stream.writable, { signal, checkCrc32: true, useWebWorkers: false }).then(() => void 0);
|
|
1271
1342
|
const producer = completed.catch((error) => {
|
|
1272
1343
|
streamController?.error(error);
|
|
1273
1344
|
}).finally(() => {
|
|
1345
|
+
signal?.removeEventListener("abort", cancelOutput);
|
|
1274
1346
|
producers.delete(producer);
|
|
1275
1347
|
});
|
|
1276
1348
|
producers.add(producer);
|
|
@@ -1335,7 +1407,7 @@ async function validateRequiredObjects(params, paths) {
|
|
|
1335
1407
|
if (!paths.has(path)) throw new Error(`Required parsed result file missing: ${path}`);
|
|
1336
1408
|
}
|
|
1337
1409
|
async function verifyArchiveChecksum(params, identity, expectedEntryHashes, retainResultArchive = false, validateResponse) {
|
|
1338
|
-
const { openSequentialArchive } = await import("./sequential-parsed-document-archive-
|
|
1410
|
+
const { openSequentialArchive } = await import("./sequential-parsed-document-archive-LPXA7W6W.mjs");
|
|
1339
1411
|
const source = await openSequentialArchive(params, identity, validateResponse);
|
|
1340
1412
|
let entryIndex = 0;
|
|
1341
1413
|
try {
|
package/dist/index.js
CHANGED
|
@@ -854,15 +854,17 @@ function readObjectVersion(object) {
|
|
|
854
854
|
return { entityTag: object.entityTag, contentLength: object.contentLength };
|
|
855
855
|
}
|
|
856
856
|
function validateCachedResponse(response, marker, signal) {
|
|
857
|
-
if (response.
|
|
857
|
+
if (response.status !== 206 || !response.body)
|
|
858
858
|
rejectResponse(
|
|
859
859
|
response,
|
|
860
|
-
new ArchiveCacheTransportError(
|
|
860
|
+
new ArchiveCacheTransportError(
|
|
861
|
+
`Parsed result archive cache requires a ranged response (HTTP ${response.status}).`
|
|
862
|
+
)
|
|
861
863
|
);
|
|
862
|
-
if (response.
|
|
864
|
+
if (response.headers.get("etag") !== marker.storageEntityTag)
|
|
863
865
|
rejectResponse(
|
|
864
866
|
response,
|
|
865
|
-
new ArchiveCacheTransportError("Parsed result archive cache
|
|
867
|
+
new ArchiveCacheTransportError("Parsed result archive cache response version changed.")
|
|
866
868
|
);
|
|
867
869
|
const range = /^bytes (\d+)-(\d+)\/(\d+)$/.exec(
|
|
868
870
|
response.headers.get("content-range") ?? ""
|
|
@@ -1122,10 +1124,14 @@ async function syncRemoteResultArchive(params) {
|
|
|
1122
1124
|
const checkpointIntervalMs = params.limits?.checkpointIntervalMs ?? 2e3;
|
|
1123
1125
|
const controller = new AbortController();
|
|
1124
1126
|
const signal = params.signal ? AbortSignal.any([params.signal, controller.signal]) : controller.signal;
|
|
1125
|
-
const
|
|
1127
|
+
const openingParams = { ...params, signal };
|
|
1126
1128
|
const previous = await params.storage.readSyncProgress(params);
|
|
1127
|
-
const openedSource = await openArchive(
|
|
1129
|
+
const openedSource = await openArchive(openingParams, previous);
|
|
1128
1130
|
const source = !openedSource.canSkipEntries && previous?.archiveIdentity && previous.archiveDownloadIdentity === openedSource.downloadIdentity ? { ...openedSource, identity: previous.archiveIdentity } : openedSource;
|
|
1131
|
+
const transferParams = {
|
|
1132
|
+
...openingParams,
|
|
1133
|
+
signal: source.signal ?? signal
|
|
1134
|
+
};
|
|
1129
1135
|
const archiveDownloadIdentity = source.isCached ? source.downloadIdentity : previous?.archiveDownloadIdentity;
|
|
1130
1136
|
const concurrency = source.canSkipEntries ? params.limits?.maxConcurrentFiles ?? 1 : 1;
|
|
1131
1137
|
const nextEntry = previous?.status === "completed" ? 0 : previous?.nextArchiveEntry ?? 0;
|
|
@@ -1451,32 +1457,43 @@ async function openArchiveTransport(params, previous, prepared) {
|
|
|
1451
1457
|
);
|
|
1452
1458
|
return { ...source, archiveCacheBypassed };
|
|
1453
1459
|
}
|
|
1460
|
+
const rangeController = new AbortController();
|
|
1461
|
+
const rangeSignal = params.signal ? AbortSignal.any([params.signal, rangeController.signal]) : rangeController.signal;
|
|
1454
1462
|
const options = {
|
|
1455
1463
|
forceRangeRequests: true,
|
|
1456
1464
|
preventHeadRequest: true,
|
|
1457
1465
|
// Cached reads already pin a strong ETag and exact lengths; CDN timestamps can drift.
|
|
1458
1466
|
checkResourceChanges: !prepared?.isCached,
|
|
1459
1467
|
fetch: async (input, init) => {
|
|
1460
|
-
let response;
|
|
1461
1468
|
try {
|
|
1462
|
-
response
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1469
|
+
let response;
|
|
1470
|
+
try {
|
|
1471
|
+
response = await fetch(input, { ...init, signal: rangeSignal });
|
|
1472
|
+
} catch (error) {
|
|
1473
|
+
rangeSignal.throwIfAborted();
|
|
1474
|
+
if (prepared?.isCached)
|
|
1475
|
+
throw new ArchiveCacheTransportError(
|
|
1476
|
+
"Parsed result archive cache transport unavailable."
|
|
1477
|
+
);
|
|
1478
|
+
throw error;
|
|
1479
|
+
}
|
|
1480
|
+
if (prepared?.isCached) return prepared.validateResponse(response);
|
|
1481
|
+
if (response.status !== 206) {
|
|
1482
|
+
const error = new Error(
|
|
1483
|
+
`Parsed result Range request failed (HTTP ${response.status}).`
|
|
1468
1484
|
);
|
|
1485
|
+
rangeController.abort(error);
|
|
1486
|
+
await response.body?.cancel(error).catch(() => void 0);
|
|
1487
|
+
throw error;
|
|
1488
|
+
}
|
|
1489
|
+
return prepared ? prepared.validateResponse(response) : response;
|
|
1490
|
+
} catch (error) {
|
|
1491
|
+
rangeController.abort(error);
|
|
1469
1492
|
throw error;
|
|
1470
1493
|
}
|
|
1471
|
-
if (prepared?.isCached) return prepared.validateResponse(response);
|
|
1472
|
-
if (response.status !== 206) {
|
|
1473
|
-
await response.body?.cancel();
|
|
1474
|
-
throw new Error(`Parsed result Range request failed (HTTP ${response.status}).`);
|
|
1475
|
-
}
|
|
1476
|
-
return prepared ? prepared.validateResponse(response) : response;
|
|
1477
1494
|
}
|
|
1478
1495
|
};
|
|
1479
|
-
const reader = new import_zip2.ZipReader(new
|
|
1496
|
+
const reader = new import_zip2.ZipReader(new AbortableHttpRangeReader(resultUrl, options, rangeController), {
|
|
1480
1497
|
useWebWorkers: false,
|
|
1481
1498
|
checkCrc32: true
|
|
1482
1499
|
});
|
|
@@ -1492,6 +1509,7 @@ async function openArchiveTransport(params, previous, prepared) {
|
|
|
1492
1509
|
)
|
|
1493
1510
|
).digest("hex");
|
|
1494
1511
|
return {
|
|
1512
|
+
signal: rangeSignal,
|
|
1495
1513
|
identity: previous?.archiveIdentity === identity ? identity : archiveIdentity,
|
|
1496
1514
|
downloadIdentity: identity,
|
|
1497
1515
|
archiveCacheBypassed,
|
|
@@ -1511,7 +1529,7 @@ async function openArchiveTransport(params, previous, prepared) {
|
|
|
1511
1529
|
path: normalizeResultPath(entry.filename),
|
|
1512
1530
|
contentLength: entry.uncompressedSize,
|
|
1513
1531
|
read: () => {
|
|
1514
|
-
entryRead = readRangeEntry(entry,
|
|
1532
|
+
entryRead = readRangeEntry(entry, rangeSignal, producers);
|
|
1515
1533
|
return entryRead.body;
|
|
1516
1534
|
},
|
|
1517
1535
|
waitForRead: () => entryRead?.completed ?? Promise.resolve()
|
|
@@ -1524,6 +1542,7 @@ async function openArchiveTransport(params, previous, prepared) {
|
|
|
1524
1542
|
}
|
|
1525
1543
|
};
|
|
1526
1544
|
} catch (error) {
|
|
1545
|
+
rangeController.abort(error);
|
|
1527
1546
|
await reader.close();
|
|
1528
1547
|
throw error;
|
|
1529
1548
|
}
|
|
@@ -1535,10 +1554,16 @@ function readRangeEntry(entry, signal, producers) {
|
|
|
1535
1554
|
streamController = controller;
|
|
1536
1555
|
}
|
|
1537
1556
|
});
|
|
1557
|
+
const cancelOutput = () => {
|
|
1558
|
+
streamController?.error(signal?.reason);
|
|
1559
|
+
};
|
|
1560
|
+
signal?.addEventListener("abort", cancelOutput, { once: true });
|
|
1561
|
+
if (signal?.aborted) cancelOutput();
|
|
1538
1562
|
const completed = entry.getData(stream.writable, { signal, checkCrc32: true, useWebWorkers: false }).then(() => void 0);
|
|
1539
1563
|
const producer = completed.catch((error) => {
|
|
1540
1564
|
streamController?.error(error);
|
|
1541
1565
|
}).finally(() => {
|
|
1566
|
+
signal?.removeEventListener("abort", cancelOutput);
|
|
1542
1567
|
producers.delete(producer);
|
|
1543
1568
|
});
|
|
1544
1569
|
producers.add(producer);
|
|
@@ -1678,7 +1703,7 @@ function createDownloadIdentity(jobId, response) {
|
|
|
1678
1703
|
])
|
|
1679
1704
|
).digest("hex");
|
|
1680
1705
|
}
|
|
1681
|
-
var import_crypto3, import_zip2;
|
|
1706
|
+
var import_crypto3, import_zip2, AbortableHttpRangeReader;
|
|
1682
1707
|
var init_streamed_parsed_document_sync = __esm({
|
|
1683
1708
|
"src/storage/streamed-parsed-document-sync.ts"() {
|
|
1684
1709
|
"use strict";
|
|
@@ -1688,6 +1713,50 @@ var init_streamed_parsed_document_sync = __esm({
|
|
|
1688
1713
|
init_parsed_document_archive_cache();
|
|
1689
1714
|
import_zip2 = require("@zip.js/zip.js");
|
|
1690
1715
|
init_parsed_document_storage();
|
|
1716
|
+
AbortableHttpRangeReader = class extends import_zip2.HttpRangeReader {
|
|
1717
|
+
constructor(url, options, controller) {
|
|
1718
|
+
super(url, options);
|
|
1719
|
+
this.controller = controller;
|
|
1720
|
+
}
|
|
1721
|
+
controller;
|
|
1722
|
+
createReadable(options) {
|
|
1723
|
+
const reader = super.createReadable(options).getReader();
|
|
1724
|
+
const cancellation = this.controller;
|
|
1725
|
+
return new ReadableStream(
|
|
1726
|
+
{
|
|
1727
|
+
async pull(output) {
|
|
1728
|
+
try {
|
|
1729
|
+
const chunk = await reader.read();
|
|
1730
|
+
if (chunk.done) {
|
|
1731
|
+
reader.releaseLock();
|
|
1732
|
+
output.close();
|
|
1733
|
+
} else output.enqueue(chunk.value);
|
|
1734
|
+
} catch (error) {
|
|
1735
|
+
cancellation.abort(error);
|
|
1736
|
+
reader.releaseLock();
|
|
1737
|
+
output.error(error);
|
|
1738
|
+
}
|
|
1739
|
+
},
|
|
1740
|
+
async cancel(reason) {
|
|
1741
|
+
try {
|
|
1742
|
+
await reader.cancel(reason);
|
|
1743
|
+
} finally {
|
|
1744
|
+
reader.releaseLock();
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
},
|
|
1748
|
+
{ highWaterMark: 0 }
|
|
1749
|
+
);
|
|
1750
|
+
}
|
|
1751
|
+
async readUint8Array(index, length) {
|
|
1752
|
+
try {
|
|
1753
|
+
return await super.readUint8Array(index, length);
|
|
1754
|
+
} catch (error) {
|
|
1755
|
+
this.controller.abort(error);
|
|
1756
|
+
throw error;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
};
|
|
1691
1760
|
}
|
|
1692
1761
|
});
|
|
1693
1762
|
|
|
@@ -3603,14 +3672,17 @@ var Knowledge = class _Knowledge {
|
|
|
3603
3672
|
}
|
|
3604
3673
|
async syncParsedDocument(params) {
|
|
3605
3674
|
const response = await this.performParsedDocumentSync(params);
|
|
3675
|
+
params.signal?.throwIfAborted();
|
|
3606
3676
|
if (response.completed && !response.snapshot) {
|
|
3607
3677
|
const storage = this.requireParsedStorageConfig().storage;
|
|
3608
3678
|
await serializeSnapshotPublication(storage, response.documentId, async () => {
|
|
3679
|
+
params.signal?.throwIfAborted();
|
|
3609
3680
|
if (params.documentId || params.jobId) {
|
|
3610
3681
|
const current = await this.client.documents.listChunks(
|
|
3611
3682
|
response.documentId,
|
|
3612
3683
|
{ page: 1, pageSize: 1 }
|
|
3613
3684
|
);
|
|
3685
|
+
params.signal?.throwIfAborted();
|
|
3614
3686
|
if (params.jobId && current.jobId !== params.jobId) return;
|
|
3615
3687
|
if (!params.jobId && current.jobResultId !== response.revisionKey) return;
|
|
3616
3688
|
}
|
|
@@ -3625,6 +3697,7 @@ var Knowledge = class _Knowledge {
|
|
|
3625
3697
|
});
|
|
3626
3698
|
});
|
|
3627
3699
|
}
|
|
3700
|
+
params.signal?.throwIfAborted();
|
|
3628
3701
|
return response;
|
|
3629
3702
|
}
|
|
3630
3703
|
async performParsedDocumentSync(params) {
|
|
@@ -3716,15 +3789,18 @@ var Knowledge = class _Knowledge {
|
|
|
3716
3789
|
signal: params.signal,
|
|
3717
3790
|
retainResultArchive: params.retainResultArchive
|
|
3718
3791
|
});
|
|
3792
|
+
params.signal?.throwIfAborted();
|
|
3719
3793
|
if (response.completed && snapshot.snapshotId === params.job.currentSnapshotId) {
|
|
3720
3794
|
await serializeSnapshotPublication(
|
|
3721
3795
|
params.parsedStorageConfig.storage,
|
|
3722
3796
|
params.documentId,
|
|
3723
3797
|
async () => {
|
|
3798
|
+
params.signal?.throwIfAborted();
|
|
3724
3799
|
const current = await this.client.documents.listChunks(
|
|
3725
3800
|
params.documentId,
|
|
3726
3801
|
{ page: 1, pageSize: 1 }
|
|
3727
3802
|
);
|
|
3803
|
+
params.signal?.throwIfAborted();
|
|
3728
3804
|
if (current.jobResultId !== snapshot.jobResultId) return;
|
|
3729
3805
|
const pointer = Buffer.from(
|
|
3730
3806
|
JSON.stringify({
|
|
@@ -3740,6 +3816,7 @@ var Knowledge = class _Knowledge {
|
|
|
3740
3816
|
body: pointer,
|
|
3741
3817
|
contentType: "application/json; charset=utf-8"
|
|
3742
3818
|
});
|
|
3819
|
+
params.signal?.throwIfAborted();
|
|
3743
3820
|
}
|
|
3744
3821
|
await params.parsedStorageConfig.storage.writeObject({
|
|
3745
3822
|
documentId: params.documentId,
|
|
@@ -3751,6 +3828,7 @@ var Knowledge = class _Knowledge {
|
|
|
3751
3828
|
}
|
|
3752
3829
|
);
|
|
3753
3830
|
}
|
|
3831
|
+
params.signal?.throwIfAborted();
|
|
3754
3832
|
return response;
|
|
3755
3833
|
}
|
|
3756
3834
|
async resolveStoredSnapshotKey(documentId) {
|
package/dist/index.mjs
CHANGED
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
syncParseResultToParsedDocumentStorage,
|
|
48
48
|
syncRemoteResultArchive,
|
|
49
49
|
validateArchiveSyncLimits
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-PXBPL2Z5.mjs";
|
|
51
51
|
|
|
52
52
|
// src/client.ts
|
|
53
53
|
import path2 from "path";
|
|
@@ -1903,14 +1903,17 @@ var Knowledge = class _Knowledge {
|
|
|
1903
1903
|
}
|
|
1904
1904
|
async syncParsedDocument(params) {
|
|
1905
1905
|
const response = await this.performParsedDocumentSync(params);
|
|
1906
|
+
params.signal?.throwIfAborted();
|
|
1906
1907
|
if (response.completed && !response.snapshot) {
|
|
1907
1908
|
const storage = this.requireParsedStorageConfig().storage;
|
|
1908
1909
|
await serializeSnapshotPublication(storage, response.documentId, async () => {
|
|
1910
|
+
params.signal?.throwIfAborted();
|
|
1909
1911
|
if (params.documentId || params.jobId) {
|
|
1910
1912
|
const current = await this.client.documents.listChunks(
|
|
1911
1913
|
response.documentId,
|
|
1912
1914
|
{ page: 1, pageSize: 1 }
|
|
1913
1915
|
);
|
|
1916
|
+
params.signal?.throwIfAborted();
|
|
1914
1917
|
if (params.jobId && current.jobId !== params.jobId) return;
|
|
1915
1918
|
if (!params.jobId && current.jobResultId !== response.revisionKey) return;
|
|
1916
1919
|
}
|
|
@@ -1925,6 +1928,7 @@ var Knowledge = class _Knowledge {
|
|
|
1925
1928
|
});
|
|
1926
1929
|
});
|
|
1927
1930
|
}
|
|
1931
|
+
params.signal?.throwIfAborted();
|
|
1928
1932
|
return response;
|
|
1929
1933
|
}
|
|
1930
1934
|
async performParsedDocumentSync(params) {
|
|
@@ -2016,15 +2020,18 @@ var Knowledge = class _Knowledge {
|
|
|
2016
2020
|
signal: params.signal,
|
|
2017
2021
|
retainResultArchive: params.retainResultArchive
|
|
2018
2022
|
});
|
|
2023
|
+
params.signal?.throwIfAborted();
|
|
2019
2024
|
if (response.completed && snapshot.snapshotId === params.job.currentSnapshotId) {
|
|
2020
2025
|
await serializeSnapshotPublication(
|
|
2021
2026
|
params.parsedStorageConfig.storage,
|
|
2022
2027
|
params.documentId,
|
|
2023
2028
|
async () => {
|
|
2029
|
+
params.signal?.throwIfAborted();
|
|
2024
2030
|
const current = await this.client.documents.listChunks(
|
|
2025
2031
|
params.documentId,
|
|
2026
2032
|
{ page: 1, pageSize: 1 }
|
|
2027
2033
|
);
|
|
2034
|
+
params.signal?.throwIfAborted();
|
|
2028
2035
|
if (current.jobResultId !== snapshot.jobResultId) return;
|
|
2029
2036
|
const pointer = Buffer.from(
|
|
2030
2037
|
JSON.stringify({
|
|
@@ -2040,6 +2047,7 @@ var Knowledge = class _Knowledge {
|
|
|
2040
2047
|
body: pointer,
|
|
2041
2048
|
contentType: "application/json; charset=utf-8"
|
|
2042
2049
|
});
|
|
2050
|
+
params.signal?.throwIfAborted();
|
|
2043
2051
|
}
|
|
2044
2052
|
await params.parsedStorageConfig.storage.writeObject({
|
|
2045
2053
|
documentId: params.documentId,
|
|
@@ -2051,6 +2059,7 @@ var Knowledge = class _Knowledge {
|
|
|
2051
2059
|
}
|
|
2052
2060
|
);
|
|
2053
2061
|
}
|
|
2062
|
+
params.signal?.throwIfAborted();
|
|
2054
2063
|
return response;
|
|
2055
2064
|
}
|
|
2056
2065
|
async resolveStoredSnapshotKey(documentId) {
|