@cernisdata/sdk 0.0.0-stage → 0.1.0
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 +94 -2
- package/dist/cjs/index.d.ts +1940 -0
- package/dist/cjs/index.js +600 -0
- package/dist/cjs/package.json +1 -0
- package/dist/index.d.ts +1940 -0
- package/dist/index.js +577 -0
- package/package.json +38 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
// Cernis Data TypeScript SDK. Works anywhere fetch exists (Node 18+, Workers, Deno, Bun, browsers).
|
|
2
|
+
//
|
|
3
|
+
// const cernis = new CernisData(); // CERNIS_DATA_API_KEY, CERNIS_DATA_BASE_URL
|
|
4
|
+
// const page = await cernisdata.people.search({ jobTitles: ['VP Sales'], locations: ['United States'], limit: 25 });
|
|
5
|
+
// for await (const person of cernisdata.people.search.iter({ jobTitles: ['VP Sales'] }, { maxItems: 100 })) { ... }
|
|
6
|
+
//
|
|
7
|
+
// The endpoint table, parameter types and namespaces below are generated from the registry and the zod input
|
|
8
|
+
// schemas by scripts/build-openapi.ts (npm run openapi). Everything after the generated block is hand written.
|
|
9
|
+
// Kept in one file so Node can run it straight from source with type stripping.
|
|
10
|
+
// BEGIN GENERATED by scripts/build-openapi.ts. Do not edit by hand.
|
|
11
|
+
/** Fallback API base URL, from APP_URL in wrangler.jsonc at build time. Empty until a domain is set: pass baseUrl or set CERNIS_DATA_BASE_URL. */
|
|
12
|
+
export const DEFAULT_BASE_URL = "https://cernisdata.io";
|
|
13
|
+
/** Fields of each filters object, and which of them are include/exclude lists. */
|
|
14
|
+
export const FILTERS = {
|
|
15
|
+
PeopleFilters: { fields: ['first_names', 'last_names', 'job_titles', 'past_job_titles', 'keywords', 'locations', 'languages', 'schools', 'skills', 'company_names', 'company_domains', 'company_linkedin_urls', 'company_industries', 'company_locations', 'company_keywords', 'company_headcount', 'years_of_experience'], lists: ['first_names', 'last_names', 'job_titles', 'past_job_titles', 'keywords', 'locations', 'languages', 'schools', 'skills', 'company_names', 'company_domains', 'company_linkedin_urls', 'company_industries', 'company_locations', 'company_keywords'] },
|
|
16
|
+
CompanyFilters: { fields: ['names', 'domains', 'industries', 'locations', 'keywords', 'types', 'headcount'], lists: ['names', 'domains', 'industries', 'locations', 'keywords', 'types'] },
|
|
17
|
+
};
|
|
18
|
+
export const ENDPOINTS = [
|
|
19
|
+
{ id: 'people.search', name: "People Search", category: 'people', fn: 'search', method: 'POST', path: '/v1/people/search', mode: 'sync', status: 'live', typed: true, paginated: true, filters: 'PeopleFilters' },
|
|
20
|
+
{ id: 'people.search_count', name: "People Search Count", category: 'people', fn: 'searchCount', method: 'POST', path: '/v1/people/search/count', mode: 'sync', status: 'live', typed: true, filters: 'PeopleFilters' },
|
|
21
|
+
{ id: 'people.decision_makers', name: "Decision-Maker Search", category: 'people', fn: 'decisionMakers', method: 'POST', path: '/v1/people/decision-makers', mode: 'sync', status: 'live', typed: true, paginated: true, lists: ['locations'] },
|
|
22
|
+
{ id: 'people.employees', name: "Employee Finder", category: 'people', fn: 'employees', method: 'POST', path: '/v1/people/employees', mode: 'sync', status: 'live', typed: true, paginated: true, lists: ['job_titles', 'locations'] },
|
|
23
|
+
{ id: 'people.profile_basic', name: "Basic Professional Profile", category: 'people', fn: 'profileBasic', method: 'GET', path: '/v1/people/profile/basic', mode: 'sync', status: 'live', typed: true },
|
|
24
|
+
{ id: 'people.profile', name: "Full Professional Profile", category: 'people', fn: 'profile', method: 'GET', path: '/v1/people/profile', mode: 'sync', status: 'live', typed: true },
|
|
25
|
+
{ id: 'people.employment_history', name: "Employment History", category: 'people', fn: 'employmentHistory', method: 'GET', path: '/v1/people/employment-history', mode: 'sync', status: 'live', typed: true },
|
|
26
|
+
{ id: 'people.profile_url', name: "Professional Profile URL Finder", category: 'people', fn: 'profileUrl', method: 'POST', path: '/v1/people/profile-url', mode: 'sync', status: 'live', typed: true },
|
|
27
|
+
{ id: 'people.current_role', name: "Current Role", category: 'people', fn: 'currentRole', method: 'GET', path: '/v1/people/current-role', mode: 'sync', status: 'live', typed: true },
|
|
28
|
+
{ id: 'people.seniority', name: "Seniority Classification", category: 'people', fn: 'seniority', method: 'POST', path: '/v1/people/seniority', mode: 'sync', status: 'live', typed: true },
|
|
29
|
+
{ id: 'company.search', name: "Company Search", category: 'company', fn: 'search', method: 'POST', path: '/v1/companies/search', mode: 'sync', status: 'live', typed: true, paginated: true, filters: 'CompanyFilters' },
|
|
30
|
+
{ id: 'company.search_count', name: "Company Search Count", category: 'company', fn: 'searchCount', method: 'POST', path: '/v1/companies/search/count', mode: 'sync', status: 'live', typed: true, filters: 'CompanyFilters' },
|
|
31
|
+
{ id: 'company.enrich', name: "Company Enrichment", category: 'company', fn: 'enrich', method: 'POST', path: '/v1/companies/enrich', mode: 'sync', status: 'live', typed: true },
|
|
32
|
+
{ id: 'company.domain', name: "Company Domain Finder", category: 'company', fn: 'domain', method: 'POST', path: '/v1/companies/domain', mode: 'sync', status: 'live', typed: true },
|
|
33
|
+
{ id: 'company.linkedin', name: "LinkedIn Company Profile", category: 'company', fn: 'linkedin', method: 'GET', path: '/v1/companies/linkedin', mode: 'sync', status: 'live', typed: true },
|
|
34
|
+
{ id: 'company.profile_url', name: "Company Profile URL Finder", category: 'company', fn: 'profileUrl', method: 'POST', path: '/v1/companies/profile-url', mode: 'sync', status: 'live', typed: true },
|
|
35
|
+
{ id: 'company.firmographics', name: "Company Firmographics", category: 'company', fn: 'firmographics', method: 'GET', path: '/v1/companies/firmographics', mode: 'sync', status: 'live', typed: true },
|
|
36
|
+
{ id: 'company.headcount', name: "Company Headcount", category: 'company', fn: 'headcount', method: 'GET', path: '/v1/companies/headcount', mode: 'sync', status: 'live', typed: true },
|
|
37
|
+
{ id: 'company.funding', name: "Company Funding", category: 'company', fn: 'funding', method: 'GET', path: '/v1/companies/funding', mode: 'sync', status: 'live', typed: true },
|
|
38
|
+
{ id: 'company.technographics', name: "Technographics", category: 'company', fn: 'technographics', method: 'GET', path: '/v1/companies/technographics', mode: 'sync', status: 'live', typed: true },
|
|
39
|
+
{ id: 'company.similar', name: "Similar Companies", category: 'company', fn: 'similar', method: 'POST', path: '/v1/companies/similar', mode: 'sync', status: 'live', typed: true },
|
|
40
|
+
{ id: 'company.website_metadata', name: "Website Metadata", category: 'company', fn: 'websiteMetadata', method: 'GET', path: '/v1/companies/website-metadata', mode: 'sync', status: 'live', typed: true },
|
|
41
|
+
{ id: 'contact.email', name: "Work Email Finder", category: 'contact', fn: 'email', method: 'POST', path: '/v1/contacts/email', mode: 'async', status: 'live', typed: true },
|
|
42
|
+
{ id: 'contact.email_bulk', name: "Bulk Email Finder", category: 'contact', fn: 'emailBulk', method: 'POST', path: '/v1/contacts/email/bulk', mode: 'job', status: 'live', typed: true },
|
|
43
|
+
{ id: 'contact.verify', name: "Email Verification", category: 'contact', fn: 'verify', method: 'POST', path: '/v1/contacts/verify', mode: 'async', status: 'live', typed: true },
|
|
44
|
+
{ id: 'contact.verify_bulk', name: "Bulk Email Verification", category: 'contact', fn: 'verifyBulk', method: 'POST', path: '/v1/contacts/verify/bulk', mode: 'job', status: 'live', typed: true },
|
|
45
|
+
{ id: 'contact.reverse', name: "Reverse Email Lookup", category: 'contact', fn: 'reverse', method: 'GET', path: '/v1/contacts/reverse', mode: 'sync', status: 'live', typed: true },
|
|
46
|
+
{ id: 'contact.phone', name: "Mobile Phone Finder", category: 'contact', fn: 'phone', method: 'POST', path: '/v1/contacts/phone', mode: 'sync', status: 'live', typed: true },
|
|
47
|
+
{ id: 'contact.domain_emails', name: "Domain Email Discovery", category: 'contact', fn: 'domainEmails', method: 'GET', path: '/v1/contacts/domain-emails', mode: 'sync', status: 'live', typed: true },
|
|
48
|
+
{ id: 'contact.linkedin_email', name: "LinkedIn to Work Email", category: 'contact', fn: 'linkedinEmail', method: 'POST', path: '/v1/contacts/linkedin-email', mode: 'async', status: 'live', typed: true },
|
|
49
|
+
{ id: 'contact.waterfall', name: "Email Waterfall", category: 'contact', fn: 'waterfall', method: 'POST', path: '/v1/contacts/email/waterfall', mode: 'async', status: 'live', typed: true },
|
|
50
|
+
{ id: 'contact.validate_syntax', name: "Email Syntax Validation", category: 'contact', fn: 'validateSyntax', method: 'POST', path: '/v1/contacts/validate/syntax', mode: 'sync', status: 'live', typed: true },
|
|
51
|
+
{ id: 'contact.validate_mx', name: "MX Record Validation", category: 'contact', fn: 'validateMx', method: 'GET', path: '/v1/contacts/validate/mx', mode: 'sync', status: 'live', typed: true },
|
|
52
|
+
{ id: 'signals.jobs_search', name: "Job Search", category: 'signals', fn: 'jobsSearch', method: 'POST', path: '/v1/signals/jobs/search', mode: 'sync', status: 'live', typed: true, paginated: true },
|
|
53
|
+
{ id: 'signals.job', name: "Job Details", category: 'signals', fn: 'job', method: 'GET', path: '/v1/signals/jobs', mode: 'sync', status: 'live', typed: true },
|
|
54
|
+
{ id: 'signals.hiring', name: "Company Hiring Activity", category: 'signals', fn: 'hiring', method: 'GET', path: '/v1/signals/hiring', mode: 'sync', status: 'live', typed: true },
|
|
55
|
+
{ id: 'signals.job_changes', name: "Job Change Detector", category: 'signals', fn: 'jobChanges', method: 'POST', path: '/v1/signals/job-changes', mode: 'sync', status: 'live', typed: true },
|
|
56
|
+
{ id: 'signals.funding', name: "Funding Lookup", category: 'signals', fn: 'funding', method: 'GET', path: '/v1/signals/funding', mode: 'sync', status: 'live', typed: true },
|
|
57
|
+
{ id: 'signals.funding_recent', name: "Recent Funding Events", category: 'signals', fn: 'fundingRecent', method: 'POST', path: '/v1/signals/funding/recent', mode: 'sync', status: 'live', typed: true },
|
|
58
|
+
{ id: 'signals.leadership', name: "Leadership Changes", category: 'signals', fn: 'leadership', method: 'GET', path: '/v1/signals/leadership', mode: 'sync', status: 'live', typed: true },
|
|
59
|
+
{ id: 'signals.news', name: "Company News", category: 'signals', fn: 'news', method: 'GET', path: '/v1/signals/news', mode: 'sync', status: 'live', typed: true },
|
|
60
|
+
{ id: 'signals.website_changes', name: "Website Change Detection", category: 'signals', fn: 'websiteChanges', method: 'POST', path: '/v1/signals/website-changes', mode: 'sync', status: 'live', typed: true },
|
|
61
|
+
{ id: 'signals.custom', name: "Custom Buying Signals", category: 'signals', fn: 'custom', method: 'POST', path: '/v1/signals/custom', mode: 'sync', status: 'live', typed: true },
|
|
62
|
+
{ id: 'signals.linkedin_posts_search', name: "LinkedIn Post Search", category: 'signals', fn: 'linkedinPostsSearch', method: 'POST', path: '/v1/signals/linkedin/posts/search', mode: 'sync', status: 'live', typed: true },
|
|
63
|
+
{ id: 'signals.linkedin_posts', name: "LinkedIn Posts by Profile or Company", category: 'signals', fn: 'linkedinPosts', method: 'GET', path: '/v1/signals/linkedin/posts', mode: 'sync', status: 'live', typed: true },
|
|
64
|
+
{ id: 'signals.linkedin_post_engagers', name: "LinkedIn Post Engagers", category: 'signals', fn: 'linkedinPostEngagers', method: 'GET', path: '/v1/signals/linkedin/posts/engagers', mode: 'sync', status: 'live', typed: true },
|
|
65
|
+
{ id: 'web.search', name: "Google Search", category: 'web', fn: 'search', method: 'POST', path: '/v1/web/search', mode: 'sync', status: 'live', typed: true },
|
|
66
|
+
{ id: 'web.semantic_search', name: "Semantic Search", category: 'web', fn: 'semanticSearch', method: 'POST', path: '/v1/web/semantic-search', mode: 'sync', status: 'coming_soon', typed: false },
|
|
67
|
+
{ id: 'web.news', name: "News Search", category: 'web', fn: 'news', method: 'POST', path: '/v1/web/news', mode: 'sync', status: 'live', typed: true },
|
|
68
|
+
{ id: 'web.scrape', name: "Web Scraping", category: 'web', fn: 'scrape', method: 'POST', path: '/v1/web/scrape', mode: 'sync', status: 'live', typed: true },
|
|
69
|
+
{ id: 'web.markdown', name: "Website to Markdown", category: 'web', fn: 'markdown', method: 'POST', path: '/v1/web/markdown', mode: 'sync', status: 'live', typed: true },
|
|
70
|
+
{ id: 'web.extract', name: "Structured Data Extraction", category: 'web', fn: 'extract', method: 'POST', path: '/v1/web/extract', mode: 'sync', status: 'live', typed: true },
|
|
71
|
+
{ id: 'web.sitemap', name: "Website Sitemap", category: 'web', fn: 'sitemap', method: 'GET', path: '/v1/web/sitemap', mode: 'sync', status: 'live', typed: true },
|
|
72
|
+
{ id: 'web.crawl', name: "Website Crawling", category: 'web', fn: 'crawl', method: 'POST', path: '/v1/web/crawl', mode: 'job', status: 'live', typed: true },
|
|
73
|
+
{ id: 'web.research_company', name: "Company Research", category: 'web', fn: 'researchCompany', method: 'POST', path: '/v1/web/research/company', mode: 'async', status: 'live', typed: true },
|
|
74
|
+
{ id: 'web.research', name: "Deep Research", category: 'web', fn: 'research', method: 'POST', path: '/v1/web/research', mode: 'async', status: 'live', typed: true },
|
|
75
|
+
{ id: 'web.qualify', name: "ICP Qualification", category: 'web', fn: 'qualify', method: 'POST', path: '/v1/web/qualify', mode: 'sync', status: 'live', typed: true },
|
|
76
|
+
];
|
|
77
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
78
|
+
// Errors
|
|
79
|
+
/** Base class for every error the SDK throws. `code` is the API error code (see the error table in the docs). */
|
|
80
|
+
export class CernisDataError extends Error {
|
|
81
|
+
status;
|
|
82
|
+
code;
|
|
83
|
+
requestId;
|
|
84
|
+
details;
|
|
85
|
+
checkoutUrl;
|
|
86
|
+
constructor(status, body, message) {
|
|
87
|
+
super(message ?? body?.error?.message ?? `HTTP ${status}`);
|
|
88
|
+
this.name = new.target.name;
|
|
89
|
+
this.status = status;
|
|
90
|
+
this.code = body?.error?.code ?? 'http_error';
|
|
91
|
+
this.requestId = body?.request_id ?? null;
|
|
92
|
+
this.details = body?.error?.details;
|
|
93
|
+
this.checkoutUrl = body?.error?.checkout_url ?? null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** 400: the input failed validation. `details` lists `{ field, message }`. */
|
|
97
|
+
export class InvalidInputError extends CernisDataError {
|
|
98
|
+
}
|
|
99
|
+
/** 401: missing, wrong or revoked API key. */
|
|
100
|
+
export class AuthenticationError extends CernisDataError {
|
|
101
|
+
}
|
|
102
|
+
/** 402: not enough balance. `checkoutUrl` tops up the wallet. */
|
|
103
|
+
export class InsufficientBalanceError extends CernisDataError {
|
|
104
|
+
}
|
|
105
|
+
/** 403: the key's scopes do not allow this call. */
|
|
106
|
+
export class PermissionDeniedError extends CernisDataError {
|
|
107
|
+
}
|
|
108
|
+
/** 404 */
|
|
109
|
+
export class NotFoundError extends CernisDataError {
|
|
110
|
+
}
|
|
111
|
+
/** 409 / 422: an idempotency key conflict or an expired quote. */
|
|
112
|
+
export class ConflictError extends CernisDataError {
|
|
113
|
+
}
|
|
114
|
+
/** 429: slow down. `retryAfter` is in seconds when the API sent one. */
|
|
115
|
+
export class RateLimitError extends CernisDataError {
|
|
116
|
+
retryAfter = null;
|
|
117
|
+
}
|
|
118
|
+
/** 501: the endpoint has no live data route yet. */
|
|
119
|
+
export class EndpointNotAvailableError extends CernisDataError {
|
|
120
|
+
}
|
|
121
|
+
/** 504 from the API, or the SDK gave up waiting (status 0). */
|
|
122
|
+
export class TimeoutError extends CernisDataError {
|
|
123
|
+
}
|
|
124
|
+
/** 5xx: provider unavailable, no qualified route, or an internal error. You were not charged. */
|
|
125
|
+
export class ServerError extends CernisDataError {
|
|
126
|
+
}
|
|
127
|
+
/** The request never got an answer: DNS, TLS, connection reset. */
|
|
128
|
+
export class APIConnectionError extends CernisDataError {
|
|
129
|
+
}
|
|
130
|
+
/** A webhook failed signature verification. */
|
|
131
|
+
export class WebhookVerificationError extends CernisDataError {
|
|
132
|
+
}
|
|
133
|
+
const BY_CODE = {
|
|
134
|
+
invalid_input: InvalidInputError, unauthorized: AuthenticationError, insufficient_balance: InsufficientBalanceError, trial_expired: InsufficientBalanceError,
|
|
135
|
+
forbidden: PermissionDeniedError, not_found: NotFoundError, quote_expired: ConflictError, idempotency_in_progress: ConflictError,
|
|
136
|
+
idempotency_key_reused: ConflictError, rate_limited: RateLimitError, endpoint_not_available: EndpointNotAvailableError, deadline_exceeded: TimeoutError,
|
|
137
|
+
provider_unavailable: ServerError, no_qualified_route: ServerError, internal_error: ServerError,
|
|
138
|
+
};
|
|
139
|
+
const BY_STATUS = {
|
|
140
|
+
400: InvalidInputError, 401: AuthenticationError, 402: InsufficientBalanceError, 403: PermissionDeniedError, 404: NotFoundError,
|
|
141
|
+
409: ConflictError, 422: ConflictError, 429: RateLimitError, 501: EndpointNotAvailableError, 504: TimeoutError,
|
|
142
|
+
};
|
|
143
|
+
/** Build the right error subclass from an API error response. */
|
|
144
|
+
export function errorFromResponse(status, body, headers) {
|
|
145
|
+
const Cls = BY_CODE[body?.error?.code] ?? BY_STATUS[status] ?? (status >= 500 ? ServerError : CernisDataError);
|
|
146
|
+
const err = new Cls(status, body);
|
|
147
|
+
if (err instanceof RateLimitError)
|
|
148
|
+
err.retryAfter = retryAfterSeconds(headers);
|
|
149
|
+
return err;
|
|
150
|
+
}
|
|
151
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
152
|
+
// Helpers
|
|
153
|
+
const envVar = (name) => globalThis.process?.env?.[name] || undefined;
|
|
154
|
+
const sleep = (ms, signal) => new Promise((resolve, reject) => {
|
|
155
|
+
if (signal?.aborted)
|
|
156
|
+
return reject(signal.reason);
|
|
157
|
+
const t = setTimeout(resolve, ms);
|
|
158
|
+
signal?.addEventListener('abort', () => { clearTimeout(t); reject(signal.reason); }, { once: true });
|
|
159
|
+
});
|
|
160
|
+
const isPlainObject = (v) => !!v && typeof v === 'object' && !Array.isArray(v) && Object.getPrototypeOf(v) === Object.prototype;
|
|
161
|
+
const toSnake = (k) => k.replace(/[A-Z]/g, (m) => `_${m.toLowerCase()}`);
|
|
162
|
+
const randomId = () => globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`;
|
|
163
|
+
function retryAfterSeconds(headers) {
|
|
164
|
+
const v = headers?.get('retry-after');
|
|
165
|
+
if (!v)
|
|
166
|
+
return null;
|
|
167
|
+
if (/^\d+(\.\d+)?$/.test(v.trim()))
|
|
168
|
+
return Number(v);
|
|
169
|
+
const at = Date.parse(v);
|
|
170
|
+
return Number.isNaN(at) ? null : Math.max(0, (at - Date.now()) / 1000);
|
|
171
|
+
}
|
|
172
|
+
/** camelCase keys to snake_case, deep. Drops undefined values. Strings and other values are left alone. */
|
|
173
|
+
export function snakeKeys(v) {
|
|
174
|
+
if (Array.isArray(v))
|
|
175
|
+
return v.map(snakeKeys);
|
|
176
|
+
if (!isPlainObject(v))
|
|
177
|
+
return v;
|
|
178
|
+
const out = {};
|
|
179
|
+
for (const [k, val] of Object.entries(v))
|
|
180
|
+
if (val !== undefined)
|
|
181
|
+
out[toSnake(k)] = snakeKeys(val);
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
const asList = (v) => (typeof v === 'string' ? [v] : v);
|
|
185
|
+
function normalizeLists(o, fields) {
|
|
186
|
+
for (const f of fields) {
|
|
187
|
+
const v = o[f];
|
|
188
|
+
if (v === undefined || v === null)
|
|
189
|
+
continue;
|
|
190
|
+
if (isPlainObject(v)) {
|
|
191
|
+
o[f] = { ...v };
|
|
192
|
+
for (const side of ['include', 'exclude'])
|
|
193
|
+
if (v[side] !== undefined)
|
|
194
|
+
o[f][side] = asList(v[side]);
|
|
195
|
+
}
|
|
196
|
+
else
|
|
197
|
+
o[f] = asList(v);
|
|
198
|
+
}
|
|
199
|
+
return o;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* What goes on the wire for an endpoint: snake_case keys, flat filter fields moved into `filters`, and
|
|
203
|
+
* include/exclude lists given as a string turned into arrays.
|
|
204
|
+
*/
|
|
205
|
+
export function prepareInput(endpoint, params) {
|
|
206
|
+
const input = snakeKeys(params ?? {});
|
|
207
|
+
if (!endpoint)
|
|
208
|
+
return input;
|
|
209
|
+
const e = endpoint;
|
|
210
|
+
if (e.filters) {
|
|
211
|
+
const group = FILTERS[e.filters];
|
|
212
|
+
const filters = isPlainObject(input.filters) ? { ...input.filters } : {};
|
|
213
|
+
for (const f of group.fields)
|
|
214
|
+
if (f in input) {
|
|
215
|
+
filters[f] = input[f];
|
|
216
|
+
delete input[f];
|
|
217
|
+
}
|
|
218
|
+
if (Object.keys(filters).length || input.filters !== undefined)
|
|
219
|
+
input.filters = normalizeLists(filters, group.lists);
|
|
220
|
+
}
|
|
221
|
+
if (e.lists)
|
|
222
|
+
normalizeLists(input, e.lists);
|
|
223
|
+
return input;
|
|
224
|
+
}
|
|
225
|
+
export const findEndpoint = (id) => ENDPOINTS.find((e) => e.id === id);
|
|
226
|
+
const endpointByPath = (method, path) => ENDPOINTS.find((e) => e.method === method && e.path === path);
|
|
227
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
228
|
+
// Webhooks
|
|
229
|
+
const enc = new TextEncoder();
|
|
230
|
+
const toHex = (b) => [...new Uint8Array(b)].map((x) => x.toString(16).padStart(2, '0')).join('');
|
|
231
|
+
function safeEqual(a, b) {
|
|
232
|
+
if (a.length !== b.length)
|
|
233
|
+
return false;
|
|
234
|
+
let diff = 0;
|
|
235
|
+
for (let i = 0; i < a.length; i++)
|
|
236
|
+
diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
237
|
+
return diff === 0;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Verify a job webhook and return its parsed payload. Pass the raw request body (not re-serialized JSON), the
|
|
241
|
+
* CernisData-Signature header and your secret from `client.webhooks.secret()`. Throws WebhookVerificationError.
|
|
242
|
+
*/
|
|
243
|
+
export async function verifyWebhook(payload, signature, secret, options = {}) {
|
|
244
|
+
const fail = (message) => new WebhookVerificationError(400, { error: { code: 'invalid_signature', message } });
|
|
245
|
+
const body = typeof payload === 'string' ? payload : new TextDecoder().decode(payload);
|
|
246
|
+
let ts = null;
|
|
247
|
+
const sigs = [];
|
|
248
|
+
for (const part of (signature ?? '').split(',')) {
|
|
249
|
+
const [k, v] = part.trim().split('=', 2);
|
|
250
|
+
if (k === 't' && v && /^\d+$/.test(v))
|
|
251
|
+
ts = Number(v);
|
|
252
|
+
else if (k === 'v1' && v)
|
|
253
|
+
sigs.push(v);
|
|
254
|
+
}
|
|
255
|
+
if (ts === null || !sigs.length)
|
|
256
|
+
throw fail('Missing or malformed CernisData-Signature header.');
|
|
257
|
+
const tolerance = options.toleranceSec ?? 300;
|
|
258
|
+
const nowSec = Math.floor((options.now ?? Date.now()) / 1000);
|
|
259
|
+
if (tolerance > 0 && Math.abs(nowSec - ts) > tolerance)
|
|
260
|
+
throw fail('Webhook timestamp is outside the tolerance window.');
|
|
261
|
+
const key = await crypto.subtle.importKey('raw', enc.encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
|
|
262
|
+
const expected = toHex(await crypto.subtle.sign('HMAC', key, enc.encode(`${ts}.${body}`)));
|
|
263
|
+
if (!sigs.some((s) => safeEqual(s, expected)))
|
|
264
|
+
throw fail('Webhook signature does not match.');
|
|
265
|
+
return JSON.parse(body);
|
|
266
|
+
}
|
|
267
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
268
|
+
// Jobs
|
|
269
|
+
const PENDING = new Set(['pending', 'queued', 'running']);
|
|
270
|
+
/** A bulk job. `await job.wait()` then `for await (const item of job.results())`. */
|
|
271
|
+
export class Job {
|
|
272
|
+
id;
|
|
273
|
+
status;
|
|
274
|
+
total;
|
|
275
|
+
done;
|
|
276
|
+
/** The last raw response for this job. */
|
|
277
|
+
raw;
|
|
278
|
+
#client;
|
|
279
|
+
constructor(client, raw) {
|
|
280
|
+
this.#client = client;
|
|
281
|
+
this.id = raw.job_id ?? raw.request_id;
|
|
282
|
+
this.raw = raw;
|
|
283
|
+
this.status = raw.status;
|
|
284
|
+
this.total = raw.total ?? 0;
|
|
285
|
+
this.done = raw.done ?? 0;
|
|
286
|
+
}
|
|
287
|
+
get finished() { return !PENDING.has(this.status); }
|
|
288
|
+
/** Fetch the current status. */
|
|
289
|
+
async refresh() {
|
|
290
|
+
const raw = await this.#client.job(this.id);
|
|
291
|
+
this.raw = raw;
|
|
292
|
+
this.status = raw.status;
|
|
293
|
+
this.total = raw.total ?? this.total;
|
|
294
|
+
this.done = raw.done ?? this.done;
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
/** Poll until the job is no longer running. */
|
|
298
|
+
async wait(o = {}) {
|
|
299
|
+
await this.#client.poll(() => this.refresh().then((j) => (j.finished ? j : null)), { ...o, what: `Job ${this.id}` });
|
|
300
|
+
return this;
|
|
301
|
+
}
|
|
302
|
+
/** Every item with its result, 100 per request. Works while the job runs too (finished items only). */
|
|
303
|
+
async *results() {
|
|
304
|
+
let after;
|
|
305
|
+
for (;;) {
|
|
306
|
+
const page = await this.#client.job(this.id, after);
|
|
307
|
+
for (const it of page.items ?? [])
|
|
308
|
+
yield it;
|
|
309
|
+
if (page.next_after === null || page.next_after === undefined)
|
|
310
|
+
return;
|
|
311
|
+
after = page.next_after;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
toJSON() { return this.raw; }
|
|
315
|
+
}
|
|
316
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
317
|
+
// Client
|
|
318
|
+
const NAMESPACES = { people: 'people', company: 'companies', contact: 'contacts', signals: 'signals', web: 'web' };
|
|
319
|
+
const MAX_RETRY_AFTER_MS = 60_000;
|
|
320
|
+
export class CernisData {
|
|
321
|
+
apiKey;
|
|
322
|
+
/** Empty when no base URL is configured; calls then throw a CernisDataError explaining how to set one. */
|
|
323
|
+
baseUrl;
|
|
324
|
+
surface;
|
|
325
|
+
timeoutMs;
|
|
326
|
+
maxRetries;
|
|
327
|
+
waitTimeoutMs;
|
|
328
|
+
pollIntervalMs;
|
|
329
|
+
fetcher;
|
|
330
|
+
extraHeaders;
|
|
331
|
+
static verifyWebhook = verifyWebhook;
|
|
332
|
+
constructor(o = {}) {
|
|
333
|
+
this.apiKey = o.apiKey ?? envVar('CERNIS_DATA_API_KEY');
|
|
334
|
+
this.baseUrl = (o.baseUrl ?? envVar('CERNIS_DATA_BASE_URL') ?? DEFAULT_BASE_URL ?? '').replace(/\/+$/, '').replace(/\/v1$/, '');
|
|
335
|
+
this.surface = o.surface ?? 'sdk';
|
|
336
|
+
this.timeoutMs = o.timeoutMs ?? 60_000;
|
|
337
|
+
this.maxRetries = o.maxRetries ?? 2;
|
|
338
|
+
this.waitTimeoutMs = o.waitTimeoutMs ?? 300_000;
|
|
339
|
+
this.pollIntervalMs = o.pollIntervalMs ?? 1_000;
|
|
340
|
+
this.extraHeaders = o.headers ?? {};
|
|
341
|
+
this.fetcher = o.fetch ?? ((...a) => fetch(...a));
|
|
342
|
+
const self = this;
|
|
343
|
+
for (const ns of Object.values(NAMESPACES))
|
|
344
|
+
self[ns] = {};
|
|
345
|
+
for (const e of ENDPOINTS) {
|
|
346
|
+
if (!e.typed)
|
|
347
|
+
continue;
|
|
348
|
+
const fn = (params, opts) => this.invoke(e, params, opts);
|
|
349
|
+
if (e.paginated)
|
|
350
|
+
fn.iter = (params, opts) => this.paginate(e, params, opts);
|
|
351
|
+
self[NAMESPACES[e.category]][e.fn] = fn;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
// --- Low level ---------------------------------------------------------------------------------------------
|
|
355
|
+
/** Raw request against the API. Returns the parsed JSON body and throws a CernisDataError subclass on any non 2xx answer. */
|
|
356
|
+
async request(method, path, o = {}) {
|
|
357
|
+
return (await this.send(method, path, o)).body;
|
|
358
|
+
}
|
|
359
|
+
/** Call an endpoint by id with its input, e.g. `call('company.enrich', { domain: 'stripe.com' })`. Returns the envelope as sent (no waiting). */
|
|
360
|
+
call(id, input = {}, o = {}) {
|
|
361
|
+
const e = findEndpoint(id);
|
|
362
|
+
if (!e)
|
|
363
|
+
return Promise.reject(new NotFoundError(404, { error: { code: 'not_found', message: `Unknown endpoint ${id}` } }));
|
|
364
|
+
return o.wait ? this.invoke(e, input, o) : this.callEndpoint(e, input, o);
|
|
365
|
+
}
|
|
366
|
+
callEndpoint(e, params, o = {}) {
|
|
367
|
+
const input = prepareInput(e, params);
|
|
368
|
+
return e.method === 'GET'
|
|
369
|
+
? this.request('GET', e.path, { ...o, query: input })
|
|
370
|
+
: this.request('POST', e.path, { ...o, body: input, idempotent: true });
|
|
371
|
+
}
|
|
372
|
+
async invoke(e, params, o = {}) {
|
|
373
|
+
const res = await this.callEndpoint(e, params, o);
|
|
374
|
+
if (e.mode === 'job')
|
|
375
|
+
return new Job(this, res);
|
|
376
|
+
if (e.mode === 'async' && o.wait !== false && res?.status === 'pending' && res.job_id)
|
|
377
|
+
return this.waitForRequest(res.job_id, o);
|
|
378
|
+
return res;
|
|
379
|
+
}
|
|
380
|
+
async *paginate(e, params, o = {}) {
|
|
381
|
+
const input = prepareInput(e, params);
|
|
382
|
+
let cursor = input.cursor;
|
|
383
|
+
let count = 0;
|
|
384
|
+
let pages = 0;
|
|
385
|
+
for (;;) {
|
|
386
|
+
const page = await this.callEndpoint(e, cursor ? { ...input, cursor } : input, o);
|
|
387
|
+
const items = Array.isArray(page.data) ? page.data : Array.isArray(page.data?.results) ? page.data.results : [];
|
|
388
|
+
for (const it of items) {
|
|
389
|
+
yield it;
|
|
390
|
+
if (o.maxItems && ++count >= o.maxItems)
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
pages++;
|
|
394
|
+
cursor = page.meta?.next_cursor ?? undefined;
|
|
395
|
+
if (!cursor || !items.length || (o.maxPages && pages >= o.maxPages))
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
/** Repeat `check` with growing intervals until it returns a value. Throws TimeoutError after waitTimeoutMs. */
|
|
400
|
+
async poll(check, o = {}) {
|
|
401
|
+
const until = Date.now() + (o.waitTimeoutMs ?? this.waitTimeoutMs);
|
|
402
|
+
let interval = o.pollIntervalMs ?? this.pollIntervalMs;
|
|
403
|
+
for (;;) {
|
|
404
|
+
const r = await check();
|
|
405
|
+
if (r !== null)
|
|
406
|
+
return r;
|
|
407
|
+
if (Date.now() + interval > until) {
|
|
408
|
+
throw new TimeoutError(0, { error: { code: 'wait_timeout', message: `${o.what ?? 'Request'} is still running. Poll it again later.` } });
|
|
409
|
+
}
|
|
410
|
+
await sleep(interval, o.signal);
|
|
411
|
+
interval = Math.min(5_000, interval * 1.5);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
waitForRequest(id, o = {}) {
|
|
415
|
+
return this.poll(async () => {
|
|
416
|
+
const r = await this.send('GET', `/v1/jobs/${encodeURIComponent(id)}`, { signal: o.signal, maxRetries: o.maxRetries });
|
|
417
|
+
return r.status === 202 || PENDING.has(r.body?.status) ? null : r.body;
|
|
418
|
+
}, { ...o, what: `Request ${id}` });
|
|
419
|
+
}
|
|
420
|
+
async send(method, path, o) {
|
|
421
|
+
if (!this.baseUrl) {
|
|
422
|
+
throw new CernisDataError(0, { error: { code: 'missing_base_url', message: 'No API base URL. Pass `baseUrl` to new CernisData({ baseUrl }) or set CERNIS_DATA_BASE_URL.' } });
|
|
423
|
+
}
|
|
424
|
+
const url = new URL(this.baseUrl + path);
|
|
425
|
+
for (const [k, v] of Object.entries(o.query ?? {})) {
|
|
426
|
+
if (v === undefined || v === null)
|
|
427
|
+
continue;
|
|
428
|
+
if (isPlainObject(v)) {
|
|
429
|
+
for (const [kk, vv] of Object.entries(v))
|
|
430
|
+
if (vv != null)
|
|
431
|
+
url.searchParams.set(`${k}[${kk}]`, String(vv));
|
|
432
|
+
}
|
|
433
|
+
else
|
|
434
|
+
url.searchParams.set(k, Array.isArray(v) ? v.join(',') : String(v));
|
|
435
|
+
}
|
|
436
|
+
const headers = { accept: 'application/json', 'x-cernisdata-surface': this.surface, ...this.extraHeaders, ...o.headers };
|
|
437
|
+
if (this.apiKey)
|
|
438
|
+
headers.authorization = `Bearer ${this.apiKey}`;
|
|
439
|
+
if (o.body !== undefined)
|
|
440
|
+
headers['content-type'] = 'application/json';
|
|
441
|
+
if (o.timeoutMs)
|
|
442
|
+
headers['x-timeout-ms'] = String(Math.min(120_000, Math.max(1_000, Math.round(o.timeoutMs))));
|
|
443
|
+
// POSTs to endpoints carry an Idempotency-Key, so a retry never charges twice. Other POSTs (keys, checkout) are
|
|
444
|
+
// only retried when the API refused them before doing anything (429).
|
|
445
|
+
const idempotent = method !== 'POST' || !!(o.idempotent ?? endpointByPath('POST', path));
|
|
446
|
+
const userKey = o.idempotencyKey ?? headers['idempotency-key'];
|
|
447
|
+
let key = method === 'POST' && idempotent ? userKey ?? `idk_${randomId()}` : undefined;
|
|
448
|
+
const maxRetries = o.maxRetries ?? this.maxRetries;
|
|
449
|
+
const payload = o.body === undefined ? undefined : JSON.stringify(o.body);
|
|
450
|
+
for (let attempt = 0;; attempt++) {
|
|
451
|
+
if (key)
|
|
452
|
+
headers['idempotency-key'] = key;
|
|
453
|
+
let res;
|
|
454
|
+
const ctl = new AbortController();
|
|
455
|
+
const onAbort = () => ctl.abort(o.signal.reason);
|
|
456
|
+
o.signal?.addEventListener('abort', onAbort, { once: true });
|
|
457
|
+
const timer = setTimeout(() => ctl.abort('timeout'), o.timeoutMs ?? this.timeoutMs);
|
|
458
|
+
let text;
|
|
459
|
+
try {
|
|
460
|
+
res = await this.fetcher(url.toString(), { method, headers, body: payload, signal: ctl.signal });
|
|
461
|
+
text = await res.text();
|
|
462
|
+
}
|
|
463
|
+
catch (e) {
|
|
464
|
+
if (o.signal?.aborted)
|
|
465
|
+
throw o.signal.reason ?? e;
|
|
466
|
+
const timedOut = ctl.signal.aborted;
|
|
467
|
+
const err = timedOut
|
|
468
|
+
? new TimeoutError(0, { error: { code: 'timeout', message: `No answer within ${o.timeoutMs ?? this.timeoutMs} ms.` } })
|
|
469
|
+
: new APIConnectionError(0, { error: { code: 'connection_error', message: `Could not reach the API: ${e?.message ?? e}` } });
|
|
470
|
+
// The request may have reached the server, so retry only with the same Idempotency-Key (or for GETs).
|
|
471
|
+
if (attempt >= maxRetries || !idempotent)
|
|
472
|
+
throw err;
|
|
473
|
+
await sleep(backoff(attempt), o.signal);
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
finally {
|
|
477
|
+
clearTimeout(timer);
|
|
478
|
+
o.signal?.removeEventListener('abort', onAbort);
|
|
479
|
+
}
|
|
480
|
+
let body = null;
|
|
481
|
+
try {
|
|
482
|
+
body = text ? JSON.parse(text) : null;
|
|
483
|
+
}
|
|
484
|
+
catch {
|
|
485
|
+
body = res.ok ? text : { error: { code: 'bad_response', message: text.slice(0, 200) } };
|
|
486
|
+
}
|
|
487
|
+
if (res.ok)
|
|
488
|
+
return { status: res.status, body, headers: res.headers };
|
|
489
|
+
const err = errorFromResponse(res.status, body, res.headers);
|
|
490
|
+
const answered = typeof body?.error?.code === 'string';
|
|
491
|
+
const retryable = res.status === 429 || (res.status >= 500 && res.status !== 501 && err.code !== 'deadline_exceeded');
|
|
492
|
+
if (!retryable || attempt >= maxRetries || (!idempotent && res.status !== 429))
|
|
493
|
+
throw err;
|
|
494
|
+
if (res.status >= 500 && answered && method === 'POST') {
|
|
495
|
+
// The API recorded this attempt as failed (not charged). The same key would now be refused, so a retry
|
|
496
|
+
// needs a fresh one. A key you chose is never swapped: that error is yours to handle.
|
|
497
|
+
if (userKey)
|
|
498
|
+
throw err;
|
|
499
|
+
key = `idk_${randomId()}`;
|
|
500
|
+
}
|
|
501
|
+
const after = retryAfterSeconds(res.headers);
|
|
502
|
+
if (after !== null && after * 1000 > MAX_RETRY_AFTER_MS)
|
|
503
|
+
throw err;
|
|
504
|
+
await sleep(after !== null ? after * 1000 : backoff(attempt), o.signal);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
// --- Account ------------------------------------------------------------------------------------------------
|
|
508
|
+
/** Every endpoint with its price and status. No key needed. */
|
|
509
|
+
catalog() { return this.request('GET', '/v1/catalog'); }
|
|
510
|
+
/** Balance and the free allowance (`free_requests: { limit, used, remaining }`). */
|
|
511
|
+
wallet() { return this.request('GET', '/v1/wallet'); }
|
|
512
|
+
/** Requests and spend per endpoint per day. */
|
|
513
|
+
usage(o = {}) {
|
|
514
|
+
return this.request('GET', '/v1/usage', { query: o });
|
|
515
|
+
}
|
|
516
|
+
/** Raw status of a job or pending request. `after` pages through job items. */
|
|
517
|
+
job(id, after) { return this.request('GET', `/v1/jobs/${encodeURIComponent(id)}`, { query: { after } }); }
|
|
518
|
+
/** Poll a job or pending request until it is no longer pending and return its last raw response. */
|
|
519
|
+
wait(id, o = {}) {
|
|
520
|
+
return this.poll(async () => {
|
|
521
|
+
const r = await this.send('GET', `/v1/jobs/${encodeURIComponent(id)}`, { signal: o.signal });
|
|
522
|
+
return r.status === 202 || PENDING.has(r.body?.status) ? null : r.body;
|
|
523
|
+
}, { ...o, waitTimeoutMs: o.waitTimeoutMs ?? o.timeoutMs, what: `Job ${id}` });
|
|
524
|
+
}
|
|
525
|
+
requests = {
|
|
526
|
+
/** Recent requests, newest first. Pass `before: next_before` for the next page. */
|
|
527
|
+
list: (o = {}) => this.request('GET', '/v1/requests', { query: o }),
|
|
528
|
+
/** Every request, newest first, across pages. */
|
|
529
|
+
iter: (o = {}) => this.iterRequests(o),
|
|
530
|
+
/** The stored answer of a request (async requests: the envelope once ready). */
|
|
531
|
+
retrieve: (id) => this.job(id),
|
|
532
|
+
/** Wait for a pending async request and return its envelope. Throws its error if it failed. */
|
|
533
|
+
wait: (id, o = {}) => this.waitForRequest(id, o),
|
|
534
|
+
};
|
|
535
|
+
async *iterRequests(o) {
|
|
536
|
+
let before;
|
|
537
|
+
let n = 0;
|
|
538
|
+
for (;;) {
|
|
539
|
+
const page = await this.requests.list({ limit: o.limit, before });
|
|
540
|
+
for (const r of page.requests) {
|
|
541
|
+
yield r;
|
|
542
|
+
if (o.maxItems && ++n >= o.maxItems)
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
if (page.next_before === null)
|
|
546
|
+
return;
|
|
547
|
+
before = page.next_before;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
jobs = {
|
|
551
|
+
/** A bulk job by id, as a Job you can wait on and read results from. */
|
|
552
|
+
retrieve: async (id) => new Job(this, await this.job(id)),
|
|
553
|
+
};
|
|
554
|
+
keys = {
|
|
555
|
+
list: () => this.request('GET', '/v1/keys'),
|
|
556
|
+
/** Create a key. Scopes: '*' or categories ('people', 'company', 'contact', 'signals', 'web'). The key is shown once. */
|
|
557
|
+
create: (o = {}) => this.request('POST', '/v1/keys', { body: o }),
|
|
558
|
+
revoke: (id) => this.request('DELETE', `/v1/keys/${encodeURIComponent(id)}`),
|
|
559
|
+
};
|
|
560
|
+
billing = {
|
|
561
|
+
/** A checkout link to add credits. */
|
|
562
|
+
checkout: (o) => this.request('POST', '/v1/billing/checkout', { body: { amount_usd: o.amountUsd } }),
|
|
563
|
+
};
|
|
564
|
+
webhooks = {
|
|
565
|
+
/** The signing secret for job webhooks. Needs a full-access key. */
|
|
566
|
+
secret: () => this.request('GET', '/v1/webhooks/secret'),
|
|
567
|
+
rotateSecret: () => this.request('POST', '/v1/webhooks/secret/rotate'),
|
|
568
|
+
deliveries: () => this.request('GET', '/v1/webhooks/deliveries'),
|
|
569
|
+
/** Same as the exported verifyWebhook. */
|
|
570
|
+
verify: verifyWebhook,
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
function backoff(attempt) {
|
|
574
|
+
const base = Math.min(8_000, 500 * 2 ** attempt);
|
|
575
|
+
return base / 2 + Math.random() * (base / 2);
|
|
576
|
+
}
|
|
577
|
+
export default CernisData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cernisdata/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for the Cernis Data API: people, company, contact, signal and web data behind one key",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/cjs/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/cjs/index.d.ts",
|
|
16
|
+
"default": "./dist/cjs/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"keywords": [
|
|
27
|
+
"gtm",
|
|
28
|
+
"enrichment",
|
|
29
|
+
"b2b data",
|
|
30
|
+
"api",
|
|
31
|
+
"sdk"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
35
|
+
},
|
|
36
|
+
"module": "./dist/index.js",
|
|
37
|
+
"scripts": {
|
|
38
|
+
"postpack": "node build.mjs --postpack"
|
|
39
|
+
}
|
|
40
|
+
}
|