@signaliz/sdk 1.0.29 → 1.0.30
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 +3 -2
- package/dist/{chunk-R4DIAP7P.mjs → chunk-INM326KO.mjs} +308 -128
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +308 -128
- package/dist/index.mjs +1 -1
- package/dist/mcp-config.js +308 -128
- package/dist/mcp-config.mjs +1 -1
- package/package.json +13 -3
package/dist/mcp-config.js
CHANGED
|
@@ -384,89 +384,51 @@ var Signaliz = class {
|
|
|
384
384
|
this.client = new HttpClient(config);
|
|
385
385
|
}
|
|
386
386
|
async findEmail(params) {
|
|
387
|
-
const data = await this.client.post("api/v1/find-email",
|
|
388
|
-
|
|
389
|
-
full_name: params.fullName,
|
|
390
|
-
first_name: params.firstName,
|
|
391
|
-
last_name: params.lastName,
|
|
392
|
-
linkedin_url: params.linkedinUrl,
|
|
393
|
-
company_name: params.companyName,
|
|
394
|
-
skip_cache: params.skipCache
|
|
395
|
-
}));
|
|
396
|
-
const email = typeof data.email === "string" && data.email.trim() ? data.email.trim() : null;
|
|
397
|
-
const found = Boolean(email) && data.found !== false;
|
|
398
|
-
const verificationStatus = data.verification_status ?? data.status ?? "unknown";
|
|
399
|
-
const rawFreshness = String(data.verification_freshness ?? "").toLowerCase();
|
|
400
|
-
const verificationFreshness = rawFreshness === "fresh" || rawFreshness === "stale" ? rawFreshness : "unknown";
|
|
401
|
-
const needsReverification = data.needs_reverification === true || verificationFreshness === "stale";
|
|
402
|
-
const explicitlyNotSendSafe = data.verified_for_sending === false || needsReverification;
|
|
403
|
-
const verified = !explicitlyNotSendSafe && (data.email_verified === true || data.verified_for_sending === true || ["valid", "deliverable"].includes(String(verificationStatus).toLowerCase()));
|
|
404
|
-
const verificationAgeDays = typeof data.verification_age_days === "number" && Number.isFinite(data.verification_age_days) ? data.verification_age_days : null;
|
|
405
|
-
return {
|
|
406
|
-
success: data.success !== false && found,
|
|
407
|
-
found,
|
|
408
|
-
email,
|
|
409
|
-
firstName: data.first_name,
|
|
410
|
-
lastName: data.last_name,
|
|
411
|
-
confidence: data.confidence ?? data.confidence_score ?? (verified ? 1 : 0),
|
|
412
|
-
verificationStatus,
|
|
413
|
-
isVerified: verified,
|
|
414
|
-
isVerifiedForSending: !needsReverification && data.verified_for_sending === true,
|
|
415
|
-
isCatchAll: data.email_is_catch_all === true || data.is_catch_all === true,
|
|
416
|
-
verificationFreshness,
|
|
417
|
-
verificationAgeDays,
|
|
418
|
-
verifiedAt: typeof data.verified_at === "string" ? data.verified_at : null,
|
|
419
|
-
needsReverification,
|
|
420
|
-
providerUsed: data.provider_used ?? data.provider ?? data.email_source ?? data.source ?? "unknown",
|
|
421
|
-
error: found ? void 0 : data.error ?? "No verified email found",
|
|
422
|
-
errorCode: found ? void 0 : data.error_code ?? "EMAIL_NOT_FOUND",
|
|
423
|
-
raw: data
|
|
424
|
-
};
|
|
387
|
+
const data = await this.client.post("api/v1/find-email", findEmailRequestBody(params));
|
|
388
|
+
return normalizeFindEmailResult(data);
|
|
425
389
|
}
|
|
426
390
|
async findEmails(params, options) {
|
|
427
|
-
|
|
391
|
+
validateBatchSize(params);
|
|
392
|
+
const startedAt = Date.now();
|
|
393
|
+
const round = await this.runCoreBatchRound(
|
|
394
|
+
"api/v1/find-email",
|
|
395
|
+
params.map((item, index) => ({ index, request: findEmailRequestBody(item) })),
|
|
396
|
+
options
|
|
397
|
+
);
|
|
398
|
+
return finalizeCoreBatch(
|
|
399
|
+
params.length,
|
|
400
|
+
startedAt,
|
|
401
|
+
round,
|
|
402
|
+
(item) => normalizeFindEmailResult(item.raw)
|
|
403
|
+
);
|
|
428
404
|
}
|
|
429
405
|
async verifyEmail(email, options) {
|
|
430
406
|
const data = await this.client.post("api/v1/verify-email", {
|
|
431
407
|
email,
|
|
432
408
|
skip_cache: options?.skipCache
|
|
433
409
|
});
|
|
434
|
-
|
|
435
|
-
const verified = data.email_verified === true || ["valid", "deliverable"].includes(verificationStatus);
|
|
436
|
-
return {
|
|
437
|
-
email: data.email ?? email,
|
|
438
|
-
isValid: data.is_valid ?? data.valid ?? verified,
|
|
439
|
-
isDeliverable: data.is_deliverable ?? data.deliverable ?? verified,
|
|
440
|
-
isCatchAll: data.is_catch_all ?? data.catch_all ?? data.diagnostics?.is_catch_all ?? false,
|
|
441
|
-
confidenceScore: data.confidence_score ?? data.confidence ?? data.diagnostics?.confidence_score ?? (verified ? 1 : 0),
|
|
442
|
-
provider: data.provider,
|
|
443
|
-
verificationSource: data.verification_source,
|
|
444
|
-
raw: data
|
|
445
|
-
};
|
|
410
|
+
return normalizeVerifyEmailResult(email, data);
|
|
446
411
|
}
|
|
447
412
|
async verifyEmails(emails, options) {
|
|
448
|
-
|
|
413
|
+
validateBatchSize(emails);
|
|
414
|
+
const startedAt = Date.now();
|
|
415
|
+
const round = await this.runCoreBatchRound(
|
|
416
|
+
"api/v1/verify-email",
|
|
417
|
+
emails.map((email, index) => ({
|
|
418
|
+
index,
|
|
419
|
+
request: { email, skip_cache: options?.skipCache }
|
|
420
|
+
})),
|
|
421
|
+
options
|
|
422
|
+
);
|
|
423
|
+
return finalizeCoreBatch(
|
|
424
|
+
emails.length,
|
|
425
|
+
startedAt,
|
|
426
|
+
round,
|
|
427
|
+
(item) => normalizeVerifyEmailResult(emails[item.index], item.raw)
|
|
428
|
+
);
|
|
449
429
|
}
|
|
450
430
|
async enrichCompanySignals(params) {
|
|
451
|
-
const
|
|
452
|
-
const request = compact({
|
|
453
|
-
signal_run_id: params.signalRunId,
|
|
454
|
-
company_domain: params.companyDomain,
|
|
455
|
-
company_name: params.companyName,
|
|
456
|
-
research_prompt: params.researchPrompt,
|
|
457
|
-
signal_types: params.signalTypes,
|
|
458
|
-
target_signal_count: params.targetSignalCount,
|
|
459
|
-
lookback_days: params.lookbackDays,
|
|
460
|
-
online,
|
|
461
|
-
enable_deep_search: params.enableDeepSearch ?? online,
|
|
462
|
-
enable_outreach_intelligence: params.enableOutreachIntelligence,
|
|
463
|
-
enable_predictive_intelligence: params.enablePredictiveIntelligence,
|
|
464
|
-
skip_cache: params.skipCache,
|
|
465
|
-
// REST always returns a resumable run instead of holding the connection;
|
|
466
|
-
// waitForResult controls this SDK's polling loop below.
|
|
467
|
-
wait_for_result: false,
|
|
468
|
-
max_wait_ms: params.maxWaitMs
|
|
469
|
-
});
|
|
431
|
+
const request = companySignalRequestBody(params);
|
|
470
432
|
let data = await this.client.post("api/v1/company-signals", request);
|
|
471
433
|
if (params.waitForResult !== false && data.run_id && isPendingSignalResponse(data)) {
|
|
472
434
|
const maxWaitMs = Math.max(1e3, params.maxWaitMs ?? 20 * 6e4);
|
|
@@ -494,47 +456,68 @@ var Signaliz = class {
|
|
|
494
456
|
throw new Error(`Company signal enrichment ${data.run_id} did not complete within ${maxWaitMs}ms`);
|
|
495
457
|
}
|
|
496
458
|
}
|
|
497
|
-
return
|
|
498
|
-
success: data.success ?? true,
|
|
499
|
-
status: data.status,
|
|
500
|
-
signalRunId: data.signal_run_id ?? data.run_id,
|
|
501
|
-
company: {
|
|
502
|
-
name: data.company?.name ?? params.companyName ?? null,
|
|
503
|
-
domain: data.company?.domain ?? params.companyDomain ?? null
|
|
504
|
-
},
|
|
505
|
-
signals: (data.signals ?? []).map((signal) => {
|
|
506
|
-
const metadata = signal.metadata && typeof signal.metadata === "object" && !Array.isArray(signal.metadata) ? signal.metadata : void 0;
|
|
507
|
-
return {
|
|
508
|
-
id: signal.id,
|
|
509
|
-
title: signal.title ?? "",
|
|
510
|
-
type: signal.type ?? signal.signal_type ?? "unknown",
|
|
511
|
-
content: signal.content ?? signal.description ?? "",
|
|
512
|
-
date: signal.date ?? signal.detected_at ?? null,
|
|
513
|
-
datePrecision: signal.date_precision,
|
|
514
|
-
sourceUrl: signal.source_url ?? signal.url ?? null,
|
|
515
|
-
sourceType: signal.source_type,
|
|
516
|
-
sourceProvenance: signal.source_provenance,
|
|
517
|
-
confidence: signal.confidence ?? signal.confidence_score ?? null,
|
|
518
|
-
entityConfidence: signal.entity_confidence ?? metadata?.entity_confidence ?? null,
|
|
519
|
-
signalFamily: signal.signal_family,
|
|
520
|
-
eventType: signal.signal_event_type,
|
|
521
|
-
eventLabel: signal.signal_event_label,
|
|
522
|
-
classification: signal.signal_classification ?? null,
|
|
523
|
-
derived: signal.derived === true,
|
|
524
|
-
evidencePublishedDate: signal.evidence_published_date ?? metadata?.evidence_published_date ?? null,
|
|
525
|
-
signalFeedSource: signal.signal_feed_source ?? metadata?.signal_feed_source,
|
|
526
|
-
metadata
|
|
527
|
-
};
|
|
528
|
-
}),
|
|
529
|
-
signalCount: data.signal_count ?? data.total_signals ?? data.signals?.length ?? 0,
|
|
530
|
-
intelligence: data.intelligence ?? null,
|
|
531
|
-
credits: data.credits,
|
|
532
|
-
metadata: data.metadata,
|
|
533
|
-
raw: data
|
|
534
|
-
};
|
|
459
|
+
return normalizeCompanySignalResult(params, data);
|
|
535
460
|
}
|
|
536
461
|
async enrichCompanies(companies, options) {
|
|
537
|
-
|
|
462
|
+
validateBatchSize(companies);
|
|
463
|
+
const startedAt = Date.now();
|
|
464
|
+
const results = new Array(companies.length);
|
|
465
|
+
let pending = companies.map((params, index) => ({
|
|
466
|
+
index,
|
|
467
|
+
request: companySignalRequestBody(params)
|
|
468
|
+
}));
|
|
469
|
+
while (pending.length > 0) {
|
|
470
|
+
const round = await this.runCoreBatchRound("api/v1/company-signals", pending, options);
|
|
471
|
+
const taskByIndex = new Map(pending.map((task) => [task.index, task]));
|
|
472
|
+
const nextPending = [];
|
|
473
|
+
let nextDelayMs = 6e4;
|
|
474
|
+
for (const item of round) {
|
|
475
|
+
const params = companies[item.index];
|
|
476
|
+
const task = taskByIndex.get(item.index);
|
|
477
|
+
if (!item.success || !item.raw) {
|
|
478
|
+
results[item.index] = { index: item.index, success: false, error: item.error || "Company Signal batch request failed" };
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
if (!isPendingSignalResponse(item.raw) || params.waitForResult === false) {
|
|
482
|
+
results[item.index] = { index: item.index, success: true, data: normalizeCompanySignalResult(params, item.raw) };
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
const maxWaitMs = Math.max(1e3, params.maxWaitMs ?? 20 * 6e4);
|
|
486
|
+
if (Date.now() - startedAt >= maxWaitMs) {
|
|
487
|
+
results[item.index] = {
|
|
488
|
+
index: item.index,
|
|
489
|
+
success: false,
|
|
490
|
+
error: `Company signal enrichment ${item.raw.signal_run_id || item.raw.run_id || ""} did not complete within ${maxWaitMs}ms`
|
|
491
|
+
};
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
const signalRunId = item.raw.signal_run_id || item.raw.run_id;
|
|
495
|
+
if (!signalRunId) {
|
|
496
|
+
results[item.index] = { index: item.index, success: false, error: "Company signal enrichment is processing without a signal_run_id" };
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
nextDelayMs = Math.min(
|
|
500
|
+
nextDelayMs,
|
|
501
|
+
signalPollDelayMs(item.raw, params.pollIntervalMs),
|
|
502
|
+
maxWaitMs - (Date.now() - startedAt)
|
|
503
|
+
);
|
|
504
|
+
nextPending.push({
|
|
505
|
+
...task,
|
|
506
|
+
request: { ...task.request, signal_run_id: signalRunId }
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
if (nextPending.length === 0) break;
|
|
510
|
+
await sleep2(Math.max(1, nextDelayMs));
|
|
511
|
+
pending = nextPending;
|
|
512
|
+
}
|
|
513
|
+
const succeeded = results.filter((item) => item.success).length;
|
|
514
|
+
return {
|
|
515
|
+
total: companies.length,
|
|
516
|
+
succeeded,
|
|
517
|
+
failed: companies.length - succeeded,
|
|
518
|
+
durationMs: Date.now() - startedAt,
|
|
519
|
+
results
|
|
520
|
+
};
|
|
538
521
|
}
|
|
539
522
|
async signalToCopy(params) {
|
|
540
523
|
const request = signalToCopyRequestBody(params);
|
|
@@ -557,22 +540,17 @@ var Signaliz = class {
|
|
|
557
540
|
return normalizeSignalToCopyResult(data);
|
|
558
541
|
}
|
|
559
542
|
async createSignalCopyBatch(requests, options) {
|
|
560
|
-
|
|
561
|
-
throw new Error("Signaliz batch requests require at least one item");
|
|
562
|
-
}
|
|
563
|
-
if (requests.length > 5e3) {
|
|
564
|
-
throw new Error(`Signaliz batch requests support at most 5,000 items; received ${requests.length}`);
|
|
565
|
-
}
|
|
543
|
+
validateBatchSize(requests);
|
|
566
544
|
const startedAt = Date.now();
|
|
567
545
|
const chunks = [];
|
|
568
546
|
for (let offset = 0; offset < requests.length; offset += 25) {
|
|
569
547
|
chunks.push({ offset, requests: requests.slice(offset, offset + 25) });
|
|
570
548
|
}
|
|
571
|
-
const serverConcurrency =
|
|
549
|
+
const { serverConcurrency, chunkConcurrency } = batchConcurrencyPlan(options);
|
|
572
550
|
const chunkBatch = await runBatch(
|
|
573
551
|
chunks,
|
|
574
552
|
(chunk) => this.runSignalCopyBatchChunk(chunk.requests, serverConcurrency),
|
|
575
|
-
|
|
553
|
+
{ concurrency: chunkConcurrency }
|
|
576
554
|
);
|
|
577
555
|
const results = new Array(requests.length);
|
|
578
556
|
for (const chunkResult of chunkBatch.results) {
|
|
@@ -662,6 +640,50 @@ var Signaliz = class {
|
|
|
662
640
|
}
|
|
663
641
|
return results;
|
|
664
642
|
}
|
|
643
|
+
async runCoreBatchRound(path2, tasks, options) {
|
|
644
|
+
const { serverConcurrency, chunkConcurrency } = batchConcurrencyPlan(options);
|
|
645
|
+
const chunks = [];
|
|
646
|
+
for (let offset = 0; offset < tasks.length; offset += 25) {
|
|
647
|
+
chunks.push({ offset, tasks: tasks.slice(offset, offset + 25) });
|
|
648
|
+
}
|
|
649
|
+
const chunkBatch = await runBatch(chunks, async (chunk) => {
|
|
650
|
+
const data = await this.client.post(path2, {
|
|
651
|
+
requests: chunk.tasks.map((task) => task.request),
|
|
652
|
+
concurrency: serverConcurrency
|
|
653
|
+
});
|
|
654
|
+
if (!Array.isArray(data.results) || data.results.length !== chunk.tasks.length) {
|
|
655
|
+
throw new Error(`${path2} batch returned an invalid result count`);
|
|
656
|
+
}
|
|
657
|
+
if (data.results.some((row, index) => row.index !== index)) {
|
|
658
|
+
throw new Error(`${path2} batch returned results out of order`);
|
|
659
|
+
}
|
|
660
|
+
return data.results;
|
|
661
|
+
}, { concurrency: chunkConcurrency });
|
|
662
|
+
const results = new Array(tasks.length);
|
|
663
|
+
for (const chunkResult of chunkBatch.results) {
|
|
664
|
+
const chunk = chunks[chunkResult.index];
|
|
665
|
+
if (!chunkResult.success || !chunkResult.data) {
|
|
666
|
+
for (let index = 0; index < chunk.tasks.length; index += 1) {
|
|
667
|
+
results[chunk.offset + index] = {
|
|
668
|
+
index: chunk.tasks[index].index,
|
|
669
|
+
success: false,
|
|
670
|
+
error: chunkResult.error || `${path2} batch request failed`
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
for (let index = 0; index < chunkResult.data.length; index += 1) {
|
|
676
|
+
const raw = chunkResult.data[index];
|
|
677
|
+
results[chunk.offset + index] = {
|
|
678
|
+
index: chunk.tasks[index].index,
|
|
679
|
+
success: raw.success !== false,
|
|
680
|
+
raw,
|
|
681
|
+
error: raw.success === false ? raw.error || raw.message || raw.error_code || `${path2} item failed` : void 0
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
return results;
|
|
686
|
+
}
|
|
665
687
|
async listTools() {
|
|
666
688
|
const result = await this.client.mcp("tools/list");
|
|
667
689
|
return result.tools ?? [];
|
|
@@ -677,6 +699,172 @@ var Signaliz = class {
|
|
|
677
699
|
function compact(input) {
|
|
678
700
|
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
|
|
679
701
|
}
|
|
702
|
+
function findEmailRequestBody(params) {
|
|
703
|
+
return compact({
|
|
704
|
+
company_domain: params.companyDomain,
|
|
705
|
+
full_name: params.fullName,
|
|
706
|
+
first_name: params.firstName,
|
|
707
|
+
last_name: params.lastName,
|
|
708
|
+
linkedin_url: params.linkedinUrl,
|
|
709
|
+
company_name: params.companyName,
|
|
710
|
+
skip_cache: params.skipCache
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
function normalizeFindEmailResult(data) {
|
|
714
|
+
const email = typeof data.email === "string" && data.email.trim() ? data.email.trim() : null;
|
|
715
|
+
const found = Boolean(email) && data.found !== false;
|
|
716
|
+
const verificationStatus = data.verification_status ?? data.status ?? "unknown";
|
|
717
|
+
const rawFreshness = String(data.verification_freshness ?? "").toLowerCase();
|
|
718
|
+
const verificationFreshness = rawFreshness === "fresh" || rawFreshness === "stale" ? rawFreshness : "unknown";
|
|
719
|
+
const needsReverification = data.needs_reverification === true || verificationFreshness === "stale";
|
|
720
|
+
const explicitlyNotSendSafe = data.verified_for_sending === false || needsReverification;
|
|
721
|
+
const verified = !explicitlyNotSendSafe && (data.email_verified === true || data.verified_for_sending === true || ["valid", "deliverable"].includes(String(verificationStatus).toLowerCase()));
|
|
722
|
+
const verificationAgeDays = typeof data.verification_age_days === "number" && Number.isFinite(data.verification_age_days) ? data.verification_age_days : null;
|
|
723
|
+
return {
|
|
724
|
+
success: data.success !== false && found,
|
|
725
|
+
found,
|
|
726
|
+
email,
|
|
727
|
+
firstName: data.first_name,
|
|
728
|
+
lastName: data.last_name,
|
|
729
|
+
confidence: data.confidence ?? data.confidence_score ?? (verified ? 1 : 0),
|
|
730
|
+
verificationStatus,
|
|
731
|
+
isVerified: verified,
|
|
732
|
+
isVerifiedForSending: !needsReverification && data.verified_for_sending === true,
|
|
733
|
+
isCatchAll: data.email_is_catch_all === true || data.is_catch_all === true,
|
|
734
|
+
verificationFreshness,
|
|
735
|
+
verificationAgeDays,
|
|
736
|
+
verifiedAt: typeof data.verified_at === "string" ? data.verified_at : null,
|
|
737
|
+
needsReverification,
|
|
738
|
+
providerUsed: data.provider_used ?? data.provider ?? data.email_source ?? data.source ?? "unknown",
|
|
739
|
+
error: found ? void 0 : data.error ?? "No verified email found",
|
|
740
|
+
errorCode: found ? void 0 : data.error_code ?? "EMAIL_NOT_FOUND",
|
|
741
|
+
raw: data
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
function normalizeVerifyEmailResult(email, data) {
|
|
745
|
+
const verificationStatus = String(data.verification_status ?? "").toLowerCase();
|
|
746
|
+
const verified = data.email_verified === true || ["valid", "deliverable"].includes(verificationStatus);
|
|
747
|
+
return {
|
|
748
|
+
email: data.email ?? email,
|
|
749
|
+
isValid: data.is_valid ?? data.valid ?? verified,
|
|
750
|
+
isDeliverable: data.is_deliverable ?? data.deliverable ?? verified,
|
|
751
|
+
isCatchAll: data.email_is_catch_all ?? data.is_catch_all ?? data.catch_all ?? data.diagnostics?.is_catch_all ?? false,
|
|
752
|
+
confidenceScore: data.confidence_score ?? data.confidence ?? data.diagnostics?.confidence_score ?? (verified ? 1 : 0),
|
|
753
|
+
provider: data.provider,
|
|
754
|
+
verificationSource: data.verification_source,
|
|
755
|
+
raw: data
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
function companySignalRequestBody(params) {
|
|
759
|
+
const online = params.online ?? true;
|
|
760
|
+
return compact({
|
|
761
|
+
signal_run_id: params.signalRunId,
|
|
762
|
+
company_domain: params.companyDomain,
|
|
763
|
+
company_name: params.companyName,
|
|
764
|
+
research_prompt: params.researchPrompt,
|
|
765
|
+
signal_types: params.signalTypes,
|
|
766
|
+
target_signal_count: params.targetSignalCount,
|
|
767
|
+
lookback_days: params.lookbackDays,
|
|
768
|
+
online,
|
|
769
|
+
enable_deep_search: params.enableDeepSearch ?? online,
|
|
770
|
+
enable_outreach_intelligence: params.enableOutreachIntelligence,
|
|
771
|
+
enable_predictive_intelligence: params.enablePredictiveIntelligence,
|
|
772
|
+
skip_cache: params.skipCache,
|
|
773
|
+
// REST always returns a resumable run instead of holding the connection;
|
|
774
|
+
// waitForResult controls the SDK polling loop.
|
|
775
|
+
wait_for_result: false,
|
|
776
|
+
max_wait_ms: params.maxWaitMs
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
function normalizeCompanySignalResult(params, data) {
|
|
780
|
+
return {
|
|
781
|
+
success: data.success ?? true,
|
|
782
|
+
status: data.status,
|
|
783
|
+
signalRunId: data.signal_run_id ?? data.run_id,
|
|
784
|
+
company: {
|
|
785
|
+
name: data.company?.name ?? params.companyName ?? null,
|
|
786
|
+
domain: data.company?.domain ?? params.companyDomain ?? null
|
|
787
|
+
},
|
|
788
|
+
signals: (data.signals ?? []).map((signal) => {
|
|
789
|
+
const metadata = signal.metadata && typeof signal.metadata === "object" && !Array.isArray(signal.metadata) ? signal.metadata : void 0;
|
|
790
|
+
return {
|
|
791
|
+
id: signal.id,
|
|
792
|
+
title: signal.title ?? "",
|
|
793
|
+
type: signal.type ?? signal.signal_type ?? "unknown",
|
|
794
|
+
content: signal.content ?? signal.description ?? "",
|
|
795
|
+
date: signal.date ?? signal.detected_at ?? null,
|
|
796
|
+
datePrecision: signal.date_precision,
|
|
797
|
+
sourceUrl: signal.source_url ?? signal.url ?? null,
|
|
798
|
+
sourceType: signal.source_type,
|
|
799
|
+
sourceProvenance: signal.source_provenance,
|
|
800
|
+
confidence: signal.confidence ?? signal.confidence_score ?? null,
|
|
801
|
+
entityConfidence: signal.entity_confidence ?? metadata?.entity_confidence ?? null,
|
|
802
|
+
signalFamily: signal.signal_family,
|
|
803
|
+
eventType: signal.signal_event_type,
|
|
804
|
+
eventLabel: signal.signal_event_label,
|
|
805
|
+
classification: signal.signal_classification ?? null,
|
|
806
|
+
derived: signal.derived === true,
|
|
807
|
+
evidencePublishedDate: signal.evidence_published_date ?? metadata?.evidence_published_date ?? null,
|
|
808
|
+
signalFeedSource: signal.signal_feed_source ?? metadata?.signal_feed_source,
|
|
809
|
+
metadata
|
|
810
|
+
};
|
|
811
|
+
}),
|
|
812
|
+
signalCount: data.signal_count ?? data.total_signals ?? data.signals?.length ?? 0,
|
|
813
|
+
intelligence: data.intelligence ?? null,
|
|
814
|
+
credits: data.credits,
|
|
815
|
+
metadata: data.metadata,
|
|
816
|
+
raw: data
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
function validateBatchSize(items) {
|
|
820
|
+
if (!Array.isArray(items) || items.length === 0) {
|
|
821
|
+
throw new Error("Signaliz batch requests require at least one item");
|
|
822
|
+
}
|
|
823
|
+
if (items.length > 5e3) {
|
|
824
|
+
throw new Error(`Signaliz batch requests support at most 5,000 items; received ${items.length}`);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
function validatedBatchConcurrency(options) {
|
|
828
|
+
const concurrency = options?.concurrency ?? 10;
|
|
829
|
+
if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 50) {
|
|
830
|
+
throw new Error("Signaliz batch concurrency must be an integer between 1 and 50");
|
|
831
|
+
}
|
|
832
|
+
return concurrency;
|
|
833
|
+
}
|
|
834
|
+
function batchConcurrencyPlan(options) {
|
|
835
|
+
const concurrency = validatedBatchConcurrency(options);
|
|
836
|
+
const serverConcurrency = Math.min(10, concurrency);
|
|
837
|
+
return {
|
|
838
|
+
serverConcurrency,
|
|
839
|
+
chunkConcurrency: Math.max(1, Math.floor(concurrency / serverConcurrency))
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
function finalizeCoreBatch(total, startedAt, round, normalize) {
|
|
843
|
+
const results = new Array(total);
|
|
844
|
+
for (const item of round) {
|
|
845
|
+
if (!item.success || !item.raw) {
|
|
846
|
+
results[item.index] = { index: item.index, success: false, error: item.error || "Signaliz batch item failed" };
|
|
847
|
+
continue;
|
|
848
|
+
}
|
|
849
|
+
try {
|
|
850
|
+
results[item.index] = { index: item.index, success: true, data: normalize(item) };
|
|
851
|
+
} catch (error) {
|
|
852
|
+
results[item.index] = {
|
|
853
|
+
index: item.index,
|
|
854
|
+
success: false,
|
|
855
|
+
error: error instanceof Error ? error.message : String(error)
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
const succeeded = results.filter((item) => item.success).length;
|
|
860
|
+
return {
|
|
861
|
+
total,
|
|
862
|
+
succeeded,
|
|
863
|
+
failed: total - succeeded,
|
|
864
|
+
durationMs: Date.now() - startedAt,
|
|
865
|
+
results
|
|
866
|
+
};
|
|
867
|
+
}
|
|
680
868
|
function signalToCopyRequestBody(params) {
|
|
681
869
|
return compact({
|
|
682
870
|
company_domain: params.companyDomain,
|
|
@@ -738,16 +926,8 @@ function sleep2(ms) {
|
|
|
738
926
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
739
927
|
}
|
|
740
928
|
async function runBatch(items, execute, options) {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
}
|
|
744
|
-
if (items.length > 5e3) {
|
|
745
|
-
throw new Error(`Signaliz batch requests support at most 5,000 items; received ${items.length}`);
|
|
746
|
-
}
|
|
747
|
-
const concurrency = options?.concurrency ?? 10;
|
|
748
|
-
if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 50) {
|
|
749
|
-
throw new Error("Signaliz batch concurrency must be an integer between 1 and 50");
|
|
750
|
-
}
|
|
929
|
+
validateBatchSize(items);
|
|
930
|
+
const concurrency = validatedBatchConcurrency(options);
|
|
751
931
|
const startedAt = Date.now();
|
|
752
932
|
const results = new Array(items.length);
|
|
753
933
|
let nextIndex = 0;
|
package/dist/mcp-config.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signaliz/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
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",
|
|
@@ -8,14 +8,24 @@
|
|
|
8
8
|
"bin": {
|
|
9
9
|
"signaliz-mcp": "dist/mcp-config.js"
|
|
10
10
|
},
|
|
11
|
-
"files": [
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
12
15
|
"scripts": {
|
|
13
16
|
"generate-types": "tsx scripts/generate-types.ts",
|
|
14
17
|
"build": "npm run generate-types && tsup src/index.ts src/mcp-config.ts --format cjs,esm --dts --clean",
|
|
15
18
|
"test": "tsx tests/core-products.test.ts",
|
|
16
19
|
"prepublishOnly": "npm run build"
|
|
17
20
|
},
|
|
18
|
-
"keywords": [
|
|
21
|
+
"keywords": [
|
|
22
|
+
"signaliz",
|
|
23
|
+
"mcp",
|
|
24
|
+
"email-finder",
|
|
25
|
+
"email-verification",
|
|
26
|
+
"company-signals",
|
|
27
|
+
"signal-to-copy"
|
|
28
|
+
],
|
|
19
29
|
"license": "MIT",
|
|
20
30
|
"repository": {
|
|
21
31
|
"type": "git",
|