@airtop/sdk 1.0.0-alpha2.15 → 1.0.0-alpha2.17
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.cjs +33 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -13
- package/dist/index.d.ts +46 -13
- package/dist/index.js +21 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
@@ -9,7 +9,7 @@ var require_package = __commonJS({
|
|
9
9
|
module.exports = {
|
10
10
|
name: "@airtop/sdk",
|
11
11
|
description: "Airtop SDK for TypeScript",
|
12
|
-
version: "1.0.0-alpha2.
|
12
|
+
version: "1.0.0-alpha2.17",
|
13
13
|
type: "module",
|
14
14
|
main: "./dist/index.cjs",
|
15
15
|
module: "./dist/index.js",
|
@@ -47,7 +47,7 @@ var require_package = __commonJS({
|
|
47
47
|
},
|
48
48
|
dependencies: {
|
49
49
|
"@airtop/json-schema-adapter": "workspace:*",
|
50
|
-
"@airtop/core": "0.1.0-alpha.
|
50
|
+
"@airtop/core": "0.1.0-alpha.30",
|
51
51
|
"date-fns": "4.1.0",
|
52
52
|
loglayer: "6.3.3",
|
53
53
|
"serialize-error": "12.0.0",
|
@@ -290,7 +290,7 @@ async function waitForRequestCompletion(client, requestId, requestOptions) {
|
|
290
290
|
const startTime = Date.now();
|
291
291
|
const timeoutMs = _datefns.secondsToMilliseconds.call(void 0, _optionalChain([requestOptions, 'optionalAccess', _5 => _5.timeoutInSeconds]) || DEFAULT_TIMEOUT_SECONDS);
|
292
292
|
while (Date.now() - startTime < timeoutMs) {
|
293
|
-
const apiResponse = await client.requests.
|
293
|
+
const apiResponse = await client.requests.getRequestStatusV2(requestId, requestOptions);
|
294
294
|
if (apiResponse.status === "completed") {
|
295
295
|
return apiResponse.response;
|
296
296
|
}
|
@@ -302,8 +302,15 @@ async function waitForRequestCompletion(client, requestId, requestOptions) {
|
|
302
302
|
throw new Error("Waiting for request timed out");
|
303
303
|
}
|
304
304
|
async function withRequestCompletionPolling(client, fn, requestOptions) {
|
305
|
-
|
306
|
-
|
305
|
+
try {
|
306
|
+
const response = await fn();
|
307
|
+
return waitForRequestCompletion(client, response.requestId, requestOptions);
|
308
|
+
} catch (thrownError) {
|
309
|
+
if (_optionalChain([thrownError, 'access', _6 => _6.error, 'optionalAccess', _7 => _7.errors])) {
|
310
|
+
throw new AirtopError(thrownError.error.errors);
|
311
|
+
}
|
312
|
+
throw thrownError;
|
313
|
+
}
|
307
314
|
}
|
308
315
|
|
309
316
|
// src/window/AirtopNode.ts
|
@@ -521,8 +528,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
521
528
|
this.client.windows.get(
|
522
529
|
this.windowId,
|
523
530
|
{
|
524
|
-
sessionId: this.sessionId
|
525
|
-
...config
|
531
|
+
sessionId: this.sessionId
|
526
532
|
},
|
527
533
|
this.resolveRequestOptions()
|
528
534
|
).then((results) => {
|
@@ -676,7 +682,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
676
682
|
prompt
|
677
683
|
}).info("Performing a page query");
|
678
684
|
const newConfig = config;
|
679
|
-
if (_optionalChain([config, 'optionalAccess',
|
685
|
+
if (_optionalChain([config, 'optionalAccess', _8 => _8.configuration, 'access', _9 => _9.outputSchema])) {
|
680
686
|
newConfig.configuration.outputSchema = this.convertToJsonSchema(config.configuration.outputSchema);
|
681
687
|
}
|
682
688
|
return this.client.windows.pageQuery(
|
@@ -704,7 +710,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
704
710
|
prompt
|
705
711
|
}).info("Performing a paginated extraction");
|
706
712
|
const newConfig = config;
|
707
|
-
if (_optionalChain([config, 'optionalAccess',
|
713
|
+
if (_optionalChain([config, 'optionalAccess', _10 => _10.configuration, 'access', _11 => _11.outputSchema])) {
|
708
714
|
newConfig.configuration.outputSchema = this.convertToJsonSchema(config.configuration.outputSchema);
|
709
715
|
}
|
710
716
|
return this.client.windows.paginatedExtraction(
|
@@ -852,6 +858,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
852
858
|
{
|
853
859
|
prompt,
|
854
860
|
sessionId: this.sessionId,
|
861
|
+
jobId: this.jobId,
|
855
862
|
...config || {}
|
856
863
|
},
|
857
864
|
{
|
@@ -883,16 +890,12 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
883
890
|
throw new AirtopError(apiResponse.errors);
|
884
891
|
}
|
885
892
|
try {
|
886
|
-
if (!apiResponse.data.
|
893
|
+
if (!apiResponse.data.nodeHandle) {
|
887
894
|
return null;
|
888
895
|
}
|
889
|
-
|
890
|
-
if (Object.keys(nodeData).length === 0) {
|
891
|
-
return null;
|
892
|
-
}
|
893
|
-
return new AirtopNode(this, nodeData);
|
896
|
+
return new AirtopNode(this, apiResponse.data.nodeHandle);
|
894
897
|
} catch (error) {
|
895
|
-
this.log.withMetadata({ nodeDataStr: apiResponse.data.
|
898
|
+
this.log.withMetadata({ nodeDataStr: apiResponse.data.nodeHandle }).withError(error).error("Error parsing node data");
|
896
899
|
throw error;
|
897
900
|
}
|
898
901
|
}
|
@@ -925,21 +928,8 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
925
928
|
if (apiResponse.errors.length > 0) {
|
926
929
|
throw new AirtopError(apiResponse.errors);
|
927
930
|
}
|
928
|
-
const
|
929
|
-
return
|
930
|
-
try {
|
931
|
-
if (!nodeDataStr) {
|
932
|
-
return null;
|
933
|
-
}
|
934
|
-
const nodeData = JSON.parse(nodeDataStr);
|
935
|
-
if (Object.keys(nodeData).length === 0) {
|
936
|
-
return null;
|
937
|
-
}
|
938
|
-
return new AirtopNode(this, nodeData);
|
939
|
-
} catch (error) {
|
940
|
-
this.log.withMetadata({ nodeDataStr }).withError(error).error("Error parsing node data");
|
941
|
-
}
|
942
|
-
}).filter((node) => !!node);
|
931
|
+
const nodeHandleData = apiResponse.data.nodeHandles;
|
932
|
+
return nodeHandleData.map((nodeHandle) => new AirtopNode(this, nodeHandle));
|
943
933
|
}
|
944
934
|
async findMany(prompt, config, requestOptions = {}) {
|
945
935
|
const configOverride = { ...config, optional: false };
|
@@ -956,6 +946,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
956
946
|
this.getWindowId(),
|
957
947
|
{
|
958
948
|
sessionId: this.sessionId,
|
949
|
+
jobId: this.jobId,
|
959
950
|
...config || {}
|
960
951
|
},
|
961
952
|
{
|
@@ -973,6 +964,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
973
964
|
{
|
974
965
|
direction,
|
975
966
|
sessionId: this.sessionId,
|
967
|
+
jobId: this.jobId,
|
976
968
|
...config || {}
|
977
969
|
},
|
978
970
|
{
|
@@ -1231,19 +1223,19 @@ var AirtopClient = class extends AirtopBase {
|
|
1231
1223
|
*/
|
1232
1224
|
constructor(config) {
|
1233
1225
|
super({
|
1234
|
-
logLevel: _optionalChain([config, 'optionalAccess',
|
1226
|
+
logLevel: _optionalChain([config, 'optionalAccess', _12 => _12.logLevel]),
|
1235
1227
|
client: new (0, _core.Airtop)({
|
1236
1228
|
maxRetries: 0,
|
1237
1229
|
timeout: _minutesToMilliseconds.minutesToMilliseconds.call(void 0, 1),
|
1238
1230
|
apiKey: config.apiKey,
|
1239
|
-
baseURL: _optionalChain([config, 'optionalAccess',
|
1240
|
-
logLevel: _optionalChain([config, 'optionalAccess',
|
1231
|
+
baseURL: _optionalChain([config, 'optionalAccess', _13 => _13.airtopUrl]),
|
1232
|
+
logLevel: _optionalChain([config, 'optionalAccess', _14 => _14.logLevel]) || "off",
|
1241
1233
|
defaultHeaders: {
|
1242
1234
|
"x-airtop-sdk-source": "typescript",
|
1243
1235
|
"x-airtop-sdk-version": version
|
1244
1236
|
}
|
1245
1237
|
}),
|
1246
|
-
log: _optionalChain([config, 'optionalAccess',
|
1238
|
+
log: _optionalChain([config, 'optionalAccess', _15 => _15.logger]) || new (0, _loglayer.LogLayer)({
|
1247
1239
|
errorSerializer: _serializeerror.serializeError,
|
1248
1240
|
transport: new (0, _loglayer.ConsoleTransport)({
|
1249
1241
|
logger: console,
|
@@ -1282,8 +1274,8 @@ var AirtopClient = class extends AirtopBase {
|
|
1282
1274
|
* @returns A new AirtopSession instance
|
1283
1275
|
*/
|
1284
1276
|
async createSession(config, options = {}) {
|
1285
|
-
const skipWaitSessionReady = _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
1286
|
-
_optionalChainDelete([config, 'optionalAccess',
|
1277
|
+
const skipWaitSessionReady = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _16 => _16.skipWaitSessionReady]), () => ( false));
|
1278
|
+
_optionalChainDelete([config, 'optionalAccess', _17 => delete _17.skipWaitSessionReady]);
|
1287
1279
|
const sessionResponse = await this.client.sessions.create(
|
1288
1280
|
{
|
1289
1281
|
configuration: config
|
@@ -1490,19 +1482,19 @@ var AirtopAgentClient = class extends AirtopBase {
|
|
1490
1482
|
*/
|
1491
1483
|
constructor(config) {
|
1492
1484
|
super({
|
1493
|
-
logLevel: _optionalChain([config, 'optionalAccess',
|
1485
|
+
logLevel: _optionalChain([config, 'optionalAccess', _18 => _18.logLevel]),
|
1494
1486
|
client: new (0, _core.Airtop)({
|
1495
1487
|
maxRetries: 0,
|
1496
1488
|
timeout: _datefns.minutesToMilliseconds.call(void 0, 1),
|
1497
1489
|
apiKey: config.apiKey,
|
1498
|
-
baseURL: _optionalChain([config, 'optionalAccess',
|
1499
|
-
logLevel: _optionalChain([config, 'optionalAccess',
|
1490
|
+
baseURL: _optionalChain([config, 'optionalAccess', _19 => _19.airtopUrl]),
|
1491
|
+
logLevel: _optionalChain([config, 'optionalAccess', _20 => _20.logLevel]) || "off",
|
1500
1492
|
defaultHeaders: {
|
1501
1493
|
"x-airtop-sdk-source": "typescript",
|
1502
1494
|
"x-airtop-sdk-version": _process.version
|
1503
1495
|
}
|
1504
1496
|
}),
|
1505
|
-
log: _optionalChain([config, 'optionalAccess',
|
1497
|
+
log: _optionalChain([config, 'optionalAccess', _21 => _21.logger]) || new (0, _loglayer.LogLayer)({
|
1506
1498
|
errorSerializer: _serializeerror.serializeError,
|
1507
1499
|
transport: new (0, _loglayer.ConsoleTransport)({
|
1508
1500
|
logger: console,
|