@signaliz/sdk 1.0.45 → 1.0.46

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 CHANGED
@@ -100,6 +100,10 @@ const compactSignals = await signaliz.enrichCompanies(companies, {
100
100
  });
101
101
  ```
102
102
 
103
+ Failed rows preserve `errorCode`, `retryEligible`, and `retryAfterSeconds`
104
+ when the REST API supplies them, including after automatic row retries are
105
+ exhausted.
106
+
103
107
  For an ambiguous submission failure, retry with the same
104
108
  `idempotencyKey` to recover the original job without duplicate work.
105
109
 
@@ -496,7 +496,11 @@ var Signaliz = class {
496
496
  const params = companies[item.index];
497
497
  const task = taskByIndex.get(item.index);
498
498
  if (!item.success || !item.raw) {
499
- results[item.index] = { index: item.index, success: false, error: item.error || "Company Signal batch request failed" };
499
+ results[item.index] = batchItemFailure(
500
+ item.index,
501
+ item.error || "Company Signal batch request failed",
502
+ item.raw ?? item
503
+ );
500
504
  continue;
501
505
  }
502
506
  if (!isPendingSignalResponse(item.raw) || params.waitForResult === false) {
@@ -605,11 +609,11 @@ var Signaliz = class {
605
609
  const chunk = chunks[chunkResult.index];
606
610
  if (!chunkResult.success || !chunkResult.data) {
607
611
  for (let index = 0; index < chunk.requests.length; index += 1) {
608
- uniqueResults[chunk.offset + index] = {
609
- index: chunk.offset + index,
610
- success: false,
611
- error: chunkResult.error || "Signal to Copy batch request failed"
612
- };
612
+ uniqueResults[chunk.offset + index] = batchItemFailure(
613
+ chunk.offset + index,
614
+ chunkResult.error || "Signal to Copy batch request failed",
615
+ chunkResult
616
+ );
613
617
  }
614
618
  continue;
615
619
  }
@@ -631,7 +635,7 @@ var Signaliz = class {
631
635
  const results = new Array(requests.length);
632
636
  for (const row of rows) {
633
637
  const index = Number(row.index);
634
- results[index] = recoverableJobRowFailed(row) ? { index, success: false, error: row.error || row.message || "Signal to Copy failed" } : { index, success: true, data: normalizeSignalToCopyResult(row) };
638
+ results[index] = recoverableJobRowFailed(row) ? batchItemFailure(index, row.error || row.message || "Signal to Copy failed", row) : { index, success: true, data: normalizeSignalToCopyResult(row) };
635
639
  }
636
640
  return results;
637
641
  }
@@ -736,7 +740,11 @@ var Signaliz = class {
736
740
  rateLimited.push({ index: task.index, params: task.params, raw: item });
737
741
  continue;
738
742
  }
739
- results[task.index] = { index: task.index, success: false, error: item.error || item.message || "Signal to Copy failed" };
743
+ results[task.index] = batchItemFailure(
744
+ task.index,
745
+ item.error || item.message || "Signal to Copy failed",
746
+ item
747
+ );
740
748
  continue;
741
749
  }
742
750
  if (!isPendingSignalResponse(item)) {
@@ -841,7 +849,10 @@ var Signaliz = class {
841
849
  uniqueResults[chunk.offset + index] = {
842
850
  index: chunk.tasks[index].index,
843
851
  success: false,
844
- error: chunkResult.error || `${path} batch request failed`
852
+ error: chunkResult.error || `${path} batch request failed`,
853
+ errorCode: chunkResult.errorCode,
854
+ retryEligible: chunkResult.retryEligible,
855
+ retryAfterSeconds: chunkResult.retryAfterSeconds
845
856
  };
846
857
  }
847
858
  continue;
@@ -907,6 +918,21 @@ function rowRateLimitDelayMs(items) {
907
918
  });
908
919
  return Math.max(1, Math.min(6e4, Math.max(...delays)));
909
920
  }
921
+ function batchItemFailure(index, error, raw) {
922
+ const errorCode = String(raw?.error_code ?? raw?.code ?? raw?.errorCode ?? "").trim();
923
+ const retryAfterSeconds2 = Number(
924
+ raw?.retry_after_seconds ?? raw?.retry_after ?? raw?.retryAfterSeconds ?? (Number.isFinite(Number(raw?.retry_after_ms)) ? Number(raw?.retry_after_ms) / 1e3 : void 0)
925
+ );
926
+ const retryEligible = raw?.retry_eligible ?? raw?.retryEligible;
927
+ return {
928
+ index,
929
+ success: false,
930
+ error,
931
+ ...errorCode ? { errorCode } : {},
932
+ ...typeof retryEligible === "boolean" ? { retryEligible } : {},
933
+ ...Number.isFinite(retryAfterSeconds2) && retryAfterSeconds2 >= 0 ? { retryAfterSeconds: retryAfterSeconds2 } : {}
934
+ };
935
+ }
910
936
  function recoverableJobRowFailed(row) {
911
937
  return row.success === false || ["failed", "skipped"].includes(String(row._status || "").toLowerCase());
912
938
  }
@@ -1117,7 +1143,11 @@ function finalizeCoreBatch(total, startedAt, round, normalize, options) {
1117
1143
  const results = new Array(total);
1118
1144
  for (const item of round) {
1119
1145
  if (!item.success || !item.raw) {
1120
- results[item.index] = { index: item.index, success: false, error: item.error || "Signaliz batch item failed" };
1146
+ results[item.index] = batchItemFailure(
1147
+ item.index,
1148
+ item.error || "Signaliz batch item failed",
1149
+ item.raw ?? item
1150
+ );
1121
1151
  continue;
1122
1152
  }
1123
1153
  try {
@@ -1245,11 +1275,15 @@ async function runBatch(items, execute, options) {
1245
1275
  try {
1246
1276
  results[index] = { index, success: true, data: await execute(items[index]) };
1247
1277
  } catch (error) {
1248
- results[index] = {
1278
+ results[index] = batchItemFailure(
1249
1279
  index,
1250
- success: false,
1251
- error: error instanceof Error ? error.message : String(error)
1252
- };
1280
+ error instanceof Error ? error.message : String(error),
1281
+ error instanceof SignalizError ? {
1282
+ error_code: error.code,
1283
+ retry_eligible: error.isRetryable,
1284
+ retry_after_seconds: error.retryAfter
1285
+ } : void 0
1286
+ );
1253
1287
  }
1254
1288
  }
1255
1289
  };
package/dist/index.d.mts CHANGED
@@ -19,6 +19,12 @@ interface BatchItemResult<T> {
19
19
  success: boolean;
20
20
  data?: T;
21
21
  error?: string;
22
+ /** Stable public error code for a failed row. */
23
+ errorCode?: string;
24
+ /** Whether retrying the failed row is safe. */
25
+ retryEligible?: boolean;
26
+ /** Server-provided delay before retrying the failed row. */
27
+ retryAfterSeconds?: number;
22
28
  /** Zero-based input index containing the full result for this exact duplicate. */
23
29
  duplicateOf?: number;
24
30
  }
package/dist/index.d.ts CHANGED
@@ -19,6 +19,12 @@ interface BatchItemResult<T> {
19
19
  success: boolean;
20
20
  data?: T;
21
21
  error?: string;
22
+ /** Stable public error code for a failed row. */
23
+ errorCode?: string;
24
+ /** Whether retrying the failed row is safe. */
25
+ retryEligible?: boolean;
26
+ /** Server-provided delay before retrying the failed row. */
27
+ retryAfterSeconds?: number;
22
28
  /** Zero-based input index containing the full result for this exact duplicate. */
23
29
  duplicateOf?: number;
24
30
  }
package/dist/index.js CHANGED
@@ -523,7 +523,11 @@ var Signaliz = class {
523
523
  const params = companies[item.index];
524
524
  const task = taskByIndex.get(item.index);
525
525
  if (!item.success || !item.raw) {
526
- results[item.index] = { index: item.index, success: false, error: item.error || "Company Signal batch request failed" };
526
+ results[item.index] = batchItemFailure(
527
+ item.index,
528
+ item.error || "Company Signal batch request failed",
529
+ item.raw ?? item
530
+ );
527
531
  continue;
528
532
  }
529
533
  if (!isPendingSignalResponse(item.raw) || params.waitForResult === false) {
@@ -632,11 +636,11 @@ var Signaliz = class {
632
636
  const chunk = chunks[chunkResult.index];
633
637
  if (!chunkResult.success || !chunkResult.data) {
634
638
  for (let index = 0; index < chunk.requests.length; index += 1) {
635
- uniqueResults[chunk.offset + index] = {
636
- index: chunk.offset + index,
637
- success: false,
638
- error: chunkResult.error || "Signal to Copy batch request failed"
639
- };
639
+ uniqueResults[chunk.offset + index] = batchItemFailure(
640
+ chunk.offset + index,
641
+ chunkResult.error || "Signal to Copy batch request failed",
642
+ chunkResult
643
+ );
640
644
  }
641
645
  continue;
642
646
  }
@@ -658,7 +662,7 @@ var Signaliz = class {
658
662
  const results = new Array(requests.length);
659
663
  for (const row of rows) {
660
664
  const index = Number(row.index);
661
- results[index] = recoverableJobRowFailed(row) ? { index, success: false, error: row.error || row.message || "Signal to Copy failed" } : { index, success: true, data: normalizeSignalToCopyResult(row) };
665
+ results[index] = recoverableJobRowFailed(row) ? batchItemFailure(index, row.error || row.message || "Signal to Copy failed", row) : { index, success: true, data: normalizeSignalToCopyResult(row) };
662
666
  }
663
667
  return results;
664
668
  }
@@ -763,7 +767,11 @@ var Signaliz = class {
763
767
  rateLimited.push({ index: task.index, params: task.params, raw: item });
764
768
  continue;
765
769
  }
766
- results[task.index] = { index: task.index, success: false, error: item.error || item.message || "Signal to Copy failed" };
770
+ results[task.index] = batchItemFailure(
771
+ task.index,
772
+ item.error || item.message || "Signal to Copy failed",
773
+ item
774
+ );
767
775
  continue;
768
776
  }
769
777
  if (!isPendingSignalResponse(item)) {
@@ -868,7 +876,10 @@ var Signaliz = class {
868
876
  uniqueResults[chunk.offset + index] = {
869
877
  index: chunk.tasks[index].index,
870
878
  success: false,
871
- error: chunkResult.error || `${path} batch request failed`
879
+ error: chunkResult.error || `${path} batch request failed`,
880
+ errorCode: chunkResult.errorCode,
881
+ retryEligible: chunkResult.retryEligible,
882
+ retryAfterSeconds: chunkResult.retryAfterSeconds
872
883
  };
873
884
  }
874
885
  continue;
@@ -934,6 +945,21 @@ function rowRateLimitDelayMs(items) {
934
945
  });
935
946
  return Math.max(1, Math.min(6e4, Math.max(...delays)));
936
947
  }
948
+ function batchItemFailure(index, error, raw) {
949
+ const errorCode = String(raw?.error_code ?? raw?.code ?? raw?.errorCode ?? "").trim();
950
+ const retryAfterSeconds2 = Number(
951
+ raw?.retry_after_seconds ?? raw?.retry_after ?? raw?.retryAfterSeconds ?? (Number.isFinite(Number(raw?.retry_after_ms)) ? Number(raw?.retry_after_ms) / 1e3 : void 0)
952
+ );
953
+ const retryEligible = raw?.retry_eligible ?? raw?.retryEligible;
954
+ return {
955
+ index,
956
+ success: false,
957
+ error,
958
+ ...errorCode ? { errorCode } : {},
959
+ ...typeof retryEligible === "boolean" ? { retryEligible } : {},
960
+ ...Number.isFinite(retryAfterSeconds2) && retryAfterSeconds2 >= 0 ? { retryAfterSeconds: retryAfterSeconds2 } : {}
961
+ };
962
+ }
937
963
  function recoverableJobRowFailed(row) {
938
964
  return row.success === false || ["failed", "skipped"].includes(String(row._status || "").toLowerCase());
939
965
  }
@@ -1144,7 +1170,11 @@ function finalizeCoreBatch(total, startedAt, round, normalize, options) {
1144
1170
  const results = new Array(total);
1145
1171
  for (const item of round) {
1146
1172
  if (!item.success || !item.raw) {
1147
- results[item.index] = { index: item.index, success: false, error: item.error || "Signaliz batch item failed" };
1173
+ results[item.index] = batchItemFailure(
1174
+ item.index,
1175
+ item.error || "Signaliz batch item failed",
1176
+ item.raw ?? item
1177
+ );
1148
1178
  continue;
1149
1179
  }
1150
1180
  try {
@@ -1272,11 +1302,15 @@ async function runBatch(items, execute, options) {
1272
1302
  try {
1273
1303
  results[index] = { index, success: true, data: await execute(items[index]) };
1274
1304
  } catch (error) {
1275
- results[index] = {
1305
+ results[index] = batchItemFailure(
1276
1306
  index,
1277
- success: false,
1278
- error: error instanceof Error ? error.message : String(error)
1279
- };
1307
+ error instanceof Error ? error.message : String(error),
1308
+ error instanceof SignalizError ? {
1309
+ error_code: error.code,
1310
+ retry_eligible: error.isRetryable,
1311
+ retry_after_seconds: error.retryAfter
1312
+ } : void 0
1313
+ );
1280
1314
  }
1281
1315
  }
1282
1316
  };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Signaliz,
3
3
  SignalizError
4
- } from "./chunk-NAJO2CAD.mjs";
4
+ } from "./chunk-4LXMT3S5.mjs";
5
5
  export {
6
6
  Signaliz,
7
7
  SignalizError
@@ -527,7 +527,11 @@ var Signaliz = class {
527
527
  const params = companies[item.index];
528
528
  const task = taskByIndex.get(item.index);
529
529
  if (!item.success || !item.raw) {
530
- results[item.index] = { index: item.index, success: false, error: item.error || "Company Signal batch request failed" };
530
+ results[item.index] = batchItemFailure(
531
+ item.index,
532
+ item.error || "Company Signal batch request failed",
533
+ item.raw ?? item
534
+ );
531
535
  continue;
532
536
  }
533
537
  if (!isPendingSignalResponse(item.raw) || params.waitForResult === false) {
@@ -636,11 +640,11 @@ var Signaliz = class {
636
640
  const chunk = chunks[chunkResult.index];
637
641
  if (!chunkResult.success || !chunkResult.data) {
638
642
  for (let index = 0; index < chunk.requests.length; index += 1) {
639
- uniqueResults[chunk.offset + index] = {
640
- index: chunk.offset + index,
641
- success: false,
642
- error: chunkResult.error || "Signal to Copy batch request failed"
643
- };
643
+ uniqueResults[chunk.offset + index] = batchItemFailure(
644
+ chunk.offset + index,
645
+ chunkResult.error || "Signal to Copy batch request failed",
646
+ chunkResult
647
+ );
644
648
  }
645
649
  continue;
646
650
  }
@@ -662,7 +666,7 @@ var Signaliz = class {
662
666
  const results = new Array(requests.length);
663
667
  for (const row of rows) {
664
668
  const index = Number(row.index);
665
- results[index] = recoverableJobRowFailed(row) ? { index, success: false, error: row.error || row.message || "Signal to Copy failed" } : { index, success: true, data: normalizeSignalToCopyResult(row) };
669
+ results[index] = recoverableJobRowFailed(row) ? batchItemFailure(index, row.error || row.message || "Signal to Copy failed", row) : { index, success: true, data: normalizeSignalToCopyResult(row) };
666
670
  }
667
671
  return results;
668
672
  }
@@ -767,7 +771,11 @@ var Signaliz = class {
767
771
  rateLimited.push({ index: task.index, params: task.params, raw: item });
768
772
  continue;
769
773
  }
770
- results[task.index] = { index: task.index, success: false, error: item.error || item.message || "Signal to Copy failed" };
774
+ results[task.index] = batchItemFailure(
775
+ task.index,
776
+ item.error || item.message || "Signal to Copy failed",
777
+ item
778
+ );
771
779
  continue;
772
780
  }
773
781
  if (!isPendingSignalResponse(item)) {
@@ -872,7 +880,10 @@ var Signaliz = class {
872
880
  uniqueResults[chunk.offset + index] = {
873
881
  index: chunk.tasks[index].index,
874
882
  success: false,
875
- error: chunkResult.error || `${path2} batch request failed`
883
+ error: chunkResult.error || `${path2} batch request failed`,
884
+ errorCode: chunkResult.errorCode,
885
+ retryEligible: chunkResult.retryEligible,
886
+ retryAfterSeconds: chunkResult.retryAfterSeconds
876
887
  };
877
888
  }
878
889
  continue;
@@ -938,6 +949,21 @@ function rowRateLimitDelayMs(items) {
938
949
  });
939
950
  return Math.max(1, Math.min(6e4, Math.max(...delays)));
940
951
  }
952
+ function batchItemFailure(index, error, raw) {
953
+ const errorCode = String(raw?.error_code ?? raw?.code ?? raw?.errorCode ?? "").trim();
954
+ const retryAfterSeconds2 = Number(
955
+ raw?.retry_after_seconds ?? raw?.retry_after ?? raw?.retryAfterSeconds ?? (Number.isFinite(Number(raw?.retry_after_ms)) ? Number(raw?.retry_after_ms) / 1e3 : void 0)
956
+ );
957
+ const retryEligible = raw?.retry_eligible ?? raw?.retryEligible;
958
+ return {
959
+ index,
960
+ success: false,
961
+ error,
962
+ ...errorCode ? { errorCode } : {},
963
+ ...typeof retryEligible === "boolean" ? { retryEligible } : {},
964
+ ...Number.isFinite(retryAfterSeconds2) && retryAfterSeconds2 >= 0 ? { retryAfterSeconds: retryAfterSeconds2 } : {}
965
+ };
966
+ }
941
967
  function recoverableJobRowFailed(row) {
942
968
  return row.success === false || ["failed", "skipped"].includes(String(row._status || "").toLowerCase());
943
969
  }
@@ -1148,7 +1174,11 @@ function finalizeCoreBatch(total, startedAt, round, normalize, options) {
1148
1174
  const results = new Array(total);
1149
1175
  for (const item of round) {
1150
1176
  if (!item.success || !item.raw) {
1151
- results[item.index] = { index: item.index, success: false, error: item.error || "Signaliz batch item failed" };
1177
+ results[item.index] = batchItemFailure(
1178
+ item.index,
1179
+ item.error || "Signaliz batch item failed",
1180
+ item.raw ?? item
1181
+ );
1152
1182
  continue;
1153
1183
  }
1154
1184
  try {
@@ -1276,11 +1306,15 @@ async function runBatch(items, execute, options) {
1276
1306
  try {
1277
1307
  results[index] = { index, success: true, data: await execute(items[index]) };
1278
1308
  } catch (error) {
1279
- results[index] = {
1309
+ results[index] = batchItemFailure(
1280
1310
  index,
1281
- success: false,
1282
- error: error instanceof Error ? error.message : String(error)
1283
- };
1311
+ error instanceof Error ? error.message : String(error),
1312
+ error instanceof SignalizError ? {
1313
+ error_code: error.code,
1314
+ retry_eligible: error.isRetryable,
1315
+ retry_after_seconds: error.retryAfter
1316
+ } : void 0
1317
+ );
1284
1318
  }
1285
1319
  }
1286
1320
  };
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  Signaliz
4
- } from "./chunk-NAJO2CAD.mjs";
4
+ } from "./chunk-4LXMT3S5.mjs";
5
5
 
6
6
  // src/mcp-config.ts
7
7
  import * as fs from "fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signaliz/sdk",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
4
4
  "description": "Signaliz SDK for Find Email, Verify Email, Company Signal Enrichment, and Signal to Copy AI.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",