exa-js 2.5.1-beta.0 → 2.5.1-beta.2
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/dist/index.d.mts +437 -426
- package/dist/index.d.ts +437 -426
- package/dist/index.js +1596 -1527
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1595 -1526
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import fetch2, { Headers } from "cross-fetch";
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "exa-js",
|
|
7
|
-
version: "2.5.1-beta.
|
|
7
|
+
version: "2.5.1-beta.2",
|
|
8
8
|
description: "Exa SDK for Node.js and the browser",
|
|
9
9
|
publishConfig: {
|
|
10
10
|
access: "public"
|
|
@@ -88,67 +88,14 @@ var package_default = {
|
|
|
88
88
|
homepage: "https://github.com/exa-labs/exa-js#readme"
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
// src/
|
|
92
|
-
var
|
|
93
|
-
HttpStatusCode2[HttpStatusCode2["BadRequest"] = 400] = "BadRequest";
|
|
94
|
-
HttpStatusCode2[HttpStatusCode2["NotFound"] = 404] = "NotFound";
|
|
95
|
-
HttpStatusCode2[HttpStatusCode2["Unauthorized"] = 401] = "Unauthorized";
|
|
96
|
-
HttpStatusCode2[HttpStatusCode2["Forbidden"] = 403] = "Forbidden";
|
|
97
|
-
HttpStatusCode2[HttpStatusCode2["TooManyRequests"] = 429] = "TooManyRequests";
|
|
98
|
-
HttpStatusCode2[HttpStatusCode2["RequestTimeout"] = 408] = "RequestTimeout";
|
|
99
|
-
HttpStatusCode2[HttpStatusCode2["InternalServerError"] = 500] = "InternalServerError";
|
|
100
|
-
HttpStatusCode2[HttpStatusCode2["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
101
|
-
return HttpStatusCode2;
|
|
102
|
-
})(HttpStatusCode || {});
|
|
103
|
-
var ExaError = class extends Error {
|
|
104
|
-
/**
|
|
105
|
-
* Create a new ExaError
|
|
106
|
-
* @param message Error message
|
|
107
|
-
* @param statusCode HTTP status code
|
|
108
|
-
* @param timestamp ISO timestamp from API
|
|
109
|
-
* @param path Path that caused the error
|
|
110
|
-
*/
|
|
111
|
-
constructor(message, statusCode, timestamp, path) {
|
|
112
|
-
super(message);
|
|
113
|
-
this.name = "ExaError";
|
|
114
|
-
this.statusCode = statusCode;
|
|
115
|
-
this.timestamp = timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
116
|
-
this.path = path;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
// src/zod-utils.ts
|
|
121
|
-
import { ZodType } from "zod";
|
|
122
|
-
import { zodToJsonSchema as convertZodToJsonSchema } from "zod-to-json-schema";
|
|
123
|
-
function isZodSchema(obj) {
|
|
124
|
-
return obj instanceof ZodType;
|
|
125
|
-
}
|
|
126
|
-
function zodToJsonSchema(schema) {
|
|
127
|
-
return convertZodToJsonSchema(schema, {
|
|
128
|
-
$refStrategy: "none"
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// src/research/base.ts
|
|
133
|
-
var ResearchBaseClient = class {
|
|
91
|
+
// src/nova/websets-client.ts
|
|
92
|
+
var WebsetsBaseClient = class {
|
|
134
93
|
constructor(client) {
|
|
135
94
|
this.client = client;
|
|
136
95
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
method,
|
|
141
|
-
data,
|
|
142
|
-
params
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
async rawRequest(endpoint, method = "POST", data, params) {
|
|
146
|
-
return this.client.rawRequest(
|
|
147
|
-
`/research/v1${endpoint}`,
|
|
148
|
-
method,
|
|
149
|
-
data,
|
|
150
|
-
params
|
|
151
|
-
);
|
|
96
|
+
/** Make a request to the API, prepending `/websets` to the path. */
|
|
97
|
+
async request(endpoint, method = "POST", data, params, headers) {
|
|
98
|
+
return this.client.request(`/websets${endpoint}`, method, data, params, headers);
|
|
152
99
|
}
|
|
153
100
|
buildPaginationParams(pagination) {
|
|
154
101
|
const params = {};
|
|
@@ -158,288 +105,115 @@ var ResearchBaseClient = class {
|
|
|
158
105
|
return params;
|
|
159
106
|
}
|
|
160
107
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
constructor(client) {
|
|
165
|
-
super(client);
|
|
166
|
-
}
|
|
167
|
-
async create(params) {
|
|
168
|
-
const { instructions, model, outputSchema } = params;
|
|
169
|
-
let schema = outputSchema;
|
|
170
|
-
if (schema && isZodSchema(schema)) {
|
|
171
|
-
schema = zodToJsonSchema(schema);
|
|
172
|
-
}
|
|
173
|
-
const payload = {
|
|
174
|
-
instructions,
|
|
175
|
-
model: model ?? "exa-research-fast"
|
|
176
|
-
};
|
|
177
|
-
if (schema) {
|
|
178
|
-
payload.outputSchema = schema;
|
|
179
|
-
}
|
|
180
|
-
return this.request("", "POST", payload);
|
|
108
|
+
var WebsetItemsClient = class extends WebsetsBaseClient {
|
|
109
|
+
async get(websetId, id) {
|
|
110
|
+
return this.request(`/v0/websets/${websetId}/items/${id}`, "GET");
|
|
181
111
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const promise = async () => {
|
|
185
|
-
const params = { stream: "true" };
|
|
186
|
-
if (options.events !== void 0) {
|
|
187
|
-
params.events = options.events.toString();
|
|
188
|
-
}
|
|
189
|
-
const resp = await this.rawRequest(
|
|
190
|
-
`/${researchId}`,
|
|
191
|
-
"GET",
|
|
192
|
-
void 0,
|
|
193
|
-
params
|
|
194
|
-
);
|
|
195
|
-
if (!resp.body) {
|
|
196
|
-
throw new Error("No response body for SSE stream");
|
|
197
|
-
}
|
|
198
|
-
const reader = resp.body.getReader();
|
|
199
|
-
const decoder = new TextDecoder();
|
|
200
|
-
let buffer = "";
|
|
201
|
-
function processPart(part) {
|
|
202
|
-
const lines = part.split("\n");
|
|
203
|
-
let data = lines.slice(1).join("\n");
|
|
204
|
-
if (data.startsWith("data:")) {
|
|
205
|
-
data = data.slice(5).trimStart();
|
|
206
|
-
}
|
|
207
|
-
try {
|
|
208
|
-
return JSON.parse(data);
|
|
209
|
-
} catch (e) {
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
async function* streamEvents() {
|
|
214
|
-
while (true) {
|
|
215
|
-
const { done, value } = await reader.read();
|
|
216
|
-
if (done) break;
|
|
217
|
-
buffer += decoder.decode(value, { stream: true });
|
|
218
|
-
let parts = buffer.split("\n\n");
|
|
219
|
-
buffer = parts.pop() ?? "";
|
|
220
|
-
for (const part of parts) {
|
|
221
|
-
const processed = processPart(part);
|
|
222
|
-
if (processed) {
|
|
223
|
-
yield processed;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (buffer.trim()) {
|
|
228
|
-
const processed = processPart(buffer.trim());
|
|
229
|
-
if (processed) {
|
|
230
|
-
yield processed;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return streamEvents();
|
|
235
|
-
};
|
|
236
|
-
return promise();
|
|
237
|
-
} else {
|
|
238
|
-
const params = { stream: "false" };
|
|
239
|
-
if (options?.events !== void 0) {
|
|
240
|
-
params.events = options.events.toString();
|
|
241
|
-
}
|
|
242
|
-
return this.request(
|
|
243
|
-
`/${researchId}`,
|
|
244
|
-
"GET",
|
|
245
|
-
void 0,
|
|
246
|
-
params
|
|
247
|
-
);
|
|
248
|
-
}
|
|
112
|
+
async delete(websetId, id) {
|
|
113
|
+
return this.request(`/v0/websets/${websetId}/items/${id}`, "DELETE");
|
|
249
114
|
}
|
|
250
|
-
async list(options) {
|
|
251
|
-
const
|
|
252
|
-
return this.request(
|
|
115
|
+
async list(websetId, options) {
|
|
116
|
+
const queryParams = { ...this.buildPaginationParams(options), sourceId: options?.sourceId };
|
|
117
|
+
return this.request(`/v0/websets/${websetId}/items`, "GET", void 0, queryParams);
|
|
253
118
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const
|
|
258
|
-
const startTime = Date.now();
|
|
259
|
-
let consecutiveFailures = 0;
|
|
119
|
+
/** Iterate through all items in a Webset, handling pagination automatically. */
|
|
120
|
+
async *listAll(websetId, options) {
|
|
121
|
+
let cursor = void 0;
|
|
122
|
+
const pageOptions = options ? { ...options } : {};
|
|
260
123
|
while (true) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
});
|
|
265
|
-
consecutiveFailures = 0;
|
|
266
|
-
if (research.status === "completed" || research.status === "failed" || research.status === "canceled") {
|
|
267
|
-
return research;
|
|
268
|
-
}
|
|
269
|
-
} catch (err) {
|
|
270
|
-
consecutiveFailures += 1;
|
|
271
|
-
if (consecutiveFailures >= maxConsecutiveFailures) {
|
|
272
|
-
throw new Error(
|
|
273
|
-
`Polling failed ${maxConsecutiveFailures} times in a row for research ${researchId}: ${err}`
|
|
274
|
-
);
|
|
275
|
-
}
|
|
124
|
+
const response = await this.list(websetId, { ...pageOptions, cursor });
|
|
125
|
+
for (const item of response.data) {
|
|
126
|
+
yield item;
|
|
276
127
|
}
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
`Polling timeout: Research ${researchId} did not complete within ${timeoutMs}ms`
|
|
280
|
-
);
|
|
128
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
129
|
+
break;
|
|
281
130
|
}
|
|
282
|
-
|
|
131
|
+
cursor = response.nextCursor;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** Collect all items from a Webset into an array. */
|
|
135
|
+
async getAll(websetId, options) {
|
|
136
|
+
const items = [];
|
|
137
|
+
for await (const item of this.listAll(websetId, options)) {
|
|
138
|
+
items.push(item);
|
|
283
139
|
}
|
|
140
|
+
return items;
|
|
284
141
|
}
|
|
285
142
|
};
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Initialize a new Websets base client
|
|
291
|
-
* @param client The Exa client instance
|
|
292
|
-
*/
|
|
293
|
-
constructor(client) {
|
|
294
|
-
this.client = client;
|
|
143
|
+
var WebsetSearchesClient = class extends WebsetsBaseClient {
|
|
144
|
+
async create(websetId, params, options) {
|
|
145
|
+
return this.request(`/v0/websets/${websetId}/searches`, "POST", { ...params }, void 0, options?.headers);
|
|
295
146
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
* @param endpoint The endpoint path
|
|
299
|
-
* @param method The HTTP method
|
|
300
|
-
* @param data Optional request body data
|
|
301
|
-
* @param params Optional query parameters
|
|
302
|
-
* @returns The response JSON
|
|
303
|
-
* @throws ExaError with API error details if the request fails
|
|
304
|
-
*/
|
|
305
|
-
async request(endpoint, method = "POST", data, params, headers) {
|
|
306
|
-
return this.client.request(
|
|
307
|
-
`/websets${endpoint}`,
|
|
308
|
-
method,
|
|
309
|
-
data,
|
|
310
|
-
params,
|
|
311
|
-
headers
|
|
312
|
-
);
|
|
147
|
+
async get(websetId, id) {
|
|
148
|
+
return this.request(`/v0/websets/${websetId}/searches/${id}`, "GET");
|
|
313
149
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
* @param pagination The pagination parameters
|
|
317
|
-
* @returns QueryParams object with pagination parameters
|
|
318
|
-
*/
|
|
319
|
-
buildPaginationParams(pagination) {
|
|
320
|
-
const params = {};
|
|
321
|
-
if (!pagination) return params;
|
|
322
|
-
if (pagination.cursor) params.cursor = pagination.cursor;
|
|
323
|
-
if (pagination.limit) params.limit = pagination.limit;
|
|
324
|
-
return params;
|
|
150
|
+
async cancel(websetId, id) {
|
|
151
|
+
return this.request(`/v0/websets/${websetId}/searches/${id}/cancel`, "POST");
|
|
325
152
|
}
|
|
326
153
|
};
|
|
327
|
-
|
|
328
|
-
// src/websets/enrichments.ts
|
|
329
154
|
var WebsetEnrichmentsClient = class extends WebsetsBaseClient {
|
|
330
|
-
/**
|
|
331
|
-
* Create an Enrichment for a Webset
|
|
332
|
-
* @param websetId The ID of the Webset
|
|
333
|
-
* @param params The enrichment parameters
|
|
334
|
-
* @returns The created Webset Enrichment
|
|
335
|
-
*/
|
|
336
155
|
async create(websetId, params) {
|
|
337
|
-
return this.request(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
);
|
|
156
|
+
return this.request(`/v0/websets/${websetId}/enrichments`, "POST", { ...params });
|
|
157
|
+
}
|
|
158
|
+
async update(websetId, id, params) {
|
|
159
|
+
return this.request(`/v0/websets/${websetId}/enrichments/${id}`, "PATCH", { ...params });
|
|
342
160
|
}
|
|
343
|
-
/**
|
|
344
|
-
* Get an Enrichment by ID
|
|
345
|
-
* @param websetId The ID of the Webset
|
|
346
|
-
* @param id The ID of the Enrichment
|
|
347
|
-
* @returns The Webset Enrichment
|
|
348
|
-
*/
|
|
349
161
|
async get(websetId, id) {
|
|
350
|
-
return this.request(
|
|
351
|
-
`/v0/websets/${websetId}/enrichments/${id}`,
|
|
352
|
-
"GET"
|
|
353
|
-
);
|
|
162
|
+
return this.request(`/v0/websets/${websetId}/enrichments/${id}`, "GET");
|
|
354
163
|
}
|
|
355
|
-
/**
|
|
356
|
-
* Delete an Enrichment
|
|
357
|
-
* @param websetId The ID of the Webset
|
|
358
|
-
* @param id The ID of the Enrichment
|
|
359
|
-
* @returns The deleted Webset Enrichment
|
|
360
|
-
*/
|
|
361
164
|
async delete(websetId, id) {
|
|
362
|
-
return this.request(
|
|
363
|
-
`/v0/websets/${websetId}/enrichments/${id}`,
|
|
364
|
-
"DELETE"
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Update an Enrichment
|
|
369
|
-
* @param websetId The ID of the Webset
|
|
370
|
-
* @param id The ID of the Enrichment
|
|
371
|
-
* @param params The enrichment update parameters
|
|
372
|
-
* @returns Promise that resolves when the update is complete
|
|
373
|
-
*/
|
|
374
|
-
async update(websetId, id, params) {
|
|
375
|
-
return this.request(
|
|
376
|
-
`/v0/websets/${websetId}/enrichments/${id}`,
|
|
377
|
-
"PATCH",
|
|
378
|
-
params
|
|
379
|
-
);
|
|
165
|
+
return this.request(`/v0/websets/${websetId}/enrichments/${id}`, "DELETE");
|
|
380
166
|
}
|
|
381
|
-
/**
|
|
382
|
-
* Cancel a running Enrichment
|
|
383
|
-
* @param websetId The ID of the Webset
|
|
384
|
-
* @param id The ID of the Enrichment
|
|
385
|
-
* @returns The canceled Webset Enrichment
|
|
386
|
-
*/
|
|
387
167
|
async cancel(websetId, id) {
|
|
388
|
-
return this.request(
|
|
389
|
-
`/v0/websets/${websetId}/enrichments/${id}/cancel`,
|
|
390
|
-
"POST"
|
|
391
|
-
);
|
|
168
|
+
return this.request(`/v0/websets/${websetId}/enrichments/${id}/cancel`, "POST");
|
|
392
169
|
}
|
|
393
170
|
};
|
|
394
|
-
|
|
395
|
-
// src/websets/events.ts
|
|
396
171
|
var EventsClient = class extends WebsetsBaseClient {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
172
|
+
async list(options) {
|
|
173
|
+
const queryParams = { ...this.buildPaginationParams(options), types: options?.types, createdBefore: options?.createdBefore, createdAfter: options?.createdAfter };
|
|
174
|
+
return this.request("/v0/events", "GET", void 0, queryParams);
|
|
175
|
+
}
|
|
176
|
+
async get(id) {
|
|
177
|
+
return this.request(`/v0/events/${id}`, "GET");
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
var WebsetMonitorRunsClient = class extends WebsetsBaseClient {
|
|
181
|
+
async list(monitorId) {
|
|
182
|
+
return this.request(`/v0/monitors/${monitorId}/runs`, "GET");
|
|
183
|
+
}
|
|
184
|
+
async get(monitorId, id) {
|
|
185
|
+
return this.request(`/v0/monitors/${monitorId}/runs/${id}`, "GET");
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
var WebsetMonitorsClient = class extends WebsetsBaseClient {
|
|
401
189
|
constructor(client) {
|
|
402
190
|
super(client);
|
|
191
|
+
this.runs = new WebsetMonitorRunsClient(client);
|
|
192
|
+
}
|
|
193
|
+
async create(params) {
|
|
194
|
+
return this.request("/v0/monitors", "POST", { ...params });
|
|
403
195
|
}
|
|
404
|
-
/**
|
|
405
|
-
* List all Events
|
|
406
|
-
* @param options Optional filtering and pagination options
|
|
407
|
-
* @returns The list of Events
|
|
408
|
-
*/
|
|
409
196
|
async list(options) {
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
limit: options?.limit,
|
|
413
|
-
types: options?.types
|
|
414
|
-
};
|
|
415
|
-
return this.request(
|
|
416
|
-
"/v0/events",
|
|
417
|
-
"GET",
|
|
418
|
-
void 0,
|
|
419
|
-
params
|
|
420
|
-
);
|
|
197
|
+
const queryParams = { ...this.buildPaginationParams(options), websetId: options?.websetId };
|
|
198
|
+
return this.request("/v0/monitors", "GET", void 0, queryParams);
|
|
421
199
|
}
|
|
422
|
-
/**
|
|
423
|
-
* Get an Event by ID
|
|
424
|
-
* @param id The ID of the Event
|
|
425
|
-
* @returns The Event
|
|
426
|
-
*/
|
|
427
200
|
async get(id) {
|
|
428
|
-
return this.request(`/v0/
|
|
201
|
+
return this.request(`/v0/monitors/${id}`, "GET");
|
|
429
202
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
203
|
+
async update(id, params) {
|
|
204
|
+
return this.request(`/v0/monitors/${id}`, "PATCH", { ...params });
|
|
205
|
+
}
|
|
206
|
+
async delete(id) {
|
|
207
|
+
return this.request(`/v0/monitors/${id}`, "DELETE");
|
|
208
|
+
}
|
|
209
|
+
/** Iterate through all monitors, handling pagination automatically. */
|
|
435
210
|
async *listAll(options) {
|
|
436
211
|
let cursor = void 0;
|
|
437
212
|
const pageOptions = options ? { ...options } : {};
|
|
438
213
|
while (true) {
|
|
439
|
-
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
yield event;
|
|
214
|
+
const response = await this.list({ ...pageOptions, cursor });
|
|
215
|
+
for (const monitor of response.data) {
|
|
216
|
+
yield monitor;
|
|
443
217
|
}
|
|
444
218
|
if (!response.hasMore || !response.nextCursor) {
|
|
445
219
|
break;
|
|
@@ -447,645 +221,833 @@ var EventsClient = class extends WebsetsBaseClient {
|
|
|
447
221
|
cursor = response.nextCursor;
|
|
448
222
|
}
|
|
449
223
|
}
|
|
450
|
-
/**
|
|
451
|
-
* Collect all Events into an array
|
|
452
|
-
* @param options Filtering and pagination options
|
|
453
|
-
* @returns Promise resolving to an array of all Events
|
|
454
|
-
*/
|
|
224
|
+
/** Collect all monitors into an array. */
|
|
455
225
|
async getAll(options) {
|
|
456
|
-
const
|
|
457
|
-
for await (const
|
|
458
|
-
|
|
226
|
+
const monitors = [];
|
|
227
|
+
for await (const monitor of this.listAll(options)) {
|
|
228
|
+
monitors.push(monitor);
|
|
229
|
+
}
|
|
230
|
+
return monitors;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
var WebsetWebhooksClient = class extends WebsetsBaseClient {
|
|
234
|
+
async create(params) {
|
|
235
|
+
return this.request("/v0/webhooks", "POST", { ...params });
|
|
236
|
+
}
|
|
237
|
+
async list(options) {
|
|
238
|
+
const queryParams = this.buildPaginationParams(options);
|
|
239
|
+
return this.request("/v0/webhooks", "GET", void 0, queryParams);
|
|
240
|
+
}
|
|
241
|
+
async get(id) {
|
|
242
|
+
return this.request(`/v0/webhooks/${id}`, "GET");
|
|
243
|
+
}
|
|
244
|
+
async update(id, params) {
|
|
245
|
+
return this.request(`/v0/webhooks/${id}`, "PATCH", { ...params });
|
|
246
|
+
}
|
|
247
|
+
async delete(id) {
|
|
248
|
+
return this.request(`/v0/webhooks/${id}`, "DELETE");
|
|
249
|
+
}
|
|
250
|
+
async listAttempts(id, options) {
|
|
251
|
+
const queryParams = { ...this.buildPaginationParams(options), eventType: options?.eventType, successful: options?.successful };
|
|
252
|
+
return this.request(`/v0/webhooks/${id}/attempts`, "GET", void 0, queryParams);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
var ImportsClient = class extends WebsetsBaseClient {
|
|
256
|
+
async create(params) {
|
|
257
|
+
return this.request("/v0/imports", "POST", { ...params });
|
|
258
|
+
}
|
|
259
|
+
async list(options) {
|
|
260
|
+
const queryParams = this.buildPaginationParams(options);
|
|
261
|
+
return this.request("/v0/imports", "GET", void 0, queryParams);
|
|
262
|
+
}
|
|
263
|
+
async get(id) {
|
|
264
|
+
return this.request(`/v0/imports/${id}`, "GET");
|
|
265
|
+
}
|
|
266
|
+
async update(id, params) {
|
|
267
|
+
return this.request(`/v0/imports/${id}`, "PATCH", { ...params });
|
|
268
|
+
}
|
|
269
|
+
async delete(id) {
|
|
270
|
+
return this.request(`/v0/imports/${id}`, "DELETE");
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
var WebsetsClient = class extends WebsetsBaseClient {
|
|
274
|
+
constructor(client) {
|
|
275
|
+
super(client);
|
|
276
|
+
this.items = new WebsetItemsClient(client);
|
|
277
|
+
this.searches = new WebsetSearchesClient(client);
|
|
278
|
+
this.enrichments = new WebsetEnrichmentsClient(client);
|
|
279
|
+
this.events = new EventsClient(client);
|
|
280
|
+
this.monitors = new WebsetMonitorsClient(client);
|
|
281
|
+
this.webhooks = new WebsetWebhooksClient(client);
|
|
282
|
+
this.imports = new ImportsClient(client);
|
|
283
|
+
}
|
|
284
|
+
async create(params, options) {
|
|
285
|
+
return this.request("/v0/websets", "POST", { ...params }, void 0, options?.headers);
|
|
286
|
+
}
|
|
287
|
+
async list(options) {
|
|
288
|
+
const queryParams = { ...this.buildPaginationParams(options), search: options?.search };
|
|
289
|
+
return this.request("/v0/websets", "GET", void 0, queryParams);
|
|
290
|
+
}
|
|
291
|
+
async get(id, options) {
|
|
292
|
+
const queryParams = { expand: options?.expand };
|
|
293
|
+
return this.request(`/v0/websets/${id}`, "GET", void 0, queryParams);
|
|
294
|
+
}
|
|
295
|
+
async update(id, params) {
|
|
296
|
+
return this.request(`/v0/websets/${id}`, "POST", { ...params });
|
|
297
|
+
}
|
|
298
|
+
async delete(id) {
|
|
299
|
+
return this.request(`/v0/websets/${id}`, "DELETE");
|
|
300
|
+
}
|
|
301
|
+
async cancel(id) {
|
|
302
|
+
return this.request(`/v0/websets/${id}/cancel`, "POST");
|
|
303
|
+
}
|
|
304
|
+
async preview(params, options) {
|
|
305
|
+
const queryParams = { search: options?.search };
|
|
306
|
+
return this.request("/v0/websets/preview", "POST", { ...params }, queryParams);
|
|
307
|
+
}
|
|
308
|
+
/** Iterate through all Websets, handling pagination automatically. */
|
|
309
|
+
async *listAll(options) {
|
|
310
|
+
let cursor = void 0;
|
|
311
|
+
const pageOptions = options ? { ...options } : {};
|
|
312
|
+
while (true) {
|
|
313
|
+
const response = await this.list({ ...pageOptions, cursor });
|
|
314
|
+
for (const webset of response.data) {
|
|
315
|
+
yield webset;
|
|
316
|
+
}
|
|
317
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
cursor = response.nextCursor;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/** Collect all Websets into an array. */
|
|
324
|
+
async getAll(options) {
|
|
325
|
+
const websets = [];
|
|
326
|
+
for await (const webset of this.listAll(options)) {
|
|
327
|
+
websets.push(webset);
|
|
328
|
+
}
|
|
329
|
+
return websets;
|
|
330
|
+
}
|
|
331
|
+
/** Poll until a Webset reaches idle status. */
|
|
332
|
+
async waitUntilIdle(id, options) {
|
|
333
|
+
let timeout;
|
|
334
|
+
let pollInterval = 1e3;
|
|
335
|
+
let onPoll;
|
|
336
|
+
if (typeof options === "number") {
|
|
337
|
+
timeout = options;
|
|
338
|
+
} else if (options) {
|
|
339
|
+
timeout = options.timeout;
|
|
340
|
+
pollInterval = options.pollInterval || 1e3;
|
|
341
|
+
onPoll = options.onPoll;
|
|
342
|
+
}
|
|
343
|
+
const startTime = Date.now();
|
|
344
|
+
while (true) {
|
|
345
|
+
const webset = await this.get(id);
|
|
346
|
+
if (onPoll) onPoll(webset.status);
|
|
347
|
+
if (webset.status === "idle") return webset;
|
|
348
|
+
if (timeout && Date.now() - startTime > timeout) {
|
|
349
|
+
throw new Error(`Webset ${id} did not reach idle state within ${timeout}ms. Current status: ${webset.status}`);
|
|
350
|
+
}
|
|
351
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
459
352
|
}
|
|
460
|
-
return events;
|
|
461
353
|
}
|
|
462
354
|
};
|
|
463
355
|
|
|
464
|
-
// src/
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
EventType2["monitor_created"] = "monitor.created";
|
|
498
|
-
EventType2["monitor_updated"] = "monitor.updated";
|
|
499
|
-
EventType2["monitor_deleted"] = "monitor.deleted";
|
|
500
|
-
EventType2["monitor_run_created"] = "monitor.run.created";
|
|
501
|
-
EventType2["monitor_run_completed"] = "monitor.run.completed";
|
|
502
|
-
EventType2["webset_export_created"] = "webset.export.created";
|
|
503
|
-
EventType2["webset_export_completed"] = "webset.export.completed";
|
|
504
|
-
return EventType2;
|
|
505
|
-
})(EventType || {});
|
|
506
|
-
var ImportFailedReason = /* @__PURE__ */ ((ImportFailedReason2) => {
|
|
507
|
-
ImportFailedReason2["invalid_format"] = "invalid_format";
|
|
508
|
-
ImportFailedReason2["invalid_file_content"] = "invalid_file_content";
|
|
509
|
-
ImportFailedReason2["missing_identifier"] = "missing_identifier";
|
|
510
|
-
return ImportFailedReason2;
|
|
511
|
-
})(ImportFailedReason || {});
|
|
512
|
-
var ImportFormat = /* @__PURE__ */ ((ImportFormat2) => {
|
|
513
|
-
ImportFormat2["csv"] = "csv";
|
|
514
|
-
ImportFormat2["webset"] = "webset";
|
|
515
|
-
return ImportFormat2;
|
|
516
|
-
})(ImportFormat || {});
|
|
517
|
-
var ImportObject = /* @__PURE__ */ ((ImportObject2) => {
|
|
518
|
-
ImportObject2["import"] = "import";
|
|
519
|
-
return ImportObject2;
|
|
520
|
-
})(ImportObject || {});
|
|
521
|
-
var ImportStatus = /* @__PURE__ */ ((ImportStatus2) => {
|
|
522
|
-
ImportStatus2["pending"] = "pending";
|
|
523
|
-
ImportStatus2["processing"] = "processing";
|
|
524
|
-
ImportStatus2["completed"] = "completed";
|
|
525
|
-
ImportStatus2["failed"] = "failed";
|
|
526
|
-
return ImportStatus2;
|
|
527
|
-
})(ImportStatus || {});
|
|
528
|
-
var MonitorObject = /* @__PURE__ */ ((MonitorObject2) => {
|
|
529
|
-
MonitorObject2["monitor"] = "monitor";
|
|
530
|
-
return MonitorObject2;
|
|
531
|
-
})(MonitorObject || {});
|
|
532
|
-
var MonitorStatus = /* @__PURE__ */ ((MonitorStatus2) => {
|
|
533
|
-
MonitorStatus2["enabled"] = "enabled";
|
|
534
|
-
MonitorStatus2["disabled"] = "disabled";
|
|
535
|
-
return MonitorStatus2;
|
|
536
|
-
})(MonitorStatus || {});
|
|
537
|
-
var MonitorRunObject = /* @__PURE__ */ ((MonitorRunObject2) => {
|
|
538
|
-
MonitorRunObject2["monitor_run"] = "monitor_run";
|
|
539
|
-
return MonitorRunObject2;
|
|
540
|
-
})(MonitorRunObject || {});
|
|
541
|
-
var MonitorRunStatus = /* @__PURE__ */ ((MonitorRunStatus2) => {
|
|
542
|
-
MonitorRunStatus2["created"] = "created";
|
|
543
|
-
MonitorRunStatus2["running"] = "running";
|
|
544
|
-
MonitorRunStatus2["completed"] = "completed";
|
|
545
|
-
MonitorRunStatus2["canceled"] = "canceled";
|
|
546
|
-
MonitorRunStatus2["failed"] = "failed";
|
|
547
|
-
return MonitorRunStatus2;
|
|
548
|
-
})(MonitorRunStatus || {});
|
|
549
|
-
var MonitorRunType = /* @__PURE__ */ ((MonitorRunType2) => {
|
|
550
|
-
MonitorRunType2["search"] = "search";
|
|
551
|
-
MonitorRunType2["refresh"] = "refresh";
|
|
552
|
-
return MonitorRunType2;
|
|
553
|
-
})(MonitorRunType || {});
|
|
554
|
-
var UpdateMonitorStatus = /* @__PURE__ */ ((UpdateMonitorStatus2) => {
|
|
555
|
-
UpdateMonitorStatus2["enabled"] = "enabled";
|
|
556
|
-
UpdateMonitorStatus2["disabled"] = "disabled";
|
|
557
|
-
return UpdateMonitorStatus2;
|
|
558
|
-
})(UpdateMonitorStatus || {});
|
|
559
|
-
var WebhookStatus = /* @__PURE__ */ ((WebhookStatus2) => {
|
|
560
|
-
WebhookStatus2["active"] = "active";
|
|
561
|
-
WebhookStatus2["inactive"] = "inactive";
|
|
562
|
-
return WebhookStatus2;
|
|
563
|
-
})(WebhookStatus || {});
|
|
564
|
-
var WebsetStatus = /* @__PURE__ */ ((WebsetStatus2) => {
|
|
565
|
-
WebsetStatus2["idle"] = "idle";
|
|
566
|
-
WebsetStatus2["pending"] = "pending";
|
|
567
|
-
WebsetStatus2["running"] = "running";
|
|
568
|
-
WebsetStatus2["paused"] = "paused";
|
|
569
|
-
return WebsetStatus2;
|
|
570
|
-
})(WebsetStatus || {});
|
|
571
|
-
var WebsetEnrichmentStatus = /* @__PURE__ */ ((WebsetEnrichmentStatus2) => {
|
|
572
|
-
WebsetEnrichmentStatus2["pending"] = "pending";
|
|
573
|
-
WebsetEnrichmentStatus2["canceled"] = "canceled";
|
|
574
|
-
WebsetEnrichmentStatus2["completed"] = "completed";
|
|
575
|
-
return WebsetEnrichmentStatus2;
|
|
576
|
-
})(WebsetEnrichmentStatus || {});
|
|
577
|
-
var WebsetEnrichmentFormat = /* @__PURE__ */ ((WebsetEnrichmentFormat2) => {
|
|
578
|
-
WebsetEnrichmentFormat2["text"] = "text";
|
|
579
|
-
WebsetEnrichmentFormat2["date"] = "date";
|
|
580
|
-
WebsetEnrichmentFormat2["number"] = "number";
|
|
581
|
-
WebsetEnrichmentFormat2["options"] = "options";
|
|
582
|
-
WebsetEnrichmentFormat2["email"] = "email";
|
|
583
|
-
WebsetEnrichmentFormat2["phone"] = "phone";
|
|
584
|
-
WebsetEnrichmentFormat2["url"] = "url";
|
|
585
|
-
return WebsetEnrichmentFormat2;
|
|
586
|
-
})(WebsetEnrichmentFormat || {});
|
|
587
|
-
var WebsetItemSource = /* @__PURE__ */ ((WebsetItemSource2) => {
|
|
588
|
-
WebsetItemSource2["search"] = "search";
|
|
589
|
-
WebsetItemSource2["import"] = "import";
|
|
590
|
-
return WebsetItemSource2;
|
|
591
|
-
})(WebsetItemSource || {});
|
|
592
|
-
var WebsetItemEvaluationSatisfied = /* @__PURE__ */ ((WebsetItemEvaluationSatisfied2) => {
|
|
593
|
-
WebsetItemEvaluationSatisfied2["yes"] = "yes";
|
|
594
|
-
WebsetItemEvaluationSatisfied2["no"] = "no";
|
|
595
|
-
WebsetItemEvaluationSatisfied2["unclear"] = "unclear";
|
|
596
|
-
return WebsetItemEvaluationSatisfied2;
|
|
597
|
-
})(WebsetItemEvaluationSatisfied || {});
|
|
598
|
-
var WebsetExcludeSource = /* @__PURE__ */ ((WebsetExcludeSource2) => {
|
|
599
|
-
WebsetExcludeSource2["import"] = "import";
|
|
600
|
-
WebsetExcludeSource2["webset"] = "webset";
|
|
601
|
-
return WebsetExcludeSource2;
|
|
602
|
-
})(WebsetExcludeSource || {});
|
|
603
|
-
var WebsetSearchScopeSource = /* @__PURE__ */ ((WebsetSearchScopeSource2) => {
|
|
604
|
-
WebsetSearchScopeSource2["import"] = "import";
|
|
605
|
-
WebsetSearchScopeSource2["webset"] = "webset";
|
|
606
|
-
return WebsetSearchScopeSource2;
|
|
607
|
-
})(WebsetSearchScopeSource || {});
|
|
608
|
-
var WebsetSearchStatus = /* @__PURE__ */ ((WebsetSearchStatus2) => {
|
|
609
|
-
WebsetSearchStatus2["created"] = "created";
|
|
610
|
-
WebsetSearchStatus2["pending"] = "pending";
|
|
611
|
-
WebsetSearchStatus2["running"] = "running";
|
|
612
|
-
WebsetSearchStatus2["completed"] = "completed";
|
|
613
|
-
WebsetSearchStatus2["canceled"] = "canceled";
|
|
614
|
-
return WebsetSearchStatus2;
|
|
615
|
-
})(WebsetSearchStatus || {});
|
|
616
|
-
var WebsetSearchBehavior = /* @__PURE__ */ ((WebsetSearchBehavior2) => {
|
|
617
|
-
WebsetSearchBehavior2["override"] = "override";
|
|
618
|
-
WebsetSearchBehavior2["append"] = "append";
|
|
619
|
-
return WebsetSearchBehavior2;
|
|
620
|
-
})(WebsetSearchBehavior || {});
|
|
621
|
-
var WebsetSearchCanceledReason = /* @__PURE__ */ ((WebsetSearchCanceledReason2) => {
|
|
622
|
-
WebsetSearchCanceledReason2["webset_deleted"] = "webset_deleted";
|
|
623
|
-
WebsetSearchCanceledReason2["webset_canceled"] = "webset_canceled";
|
|
624
|
-
return WebsetSearchCanceledReason2;
|
|
625
|
-
})(WebsetSearchCanceledReason || {});
|
|
626
|
-
|
|
627
|
-
// src/websets/imports.ts
|
|
628
|
-
var ImportsClient = class extends WebsetsBaseClient {
|
|
629
|
-
async create(params, csv) {
|
|
630
|
-
if (csv === void 0) {
|
|
631
|
-
return this.request(
|
|
632
|
-
"/v0/imports",
|
|
633
|
-
"POST",
|
|
634
|
-
params
|
|
635
|
-
);
|
|
636
|
-
}
|
|
637
|
-
let csvBuffer;
|
|
638
|
-
if (typeof csv === "string") {
|
|
639
|
-
csvBuffer = Buffer.from(csv, "utf8");
|
|
640
|
-
} else if (Buffer.isBuffer(csv)) {
|
|
641
|
-
csvBuffer = csv;
|
|
642
|
-
} else {
|
|
643
|
-
throw new ExaError(
|
|
644
|
-
"Invalid CSV data input. Must be string or Buffer",
|
|
645
|
-
400 /* BadRequest */
|
|
646
|
-
);
|
|
356
|
+
// src/nova/research-client.ts
|
|
357
|
+
import { ZodType } from "zod";
|
|
358
|
+
import { zodToJsonSchema as zodToJsonSchemaLib } from "zod-to-json-schema";
|
|
359
|
+
function zodToJsonSchema(schema) {
|
|
360
|
+
return zodToJsonSchemaLib(schema, { $refStrategy: "none" });
|
|
361
|
+
}
|
|
362
|
+
var ResearchBaseClient = class {
|
|
363
|
+
constructor(client) {
|
|
364
|
+
this.client = client;
|
|
365
|
+
}
|
|
366
|
+
/** Make a request to the API, prepending `/research/v1` to the path. */
|
|
367
|
+
async request(endpoint, method = "POST", data, params) {
|
|
368
|
+
return this.client.request(`/research/v1${endpoint}`, method, data, params);
|
|
369
|
+
}
|
|
370
|
+
buildPaginationParams(pagination) {
|
|
371
|
+
const params = {};
|
|
372
|
+
if (!pagination) return params;
|
|
373
|
+
if (pagination.cursor) params.cursor = pagination.cursor;
|
|
374
|
+
if (pagination.limit) params.limit = pagination.limit;
|
|
375
|
+
return params;
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
var ResearchClient = class extends ResearchBaseClient {
|
|
379
|
+
/** List research requests. */
|
|
380
|
+
async list(options) {
|
|
381
|
+
const params = this.buildPaginationParams(options);
|
|
382
|
+
return this.client.request("/research/v1", "GET", void 0, params);
|
|
383
|
+
}
|
|
384
|
+
/** Create a new research request. Defaults model to "exa-research-fast" if not provided. */
|
|
385
|
+
async create(params) {
|
|
386
|
+
let schema = params.outputSchema;
|
|
387
|
+
if (schema instanceof ZodType) {
|
|
388
|
+
schema = zodToJsonSchema(schema);
|
|
647
389
|
}
|
|
648
|
-
const
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
throw new ExaError(
|
|
655
|
-
`CSV file too large: ${sizeInMB}MB. Maximum size is 50MB.`,
|
|
656
|
-
400 /* BadRequest */
|
|
657
|
-
);
|
|
390
|
+
const payload = {
|
|
391
|
+
instructions: params.instructions,
|
|
392
|
+
model: params.model ?? "exa-research-fast"
|
|
393
|
+
};
|
|
394
|
+
if (schema) {
|
|
395
|
+
payload.outputSchema = schema;
|
|
658
396
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
397
|
+
return this.client.request("/research/v1", "POST", payload, void 0);
|
|
398
|
+
}
|
|
399
|
+
/** Get a research request by ID. */
|
|
400
|
+
async get(researchId, options) {
|
|
401
|
+
const params = {};
|
|
402
|
+
if (options?.events !== void 0) params.events = options.events.toString();
|
|
403
|
+
return this.client.request(`/research/v1/${researchId}`, "GET", void 0, params);
|
|
404
|
+
}
|
|
405
|
+
/** Poll a research request until it reaches a terminal state (completed, failed, or canceled). */
|
|
406
|
+
async pollUntilFinished(researchId, options) {
|
|
407
|
+
const pollInterval = options?.pollInterval ?? 1e3;
|
|
408
|
+
const timeoutMs = options?.timeoutMs ?? 10 * 60 * 1e3;
|
|
409
|
+
const maxConsecutiveFailures = 5;
|
|
410
|
+
const startTime = Date.now();
|
|
411
|
+
let consecutiveFailures = 0;
|
|
412
|
+
while (true) {
|
|
413
|
+
try {
|
|
414
|
+
const research = await this.get(researchId, { events: options?.events });
|
|
415
|
+
consecutiveFailures = 0;
|
|
416
|
+
if (research.status === "completed" || research.status === "failed" || research.status === "canceled") {
|
|
417
|
+
return research;
|
|
418
|
+
}
|
|
419
|
+
} catch (err) {
|
|
420
|
+
consecutiveFailures += 1;
|
|
421
|
+
if (consecutiveFailures >= maxConsecutiveFailures) {
|
|
422
|
+
throw new Error(`Polling failed ${maxConsecutiveFailures} times in a row for research ${researchId}: ${err}`);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
if (Date.now() - startTime > timeoutMs) {
|
|
426
|
+
throw new Error(`Polling timeout: Research ${researchId} did not complete within ${timeoutMs}ms`);
|
|
427
|
+
}
|
|
428
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
664
429
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
// src/nova/client.ts
|
|
434
|
+
function isRecord(value) {
|
|
435
|
+
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
436
|
+
}
|
|
437
|
+
var ExaError = class extends Error {
|
|
438
|
+
constructor(message, statusCode, timestamp, path, details) {
|
|
439
|
+
super(message);
|
|
440
|
+
this.name = "ExaError";
|
|
441
|
+
this.statusCode = statusCode;
|
|
442
|
+
this.timestamp = timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
443
|
+
this.path = path;
|
|
444
|
+
this.details = details;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
var CONTENTS_FIELDS = /* @__PURE__ */ new Set(["text", "highlights", "summary", "subpages", "subpageTarget", "extras", "livecrawl", "livecrawlTimeout", "maxAgeHours", "filterEmptyResults", "context"]);
|
|
448
|
+
var DEFAULT_MAX_CHARACTERS = 1e4;
|
|
449
|
+
var Exa = class {
|
|
450
|
+
constructor(apiKey, baseURL = "https://api.exa.ai") {
|
|
451
|
+
this.baseURL = baseURL;
|
|
452
|
+
if (!apiKey) {
|
|
453
|
+
apiKey = typeof process !== "undefined" ? process.env?.EXA_API_KEY : void 0;
|
|
454
|
+
if (!apiKey) {
|
|
686
455
|
throw new ExaError(
|
|
687
|
-
|
|
688
|
-
|
|
456
|
+
"API key must be provided as an argument or as an environment variable (EXA_API_KEY)",
|
|
457
|
+
401
|
|
689
458
|
);
|
|
690
459
|
}
|
|
691
|
-
} catch (error) {
|
|
692
|
-
if (error instanceof ExaError) {
|
|
693
|
-
throw error;
|
|
694
|
-
}
|
|
695
|
-
throw new ExaError(
|
|
696
|
-
`Failed to upload CSV data: ${error.message}`,
|
|
697
|
-
400 /* BadRequest */
|
|
698
|
-
);
|
|
699
460
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
*/
|
|
707
|
-
async get(id) {
|
|
708
|
-
return this.request(`/v0/imports/${id}`, "GET");
|
|
461
|
+
this.headers = {
|
|
462
|
+
"x-api-key": apiKey,
|
|
463
|
+
"Content-Type": "application/json"
|
|
464
|
+
};
|
|
465
|
+
this.websets = new WebsetsClient(this);
|
|
466
|
+
this.research = new ResearchClient(this);
|
|
709
467
|
}
|
|
710
|
-
/**
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
468
|
+
/** Make a request to the Exa API. Used by sub-clients and available for direct use. */
|
|
469
|
+
async request(endpoint, method, body, params, headers) {
|
|
470
|
+
const url = this.buildRequestUrl(endpoint, params);
|
|
471
|
+
const normalizedBody = this.normalizeCategoryInBody(body);
|
|
472
|
+
const combinedHeaders = headers ? { ...this.headers, ...headers } : this.headers;
|
|
473
|
+
const response = await fetch(url, {
|
|
474
|
+
method,
|
|
475
|
+
headers: combinedHeaders,
|
|
476
|
+
body: normalizedBody ? JSON.stringify(normalizedBody) : void 0
|
|
477
|
+
});
|
|
478
|
+
if (!response.ok) {
|
|
479
|
+
throw await this.toExaError(response, endpoint);
|
|
480
|
+
}
|
|
481
|
+
return await response.json();
|
|
723
482
|
}
|
|
724
|
-
/**
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
483
|
+
/** Make a raw request returning the Response object directly. */
|
|
484
|
+
async rawRequest(endpoint, method = "POST", body, params) {
|
|
485
|
+
const url = this.buildRequestUrl(endpoint, params);
|
|
486
|
+
const normalizedBody = this.normalizeCategoryInBody(body);
|
|
487
|
+
return fetch(url, {
|
|
488
|
+
method,
|
|
489
|
+
headers: this.headers,
|
|
490
|
+
body: normalizedBody ? JSON.stringify(normalizedBody) : void 0
|
|
491
|
+
});
|
|
732
492
|
}
|
|
733
|
-
/**
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
return this.request(`/v0/imports/${id}`, "DELETE");
|
|
493
|
+
/** Normalize category values to underscore form. */
|
|
494
|
+
normalizeCategoryInBody(body) {
|
|
495
|
+
if (body == null || typeof body.category !== "string") {
|
|
496
|
+
return body;
|
|
497
|
+
}
|
|
498
|
+
return { ...body, category: body.category.replace(/ /g, "_") };
|
|
740
499
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
const importItem = await this.get(id);
|
|
755
|
-
if (onPoll) {
|
|
756
|
-
onPoll(importItem.status);
|
|
500
|
+
buildRequestUrl(endpoint, params) {
|
|
501
|
+
let url = `${this.baseURL}${endpoint}`;
|
|
502
|
+
if (params == null || Object.keys(params).length === 0) {
|
|
503
|
+
return url;
|
|
504
|
+
}
|
|
505
|
+
const searchParams = new URLSearchParams();
|
|
506
|
+
for (const [key, value] of Object.entries(params)) {
|
|
507
|
+
if (Array.isArray(value)) {
|
|
508
|
+
for (const item of value) {
|
|
509
|
+
searchParams.append(key, item);
|
|
510
|
+
}
|
|
511
|
+
} else if (value !== void 0) {
|
|
512
|
+
searchParams.append(key, String(value));
|
|
757
513
|
}
|
|
758
|
-
|
|
759
|
-
|
|
514
|
+
}
|
|
515
|
+
url += `?${searchParams.toString()}`;
|
|
516
|
+
return url;
|
|
517
|
+
}
|
|
518
|
+
tryParseJsonRecord(text) {
|
|
519
|
+
if (text.length === 0) {
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
try {
|
|
523
|
+
const parsed = JSON.parse(text);
|
|
524
|
+
return isRecord(parsed) ? parsed : null;
|
|
525
|
+
} catch {
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
async toExaError(response, endpoint) {
|
|
530
|
+
const text = await response.text();
|
|
531
|
+
const parsed = this.tryParseJsonRecord(text);
|
|
532
|
+
const statusCode = parsed != null && typeof parsed.statusCode === "number" ? parsed.statusCode : response.status;
|
|
533
|
+
const timestamp = parsed != null && typeof parsed.timestamp === "string" ? parsed.timestamp : void 0;
|
|
534
|
+
const path = parsed != null && typeof parsed.path === "string" ? parsed.path : endpoint;
|
|
535
|
+
const errorMessage = parsed != null && typeof parsed.error === "string" ? parsed.error : void 0;
|
|
536
|
+
const detailMessage = parsed != null && typeof parsed.message === "string" ? parsed.message : void 0;
|
|
537
|
+
let message;
|
|
538
|
+
if (errorMessage != null && detailMessage != null) {
|
|
539
|
+
message = `${errorMessage}. ${detailMessage}`;
|
|
540
|
+
} else if (errorMessage != null) {
|
|
541
|
+
message = errorMessage;
|
|
542
|
+
} else if (detailMessage != null) {
|
|
543
|
+
message = detailMessage;
|
|
544
|
+
} else if (text.length > 0) {
|
|
545
|
+
message = text;
|
|
546
|
+
} else {
|
|
547
|
+
message = `Exa API error ${response.status}`;
|
|
548
|
+
}
|
|
549
|
+
return new ExaError(message, statusCode, timestamp, path, parsed ?? text);
|
|
550
|
+
}
|
|
551
|
+
parseAnswerStreamLine(line) {
|
|
552
|
+
if (!line.startsWith("data:")) {
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
const jsonStr = line.replace(/^data:\s*/, "").trim();
|
|
556
|
+
if (jsonStr.length === 0 || jsonStr === "[DONE]") {
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
let parsedChunk;
|
|
560
|
+
try {
|
|
561
|
+
parsedChunk = JSON.parse(jsonStr);
|
|
562
|
+
} catch {
|
|
563
|
+
return null;
|
|
564
|
+
}
|
|
565
|
+
if (!isRecord(parsedChunk)) {
|
|
566
|
+
return null;
|
|
567
|
+
}
|
|
568
|
+
let content;
|
|
569
|
+
const choices = parsedChunk.choices;
|
|
570
|
+
if (Array.isArray(choices) && choices.length > 0 && isRecord(choices[0])) {
|
|
571
|
+
const delta = choices[0].delta;
|
|
572
|
+
if (isRecord(delta) && typeof delta.content === "string") {
|
|
573
|
+
content = delta.content;
|
|
760
574
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
575
|
+
}
|
|
576
|
+
let citations;
|
|
577
|
+
if (Array.isArray(parsedChunk.citations)) {
|
|
578
|
+
const normalized = [];
|
|
579
|
+
for (const citation of parsedChunk.citations) {
|
|
580
|
+
if (!isRecord(citation)) {
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
const id = typeof citation.id === "string" ? citation.id : void 0;
|
|
584
|
+
const url = typeof citation.url === "string" ? citation.url : void 0;
|
|
585
|
+
const title = typeof citation.title === "string" ? citation.title : void 0;
|
|
586
|
+
const publishedDate = typeof citation.publishedDate === "string" ? citation.publishedDate : void 0;
|
|
587
|
+
const author = typeof citation.author === "string" ? citation.author : void 0;
|
|
588
|
+
const text = typeof citation.text === "string" ? citation.text : void 0;
|
|
589
|
+
normalized.push({
|
|
590
|
+
...id != null ? { id } : {},
|
|
591
|
+
...url != null ? { url } : {},
|
|
592
|
+
...title != null ? { title } : {},
|
|
593
|
+
...publishedDate != null ? { publishedDate } : {},
|
|
594
|
+
...author != null ? { author } : {},
|
|
595
|
+
...text != null ? { text } : {}
|
|
596
|
+
});
|
|
766
597
|
}
|
|
767
|
-
if (
|
|
768
|
-
|
|
769
|
-
`Import ${id} did not complete within ${timeout}ms. Current status: ${importItem.status}`,
|
|
770
|
-
408 /* RequestTimeout */
|
|
771
|
-
);
|
|
598
|
+
if (normalized.length > 0) {
|
|
599
|
+
citations = normalized;
|
|
772
600
|
}
|
|
773
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
774
601
|
}
|
|
602
|
+
if (content == null && (citations == null || citations.length === 0)) {
|
|
603
|
+
return null;
|
|
604
|
+
}
|
|
605
|
+
return {
|
|
606
|
+
...content != null ? { content } : {},
|
|
607
|
+
...citations != null ? { citations } : {}
|
|
608
|
+
};
|
|
775
609
|
}
|
|
776
|
-
/**
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
for (const importItem of response.data) {
|
|
788
|
-
yield importItem;
|
|
789
|
-
}
|
|
790
|
-
if (!response.hasMore || !response.nextCursor) {
|
|
791
|
-
break;
|
|
610
|
+
/** Separate content-specific options from search/filter options. */
|
|
611
|
+
extractContentsOptions(options) {
|
|
612
|
+
const contentsOptions = {};
|
|
613
|
+
const restOptions = {};
|
|
614
|
+
let hasContentField = false;
|
|
615
|
+
for (const [key, value] of Object.entries(options)) {
|
|
616
|
+
if (CONTENTS_FIELDS.has(key)) {
|
|
617
|
+
contentsOptions[key] = value;
|
|
618
|
+
hasContentField = true;
|
|
619
|
+
} else {
|
|
620
|
+
restOptions[key] = value;
|
|
792
621
|
}
|
|
793
|
-
cursor = response.nextCursor;
|
|
794
622
|
}
|
|
623
|
+
if (!hasContentField) {
|
|
624
|
+
contentsOptions.text = { maxCharacters: DEFAULT_MAX_CHARACTERS };
|
|
625
|
+
}
|
|
626
|
+
return { contentsOptions, restOptions };
|
|
795
627
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
628
|
+
search(query, options) {
|
|
629
|
+
let body;
|
|
630
|
+
if (options === void 0 || !("contents" in options)) {
|
|
631
|
+
body = { query, ...options, contents: { text: { maxCharacters: DEFAULT_MAX_CHARACTERS } } };
|
|
632
|
+
} else if (options.contents === false || options.contents === null || options.contents === void 0) {
|
|
633
|
+
const { contents, ...restOptions } = options;
|
|
634
|
+
body = { query, ...restOptions };
|
|
635
|
+
} else {
|
|
636
|
+
body = { query, ...options };
|
|
805
637
|
}
|
|
806
|
-
return
|
|
638
|
+
return this.request("/search", "POST", body);
|
|
807
639
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
const queryParams = {
|
|
820
|
-
...this.buildPaginationParams(params),
|
|
821
|
-
sourceId: params?.sourceId
|
|
822
|
-
};
|
|
823
|
-
return this.request(
|
|
824
|
-
`/v0/websets/${websetId}/items`,
|
|
825
|
-
"GET",
|
|
826
|
-
void 0,
|
|
827
|
-
queryParams
|
|
828
|
-
);
|
|
640
|
+
findSimilar(url, options) {
|
|
641
|
+
let body;
|
|
642
|
+
if (options === void 0 || !("contents" in options)) {
|
|
643
|
+
body = { url, ...options, contents: { text: { maxCharacters: DEFAULT_MAX_CHARACTERS } } };
|
|
644
|
+
} else if (options.contents === false || options.contents === null || options.contents === void 0) {
|
|
645
|
+
const { contents, ...restOptions } = options;
|
|
646
|
+
body = { url, ...restOptions };
|
|
647
|
+
} else {
|
|
648
|
+
body = { url, ...options };
|
|
649
|
+
}
|
|
650
|
+
return this.request("/findSimilar", "POST", body);
|
|
829
651
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
652
|
+
getContents(urls, options) {
|
|
653
|
+
return this.request("/contents", "POST", { urls, ...options });
|
|
654
|
+
}
|
|
655
|
+
answer(query, options) {
|
|
656
|
+
if (options?.stream) {
|
|
657
|
+
throw new ExaError("For streaming responses, please use streamAnswer() instead:\n\nfor await (const chunk of exa.streamAnswer(query)) {\n // Handle chunks\n}", 400);
|
|
658
|
+
}
|
|
659
|
+
return this.request("/answer", "POST", { query, model: "exa", stream: false, text: false, ...options });
|
|
660
|
+
}
|
|
661
|
+
async *streamAnswer(query, options) {
|
|
662
|
+
const response = await this.rawRequest("/answer", "POST", { query, model: "exa", text: false, ...options, stream: true });
|
|
663
|
+
if (!response.ok) {
|
|
664
|
+
throw await this.toExaError(response, "/answer");
|
|
665
|
+
}
|
|
666
|
+
const reader = response.body?.getReader();
|
|
667
|
+
if (!reader) {
|
|
668
|
+
throw new ExaError("No response body available for streaming.", 500, (/* @__PURE__ */ new Date()).toISOString(), "/answer");
|
|
669
|
+
}
|
|
670
|
+
const decoder = new TextDecoder();
|
|
671
|
+
let buffer = "";
|
|
672
|
+
try {
|
|
673
|
+
while (true) {
|
|
674
|
+
const { done, value } = await reader.read();
|
|
675
|
+
if (done) break;
|
|
676
|
+
buffer += decoder.decode(value, { stream: true });
|
|
677
|
+
const lines = buffer.split("\n");
|
|
678
|
+
buffer = lines.pop() ?? "";
|
|
679
|
+
for (const line of lines) {
|
|
680
|
+
const chunk = this.parseAnswerStreamLine(line);
|
|
681
|
+
if (chunk != null) {
|
|
682
|
+
yield chunk;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
844
685
|
}
|
|
845
|
-
|
|
846
|
-
|
|
686
|
+
const trailingChunk = this.parseAnswerStreamLine(buffer);
|
|
687
|
+
if (trailingChunk != null) {
|
|
688
|
+
yield trailingChunk;
|
|
847
689
|
}
|
|
848
|
-
|
|
690
|
+
} finally {
|
|
691
|
+
reader.releaseLock();
|
|
849
692
|
}
|
|
850
693
|
}
|
|
851
694
|
/**
|
|
852
|
-
*
|
|
853
|
-
*
|
|
854
|
-
* @param options Pagination options
|
|
855
|
-
* @returns Promise resolving to an array of all Webset Items
|
|
695
|
+
* @deprecated Use `search()` instead. The search method now returns text contents by default.
|
|
696
|
+
* Search with contents. Extracts content fields (text, highlights, summary, etc.) into a `contents` wrapper.
|
|
856
697
|
*/
|
|
857
|
-
async
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
698
|
+
async searchAndContents(query, options) {
|
|
699
|
+
if (options === void 0) {
|
|
700
|
+
return this.request("/search", "POST", {
|
|
701
|
+
query,
|
|
702
|
+
contents: { text: { maxCharacters: DEFAULT_MAX_CHARACTERS } }
|
|
703
|
+
});
|
|
861
704
|
}
|
|
862
|
-
|
|
705
|
+
const { contentsOptions, restOptions } = this.extractContentsOptions(options);
|
|
706
|
+
return this.request("/search", "POST", { query, contents: contentsOptions, ...restOptions });
|
|
863
707
|
}
|
|
864
708
|
/**
|
|
865
|
-
*
|
|
866
|
-
*
|
|
867
|
-
* @param id The ID of the Item
|
|
868
|
-
* @returns The Webset Item
|
|
709
|
+
* @deprecated Use `findSimilar()` instead. The findSimilar method now returns text contents by default.
|
|
710
|
+
* Find similar with contents. Extracts content fields into a `contents` wrapper.
|
|
869
711
|
*/
|
|
870
|
-
async
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
712
|
+
async findSimilarAndContents(url, options) {
|
|
713
|
+
if (options === void 0) {
|
|
714
|
+
return this.request("/findSimilar", "POST", {
|
|
715
|
+
url,
|
|
716
|
+
contents: { text: { maxCharacters: DEFAULT_MAX_CHARACTERS } }
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
const { contentsOptions, restOptions } = this.extractContentsOptions(options);
|
|
720
|
+
return this.request("/findSimilar", "POST", { url, contents: contentsOptions, ...restOptions });
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
// src/errors.ts
|
|
725
|
+
var HttpStatusCode = /* @__PURE__ */ ((HttpStatusCode2) => {
|
|
726
|
+
HttpStatusCode2[HttpStatusCode2["BadRequest"] = 400] = "BadRequest";
|
|
727
|
+
HttpStatusCode2[HttpStatusCode2["NotFound"] = 404] = "NotFound";
|
|
728
|
+
HttpStatusCode2[HttpStatusCode2["Unauthorized"] = 401] = "Unauthorized";
|
|
729
|
+
HttpStatusCode2[HttpStatusCode2["Forbidden"] = 403] = "Forbidden";
|
|
730
|
+
HttpStatusCode2[HttpStatusCode2["TooManyRequests"] = 429] = "TooManyRequests";
|
|
731
|
+
HttpStatusCode2[HttpStatusCode2["RequestTimeout"] = 408] = "RequestTimeout";
|
|
732
|
+
HttpStatusCode2[HttpStatusCode2["InternalServerError"] = 500] = "InternalServerError";
|
|
733
|
+
HttpStatusCode2[HttpStatusCode2["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
734
|
+
return HttpStatusCode2;
|
|
735
|
+
})(HttpStatusCode || {});
|
|
736
|
+
|
|
737
|
+
// src/zod-utils.ts
|
|
738
|
+
import { ZodType as ZodType2 } from "zod";
|
|
739
|
+
import { zodToJsonSchema as convertZodToJsonSchema } from "zod-to-json-schema";
|
|
740
|
+
function isZodSchema(obj) {
|
|
741
|
+
return obj instanceof ZodType2;
|
|
742
|
+
}
|
|
743
|
+
function zodToJsonSchema2(schema) {
|
|
744
|
+
return convertZodToJsonSchema(schema, {
|
|
745
|
+
$refStrategy: "none"
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// src/research/base.ts
|
|
750
|
+
var ResearchBaseClient2 = class {
|
|
751
|
+
constructor(client) {
|
|
752
|
+
this.client = client;
|
|
875
753
|
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
async delete(websetId, id) {
|
|
883
|
-
return this.request(
|
|
884
|
-
`/v0/websets/${websetId}/items/${id}`,
|
|
885
|
-
"DELETE"
|
|
754
|
+
async request(endpoint, method = "POST", data, params) {
|
|
755
|
+
return this.client.request(
|
|
756
|
+
`/research/v1${endpoint}`,
|
|
757
|
+
method,
|
|
758
|
+
data,
|
|
759
|
+
params
|
|
886
760
|
);
|
|
887
761
|
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
* List all runs for a Monitor
|
|
894
|
-
* @param monitorId The ID of the Monitor
|
|
895
|
-
* @param options Pagination options
|
|
896
|
-
* @returns The list of Monitor runs
|
|
897
|
-
*/
|
|
898
|
-
async list(monitorId, options) {
|
|
899
|
-
const params = this.buildPaginationParams(options);
|
|
900
|
-
return this.request(
|
|
901
|
-
`/v0/monitors/${monitorId}/runs`,
|
|
902
|
-
"GET",
|
|
903
|
-
void 0,
|
|
762
|
+
async rawRequest(endpoint, method = "POST", data, params) {
|
|
763
|
+
return this.client.rawRequest(
|
|
764
|
+
`/research/v1${endpoint}`,
|
|
765
|
+
method,
|
|
766
|
+
data,
|
|
904
767
|
params
|
|
905
768
|
);
|
|
906
769
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
async get(monitorId, runId) {
|
|
914
|
-
return this.request(
|
|
915
|
-
`/v0/monitors/${monitorId}/runs/${runId}`,
|
|
916
|
-
"GET"
|
|
917
|
-
);
|
|
770
|
+
buildPaginationParams(pagination) {
|
|
771
|
+
const params = {};
|
|
772
|
+
if (!pagination) return params;
|
|
773
|
+
if (pagination.cursor) params.cursor = pagination.cursor;
|
|
774
|
+
if (pagination.limit) params.limit = pagination.limit;
|
|
775
|
+
return params;
|
|
918
776
|
}
|
|
919
777
|
};
|
|
920
|
-
|
|
778
|
+
|
|
779
|
+
// src/research/client.ts
|
|
780
|
+
var ResearchClient2 = class extends ResearchBaseClient2 {
|
|
921
781
|
constructor(client) {
|
|
922
782
|
super(client);
|
|
923
|
-
this.runs = new WebsetMonitorRunsClient(client);
|
|
924
783
|
}
|
|
925
|
-
/**
|
|
926
|
-
* Create a Monitor
|
|
927
|
-
* @param params The monitor parameters
|
|
928
|
-
* @returns The created Monitor
|
|
929
|
-
*/
|
|
930
784
|
async create(params) {
|
|
931
|
-
|
|
785
|
+
const { instructions, model, outputSchema } = params;
|
|
786
|
+
let schema = outputSchema;
|
|
787
|
+
if (schema && isZodSchema(schema)) {
|
|
788
|
+
schema = zodToJsonSchema2(schema);
|
|
789
|
+
}
|
|
790
|
+
const payload = {
|
|
791
|
+
instructions,
|
|
792
|
+
model: model ?? "exa-research-fast"
|
|
793
|
+
};
|
|
794
|
+
if (schema) {
|
|
795
|
+
payload.outputSchema = schema;
|
|
796
|
+
}
|
|
797
|
+
return this.request("", "POST", payload);
|
|
932
798
|
}
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
799
|
+
get(researchId, options) {
|
|
800
|
+
if (options?.stream) {
|
|
801
|
+
const promise = async () => {
|
|
802
|
+
const params = { stream: "true" };
|
|
803
|
+
if (options.events !== void 0) {
|
|
804
|
+
params.events = options.events.toString();
|
|
805
|
+
}
|
|
806
|
+
const resp = await this.rawRequest(
|
|
807
|
+
`/${researchId}`,
|
|
808
|
+
"GET",
|
|
809
|
+
void 0,
|
|
810
|
+
params
|
|
811
|
+
);
|
|
812
|
+
if (!resp.body) {
|
|
813
|
+
throw new Error("No response body for SSE stream");
|
|
814
|
+
}
|
|
815
|
+
const reader = resp.body.getReader();
|
|
816
|
+
const decoder = new TextDecoder();
|
|
817
|
+
let buffer = "";
|
|
818
|
+
function processPart(part) {
|
|
819
|
+
const lines = part.split("\n");
|
|
820
|
+
let data = lines.slice(1).join("\n");
|
|
821
|
+
if (data.startsWith("data:")) {
|
|
822
|
+
data = data.slice(5).trimStart();
|
|
823
|
+
}
|
|
824
|
+
try {
|
|
825
|
+
return JSON.parse(data);
|
|
826
|
+
} catch (e) {
|
|
827
|
+
return null;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
async function* streamEvents() {
|
|
831
|
+
while (true) {
|
|
832
|
+
const { done, value } = await reader.read();
|
|
833
|
+
if (done) break;
|
|
834
|
+
buffer += decoder.decode(value, { stream: true });
|
|
835
|
+
let parts = buffer.split("\n\n");
|
|
836
|
+
buffer = parts.pop() ?? "";
|
|
837
|
+
for (const part of parts) {
|
|
838
|
+
const processed = processPart(part);
|
|
839
|
+
if (processed) {
|
|
840
|
+
yield processed;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
if (buffer.trim()) {
|
|
845
|
+
const processed = processPart(buffer.trim());
|
|
846
|
+
if (processed) {
|
|
847
|
+
yield processed;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
return streamEvents();
|
|
852
|
+
};
|
|
853
|
+
return promise();
|
|
854
|
+
} else {
|
|
855
|
+
const params = { stream: "false" };
|
|
856
|
+
if (options?.events !== void 0) {
|
|
857
|
+
params.events = options.events.toString();
|
|
858
|
+
}
|
|
859
|
+
return this.request(
|
|
860
|
+
`/${researchId}`,
|
|
861
|
+
"GET",
|
|
862
|
+
void 0,
|
|
863
|
+
params
|
|
864
|
+
);
|
|
865
|
+
}
|
|
940
866
|
}
|
|
941
|
-
/**
|
|
942
|
-
* List all Monitors
|
|
943
|
-
* @param options Pagination and filtering options
|
|
944
|
-
* @returns The list of Monitors
|
|
945
|
-
*/
|
|
946
867
|
async list(options) {
|
|
947
|
-
const params =
|
|
948
|
-
|
|
949
|
-
limit: options?.limit,
|
|
950
|
-
websetId: options?.websetId
|
|
951
|
-
};
|
|
952
|
-
return this.request(
|
|
953
|
-
"/v0/monitors",
|
|
954
|
-
"GET",
|
|
955
|
-
void 0,
|
|
956
|
-
params
|
|
957
|
-
);
|
|
868
|
+
const params = this.buildPaginationParams(options);
|
|
869
|
+
return this.request("", "GET", void 0, params);
|
|
958
870
|
}
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
871
|
+
async pollUntilFinished(researchId, options) {
|
|
872
|
+
const pollInterval = options?.pollInterval ?? 1e3;
|
|
873
|
+
const timeoutMs = options?.timeoutMs ?? 10 * 60 * 1e3;
|
|
874
|
+
const maxConsecutiveFailures = 5;
|
|
875
|
+
const startTime = Date.now();
|
|
876
|
+
let consecutiveFailures = 0;
|
|
877
|
+
while (true) {
|
|
878
|
+
try {
|
|
879
|
+
const research = await this.get(researchId, {
|
|
880
|
+
events: options?.events
|
|
881
|
+
});
|
|
882
|
+
consecutiveFailures = 0;
|
|
883
|
+
if (research.status === "completed" || research.status === "failed" || research.status === "canceled") {
|
|
884
|
+
return research;
|
|
885
|
+
}
|
|
886
|
+
} catch (err) {
|
|
887
|
+
consecutiveFailures += 1;
|
|
888
|
+
if (consecutiveFailures >= maxConsecutiveFailures) {
|
|
889
|
+
throw new Error(
|
|
890
|
+
`Polling failed ${maxConsecutiveFailures} times in a row for research ${researchId}: ${err}`
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
if (Date.now() - startTime > timeoutMs) {
|
|
895
|
+
throw new Error(
|
|
896
|
+
`Polling timeout: Research ${researchId} did not complete within ${timeoutMs}ms`
|
|
897
|
+
);
|
|
898
|
+
}
|
|
899
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
900
|
+
}
|
|
967
901
|
}
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
// src/websets/base.ts
|
|
905
|
+
var WebsetsBaseClient2 = class {
|
|
968
906
|
/**
|
|
969
|
-
*
|
|
970
|
-
* @param
|
|
971
|
-
* @returns The deleted Monitor
|
|
907
|
+
* Initialize a new Websets base client
|
|
908
|
+
* @param client The Exa client instance
|
|
972
909
|
*/
|
|
973
|
-
|
|
974
|
-
|
|
910
|
+
constructor(client) {
|
|
911
|
+
this.client = client;
|
|
975
912
|
}
|
|
976
913
|
/**
|
|
977
|
-
*
|
|
978
|
-
* @param
|
|
979
|
-
* @
|
|
914
|
+
* Make a request to the Websets API
|
|
915
|
+
* @param endpoint The endpoint path
|
|
916
|
+
* @param method The HTTP method
|
|
917
|
+
* @param data Optional request body data
|
|
918
|
+
* @param params Optional query parameters
|
|
919
|
+
* @returns The response JSON
|
|
920
|
+
* @throws ExaError with API error details if the request fails
|
|
980
921
|
*/
|
|
981
|
-
async
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
}
|
|
990
|
-
if (!response.hasMore || !response.nextCursor) {
|
|
991
|
-
break;
|
|
992
|
-
}
|
|
993
|
-
cursor = response.nextCursor;
|
|
994
|
-
}
|
|
922
|
+
async request(endpoint, method = "POST", data, params, headers) {
|
|
923
|
+
return this.client.request(
|
|
924
|
+
`/websets${endpoint}`,
|
|
925
|
+
method,
|
|
926
|
+
data,
|
|
927
|
+
params,
|
|
928
|
+
headers
|
|
929
|
+
);
|
|
995
930
|
}
|
|
996
931
|
/**
|
|
997
|
-
*
|
|
998
|
-
* @param
|
|
999
|
-
* @returns
|
|
932
|
+
* Helper to build pagination parameters
|
|
933
|
+
* @param pagination The pagination parameters
|
|
934
|
+
* @returns QueryParams object with pagination parameters
|
|
1000
935
|
*/
|
|
1001
|
-
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
return
|
|
936
|
+
buildPaginationParams(pagination) {
|
|
937
|
+
const params = {};
|
|
938
|
+
if (!pagination) return params;
|
|
939
|
+
if (pagination.cursor) params.cursor = pagination.cursor;
|
|
940
|
+
if (pagination.limit) params.limit = pagination.limit;
|
|
941
|
+
return params;
|
|
1007
942
|
}
|
|
1008
943
|
};
|
|
1009
944
|
|
|
1010
|
-
// src/websets/
|
|
1011
|
-
var
|
|
945
|
+
// src/websets/enrichments.ts
|
|
946
|
+
var WebsetEnrichmentsClient2 = class extends WebsetsBaseClient2 {
|
|
1012
947
|
/**
|
|
1013
|
-
* Create
|
|
948
|
+
* Create an Enrichment for a Webset
|
|
1014
949
|
* @param websetId The ID of the Webset
|
|
1015
|
-
* @param params The
|
|
1016
|
-
* @returns The created Webset
|
|
950
|
+
* @param params The enrichment parameters
|
|
951
|
+
* @returns The created Webset Enrichment
|
|
1017
952
|
*/
|
|
1018
|
-
async create(websetId, params
|
|
953
|
+
async create(websetId, params) {
|
|
1019
954
|
return this.request(
|
|
1020
|
-
`/v0/websets/${websetId}/
|
|
955
|
+
`/v0/websets/${websetId}/enrichments`,
|
|
1021
956
|
"POST",
|
|
1022
|
-
params
|
|
1023
|
-
void 0,
|
|
1024
|
-
options?.headers
|
|
957
|
+
params
|
|
1025
958
|
);
|
|
1026
959
|
}
|
|
1027
960
|
/**
|
|
1028
|
-
* Get
|
|
961
|
+
* Get an Enrichment by ID
|
|
1029
962
|
* @param websetId The ID of the Webset
|
|
1030
|
-
* @param id The ID of the
|
|
1031
|
-
* @returns The Webset
|
|
963
|
+
* @param id The ID of the Enrichment
|
|
964
|
+
* @returns The Webset Enrichment
|
|
1032
965
|
*/
|
|
1033
966
|
async get(websetId, id) {
|
|
1034
967
|
return this.request(
|
|
1035
|
-
`/v0/websets/${websetId}/
|
|
968
|
+
`/v0/websets/${websetId}/enrichments/${id}`,
|
|
1036
969
|
"GET"
|
|
1037
970
|
);
|
|
1038
971
|
}
|
|
1039
972
|
/**
|
|
1040
|
-
*
|
|
973
|
+
* Delete an Enrichment
|
|
1041
974
|
* @param websetId The ID of the Webset
|
|
1042
|
-
* @param id The ID of the
|
|
1043
|
-
* @returns The
|
|
975
|
+
* @param id The ID of the Enrichment
|
|
976
|
+
* @returns The deleted Webset Enrichment
|
|
977
|
+
*/
|
|
978
|
+
async delete(websetId, id) {
|
|
979
|
+
return this.request(
|
|
980
|
+
`/v0/websets/${websetId}/enrichments/${id}`,
|
|
981
|
+
"DELETE"
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Update an Enrichment
|
|
986
|
+
* @param websetId The ID of the Webset
|
|
987
|
+
* @param id The ID of the Enrichment
|
|
988
|
+
* @param params The enrichment update parameters
|
|
989
|
+
* @returns Promise that resolves when the update is complete
|
|
990
|
+
*/
|
|
991
|
+
async update(websetId, id, params) {
|
|
992
|
+
return this.request(
|
|
993
|
+
`/v0/websets/${websetId}/enrichments/${id}`,
|
|
994
|
+
"PATCH",
|
|
995
|
+
params
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Cancel a running Enrichment
|
|
1000
|
+
* @param websetId The ID of the Webset
|
|
1001
|
+
* @param id The ID of the Enrichment
|
|
1002
|
+
* @returns The canceled Webset Enrichment
|
|
1044
1003
|
*/
|
|
1045
1004
|
async cancel(websetId, id) {
|
|
1046
1005
|
return this.request(
|
|
1047
|
-
`/v0/websets/${websetId}/
|
|
1006
|
+
`/v0/websets/${websetId}/enrichments/${id}/cancel`,
|
|
1048
1007
|
"POST"
|
|
1049
1008
|
);
|
|
1050
1009
|
}
|
|
1051
1010
|
};
|
|
1052
1011
|
|
|
1053
|
-
// src/websets/
|
|
1054
|
-
var
|
|
1055
|
-
/**
|
|
1056
|
-
* Create a Webhook
|
|
1057
|
-
* @param params The webhook parameters
|
|
1058
|
-
* @returns The created Webhook
|
|
1059
|
-
*/
|
|
1060
|
-
async create(params) {
|
|
1061
|
-
return this.request("/v0/webhooks", "POST", params);
|
|
1062
|
-
}
|
|
1012
|
+
// src/websets/events.ts
|
|
1013
|
+
var EventsClient2 = class extends WebsetsBaseClient2 {
|
|
1063
1014
|
/**
|
|
1064
|
-
*
|
|
1065
|
-
* @param
|
|
1066
|
-
* @returns The Webhook
|
|
1015
|
+
* Initialize a new Events client
|
|
1016
|
+
* @param client The Exa client instance
|
|
1067
1017
|
*/
|
|
1068
|
-
|
|
1069
|
-
|
|
1018
|
+
constructor(client) {
|
|
1019
|
+
super(client);
|
|
1070
1020
|
}
|
|
1071
1021
|
/**
|
|
1072
|
-
* List all
|
|
1073
|
-
* @param options
|
|
1074
|
-
* @returns The list of
|
|
1022
|
+
* List all Events
|
|
1023
|
+
* @param options Optional filtering and pagination options
|
|
1024
|
+
* @returns The list of Events
|
|
1075
1025
|
*/
|
|
1076
1026
|
async list(options) {
|
|
1077
|
-
const params =
|
|
1027
|
+
const params = {
|
|
1028
|
+
cursor: options?.cursor,
|
|
1029
|
+
limit: options?.limit,
|
|
1030
|
+
types: options?.types
|
|
1031
|
+
};
|
|
1078
1032
|
return this.request(
|
|
1079
|
-
"/v0/
|
|
1033
|
+
"/v0/events",
|
|
1080
1034
|
"GET",
|
|
1081
1035
|
void 0,
|
|
1082
1036
|
params
|
|
1083
1037
|
);
|
|
1084
1038
|
}
|
|
1085
1039
|
/**
|
|
1086
|
-
*
|
|
1087
|
-
* @param
|
|
1088
|
-
* @returns
|
|
1040
|
+
* Get an Event by ID
|
|
1041
|
+
* @param id The ID of the Event
|
|
1042
|
+
* @returns The Event
|
|
1043
|
+
*/
|
|
1044
|
+
async get(id) {
|
|
1045
|
+
return this.request(`/v0/events/${id}`, "GET");
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Iterate through all Events, handling pagination automatically
|
|
1049
|
+
* @param options Filtering and pagination options
|
|
1050
|
+
* @returns Async generator of Events
|
|
1089
1051
|
*/
|
|
1090
1052
|
async *listAll(options) {
|
|
1091
1053
|
let cursor = void 0;
|
|
@@ -1093,8 +1055,8 @@ var WebsetWebhooksClient = class extends WebsetsBaseClient {
|
|
|
1093
1055
|
while (true) {
|
|
1094
1056
|
pageOptions.cursor = cursor;
|
|
1095
1057
|
const response = await this.list(pageOptions);
|
|
1096
|
-
for (const
|
|
1097
|
-
yield
|
|
1058
|
+
for (const event of response.data) {
|
|
1059
|
+
yield event;
|
|
1098
1060
|
}
|
|
1099
1061
|
if (!response.hasMore || !response.nextCursor) {
|
|
1100
1062
|
break;
|
|
@@ -1103,299 +1065,377 @@ var WebsetWebhooksClient = class extends WebsetsBaseClient {
|
|
|
1103
1065
|
}
|
|
1104
1066
|
}
|
|
1105
1067
|
/**
|
|
1106
|
-
* Collect all
|
|
1107
|
-
* @param options
|
|
1108
|
-
* @returns Promise resolving to an array of all
|
|
1068
|
+
* Collect all Events into an array
|
|
1069
|
+
* @param options Filtering and pagination options
|
|
1070
|
+
* @returns Promise resolving to an array of all Events
|
|
1109
1071
|
*/
|
|
1110
1072
|
async getAll(options) {
|
|
1111
|
-
const
|
|
1112
|
-
for await (const
|
|
1113
|
-
|
|
1073
|
+
const events = [];
|
|
1074
|
+
for await (const event of this.listAll(options)) {
|
|
1075
|
+
events.push(event);
|
|
1076
|
+
}
|
|
1077
|
+
return events;
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
// src/websets/openapi.ts
|
|
1082
|
+
var CreateEnrichmentParametersFormat = /* @__PURE__ */ ((CreateEnrichmentParametersFormat2) => {
|
|
1083
|
+
CreateEnrichmentParametersFormat2["text"] = "text";
|
|
1084
|
+
CreateEnrichmentParametersFormat2["date"] = "date";
|
|
1085
|
+
CreateEnrichmentParametersFormat2["number"] = "number";
|
|
1086
|
+
CreateEnrichmentParametersFormat2["options"] = "options";
|
|
1087
|
+
CreateEnrichmentParametersFormat2["email"] = "email";
|
|
1088
|
+
CreateEnrichmentParametersFormat2["phone"] = "phone";
|
|
1089
|
+
CreateEnrichmentParametersFormat2["url"] = "url";
|
|
1090
|
+
return CreateEnrichmentParametersFormat2;
|
|
1091
|
+
})(CreateEnrichmentParametersFormat || {});
|
|
1092
|
+
var CreateImportParametersFormat = /* @__PURE__ */ ((CreateImportParametersFormat2) => {
|
|
1093
|
+
CreateImportParametersFormat2["csv"] = "csv";
|
|
1094
|
+
return CreateImportParametersFormat2;
|
|
1095
|
+
})(CreateImportParametersFormat || {});
|
|
1096
|
+
var WebsetImportSource = /* @__PURE__ */ ((WebsetImportSource2) => {
|
|
1097
|
+
WebsetImportSource2["import"] = "import";
|
|
1098
|
+
WebsetImportSource2["webset"] = "webset";
|
|
1099
|
+
return WebsetImportSource2;
|
|
1100
|
+
})(WebsetImportSource || {});
|
|
1101
|
+
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
1102
|
+
EventType2["webset_created"] = "webset.created";
|
|
1103
|
+
EventType2["webset_deleted"] = "webset.deleted";
|
|
1104
|
+
EventType2["webset_paused"] = "webset.paused";
|
|
1105
|
+
EventType2["webset_idle"] = "webset.idle";
|
|
1106
|
+
EventType2["webset_search_created"] = "webset.search.created";
|
|
1107
|
+
EventType2["webset_search_canceled"] = "webset.search.canceled";
|
|
1108
|
+
EventType2["webset_search_completed"] = "webset.search.completed";
|
|
1109
|
+
EventType2["webset_search_updated"] = "webset.search.updated";
|
|
1110
|
+
EventType2["import_created"] = "import.created";
|
|
1111
|
+
EventType2["import_completed"] = "import.completed";
|
|
1112
|
+
EventType2["webset_item_created"] = "webset.item.created";
|
|
1113
|
+
EventType2["webset_item_enriched"] = "webset.item.enriched";
|
|
1114
|
+
EventType2["monitor_created"] = "monitor.created";
|
|
1115
|
+
EventType2["monitor_updated"] = "monitor.updated";
|
|
1116
|
+
EventType2["monitor_deleted"] = "monitor.deleted";
|
|
1117
|
+
EventType2["monitor_run_created"] = "monitor.run.created";
|
|
1118
|
+
EventType2["monitor_run_completed"] = "monitor.run.completed";
|
|
1119
|
+
EventType2["webset_export_created"] = "webset.export.created";
|
|
1120
|
+
EventType2["webset_export_completed"] = "webset.export.completed";
|
|
1121
|
+
return EventType2;
|
|
1122
|
+
})(EventType || {});
|
|
1123
|
+
var ImportFailedReason = /* @__PURE__ */ ((ImportFailedReason2) => {
|
|
1124
|
+
ImportFailedReason2["invalid_format"] = "invalid_format";
|
|
1125
|
+
ImportFailedReason2["invalid_file_content"] = "invalid_file_content";
|
|
1126
|
+
ImportFailedReason2["missing_identifier"] = "missing_identifier";
|
|
1127
|
+
return ImportFailedReason2;
|
|
1128
|
+
})(ImportFailedReason || {});
|
|
1129
|
+
var ImportFormat = /* @__PURE__ */ ((ImportFormat2) => {
|
|
1130
|
+
ImportFormat2["csv"] = "csv";
|
|
1131
|
+
ImportFormat2["webset"] = "webset";
|
|
1132
|
+
return ImportFormat2;
|
|
1133
|
+
})(ImportFormat || {});
|
|
1134
|
+
var ImportObject = /* @__PURE__ */ ((ImportObject2) => {
|
|
1135
|
+
ImportObject2["import"] = "import";
|
|
1136
|
+
return ImportObject2;
|
|
1137
|
+
})(ImportObject || {});
|
|
1138
|
+
var ImportStatus = /* @__PURE__ */ ((ImportStatus2) => {
|
|
1139
|
+
ImportStatus2["pending"] = "pending";
|
|
1140
|
+
ImportStatus2["processing"] = "processing";
|
|
1141
|
+
ImportStatus2["completed"] = "completed";
|
|
1142
|
+
ImportStatus2["failed"] = "failed";
|
|
1143
|
+
return ImportStatus2;
|
|
1144
|
+
})(ImportStatus || {});
|
|
1145
|
+
var MonitorObject = /* @__PURE__ */ ((MonitorObject2) => {
|
|
1146
|
+
MonitorObject2["monitor"] = "monitor";
|
|
1147
|
+
return MonitorObject2;
|
|
1148
|
+
})(MonitorObject || {});
|
|
1149
|
+
var MonitorStatus = /* @__PURE__ */ ((MonitorStatus2) => {
|
|
1150
|
+
MonitorStatus2["enabled"] = "enabled";
|
|
1151
|
+
MonitorStatus2["disabled"] = "disabled";
|
|
1152
|
+
return MonitorStatus2;
|
|
1153
|
+
})(MonitorStatus || {});
|
|
1154
|
+
var MonitorRunObject = /* @__PURE__ */ ((MonitorRunObject2) => {
|
|
1155
|
+
MonitorRunObject2["monitor_run"] = "monitor_run";
|
|
1156
|
+
return MonitorRunObject2;
|
|
1157
|
+
})(MonitorRunObject || {});
|
|
1158
|
+
var MonitorRunStatus = /* @__PURE__ */ ((MonitorRunStatus2) => {
|
|
1159
|
+
MonitorRunStatus2["created"] = "created";
|
|
1160
|
+
MonitorRunStatus2["running"] = "running";
|
|
1161
|
+
MonitorRunStatus2["completed"] = "completed";
|
|
1162
|
+
MonitorRunStatus2["canceled"] = "canceled";
|
|
1163
|
+
MonitorRunStatus2["failed"] = "failed";
|
|
1164
|
+
return MonitorRunStatus2;
|
|
1165
|
+
})(MonitorRunStatus || {});
|
|
1166
|
+
var MonitorRunType = /* @__PURE__ */ ((MonitorRunType2) => {
|
|
1167
|
+
MonitorRunType2["search"] = "search";
|
|
1168
|
+
MonitorRunType2["refresh"] = "refresh";
|
|
1169
|
+
return MonitorRunType2;
|
|
1170
|
+
})(MonitorRunType || {});
|
|
1171
|
+
var UpdateMonitorStatus = /* @__PURE__ */ ((UpdateMonitorStatus2) => {
|
|
1172
|
+
UpdateMonitorStatus2["enabled"] = "enabled";
|
|
1173
|
+
UpdateMonitorStatus2["disabled"] = "disabled";
|
|
1174
|
+
return UpdateMonitorStatus2;
|
|
1175
|
+
})(UpdateMonitorStatus || {});
|
|
1176
|
+
var WebhookStatus = /* @__PURE__ */ ((WebhookStatus2) => {
|
|
1177
|
+
WebhookStatus2["active"] = "active";
|
|
1178
|
+
WebhookStatus2["inactive"] = "inactive";
|
|
1179
|
+
return WebhookStatus2;
|
|
1180
|
+
})(WebhookStatus || {});
|
|
1181
|
+
var WebsetStatus = /* @__PURE__ */ ((WebsetStatus2) => {
|
|
1182
|
+
WebsetStatus2["idle"] = "idle";
|
|
1183
|
+
WebsetStatus2["pending"] = "pending";
|
|
1184
|
+
WebsetStatus2["running"] = "running";
|
|
1185
|
+
WebsetStatus2["paused"] = "paused";
|
|
1186
|
+
return WebsetStatus2;
|
|
1187
|
+
})(WebsetStatus || {});
|
|
1188
|
+
var WebsetEnrichmentStatus = /* @__PURE__ */ ((WebsetEnrichmentStatus2) => {
|
|
1189
|
+
WebsetEnrichmentStatus2["pending"] = "pending";
|
|
1190
|
+
WebsetEnrichmentStatus2["canceled"] = "canceled";
|
|
1191
|
+
WebsetEnrichmentStatus2["completed"] = "completed";
|
|
1192
|
+
return WebsetEnrichmentStatus2;
|
|
1193
|
+
})(WebsetEnrichmentStatus || {});
|
|
1194
|
+
var WebsetEnrichmentFormat = /* @__PURE__ */ ((WebsetEnrichmentFormat2) => {
|
|
1195
|
+
WebsetEnrichmentFormat2["text"] = "text";
|
|
1196
|
+
WebsetEnrichmentFormat2["date"] = "date";
|
|
1197
|
+
WebsetEnrichmentFormat2["number"] = "number";
|
|
1198
|
+
WebsetEnrichmentFormat2["options"] = "options";
|
|
1199
|
+
WebsetEnrichmentFormat2["email"] = "email";
|
|
1200
|
+
WebsetEnrichmentFormat2["phone"] = "phone";
|
|
1201
|
+
WebsetEnrichmentFormat2["url"] = "url";
|
|
1202
|
+
return WebsetEnrichmentFormat2;
|
|
1203
|
+
})(WebsetEnrichmentFormat || {});
|
|
1204
|
+
var WebsetItemSource = /* @__PURE__ */ ((WebsetItemSource2) => {
|
|
1205
|
+
WebsetItemSource2["search"] = "search";
|
|
1206
|
+
WebsetItemSource2["import"] = "import";
|
|
1207
|
+
return WebsetItemSource2;
|
|
1208
|
+
})(WebsetItemSource || {});
|
|
1209
|
+
var WebsetItemEvaluationSatisfied = /* @__PURE__ */ ((WebsetItemEvaluationSatisfied2) => {
|
|
1210
|
+
WebsetItemEvaluationSatisfied2["yes"] = "yes";
|
|
1211
|
+
WebsetItemEvaluationSatisfied2["no"] = "no";
|
|
1212
|
+
WebsetItemEvaluationSatisfied2["unclear"] = "unclear";
|
|
1213
|
+
return WebsetItemEvaluationSatisfied2;
|
|
1214
|
+
})(WebsetItemEvaluationSatisfied || {});
|
|
1215
|
+
var WebsetExcludeSource = /* @__PURE__ */ ((WebsetExcludeSource2) => {
|
|
1216
|
+
WebsetExcludeSource2["import"] = "import";
|
|
1217
|
+
WebsetExcludeSource2["webset"] = "webset";
|
|
1218
|
+
return WebsetExcludeSource2;
|
|
1219
|
+
})(WebsetExcludeSource || {});
|
|
1220
|
+
var WebsetSearchScopeSource = /* @__PURE__ */ ((WebsetSearchScopeSource2) => {
|
|
1221
|
+
WebsetSearchScopeSource2["import"] = "import";
|
|
1222
|
+
WebsetSearchScopeSource2["webset"] = "webset";
|
|
1223
|
+
return WebsetSearchScopeSource2;
|
|
1224
|
+
})(WebsetSearchScopeSource || {});
|
|
1225
|
+
var WebsetSearchStatus = /* @__PURE__ */ ((WebsetSearchStatus2) => {
|
|
1226
|
+
WebsetSearchStatus2["created"] = "created";
|
|
1227
|
+
WebsetSearchStatus2["pending"] = "pending";
|
|
1228
|
+
WebsetSearchStatus2["running"] = "running";
|
|
1229
|
+
WebsetSearchStatus2["completed"] = "completed";
|
|
1230
|
+
WebsetSearchStatus2["canceled"] = "canceled";
|
|
1231
|
+
return WebsetSearchStatus2;
|
|
1232
|
+
})(WebsetSearchStatus || {});
|
|
1233
|
+
var WebsetSearchBehavior = /* @__PURE__ */ ((WebsetSearchBehavior2) => {
|
|
1234
|
+
WebsetSearchBehavior2["override"] = "override";
|
|
1235
|
+
WebsetSearchBehavior2["append"] = "append";
|
|
1236
|
+
return WebsetSearchBehavior2;
|
|
1237
|
+
})(WebsetSearchBehavior || {});
|
|
1238
|
+
var WebsetSearchCanceledReason = /* @__PURE__ */ ((WebsetSearchCanceledReason2) => {
|
|
1239
|
+
WebsetSearchCanceledReason2["webset_deleted"] = "webset_deleted";
|
|
1240
|
+
WebsetSearchCanceledReason2["webset_canceled"] = "webset_canceled";
|
|
1241
|
+
return WebsetSearchCanceledReason2;
|
|
1242
|
+
})(WebsetSearchCanceledReason || {});
|
|
1243
|
+
|
|
1244
|
+
// src/websets/imports.ts
|
|
1245
|
+
var ImportsClient2 = class extends WebsetsBaseClient2 {
|
|
1246
|
+
async create(params, csv) {
|
|
1247
|
+
if (csv === void 0) {
|
|
1248
|
+
return this.request(
|
|
1249
|
+
"/v0/imports",
|
|
1250
|
+
"POST",
|
|
1251
|
+
params
|
|
1252
|
+
);
|
|
1114
1253
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
}
|
|
1126
|
-
/**
|
|
1127
|
-
* Delete a Webhook
|
|
1128
|
-
* @param id The ID of the Webhook
|
|
1129
|
-
* @returns The deleted Webhook
|
|
1130
|
-
*/
|
|
1131
|
-
async delete(id) {
|
|
1132
|
-
return this.request(`/v0/webhooks/${id}`, "DELETE");
|
|
1133
|
-
}
|
|
1134
|
-
/**
|
|
1135
|
-
* List all attempts for a Webhook
|
|
1136
|
-
* @param id The ID of the Webhook
|
|
1137
|
-
* @param options Pagination and filtering options
|
|
1138
|
-
* @returns The list of Webhook attempts
|
|
1139
|
-
*/
|
|
1140
|
-
async listAttempts(id, options) {
|
|
1141
|
-
const params = {
|
|
1142
|
-
cursor: options?.cursor,
|
|
1143
|
-
limit: options?.limit,
|
|
1144
|
-
eventType: options?.eventType,
|
|
1145
|
-
successful: options?.successful
|
|
1146
|
-
};
|
|
1147
|
-
return this.request(
|
|
1148
|
-
`/v0/webhooks/${id}/attempts`,
|
|
1149
|
-
"GET",
|
|
1150
|
-
void 0,
|
|
1151
|
-
params
|
|
1152
|
-
);
|
|
1153
|
-
}
|
|
1154
|
-
/**
|
|
1155
|
-
* Iterate through all attempts for a Webhook, handling pagination automatically
|
|
1156
|
-
* @param id The ID of the Webhook
|
|
1157
|
-
* @param options Pagination and filtering options
|
|
1158
|
-
* @returns Async generator of Webhook attempts
|
|
1159
|
-
*/
|
|
1160
|
-
async *listAllAttempts(id, options) {
|
|
1161
|
-
let cursor = void 0;
|
|
1162
|
-
const pageOptions = options ? { ...options } : {};
|
|
1163
|
-
while (true) {
|
|
1164
|
-
pageOptions.cursor = cursor;
|
|
1165
|
-
const response = await this.listAttempts(id, pageOptions);
|
|
1166
|
-
for (const attempt of response.data) {
|
|
1167
|
-
yield attempt;
|
|
1168
|
-
}
|
|
1169
|
-
if (!response.hasMore || !response.nextCursor) {
|
|
1170
|
-
break;
|
|
1171
|
-
}
|
|
1172
|
-
cursor = response.nextCursor;
|
|
1254
|
+
let csvBuffer;
|
|
1255
|
+
if (typeof csv === "string") {
|
|
1256
|
+
csvBuffer = Buffer.from(csv, "utf8");
|
|
1257
|
+
} else if (Buffer.isBuffer(csv)) {
|
|
1258
|
+
csvBuffer = csv;
|
|
1259
|
+
} else {
|
|
1260
|
+
throw new ExaError(
|
|
1261
|
+
"Invalid CSV data input. Must be string or Buffer",
|
|
1262
|
+
400 /* BadRequest */
|
|
1263
|
+
);
|
|
1173
1264
|
}
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
attempts.push(attempt);
|
|
1265
|
+
const sizeInBytes = csvBuffer.length;
|
|
1266
|
+
const sizeInMB = Math.max(1, Math.ceil(sizeInBytes / (1024 * 1024)));
|
|
1267
|
+
const csvText = csvBuffer.toString("utf8");
|
|
1268
|
+
const lines = csvText.split("\n").filter((line) => line.trim().length > 0);
|
|
1269
|
+
const recordCount = Math.max(0, lines.length - 1);
|
|
1270
|
+
if (sizeInMB > 50) {
|
|
1271
|
+
throw new ExaError(
|
|
1272
|
+
`CSV file too large: ${sizeInMB}MB. Maximum size is 50MB.`,
|
|
1273
|
+
400 /* BadRequest */
|
|
1274
|
+
);
|
|
1185
1275
|
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
var WebsetsClient = class extends WebsetsBaseClient {
|
|
1192
|
-
/**
|
|
1193
|
-
* Initialize a new Websets client
|
|
1194
|
-
* @param client The Exa client instance
|
|
1195
|
-
*/
|
|
1196
|
-
constructor(client) {
|
|
1197
|
-
super(client);
|
|
1198
|
-
this.events = new EventsClient(client);
|
|
1199
|
-
this.imports = new ImportsClient(client);
|
|
1200
|
-
this.items = new WebsetItemsClient(client);
|
|
1201
|
-
this.searches = new WebsetSearchesClient(client);
|
|
1202
|
-
this.enrichments = new WebsetEnrichmentsClient(client);
|
|
1203
|
-
this.monitors = new WebsetMonitorsClient(client);
|
|
1204
|
-
this.webhooks = new WebsetWebhooksClient(client);
|
|
1205
|
-
}
|
|
1206
|
-
/**
|
|
1207
|
-
* Create a new Webset
|
|
1208
|
-
* @param params The Webset creation parameters
|
|
1209
|
-
* @returns The created Webset
|
|
1210
|
-
*/
|
|
1211
|
-
async create(params, options) {
|
|
1212
|
-
return this.request(
|
|
1213
|
-
"/v0/websets",
|
|
1214
|
-
"POST",
|
|
1215
|
-
params,
|
|
1216
|
-
void 0,
|
|
1217
|
-
options?.headers
|
|
1218
|
-
);
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
* Preview a webset
|
|
1222
|
-
* @param params The preview parameters
|
|
1223
|
-
* @param options Optional parameters. Search = true allows you to retrieve a preview set of items that could be returned by the webset.
|
|
1224
|
-
* @returns The preview response showing how the query will be decomposed
|
|
1225
|
-
*/
|
|
1226
|
-
async preview(params, options) {
|
|
1227
|
-
const queryParams = {};
|
|
1228
|
-
if (options?.search !== void 0) {
|
|
1229
|
-
queryParams.search = options.search;
|
|
1276
|
+
if (recordCount === 0) {
|
|
1277
|
+
throw new ExaError(
|
|
1278
|
+
"CSV file appears to have no data records (only header or empty)",
|
|
1279
|
+
400 /* BadRequest */
|
|
1280
|
+
);
|
|
1230
1281
|
}
|
|
1231
|
-
|
|
1232
|
-
|
|
1282
|
+
const createParams = {
|
|
1283
|
+
title: params.title,
|
|
1284
|
+
format: "csv" /* csv */,
|
|
1285
|
+
entity: params.entity,
|
|
1286
|
+
size: sizeInBytes,
|
|
1287
|
+
count: recordCount,
|
|
1288
|
+
metadata: params.metadata,
|
|
1289
|
+
csv: params.csv
|
|
1290
|
+
};
|
|
1291
|
+
const importResponse = await this.request(
|
|
1292
|
+
"/v0/imports",
|
|
1233
1293
|
"POST",
|
|
1234
|
-
|
|
1235
|
-
queryParams
|
|
1294
|
+
createParams
|
|
1236
1295
|
);
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1296
|
+
try {
|
|
1297
|
+
const uploadResponse = await fetch(importResponse.uploadUrl, {
|
|
1298
|
+
method: "PUT",
|
|
1299
|
+
body: csvBuffer
|
|
1300
|
+
});
|
|
1301
|
+
if (!uploadResponse.ok) {
|
|
1302
|
+
const errorText = await uploadResponse.text();
|
|
1303
|
+
throw new ExaError(
|
|
1304
|
+
`Upload failed: ${uploadResponse.status} ${uploadResponse.statusText}. ${errorText}`,
|
|
1305
|
+
400 /* BadRequest */
|
|
1306
|
+
);
|
|
1307
|
+
}
|
|
1308
|
+
} catch (error) {
|
|
1309
|
+
if (error instanceof ExaError) {
|
|
1310
|
+
throw error;
|
|
1311
|
+
}
|
|
1312
|
+
throw new ExaError(
|
|
1313
|
+
`Failed to upload CSV data: ${error.message}`,
|
|
1314
|
+
400 /* BadRequest */
|
|
1315
|
+
);
|
|
1248
1316
|
}
|
|
1249
|
-
return
|
|
1250
|
-
`/v0/websets/${id}`,
|
|
1251
|
-
"GET",
|
|
1252
|
-
void 0,
|
|
1253
|
-
params
|
|
1254
|
-
);
|
|
1317
|
+
return importResponse;
|
|
1255
1318
|
}
|
|
1256
1319
|
/**
|
|
1257
|
-
*
|
|
1258
|
-
* @param
|
|
1259
|
-
* @returns The
|
|
1320
|
+
* Get an Import by ID
|
|
1321
|
+
* @param id The ID of the Import
|
|
1322
|
+
* @returns The Import
|
|
1323
|
+
*/
|
|
1324
|
+
async get(id) {
|
|
1325
|
+
return this.request(`/v0/imports/${id}`, "GET");
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* List all Imports
|
|
1329
|
+
* @param options Pagination options
|
|
1330
|
+
* @returns The list of Imports
|
|
1260
1331
|
*/
|
|
1261
1332
|
async list(options) {
|
|
1262
1333
|
const params = this.buildPaginationParams(options);
|
|
1263
1334
|
return this.request(
|
|
1264
|
-
"/v0/
|
|
1335
|
+
"/v0/imports",
|
|
1265
1336
|
"GET",
|
|
1266
1337
|
void 0,
|
|
1267
1338
|
params
|
|
1268
1339
|
);
|
|
1269
1340
|
}
|
|
1270
1341
|
/**
|
|
1271
|
-
*
|
|
1272
|
-
* @param
|
|
1273
|
-
* @
|
|
1274
|
-
|
|
1275
|
-
async *listAll(options) {
|
|
1276
|
-
let cursor = void 0;
|
|
1277
|
-
const pageOptions = options ? { ...options } : {};
|
|
1278
|
-
while (true) {
|
|
1279
|
-
pageOptions.cursor = cursor;
|
|
1280
|
-
const response = await this.list(pageOptions);
|
|
1281
|
-
for (const webset of response.data) {
|
|
1282
|
-
yield webset;
|
|
1283
|
-
}
|
|
1284
|
-
if (!response.hasMore || !response.nextCursor) {
|
|
1285
|
-
break;
|
|
1286
|
-
}
|
|
1287
|
-
cursor = response.nextCursor;
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
/**
|
|
1291
|
-
* Collect all Websets into an array
|
|
1292
|
-
* @param options Pagination options
|
|
1293
|
-
* @returns Promise resolving to an array of all Websets
|
|
1294
|
-
*/
|
|
1295
|
-
async getAll(options) {
|
|
1296
|
-
const websets = [];
|
|
1297
|
-
for await (const webset of this.listAll(options)) {
|
|
1298
|
-
websets.push(webset);
|
|
1299
|
-
}
|
|
1300
|
-
return websets;
|
|
1301
|
-
}
|
|
1302
|
-
/**
|
|
1303
|
-
* Update a Webset
|
|
1304
|
-
* @param id The ID of the Webset
|
|
1305
|
-
* @param params The Webset update parameters
|
|
1306
|
-
* @returns The updated Webset
|
|
1342
|
+
* Update an Import
|
|
1343
|
+
* @param id The ID of the Import
|
|
1344
|
+
* @param params The import update parameters
|
|
1345
|
+
* @returns The updated Import
|
|
1307
1346
|
*/
|
|
1308
1347
|
async update(id, params) {
|
|
1309
|
-
return this.request(`/v0/
|
|
1348
|
+
return this.request(`/v0/imports/${id}`, "PATCH", params);
|
|
1310
1349
|
}
|
|
1311
1350
|
/**
|
|
1312
|
-
* Delete
|
|
1313
|
-
* @param id The ID of the
|
|
1314
|
-
* @returns The deleted
|
|
1351
|
+
* Delete an Import
|
|
1352
|
+
* @param id The ID of the Import
|
|
1353
|
+
* @returns The deleted Import
|
|
1315
1354
|
*/
|
|
1316
1355
|
async delete(id) {
|
|
1317
|
-
return this.request(`/v0/
|
|
1318
|
-
}
|
|
1319
|
-
/**
|
|
1320
|
-
* Cancel a running Webset
|
|
1321
|
-
* @param id The ID or external ID of the Webset
|
|
1322
|
-
* @returns The canceled Webset (as returned by the API)
|
|
1323
|
-
*/
|
|
1324
|
-
async cancel(id) {
|
|
1325
|
-
return this.request(`/v0/websets/${id}/cancel`, "POST");
|
|
1356
|
+
return this.request(`/v0/imports/${id}`, "DELETE");
|
|
1326
1357
|
}
|
|
1327
1358
|
/**
|
|
1328
|
-
* Wait until
|
|
1329
|
-
* @param id The ID of the
|
|
1359
|
+
* Wait until an Import is completed or failed
|
|
1360
|
+
* @param id The ID of the Import
|
|
1330
1361
|
* @param options Configuration options for timeout and polling
|
|
1331
|
-
* @returns The
|
|
1332
|
-
* @throws Error if the
|
|
1362
|
+
* @returns The Import once it reaches a final state (completed or failed)
|
|
1363
|
+
* @throws Error if the Import does not complete within the timeout or fails
|
|
1333
1364
|
*/
|
|
1334
|
-
async
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
if (typeof options === "number") {
|
|
1339
|
-
timeout = options;
|
|
1340
|
-
} else if (options) {
|
|
1341
|
-
timeout = options.timeout;
|
|
1342
|
-
pollInterval = options.pollInterval || 1e3;
|
|
1343
|
-
onPoll = options.onPoll;
|
|
1344
|
-
}
|
|
1365
|
+
async waitUntilCompleted(id, options) {
|
|
1366
|
+
const timeout = options?.timeout ?? 30 * 60 * 1e3;
|
|
1367
|
+
const pollInterval = options?.pollInterval ?? 2e3;
|
|
1368
|
+
const onPoll = options?.onPoll;
|
|
1345
1369
|
const startTime = Date.now();
|
|
1346
1370
|
while (true) {
|
|
1347
|
-
const
|
|
1371
|
+
const importItem = await this.get(id);
|
|
1348
1372
|
if (onPoll) {
|
|
1349
|
-
onPoll(
|
|
1373
|
+
onPoll(importItem.status);
|
|
1350
1374
|
}
|
|
1351
|
-
if (
|
|
1352
|
-
return
|
|
1375
|
+
if (importItem.status === "completed" /* completed */) {
|
|
1376
|
+
return importItem;
|
|
1353
1377
|
}
|
|
1354
|
-
if (
|
|
1378
|
+
if (importItem.status === "failed" /* failed */) {
|
|
1355
1379
|
throw new ExaError(
|
|
1356
|
-
`
|
|
1380
|
+
`Import ${id} failed: ${importItem.failedMessage || "Unknown error"}`,
|
|
1381
|
+
400 /* BadRequest */
|
|
1382
|
+
);
|
|
1383
|
+
}
|
|
1384
|
+
if (Date.now() - startTime > timeout) {
|
|
1385
|
+
throw new ExaError(
|
|
1386
|
+
`Import ${id} did not complete within ${timeout}ms. Current status: ${importItem.status}`,
|
|
1357
1387
|
408 /* RequestTimeout */
|
|
1358
1388
|
);
|
|
1359
1389
|
}
|
|
1360
1390
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
1361
1391
|
}
|
|
1362
1392
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1393
|
+
/**
|
|
1394
|
+
* Iterate through all Imports, handling pagination automatically
|
|
1395
|
+
* @param options Pagination options
|
|
1396
|
+
* @returns Async generator of Imports
|
|
1397
|
+
*/
|
|
1398
|
+
async *listAll(options) {
|
|
1399
|
+
let cursor = void 0;
|
|
1400
|
+
const pageOptions = options ? { ...options } : {};
|
|
1401
|
+
while (true) {
|
|
1402
|
+
pageOptions.cursor = cursor;
|
|
1403
|
+
const response = await this.list(pageOptions);
|
|
1404
|
+
for (const importItem of response.data) {
|
|
1405
|
+
yield importItem;
|
|
1406
|
+
}
|
|
1407
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
1408
|
+
break;
|
|
1409
|
+
}
|
|
1410
|
+
cursor = response.nextCursor;
|
|
1411
|
+
}
|
|
1379
1412
|
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1413
|
+
/**
|
|
1414
|
+
* Collect all Imports into an array
|
|
1415
|
+
* @param options Pagination options
|
|
1416
|
+
* @returns Promise resolving to an array of all Imports
|
|
1417
|
+
*/
|
|
1418
|
+
async getAll(options) {
|
|
1419
|
+
const imports = [];
|
|
1420
|
+
for await (const importItem of this.listAll(options)) {
|
|
1421
|
+
imports.push(importItem);
|
|
1422
|
+
}
|
|
1423
|
+
return imports;
|
|
1386
1424
|
}
|
|
1387
1425
|
};
|
|
1426
|
+
|
|
1427
|
+
// src/websets/items.ts
|
|
1388
1428
|
var WebsetItemsClient2 = class extends WebsetsBaseClient2 {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1429
|
+
/**
|
|
1430
|
+
* List all Items for a Webset
|
|
1431
|
+
* @param websetId The ID of the Webset
|
|
1432
|
+
* @param params - Optional pagination and filtering parameters
|
|
1433
|
+
* @returns A promise that resolves with the list of Items
|
|
1434
|
+
*/
|
|
1435
|
+
list(websetId, params) {
|
|
1396
1436
|
const queryParams = {
|
|
1397
|
-
...this.buildPaginationParams(
|
|
1398
|
-
sourceId:
|
|
1437
|
+
...this.buildPaginationParams(params),
|
|
1438
|
+
sourceId: params?.sourceId
|
|
1399
1439
|
};
|
|
1400
1440
|
return this.request(
|
|
1401
1441
|
`/v0/websets/${websetId}/items`,
|
|
@@ -1404,73 +1444,94 @@ var WebsetItemsClient2 = class extends WebsetsBaseClient2 {
|
|
|
1404
1444
|
queryParams
|
|
1405
1445
|
);
|
|
1406
1446
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
)
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
};
|
|
1428
|
-
var WebsetEnrichmentsClient2 = class extends WebsetsBaseClient2 {
|
|
1429
|
-
async create(websetId, params) {
|
|
1430
|
-
return this.request(`/v0/websets/${websetId}/enrichments`, "POST", {
|
|
1431
|
-
...params
|
|
1432
|
-
});
|
|
1447
|
+
/**
|
|
1448
|
+
* Iterate through all Items in a Webset, handling pagination automatically
|
|
1449
|
+
* @param websetId The ID of the Webset
|
|
1450
|
+
* @param options Pagination options
|
|
1451
|
+
* @returns Async generator of Webset Items
|
|
1452
|
+
*/
|
|
1453
|
+
async *listAll(websetId, options) {
|
|
1454
|
+
let cursor = void 0;
|
|
1455
|
+
const pageOptions = options ? { ...options } : {};
|
|
1456
|
+
while (true) {
|
|
1457
|
+
pageOptions.cursor = cursor;
|
|
1458
|
+
const response = await this.list(websetId, pageOptions);
|
|
1459
|
+
for (const item of response.data) {
|
|
1460
|
+
yield item;
|
|
1461
|
+
}
|
|
1462
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
1463
|
+
break;
|
|
1464
|
+
}
|
|
1465
|
+
cursor = response.nextCursor;
|
|
1466
|
+
}
|
|
1433
1467
|
}
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1468
|
+
/**
|
|
1469
|
+
* Collect all items from a Webset into an array
|
|
1470
|
+
* @param websetId The ID of the Webset
|
|
1471
|
+
* @param options Pagination options
|
|
1472
|
+
* @returns Promise resolving to an array of all Webset Items
|
|
1473
|
+
*/
|
|
1474
|
+
async getAll(websetId, options) {
|
|
1475
|
+
const items = [];
|
|
1476
|
+
for await (const item of this.listAll(websetId, options)) {
|
|
1477
|
+
items.push(item);
|
|
1478
|
+
}
|
|
1479
|
+
return items;
|
|
1440
1480
|
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Get an Item by ID
|
|
1483
|
+
* @param websetId The ID of the Webset
|
|
1484
|
+
* @param id The ID of the Item
|
|
1485
|
+
* @returns The Webset Item
|
|
1486
|
+
*/
|
|
1441
1487
|
async get(websetId, id) {
|
|
1442
|
-
return this.request(
|
|
1488
|
+
return this.request(
|
|
1489
|
+
`/v0/websets/${websetId}/items/${id}`,
|
|
1490
|
+
"GET"
|
|
1491
|
+
);
|
|
1443
1492
|
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Delete an Item
|
|
1495
|
+
* @param websetId The ID of the Webset
|
|
1496
|
+
* @param id The ID of the Item
|
|
1497
|
+
* @returns The deleted Webset Item
|
|
1498
|
+
*/
|
|
1444
1499
|
async delete(websetId, id) {
|
|
1445
|
-
return this.request(`/v0/websets/${websetId}/enrichments/${id}`, "DELETE");
|
|
1446
|
-
}
|
|
1447
|
-
async cancel(websetId, id) {
|
|
1448
1500
|
return this.request(
|
|
1449
|
-
`/v0/websets/${websetId}/
|
|
1450
|
-
"
|
|
1501
|
+
`/v0/websets/${websetId}/items/${id}`,
|
|
1502
|
+
"DELETE"
|
|
1451
1503
|
);
|
|
1452
1504
|
}
|
|
1453
1505
|
};
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
const queryParams = {
|
|
1457
|
-
...this.buildPaginationParams(options),
|
|
1458
|
-
types: options?.types,
|
|
1459
|
-
createdBefore: options?.createdBefore,
|
|
1460
|
-
createdAfter: options?.createdAfter
|
|
1461
|
-
};
|
|
1462
|
-
return this.request("/v0/events", "GET", void 0, queryParams);
|
|
1463
|
-
}
|
|
1464
|
-
async get(id) {
|
|
1465
|
-
return this.request(`/v0/events/${id}`, "GET");
|
|
1466
|
-
}
|
|
1467
|
-
};
|
|
1506
|
+
|
|
1507
|
+
// src/websets/monitors.ts
|
|
1468
1508
|
var WebsetMonitorRunsClient2 = class extends WebsetsBaseClient2 {
|
|
1469
|
-
|
|
1470
|
-
|
|
1509
|
+
/**
|
|
1510
|
+
* List all runs for a Monitor
|
|
1511
|
+
* @param monitorId The ID of the Monitor
|
|
1512
|
+
* @param options Pagination options
|
|
1513
|
+
* @returns The list of Monitor runs
|
|
1514
|
+
*/
|
|
1515
|
+
async list(monitorId, options) {
|
|
1516
|
+
const params = this.buildPaginationParams(options);
|
|
1517
|
+
return this.request(
|
|
1518
|
+
`/v0/monitors/${monitorId}/runs`,
|
|
1519
|
+
"GET",
|
|
1520
|
+
void 0,
|
|
1521
|
+
params
|
|
1522
|
+
);
|
|
1471
1523
|
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1524
|
+
/**
|
|
1525
|
+
* Get a specific Monitor run
|
|
1526
|
+
* @param monitorId The ID of the Monitor
|
|
1527
|
+
* @param runId The ID of the Monitor run
|
|
1528
|
+
* @returns The Monitor run
|
|
1529
|
+
*/
|
|
1530
|
+
async get(monitorId, runId) {
|
|
1531
|
+
return this.request(
|
|
1532
|
+
`/v0/monitors/${monitorId}/runs/${runId}`,
|
|
1533
|
+
"GET"
|
|
1534
|
+
);
|
|
1474
1535
|
}
|
|
1475
1536
|
};
|
|
1476
1537
|
var WebsetMonitorsClient2 = class extends WebsetsBaseClient2 {
|
|
@@ -1478,435 +1539,443 @@ var WebsetMonitorsClient2 = class extends WebsetsBaseClient2 {
|
|
|
1478
1539
|
super(client);
|
|
1479
1540
|
this.runs = new WebsetMonitorRunsClient2(client);
|
|
1480
1541
|
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Create a Monitor
|
|
1544
|
+
* @param params The monitor parameters
|
|
1545
|
+
* @returns The created Monitor
|
|
1546
|
+
*/
|
|
1481
1547
|
async create(params) {
|
|
1482
|
-
return this.request("/v0/monitors", "POST",
|
|
1483
|
-
}
|
|
1484
|
-
async list(options) {
|
|
1485
|
-
const queryParams = {
|
|
1486
|
-
...this.buildPaginationParams(options),
|
|
1487
|
-
websetId: options?.websetId
|
|
1488
|
-
};
|
|
1489
|
-
return this.request("/v0/monitors", "GET", void 0, queryParams);
|
|
1548
|
+
return this.request("/v0/monitors", "POST", params);
|
|
1490
1549
|
}
|
|
1550
|
+
/**
|
|
1551
|
+
* Get a Monitor by ID
|
|
1552
|
+
* @param id The ID of the Monitor
|
|
1553
|
+
* @returns The Monitor
|
|
1554
|
+
*/
|
|
1491
1555
|
async get(id) {
|
|
1492
1556
|
return this.request(`/v0/monitors/${id}`, "GET");
|
|
1493
1557
|
}
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
}
|
|
1500
|
-
};
|
|
1501
|
-
var WebsetWebhooksClient2 = class extends WebsetsBaseClient2 {
|
|
1502
|
-
async create(params) {
|
|
1503
|
-
return this.request("/v0/webhooks", "POST", { ...params });
|
|
1504
|
-
}
|
|
1558
|
+
/**
|
|
1559
|
+
* List all Monitors
|
|
1560
|
+
* @param options Pagination and filtering options
|
|
1561
|
+
* @returns The list of Monitors
|
|
1562
|
+
*/
|
|
1505
1563
|
async list(options) {
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
return this.request(`/v0/webhooks/${id}`, "GET");
|
|
1511
|
-
}
|
|
1512
|
-
async update(id, params) {
|
|
1513
|
-
return this.request(`/v0/webhooks/${id}`, "PATCH", { ...params });
|
|
1514
|
-
}
|
|
1515
|
-
async delete(id) {
|
|
1516
|
-
return this.request(`/v0/webhooks/${id}`, "DELETE");
|
|
1517
|
-
}
|
|
1518
|
-
async listAttempts(id, options) {
|
|
1519
|
-
const queryParams = {
|
|
1520
|
-
...this.buildPaginationParams(options),
|
|
1521
|
-
eventType: options?.eventType,
|
|
1522
|
-
successful: options?.successful
|
|
1564
|
+
const params = {
|
|
1565
|
+
cursor: options?.cursor,
|
|
1566
|
+
limit: options?.limit,
|
|
1567
|
+
websetId: options?.websetId
|
|
1523
1568
|
};
|
|
1524
1569
|
return this.request(
|
|
1525
|
-
|
|
1570
|
+
"/v0/monitors",
|
|
1526
1571
|
"GET",
|
|
1527
1572
|
void 0,
|
|
1528
|
-
|
|
1529
|
-
);
|
|
1530
|
-
}
|
|
1531
|
-
};
|
|
1532
|
-
var ImportsClient2 = class extends WebsetsBaseClient2 {
|
|
1533
|
-
async create(params) {
|
|
1534
|
-
return this.request("/v0/imports", "POST", { ...params });
|
|
1535
|
-
}
|
|
1536
|
-
async list(options) {
|
|
1537
|
-
const queryParams = this.buildPaginationParams(options);
|
|
1538
|
-
return this.request("/v0/imports", "GET", void 0, queryParams);
|
|
1539
|
-
}
|
|
1540
|
-
async get(id) {
|
|
1541
|
-
return this.request(`/v0/imports/${id}`, "GET");
|
|
1542
|
-
}
|
|
1543
|
-
async update(id, params) {
|
|
1544
|
-
return this.request(`/v0/imports/${id}`, "PATCH", { ...params });
|
|
1545
|
-
}
|
|
1546
|
-
async delete(id) {
|
|
1547
|
-
return this.request(`/v0/imports/${id}`, "DELETE");
|
|
1548
|
-
}
|
|
1549
|
-
};
|
|
1550
|
-
var WebsetsClient2 = class extends WebsetsBaseClient2 {
|
|
1551
|
-
constructor(client) {
|
|
1552
|
-
super(client);
|
|
1553
|
-
this.items = new WebsetItemsClient2(client);
|
|
1554
|
-
this.searches = new WebsetSearchesClient2(client);
|
|
1555
|
-
this.enrichments = new WebsetEnrichmentsClient2(client);
|
|
1556
|
-
this.events = new EventsClient2(client);
|
|
1557
|
-
this.monitors = new WebsetMonitorsClient2(client);
|
|
1558
|
-
this.webhooks = new WebsetWebhooksClient2(client);
|
|
1559
|
-
this.imports = new ImportsClient2(client);
|
|
1560
|
-
}
|
|
1561
|
-
async create(params, options) {
|
|
1562
|
-
return this.request(
|
|
1563
|
-
"/v0/websets",
|
|
1564
|
-
"POST",
|
|
1565
|
-
{ ...params },
|
|
1566
|
-
void 0,
|
|
1567
|
-
options?.headers
|
|
1573
|
+
params
|
|
1568
1574
|
);
|
|
1569
1575
|
}
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
}
|
|
1577
|
-
async get(id, options) {
|
|
1578
|
-
const queryParams = { expand: options?.expand };
|
|
1579
|
-
return this.request(`/v0/websets/${id}`, "GET", void 0, queryParams);
|
|
1580
|
-
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Update a Monitor
|
|
1578
|
+
* @param id The ID of the Monitor
|
|
1579
|
+
* @param params The monitor update parameters (status, metadata)
|
|
1580
|
+
* @returns The updated Monitor
|
|
1581
|
+
*/
|
|
1581
1582
|
async update(id, params) {
|
|
1582
|
-
return this.request(`/v0/
|
|
1583
|
+
return this.request(`/v0/monitors/${id}`, "PATCH", params);
|
|
1583
1584
|
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Delete a Monitor
|
|
1587
|
+
* @param id The ID of the Monitor
|
|
1588
|
+
* @returns The deleted Monitor
|
|
1589
|
+
*/
|
|
1584
1590
|
async delete(id) {
|
|
1585
|
-
return this.request(`/v0/
|
|
1586
|
-
}
|
|
1587
|
-
async cancel(id) {
|
|
1588
|
-
return this.request(`/v0/websets/${id}/cancel`, "POST");
|
|
1589
|
-
}
|
|
1590
|
-
async preview(params, options) {
|
|
1591
|
-
const queryParams = { search: options?.search };
|
|
1592
|
-
return this.request(
|
|
1593
|
-
"/v0/websets/preview",
|
|
1594
|
-
"POST",
|
|
1595
|
-
{ ...params },
|
|
1596
|
-
queryParams
|
|
1597
|
-
);
|
|
1591
|
+
return this.request(`/v0/monitors/${id}`, "DELETE");
|
|
1598
1592
|
}
|
|
1599
|
-
/**
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
timeout = options.timeout;
|
|
1608
|
-
pollInterval = options.pollInterval || 1e3;
|
|
1609
|
-
onPoll = options.onPoll;
|
|
1610
|
-
}
|
|
1611
|
-
const startTime = Date.now();
|
|
1593
|
+
/**
|
|
1594
|
+
* Iterate through all Monitors, handling pagination automatically
|
|
1595
|
+
* @param options Pagination and filtering options
|
|
1596
|
+
* @returns Async generator of Monitors
|
|
1597
|
+
*/
|
|
1598
|
+
async *listAll(options) {
|
|
1599
|
+
let cursor = void 0;
|
|
1600
|
+
const pageOptions = options ? { ...options } : {};
|
|
1612
1601
|
while (true) {
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
throw new Error(
|
|
1618
|
-
`Webset ${id} did not reach idle state within ${timeout}ms. Current status: ${webset.status}`
|
|
1619
|
-
);
|
|
1602
|
+
pageOptions.cursor = cursor;
|
|
1603
|
+
const response = await this.list(pageOptions);
|
|
1604
|
+
for (const monitor of response.data) {
|
|
1605
|
+
yield monitor;
|
|
1620
1606
|
}
|
|
1621
|
-
|
|
1607
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
1608
|
+
break;
|
|
1609
|
+
}
|
|
1610
|
+
cursor = response.nextCursor;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
/**
|
|
1614
|
+
* Collect all Monitors into an array
|
|
1615
|
+
* @param options Pagination and filtering options
|
|
1616
|
+
* @returns Promise resolving to an array of all Monitors
|
|
1617
|
+
*/
|
|
1618
|
+
async getAll(options) {
|
|
1619
|
+
const monitors = [];
|
|
1620
|
+
for await (const monitor of this.listAll(options)) {
|
|
1621
|
+
monitors.push(monitor);
|
|
1622
1622
|
}
|
|
1623
|
+
return monitors;
|
|
1623
1624
|
}
|
|
1624
1625
|
};
|
|
1625
1626
|
|
|
1626
|
-
// src/
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1627
|
+
// src/websets/searches.ts
|
|
1628
|
+
var WebsetSearchesClient2 = class extends WebsetsBaseClient2 {
|
|
1629
|
+
/**
|
|
1630
|
+
* Create a new Search for the Webset
|
|
1631
|
+
* @param websetId The ID of the Webset
|
|
1632
|
+
* @param params The search parameters
|
|
1633
|
+
* @returns The created Webset Search
|
|
1634
|
+
*/
|
|
1635
|
+
async create(websetId, params, options) {
|
|
1636
|
+
return this.request(
|
|
1637
|
+
`/v0/websets/${websetId}/searches`,
|
|
1638
|
+
"POST",
|
|
1639
|
+
params,
|
|
1640
|
+
void 0,
|
|
1641
|
+
options?.headers
|
|
1642
|
+
);
|
|
1635
1643
|
}
|
|
1636
|
-
/**
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1644
|
+
/**
|
|
1645
|
+
* Get a Search by ID
|
|
1646
|
+
* @param websetId The ID of the Webset
|
|
1647
|
+
* @param id The ID of the Search
|
|
1648
|
+
* @returns The Webset Search
|
|
1649
|
+
*/
|
|
1650
|
+
async get(websetId, id) {
|
|
1651
|
+
return this.request(
|
|
1652
|
+
`/v0/websets/${websetId}/searches/${id}`,
|
|
1653
|
+
"GET"
|
|
1643
1654
|
);
|
|
1644
1655
|
}
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1656
|
+
/**
|
|
1657
|
+
* Cancel a running Search
|
|
1658
|
+
* @param websetId The ID of the Webset
|
|
1659
|
+
* @param id The ID of the Search
|
|
1660
|
+
* @returns The canceled Webset Search
|
|
1661
|
+
*/
|
|
1662
|
+
async cancel(websetId, id) {
|
|
1663
|
+
return this.request(
|
|
1664
|
+
`/v0/websets/${websetId}/searches/${id}/cancel`,
|
|
1665
|
+
"POST"
|
|
1666
|
+
);
|
|
1651
1667
|
}
|
|
1652
1668
|
};
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1669
|
+
|
|
1670
|
+
// src/websets/webhooks.ts
|
|
1671
|
+
var WebsetWebhooksClient2 = class extends WebsetsBaseClient2 {
|
|
1672
|
+
/**
|
|
1673
|
+
* Create a Webhook
|
|
1674
|
+
* @param params The webhook parameters
|
|
1675
|
+
* @returns The created Webhook
|
|
1676
|
+
*/
|
|
1660
1677
|
async create(params) {
|
|
1661
|
-
|
|
1662
|
-
if (schema instanceof ZodType2) {
|
|
1663
|
-
schema = zodToJsonSchema2(schema);
|
|
1664
|
-
}
|
|
1665
|
-
const payload = {
|
|
1666
|
-
instructions: params.instructions,
|
|
1667
|
-
model: params.model ?? "exa-research-fast"
|
|
1668
|
-
};
|
|
1669
|
-
if (schema) {
|
|
1670
|
-
payload.outputSchema = schema;
|
|
1671
|
-
}
|
|
1672
|
-
return this.client.request("/research/v1", "POST", payload, void 0);
|
|
1678
|
+
return this.request("/v0/webhooks", "POST", params);
|
|
1673
1679
|
}
|
|
1674
|
-
/**
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1680
|
+
/**
|
|
1681
|
+
* Get a Webhook by ID
|
|
1682
|
+
* @param id The ID of the Webhook
|
|
1683
|
+
* @returns The Webhook
|
|
1684
|
+
*/
|
|
1685
|
+
async get(id) {
|
|
1686
|
+
return this.request(`/v0/webhooks/${id}`, "GET");
|
|
1687
|
+
}
|
|
1688
|
+
/**
|
|
1689
|
+
* List all Webhooks
|
|
1690
|
+
* @param options Pagination options
|
|
1691
|
+
* @returns The list of Webhooks
|
|
1692
|
+
*/
|
|
1693
|
+
async list(options) {
|
|
1694
|
+
const params = this.buildPaginationParams(options);
|
|
1695
|
+
return this.request(
|
|
1696
|
+
"/v0/webhooks",
|
|
1681
1697
|
"GET",
|
|
1682
1698
|
void 0,
|
|
1683
1699
|
params
|
|
1684
1700
|
);
|
|
1685
1701
|
}
|
|
1686
|
-
/**
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
let
|
|
1702
|
+
/**
|
|
1703
|
+
* Iterate through all Webhooks, handling pagination automatically
|
|
1704
|
+
* @param options Pagination options
|
|
1705
|
+
* @returns Async generator of Webhooks
|
|
1706
|
+
*/
|
|
1707
|
+
async *listAll(options) {
|
|
1708
|
+
let cursor = void 0;
|
|
1709
|
+
const pageOptions = options ? { ...options } : {};
|
|
1693
1710
|
while (true) {
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
consecutiveFailures = 0;
|
|
1699
|
-
if (research.status === "completed" || research.status === "failed" || research.status === "canceled") {
|
|
1700
|
-
return research;
|
|
1701
|
-
}
|
|
1702
|
-
} catch (err) {
|
|
1703
|
-
consecutiveFailures += 1;
|
|
1704
|
-
if (consecutiveFailures >= maxConsecutiveFailures) {
|
|
1705
|
-
throw new Error(
|
|
1706
|
-
`Polling failed ${maxConsecutiveFailures} times in a row for research ${researchId}: ${err}`
|
|
1707
|
-
);
|
|
1708
|
-
}
|
|
1711
|
+
pageOptions.cursor = cursor;
|
|
1712
|
+
const response = await this.list(pageOptions);
|
|
1713
|
+
for (const webhook of response.data) {
|
|
1714
|
+
yield webhook;
|
|
1709
1715
|
}
|
|
1710
|
-
if (
|
|
1711
|
-
|
|
1712
|
-
`Polling timeout: Research ${researchId} did not complete within ${timeoutMs}ms`
|
|
1713
|
-
);
|
|
1716
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
1717
|
+
break;
|
|
1714
1718
|
}
|
|
1715
|
-
|
|
1719
|
+
cursor = response.nextCursor;
|
|
1716
1720
|
}
|
|
1717
1721
|
}
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
"extras",
|
|
1728
|
-
"livecrawl",
|
|
1729
|
-
"livecrawlTimeout",
|
|
1730
|
-
"maxAgeHours",
|
|
1731
|
-
"filterEmptyResults",
|
|
1732
|
-
"context"
|
|
1733
|
-
]);
|
|
1734
|
-
var DEFAULT_MAX_CHARACTERS = 1e4;
|
|
1735
|
-
var Exa2 = class {
|
|
1736
|
-
constructor(apiKey, baseURL = "https://api.exa.ai") {
|
|
1737
|
-
this.baseURL = baseURL;
|
|
1738
|
-
if (!apiKey) {
|
|
1739
|
-
apiKey = typeof process !== "undefined" ? process.env?.EXA_API_KEY : void 0;
|
|
1740
|
-
if (!apiKey) {
|
|
1741
|
-
throw new Error(
|
|
1742
|
-
"API key must be provided as an argument or as an environment variable (EXA_API_KEY)"
|
|
1743
|
-
);
|
|
1744
|
-
}
|
|
1722
|
+
/**
|
|
1723
|
+
* Collect all Webhooks into an array
|
|
1724
|
+
* @param options Pagination options
|
|
1725
|
+
* @returns Promise resolving to an array of all Webhooks
|
|
1726
|
+
*/
|
|
1727
|
+
async getAll(options) {
|
|
1728
|
+
const webhooks = [];
|
|
1729
|
+
for await (const webhook of this.listAll(options)) {
|
|
1730
|
+
webhooks.push(webhook);
|
|
1745
1731
|
}
|
|
1746
|
-
|
|
1747
|
-
"x-api-key": apiKey,
|
|
1748
|
-
"Content-Type": "application/json"
|
|
1749
|
-
};
|
|
1750
|
-
this.websets = new WebsetsClient2(this);
|
|
1751
|
-
this.research = new ResearchClient2(this);
|
|
1732
|
+
return webhooks;
|
|
1752
1733
|
}
|
|
1753
|
-
/**
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
for (const item of value) {
|
|
1762
|
-
searchParams.append(key, item);
|
|
1763
|
-
}
|
|
1764
|
-
} else if (value !== void 0) {
|
|
1765
|
-
searchParams.append(key, String(value));
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
url += `?${searchParams.toString()}`;
|
|
1769
|
-
}
|
|
1770
|
-
const combinedHeaders = headers ? { ...this.headers, ...headers } : this.headers;
|
|
1771
|
-
const response = await fetch(url, {
|
|
1772
|
-
method,
|
|
1773
|
-
headers: combinedHeaders,
|
|
1774
|
-
body: normalizedBody ? JSON.stringify(normalizedBody) : void 0
|
|
1775
|
-
});
|
|
1776
|
-
if (!response.ok) {
|
|
1777
|
-
const text = await response.text();
|
|
1778
|
-
throw new Error(`Exa API error ${response.status}: ${text}`);
|
|
1779
|
-
}
|
|
1780
|
-
return await response.json();
|
|
1734
|
+
/**
|
|
1735
|
+
* Update a Webhook
|
|
1736
|
+
* @param id The ID of the Webhook
|
|
1737
|
+
* @param params The webhook update parameters (events, metadata, url)
|
|
1738
|
+
* @returns The updated Webhook
|
|
1739
|
+
*/
|
|
1740
|
+
async update(id, params) {
|
|
1741
|
+
return this.request(`/v0/webhooks/${id}`, "PATCH", params);
|
|
1781
1742
|
}
|
|
1782
|
-
/**
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
if (Array.isArray(value)) {
|
|
1790
|
-
for (const item of value) {
|
|
1791
|
-
searchParams.append(key, item);
|
|
1792
|
-
}
|
|
1793
|
-
} else if (value !== void 0) {
|
|
1794
|
-
searchParams.append(key, String(value));
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
url += `?${searchParams.toString()}`;
|
|
1798
|
-
}
|
|
1799
|
-
return fetch(url, {
|
|
1800
|
-
method,
|
|
1801
|
-
headers: this.headers,
|
|
1802
|
-
body: normalizedBody ? JSON.stringify(normalizedBody) : void 0
|
|
1803
|
-
});
|
|
1743
|
+
/**
|
|
1744
|
+
* Delete a Webhook
|
|
1745
|
+
* @param id The ID of the Webhook
|
|
1746
|
+
* @returns The deleted Webhook
|
|
1747
|
+
*/
|
|
1748
|
+
async delete(id) {
|
|
1749
|
+
return this.request(`/v0/webhooks/${id}`, "DELETE");
|
|
1804
1750
|
}
|
|
1805
|
-
/**
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1751
|
+
/**
|
|
1752
|
+
* List all attempts for a Webhook
|
|
1753
|
+
* @param id The ID of the Webhook
|
|
1754
|
+
* @param options Pagination and filtering options
|
|
1755
|
+
* @returns The list of Webhook attempts
|
|
1756
|
+
*/
|
|
1757
|
+
async listAttempts(id, options) {
|
|
1758
|
+
const params = {
|
|
1759
|
+
cursor: options?.cursor,
|
|
1760
|
+
limit: options?.limit,
|
|
1761
|
+
eventType: options?.eventType,
|
|
1762
|
+
successful: options?.successful
|
|
1763
|
+
};
|
|
1764
|
+
return this.request(
|
|
1765
|
+
`/v0/webhooks/${id}/attempts`,
|
|
1766
|
+
"GET",
|
|
1767
|
+
void 0,
|
|
1768
|
+
params
|
|
1769
|
+
);
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* Iterate through all attempts for a Webhook, handling pagination automatically
|
|
1773
|
+
* @param id The ID of the Webhook
|
|
1774
|
+
* @param options Pagination and filtering options
|
|
1775
|
+
* @returns Async generator of Webhook attempts
|
|
1776
|
+
*/
|
|
1777
|
+
async *listAllAttempts(id, options) {
|
|
1778
|
+
let cursor = void 0;
|
|
1779
|
+
const pageOptions = options ? { ...options } : {};
|
|
1780
|
+
while (true) {
|
|
1781
|
+
pageOptions.cursor = cursor;
|
|
1782
|
+
const response = await this.listAttempts(id, pageOptions);
|
|
1783
|
+
for (const attempt of response.data) {
|
|
1784
|
+
yield attempt;
|
|
1785
|
+
}
|
|
1786
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
1787
|
+
break;
|
|
1788
|
+
}
|
|
1789
|
+
cursor = response.nextCursor;
|
|
1809
1790
|
}
|
|
1810
|
-
return { ...body, category: body.category.replace(/ /g, "_") };
|
|
1811
1791
|
}
|
|
1812
|
-
/**
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
restOptions[key] = value;
|
|
1823
|
-
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Collect all attempts for a Webhook into an array
|
|
1794
|
+
* @param id The ID of the Webhook
|
|
1795
|
+
* @param options Pagination and filtering options
|
|
1796
|
+
* @returns Promise resolving to an array of all Webhook attempts
|
|
1797
|
+
*/
|
|
1798
|
+
async getAllAttempts(id, options) {
|
|
1799
|
+
const attempts = [];
|
|
1800
|
+
for await (const attempt of this.listAllAttempts(id, options)) {
|
|
1801
|
+
attempts.push(attempt);
|
|
1824
1802
|
}
|
|
1825
|
-
|
|
1826
|
-
|
|
1803
|
+
return attempts;
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
|
|
1807
|
+
// src/websets/client.ts
|
|
1808
|
+
var WebsetsClient2 = class extends WebsetsBaseClient2 {
|
|
1809
|
+
/**
|
|
1810
|
+
* Initialize a new Websets client
|
|
1811
|
+
* @param client The Exa client instance
|
|
1812
|
+
*/
|
|
1813
|
+
constructor(client) {
|
|
1814
|
+
super(client);
|
|
1815
|
+
this.events = new EventsClient2(client);
|
|
1816
|
+
this.imports = new ImportsClient2(client);
|
|
1817
|
+
this.items = new WebsetItemsClient2(client);
|
|
1818
|
+
this.searches = new WebsetSearchesClient2(client);
|
|
1819
|
+
this.enrichments = new WebsetEnrichmentsClient2(client);
|
|
1820
|
+
this.monitors = new WebsetMonitorsClient2(client);
|
|
1821
|
+
this.webhooks = new WebsetWebhooksClient2(client);
|
|
1822
|
+
}
|
|
1823
|
+
/**
|
|
1824
|
+
* Create a new Webset
|
|
1825
|
+
* @param params The Webset creation parameters
|
|
1826
|
+
* @returns The created Webset
|
|
1827
|
+
*/
|
|
1828
|
+
async create(params, options) {
|
|
1829
|
+
return this.request(
|
|
1830
|
+
"/v0/websets",
|
|
1831
|
+
"POST",
|
|
1832
|
+
params,
|
|
1833
|
+
void 0,
|
|
1834
|
+
options?.headers
|
|
1835
|
+
);
|
|
1836
|
+
}
|
|
1837
|
+
/**
|
|
1838
|
+
* Preview a webset
|
|
1839
|
+
* @param params The preview parameters
|
|
1840
|
+
* @param options Optional parameters. Search = true allows you to retrieve a preview set of items that could be returned by the webset.
|
|
1841
|
+
* @returns The preview response showing how the query will be decomposed
|
|
1842
|
+
*/
|
|
1843
|
+
async preview(params, options) {
|
|
1844
|
+
const queryParams = {};
|
|
1845
|
+
if (options?.search !== void 0) {
|
|
1846
|
+
queryParams.search = options.search;
|
|
1827
1847
|
}
|
|
1828
|
-
return
|
|
1848
|
+
return this.request(
|
|
1849
|
+
"/v0/websets/preview",
|
|
1850
|
+
"POST",
|
|
1851
|
+
params,
|
|
1852
|
+
queryParams
|
|
1853
|
+
);
|
|
1829
1854
|
}
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
body = { query, ...restOptions };
|
|
1841
|
-
} else {
|
|
1842
|
-
body = { query, ...options };
|
|
1855
|
+
/**
|
|
1856
|
+
* Get a Webset by ID
|
|
1857
|
+
* @param id The ID of the Webset
|
|
1858
|
+
* @param expand Optional array of relations to expand
|
|
1859
|
+
* @returns The Webset
|
|
1860
|
+
*/
|
|
1861
|
+
async get(id, expand) {
|
|
1862
|
+
const params = {};
|
|
1863
|
+
if (expand) {
|
|
1864
|
+
params.expand = expand;
|
|
1843
1865
|
}
|
|
1844
|
-
return this.request(
|
|
1866
|
+
return this.request(
|
|
1867
|
+
`/v0/websets/${id}`,
|
|
1868
|
+
"GET",
|
|
1869
|
+
void 0,
|
|
1870
|
+
params
|
|
1871
|
+
);
|
|
1845
1872
|
}
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1873
|
+
/**
|
|
1874
|
+
* List all Websets
|
|
1875
|
+
* @param options Pagination options (filtering by status is not supported by API)
|
|
1876
|
+
* @returns The list of Websets
|
|
1877
|
+
*/
|
|
1878
|
+
async list(options) {
|
|
1879
|
+
const params = this.buildPaginationParams(options);
|
|
1880
|
+
return this.request(
|
|
1881
|
+
"/v0/websets",
|
|
1882
|
+
"GET",
|
|
1883
|
+
void 0,
|
|
1884
|
+
params
|
|
1885
|
+
);
|
|
1886
|
+
}
|
|
1887
|
+
/**
|
|
1888
|
+
* Iterate through all Websets, handling pagination automatically
|
|
1889
|
+
* @param options Pagination options
|
|
1890
|
+
* @returns Async generator of Websets
|
|
1891
|
+
*/
|
|
1892
|
+
async *listAll(options) {
|
|
1893
|
+
let cursor = void 0;
|
|
1894
|
+
const pageOptions = options ? { ...options } : {};
|
|
1895
|
+
while (true) {
|
|
1896
|
+
pageOptions.cursor = cursor;
|
|
1897
|
+
const response = await this.list(pageOptions);
|
|
1898
|
+
for (const webset of response.data) {
|
|
1899
|
+
yield webset;
|
|
1900
|
+
}
|
|
1901
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
1902
|
+
break;
|
|
1903
|
+
}
|
|
1904
|
+
cursor = response.nextCursor;
|
|
1859
1905
|
}
|
|
1860
|
-
return this.request("/findSimilar", "POST", body);
|
|
1861
1906
|
}
|
|
1862
|
-
|
|
1863
|
-
|
|
1907
|
+
/**
|
|
1908
|
+
* Collect all Websets into an array
|
|
1909
|
+
* @param options Pagination options
|
|
1910
|
+
* @returns Promise resolving to an array of all Websets
|
|
1911
|
+
*/
|
|
1912
|
+
async getAll(options) {
|
|
1913
|
+
const websets = [];
|
|
1914
|
+
for await (const webset of this.listAll(options)) {
|
|
1915
|
+
websets.push(webset);
|
|
1916
|
+
}
|
|
1917
|
+
return websets;
|
|
1864
1918
|
}
|
|
1865
|
-
|
|
1866
|
-
|
|
1919
|
+
/**
|
|
1920
|
+
* Update a Webset
|
|
1921
|
+
* @param id The ID of the Webset
|
|
1922
|
+
* @param params The Webset update parameters
|
|
1923
|
+
* @returns The updated Webset
|
|
1924
|
+
*/
|
|
1925
|
+
async update(id, params) {
|
|
1926
|
+
return this.request(`/v0/websets/${id}`, "POST", params);
|
|
1867
1927
|
}
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1928
|
+
/**
|
|
1929
|
+
* Delete a Webset
|
|
1930
|
+
* @param id The ID of the Webset
|
|
1931
|
+
* @returns The deleted Webset
|
|
1932
|
+
*/
|
|
1933
|
+
async delete(id) {
|
|
1934
|
+
return this.request(`/v0/websets/${id}`, "DELETE");
|
|
1874
1935
|
}
|
|
1875
1936
|
/**
|
|
1876
|
-
*
|
|
1877
|
-
*
|
|
1937
|
+
* Cancel a running Webset
|
|
1938
|
+
* @param id The ID or external ID of the Webset
|
|
1939
|
+
* @returns The canceled Webset (as returned by the API)
|
|
1878
1940
|
*/
|
|
1879
|
-
async
|
|
1880
|
-
|
|
1881
|
-
return this.request("/search", "POST", {
|
|
1882
|
-
query,
|
|
1883
|
-
contents: { text: { maxCharacters: DEFAULT_MAX_CHARACTERS } }
|
|
1884
|
-
});
|
|
1885
|
-
}
|
|
1886
|
-
const { contentsOptions, restOptions } = this.extractContentsOptions(options);
|
|
1887
|
-
return this.request("/search", "POST", {
|
|
1888
|
-
query,
|
|
1889
|
-
contents: contentsOptions,
|
|
1890
|
-
...restOptions
|
|
1891
|
-
});
|
|
1941
|
+
async cancel(id) {
|
|
1942
|
+
return this.request(`/v0/websets/${id}/cancel`, "POST");
|
|
1892
1943
|
}
|
|
1893
1944
|
/**
|
|
1894
|
-
*
|
|
1895
|
-
*
|
|
1945
|
+
* Wait until a Webset is idle
|
|
1946
|
+
* @param id The ID of the Webset
|
|
1947
|
+
* @param options Configuration options for timeout and polling
|
|
1948
|
+
* @returns The Webset once it becomes idle
|
|
1949
|
+
* @throws Error if the Webset does not become idle within the timeout
|
|
1896
1950
|
*/
|
|
1897
|
-
async
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1951
|
+
async waitUntilIdle(id, options) {
|
|
1952
|
+
let timeout;
|
|
1953
|
+
let pollInterval = 1e3;
|
|
1954
|
+
let onPoll;
|
|
1955
|
+
if (typeof options === "number") {
|
|
1956
|
+
timeout = options;
|
|
1957
|
+
} else if (options) {
|
|
1958
|
+
timeout = options.timeout;
|
|
1959
|
+
pollInterval = options.pollInterval || 1e3;
|
|
1960
|
+
onPoll = options.onPoll;
|
|
1961
|
+
}
|
|
1962
|
+
const startTime = Date.now();
|
|
1963
|
+
while (true) {
|
|
1964
|
+
const webset = await this.get(id);
|
|
1965
|
+
if (onPoll) {
|
|
1966
|
+
onPoll(webset.status);
|
|
1967
|
+
}
|
|
1968
|
+
if (webset.status === "idle" /* idle */) {
|
|
1969
|
+
return webset;
|
|
1970
|
+
}
|
|
1971
|
+
if (timeout && Date.now() - startTime > timeout) {
|
|
1972
|
+
throw new ExaError(
|
|
1973
|
+
`Webset ${id} did not reach idle state within ${timeout}ms. Current status: ${webset.status}`,
|
|
1974
|
+
408 /* RequestTimeout */
|
|
1975
|
+
);
|
|
1976
|
+
}
|
|
1977
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
1903
1978
|
}
|
|
1904
|
-
const { contentsOptions, restOptions } = this.extractContentsOptions(options);
|
|
1905
|
-
return this.request("/findSimilar", "POST", {
|
|
1906
|
-
url,
|
|
1907
|
-
contents: contentsOptions,
|
|
1908
|
-
...restOptions
|
|
1909
|
-
});
|
|
1910
1979
|
}
|
|
1911
1980
|
};
|
|
1912
1981
|
|
|
@@ -1942,7 +2011,7 @@ var Exa3 = class {
|
|
|
1942
2011
|
if (typeof summary === "object" && summary !== null && "schema" in summary && summary.schema && isZodSchema(summary.schema)) {
|
|
1943
2012
|
contentsOptions.summary = {
|
|
1944
2013
|
...summary,
|
|
1945
|
-
schema:
|
|
2014
|
+
schema: zodToJsonSchema2(summary.schema)
|
|
1946
2015
|
};
|
|
1947
2016
|
} else {
|
|
1948
2017
|
contentsOptions.summary = summary;
|
|
@@ -1983,8 +2052,8 @@ var Exa3 = class {
|
|
|
1983
2052
|
"Content-Type": "application/json",
|
|
1984
2053
|
"User-Agent": `exa-node ${package_default.version}`
|
|
1985
2054
|
});
|
|
1986
|
-
this.websets = new
|
|
1987
|
-
this.research = new
|
|
2055
|
+
this.websets = new WebsetsClient2(this);
|
|
2056
|
+
this.research = new ResearchClient2(this);
|
|
1988
2057
|
}
|
|
1989
2058
|
/**
|
|
1990
2059
|
* Makes a request to the Exa API.
|
|
@@ -2196,7 +2265,7 @@ var Exa3 = class {
|
|
|
2196
2265
|
}
|
|
2197
2266
|
let outputSchema = options?.outputSchema;
|
|
2198
2267
|
if (outputSchema && isZodSchema(outputSchema)) {
|
|
2199
|
-
outputSchema =
|
|
2268
|
+
outputSchema = zodToJsonSchema2(outputSchema);
|
|
2200
2269
|
}
|
|
2201
2270
|
const requestBody = {
|
|
2202
2271
|
query,
|
|
@@ -2212,7 +2281,7 @@ var Exa3 = class {
|
|
|
2212
2281
|
async *streamAnswer(query, options) {
|
|
2213
2282
|
let outputSchema = options?.outputSchema;
|
|
2214
2283
|
if (outputSchema && isZodSchema(outputSchema)) {
|
|
2215
|
-
outputSchema =
|
|
2284
|
+
outputSchema = zodToJsonSchema2(outputSchema);
|
|
2216
2285
|
}
|
|
2217
2286
|
const body = {
|
|
2218
2287
|
query,
|
|
@@ -2379,16 +2448,16 @@ export {
|
|
|
2379
2448
|
CreateEnrichmentParametersFormat,
|
|
2380
2449
|
CreateImportParametersFormat,
|
|
2381
2450
|
EventType,
|
|
2382
|
-
EventsClient,
|
|
2451
|
+
EventsClient2 as EventsClient,
|
|
2383
2452
|
Exa3 as Exa,
|
|
2384
2453
|
ExaError,
|
|
2385
|
-
|
|
2454
|
+
Exa as ExaNova,
|
|
2386
2455
|
HttpStatusCode,
|
|
2387
2456
|
ImportFailedReason,
|
|
2388
2457
|
ImportFormat,
|
|
2389
2458
|
ImportObject,
|
|
2390
2459
|
ImportStatus,
|
|
2391
|
-
ImportsClient,
|
|
2460
|
+
ImportsClient2 as ImportsClient,
|
|
2392
2461
|
MonitorObject,
|
|
2393
2462
|
MonitorRunObject,
|
|
2394
2463
|
MonitorRunStatus,
|
|
@@ -2398,21 +2467,21 @@ export {
|
|
|
2398
2467
|
WebhookStatus,
|
|
2399
2468
|
WebsetEnrichmentFormat,
|
|
2400
2469
|
WebsetEnrichmentStatus,
|
|
2401
|
-
WebsetEnrichmentsClient,
|
|
2470
|
+
WebsetEnrichmentsClient2 as WebsetEnrichmentsClient,
|
|
2402
2471
|
WebsetExcludeSource,
|
|
2403
2472
|
WebsetImportSource,
|
|
2404
2473
|
WebsetItemEvaluationSatisfied,
|
|
2405
2474
|
WebsetItemSource,
|
|
2406
|
-
WebsetItemsClient,
|
|
2407
|
-
WebsetMonitorsClient,
|
|
2475
|
+
WebsetItemsClient2 as WebsetItemsClient,
|
|
2476
|
+
WebsetMonitorsClient2 as WebsetMonitorsClient,
|
|
2408
2477
|
WebsetSearchBehavior,
|
|
2409
2478
|
WebsetSearchCanceledReason,
|
|
2410
2479
|
WebsetSearchScopeSource,
|
|
2411
2480
|
WebsetSearchStatus,
|
|
2412
|
-
WebsetSearchesClient,
|
|
2481
|
+
WebsetSearchesClient2 as WebsetSearchesClient,
|
|
2413
2482
|
WebsetStatus,
|
|
2414
|
-
WebsetWebhooksClient,
|
|
2415
|
-
WebsetsClient,
|
|
2483
|
+
WebsetWebhooksClient2 as WebsetWebhooksClient,
|
|
2484
|
+
WebsetsClient2 as WebsetsClient,
|
|
2416
2485
|
index_default as default
|
|
2417
2486
|
};
|
|
2418
2487
|
//# sourceMappingURL=index.mjs.map
|