exa-js 2.1.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -155
- package/dist/index.d.mts +70 -7
- package/dist/index.d.ts +70 -7
- package/dist/index.js +104 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -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.
|
|
7
|
+
version: "2.3.0",
|
|
8
8
|
description: "Exa SDK for Node.js and the browser",
|
|
9
9
|
publishConfig: {
|
|
10
10
|
access: "public"
|
|
@@ -35,6 +35,7 @@ var package_default = {
|
|
|
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",
|
|
38
|
+
"generate-docs": "npx tsx scripts/generate-docs.ts",
|
|
38
39
|
"build:beta": "cross-env NPM_CONFIG_TAG=beta npm run build",
|
|
39
40
|
"version:beta": "npm version prerelease --preid=beta",
|
|
40
41
|
"version:stable": "npm version patch",
|
|
@@ -48,8 +49,10 @@ var package_default = {
|
|
|
48
49
|
"cross-env": "~7.0.3",
|
|
49
50
|
"openapi-typescript": "~7.6.1",
|
|
50
51
|
prettier: "~3.5.3",
|
|
52
|
+
"ts-morph": "^27.0.2",
|
|
51
53
|
"ts-node": "~10.9.2",
|
|
52
54
|
tsup: "~8.4.0",
|
|
55
|
+
tsx: "^4.21.0",
|
|
53
56
|
typescript: "~5.8.3",
|
|
54
57
|
vitest: "~3.1.1"
|
|
55
58
|
},
|
|
@@ -424,6 +427,38 @@ var EventsClient = class extends WebsetsBaseClient {
|
|
|
424
427
|
async get(id) {
|
|
425
428
|
return this.request(`/v0/events/${id}`, "GET");
|
|
426
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* Iterate through all Events, handling pagination automatically
|
|
432
|
+
* @param options Filtering and pagination options
|
|
433
|
+
* @returns Async generator of Events
|
|
434
|
+
*/
|
|
435
|
+
async *listAll(options) {
|
|
436
|
+
let cursor = void 0;
|
|
437
|
+
const pageOptions = options ? { ...options } : {};
|
|
438
|
+
while (true) {
|
|
439
|
+
pageOptions.cursor = cursor;
|
|
440
|
+
const response = await this.list(pageOptions);
|
|
441
|
+
for (const event of response.data) {
|
|
442
|
+
yield event;
|
|
443
|
+
}
|
|
444
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
cursor = response.nextCursor;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
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
|
+
*/
|
|
455
|
+
async getAll(options) {
|
|
456
|
+
const events = [];
|
|
457
|
+
for await (const event of this.listAll(options)) {
|
|
458
|
+
events.push(event);
|
|
459
|
+
}
|
|
460
|
+
return events;
|
|
461
|
+
}
|
|
427
462
|
};
|
|
428
463
|
|
|
429
464
|
// src/websets/openapi.ts
|
|
@@ -738,6 +773,38 @@ var ImportsClient = class extends WebsetsBaseClient {
|
|
|
738
773
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
739
774
|
}
|
|
740
775
|
}
|
|
776
|
+
/**
|
|
777
|
+
* Iterate through all Imports, handling pagination automatically
|
|
778
|
+
* @param options Pagination options
|
|
779
|
+
* @returns Async generator of Imports
|
|
780
|
+
*/
|
|
781
|
+
async *listAll(options) {
|
|
782
|
+
let cursor = void 0;
|
|
783
|
+
const pageOptions = options ? { ...options } : {};
|
|
784
|
+
while (true) {
|
|
785
|
+
pageOptions.cursor = cursor;
|
|
786
|
+
const response = await this.list(pageOptions);
|
|
787
|
+
for (const importItem of response.data) {
|
|
788
|
+
yield importItem;
|
|
789
|
+
}
|
|
790
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
791
|
+
break;
|
|
792
|
+
}
|
|
793
|
+
cursor = response.nextCursor;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Collect all Imports into an array
|
|
798
|
+
* @param options Pagination options
|
|
799
|
+
* @returns Promise resolving to an array of all Imports
|
|
800
|
+
*/
|
|
801
|
+
async getAll(options) {
|
|
802
|
+
const imports = [];
|
|
803
|
+
for await (const importItem of this.listAll(options)) {
|
|
804
|
+
imports.push(importItem);
|
|
805
|
+
}
|
|
806
|
+
return imports;
|
|
807
|
+
}
|
|
741
808
|
};
|
|
742
809
|
|
|
743
810
|
// src/websets/items.ts
|
|
@@ -906,6 +973,38 @@ var WebsetMonitorsClient = class extends WebsetsBaseClient {
|
|
|
906
973
|
async delete(id) {
|
|
907
974
|
return this.request(`/v0/monitors/${id}`, "DELETE");
|
|
908
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Iterate through all Monitors, handling pagination automatically
|
|
978
|
+
* @param options Pagination and filtering options
|
|
979
|
+
* @returns Async generator of Monitors
|
|
980
|
+
*/
|
|
981
|
+
async *listAll(options) {
|
|
982
|
+
let cursor = void 0;
|
|
983
|
+
const pageOptions = options ? { ...options } : {};
|
|
984
|
+
while (true) {
|
|
985
|
+
pageOptions.cursor = cursor;
|
|
986
|
+
const response = await this.list(pageOptions);
|
|
987
|
+
for (const monitor of response.data) {
|
|
988
|
+
yield monitor;
|
|
989
|
+
}
|
|
990
|
+
if (!response.hasMore || !response.nextCursor) {
|
|
991
|
+
break;
|
|
992
|
+
}
|
|
993
|
+
cursor = response.nextCursor;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Collect all Monitors into an array
|
|
998
|
+
* @param options Pagination and filtering options
|
|
999
|
+
* @returns Promise resolving to an array of all Monitors
|
|
1000
|
+
*/
|
|
1001
|
+
async getAll(options) {
|
|
1002
|
+
const monitors = [];
|
|
1003
|
+
for await (const monitor of this.listAll(options)) {
|
|
1004
|
+
monitors.push(monitor);
|
|
1005
|
+
}
|
|
1006
|
+
return monitors;
|
|
1007
|
+
}
|
|
909
1008
|
};
|
|
910
1009
|
|
|
911
1010
|
// src/websets/searches.ts
|
|
@@ -1281,6 +1380,7 @@ var Exa2 = class {
|
|
|
1281
1380
|
extras,
|
|
1282
1381
|
livecrawl,
|
|
1283
1382
|
livecrawlTimeout,
|
|
1383
|
+
maxAgeHours,
|
|
1284
1384
|
context,
|
|
1285
1385
|
...rest
|
|
1286
1386
|
} = options;
|
|
@@ -1307,6 +1407,7 @@ var Exa2 = class {
|
|
|
1307
1407
|
if (livecrawl !== void 0) contentsOptions.livecrawl = livecrawl;
|
|
1308
1408
|
if (livecrawlTimeout !== void 0)
|
|
1309
1409
|
contentsOptions.livecrawlTimeout = livecrawlTimeout;
|
|
1410
|
+
if (maxAgeHours !== void 0) contentsOptions.maxAgeHours = maxAgeHours;
|
|
1310
1411
|
if (context !== void 0) contentsOptions.context = context;
|
|
1311
1412
|
return {
|
|
1312
1413
|
contentsOptions,
|
|
@@ -1571,7 +1672,8 @@ var Exa2 = class {
|
|
|
1571
1672
|
stream: true,
|
|
1572
1673
|
model: options?.model ?? "exa",
|
|
1573
1674
|
systemPrompt: options?.systemPrompt,
|
|
1574
|
-
outputSchema
|
|
1675
|
+
outputSchema,
|
|
1676
|
+
userLocation: options?.userLocation
|
|
1575
1677
|
};
|
|
1576
1678
|
const response = await fetchImpl(this.baseURL + "/answer", {
|
|
1577
1679
|
method: "POST",
|