@airtop/sdk 1.0.0-alpha2.34 → 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 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.34",
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.43",
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 = _optionalChain([requestOptions, 'optionalAccess', _19 => _19.timeoutInSeconds]) || 120;
@@ -1421,7 +1422,7 @@ 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
1428
  for await (const event of sessionEvents) {
@@ -1431,16 +1432,22 @@ var AirtopSessionClient = class extends AirtopBase {
1431
1432
  const eventTime = Date.parse(e.eventTime);
1432
1433
  this.log.info(`file_status message received:
1433
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
+ }
1434
1439
  const thresholdTime = startTime.getTime() - lookbackSeconds * 1e3;
1435
1440
  if (eventTime < thresholdTime) {
1436
1441
  this.log.info(
1437
- `skipping file available event for ${e.fileId} because its timestamp is earlier than lookbackSeconds`
1442
+ `stopping event processing - encountered event older than lookbackSeconds threshold`
1438
1443
  );
1439
- continue;
1444
+ break;
1440
1445
  }
1441
1446
  return {
1442
1447
  id: e.fileId,
1443
- downloadUrl: e.downloadUrl
1448
+ downloadUrl: e.downloadUrl,
1449
+ fileName: e.name,
1450
+ fileType: e.type
1444
1451
  };
1445
1452
  }
1446
1453
  }