@airtop/sdk 0.1.37-beta0 → 0.1.37-beta2

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.
Files changed (45) hide show
  1. package/api/resources/automations/client/Client.js +4 -4
  2. package/api/resources/files/client/Client.js +4 -4
  3. package/api/resources/profiles/client/Client.js +1 -1
  4. package/api/resources/requests/client/Client.js +1 -1
  5. package/api/resources/sessions/client/Client.js +6 -6
  6. package/api/resources/sessions/types/SessionsEventsResponse.d.ts +7 -7
  7. package/api/resources/sessions/types/index.d.ts +2 -2
  8. package/api/resources/sessions/types/index.js +2 -2
  9. package/api/resources/windows/client/Client.js +31 -31
  10. package/api/types/FileEventMessage.d.ts +2 -0
  11. package/dist/api/resources/automations/client/Client.js +4 -4
  12. package/dist/api/resources/files/client/Client.js +4 -4
  13. package/dist/api/resources/profiles/client/Client.js +1 -1
  14. package/dist/api/resources/requests/client/Client.js +1 -1
  15. package/dist/api/resources/sessions/client/Client.js +6 -6
  16. package/dist/api/resources/sessions/types/SessionsEventsResponse.d.ts +7 -7
  17. package/dist/api/resources/sessions/types/index.d.ts +2 -2
  18. package/dist/api/resources/sessions/types/index.js +2 -2
  19. package/dist/api/resources/windows/client/Client.js +31 -31
  20. package/dist/api/types/FileEventMessage.d.ts +2 -0
  21. package/dist/serialization/resources/sessions/types/SessionsEventsResponse.d.ts +9 -9
  22. package/dist/serialization/resources/sessions/types/SessionsEventsResponse.js +4 -4
  23. package/dist/serialization/resources/sessions/types/index.d.ts +2 -2
  24. package/dist/serialization/resources/sessions/types/index.js +2 -2
  25. package/dist/serialization/types/FileEventMessage.d.ts +1 -0
  26. package/dist/serialization/types/FileEventMessage.js +1 -0
  27. package/dist/version.d.ts +1 -1
  28. package/dist/version.js +1 -1
  29. package/dist/wrapper/AirtopFiles.d.ts +1 -1
  30. package/dist/wrapper/AirtopFiles.js +1 -1
  31. package/dist/wrapper/AirtopSessions.d.ts +34 -15
  32. package/dist/wrapper/AirtopSessions.js +52 -20
  33. package/package.json +1 -1
  34. package/serialization/resources/sessions/types/SessionsEventsResponse.d.ts +9 -9
  35. package/serialization/resources/sessions/types/SessionsEventsResponse.js +4 -4
  36. package/serialization/resources/sessions/types/index.d.ts +2 -2
  37. package/serialization/resources/sessions/types/index.js +2 -2
  38. package/serialization/types/FileEventMessage.d.ts +1 -0
  39. package/serialization/types/FileEventMessage.js +1 -0
  40. package/version.d.ts +1 -1
  41. package/version.js +1 -1
  42. package/wrapper/AirtopFiles.d.ts +1 -1
  43. package/wrapper/AirtopFiles.js +1 -1
  44. package/wrapper/AirtopSessions.d.ts +34 -15
  45. package/wrapper/AirtopSessions.js +52 -20
@@ -4,20 +4,14 @@
4
4
  import * as serializers from "../../../index";
5
5
  import * as Airtop from "../../../../api/index";
6
6
  import * as core from "../../../../core";
7
- import { SessionsEventsResponseStatus } from "./SessionsEventsResponseStatus";
8
- import { SessionsEventsResponseError } from "./SessionsEventsResponseError";
9
7
  import { SessionsEventsResponseWindowEvent } from "./SessionsEventsResponseWindowEvent";
10
8
  import { SessionsEventsResponseSessionEvent } from "./SessionsEventsResponseSessionEvent";
11
9
  import { SessionsEventsResponseFileEvent } from "./SessionsEventsResponseFileEvent";
10
+ import { SessionsEventsResponseStatus } from "./SessionsEventsResponseStatus";
11
+ import { SessionsEventsResponseError } from "./SessionsEventsResponseError";
12
12
  export declare const SessionsEventsResponse: core.serialization.Schema<serializers.SessionsEventsResponse.Raw, Airtop.SessionsEventsResponse>;
