@pipe0/client 0.0.38 → 0.0.40
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/CHANGELOG.md +13 -0
- package/dist/generated/openapi.types.d.mts +895 -618
- package/dist/generated/openapi.types.d.mts.map +1 -1
- package/dist/pipe0.d.mts +27 -44
- package/dist/pipe0.d.mts.map +1 -1
- package/dist/pipe0.mjs +2 -2
- package/dist/pipe0.mjs.map +1 -1
- package/package.json +1 -1
package/dist/pipe0.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { paths } from "./generated/openapi.types.mjs";
|
|
1
|
+
import { components, paths } from "./generated/openapi.types.mjs";
|
|
2
2
|
import { Client } from "openapi-fetch";
|
|
3
3
|
|
|
4
4
|
//#region src/pipe0.d.ts
|
|
@@ -120,7 +120,7 @@ declare class Pipe0 {
|
|
|
120
120
|
type: "string" | "number" | "boolean" | "json" | "unknown";
|
|
121
121
|
label: string;
|
|
122
122
|
added_by: {
|
|
123
|
-
ref: ("prompt:run@1" | "company:newssummary:website@1" | "company:newssummary:domain@1" | "company:techstack:builtwith@1" | "company:techstack:builtwith@2" | "company:websiteurl:email@1" | "company:domain:workemail@1" | "company:funding:leadmagic@1" | "company:funding:leadmagic@2" | "people:workemail:waterfall@1" | "person:workemail:waterfall@1" | "people:email:iswork@1" | "email:iswork@1" | "people:name:split@1" | "person:name:split@1" | "person:name:join@1" | "people:validate:email:zerobounce@1" | "people:email:validate:zerobounce@2" | "email:validate:zerobounce@1" | "people:mobilenumber:workemail:waterfall@1" | "company:overview@1" | "company:overview@2" | "company:overview@3" | "json:extract:multi@1" | "email:write@1" | "message:write@1" | "email:send:resend@1" | "email:send:gmail@1" | "message:send:slack@1" | "template:fill@1" | "contact:create:resend@1" | "people:match:role:waterfall@1" | "person:match:role:waterfall@1" | "person:identity:amplemarket@1" | "company:identity@2" | "company:identity@3" | "person:match:amplemarket@1" | "people:phone:profile:waterfall@1" | "person:mobile:profileurl:waterfall@1" | "people:personalemail:profile:waterfall@1" | "person:personalemail:profileurl:waterfall@1" | "people:profile:waterfall@1" | "person:profile:waterfall@1" | "people:profileurl:email:waterfall@1" | "person:profileurl:email:waterfall@1" | "person:profileurl:name@1" | "people:email:validate:zerobounce@1" | "person:email:validate:millionverifier@1" | "people:phone:workemail:waterfall@1" | "person:mobile:workemail:waterfall@1" | "fields:merge@1" | "field:slugify@1" | "field:domainify@1" | "website:scrape:firecrawl@1" | "website:scrapelist:firecrawl@1" | "website:extract:firecrawl@1" | "website:maplinks:firecrawl@1" | "sheet:row:append@1" | "sheet:row:expandappend@1" | "company:lookalikes:companyenrich@1" | "company:lookalikes:companyenrich@2" | "company:match:logodev@1" | "company:match:logodev@2" | "person:posts:crustdata@1" | "company:match:crustdata@1" | "company:match:crustdata@2" | "people:profile:workemail:crustdata@1" | "person:profile:workemail:crustdata@1" | "people:workemail:profileurl:waterfall@1" | "person:workemail:profileurl:waterfall@1" | "people:identity:email:waterfall@1" | "person:identity:email:waterfall@1" | "http:request@1" | "company:identity@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:mobilenumber:professionalprofile:waterfall@1") | "input";
|
|
123
|
+
ref: ("prompt:run@1" | "company:newssummary:website@1" | "company:newssummary:domain@1" | "company:techstack:builtwith@1" | "company:techstack:builtwith@2" | "company:websiteurl:email@1" | "company:domain:workemail@1" | "company:funding:leadmagic@1" | "company:funding:leadmagic@2" | "people:workemail:waterfall@1" | "person:workemail:waterfall@1" | "people:email:iswork@1" | "email:iswork@1" | "people:name:split@1" | "person:name:split@1" | "person:name:join@1" | "people:validate:email:zerobounce@1" | "people:email:validate:zerobounce@2" | "email:validate:zerobounce@1" | "people:mobilenumber:workemail:waterfall@1" | "company:overview@1" | "company:overview@2" | "company:overview@3" | "json:extract:multi@1" | "email:write@1" | "message:write@1" | "email:send:resend@1" | "email:send:gmail@1" | "message:send:slack@1" | "template:fill@1" | "contact:create:resend@1" | "people:match:role:waterfall@1" | "person:match:role:waterfall@1" | "person:identity:amplemarket@1" | "company:identity@2" | "company:identity@3" | "person:match:amplemarket@1" | "people:phone:profile:waterfall@1" | "person:mobile:profileurl:waterfall@1" | "people:personalemail:profile:waterfall@1" | "person:personalemail:profileurl:waterfall@1" | "people:profile:waterfall@1" | "person:profile:waterfall@1" | "people:profileurl:email:waterfall@1" | "person:profileurl:email:waterfall@1" | "person:profileurl:name@1" | "people:email:validate:zerobounce@1" | "person:email:validate:millionverifier@1" | "people:phone:workemail:waterfall@1" | "person:mobile:workemail:waterfall@1" | "fields:merge@1" | "field:slugify@1" | "field:domainify@1" | "website:scrape:firecrawl@1" | "website:scrapelist:firecrawl@1" | "website:extract:firecrawl@1" | "website:maplinks:firecrawl@1" | "sheet:row:append@1" | "sheet:row:expandappend@1" | "company:lookalikes:companyenrich@1" | "company:lookalikes:companyenrich@2" | "company:match:logodev@1" | "company:match:logodev@2" | "person:posts:crustdata@1" | "company:match:crustdata@1" | "company:match:crustdata@2" | "people:profile:workemail:crustdata@1" | "person:profile:workemail:crustdata@1" | "people:workemail:profileurl:waterfall@1" | "person:workemail:profileurl:waterfall@1" | "people:identity:email:waterfall@1" | "person:identity:email:waterfall@1" | "person:devprofileurl:profileurl:waterfall@1" | "http:request@1" | "company:identity@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:mobilenumber:professionalprofile:waterfall@1") | "input";
|
|
124
124
|
config_hash: string | null;
|
|
125
125
|
pipe_index: number | null;
|
|
126
126
|
};
|
|
@@ -149,11 +149,11 @@ declare class Pipe0 {
|
|
|
149
149
|
message: string;
|
|
150
150
|
} | null;
|
|
151
151
|
claimed_by: {
|
|
152
|
-
ref: "prompt:run@1" | "company:newssummary:website@1" | "company:newssummary:domain@1" | "company:techstack:builtwith@1" | "company:techstack:builtwith@2" | "company:websiteurl:email@1" | "company:domain:workemail@1" | "company:funding:leadmagic@1" | "company:funding:leadmagic@2" | "people:workemail:waterfall@1" | "person:workemail:waterfall@1" | "people:email:iswork@1" | "email:iswork@1" | "people:name:split@1" | "person:name:split@1" | "person:name:join@1" | "people:validate:email:zerobounce@1" | "people:email:validate:zerobounce@2" | "email:validate:zerobounce@1" | "people:mobilenumber:workemail:waterfall@1" | "company:overview@1" | "company:overview@2" | "company:overview@3" | "json:extract:multi@1" | "email:write@1" | "message:write@1" | "email:send:resend@1" | "email:send:gmail@1" | "message:send:slack@1" | "template:fill@1" | "contact:create:resend@1" | "people:match:role:waterfall@1" | "person:match:role:waterfall@1" | "person:identity:amplemarket@1" | "company:identity@2" | "company:identity@3" | "person:match:amplemarket@1" | "people:phone:profile:waterfall@1" | "person:mobile:profileurl:waterfall@1" | "people:personalemail:profile:waterfall@1" | "person:personalemail:profileurl:waterfall@1" | "people:profile:waterfall@1" | "person:profile:waterfall@1" | "people:profileurl:email:waterfall@1" | "person:profileurl:email:waterfall@1" | "person:profileurl:name@1" | "people:email:validate:zerobounce@1" | "person:email:validate:millionverifier@1" | "people:phone:workemail:waterfall@1" | "person:mobile:workemail:waterfall@1" | "fields:merge@1" | "field:slugify@1" | "field:domainify@1" | "website:scrape:firecrawl@1" | "website:scrapelist:firecrawl@1" | "website:extract:firecrawl@1" | "website:maplinks:firecrawl@1" | "sheet:row:append@1" | "sheet:row:expandappend@1" | "company:lookalikes:companyenrich@1" | "company:lookalikes:companyenrich@2" | "company:match:logodev@1" | "company:match:logodev@2" | "person:posts:crustdata@1" | "company:match:crustdata@1" | "company:match:crustdata@2" | "people:profile:workemail:crustdata@1" | "person:profile:workemail:crustdata@1" | "people:workemail:profileurl:waterfall@1" | "person:workemail:profileurl:waterfall@1" | "people:identity:email:waterfall@1" | "person:identity:email:waterfall@1" | "http:request@1" | "company:identity@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "input" | null;
|
|
152
|
+
ref: "prompt:run@1" | "company:newssummary:website@1" | "company:newssummary:domain@1" | "company:techstack:builtwith@1" | "company:techstack:builtwith@2" | "company:websiteurl:email@1" | "company:domain:workemail@1" | "company:funding:leadmagic@1" | "company:funding:leadmagic@2" | "people:workemail:waterfall@1" | "person:workemail:waterfall@1" | "people:email:iswork@1" | "email:iswork@1" | "people:name:split@1" | "person:name:split@1" | "person:name:join@1" | "people:validate:email:zerobounce@1" | "people:email:validate:zerobounce@2" | "email:validate:zerobounce@1" | "people:mobilenumber:workemail:waterfall@1" | "company:overview@1" | "company:overview@2" | "company:overview@3" | "json:extract:multi@1" | "email:write@1" | "message:write@1" | "email:send:resend@1" | "email:send:gmail@1" | "message:send:slack@1" | "template:fill@1" | "contact:create:resend@1" | "people:match:role:waterfall@1" | "person:match:role:waterfall@1" | "person:identity:amplemarket@1" | "company:identity@2" | "company:identity@3" | "person:match:amplemarket@1" | "people:phone:profile:waterfall@1" | "person:mobile:profileurl:waterfall@1" | "people:personalemail:profile:waterfall@1" | "person:personalemail:profileurl:waterfall@1" | "people:profile:waterfall@1" | "person:profile:waterfall@1" | "people:profileurl:email:waterfall@1" | "person:profileurl:email:waterfall@1" | "person:profileurl:name@1" | "people:email:validate:zerobounce@1" | "person:email:validate:millionverifier@1" | "people:phone:workemail:waterfall@1" | "person:mobile:workemail:waterfall@1" | "fields:merge@1" | "field:slugify@1" | "field:domainify@1" | "website:scrape:firecrawl@1" | "website:scrapelist:firecrawl@1" | "website:extract:firecrawl@1" | "website:maplinks:firecrawl@1" | "sheet:row:append@1" | "sheet:row:expandappend@1" | "company:lookalikes:companyenrich@1" | "company:lookalikes:companyenrich@2" | "company:match:logodev@1" | "company:match:logodev@2" | "person:posts:crustdata@1" | "company:match:crustdata@1" | "company:match:crustdata@2" | "people:profile:workemail:crustdata@1" | "person:profile:workemail:crustdata@1" | "people:workemail:profileurl:waterfall@1" | "person:workemail:profileurl:waterfall@1" | "people:identity:email:waterfall@1" | "person:identity:email:waterfall@1" | "person:devprofileurl:profileurl:waterfall@1" | "http:request@1" | "company:identity@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "input" | null;
|
|
153
153
|
config_hash: string | null;
|
|
154
154
|
};
|
|
155
155
|
resolved_by: {
|
|
156
|
-
ref: "prompt:run@1" | "company:newssummary:website@1" | "company:newssummary:domain@1" | "company:techstack:builtwith@1" | "company:techstack:builtwith@2" | "company:websiteurl:email@1" | "company:domain:workemail@1" | "company:funding:leadmagic@1" | "company:funding:leadmagic@2" | "people:workemail:waterfall@1" | "person:workemail:waterfall@1" | "people:email:iswork@1" | "email:iswork@1" | "people:name:split@1" | "person:name:split@1" | "person:name:join@1" | "people:validate:email:zerobounce@1" | "people:email:validate:zerobounce@2" | "email:validate:zerobounce@1" | "people:mobilenumber:workemail:waterfall@1" | "company:overview@1" | "company:overview@2" | "company:overview@3" | "json:extract:multi@1" | "email:write@1" | "message:write@1" | "email:send:resend@1" | "email:send:gmail@1" | "message:send:slack@1" | "template:fill@1" | "contact:create:resend@1" | "people:match:role:waterfall@1" | "person:match:role:waterfall@1" | "person:identity:amplemarket@1" | "company:identity@2" | "company:identity@3" | "person:match:amplemarket@1" | "people:phone:profile:waterfall@1" | "person:mobile:profileurl:waterfall@1" | "people:personalemail:profile:waterfall@1" | "person:personalemail:profileurl:waterfall@1" | "people:profile:waterfall@1" | "person:profile:waterfall@1" | "people:profileurl:email:waterfall@1" | "person:profileurl:email:waterfall@1" | "person:profileurl:name@1" | "people:email:validate:zerobounce@1" | "person:email:validate:millionverifier@1" | "people:phone:workemail:waterfall@1" | "person:mobile:workemail:waterfall@1" | "fields:merge@1" | "field:slugify@1" | "field:domainify@1" | "website:scrape:firecrawl@1" | "website:scrapelist:firecrawl@1" | "website:extract:firecrawl@1" | "website:maplinks:firecrawl@1" | "sheet:row:append@1" | "sheet:row:expandappend@1" | "company:lookalikes:companyenrich@1" | "company:lookalikes:companyenrich@2" | "company:match:logodev@1" | "company:match:logodev@2" | "person:posts:crustdata@1" | "company:match:crustdata@1" | "company:match:crustdata@2" | "people:profile:workemail:crustdata@1" | "person:profile:workemail:crustdata@1" | "people:workemail:profileurl:waterfall@1" | "person:workemail:profileurl:waterfall@1" | "people:identity:email:waterfall@1" | "person:identity:email:waterfall@1" | "http:request@1" | "company:identity@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "input" | "system" | null;
|
|
156
|
+
ref: "prompt:run@1" | "company:newssummary:website@1" | "company:newssummary:domain@1" | "company:techstack:builtwith@1" | "company:techstack:builtwith@2" | "company:websiteurl:email@1" | "company:domain:workemail@1" | "company:funding:leadmagic@1" | "company:funding:leadmagic@2" | "people:workemail:waterfall@1" | "person:workemail:waterfall@1" | "people:email:iswork@1" | "email:iswork@1" | "people:name:split@1" | "person:name:split@1" | "person:name:join@1" | "people:validate:email:zerobounce@1" | "people:email:validate:zerobounce@2" | "email:validate:zerobounce@1" | "people:mobilenumber:workemail:waterfall@1" | "company:overview@1" | "company:overview@2" | "company:overview@3" | "json:extract:multi@1" | "email:write@1" | "message:write@1" | "email:send:resend@1" | "email:send:gmail@1" | "message:send:slack@1" | "template:fill@1" | "contact:create:resend@1" | "people:match:role:waterfall@1" | "person:match:role:waterfall@1" | "person:identity:amplemarket@1" | "company:identity@2" | "company:identity@3" | "person:match:amplemarket@1" | "people:phone:profile:waterfall@1" | "person:mobile:profileurl:waterfall@1" | "people:personalemail:profile:waterfall@1" | "person:personalemail:profileurl:waterfall@1" | "people:profile:waterfall@1" | "person:profile:waterfall@1" | "people:profileurl:email:waterfall@1" | "person:profileurl:email:waterfall@1" | "person:profileurl:name@1" | "people:email:validate:zerobounce@1" | "person:email:validate:millionverifier@1" | "people:phone:workemail:waterfall@1" | "person:mobile:workemail:waterfall@1" | "fields:merge@1" | "field:slugify@1" | "field:domainify@1" | "website:scrape:firecrawl@1" | "website:scrapelist:firecrawl@1" | "website:extract:firecrawl@1" | "website:maplinks:firecrawl@1" | "sheet:row:append@1" | "sheet:row:expandappend@1" | "company:lookalikes:companyenrich@1" | "company:lookalikes:companyenrich@2" | "company:match:logodev@1" | "company:match:logodev@2" | "person:posts:crustdata@1" | "company:match:crustdata@1" | "company:match:crustdata@2" | "people:profile:workemail:crustdata@1" | "person:profile:workemail:crustdata@1" | "people:workemail:profileurl:waterfall@1" | "person:workemail:profileurl:waterfall@1" | "people:identity:email:waterfall@1" | "person:identity:email:waterfall@1" | "person:devprofileurl:profileurl:waterfall@1" | "http:request@1" | "company:identity@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "input" | "system" | null;
|
|
157
157
|
environment: "production" | "sandbox" | null;
|
|
158
158
|
config_hash: string | null;
|
|
159
159
|
input_hash: string | null;
|
|
@@ -175,10 +175,10 @@ declare class Pipe0 {
|
|
|
175
175
|
};
|
|
176
176
|
waterfall?: {
|
|
177
177
|
attempted_providers: {
|
|
178
|
-
provider: "pipe0" | "findymail" | "crustdata" | "hunter" | "zerobounce" | "millionverifier" | "googlemaps" | "gemini" | "leadmagic" | "mixrank" | "builtwith" | "perplexity" | "serper" | "icypeas" | "prospeo" | "clado" | "resend" | "slack" | "gmail" | "firecrawl" | "exa" | "openai" | "companyenrich" | "logodev" | "amplemarket";
|
|
178
|
+
provider: "pipe0" | "findymail" | "crustdata" | "hunter" | "zerobounce" | "millionverifier" | "googlemaps" | "gemini" | "leadmagic" | "mixrank" | "builtwith" | "perplexity" | "serper" | "icypeas" | "prospeo" | "clado" | "resend" | "slack" | "gmail" | "firecrawl" | "exa" | "openai" | "companyenrich" | "logodev" | "amplemarket" | "parallel";
|
|
179
179
|
}[];
|
|
180
|
-
available_providers: ("pipe0" | "findymail" | "crustdata" | "hunter" | "zerobounce" | "millionverifier" | "googlemaps" | "gemini" | "leadmagic" | "mixrank" | "builtwith" | "perplexity" | "serper" | "icypeas" | "prospeo" | "clado" | "resend" | "slack" | "gmail" | "firecrawl" | "exa" | "openai" | "companyenrich" | "logodev" | "amplemarket")[];
|
|
181
|
-
successful_provider?: "pipe0" | "findymail" | "crustdata" | "hunter" | "zerobounce" | "millionverifier" | "googlemaps" | "gemini" | "leadmagic" | "mixrank" | "builtwith" | "perplexity" | "serper" | "icypeas" | "prospeo" | "clado" | "resend" | "slack" | "gmail" | "firecrawl" | "exa" | "openai" | "companyenrich" | "logodev" | "amplemarket";
|
|
180
|
+
available_providers: ("pipe0" | "findymail" | "crustdata" | "hunter" | "zerobounce" | "millionverifier" | "googlemaps" | "gemini" | "leadmagic" | "mixrank" | "builtwith" | "perplexity" | "serper" | "icypeas" | "prospeo" | "clado" | "resend" | "slack" | "gmail" | "firecrawl" | "exa" | "openai" | "companyenrich" | "logodev" | "amplemarket" | "parallel")[];
|
|
181
|
+
successful_provider?: "pipe0" | "findymail" | "crustdata" | "hunter" | "zerobounce" | "millionverifier" | "googlemaps" | "gemini" | "leadmagic" | "mixrank" | "builtwith" | "perplexity" | "serper" | "icypeas" | "prospeo" | "clado" | "resend" | "slack" | "gmail" | "firecrawl" | "exa" | "openai" | "companyenrich" | "logodev" | "amplemarket" | "parallel";
|
|
182
182
|
};
|
|
183
183
|
icon?: {
|
|
184
184
|
key: "linkedin" | "job";
|
|
@@ -229,21 +229,27 @@ declare class Pipe0 {
|
|
|
229
229
|
/**
|
|
230
230
|
* Create and immediately wait for completion (convenience method)
|
|
231
231
|
*/
|
|
232
|
-
search: (payload:
|
|
233
|
-
onPoll?: (_response:
|
|
232
|
+
search: (payload: SearchRequest, options?: {
|
|
233
|
+
onPoll?: (_response: SearchResponse) => unknown;
|
|
234
234
|
signal?: AbortSignal;
|
|
235
|
-
}) => Promise<
|
|
235
|
+
}) => Promise<SearchResponse>;
|
|
236
236
|
/**
|
|
237
237
|
* Create a searches task but don't wait for it.
|
|
238
238
|
* Use this if you want fire and forget.
|
|
239
239
|
*/
|
|
240
|
-
create: (payload:
|
|
240
|
+
create: (payload: SearchRequest) => Promise<string>;
|
|
241
241
|
/**
|
|
242
242
|
* Check the status of a search task manually.
|
|
243
243
|
*/
|
|
244
244
|
check: (runId: string) => Promise<{
|
|
245
245
|
id: string;
|
|
246
246
|
status: "completed" | "failed" | "pending" | "processing";
|
|
247
|
+
search_id: "companies:profiles:crustdata@1" | "companies:profiles:crustdata@2" | "companies:profiles:amplemarket@1" | "companies:profiles:amplemarket@2" | "people:profiles:crustdata@1" | "people:profiles:crustdata@2" | "people:profiles:amplemarket@1" | "people:profiles:amplemarket@2";
|
|
248
|
+
errors: {
|
|
249
|
+
code: string;
|
|
250
|
+
message: string;
|
|
251
|
+
path?: string;
|
|
252
|
+
}[];
|
|
247
253
|
results: {
|
|
248
254
|
[key: string]: {
|
|
249
255
|
value: string | number | boolean | null | {
|
|
@@ -253,7 +259,7 @@ declare class Pipe0 {
|
|
|
253
259
|
type?: "string" | "number" | "boolean" | "json" | "unknown";
|
|
254
260
|
format?: "json_object" | "json_list" | "json_list_string" | "url" | "website_url" | "profile_url" | "email" | "datetime" | "currency" | "date" | "phone" | "markdown" | "text" | "int" | "decimal" | "address_line_1" | "zip_code" | "percent" | null;
|
|
255
261
|
resolved_by?: {
|
|
256
|
-
ref: "prompt:run@1" | "company:newssummary:website@1" | "company:newssummary:domain@1" | "company:techstack:builtwith@1" | "company:techstack:builtwith@2" | "company:websiteurl:email@1" | "company:domain:workemail@1" | "company:funding:leadmagic@1" | "company:funding:leadmagic@2" | "people:workemail:waterfall@1" | "person:workemail:waterfall@1" | "people:email:iswork@1" | "email:iswork@1" | "people:name:split@1" | "person:name:split@1" | "person:name:join@1" | "people:validate:email:zerobounce@1" | "people:email:validate:zerobounce@2" | "email:validate:zerobounce@1" | "people:mobilenumber:workemail:waterfall@1" | "company:overview@1" | "company:overview@2" | "company:overview@3" | "json:extract:multi@1" | "email:write@1" | "message:write@1" | "email:send:resend@1" | "email:send:gmail@1" | "message:send:slack@1" | "template:fill@1" | "contact:create:resend@1" | "people:match:role:waterfall@1" | "person:match:role:waterfall@1" | "person:identity:amplemarket@1" | "company:identity@2" | "company:identity@3" | "person:match:amplemarket@1" | "people:phone:profile:waterfall@1" | "person:mobile:profileurl:waterfall@1" | "people:personalemail:profile:waterfall@1" | "person:personalemail:profileurl:waterfall@1" | "people:profile:waterfall@1" | "person:profile:waterfall@1" | "people:profileurl:email:waterfall@1" | "person:profileurl:email:waterfall@1" | "person:profileurl:name@1" | "people:email:validate:zerobounce@1" | "person:email:validate:millionverifier@1" | "people:phone:workemail:waterfall@1" | "person:mobile:workemail:waterfall@1" | "fields:merge@1" | "field:slugify@1" | "field:domainify@1" | "website:scrape:firecrawl@1" | "website:scrapelist:firecrawl@1" | "website:extract:firecrawl@1" | "website:maplinks:firecrawl@1" | "sheet:row:append@1" | "sheet:row:expandappend@1" | "company:lookalikes:companyenrich@1" | "company:lookalikes:companyenrich@2" | "company:match:logodev@1" | "company:match:logodev@2" | "person:posts:crustdata@1" | "company:match:crustdata@1" | "company:match:crustdata@2" | "people:profile:workemail:crustdata@1" | "person:profile:workemail:crustdata@1" | "people:workemail:profileurl:waterfall@1" | "person:workemail:profileurl:waterfall@1" | "people:identity:email:waterfall@1" | "person:identity:email:waterfall@1" | "http:request@1" | "company:identity@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "input" | "system" | null;
|
|
262
|
+
ref: "prompt:run@1" | "company:newssummary:website@1" | "company:newssummary:domain@1" | "company:techstack:builtwith@1" | "company:techstack:builtwith@2" | "company:websiteurl:email@1" | "company:domain:workemail@1" | "company:funding:leadmagic@1" | "company:funding:leadmagic@2" | "people:workemail:waterfall@1" | "person:workemail:waterfall@1" | "people:email:iswork@1" | "email:iswork@1" | "people:name:split@1" | "person:name:split@1" | "person:name:join@1" | "people:validate:email:zerobounce@1" | "people:email:validate:zerobounce@2" | "email:validate:zerobounce@1" | "people:mobilenumber:workemail:waterfall@1" | "company:overview@1" | "company:overview@2" | "company:overview@3" | "json:extract:multi@1" | "email:write@1" | "message:write@1" | "email:send:resend@1" | "email:send:gmail@1" | "message:send:slack@1" | "template:fill@1" | "contact:create:resend@1" | "people:match:role:waterfall@1" | "person:match:role:waterfall@1" | "person:identity:amplemarket@1" | "company:identity@2" | "company:identity@3" | "person:match:amplemarket@1" | "people:phone:profile:waterfall@1" | "person:mobile:profileurl:waterfall@1" | "people:personalemail:profile:waterfall@1" | "person:personalemail:profileurl:waterfall@1" | "people:profile:waterfall@1" | "person:profile:waterfall@1" | "people:profileurl:email:waterfall@1" | "person:profileurl:email:waterfall@1" | "person:profileurl:name@1" | "people:email:validate:zerobounce@1" | "person:email:validate:millionverifier@1" | "people:phone:workemail:waterfall@1" | "person:mobile:workemail:waterfall@1" | "fields:merge@1" | "field:slugify@1" | "field:domainify@1" | "website:scrape:firecrawl@1" | "website:scrapelist:firecrawl@1" | "website:extract:firecrawl@1" | "website:maplinks:firecrawl@1" | "sheet:row:append@1" | "sheet:row:expandappend@1" | "company:lookalikes:companyenrich@1" | "company:lookalikes:companyenrich@2" | "company:match:logodev@1" | "company:match:logodev@2" | "person:posts:crustdata@1" | "company:match:crustdata@1" | "company:match:crustdata@2" | "people:profile:workemail:crustdata@1" | "person:profile:workemail:crustdata@1" | "people:workemail:profileurl:waterfall@1" | "person:workemail:profileurl:waterfall@1" | "people:identity:email:waterfall@1" | "person:identity:email:waterfall@1" | "person:devprofileurl:profileurl:waterfall@1" | "http:request@1" | "company:identity@1" | "people:professionalprofile:waterfall@1" | "people:professionalprofileurl:name@1" | "people:professionalprofileurl:email:waterfall@1" | "people:mobilenumber:professionalprofile:waterfall@1" | "input" | "system" | null;
|
|
257
263
|
environment: "production" | "sandbox" | null;
|
|
258
264
|
config_hash: string | null;
|
|
259
265
|
input_hash: string | null;
|
|
@@ -275,10 +281,10 @@ declare class Pipe0 {
|
|
|
275
281
|
};
|
|
276
282
|
waterfall?: {
|
|
277
283
|
attempted_providers: {
|
|
278
|
-
provider: "pipe0" | "findymail" | "crustdata" | "hunter" | "zerobounce" | "millionverifier" | "googlemaps" | "gemini" | "leadmagic" | "mixrank" | "builtwith" | "perplexity" | "serper" | "icypeas" | "prospeo" | "clado" | "resend" | "slack" | "gmail" | "firecrawl" | "exa" | "openai" | "companyenrich" | "logodev" | "amplemarket";
|
|
284
|
+
provider: "pipe0" | "findymail" | "crustdata" | "hunter" | "zerobounce" | "millionverifier" | "googlemaps" | "gemini" | "leadmagic" | "mixrank" | "builtwith" | "perplexity" | "serper" | "icypeas" | "prospeo" | "clado" | "resend" | "slack" | "gmail" | "firecrawl" | "exa" | "openai" | "companyenrich" | "logodev" | "amplemarket" | "parallel";
|
|
279
285
|
}[];
|
|
280
|
-
available_providers: ("pipe0" | "findymail" | "crustdata" | "hunter" | "zerobounce" | "millionverifier" | "googlemaps" | "gemini" | "leadmagic" | "mixrank" | "builtwith" | "perplexity" | "serper" | "icypeas" | "prospeo" | "clado" | "resend" | "slack" | "gmail" | "firecrawl" | "exa" | "openai" | "companyenrich" | "logodev" | "amplemarket")[];
|
|
281
|
-
successful_provider?: "pipe0" | "findymail" | "crustdata" | "hunter" | "zerobounce" | "millionverifier" | "googlemaps" | "gemini" | "leadmagic" | "mixrank" | "builtwith" | "perplexity" | "serper" | "icypeas" | "prospeo" | "clado" | "resend" | "slack" | "gmail" | "firecrawl" | "exa" | "openai" | "companyenrich" | "logodev" | "amplemarket";
|
|
286
|
+
available_providers: ("pipe0" | "findymail" | "crustdata" | "hunter" | "zerobounce" | "millionverifier" | "googlemaps" | "gemini" | "leadmagic" | "mixrank" | "builtwith" | "perplexity" | "serper" | "icypeas" | "prospeo" | "clado" | "resend" | "slack" | "gmail" | "firecrawl" | "exa" | "openai" | "companyenrich" | "logodev" | "amplemarket" | "parallel")[];
|
|
287
|
+
successful_provider?: "pipe0" | "findymail" | "crustdata" | "hunter" | "zerobounce" | "millionverifier" | "googlemaps" | "gemini" | "leadmagic" | "mixrank" | "builtwith" | "perplexity" | "serper" | "icypeas" | "prospeo" | "clado" | "resend" | "slack" | "gmail" | "firecrawl" | "exa" | "openai" | "companyenrich" | "logodev" | "amplemarket" | "parallel";
|
|
282
288
|
};
|
|
283
289
|
icon?: {
|
|
284
290
|
key: "linkedin" | "job";
|
|
@@ -299,41 +305,18 @@ declare class Pipe0 {
|
|
|
299
305
|
};
|
|
300
306
|
} | null;
|
|
301
307
|
}[];
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
status: "pending" | "processing" | "failed" | "completed";
|
|
307
|
-
errors: {
|
|
308
|
-
code: string;
|
|
309
|
-
message: string;
|
|
310
|
-
path?: string;
|
|
311
|
-
}[];
|
|
312
|
-
meta: {
|
|
313
|
-
providers?: {
|
|
314
|
-
clado?: {
|
|
315
|
-
pagination: {
|
|
316
|
-
search_id?: string;
|
|
317
|
-
offset?: number;
|
|
318
|
-
};
|
|
319
|
-
};
|
|
320
|
-
crustdata?: {
|
|
321
|
-
pagination: {
|
|
322
|
-
cursor: string | null;
|
|
323
|
-
};
|
|
324
|
-
};
|
|
325
|
-
};
|
|
326
|
-
};
|
|
327
|
-
}[];
|
|
328
|
-
organizationId: string;
|
|
308
|
+
organization_id: string;
|
|
309
|
+
next_page: components["schemas"]["SearchPayloadSchema"];
|
|
310
|
+
pagination_type: "cursor" | "page_number" | null;
|
|
311
|
+
total_pages: number | null;
|
|
329
312
|
}>;
|
|
330
313
|
/**
|
|
331
314
|
* Poll until the search completes or fails.
|
|
332
315
|
*/
|
|
333
316
|
waitUntilComplete: (runId: string | Promise<string>, options?: {
|
|
334
|
-
onPoll?: (_response:
|
|
317
|
+
onPoll?: (_response: SearchResponse) => unknown;
|
|
335
318
|
signal?: AbortSignal;
|
|
336
|
-
}) => Promise<
|
|
319
|
+
}) => Promise<Search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W,aAAA;MA/BD;;;MAmCpB,MAAA,GAAS,WAAA;IAAA,MAEV,OAAA,CAAQ,aAAA;IAvBgB;;;;;;6BAiChB,YAAA;MAAY,WAAA;MAAA,GAAA;IAAA,IACe,YAAA,KACnC,OAAA,CAAQ,aAAA;EAAA;EAyFb,QAAA;;;;sBAKa,aAAA,EAAa,OAAA;MAEpB,MAAA,IAAU,SAAA,EAAW,cAAA;MACrB,MAAA,GAAS,WAAA;IAAA,MAEV,OAAA,CAAQ,cAAA;;;;;sBAQa,aAAA,KAAa,OAAA;;;;8BAeV,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAfU,UAAA;;;;IAXZ;;;wCA0CP,OAAA,UAAe,OAAA;MAE7B,MAAA,IAAU,SAAA,EAAW,cAAA;MACrB,MAAA,GAAS,WAAA;IAAA,MAEV,OAAA,CAAQ,cAAA;EAAA;EAAA,QAKL,KAAA;AAAA"}
|
package/dist/pipe0.mjs
CHANGED
|
@@ -159,12 +159,12 @@ var Pipe0 = class {
|
|
|
159
159
|
return this.searches.waitUntilComplete(await this.searches.create(payload), options);
|
|
160
160
|
},
|
|
161
161
|
create: async (payload) => {
|
|
162
|
-
const response = await this.client.POST("/v1/
|
|
162
|
+
const response = await this.client.POST("/v1/search/run", { body: payload });
|
|
163
163
|
if (response.error) throw new Pipe0ServerError(JSON.stringify(response.error));
|
|
164
164
|
return response.data.id;
|
|
165
165
|
},
|
|
166
166
|
check: async (runId) => {
|
|
167
|
-
const response = await this.client.GET("/v1/
|
|
167
|
+
const response = await this.client.GET("/v1/search/check/{run_id}", { params: { path: { run_id: runId } } });
|
|
168
168
|
if (response.error) throw new Pipe0ServerError(JSON.stringify(response.error));
|
|
169
169
|
return response.data;
|
|
170
170
|
},
|
package/dist/pipe0.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipe0.mjs","names":[],"sources":["../src/pipe0.ts"],"sourcesContent":["import createFetchClient, { type Client } from \"openapi-fetch\";\nimport type { paths } from \"./generated/openapi.types.js\";\n\nexport type PipesRequest =\n paths[\"/v1/pipes/run\"][\"post\"][\"requestBody\"][\"content\"][\"application/json\"];\nexport type PipesResponse =\n paths[\"/v1/pipes/check/{run_id}\"][\"get\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\nexport type SearchesRequest =\n paths[\"/v1/searches/run\"][\"post\"][\"requestBody\"][\"content\"][\"application/json\"];\nexport type SearchesResponse =\n paths[\"/v1/searches/check/{run_id}\"][\"get\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\nexport type SearchRequest =\n paths[\"/v1/search/run\"][\"post\"][\"requestBody\"][\"content\"][\"application/json\"];\nexport type SearchResponse =\n paths[\"/v1/search/check/{run_id}\"][\"get\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\nexport class Pipe0TimeoutError extends Error {\n constructor(\n message: string,\n public readonly runId?: string,\n ) {\n super(message);\n this.name = \"Pipe0TimeoutError\";\n this.runId = runId;\n }\n}\n\nexport class Pipe0AbortError extends Error {\n constructor(\n message: string,\n public readonly runId?: string,\n ) {\n super(message);\n this.name = \"Pipe0AbortError\";\n this.runId = runId;\n }\n}\n\nexport class Pipe0BatchError extends Error {\n constructor(\n message: string,\n public readonly errors: Array<{ batchIndex: number; error: Error }>,\n public readonly successfulBatches: PipesResponse[],\n ) {\n super(message);\n this.name = \"Pipe0BatchError\";\n this.errors = errors;\n this.successfulBatches = successfulBatches;\n }\n}\n\nexport class Pipe0TaskError extends Error {\n constructor(\n message: string,\n public readonly responseBody?: unknown,\n ) {\n super(message);\n this.name = \"Pipe0TaskError\";\n this.responseBody = responseBody;\n }\n}\n\nexport class Pipe0ServerError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"Pipe0ServerError\";\n }\n}\n\nexport interface BatchOptions {\n /**\n * Callback invoked on each poll for any batch\n */\n onPoll?: (_batchIndex: number, _response: PipesResponse) => void;\n /**\n * Callback invoked when each batch completes\n */\n onBatchComplete?: (_batchIndex: number, _result: PipesResponse) => void;\n /**\n * Whether to stop all batches if one fails\n * @default true\n */\n stopOnError?: boolean;\n /**\n * AbortSignal to cancel all batch operations\n */\n signal?: AbortSignal;\n}\n\nexport interface Pipe0Options {\n apiKey?: string;\n baseUrl?: string;\n credentials?: RequestInit[\"credentials\"];\n /**\n * Default timeout for polling operations in milliseconds\n * @default 900000 (15 minutes)\n */\n pollingTimeoutMs?: number;\n /**\n * Default polling interval in milliseconds\n * @default 1000 (1 second)\n */\n minPollingIntervalMs?: number;\n /**\n * Maximum polling interval in milliseconds (for exponential backoff)\n * @default 3000 (3 seconds)\n */\n maxPollingIntervalMs?: number;\n /**\n * Default batch size for large payloads\n * @default 100\n */\n defaultBatchSize?: number;\n /**\n * Maximum number of concurrent batch requests\n * @default 5\n */\n maxConcurrentBatches?: number;\n}\n\n// Utility type for any possible API response data shape\ntype Pipe0TaskStatusResponse = PipesResponse | SearchesResponse;\n\nexport class Pipe0 {\n public client: Client<paths, `${string}/${string}`>;\n private apiKey?: string;\n\n private pollingTimeoutMs: number;\n private minPollingIntervalMs: number;\n private maxPollingIntervalMs: number;\n private defaultBatchSize: number;\n private maxConcurrentBatches: number;\n\n constructor(options: Pipe0Options = {}) {\n // eslint-disable-next-line turbo/no-undeclared-env-vars\n const envApiKey = typeof process !== \"undefined\" ? process.env?.PIPE0_API_KEY : undefined;\n this.apiKey = options.apiKey ?? envApiKey;\n\n this.pollingTimeoutMs = options.pollingTimeoutMs ?? 900000;\n this.minPollingIntervalMs = options.minPollingIntervalMs ?? 1000;\n this.maxPollingIntervalMs = options.maxPollingIntervalMs ?? this.minPollingIntervalMs * 3;\n this.defaultBatchSize = options.defaultBatchSize ?? 100;\n this.maxConcurrentBatches = options.maxConcurrentBatches ?? 5;\n\n const headers: Record<string, string> = {};\n\n if (this.apiKey) {\n headers.Authorization = `Bearer ${this.apiKey}`;\n }\n\n this.client = createFetchClient<paths>({\n baseUrl: options.baseUrl ?? \"https://api.pipe0.com\",\n credentials: options.credentials\n ? options.credentials\n : options.baseUrl\n ? \"same-origin\"\n : \"include\",\n headers,\n });\n }\n\n /**\n * Centralized logic to poll until a task completes, fails, or times out.\n */\n private async _pollUntilComplete<TResponse extends Pipe0TaskStatusResponse>(\n runId: string | Promise<string>,\n checkFn: (_id: string) => Promise<TResponse>,\n taskType: \"Pipe\" | \"Search\",\n options: {\n onPoll?: (_response: TResponse) => unknown;\n signal?: AbortSignal;\n } = {},\n ): Promise<TResponse> {\n const resolvedRunId = await runId;\n\n const timeout = this.pollingTimeoutMs;\n const initialInterval = this.minPollingIntervalMs;\n const maxInterval = this.maxPollingIntervalMs;\n // We can hardcode backoff for simplicity since it's the only logic\n const useBackoff = true;\n\n const startTime = Date.now();\n let currentInterval = initialInterval;\n\n while (true) {\n if (Date.now() - startTime >= timeout) {\n throw new Pipe0TimeoutError(\n `${taskType} polling timed out after ${timeout}ms`,\n resolvedRunId,\n );\n }\n\n if (options.signal?.aborted) {\n throw new Pipe0AbortError(`${taskType} polling was aborted`, resolvedRunId);\n }\n\n const polledResponse = await checkFn(resolvedRunId);\n\n if (options.onPoll) {\n await options.onPoll(polledResponse);\n }\n\n if (polledResponse.status === \"completed\") {\n return polledResponse;\n }\n\n if (polledResponse.status === \"failed\") {\n throw new Pipe0TaskError(\n `${taskType} failed with status: ${polledResponse.status}`,\n polledResponse,\n );\n }\n\n await this.sleep(currentInterval, options.signal);\n\n if (useBackoff) {\n currentInterval = Math.min(currentInterval * 1.1, maxInterval);\n }\n }\n }\n\n public pipes = {\n /**\n * Create and immediately wait for completion (convenience method)\n */\n pipe: async (\n payload: PipesRequest,\n options: {\n onPoll?: (_response: PipesResponse) => unknown;\n signal?: AbortSignal;\n } = {},\n ): Promise<PipesResponse> => {\n return this.pipes.waitUntilComplete(await this.pipes.create(payload), options);\n },\n /**\n * Create a pipes task but don't want for it. Use this method if you want to fire and forget.\n */\n create: async (payload: PipesRequest) => {\n const response = await this.client.POST(\"/v1/pipes/run\", {\n body: payload,\n });\n\n if (response.error) {\n throw new Pipe0ServerError(JSON.stringify(response.error));\n }\n\n return response.data.id;\n },\n /**\n * Check the status of a pipes task manually.\n */\n check: async (runId: string) => {\n const response = await this.client.GET(\"/v1/pipes/check/{run_id}\", {\n params: { path: { run_id: runId } },\n });\n\n if (response.error) {\n throw new Pipe0ServerError(JSON.stringify(response.error));\n }\n\n return response.data;\n },\n waitUntilComplete: async (\n runId: string | Promise<string>,\n options: {\n /**\n * Callback invoked on each poll with the current status\n */\n onPoll?: (_response: PipesResponse) => unknown;\n /**\n * AbortSignal to cancel the polling operation\n */\n signal?: AbortSignal;\n } = {},\n ): Promise<PipesResponse> => {\n return this._pollUntilComplete<PipesResponse>(runId, this.pipes.check, \"Pipe\", options);\n },\n /**\n * Process a large payload by batching the input array\n * @param payload - The pipe request payload with a large input array\n * @param options - Batching options\n * @returns Array of completed batch responses\n */\n pipeInBatches: async (\n payload: PipesRequest,\n { stopOnError = true, ...options }: BatchOptions = {},\n ): Promise<PipesResponse[]> => {\n const batchSize = this.defaultBatchSize;\n const maxConcurrency = this.maxConcurrentBatches;\n\n // Extract and validate input array\n if (!Array.isArray(payload.input)) {\n throw new Error(\"payload.input must be an array for batched operations\");\n }\n\n const inputArray = payload.input;\n const totalItems = inputArray.length;\n\n // Create batches\n const batches: PipesRequest[] = [];\n for (let i = 0; i < totalItems; i += batchSize) {\n const batchInput = inputArray.slice(i, i + batchSize);\n batches.push({\n ...payload,\n input: batchInput,\n });\n }\n\n // Process batches with concurrency control\n const resultsArr: PipesResponse[] = [];\n const errors: Array<{ batchIndex: number; error: Error }> = [];\n\n for (let i = 0; i < batches.length; i += maxConcurrency) {\n if (options.signal?.aborted) {\n throw new Pipe0AbortError(\"Batch operation was aborted\");\n }\n\n const batchGroup = batches.slice(i, i + maxConcurrency);\n const batchPromises = batchGroup.map(async (batch, groupIndex) => {\n const batchIndex = i + groupIndex;\n\n try {\n // Create and wait for batch\n const runId = await this.pipes.create(batch);\n const result = await this.pipes.waitUntilComplete(runId, {\n signal: options.signal,\n onPoll: options.onPoll\n ? (response) => options.onPoll!(batchIndex, response)\n : undefined,\n });\n\n if (options.onBatchComplete) {\n options.onBatchComplete(batchIndex, result);\n }\n\n return { batchIndex, result };\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n errors.push({ batchIndex, error: err });\n\n if (stopOnError) {\n throw new Pipe0BatchError(\n `Batch ${batchIndex} failed and stopOnError is enabled`,\n errors,\n resultsArr,\n );\n }\n\n return { batchIndex, result: null };\n }\n });\n\n const batchResults = await Promise.all(batchPromises);\n\n // Collect results in order\n for (const { result } of batchResults) {\n if (result) {\n resultsArr.push(result);\n }\n }\n }\n\n // If any errors occurred and stopOnError wasn't enabled, throw at the end\n if (errors.length > 0) {\n throw new Pipe0BatchError(\n `${errors.length} batch(es) failed out of ${batches.length} total`,\n errors,\n resultsArr,\n );\n }\n\n return resultsArr;\n },\n };\n\n searches = {\n /**\n * Create and immediately wait for completion (convenience method)\n */\n search: async (\n payload: SearchesRequest,\n options: {\n onPoll?: (_response: SearchesResponse) => unknown;\n signal?: AbortSignal;\n } = {},\n ): Promise<SearchesResponse> => {\n return this.searches.waitUntilComplete(await this.searches.create(payload), options);\n },\n\n /**\n * Create a searches task but don't wait for it.\n * Use this if you want fire and forget.\n */\n create: async (payload: SearchesRequest) => {\n const response = await this.client.POST(\"/v1/searches/run\", {\n body: payload,\n });\n\n if (response.error) {\n throw new Pipe0ServerError(JSON.stringify(response.error));\n }\n\n return response.data.id;\n },\n\n /**\n * Check the status of a search task manually.\n */\n check: async (runId: string) => {\n const response = await this.client.GET(\"/v1/searches/check/{run_id}\", {\n params: { path: { run_id: runId } },\n });\n\n if (response.error) {\n throw new Pipe0ServerError(JSON.stringify(response.error));\n }\n\n return response.data;\n },\n\n /**\n * Poll until the search completes or fails.\n */\n waitUntilComplete: async (\n runId: string | Promise<string>,\n options: {\n onPoll?: (_response: SearchesResponse) => unknown;\n signal?: AbortSignal;\n } = {},\n ): Promise<SearchesResponse> => {\n return this._pollUntilComplete<SearchesResponse>(\n runId,\n this.searches.check,\n \"Search\",\n options,\n );\n },\n };\n\n private sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(resolve, ms);\n\n if (signal) {\n const onAbort = () => {\n clearTimeout(timeout);\n reject(new Pipe0AbortError(\"Sleep was aborted\"));\n };\n\n if (signal.aborted) {\n clearTimeout(timeout);\n reject(new Pipe0AbortError(\"Sleep was aborted\"));\n return;\n }\n\n signal.addEventListener(\"abort\", onAbort, { once: true });\n }\n });\n }\n}\n"],"mappings":";;;AAkBA,IAAa,oBAAb,cAAuC,MAAM;CAC3C,YACE,SACA,AAAgB,OAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;AACZ,OAAK,QAAQ;;;AAIjB,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACE,SACA,AAAgB,OAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;AACZ,OAAK,QAAQ;;;AAIjB,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACE,SACA,AAAgB,QAChB,AAAgB,mBAChB;AACA,QAAM,QAAQ;EAHE;EACA;AAGhB,OAAK,OAAO;AACZ,OAAK,SAAS;AACd,OAAK,oBAAoB;;;AAI7B,IAAa,iBAAb,cAAoC,MAAM;CACxC,YACE,SACA,AAAgB,cAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;AACZ,OAAK,eAAe;;;AAIxB,IAAa,mBAAb,cAAsC,MAAM;CAC1C,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;;;AA0DhB,IAAa,QAAb,MAAmB;CACjB,AAAO;CACP,AAAQ;CAER,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAY,UAAwB,EAAE,EAAE;EAEtC,MAAM,YAAY,OAAO,YAAY,cA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AO,OAAO,UAAkB;GAC9B,MAAM,WAAW,MAAM,KAAK,OAAO,IAAI,+BAA+B,EACpE,QAAQ,EAAE,MAAM,EAAE,QAAQ,OAAO,EAAE,EACpC,CAAC;AAEF,OAAI,SAAS,MACX,OAAM,IAAI,iBAAiB,KAAK,UAAU,SAAS,MAAM,CAAC;AAG5D,UAAO,SAAS;;EAMlB,mBAAmB,OACjB,OACA,UAGI,EAAE,KACwB;AAC9B,UAAO,KAAK,mBACV,OACA,KAAK,SAAS,OACd,UACA,QACD;;EAEJ;CAED,AAAQ,MAAM,IAAY,QAAqC;AAC7D,SAAO,IAAI,SAAS,SAAS,WAAW;GACtC,MAAM,UAAU,WAAW,SAAS,GAAG;AAEvC,OAAI,QAAQ;IACV,MAAM,gBAAgB;AACpB,kBAAa,QAAQ;AACrB,YAAO,IAAI,gBAAgB,oBAAoB,CAAC;;AAGlD,QAAI,OAAO,SAAS;AAClB,kBAAa,QAAQ;AACrB,YAAO,IAAI,gBAAgB,oBAAoB,CAAC;AAChD;;AAGF,WAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,MAAM,CAAC;;IAE3D"}
|
|
1
|
+
{"version":3,"file":"pipe0.mjs","names":[],"sources":["../src/pipe0.ts"],"sourcesContent":["import createFetchClient, { type Client } from \"openapi-fetch\";\nimport type { paths } from \"./generated/openapi.types.js\";\n\nexport type PipesRequest =\n paths[\"/v1/pipes/run\"][\"post\"][\"requestBody\"][\"content\"][\"application/json\"];\nexport type PipesResponse =\n paths[\"/v1/pipes/check/{run_id}\"][\"get\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\nexport type SearchesRequest =\n paths[\"/v1/searches/run\"][\"post\"][\"requestBody\"][\"content\"][\"application/json\"];\nexport type SearchesResponse =\n paths[\"/v1/searches/check/{run_id}\"][\"get\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\nexport type SearchRequest =\n paths[\"/v1/search/run\"][\"post\"][\"requestBody\"][\"content\"][\"application/json\"];\nexport type SearchResponse =\n paths[\"/v1/search/check/{run_id}\"][\"get\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\nexport class Pipe0TimeoutError extends Error {\n constructor(\n message: string,\n public readonly runId?: string,\n ) {\n super(message);\n this.name = \"Pipe0TimeoutError\";\n this.runId = runId;\n }\n}\n\nexport class Pipe0AbortError extends Error {\n constructor(\n message: string,\n public readonly runId?: string,\n ) {\n super(message);\n this.name = \"Pipe0AbortError\";\n this.runId = runId;\n }\n}\n\nexport class Pipe0BatchError extends Error {\n constructor(\n message: string,\n public readonly errors: Array<{ batchIndex: number; error: Error }>,\n public readonly successfulBatches: PipesResponse[],\n ) {\n super(message);\n this.name = \"Pipe0BatchError\";\n this.errors = errors;\n this.successfulBatches = successfulBatches;\n }\n}\n\nexport class Pipe0TaskError extends Error {\n constructor(\n message: string,\n public readonly responseBody?: unknown,\n ) {\n super(message);\n this.name = \"Pipe0TaskError\";\n this.responseBody = responseBody;\n }\n}\n\nexport class Pipe0ServerError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"Pipe0ServerError\";\n }\n}\n\nexport interface BatchOptions {\n /**\n * Callback invoked on each poll for any batch\n */\n onPoll?: (_batchIndex: number, _response: PipesResponse) => void;\n /**\n * Callback invoked when each batch completes\n */\n onBatchComplete?: (_batchIndex: number, _result: PipesResponse) => void;\n /**\n * Whether to stop all batches if one fails\n * @default true\n */\n stopOnError?: boolean;\n /**\n * AbortSignal to cancel all batch operations\n */\n signal?: AbortSignal;\n}\n\nexport interface Pipe0Options {\n apiKey?: string;\n baseUrl?: string;\n credentials?: RequestInit[\"credentials\"];\n /**\n * Default timeout for polling operations in milliseconds\n * @default 900000 (15 minutes)\n */\n pollingTimeoutMs?: number;\n /**\n * Default polling interval in milliseconds\n * @default 1000 (1 second)\n */\n minPollingIntervalMs?: number;\n /**\n * Maximum polling interval in milliseconds (for exponential backoff)\n * @default 3000 (3 seconds)\n */\n maxPollingIntervalMs?: number;\n /**\n * Default batch size for large payloads\n * @default 100\n */\n defaultBatchSize?: number;\n /**\n * Maximum number of concurrent batch requests\n * @default 5\n */\n maxConcurrentBatches?: number;\n}\n\n// Utility type for any possible API response data shape\ntype Pipe0TaskStatusResponse = PipesResponse | SearchResponse;\n\nexport class Pipe0 {\n public client: Client<paths, `${string}/${string}`>;\n private apiKey?: string;\n\n private pollingTimeoutMs: number;\n private minPollingIntervalMs: number;\n private maxPollingIntervalMs: number;\n private defaultBatchSize: number;\n private maxConcurrentBatches: number;\n\n constructor(options: Pipe0Options = {}) {\n // eslint-disable-next-line turbo/no-undeclared-env-vars\n const envApiKey = typeof process !== \"undefined\" ? process.env?.PIPE0_API_KEY : undefined;\n this.apiKey = options.apiKey ?? envApiKey;\n\n this.pollingTimeoutMs = options.pollingTimeoutMs ?? 900000;\n this.minPollingIntervalMs = options.minPollingIntervalMs ?? 1000;\n this.maxPollingIntervalMs = options.maxPollingIntervalMs ?? this.minPollingIntervalMs * 3;\n this.defaultBatchSize = options.defaultBatchSize ?? 100;\n this.maxConcurrentBatches = options.maxConcurrentBatches ?? 5;\n\n const headers: Record<string, string> = {};\n\n if (this.apiKey) {\n headers.Authorization = `Bearer ${this.apiKey}`;\n }\n\n this.client = createFetchClient<paths>({\n baseUrl: options.baseUrl ?? \"https://api.pipe0.com\",\n credentials: options.credentials\n ? options.credentials\n : options.baseUrl\n ? \"same-origin\"\n : \"include\",\n headers,\n });\n }\n\n /**\n * Centralized logic to poll until a task completes, fails, or times out.\n */\n private async _pollUntilComplete<TResponse extends Pipe0TaskStatusResponse>(\n runId: string | Promise<string>,\n checkFn: (_id: string) => Promise<TResponse>,\n taskType: \"Pipe\" | \"Search\",\n options: {\n onPoll?: (_response: TResponse) => unknown;\n signal?: AbortSignal;\n } = {},\n ): Promise<TResponse> {\n const resolvedRunId = await runId;\n\n const timeout = this.pollingTimeoutMs;\n const initialInterval = this.minPollingIntervalMs;\n const maxInterval = this.maxPollingIntervalMs;\n // We can hardcode backoff for simplicity since it's the only logic\n const useBackoff = true;\n\n const startTime = Date.now();\n let currentInterval = initialInterval;\n\n while (true) {\n if (Date.now() - startTime >= timeout) {\n throw new Pipe0TimeoutError(\n `${taskType} polling timed out after ${timeout}ms`,\n resolvedRunId,\n );\n }\n\n if (options.signal?.aborted) {\n throw new Pipe0AbortError(`${taskType} polling was aborted`, resolvedRunId);\n }\n\n const polledResponse = await checkFn(resolvedRunId);\n\n if (options.onPoll) {\n await options.onPoll(polledResponse);\n }\n\n if (polledResponse.status === \"completed\") {\n return polledResponse;\n }\n\n if (polledResponse.status === \"failed\") {\n throw new Pipe0TaskError(\n `${taskType} failed with status: ${polledResponse.status}`,\n polledResponse,\n );\n }\n\n await this.sleep(currentInterval, options.signal);\n\n if (useBackoff) {\n currentInterval = Math.min(currentInterval * 1.1, maxInterval);\n }\n }\n }\n\n public pipes = {\n /**\n * Create and immediately wait for completion (convenience method)\n */\n pipe: async (\n payload: PipesRequest,\n options: {\n onPoll?: (_response: PipesResponse) => unknown;\n signal?: AbortSignal;\n } = {},\n ): Promise<PipesResponse> => {\n return this.pipes.waitUntilComplete(await this.pipes.create(payload), options);\n },\n /**\n * Create a pipes task but don't want for it. Use this method if you want to fire and forget.\n */\n create: async (payload: PipesRequest) => {\n const response = await this.client.POST(\"/v1/pipes/run\", {\n body: payload,\n });\n\n if (response.error) {\n throw new Pipe0ServerError(JSON.stringify(response.error));\n }\n\n return response.data.id;\n },\n /**\n * Check the status of a pipes task manually.\n */\n check: async (runId: string) => {\n const response = await this.client.GET(\"/v1/pipes/check/{run_id}\", {\n params: { path: { run_id: runId } },\n });\n\n if (response.error) {\n throw new Pipe0ServerError(JSON.stringify(response.error));\n }\n\n return response.data;\n },\n waitUntilComplete: async (\n runId: string | Promise<string>,\n options: {\n /**\n * Callback invoked on each poll with the current status\n */\n onPoll?: (_response: PipesResponse) => unknown;\n /**\n * AbortSignal to cancel the polling operation\n */\n signal?: AbortSignal;\n } = {},\n ): Promise<PipesResponse> => {\n return this._pollUntilComplete<PipesResponse>(runId, this.pipes.check, \"Pipe\", options);\n },\n /**\n * Process a large payload by batching the input array\n * @param payload - The pipe request payload with a large input array\n * @param options - Batching options\n * @returns Array of completed batch responses\n */\n pipeInBatches: async (\n payload: PipesRequest,\n { stopOnError = true, ...options }: BatchOptions = {},\n ): Promise<PipesResponse[]> => {\n const batchSize = this.defaultBatchSize;\n const maxConcurrency = this.maxConcurrentBatches;\n\n // Extract and validate input array\n if (!Array.isArray(payload.input)) {\n throw new Error(\"payload.input must be an array for batched operations\");\n }\n\n const inputArray = payload.input;\n const totalItems = inputArray.length;\n\n // Create batches\n const batches: PipesRequest[] = [];\n for (let i = 0; i < totalItems; i += batchSize) {\n const batchInput = inputArray.slice(i, i + batchSize);\n batches.push({\n ...payload,\n input: batchInput,\n });\n }\n\n // Process batches with concurrency control\n const resultsArr: PipesResponse[] = [];\n const errors: Array<{ batchIndex: number; error: Error }> = [];\n\n for (let i = 0; i < batches.length; i += maxConcurrency) {\n if (options.signal?.aborted) {\n throw new Pipe0AbortError(\"Batch operation was aborted\");\n }\n\n const batchGroup = batches.slice(i, i + maxConcurrency);\n const batchPromises = batchGroup.map(async (batch, groupIndex) => {\n const batchIndex = i + groupIndex;\n\n try {\n // Create and wait for batch\n const runId = await this.pipes.create(batch);\n const result = await this.pipes.waitUntilComplete(runId, {\n signal: options.signal,\n onPoll: options.onPoll\n ? (response) => options.onPoll!(batchIndex, response)\n : undefined,\n });\n\n if (options.onBatchComplete) {\n options.onBatchComplete(batchIndex, result);\n }\n\n return { batchIndex, result };\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n errors.push({ batchIndex, error: err });\n\n if (stopOnError) {\n throw new Pipe0BatchError(\n `Batch ${batchIndex} failed and stopOnError is enabled`,\n errors,\n resultsArr,\n );\n }\n\n return { batchIndex, result: null };\n }\n });\n\n const batchResults = await Promise.all(batchPromises);\n\n // Collect results in order\n for (const { result } of batchResults) {\n if (result) {\n resultsArr.push(result);\n }\n }\n }\n\n // If any errors occurred and stopOnError wasn't enabled, throw at the end\n if (errors.length > 0) {\n throw new Pipe0BatchError(\n `${errors.length} batch(es) failed out of ${batches.length} total`,\n errors,\n resultsArr,\n );\n }\n\n return resultsArr;\n },\n };\n\n searches = {\n /**\n * Create and immediately wait for completion (convenience method)\n */\n search: async (\n payload: SearchRequest,\n options: {\n onPoll?: (_response: SearchResponse) => unknown;\n signal?: AbortSignal;\n } = {},\n ): Promise<SearchResponse> => {\n return this.searches.waitUntilComplete(await this.searches.create(payload), options);\n },\n\n /**\n * Create a searches task but don't wait for it.\n * Use this if you want fire and forget.\n */\n create: async (payload: SearchRequest) => {\n const response = await this.client.POST(\"/v1/search/run\", {\n body: payload,\n });\n\n if (response.error) {\n throw new Pipe0ServerError(JSON.stringify(response.error));\n }\n\n return response.data.id;\n },\n\n /**\n * Check the status of a search task manually.\n */\n check: async (runId: string) => {\n const response = await this.client.GET(\"/v1/search/check/{run_id}\", {\n params: { path: { run_id: runId } },\n });\n\n if (response.error) {\n throw new Pipe0ServerError(JSON.stringify(response.error));\n }\n\n return response.data;\n },\n\n /**\n * Poll until the search completes or fails.\n */\n waitUntilComplete: async (\n runId: string | Promise<string>,\n options: {\n onPoll?: (_response: SearchResponse) => unknown;\n signal?: AbortSignal;\n } = {},\n ): Promise<SearchResponse> => {\n return this._pollUntilComplete<SearchResponse>(runId, this.searches.check, \"Search\", options);\n },\n };\n\n private sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(resolve, ms);\n\n if (signal) {\n const onAbort = () => {\n clearTimeout(timeout);\n reject(new Pipe0AbortError(\"Sleep was aborted\"));\n };\n\n if (signal.aborted) {\n clearTimeout(timeout);\n reject(new Pipe0AbortError(\"Sleep was aborted\"));\n return;\n }\n\n signal.addEventListener(\"abort\", onAbort, { once: true });\n }\n });\n }\n}\n\nfunction test() {\n const piper = new Pipe0({ apiKey: \"\" });\n\n piper.searches.search({\n search: {\n search_id: \"companies:profiles:amplemarket@2\",\n config: {\n filters: { hq_locations: { include: [\"sldjkf\"] } },\n },\n },\n });\n\n piper.searches.search({\n search: {\n search_id: \"people:profiles:crustdata@2\",\n config: {\n filters: {\n current_employer_domains: {\n include: [\"google.com\", \"microsoft.com\"],\n },\n },\n },\n },\n });\n}\n"],"mappings":";;;AAkBA,IAAa,oBAAb,cAAuC,MAAM;CAC3C,YACE,SACA,AAAgB,OAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;AACZ,OAAK,QAAQ;;;AAIjB,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACE,SACA,AAAgB,OAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;AACZ,OAAK,QAAQ;;;AAIjB,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACE,SACA,AAAgB,QAChB,AAAgB,mBAChB;AACA,QAAM,QAAQ;EAHE;EACA;AAGhB,OAAK,OAAO;AACZ,OAAK,SAAS;AACd,OAAK,oBAAoB;;;AAI7B,IAAa,iBAAb,cAAoC,MAAM;CACxC,YACE,SACA,AAAgB,cAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;AACZ,OAAK,eAAe;;;AAIxB,IAAa,mBAAb,cAAsC,MAAM;CAC1C,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;;;AA0DhB,IAAa,QAAb,MAAmB;CACjB,AAAO;CACP,AAAQ;CAER,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAY,UAAwB,EAAE,EAAE;EAEtC,MAAM,YAAY,OAAO,YAAY,cAAc,QAAQ,KAAK,gBAAgB;AAChF,OAAK,SAAS,QAAQ,UAAU;AAEhC,OAAK,mBAAmB,QAAQ,oBAAoB;AACpD,OAAK,uBAAuB,QAAQ,wBAAwB;AAC5D,OAAK,uBAAuB,QAAQ,wBAAwB,KAAK,uBAAuB;AACxF,OAAK,mBAAmB,QAAQ,oBAAoB;AACpD,OAAK,uBA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