exa-js 2.8.0 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -48
- package/dist/index.d.mts +223 -2
- package/dist/index.d.ts +223 -2
- package/dist/index.js +192 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +190 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -47,6 +47,8 @@ __export(index_exports, {
|
|
|
47
47
|
MonitorRunStatus: () => MonitorRunStatus,
|
|
48
48
|
MonitorRunType: () => MonitorRunType,
|
|
49
49
|
MonitorStatus: () => MonitorStatus,
|
|
50
|
+
SearchMonitorRunsClient: () => SearchMonitorRunsClient,
|
|
51
|
+
SearchMonitorsClient: () => SearchMonitorsClient,
|
|
50
52
|
UpdateMonitorStatus: () => UpdateMonitorStatus,
|
|
51
53
|
WebhookStatus: () => WebhookStatus,
|
|
52
54
|
WebsetEnrichmentFormat: () => WebsetEnrichmentFormat,
|
|
@@ -74,7 +76,7 @@ var import_cross_fetch = __toESM(require("cross-fetch"));
|
|
|
74
76
|
// package.json
|
|
75
77
|
var package_default = {
|
|
76
78
|
name: "exa-js",
|
|
77
|
-
version: "2.
|
|
79
|
+
version: "2.10.1",
|
|
78
80
|
description: "Exa SDK for Node.js and the browser",
|
|
79
81
|
publishConfig: {
|
|
80
82
|
access: "public"
|
|
@@ -101,7 +103,7 @@ var package_default = {
|
|
|
101
103
|
"test:unit": "vitest run --config vitest.unit.config.ts",
|
|
102
104
|
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
103
105
|
typecheck: "tsc --noEmit",
|
|
104
|
-
"typecheck:examples": "tsc --noEmit
|
|
106
|
+
"typecheck:examples": "tsc -p examples/tsconfig.json --noEmit",
|
|
105
107
|
"generate:types:websets": "openapi-typescript https://raw.githubusercontent.com/exa-labs/openapi-spec/refs/heads/master/exa-websets-spec.yaml --enum --root-types --alphabetize --root-types-no-schema-prefix --output ./src/websets/openapi.ts && npm run format:websets",
|
|
106
108
|
format: 'prettier --write "src/**/*.ts" "examples/**/*.ts"',
|
|
107
109
|
"format:websets": "prettier --write src/websets/openapi.ts",
|
|
@@ -187,6 +189,191 @@ var ExaError = class extends Error {
|
|
|
187
189
|
}
|
|
188
190
|
};
|
|
189
191
|
|
|
192
|
+
// src/monitors/base.ts
|
|
193
|
+
var SearchMonitorsBaseClient = class {
|
|
194
|
+
constructor(client) {
|
|
195
|
+
this.client = client;
|
|
196
|
+
}
|
|
197
|
+
async request(endpoint, method = "POST", data, params) {
|
|
198
|
+
return this.client.request(
|
|
199
|
+
`/monitors${endpoint}`,
|
|
200
|
+
method,
|
|
201
|
+
data,
|
|
202
|
+
params
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
buildPaginationParams(pagination) {
|
|
206
|
+
const params = {};
|
|
207
|
+
if (!pagination) return params;
|
|
208
|
+
if (pagination.cursor) params.cursor = pagination.cursor;
|
|
209
|
+
if (pagination.limit) params.limit = pagination.limit;
|
|
210
|
+
if ("status" in pagination && pagination.status)
|
|
211
|
+
params.status = pagination.status;
|
|
212
|
+
return params;
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// src/monitors/client.ts
|
|
217
|
+
var SearchMonitorRunsClient = class extends SearchMonitorsBaseClient {
|
|
218
|
+
/**
|
|
219
|
+
* List all runs for a Search Monitor
|
|
220
|
+
* @param monitorId The ID of the Search Monitor
|
|
221
|
+
* @param options Pagination options
|
|
222
|
+
* @returns The list of Search Monitor runs
|
|
223
|
+
*/
|
|
224
|
+
async list(monitorId, options) {
|
|
225
|
+
const params = this.buildPaginationParams(options);
|
|
226
|
+
return this.request(
|
|
227
|
+
`/${monitorId}/runs`,
|
|
228
|
+
"GET",
|
|
229
|
+
void 0,
|
|
230
|
+
params
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Get a specific Search Monitor run
|
|
235
|
+
* @param monitorId The ID of the Search Monitor
|
|
236
|
+
* @param runId The ID of the run
|
|
237
|
+
* @returns The Search Monitor run
|
|
238
|
+
*/
|
|
239
|
+
async get(monitorId, runId) {
|
|
240
|
+
return this.request(
|
|
241
|
+
`/${monitorId}/runs/${runId}`,
|
|
242
|
+
"GET"
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Iterate through all runs for a Search Monitor, handling pagination automatically
|
|
247
|
+
* @param monitorId The ID of the Search Monitor
|
|
248
|
+
* @param options Pagination options
|
|
249
|
+
* @returns Async generator of Search Monitor runs
|
|
250
|
+
*/
|
|
251
|
+
async *listAll(monitorId, options) {
|
|
252
|
+
let cursor = void 0;
|
|
253
|
+
const pageOptions = options ? { ...options } : {};
|
|
254
|
+
while (true) {
|
|
255
|
+
pageOptions.cursor = cursor;
|
|
256
|
+
const response = await this.list(monitorId, pageOptions);
|
|
257
|
+
for (const run of response.data) {
|
|
258
|
+
yield run;
|
|
259
|
+
}
|
|
260
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
cursor = response.nextCursor;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Collect all runs for a Search Monitor into an array
|
|
268
|
+
* @param monitorId The ID of the Search Monitor
|
|
269
|
+
* @param options Pagination options
|
|
270
|
+
* @returns Promise resolving to an array of all Search Monitor runs
|
|
271
|
+
*/
|
|
272
|
+
async getAll(monitorId, options) {
|
|
273
|
+
const runs = [];
|
|
274
|
+
for await (const run of this.listAll(monitorId, options)) {
|
|
275
|
+
runs.push(run);
|
|
276
|
+
}
|
|
277
|
+
return runs;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
var SearchMonitorsClient = class extends SearchMonitorsBaseClient {
|
|
281
|
+
constructor(client) {
|
|
282
|
+
super(client);
|
|
283
|
+
this.runs = new SearchMonitorRunsClient(client);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Create a Search Monitor
|
|
287
|
+
* @param params The monitor creation parameters
|
|
288
|
+
* @returns The created Search Monitor with webhookSecret
|
|
289
|
+
*/
|
|
290
|
+
async create(params) {
|
|
291
|
+
return this.request("", "POST", params);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Get a Search Monitor by ID
|
|
295
|
+
* @param id The ID of the Search Monitor
|
|
296
|
+
* @returns The Search Monitor
|
|
297
|
+
*/
|
|
298
|
+
async get(id) {
|
|
299
|
+
return this.request(`/${id}`, "GET");
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* List Search Monitors
|
|
303
|
+
* @param options Pagination and filtering options
|
|
304
|
+
* @returns The list of Search Monitors
|
|
305
|
+
*/
|
|
306
|
+
async list(options) {
|
|
307
|
+
const params = this.buildPaginationParams(options);
|
|
308
|
+
return this.request(
|
|
309
|
+
"",
|
|
310
|
+
"GET",
|
|
311
|
+
void 0,
|
|
312
|
+
params
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Update a Search Monitor
|
|
317
|
+
* @param id The ID of the Search Monitor
|
|
318
|
+
* @param params The update parameters
|
|
319
|
+
* @returns The updated Search Monitor
|
|
320
|
+
*/
|
|
321
|
+
async update(id, params) {
|
|
322
|
+
return this.request(`/${id}`, "PATCH", params);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Delete a Search Monitor
|
|
326
|
+
* @param id The ID of the Search Monitor
|
|
327
|
+
* @returns The deleted Search Monitor
|
|
328
|
+
*/
|
|
329
|
+
async delete(id) {
|
|
330
|
+
return this.request(`/${id}`, "DELETE");
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Trigger a Search Monitor run immediately
|
|
334
|
+
* @param id The ID of the Search Monitor
|
|
335
|
+
* @returns Whether the monitor was triggered
|
|
336
|
+
*/
|
|
337
|
+
async trigger(id) {
|
|
338
|
+
return this.request(
|
|
339
|
+
`/${id}/trigger`,
|
|
340
|
+
"POST"
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Iterate through all Search Monitors, handling pagination automatically
|
|
345
|
+
* @param options Pagination and filtering options
|
|
346
|
+
* @returns Async generator of Search Monitors
|
|
347
|
+
*/
|
|
348
|
+
async *listAll(options) {
|
|
349
|
+
let cursor = void 0;
|
|
350
|
+
const pageOptions = options ? { ...options } : {};
|
|
351
|
+
while (true) {
|
|
352
|
+
pageOptions.cursor = cursor;
|
|
353
|
+
const response = await this.list(pageOptions);
|
|
354
|
+
for (const monitor of response.data) {
|
|
355
|
+
yield monitor;
|
|
356
|
+
}
|
|
357
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
cursor = response.nextCursor;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Collect all Search Monitors into an array
|
|
365
|
+
* @param options Pagination and filtering options
|
|
366
|
+
* @returns Promise resolving to an array of all Search Monitors
|
|
367
|
+
*/
|
|
368
|
+
async getAll(options) {
|
|
369
|
+
const monitors = [];
|
|
370
|
+
for await (const monitor of this.listAll(options)) {
|
|
371
|
+
monitors.push(monitor);
|
|
372
|
+
}
|
|
373
|
+
return monitors;
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
|
|
190
377
|
// src/zod-utils.ts
|
|
191
378
|
var import_zod = require("zod");
|
|
192
379
|
var import_zod_to_json_schema = require("zod-to-json-schema");
|
|
@@ -1507,6 +1694,7 @@ var Exa2 = class {
|
|
|
1507
1694
|
});
|
|
1508
1695
|
this.websets = new WebsetsClient(this);
|
|
1509
1696
|
this.research = new ResearchClient(this);
|
|
1697
|
+
this.monitors = new SearchMonitorsClient(this);
|
|
1510
1698
|
}
|
|
1511
1699
|
/**
|
|
1512
1700
|
* Makes a request to the Exa API.
|
|
@@ -1916,6 +2104,8 @@ var index_default = Exa2;
|
|
|
1916
2104
|
MonitorRunStatus,
|
|
1917
2105
|
MonitorRunType,
|
|
1918
2106
|
MonitorStatus,
|
|
2107
|
+
SearchMonitorRunsClient,
|
|
2108
|
+
SearchMonitorsClient,
|
|
1919
2109
|
UpdateMonitorStatus,
|
|
1920
2110
|
WebhookStatus,
|
|
1921
2111
|
WebsetEnrichmentFormat,
|