@anuma/sdk 11.3.4 → 11.3.5

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.
@@ -7348,9 +7348,9 @@ function createNearbyRequest(options, apiPath = "/api/private-memories") {
7348
7348
  };
7349
7349
  const request = async (path, init = {}, signal) => {
7350
7350
  const controller = new AbortController();
7351
- let timedOut = false;
7351
+ let timedOut2 = false;
7352
7352
  const timer = setTimeout(() => {
7353
- timedOut = true;
7353
+ timedOut2 = true;
7354
7354
  controller.abort();
7355
7355
  }, timeoutMs);
7356
7356
  const forwardAbort = () => controller.abort(signal?.reason);
@@ -7416,7 +7416,7 @@ function createNearbyRequest(options, apiPath = "/api/private-memories") {
7416
7416
  if (response.status === 204) return null;
7417
7417
  return await response.json();
7418
7418
  } catch (error) {
7419
- if (timedOut) throw new RemoteMemoryError("Nearby request timed out", 408, "timeout");
7419
+ if (timedOut2) throw new RemoteMemoryError("Nearby request timed out", 408, "timeout");
7420
7420
  throw error;
7421
7421
  } finally {
7422
7422
  clearTimeout(timer);
@@ -14249,6 +14249,7 @@ var emptyMessage = {
14249
14249
  };
14250
14250
 
14251
14251
  // src/lib/chatStore/migrateChats.ts
14252
+ var timedOut = (error) => error instanceof ChatStoreError && error.status === 408;
14252
14253
  var maxPasses = 5;
14253
14254
  var verifyBatch = 1e3;
14254
14255
  var writeBatch = 25;
@@ -14517,11 +14518,20 @@ async function migrateChatsToRemote(options) {
14517
14518
  await journal.add(upload.map((r) => key(r.record)));
14518
14519
  let sent = 0;
14519
14520
  options.onProgress?.({ imported: sent, toImport: upload.length });
14520
- for (const batch of batches(upload)) {
14521
- await store.importRecords(batch, signal);
14521
+ const send = async (batch) => {
14522
+ try {
14523
+ await store.importRecords(batch, signal);
14524
+ } catch (error) {
14525
+ if (batch.length < 2 || !timedOut(error)) throw error;
14526
+ const half = Math.ceil(batch.length / 2);
14527
+ await send(batch.slice(0, half));
14528
+ await send(batch.slice(half));
14529
+ return;
14530
+ }
14522
14531
  sent += batch.length;
14523
14532
  options.onProgress?.({ imported: sent, toImport: upload.length });
14524
- }
14533
+ };
14534
+ for (const batch of batches(upload)) await send(batch);
14525
14535
  imported += sent;
14526
14536
  }
14527
14537
  };
@@ -27059,6 +27069,12 @@ async function importBatch2(request, keyId, rows, signal) {
27059
27069
  );
27060
27070
  return;
27061
27071
  } catch (error) {
27072
+ if (error instanceof RemoteMemoryError && error.status === 408 && rows.length > 1) {
27073
+ const half = Math.ceil(rows.length / 2);
27074
+ await importBatch2(request, keyId, rows.slice(0, half), signal);
27075
+ await importBatch2(request, keyId, rows.slice(half), signal);
27076
+ return;
27077
+ }
27062
27078
  if (!(error instanceof RemoteMemoryError) || error.status !== 429 || attempt >= MAX_RATE_LIMIT_WAITS)
27063
27079
  throw error;
27064
27080
  await wait(error.retryAfterMs ?? DEFAULT_RATE_LIMIT_WAIT_MS, signal);
@@ -5676,9 +5676,9 @@ function createNearbyRequest(options, apiPath = "/api/private-memories") {
5676
5676
  };
5677
5677
  const request = async (path, init = {}, signal) => {
5678
5678
  const controller = new AbortController();
5679
- let timedOut = false;
5679
+ let timedOut2 = false;
5680
5680
  const timer = setTimeout(() => {
5681
- timedOut = true;
5681
+ timedOut2 = true;
5682
5682
  controller.abort();
5683
5683
  }, timeoutMs);
5684
5684
  const forwardAbort = () => controller.abort(signal?.reason);
@@ -5744,7 +5744,7 @@ function createNearbyRequest(options, apiPath = "/api/private-memories") {
5744
5744
  if (response.status === 204) return null;
5745
5745
  return await response.json();
5746
5746
  } catch (error) {
5747
- if (timedOut) throw new RemoteMemoryError("Nearby request timed out", 408, "timeout");
5747
+ if (timedOut2) throw new RemoteMemoryError("Nearby request timed out", 408, "timeout");
5748
5748
  throw error;
5749
5749
  } finally {
5750
5750
  clearTimeout(timer);
@@ -12561,6 +12561,7 @@ var emptyMessage = {
12561
12561
  };
12562
12562
 
12563
12563
  // src/lib/chatStore/migrateChats.ts
12564
+ var timedOut = (error) => error instanceof ChatStoreError && error.status === 408;
12564
12565
  var maxPasses = 5;
12565
12566
  var verifyBatch = 1e3;
12566
12567
  var writeBatch = 25;
@@ -12829,11 +12830,20 @@ async function migrateChatsToRemote(options) {
12829
12830
  await journal.add(upload.map((r) => key(r.record)));
12830
12831
  let sent = 0;
12831
12832
  options.onProgress?.({ imported: sent, toImport: upload.length });
12832
- for (const batch of batches(upload)) {
12833
- await store.importRecords(batch, signal);
12833
+ const send = async (batch) => {
12834
+ try {
12835
+ await store.importRecords(batch, signal);
12836
+ } catch (error) {
12837
+ if (batch.length < 2 || !timedOut(error)) throw error;
12838
+ const half = Math.ceil(batch.length / 2);
12839
+ await send(batch.slice(0, half));
12840
+ await send(batch.slice(half));
12841
+ return;
12842
+ }
12834
12843
  sent += batch.length;
12835
12844
  options.onProgress?.({ imported: sent, toImport: upload.length });
12836
- }
12845
+ };
12846
+ for (const batch of batches(upload)) await send(batch);
12837
12847
  imported += sent;
12838
12848
  }
12839
12849
  };
@@ -25324,6 +25334,12 @@ async function importBatch2(request, keyId, rows, signal) {
25324
25334
  );
25325
25335
  return;
25326
25336
  } catch (error) {
25337
+ if (error instanceof RemoteMemoryError && error.status === 408 && rows.length > 1) {
25338
+ const half = Math.ceil(rows.length / 2);
25339
+ await importBatch2(request, keyId, rows.slice(0, half), signal);
25340
+ await importBatch2(request, keyId, rows.slice(half), signal);
25341
+ return;
25342
+ }
25327
25343
  if (!(error instanceof RemoteMemoryError) || error.status !== 429 || attempt >= MAX_RATE_LIMIT_WAITS)
25328
25344
  throw error;
25329
25345
  await wait(error.retryAfterMs ?? DEFAULT_RATE_LIMIT_WAIT_MS, signal);
@@ -8135,9 +8135,9 @@ function createNearbyRequest(options, apiPath = "/api/private-memories") {
8135
8135
  };
8136
8136
  const request = async (path, init = {}, signal) => {
8137
8137
  const controller = new AbortController();
8138
- let timedOut = false;
8138
+ let timedOut2 = false;
8139
8139
  const timer = setTimeout(() => {
8140
- timedOut = true;
8140
+ timedOut2 = true;
8141
8141
  controller.abort();
8142
8142
  }, timeoutMs);
8143
8143
  const forwardAbort = () => controller.abort(signal?.reason);
@@ -8203,7 +8203,7 @@ function createNearbyRequest(options, apiPath = "/api/private-memories") {
8203
8203
  if (response.status === 204) return null;
8204
8204
  return await response.json();
8205
8205
  } catch (error) {
8206
- if (timedOut) throw new RemoteMemoryError("Nearby request timed out", 408, "timeout");
8206
+ if (timedOut2) throw new RemoteMemoryError("Nearby request timed out", 408, "timeout");
8207
8207
  throw error;
8208
8208
  } finally {
8209
8209
  clearTimeout(timer);
@@ -15003,6 +15003,7 @@ var emptyMessage = {
15003
15003
  };
15004
15004
 
15005
15005
  // src/lib/chatStore/migrateChats.ts
15006
+ var timedOut = (error) => error instanceof ChatStoreError && error.status === 408;
15006
15007
  var maxPasses = 5;
15007
15008
  var verifyBatch = 1e3;
15008
15009
  var writeBatch = 25;
@@ -15271,11 +15272,20 @@ async function migrateChatsToRemote(options) {
15271
15272
  await journal.add(upload.map((r) => key(r.record)));
15272
15273
  let sent = 0;
15273
15274
  options.onProgress?.({ imported: sent, toImport: upload.length });
15274
- for (const batch of batches(upload)) {
15275
- await store.importRecords(batch, signal);
15275
+ const send = async (batch) => {
15276
+ try {
15277
+ await store.importRecords(batch, signal);
15278
+ } catch (error) {
15279
+ if (batch.length < 2 || !timedOut(error)) throw error;
15280
+ const half = Math.ceil(batch.length / 2);
15281
+ await send(batch.slice(0, half));
15282
+ await send(batch.slice(half));
15283
+ return;
15284
+ }
15276
15285
  sent += batch.length;
15277
15286
  options.onProgress?.({ imported: sent, toImport: upload.length });
15278
- }
15287
+ };
15288
+ for (const batch of batches(upload)) await send(batch);
15279
15289
  imported += sent;
15280
15290
  }
15281
15291
  };
@@ -29376,6 +29386,12 @@ async function importBatch2(request, keyId, rows, signal) {
29376
29386
  );
29377
29387
  return;
29378
29388
  } catch (error) {
29389
+ if (error instanceof RemoteMemoryError && error.status === 408 && rows.length > 1) {
29390
+ const half = Math.ceil(rows.length / 2);
29391
+ await importBatch2(request, keyId, rows.slice(0, half), signal);
29392
+ await importBatch2(request, keyId, rows.slice(half), signal);
29393
+ return;
29394
+ }
29379
29395
  if (!(error instanceof RemoteMemoryError) || error.status !== 429 || attempt >= MAX_RATE_LIMIT_WAITS)
29380
29396
  throw error;
29381
29397
  await wait(error.retryAfterMs ?? DEFAULT_RATE_LIMIT_WAIT_MS, signal);
@@ -34590,12 +34606,12 @@ async function preprocessFiles(files, options = {}) {
34590
34606
  }
34591
34607
  } catch (error) {
34592
34608
  errorCount++;
34593
- const timedOut = error instanceof ProcessingTimeoutError;
34609
+ const timedOut2 = error instanceof ProcessingTimeoutError;
34594
34610
  fileStatuses.push({
34595
34611
  fileId: file.id,
34596
34612
  fileName: file.name,
34597
34613
  status: "failed",
34598
- reason: timedOut ? "timeout" : "error"
34614
+ reason: timedOut2 ? "timeout" : "error"
34599
34615
  });
34600
34616
  logger.error(
34601
34617
  `[preprocessFiles] Error processing file ${label} with ${processor.name}:`,
@@ -6262,9 +6262,9 @@ function createNearbyRequest(options, apiPath = "/api/private-memories") {
6262
6262
  };
6263
6263
  const request = async (path, init = {}, signal) => {
6264
6264
  const controller = new AbortController();
6265
- let timedOut = false;
6265
+ let timedOut2 = false;
6266
6266
  const timer = setTimeout(() => {
6267
- timedOut = true;
6267
+ timedOut2 = true;
6268
6268
  controller.abort();
6269
6269
  }, timeoutMs);
6270
6270
  const forwardAbort = () => controller.abort(signal?.reason);
@@ -6330,7 +6330,7 @@ function createNearbyRequest(options, apiPath = "/api/private-memories") {
6330
6330
  if (response.status === 204) return null;
6331
6331
  return await response.json();
6332
6332
  } catch (error) {
6333
- if (timedOut) throw new RemoteMemoryError("Nearby request timed out", 408, "timeout");
6333
+ if (timedOut2) throw new RemoteMemoryError("Nearby request timed out", 408, "timeout");
6334
6334
  throw error;
6335
6335
  } finally {
6336
6336
  clearTimeout(timer);
@@ -13114,6 +13114,7 @@ var emptyMessage = {
13114
13114
  };
13115
13115
 
13116
13116
  // src/lib/chatStore/migrateChats.ts
13117
+ var timedOut = (error) => error instanceof ChatStoreError && error.status === 408;
13117
13118
  var maxPasses = 5;
13118
13119
  var verifyBatch = 1e3;
13119
13120
  var writeBatch = 25;
@@ -13382,11 +13383,20 @@ async function migrateChatsToRemote(options) {
13382
13383
  await journal.add(upload.map((r) => key(r.record)));
13383
13384
  let sent = 0;
13384
13385
  options.onProgress?.({ imported: sent, toImport: upload.length });
13385
- for (const batch of batches(upload)) {
13386
- await store.importRecords(batch, signal);
13386
+ const send = async (batch) => {
13387
+ try {
13388
+ await store.importRecords(batch, signal);
13389
+ } catch (error) {
13390
+ if (batch.length < 2 || !timedOut(error)) throw error;
13391
+ const half = Math.ceil(batch.length / 2);
13392
+ await send(batch.slice(0, half));
13393
+ await send(batch.slice(half));
13394
+ return;
13395
+ }
13387
13396
  sent += batch.length;
13388
13397
  options.onProgress?.({ imported: sent, toImport: upload.length });
13389
- }
13398
+ };
13399
+ for (const batch of batches(upload)) await send(batch);
13390
13400
  imported += sent;
13391
13401
  }
13392
13402
  };
@@ -27434,6 +27444,12 @@ async function importBatch2(request, keyId, rows, signal) {
27434
27444
  );
27435
27445
  return;
27436
27446
  } catch (error) {
27447
+ if (error instanceof RemoteMemoryError && error.status === 408 && rows.length > 1) {
27448
+ const half = Math.ceil(rows.length / 2);
27449
+ await importBatch2(request, keyId, rows.slice(0, half), signal);
27450
+ await importBatch2(request, keyId, rows.slice(half), signal);
27451
+ return;
27452
+ }
27437
27453
  if (!(error instanceof RemoteMemoryError) || error.status !== 429 || attempt >= MAX_RATE_LIMIT_WAITS)
27438
27454
  throw error;
27439
27455
  await wait(error.retryAfterMs ?? DEFAULT_RATE_LIMIT_WAIT_MS, signal);
@@ -32632,12 +32648,12 @@ async function preprocessFiles(files, options = {}) {
32632
32648
  }
32633
32649
  } catch (error) {
32634
32650
  errorCount++;
32635
- const timedOut = error instanceof ProcessingTimeoutError;
32651
+ const timedOut2 = error instanceof ProcessingTimeoutError;
32636
32652
  fileStatuses.push({
32637
32653
  fileId: file.id,
32638
32654
  fileName: file.name,
32639
32655
  status: "failed",
32640
- reason: timedOut ? "timeout" : "error"
32656
+ reason: timedOut2 ? "timeout" : "error"
32641
32657
  });
32642
32658
  logger.error(
32643
32659
  `[preprocessFiles] Error processing file ${label} with ${processor.name}:`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "11.3.4",
3
+ "version": "11.3.5",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",