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.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.
|
|
7
|
+
version: "2.10.1",
|
|
8
8
|
description: "Exa SDK for Node.js and the browser",
|
|
9
9
|
publishConfig: {
|
|
10
10
|
access: "public"
|
|
@@ -31,7 +31,7 @@ var package_default = {
|
|
|
31
31
|
"test:unit": "vitest run --config vitest.unit.config.ts",
|
|
32
32
|
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
33
33
|
typecheck: "tsc --noEmit",
|
|
34
|
-
"typecheck:examples": "tsc --noEmit
|
|
34
|
+
"typecheck:examples": "tsc -p examples/tsconfig.json --noEmit",
|
|
35
35
|
"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",
|
|
36
36
|
format: 'prettier --write "src/**/*.ts" "examples/**/*.ts"',
|
|
37
37
|
"format:websets": "prettier --write src/websets/openapi.ts",
|
|
@@ -117,6 +117,191 @@ var ExaError = class extends Error {
|
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
+
// src/monitors/base.ts
|
|
121
|
+
var SearchMonitorsBaseClient = class {
|
|
122
|
+
constructor(client) {
|
|
123
|
+
this.client = client;
|
|
124
|
+
}
|
|
125
|
+
async request(endpoint, method = "POST", data, params) {
|
|
126
|
+
return this.client.request(
|
|
127
|
+
`/monitors${endpoint}`,
|
|
128
|
+
method,
|
|
129
|
+
data,
|
|
130
|
+
params
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
buildPaginationParams(pagination) {
|
|
134
|
+
const params = {};
|
|
135
|
+
if (!pagination) return params;
|
|
136
|
+
if (pagination.cursor) params.cursor = pagination.cursor;
|
|
137
|
+
if (pagination.limit) params.limit = pagination.limit;
|
|
138
|
+
if ("status" in pagination && pagination.status)
|
|
139
|
+
params.status = pagination.status;
|
|
140
|
+
return params;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// src/monitors/client.ts
|
|
145
|
+
var SearchMonitorRunsClient = class extends SearchMonitorsBaseClient {
|
|
146
|
+
/**
|
|
147
|
+
* List all runs for a Search Monitor
|
|
148
|
+
* @param monitorId The ID of the Search Monitor
|
|
149
|
+
* @param options Pagination options
|
|
150
|
+
* @returns The list of Search Monitor runs
|
|
151
|
+
*/
|
|
152
|
+
async list(monitorId, options) {
|
|
153
|
+
const params = this.buildPaginationParams(options);
|
|
154
|
+
return this.request(
|
|
155
|
+
`/${monitorId}/runs`,
|
|
156
|
+
"GET",
|
|
157
|
+
void 0,
|
|
158
|
+
params
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get a specific Search Monitor run
|
|
163
|
+
* @param monitorId The ID of the Search Monitor
|
|
164
|
+
* @param runId The ID of the run
|
|
165
|
+
* @returns The Search Monitor run
|
|
166
|
+
*/
|
|
167
|
+
async get(monitorId, runId) {
|
|
168
|
+
return this.request(
|
|
169
|
+
`/${monitorId}/runs/${runId}`,
|
|
170
|
+
"GET"
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Iterate through all runs for a Search Monitor, handling pagination automatically
|
|
175
|
+
* @param monitorId The ID of the Search Monitor
|
|
176
|
+
* @param options Pagination options
|
|
177
|
+
* @returns Async generator of Search Monitor runs
|
|
178
|
+
*/
|
|
179
|
+
async *listAll(monitorId, options) {
|
|
180
|
+
let cursor = void 0;
|
|
181
|
+
const pageOptions = options ? { ...options } : {};
|
|
182
|
+
while (true) {
|
|
183
|
+
pageOptions.cursor = cursor;
|
|
184
|
+
const response = await this.list(monitorId, pageOptions);
|
|
185
|
+
for (const run of response.data) {
|
|
186
|
+
yield run;
|
|
187
|
+
}
|
|
188
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
cursor = response.nextCursor;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Collect all runs for a Search Monitor into an array
|
|
196
|
+
* @param monitorId The ID of the Search Monitor
|
|
197
|
+
* @param options Pagination options
|
|
198
|
+
* @returns Promise resolving to an array of all Search Monitor runs
|
|
199
|
+
*/
|
|
200
|
+
async getAll(monitorId, options) {
|
|
201
|
+
const runs = [];
|
|
202
|
+
for await (const run of this.listAll(monitorId, options)) {
|
|
203
|
+
runs.push(run);
|
|
204
|
+
}
|
|
205
|
+
return runs;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
var SearchMonitorsClient = class extends SearchMonitorsBaseClient {
|
|
209
|
+
constructor(client) {
|
|
210
|
+
super(client);
|
|
211
|
+
this.runs = new SearchMonitorRunsClient(client);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Create a Search Monitor
|
|
215
|
+
* @param params The monitor creation parameters
|
|
216
|
+
* @returns The created Search Monitor with webhookSecret
|
|
217
|
+
*/
|
|
218
|
+
async create(params) {
|
|
219
|
+
return this.request("", "POST", params);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Get a Search Monitor by ID
|
|
223
|
+
* @param id The ID of the Search Monitor
|
|
224
|
+
* @returns The Search Monitor
|
|
225
|
+
*/
|
|
226
|
+
async get(id) {
|
|
227
|
+
return this.request(`/${id}`, "GET");
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* List Search Monitors
|
|
231
|
+
* @param options Pagination and filtering options
|
|
232
|
+
* @returns The list of Search Monitors
|
|
233
|
+
*/
|
|
234
|
+
async list(options) {
|
|
235
|
+
const params = this.buildPaginationParams(options);
|
|
236
|
+
return this.request(
|
|
237
|
+
"",
|
|
238
|
+
"GET",
|
|
239
|
+
void 0,
|
|
240
|
+
params
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Update a Search Monitor
|
|
245
|
+
* @param id The ID of the Search Monitor
|
|
246
|
+
* @param params The update parameters
|
|
247
|
+
* @returns The updated Search Monitor
|
|
248
|
+
*/
|
|
249
|
+
async update(id, params) {
|
|
250
|
+
return this.request(`/${id}`, "PATCH", params);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Delete a Search Monitor
|
|
254
|
+
* @param id The ID of the Search Monitor
|
|
255
|
+
* @returns The deleted Search Monitor
|
|
256
|
+
*/
|
|
257
|
+
async delete(id) {
|
|
258
|
+
return this.request(`/${id}`, "DELETE");
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Trigger a Search Monitor run immediately
|
|
262
|
+
* @param id The ID of the Search Monitor
|
|
263
|
+
* @returns Whether the monitor was triggered
|
|
264
|
+
*/
|
|
265
|
+
async trigger(id) {
|
|
266
|
+
return this.request(
|
|
267
|
+
`/${id}/trigger`,
|
|
268
|
+
"POST"
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Iterate through all Search Monitors, handling pagination automatically
|
|
273
|
+
* @param options Pagination and filtering options
|
|
274
|
+
* @returns Async generator of Search Monitors
|
|
275
|
+
*/
|
|
276
|
+
async *listAll(options) {
|
|
277
|
+
let cursor = void 0;
|
|
278
|
+
const pageOptions = options ? { ...options } : {};
|
|
279
|
+
while (true) {
|
|
280
|
+
pageOptions.cursor = cursor;
|
|
281
|
+
const response = await this.list(pageOptions);
|
|
282
|
+
for (const monitor of response.data) {
|
|
283
|
+
yield monitor;
|
|
284
|
+
}
|
|
285
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
cursor = response.nextCursor;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Collect all Search Monitors into an array
|
|
293
|
+
* @param options Pagination and filtering options
|
|
294
|
+
* @returns Promise resolving to an array of all Search Monitors
|
|
295
|
+
*/
|
|
296
|
+
async getAll(options) {
|
|
297
|
+
const monitors = [];
|
|
298
|
+
for await (const monitor of this.listAll(options)) {
|
|
299
|
+
monitors.push(monitor);
|
|
300
|
+
}
|
|
301
|
+
return monitors;
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
|
|
120
305
|
// src/zod-utils.ts
|
|
121
306
|
import { ZodType } from "zod";
|
|
122
307
|
import { zodToJsonSchema as convertZodToJsonSchema } from "zod-to-json-schema";
|
|
@@ -1437,6 +1622,7 @@ var Exa2 = class {
|
|
|
1437
1622
|
});
|
|
1438
1623
|
this.websets = new WebsetsClient(this);
|
|
1439
1624
|
this.research = new ResearchClient(this);
|
|
1625
|
+
this.monitors = new SearchMonitorsClient(this);
|
|
1440
1626
|
}
|
|
1441
1627
|
/**
|
|
1442
1628
|
* Makes a request to the Exa API.
|
|
@@ -1845,6 +2031,8 @@ export {
|
|
|
1845
2031
|
MonitorRunStatus,
|
|
1846
2032
|
MonitorRunType,
|
|
1847
2033
|
MonitorStatus,
|
|
2034
|
+
SearchMonitorRunsClient,
|
|
2035
|
+
SearchMonitorsClient,
|
|
1848
2036
|
UpdateMonitorStatus,
|
|
1849
2037
|
WebhookStatus,
|
|
1850
2038
|
WebsetEnrichmentFormat,
|