exa-js 1.8.23 → 1.8.25
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 +48 -36
- package/dist/index.d.ts +48 -36
- package/dist/index.js +38 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -48,8 +48,14 @@ var WebsetsBaseClient = class {
|
|
|
48
48
|
* @returns The response JSON
|
|
49
49
|
* @throws ExaError with API error details if the request fails
|
|
50
50
|
*/
|
|
51
|
-
async request(endpoint, method = "POST", data, params) {
|
|
52
|
-
return this.client.request(
|
|
51
|
+
async request(endpoint, method = "POST", data, params, headers) {
|
|
52
|
+
return this.client.request(
|
|
53
|
+
`/websets${endpoint}`,
|
|
54
|
+
method,
|
|
55
|
+
data,
|
|
56
|
+
params,
|
|
57
|
+
headers
|
|
58
|
+
);
|
|
53
59
|
}
|
|
54
60
|
/**
|
|
55
61
|
* Helper to build pagination parameters
|
|
@@ -658,11 +664,13 @@ var WebsetSearchesClient = class extends WebsetsBaseClient {
|
|
|
658
664
|
* @param params The search parameters
|
|
659
665
|
* @returns The created Webset Search
|
|
660
666
|
*/
|
|
661
|
-
async create(websetId, params) {
|
|
667
|
+
async create(websetId, params, options) {
|
|
662
668
|
return this.request(
|
|
663
669
|
`/v0/websets/${websetId}/searches`,
|
|
664
670
|
"POST",
|
|
665
|
-
params
|
|
671
|
+
params,
|
|
672
|
+
void 0,
|
|
673
|
+
options?.headers
|
|
666
674
|
);
|
|
667
675
|
}
|
|
668
676
|
/**
|
|
@@ -849,8 +857,14 @@ var WebsetsClient = class extends WebsetsBaseClient {
|
|
|
849
857
|
* @param params The Webset creation parameters
|
|
850
858
|
* @returns The created Webset
|
|
851
859
|
*/
|
|
852
|
-
async create(params) {
|
|
853
|
-
return this.request(
|
|
860
|
+
async create(params, options) {
|
|
861
|
+
return this.request(
|
|
862
|
+
"/v0/websets",
|
|
863
|
+
"POST",
|
|
864
|
+
params,
|
|
865
|
+
void 0,
|
|
866
|
+
options?.headers
|
|
867
|
+
);
|
|
854
868
|
}
|
|
855
869
|
/**
|
|
856
870
|
* Preview a webset
|
|
@@ -858,7 +872,11 @@ var WebsetsClient = class extends WebsetsBaseClient {
|
|
|
858
872
|
* @returns The preview response showing how the query will be decomposed
|
|
859
873
|
*/
|
|
860
874
|
async preview(params) {
|
|
861
|
-
return this.request(
|
|
875
|
+
return this.request(
|
|
876
|
+
"/v0/websets/preview",
|
|
877
|
+
"POST",
|
|
878
|
+
params
|
|
879
|
+
);
|
|
862
880
|
}
|
|
863
881
|
/**
|
|
864
882
|
* Get a Webset by ID
|
|
@@ -1259,7 +1277,7 @@ var Exa2 = class {
|
|
|
1259
1277
|
* @returns {Promise<any>} The response from the API.
|
|
1260
1278
|
* @throws {ExaError} When any API request fails with structured error information
|
|
1261
1279
|
*/
|
|
1262
|
-
async request(endpoint, method, body, params) {
|
|
1280
|
+
async request(endpoint, method, body, params, headers) {
|
|
1263
1281
|
let url = this.baseURL + endpoint;
|
|
1264
1282
|
if (params && Object.keys(params).length > 0) {
|
|
1265
1283
|
const searchParams = new URLSearchParams();
|
|
@@ -1274,9 +1292,20 @@ var Exa2 = class {
|
|
|
1274
1292
|
}
|
|
1275
1293
|
url += `?${searchParams.toString()}`;
|
|
1276
1294
|
}
|
|
1295
|
+
let combinedHeaders = {};
|
|
1296
|
+
if (this.headers instanceof HeadersImpl) {
|
|
1297
|
+
this.headers.forEach((value, key) => {
|
|
1298
|
+
combinedHeaders[key] = value;
|
|
1299
|
+
});
|
|
1300
|
+
} else {
|
|
1301
|
+
combinedHeaders = { ...this.headers };
|
|
1302
|
+
}
|
|
1303
|
+
if (headers) {
|
|
1304
|
+
combinedHeaders = { ...combinedHeaders, ...headers };
|
|
1305
|
+
}
|
|
1277
1306
|
const response = await fetchImpl(url, {
|
|
1278
1307
|
method,
|
|
1279
|
-
headers:
|
|
1308
|
+
headers: combinedHeaders,
|
|
1280
1309
|
body: body ? JSON.stringify(body) : void 0
|
|
1281
1310
|
});
|
|
1282
1311
|
if (!response.ok) {
|