@signaliz/sdk 1.0.43 → 1.0.45

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.
@@ -18,7 +18,7 @@ function parseError(status, body) {
18
18
  code: body.error.code || `HTTP_${status}`,
19
19
  message: body.error.message || `Request failed with status ${status}`,
20
20
  errorType: mapErrorType(body.error.code, status),
21
- retryAfter: body.error.retry_after,
21
+ retryAfter: retryAfterSeconds(body.error),
22
22
  details: body.error.details
23
23
  });
24
24
  }
@@ -27,9 +27,22 @@ function parseError(status, body) {
27
27
  code,
28
28
  message: body?.message || body?.error || `Request failed with status ${status}`,
29
29
  errorType: mapErrorType(code, status),
30
- details: body?.details || (body?.retry_eligible !== void 0 ? { retry_eligible: body.retry_eligible } : void 0)
30
+ retryAfter: retryAfterSeconds(body),
31
+ details: body?.details || publicRetryDetails(body)
31
32
  });
32
33
  }
34
+ function retryAfterSeconds(body) {
35
+ const value = Number(body?.retry_after_seconds ?? body?.retry_after);
36
+ return Number.isFinite(value) && value >= 0 ? value : void 0;
37
+ }
38
+ function publicRetryDetails(body) {
39
+ const details = {
40
+ ...body?.retry_eligible !== void 0 ? { retry_eligible: body.retry_eligible } : {},
41
+ ...body?.retry_after !== void 0 ? { retry_after: body.retry_after } : {},
42
+ ...body?.retry_after_seconds !== void 0 ? { retry_after_seconds: body.retry_after_seconds } : {}
43
+ };
44
+ return Object.keys(details).length > 0 ? details : void 0;
45
+ }
33
46
  function mapErrorType(code, status) {
34
47
  if (code === "RATE_LIMITED" || status === 429) return "rate_limited";
35
48
  if (code === "VALIDATION_ERROR" || code === "SIGNAL_RUN_COMPANY_MISMATCH" || status === 400) return "validation";
@@ -692,9 +705,10 @@ var Signaliz = class {
692
705
  if (seen.size !== requests.length) throw new Error(`${label} batch returned incomplete indexed results`);
693
706
  return rows;
694
707
  }
695
- async runSignalCopyBatchChunk(requests, concurrency) {
708
+ async runSignalCopyBatchChunk(requests, concurrency, rowRateLimitAttempt = 0) {
696
709
  const startedAt = Date.now();
697
710
  const results = new Array(requests.length);
711
+ const rateLimited = [];
698
712
  let pending = requests.map((params, index) => ({
699
713
  index,
700
714
  params,
@@ -714,6 +728,14 @@ var Signaliz = class {
714
728
  const task = pending[index];
715
729
  const item = data.results[index];
716
730
  if (item.success === false) {
731
+ if (rowRateLimitAttempt < MAX_ROW_RATE_LIMIT_RETRIES && isRetryableRowRateLimit({
732
+ index: task.index,
733
+ success: false,
734
+ raw: item
735
+ })) {
736
+ rateLimited.push({ index: task.index, params: task.params, raw: item });
737
+ continue;
738
+ }
717
739
  results[task.index] = { index: task.index, success: false, error: item.error || item.message || "Signal to Copy failed" };
718
740
  continue;
719
741
  }
@@ -752,6 +774,21 @@ var Signaliz = class {
752
774
  pending = nextPending;
753
775
  if (pending.length > 0) await sleep2(nextDelayMs);
754
776
  }
777
+ if (rateLimited.length > 0) {
778
+ await sleep2(rowRateLimitDelayMs(rateLimited.map((item) => ({
779
+ index: item.index,
780
+ success: false,
781
+ raw: item.raw
782
+ }))));
783
+ const retried = await this.runSignalCopyBatchChunk(
784
+ rateLimited.map((item) => item.params),
785
+ concurrency,
786
+ rowRateLimitAttempt + 1
787
+ );
788
+ for (let index = 0; index < rateLimited.length; index += 1) {
789
+ results[rateLimited[index].index] = { ...retried[index], index: rateLimited[index].index };
790
+ }
791
+ }
755
792
  return results;
756
793
  }
757
794
  async runCoreBatchRound(path, tasks, options, companyRecoverableBatch, rowRateLimitAttempt = 0) {
@@ -864,8 +901,8 @@ function rowRateLimitDelayMs(items) {
864
901
  const delays = items.map((item) => {
865
902
  const retryAfterMs = Number(item.raw?.retry_after_ms);
866
903
  if (Number.isFinite(retryAfterMs) && retryAfterMs > 0) return retryAfterMs;
867
- const retryAfterSeconds = Number(item.raw?.retry_after_seconds ?? item.raw?.retry_after);
868
- if (Number.isFinite(retryAfterSeconds) && retryAfterSeconds > 0) return retryAfterSeconds * 1e3;
904
+ const retryAfterSeconds2 = Number(item.raw?.retry_after_seconds ?? item.raw?.retry_after);
905
+ if (Number.isFinite(retryAfterSeconds2) && retryAfterSeconds2 > 0) return retryAfterSeconds2 * 1e3;
869
906
  return 6e4;
870
907
  });
871
908
  return Math.max(1, Math.min(6e4, Math.max(...delays)));
package/dist/index.js CHANGED
@@ -45,7 +45,7 @@ function parseError(status, body) {
45
45
  code: body.error.code || `HTTP_${status}`,
46
46
  message: body.error.message || `Request failed with status ${status}`,
47
47
  errorType: mapErrorType(body.error.code, status),
48
- retryAfter: body.error.retry_after,
48
+ retryAfter: retryAfterSeconds(body.error),
49
49
  details: body.error.details
50
50
  });
51
51
  }
@@ -54,9 +54,22 @@ function parseError(status, body) {
54
54
  code,
55
55
  message: body?.message || body?.error || `Request failed with status ${status}`,
56
56
  errorType: mapErrorType(code, status),
57
- details: body?.details || (body?.retry_eligible !== void 0 ? { retry_eligible: body.retry_eligible } : void 0)
57
+ retryAfter: retryAfterSeconds(body),
58
+ details: body?.details || publicRetryDetails(body)
58
59
  });
59
60
  }
61
+ function retryAfterSeconds(body) {
62
+ const value = Number(body?.retry_after_seconds ?? body?.retry_after);
63
+ return Number.isFinite(value) && value >= 0 ? value : void 0;
64
+ }
65
+ function publicRetryDetails(body) {
66
+ const details = {
67
+ ...body?.retry_eligible !== void 0 ? { retry_eligible: body.retry_eligible } : {},
68
+ ...body?.retry_after !== void 0 ? { retry_after: body.retry_after } : {},
69
+ ...body?.retry_after_seconds !== void 0 ? { retry_after_seconds: body.retry_after_seconds } : {}
70
+ };
71
+ return Object.keys(details).length > 0 ? details : void 0;
72
+ }
60
73
  function mapErrorType(code, status) {
61
74
  if (code === "RATE_LIMITED" || status === 429) return "rate_limited";
62
75
  if (code === "VALIDATION_ERROR" || code === "SIGNAL_RUN_COMPANY_MISMATCH" || status === 400) return "validation";
@@ -719,9 +732,10 @@ var Signaliz = class {
719
732
  if (seen.size !== requests.length) throw new Error(`${label} batch returned incomplete indexed results`);
720
733
  return rows;
721
734
  }
722
- async runSignalCopyBatchChunk(requests, concurrency) {
735
+ async runSignalCopyBatchChunk(requests, concurrency, rowRateLimitAttempt = 0) {
723
736
  const startedAt = Date.now();
724
737
  const results = new Array(requests.length);
738
+ const rateLimited = [];
725
739
  let pending = requests.map((params, index) => ({
726
740
  index,
727
741
  params,
@@ -741,6 +755,14 @@ var Signaliz = class {
741
755
  const task = pending[index];
742
756
  const item = data.results[index];
743
757
  if (item.success === false) {
758
+ if (rowRateLimitAttempt < MAX_ROW_RATE_LIMIT_RETRIES && isRetryableRowRateLimit({
759
+ index: task.index,
760
+ success: false,
761
+ raw: item
762
+ })) {
763
+ rateLimited.push({ index: task.index, params: task.params, raw: item });
764
+ continue;
765
+ }
744
766
  results[task.index] = { index: task.index, success: false, error: item.error || item.message || "Signal to Copy failed" };
745
767
  continue;
746
768
  }
@@ -779,6 +801,21 @@ var Signaliz = class {
779
801
  pending = nextPending;
780
802
  if (pending.length > 0) await sleep2(nextDelayMs);
781
803
  }
804
+ if (rateLimited.length > 0) {
805
+ await sleep2(rowRateLimitDelayMs(rateLimited.map((item) => ({
806
+ index: item.index,
807
+ success: false,
808
+ raw: item.raw
809
+ }))));
810
+ const retried = await this.runSignalCopyBatchChunk(
811
+ rateLimited.map((item) => item.params),
812
+ concurrency,
813
+ rowRateLimitAttempt + 1
814
+ );
815
+ for (let index = 0; index < rateLimited.length; index += 1) {
816
+ results[rateLimited[index].index] = { ...retried[index], index: rateLimited[index].index };
817
+ }
818
+ }
782
819
  return results;
783
820
  }
784
821
  async runCoreBatchRound(path, tasks, options, companyRecoverableBatch, rowRateLimitAttempt = 0) {
@@ -891,8 +928,8 @@ function rowRateLimitDelayMs(items) {
891
928
  const delays = items.map((item) => {
892
929
  const retryAfterMs = Number(item.raw?.retry_after_ms);
893
930
  if (Number.isFinite(retryAfterMs) && retryAfterMs > 0) return retryAfterMs;
894
- const retryAfterSeconds = Number(item.raw?.retry_after_seconds ?? item.raw?.retry_after);
895
- if (Number.isFinite(retryAfterSeconds) && retryAfterSeconds > 0) return retryAfterSeconds * 1e3;
931
+ const retryAfterSeconds2 = Number(item.raw?.retry_after_seconds ?? item.raw?.retry_after);
932
+ if (Number.isFinite(retryAfterSeconds2) && retryAfterSeconds2 > 0) return retryAfterSeconds2 * 1e3;
896
933
  return 6e4;
897
934
  });
898
935
  return Math.max(1, Math.min(6e4, Math.max(...delays)));
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Signaliz,
3
3
  SignalizError
4
- } from "./chunk-HQS7N57T.mjs";
4
+ } from "./chunk-NAJO2CAD.mjs";
5
5
  export {
6
6
  Signaliz,
7
7
  SignalizError
@@ -49,7 +49,7 @@ function parseError(status, body) {
49
49
  code: body.error.code || `HTTP_${status}`,
50
50
  message: body.error.message || `Request failed with status ${status}`,
51
51
  errorType: mapErrorType(body.error.code, status),
52
- retryAfter: body.error.retry_after,
52
+ retryAfter: retryAfterSeconds(body.error),
53
53
  details: body.error.details
54
54
  });
55
55
  }
@@ -58,9 +58,22 @@ function parseError(status, body) {
58
58
  code,
59
59
  message: body?.message || body?.error || `Request failed with status ${status}`,
60
60
  errorType: mapErrorType(code, status),
61
- details: body?.details || (body?.retry_eligible !== void 0 ? { retry_eligible: body.retry_eligible } : void 0)
61
+ retryAfter: retryAfterSeconds(body),
62
+ details: body?.details || publicRetryDetails(body)
62
63
  });
63
64
  }
65
+ function retryAfterSeconds(body) {
66
+ const value = Number(body?.retry_after_seconds ?? body?.retry_after);
67
+ return Number.isFinite(value) && value >= 0 ? value : void 0;
68
+ }
69
+ function publicRetryDetails(body) {
70
+ const details = {
71
+ ...body?.retry_eligible !== void 0 ? { retry_eligible: body.retry_eligible } : {},
72
+ ...body?.retry_after !== void 0 ? { retry_after: body.retry_after } : {},
73
+ ...body?.retry_after_seconds !== void 0 ? { retry_after_seconds: body.retry_after_seconds } : {}
74
+ };
75
+ return Object.keys(details).length > 0 ? details : void 0;
76
+ }
64
77
  function mapErrorType(code, status) {
65
78
  if (code === "RATE_LIMITED" || status === 429) return "rate_limited";
66
79
  if (code === "VALIDATION_ERROR" || code === "SIGNAL_RUN_COMPANY_MISMATCH" || status === 400) return "validation";
@@ -723,9 +736,10 @@ var Signaliz = class {
723
736
  if (seen.size !== requests.length) throw new Error(`${label} batch returned incomplete indexed results`);
724
737
  return rows;
725
738
  }
726
- async runSignalCopyBatchChunk(requests, concurrency) {
739
+ async runSignalCopyBatchChunk(requests, concurrency, rowRateLimitAttempt = 0) {
727
740
  const startedAt = Date.now();
728
741
  const results = new Array(requests.length);
742
+ const rateLimited = [];
729
743
  let pending = requests.map((params, index) => ({
730
744
  index,
731
745
  params,
@@ -745,6 +759,14 @@ var Signaliz = class {
745
759
  const task = pending[index];
746
760
  const item = data.results[index];
747
761
  if (item.success === false) {
762
+ if (rowRateLimitAttempt < MAX_ROW_RATE_LIMIT_RETRIES && isRetryableRowRateLimit({
763
+ index: task.index,
764
+ success: false,
765
+ raw: item
766
+ })) {
767
+ rateLimited.push({ index: task.index, params: task.params, raw: item });
768
+ continue;
769
+ }
748
770
  results[task.index] = { index: task.index, success: false, error: item.error || item.message || "Signal to Copy failed" };
749
771
  continue;
750
772
  }
@@ -783,6 +805,21 @@ var Signaliz = class {
783
805
  pending = nextPending;
784
806
  if (pending.length > 0) await sleep2(nextDelayMs);
785
807
  }
808
+ if (rateLimited.length > 0) {
809
+ await sleep2(rowRateLimitDelayMs(rateLimited.map((item) => ({
810
+ index: item.index,
811
+ success: false,
812
+ raw: item.raw
813
+ }))));
814
+ const retried = await this.runSignalCopyBatchChunk(
815
+ rateLimited.map((item) => item.params),
816
+ concurrency,
817
+ rowRateLimitAttempt + 1
818
+ );
819
+ for (let index = 0; index < rateLimited.length; index += 1) {
820
+ results[rateLimited[index].index] = { ...retried[index], index: rateLimited[index].index };
821
+ }
822
+ }
786
823
  return results;
787
824
  }
788
825
  async runCoreBatchRound(path2, tasks, options, companyRecoverableBatch, rowRateLimitAttempt = 0) {
@@ -895,8 +932,8 @@ function rowRateLimitDelayMs(items) {
895
932
  const delays = items.map((item) => {
896
933
  const retryAfterMs = Number(item.raw?.retry_after_ms);
897
934
  if (Number.isFinite(retryAfterMs) && retryAfterMs > 0) return retryAfterMs;
898
- const retryAfterSeconds = Number(item.raw?.retry_after_seconds ?? item.raw?.retry_after);
899
- if (Number.isFinite(retryAfterSeconds) && retryAfterSeconds > 0) return retryAfterSeconds * 1e3;
935
+ const retryAfterSeconds2 = Number(item.raw?.retry_after_seconds ?? item.raw?.retry_after);
936
+ if (Number.isFinite(retryAfterSeconds2) && retryAfterSeconds2 > 0) return retryAfterSeconds2 * 1e3;
900
937
  return 6e4;
901
938
  });
902
939
  return Math.max(1, Math.min(6e4, Math.max(...delays)));
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  Signaliz
4
- } from "./chunk-HQS7N57T.mjs";
4
+ } from "./chunk-NAJO2CAD.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.43",
3
+ "version": "1.0.45",
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",