13
13
  export declare namespace SessionsEventsResponse {
14
- type Raw = SessionsEventsResponse.Status | SessionsEventsResponse.Error | SessionsEventsResponse.WindowEvent | SessionsEventsResponse.SessionEvent | SessionsEventsResponse.FileEvent;
15
- interface Status extends SessionsEventsResponseStatus.Raw {
16
- event: "status";
17
- }
18
- interface Error extends SessionsEventsResponseError.Raw {
19
- event: "error";
20
- }
14
+ type Raw = SessionsEventsResponse.WindowEvent | SessionsEventsResponse.SessionEvent | SessionsEventsResponse.FileEvent | SessionsEventsResponse.Status | SessionsEventsResponse.Error;
21
15
  interface WindowEvent extends SessionsEventsResponseWindowEvent.Raw {
22
16
  event: "windowEvent";
23
17
  }
@@ -27,4 +21,10 @@ export declare namespace SessionsEventsResponse {
27
21
  interface FileEvent extends SessionsEventsResponseFileEvent.Raw {
28
22
  event: "fileEvent";
29
23
  }
24
+ interface Status extends SessionsEventsResponseStatus.Raw {
25
+ event: "status";
26
+ }
27
+ interface Error extends SessionsEventsResponseError.Raw {
28
+ event: "error";
29
+ }
30
30
  }
@@ -38,18 +38,18 @@ var __importStar = (this && this.__importStar) || (function () {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.SessionsEventsResponse = void 0;
40
40
  const core = __importStar(require("../../../../core"));
41
- const SessionsEventsResponseStatus_1 = require("./SessionsEventsResponseStatus");
42
- const SessionsEventsResponseError_1 = require("./SessionsEventsResponseError");
43
41
  const SessionsEventsResponseWindowEvent_1 = require("./SessionsEventsResponseWindowEvent");
44
42
  const SessionsEventsResponseSessionEvent_1 = require("./SessionsEventsResponseSessionEvent");
45
43
  const SessionsEventsResponseFileEvent_1 = require("./SessionsEventsResponseFileEvent");
44
+ const SessionsEventsResponseStatus_1 = require("./SessionsEventsResponseStatus");
45
+ const SessionsEventsResponseError_1 = require("./SessionsEventsResponseError");
46
46
  exports.SessionsEventsResponse = core.serialization
47
47
  .union("event", {
48
- status: SessionsEventsResponseStatus_1.SessionsEventsResponseStatus,
49
- error: SessionsEventsResponseError_1.SessionsEventsResponseError,
50
48
  windowEvent: SessionsEventsResponseWindowEvent_1.SessionsEventsResponseWindowEvent,
51
49
  sessionEvent: SessionsEventsResponseSessionEvent_1.SessionsEventsResponseSessionEvent,
52
50
  fileEvent: SessionsEventsResponseFileEvent_1.SessionsEventsResponseFileEvent,
51
+ status: SessionsEventsResponseStatus_1.SessionsEventsResponseStatus,
52
+ error: SessionsEventsResponseError_1.SessionsEventsResponseError,
53
53
  })
54
54
  .transform({
55
55
  transform: (value) => value,
@@ -1,7 +1,7 @@
1
1
  export * from "./SessionsListRequestStatus";
2
- export * from "./SessionsEventsResponseStatus";
3
- export * from "./SessionsEventsResponseError";
4
2
  export * from "./SessionsEventsResponseWindowEvent";
5
3
  export * from "./SessionsEventsResponseSessionEvent";
6
4
  export * from "./SessionsEventsResponseFileEvent";
5
+ export * from "./SessionsEventsResponseStatus";
6
+ export * from "./SessionsEventsResponseError";
7
7
  export * from "./SessionsEventsResponse";
@@ -15,9 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./SessionsListRequestStatus"), exports);
18
- __exportStar(require("./SessionsEventsResponseStatus"), exports);
19
- __exportStar(require("./SessionsEventsResponseError"), exports);
20
18
  __exportStar(require("./SessionsEventsResponseWindowEvent"), exports);
21
19
  __exportStar(require("./SessionsEventsResponseSessionEvent"), exports);
22
20
  __exportStar(require("./SessionsEventsResponseFileEvent"), exports);
21
+ __exportStar(require("./SessionsEventsResponseStatus"), exports);
22
+ __exportStar(require("./SessionsEventsResponseError"), exports);
23
23
  __exportStar(require("./SessionsEventsResponse"), exports);
@@ -10,6 +10,7 @@ export declare namespace FileEventMessage {
10
10
  interface Raw {
11
11
  downloadUrl: string;
12
12
  event: string;
13
+ eventTime: string;
13
14
  fileId: string;
14
15
  status: FileEventMessageStatus.Raw;
15
16
  }
@@ -42,6 +42,7 @@ const FileEventMessageStatus_1 = require("./FileEventMessageStatus");
42
42
  exports.FileEventMessage = core.serialization.object({
43
43
  downloadUrl: core.serialization.string(),
44
44
  event: core.serialization.string(),
45
+ eventTime: core.serialization.date(),
45
46
  fileId: core.serialization.string(),
46
47
  status: FileEventMessageStatus_1.FileEventMessageStatus,
47
48
  });
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.1.37-beta0";
1
+ export declare const SDK_VERSION = "0.1.37-beta2";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.1.37-beta0";
4
+ exports.SDK_VERSION = "0.1.37-beta2";
@@ -36,7 +36,7 @@ export declare class AirtopFiles extends FilesClass {
36
36
  */
37
37
  download(fileId: string, destinationPath: string, onProgress?: (downloadedBytes: number, totalBytes: number) => void, options?: FilesNamespace.RequestOptions): Promise<void>;
38
38
  /**
39
- * Waits for a file to become available for download
39
+ * Waits for a file to become available for download.
40
40
  *
41
41
  * @param fileId - The ID of the file to wait for
42
42
  * @param options - Optional request configuration including timeout
@@ -149,7 +149,7 @@ class AirtopFiles extends Client_1.Files {
149
149
  });
150
150
  }
151
151
  /**
152
- * Waits for a file to become available for download
152
+ * Waits for a file to become available for download.
153
153
  *
154
154
  * @param fileId - The ID of the file to wait for
155
155
  * @param options - Optional request configuration including timeout
@@ -29,35 +29,54 @@ export declare class AirtopSessions extends SessionsClass {
29
29
  */
30
30
  waitForSessionReady(id: string, requestOptions?: SessionsNamespace.RequestOptions): Promise<Airtop.SessionsEventsResponse | null>;
31
31
  /**
32
- * Waits for a file to be downloaded in a session and reach 'available' status
32
+ * Waits for a file to be downloaded in a session and reach 'available' status.
33
+ * Defaults to looking back 5 seconds in the event stream for the file to be available.
34
+ * Use `lookbackSeconds` to control this behavior.
33
35
  *
34
- * @param sessionId - The ID of the session to monitor
35
- * @param requestOptions - Optional request configuration including timeout
36
- * @returns Object containing file's id and downloadUrl, or null if timed out
36
+ * @param {string} sessionId - The ID of the session to monitor
37
+ * @param {Object} configuration - The optional configuration parameters for the function
38
+ * @param {number} [configuration.lookbackSeconds=5] - The number of seconds to look back for prior events. Default `5`. 0 means no lookback.
39
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
40
+ * @returns {Promise<{ id: string, downloadUrl: string } | null>} Object containing file's id and downloadUrl, or null if timed out
37
41
  */
38
- waitForDownload(sessionId: string, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
42
+ waitForDownload(sessionId: string, configuration?: {
43
+ lookbackSeconds?: number;
44
+ }, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
39
45
  id: string;
40
46
  downloadUrl: string;
41
47
  } | null>;
42
48
  /**
43
- * Waits for a file download to start in a session
49
+ * Waits for a file download to start in a session.
50
+ * Defaults to looking back 5 seconds in the event stream for the file to be available.
51
+ * Use `lookbackSeconds` to control this behavior.
44
52
  *
45
- * @param sessionId - The ID of the session to monitor
46
- * @param requestOptions - Optional request configuration including timeout
47
- * @returns Object containing file's id and downloadUrl, or null if timed out
53
+ * @param {string} sessionId - The ID of the session to monitor
54
+ * @param {Object} configuration - The optional configuration parameters for the function
55
+ * @param {number} [configuration.lookbackSeconds=5] - The number of seconds to look back for prior events. Default `5`. 0 means no lookback.
56
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
57
+ * @returns {Promise<{ id: string, downloadUrl: string } | null>} Object containing file's id and downloadUrl, or null if timed out
48
58
  */
49
- waitForDownloadStart(sessionId: string, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
59
+ waitForDownloadStart(sessionId: string, configuration?: {
60
+ lookbackSeconds?: number;
61
+ }, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
50
62
  id: string;
51
63
  downloadUrl: string;
52
64
  } | null>;
53
65
  /**
54
66
  * Downloads the next file from a session as soon as it starts to become available
55
67
  *
56
- * @param sessionId - The ID of the session to download from
57
- * @param destinationPath - The local path where the file should be saved
58
- * @param onProgress - Optional callback to track download progress
59
- * @param requestOptions - Optional request configuration including timeout
68
+ * @param {string} sessionId - The ID of the session to download from
69
+ * @param {string} destinationPath - The local path where the file should be saved
70
+ * @param {Object} configuration - The optional configuration parameters for the function
71
+ * @param {function} [configuration.onProgress] - Optional callback to track download progress
72
+ * @param {number} [configuration.lookbackSeconds=5] - Optional number of seconds to look back for prior events. Default `5`. 0 means no lookback.
73
+ * @param {number} [configuration.timeoutSeconds=120] - Optional timeout in seconds. Default `120`.
74
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
60
75
  * @throws Error if no file is available to download within the timeout period
61
76
  */
62
- downloadNextFile(sessionId: string, destinationPath: string, onProgress?: (downloadedBytes: number, totalBytes: number) => void, requestOptions?: SessionsNamespace.RequestOptions): Promise<void>;
77
+ downloadNextFile(sessionId: string, destinationPath: string, configuration?: {
78
+ onProgress?: (downloadedBytes: number, totalBytes: number) => void;
79
+ lookbackSeconds?: number;
80
+ timeoutSeconds?: number;
81
+ }, requestOptions?: SessionsNamespace.RequestOptions): Promise<void>;
63
82
  }
@@ -152,23 +152,33 @@ class AirtopSessions extends Client_1.Sessions {
152
152
  });
153
153
  }
154
154
  /**
155
- * Waits for a file to be downloaded in a session and reach 'available' status
155
+ * Waits for a file to be downloaded in a session and reach 'available' status.
156
+ * Defaults to looking back 5 seconds in the event stream for the file to be available.
157
+ * Use `lookbackSeconds` to control this behavior.
156
158
  *
157
- * @param sessionId - The ID of the session to monitor
158
- * @param requestOptions - Optional request configuration including timeout
159
- * @returns Object containing file's id and downloadUrl, or null if timed out
159
+ * @param {string} sessionId - The ID of the session to monitor
160
+ * @param {Object} configuration - The optional configuration parameters for the function
161
+ * @param {number} [configuration.lookbackSeconds=5] - The number of seconds to look back for prior events. Default `5`. 0 means no lookback.
162
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
163
+ * @returns {Promise<{ id: string, downloadUrl: string } | null>} Object containing file's id and downloadUrl, or null if timed out
160
164
  */
161
- waitForDownload(sessionId, requestOptions) {
165
+ waitForDownload(sessionId, configuration, requestOptions) {
162
166
  return __awaiter(this, void 0, void 0, function* () {
167
+ const { lookbackSeconds = 5 } = configuration || {};
168
+ this.log(`waiting for file to be available on session: ${sessionId}`);
169
+ const startTime = new Date();
163
170
  const timeoutSeconds = (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) || 120;
164
171
  // Create a promise that resolves to null after the timeout
165
172
  const timeoutPromise = new Promise((resolve) => {
166
- setTimeout(() => resolve(null), timeoutSeconds * 1000);
173
+ setTimeout(() => {
174
+ this.log(`waiting for file timed out after ${timeoutSeconds} seconds`);
175
+ resolve(null);
176
+ }, timeoutSeconds * 1000);
167
177
  });
168
178
  // Create a promise for the event processing
169
179
  const processEventsPromise = (() => __awaiter(this, void 0, void 0, function* () {
170
180
  var _a, e_2, _b, _c;
171
- const sessionEvents = yield this.events(sessionId, {}, Object.assign({ timeoutInSeconds: timeoutSeconds }, (requestOptions || {})));
181
+ const sessionEvents = yield this.events(sessionId, { all: lookbackSeconds >= 0 }, Object.assign({ timeoutInSeconds: timeoutSeconds }, (requestOptions || {})));
172
182
  try {
173
183
  for (var _d = true, sessionEvents_2 = __asyncValues(sessionEvents), sessionEvents_2_1; sessionEvents_2_1 = yield sessionEvents_2.next(), _a = sessionEvents_2_1.done, !_a; _d = true) {
174
184
  _c = sessionEvents_2_1.value;
@@ -176,8 +186,14 @@ class AirtopSessions extends Client_1.Sessions {
176
186
  const event = _c;
177
187
  const e = event;
178
188
  if (e.event === 'file_status') {
179
- this.log(`file_status message received:\n${JSON.stringify(event, null, 2)}`);
180
189
  if (e.status === 'available') {
190
+ const eventTime = Date.parse(e.eventTime);
191
+ this.log(`file_status message received:\n${JSON.stringify(event, null, 2)}`);
192
+ const thresholdTime = startTime.getTime() - lookbackSeconds * 1000;
193
+ if (eventTime < thresholdTime) {
194
+ this.log(`skipping file available event for ${e.fileId} because its timestamp is earlier than lookbackSeconds`);
195
+ continue;
196
+ }
181
197
  return {
182
198
  id: e.fileId,
183
199
  downloadUrl: e.downloadUrl,
@@ -200,14 +216,20 @@ class AirtopSessions extends Client_1.Sessions {
200
216
  });
201
217
  }
202
218
  /**
203
- * Waits for a file download to start in a session
219
+ * Waits for a file download to start in a session.
220
+ * Defaults to looking back 5 seconds in the event stream for the file to be available.
221
+ * Use `lookbackSeconds` to control this behavior.
204
222
  *
205
- * @param sessionId - The ID of the session to monitor
206
- * @param requestOptions - Optional request configuration including timeout
207
- * @returns Object containing file's id and downloadUrl, or null if timed out
223
+ * @param {string} sessionId - The ID of the session to monitor
224
+ * @param {Object} configuration - The optional configuration parameters for the function
225
+ * @param {number} [configuration.lookbackSeconds=5] - The number of seconds to look back for prior events. Default `5`. 0 means no lookback.
226
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
227
+ * @returns {Promise<{ id: string, downloadUrl: string } | null>} Object containing file's id and downloadUrl, or null if timed out
208
228
  */
209
- waitForDownloadStart(sessionId, requestOptions) {
229
+ waitForDownloadStart(sessionId, configuration, requestOptions) {
210
230
  return __awaiter(this, void 0, void 0, function* () {
231
+ const { lookbackSeconds = 5 } = configuration || {};
232
+ const startTime = new Date();
211
233
  const timeoutSeconds = (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) || 60;
212
234
  // Create a promise that resolves to null after the timeout
213
235
  const timeoutPromise = new Promise((resolve) => {
@@ -216,7 +238,7 @@ class AirtopSessions extends Client_1.Sessions {
216
238
  // Create a promise for the event processing
217
239
  const processEventsPromise = (() => __awaiter(this, void 0, void 0, function* () {
218
240
  var _a, e_3, _b, _c;
219
- const sessionEvents = yield this.events(sessionId, {}, Object.assign({ timeoutInSeconds: timeoutSeconds }, (requestOptions || {})));
241
+ const sessionEvents = yield this.events(sessionId, { all: lookbackSeconds >= 0 }, Object.assign({ timeoutInSeconds: timeoutSeconds }, (requestOptions || {})));
220
242
  try {
221
243
  for (var _d = true, sessionEvents_3 = __asyncValues(sessionEvents), sessionEvents_3_1; sessionEvents_3_1 = yield sessionEvents_3.next(), _a = sessionEvents_3_1.done, !_a; _d = true) {
222
244
  _c = sessionEvents_3_1.value;
@@ -226,6 +248,12 @@ class AirtopSessions extends Client_1.Sessions {
226
248
  if (e.event === 'file_status') {
227
249
  this.log(`file_status message received:\n${JSON.stringify(event, null, 2)}`);
228
250
  if (e.status === 'uploading') {
251
+ const eventTime = Date.parse(e.eventTime);
252
+ const thresholdTime = startTime.getTime() - lookbackSeconds * 1000;
253
+ if (eventTime < thresholdTime) {
254
+ this.log(`skipping file uploading event for ${e.fileId} because its timestamp is earlier than lookbackSeconds`);
255
+ continue;
256
+ }
229
257
  return {
230
258
  id: e.fileId,
231
259
  downloadUrl: e.downloadUrl,
@@ -250,16 +278,20 @@ class AirtopSessions extends Client_1.Sessions {
250
278
  /**
251
279
  * Downloads the next file from a session as soon as it starts to become available
252
280
  *
253
- * @param sessionId - The ID of the session to download from
254
- * @param destinationPath - The local path where the file should be saved
255
- * @param onProgress - Optional callback to track download progress
256
- * @param requestOptions - Optional request configuration including timeout
281
+ * @param {string} sessionId - The ID of the session to download from
282
+ * @param {string} destinationPath - The local path where the file should be saved
283
+ * @param {Object} configuration - The optional configuration parameters for the function
284
+ * @param {function} [configuration.onProgress] - Optional callback to track download progress
285
+ * @param {number} [configuration.lookbackSeconds=5] - Optional number of seconds to look back for prior events. Default `5`. 0 means no lookback.
286
+ * @param {number} [configuration.timeoutSeconds=120] - Optional timeout in seconds. Default `120`.
287
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
257
288
  * @throws Error if no file is available to download within the timeout period
258
289
  */
259
- downloadNextFile(sessionId, destinationPath, onProgress, requestOptions) {
290
+ downloadNextFile(sessionId, destinationPath, configuration, requestOptions) {
260
291
  return __awaiter(this, void 0, void 0, function* () {
261
292
  var _a;
262
- const nextFile = yield this.waitForDownload(sessionId, requestOptions);
293
+ const { onProgress = undefined, lookbackSeconds = 5, timeoutSeconds = 120 } = configuration || {};
294
+ const nextFile = yield this.waitForDownload(sessionId, { lookbackSeconds }, Object.assign({ timeoutInSeconds: timeoutSeconds }, (requestOptions || {})));
263
295
  if (!nextFile) {
264
296
  throw new Error('No file to download within timeout');
265
297
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airtop/sdk",
3
- "version": "0.1.37-beta0",
3
+ "version": "0.1.37-beta2",
4
4
  "private": false,
5
5
  "repository": "https://github.com/airtop-ai/airtop-node-sdk",
6
6
  "main": "./index.js",
@@ -4,20 +4,14 @@
4
4
  import * as serializers from "../../../index";
5
5
  import * as Airtop from "../../../../api/index";
6
6
  import * as core from "../../../../core";
7
- import { SessionsEventsResponseStatus } from "./SessionsEventsResponseStatus";
8
- import { SessionsEventsResponseError } from "./SessionsEventsResponseError";
9
7
  import { SessionsEventsResponseWindowEvent } from "./SessionsEventsResponseWindowEvent";
10
8
  import { SessionsEventsResponseSessionEvent } from "./SessionsEventsResponseSessionEvent";
11
9
  import { SessionsEventsResponseFileEvent } from "./SessionsEventsResponseFileEvent";
10
+ import { SessionsEventsResponseStatus } from "./SessionsEventsResponseStatus";
11
+ import { SessionsEventsResponseError } from "./SessionsEventsResponseError";
12
12
  export declare const SessionsEventsResponse: core.serialization.Schema<serializers.SessionsEventsResponse.Raw, Airtop.SessionsEventsResponse>;
13
13
  export declare namespace SessionsEventsResponse {
14
- type Raw = SessionsEventsResponse.Status | SessionsEventsResponse.Error | SessionsEventsResponse.WindowEvent | SessionsEventsResponse.SessionEvent | SessionsEventsResponse.FileEvent;
15
- interface Status extends SessionsEventsResponseStatus.Raw {
16
- event: "status";
17
- }
18
- interface Error extends SessionsEventsResponseError.Raw {
19
- event: "error";
20
- }
14
+ type Raw = SessionsEventsResponse.WindowEvent | SessionsEventsResponse.SessionEvent | SessionsEventsResponse.FileEvent | SessionsEventsResponse.Status | SessionsEventsResponse.Error;
21
15
  interface WindowEvent extends SessionsEventsResponseWindowEvent.Raw {
22
16
  event: "windowEvent";
23
17
  }
@@ -27,4 +21,10 @@ export declare namespace SessionsEventsResponse {
27
21
  interface FileEvent extends SessionsEventsResponseFileEvent.Raw {
28
22
  event: "fileEvent";
29
23
  }
24
+ interface Status extends SessionsEventsResponseStatus.Raw {
25
+ event: "status";
26
+ }
27
+ interface Error extends SessionsEventsResponseError.Raw {
28
+ event: "error";
29
+ }
30
30
  }
@@ -38,18 +38,18 @@ var __importStar = (this && this.__importStar) || (function () {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.SessionsEventsResponse = void 0;
40
40
  const core = __importStar(require("../../../../core"));
41
- const SessionsEventsResponseStatus_1 = require("./SessionsEventsResponseStatus");
42
- const SessionsEventsResponseError_1 = require("./SessionsEventsResponseError");
43
41
  const SessionsEventsResponseWindowEvent_1 = require("./SessionsEventsResponseWindowEvent");
44
42
  const SessionsEventsResponseSessionEvent_1 = require("./SessionsEventsResponseSessionEvent");
45
43
  const SessionsEventsResponseFileEvent_1 = require("./SessionsEventsResponseFileEvent");
44
+ const SessionsEventsResponseStatus_1 = require("./SessionsEventsResponseStatus");
45
+ const SessionsEventsResponseError_1 = require("./SessionsEventsResponseError");
46
46
  exports.SessionsEventsResponse = core.serialization
47
47
  .union("event", {
48
- status: SessionsEventsResponseStatus_1.SessionsEventsResponseStatus,
49
- error: SessionsEventsResponseError_1.SessionsEventsResponseError,
50
48
  windowEvent: SessionsEventsResponseWindowEvent_1.SessionsEventsResponseWindowEvent,
51
49
  sessionEvent: SessionsEventsResponseSessionEvent_1.SessionsEventsResponseSessionEvent,
52
50
  fileEvent: SessionsEventsResponseFileEvent_1.SessionsEventsResponseFileEvent,
51
+ status: SessionsEventsResponseStatus_1.SessionsEventsResponseStatus,
52
+ error: SessionsEventsResponseError_1.SessionsEventsResponseError,
53
53
  })
54
54
  .transform({
55
55
  transform: (value) => value,
@@ -1,7 +1,7 @@
1
1
  export * from "./SessionsListRequestStatus";
2
- export * from "./SessionsEventsResponseStatus";
3
- export * from "./SessionsEventsResponseError";
4
2
  export * from "./SessionsEventsResponseWindowEvent";
5
3
  export * from "./SessionsEventsResponseSessionEvent";
6
4
  export * from "./SessionsEventsResponseFileEvent";
5
+ export * from "./SessionsEventsResponseStatus";
6
+ export * from "./SessionsEventsResponseError";
7
7
  export * from "./SessionsEventsResponse";
@@ -15,9 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./SessionsListRequestStatus"), exports);
18
- __exportStar(require("./SessionsEventsResponseStatus"), exports);
19
- __exportStar(require("./SessionsEventsResponseError"), exports);
20
18
  __exportStar(require("./SessionsEventsResponseWindowEvent"), exports);
21
19
  __exportStar(require("./SessionsEventsResponseSessionEvent"), exports);
22
20
  __exportStar(require("./SessionsEventsResponseFileEvent"), exports);
21
+ __exportStar(require("./SessionsEventsResponseStatus"), exports);
22
+ __exportStar(require("./SessionsEventsResponseError"), exports);
23
23
  __exportStar(require("./SessionsEventsResponse"), exports);
@@ -10,6 +10,7 @@ export declare namespace FileEventMessage {
10
10
  interface Raw {
11
11
  downloadUrl: string;
12
12
  event: string;
13
+ eventTime: string;
13
14
  fileId: string;
14
15
  status: FileEventMessageStatus.Raw;
15
16
  }
@@ -42,6 +42,7 @@ const FileEventMessageStatus_1 = require("./FileEventMessageStatus");
42
42
  exports.FileEventMessage = core.serialization.object({
43
43
  downloadUrl: core.serialization.string(),
44
44
  event: core.serialization.string(),
45
+ eventTime: core.serialization.date(),
45
46
  fileId: core.serialization.string(),
46
47
  status: FileEventMessageStatus_1.FileEventMessageStatus,
47
48
  });
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.1.37-beta0";
1
+ export declare const SDK_VERSION = "0.1.37-beta2";
package/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.1.37-beta0";
4
+ exports.SDK_VERSION = "0.1.37-beta2";
@@ -36,7 +36,7 @@ export declare class AirtopFiles extends FilesClass {
36
36
  */
37
37
  download(fileId: string, destinationPath: string, onProgress?: (downloadedBytes: number, totalBytes: number) => void, options?: FilesNamespace.RequestOptions): Promise<void>;
38
38
  /**
39
- * Waits for a file to become available for download
39
+ * Waits for a file to become available for download.
40
40
  *
41
41
  * @param fileId - The ID of the file to wait for
42
42
  * @param options - Optional request configuration including timeout
@@ -149,7 +149,7 @@ class AirtopFiles extends Client_1.Files {
149
149
  });
150
150
  }
151
151
  /**
152
- * Waits for a file to become available for download
152
+ * Waits for a file to become available for download.
153
153
  *
154
154
  * @param fileId - The ID of the file to wait for
155
155
  * @param options - Optional request configuration including timeout
@@ -29,35 +29,54 @@ export declare class AirtopSessions extends SessionsClass {
29
29
  */
30
30
  waitForSessionReady(id: string, requestOptions?: SessionsNamespace.RequestOptions): Promise<Airtop.SessionsEventsResponse | null>;
31
31
  /**
32
- * Waits for a file to be downloaded in a session and reach 'available' status
32
+ * Waits for a file to be downloaded in a session and reach 'available' status.
33
+ * Defaults to looking back 5 seconds in the event stream for the file to be available.
34
+ * Use `lookbackSeconds` to control this behavior.
33
35
  *
34
- * @param sessionId - The ID of the session to monitor
35
- * @param requestOptions - Optional request configuration including timeout
36
- * @returns Object containing file's id and downloadUrl, or null if timed out
36
+ * @param {string} sessionId - The ID of the session to monitor
37
+ * @param {Object} configuration - The optional configuration parameters for the function
38
+ * @param {number} [configuration.lookbackSeconds=5] - The number of seconds to look back for prior events. Default `5`. 0 means no lookback.
39
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
40
+ * @returns {Promise<{ id: string, downloadUrl: string } | null>} Object containing file's id and downloadUrl, or null if timed out
37
41
  */
38
- waitForDownload(sessionId: string, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
42
+ waitForDownload(sessionId: string, configuration?: {
43
+ lookbackSeconds?: number;
44
+ }, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
39
45
  id: string;
40
46
  downloadUrl: string;
41
47
  } | null>;
42
48
  /**
43
- * Waits for a file download to start in a session
49
+ * Waits for a file download to start in a session.
50
+ * Defaults to looking back 5 seconds in the event stream for the file to be available.
51
+ * Use `lookbackSeconds` to control this behavior.
44
52
  *
45
- * @param sessionId - The ID of the session to monitor
46
- * @param requestOptions - Optional request configuration including timeout
47
- * @returns Object containing file's id and downloadUrl, or null if timed out
53
+ * @param {string} sessionId - The ID of the session to monitor
54
+ * @param {Object} configuration - The optional configuration parameters for the function
55
+ * @param {number} [configuration.lookbackSeconds=5] - The number of seconds to look back for prior events. Default `5`. 0 means no lookback.
56
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
57
+ * @returns {Promise<{ id: string, downloadUrl: string } | null>} Object containing file's id and downloadUrl, or null if timed out
48
58
  */
49
- waitForDownloadStart(sessionId: string, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
59
+ waitForDownloadStart(sessionId: string, configuration?: {
60
+ lookbackSeconds?: number;
61
+ }, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
50
62
  id: string;
51
63
  downloadUrl: string;
52
64
  } | null>;
53
65
  /**
54
66
  * Downloads the next file from a session as soon as it starts to become available
55
67
  *
56
- * @param sessionId - The ID of the session to download from
57
- * @param destinationPath - The local path where the file should be saved
58
- * @param onProgress - Optional callback to track download progress
59
- * @param requestOptions - Optional request configuration including timeout
68
+ * @param {string} sessionId - The ID of the session to download from
69
+ * @param {string} destinationPath - The local path where the file should be saved
70
+ * @param {Object} configuration - The optional configuration parameters for the function
71
+ * @param {function} [configuration.onProgress] - Optional callback to track download progress
72
+ * @param {number} [configuration.lookbackSeconds=5] - Optional number of seconds to look back for prior events. Default `5`. 0 means no lookback.
73
+ * @param {number} [configuration.timeoutSeconds=120] - Optional timeout in seconds. Default `120`.
74
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
60
75
  * @throws Error if no file is available to download within the timeout period
61
76
  */
62
- downloadNextFile(sessionId: string, destinationPath: string, onProgress?: (downloadedBytes: number, totalBytes: number) => void, requestOptions?: SessionsNamespace.RequestOptions): Promise<void>;
77
+ downloadNextFile(sessionId: string, destinationPath: string, configuration?: {
78
+ onProgress?: (downloadedBytes: number, totalBytes: number) => void;
79
+ lookbackSeconds?: number;
80
+ timeoutSeconds?: number;
81
+ }, requestOptions?: SessionsNamespace.RequestOptions): Promise<void>;
63
82
  }