@airtop/sdk 1.0.0-alpha2.33 → 1.0.0-alpha2.35
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 +14 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +14 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -595,6 +595,11 @@ interface WaitForDownloadConfig {
|
|
|
595
595
|
* Default is 5. 0 means no lookback.
|
|
596
596
|
*/
|
|
597
597
|
lookbackSeconds?: number;
|
|
598
|
+
/**
|
|
599
|
+
* The file type to wait for, such as "browser_download".
|
|
600
|
+
* If provided, only files of this type will be considered.
|
|
601
|
+
*/
|
|
602
|
+
fileType?: string;
|
|
598
603
|
}
|
|
599
604
|
/**
|
|
600
605
|
* Result of waiting for a file download.
|
|
@@ -608,6 +613,14 @@ interface WaitForDownloadResult {
|
|
|
608
613
|
* The download URL for the file.
|
|
609
614
|
*/
|
|
610
615
|
downloadUrl: string;
|
|
616
|
+
/**
|
|
617
|
+
* The name of the file.
|
|
618
|
+
*/
|
|
619
|
+
fileName?: string;
|
|
620
|
+
/**
|
|
621
|
+
* The type of the file.
|
|
622
|
+
*/
|
|
623
|
+
fileType?: string;
|
|
611
624
|
}
|
|
612
625
|
interface CreateFileConfig extends Omit<FileCreateFileParams, "sessionId" | "fileName"> {
|
|
613
626
|
}
|
|
@@ -1250,6 +1263,7 @@ declare class AirtopSessionClient extends AirtopBase {
|
|
|
1250
1263
|
*
|
|
1251
1264
|
* @param configuration - The optional configuration parameters for the function
|
|
1252
1265
|
* @param configuration.lookbackSeconds - The number of seconds to look back for prior events. Default `5`. 0 means no lookback.
|
|
1266
|
+
* @param configuration.fileType - The file type to wait for, such as "browser_download". If provided, only files of this type will be considered.
|
|
1253
1267
|
* @param requestOptions - Optional request configuration including timeout
|
|
1254
1268
|
* @returns Object containing file's id and downloadUrl, or null if timed out
|
|
1255
1269
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -595,6 +595,11 @@ interface WaitForDownloadConfig {
|
|
|
595
595
|
* Default is 5. 0 means no lookback.
|
|
596
596
|
*/
|
|
597
597
|
lookbackSeconds?: number;
|
|
598
|
+
/**
|
|
599
|
+
* The file type to wait for, such as "browser_download".
|
|
600
|
+
* If provided, only files of this type will be considered.
|
|
601
|
+
*/
|
|
602
|
+
fileType?: string;
|
|
598
603
|
}
|
|
599
604
|
/**
|
|
600
605
|
* Result of waiting for a file download.
|
|
@@ -608,6 +613,14 @@ interface WaitForDownloadResult {
|
|
|
608
613
|
* The download URL for the file.
|
|
609
614
|
*/
|
|
610
615
|
downloadUrl: string;
|
|
616
|
+
/**
|
|
617
|
+
* The name of the file.
|
|
618
|
+
*/
|
|
619
|
+
fileName?: string;
|
|
620
|
+
/**
|
|
621
|
+
* The type of the file.
|
|
622
|
+
*/
|
|
623
|
+
fileType?: string;
|
|
611
624
|
}
|
|
612
625
|
interface CreateFileConfig extends Omit<FileCreateFileParams, "sessionId" | "fileName"> {
|
|
613
626
|
}
|
|
@@ -1250,6 +1263,7 @@ declare class AirtopSessionClient extends AirtopBase {
|
|
|
1250
1263
|
*
|
|
1251
1264
|
* @param configuration - The optional configuration parameters for the function
|
|
1252
1265
|
* @param configuration.lookbackSeconds - The number of seconds to look back for prior events. Default `5`. 0 means no lookback.
|
|
1266
|
+
* @param configuration.fileType - The file type to wait for, such as "browser_download". If provided, only files of this type will be considered.
|
|
1253
1267
|
* @param requestOptions - Optional request configuration including timeout
|
|
1254
1268
|
* @returns Object containing file's id and downloadUrl, or null if timed out
|
|
1255
1269
|
*/
|
package/dist/index.js
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.35",
|
|
13
13
|
type: "module",
|
|
14
14
|
main: "./dist/index.cjs",
|
|
15
15
|
module: "./dist/index.js",
|
|
@@ -48,7 +48,7 @@ var require_package = __commonJS({
|
|
|
48
48
|
"verify-types": "tsc --noEmit && tsc --noEmit --project tsconfig.e2e.json"
|
|
49
49
|
},
|
|
50
50
|
dependencies: {
|
|
51
|
-
"@airtop/core": "0.1.0-alpha.
|
|
51
|
+
"@airtop/core": "0.1.0-alpha.44",
|
|
52
52
|
"@airtop/json-schema-adapter": "workspace:*",
|
|
53
53
|
"date-fns": "4.1.0",
|
|
54
54
|
loglayer: "6.7.0",
|
|
@@ -1404,11 +1404,12 @@ var AirtopSessionClient = class extends AirtopBase {
|
|
|
1404
1404
|
*
|
|
1405
1405
|
* @param configuration - The optional configuration parameters for the function
|
|
1406
1406
|
* @param configuration.lookbackSeconds - The number of seconds to look back for prior events. Default `5`. 0 means no lookback.
|
|
1407
|
+
* @param configuration.fileType - The file type to wait for, such as "browser_download". If provided, only files of this type will be considered.
|
|
1407
1408
|
* @param requestOptions - Optional request configuration including timeout
|
|
1408
1409
|
* @returns Object containing file's id and downloadUrl, or null if timed out
|
|
1409
1410
|
*/
|
|
1410
1411
|
async waitForDownload(configuration, requestOptions = {}) {
|
|
1411
|
-
const { lookbackSeconds = 5 } = configuration || {};
|
|
1412
|
+
const { lookbackSeconds = 5, fileType } = configuration || {};
|
|
1412
1413
|
this.log.info(`waiting for file to be available on session: ${this.sessionId}`);
|
|
1413
1414
|
const startTime = /* @__PURE__ */ new Date();
|
|
1414
1415
|
const timeoutSeconds = requestOptions?.timeoutInSeconds || 120;
|
|
@@ -1421,31 +1422,32 @@ var AirtopSessionClient = class extends AirtopBase {
|
|
|
1421
1422
|
const processEventsPromise = (async () => {
|
|
1422
1423
|
const sessionEvents = await this.client.sessions.getEvents(
|
|
1423
1424
|
this.sessionId,
|
|
1424
|
-
{ all: lookbackSeconds >= 0 },
|
|
1425
|
+
{ all: lookbackSeconds >= 0, reverse: true },
|
|
1425
1426
|
{ timeoutInSeconds: timeoutSeconds, ...requestOptions || {} }
|
|
1426
1427
|
);
|
|
1427
|
-
const events = [];
|
|
1428
1428
|
for await (const event of sessionEvents) {
|
|
1429
|
-
events.push(event);
|
|
1430
|
-
}
|
|
1431
|
-
for (let i = events.length - 1; i >= 0; i--) {
|
|
1432
|
-
const event = events[i];
|
|
1433
1429
|
const e = event;
|
|
1434
1430
|
if (e.event === "file_status") {
|
|
1435
1431
|
if (e.status === "available") {
|
|
1436
1432
|
const eventTime = Date.parse(e.eventTime);
|
|
1437
1433
|
this.log.info(`file_status message received:
|
|
1438
1434
|
${JSON.stringify(event, null, 2)}`);
|
|
1435
|
+
if (fileType && e.type !== fileType) {
|
|
1436
|
+
this.log.info(`skipping file of type ${e.type} (looking for ${fileType})`);
|
|
1437
|
+
continue;
|
|
1438
|
+
}
|
|
1439
1439
|
const thresholdTime = startTime.getTime() - lookbackSeconds * 1e3;
|
|
1440
1440
|
if (eventTime < thresholdTime) {
|
|
1441
1441
|
this.log.info(
|
|
1442
|
-
`
|
|
1442
|
+
`stopping event processing - encountered event older than lookbackSeconds threshold`
|
|
1443
1443
|
);
|
|
1444
|
-
|
|
1444
|
+
break;
|
|
1445
1445
|
}
|
|
1446
1446
|
return {
|
|
1447
1447
|
id: e.fileId,
|
|
1448
|
-
downloadUrl: e.downloadUrl
|
|
1448
|
+
downloadUrl: e.downloadUrl,
|
|
1449
|
+
fileName: e.name,
|
|
1450
|
+
fileType: e.type
|
|
1449
1451
|
};
|
|
1450
1452
|
}
|
|
1451
1453
|
}
|