@airtop/sdk 0.1.37-beta0 → 0.1.37-beta1

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 -14
  32. package/dist/wrapper/AirtopSessions.js +39 -22
  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 -14
  45. package/wrapper/AirtopSessions.js +39 -22
@@ -4,14 +4,20 @@
4
4
  import * as serializers from "../../../index";
5
5
  import * as Airtop from "../../../../api/index";
6
6
  import * as core from "../../../../core";
7
+ import { SessionsEventsResponseSessionEvent } from "./SessionsEventsResponseSessionEvent";
8
+ import { SessionsEventsResponseFileEvent } from "./SessionsEventsResponseFileEvent";
7
9
  import { SessionsEventsResponseStatus } from "./SessionsEventsResponseStatus";
8
10
  import { SessionsEventsResponseError } from "./SessionsEventsResponseError";
9
11
  import { SessionsEventsResponseWindowEvent } from "./SessionsEventsResponseWindowEvent";
10
- import { SessionsEventsResponseSessionEvent } from "./SessionsEventsResponseSessionEvent";
11
- import { SessionsEventsResponseFileEvent } from "./SessionsEventsResponseFileEvent";
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;
14
+ type Raw = SessionsEventsResponse.SessionEvent | SessionsEventsResponse.FileEvent | SessionsEventsResponse.Status | SessionsEventsResponse.Error | SessionsEventsResponse.WindowEvent;
15
+ interface SessionEvent extends SessionsEventsResponseSessionEvent.Raw {
16
+ event: "sessionEvent";
17
+ }
18
+ interface FileEvent extends SessionsEventsResponseFileEvent.Raw {
19
+ event: "fileEvent";
20
+ }
15
21
  interface Status extends SessionsEventsResponseStatus.Raw {
16
22
  event: "status";
17
23
  }
@@ -21,10 +27,4 @@ export declare namespace SessionsEventsResponse {
21
27
  interface WindowEvent extends SessionsEventsResponseWindowEvent.Raw {
22
28
  event: "windowEvent";
23
29
  }
24
- interface SessionEvent extends SessionsEventsResponseSessionEvent.Raw {
25
- event: "sessionEvent";
26
- }
27
- interface FileEvent extends SessionsEventsResponseFileEvent.Raw {
28
- event: "fileEvent";
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 SessionsEventsResponseSessionEvent_1 = require("./SessionsEventsResponseSessionEvent");
42
+ const SessionsEventsResponseFileEvent_1 = require("./SessionsEventsResponseFileEvent");
41
43
  const SessionsEventsResponseStatus_1 = require("./SessionsEventsResponseStatus");
42
44
  const SessionsEventsResponseError_1 = require("./SessionsEventsResponseError");
43
45
  const SessionsEventsResponseWindowEvent_1 = require("./SessionsEventsResponseWindowEvent");
44
- const SessionsEventsResponseSessionEvent_1 = require("./SessionsEventsResponseSessionEvent");
45
- const SessionsEventsResponseFileEvent_1 = require("./SessionsEventsResponseFileEvent");
46
46
  exports.SessionsEventsResponse = core.serialization
47
47
  .union("event", {
48
+ sessionEvent: SessionsEventsResponseSessionEvent_1.SessionsEventsResponseSessionEvent,
49
+ fileEvent: SessionsEventsResponseFileEvent_1.SessionsEventsResponseFileEvent,
48
50
  status: SessionsEventsResponseStatus_1.SessionsEventsResponseStatus,
49
51
  error: SessionsEventsResponseError_1.SessionsEventsResponseError,
50
52
  windowEvent: SessionsEventsResponseWindowEvent_1.SessionsEventsResponseWindowEvent,
51
- sessionEvent: SessionsEventsResponseSessionEvent_1.SessionsEventsResponseSessionEvent,
52
- fileEvent: SessionsEventsResponseFileEvent_1.SessionsEventsResponseFileEvent,
53
53
  })
54
54
  .transform({
55
55
  transform: (value) => value,
@@ -1,7 +1,7 @@
1
1
  export * from "./SessionsListRequestStatus";
2
+ export * from "./SessionsEventsResponseSessionEvent";
3
+ export * from "./SessionsEventsResponseFileEvent";
2
4
  export * from "./SessionsEventsResponseStatus";
3
5
  export * from "./SessionsEventsResponseError";
4
6
  export * from "./SessionsEventsResponseWindowEvent";
5
- export * from "./SessionsEventsResponseSessionEvent";
6
- export * from "./SessionsEventsResponseFileEvent";
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("./SessionsEventsResponseSessionEvent"), exports);
19
+ __exportStar(require("./SessionsEventsResponseFileEvent"), exports);
18
20
  __exportStar(require("./SessionsEventsResponseStatus"), exports);
19
21
  __exportStar(require("./SessionsEventsResponseError"), exports);
20
22
  __exportStar(require("./SessionsEventsResponseWindowEvent"), exports);
21
- __exportStar(require("./SessionsEventsResponseSessionEvent"), exports);
22
- __exportStar(require("./SessionsEventsResponseFileEvent"), 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-beta1";
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-beta1";
@@ -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,55 @@ 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 `includePriorEvents` and `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 {Object} params - The parameters for the function
37
+ * @param {string} params.sessionId - The ID of the session to monitor
38
+ * @param {boolean} [params.includePriorEvents=true] - Whether to include prior events in the wait. Default `true`.
39
+ * @param {number} [params.lookbackSeconds=5] - The number of seconds to look back for prior events. Default `5`.
40
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
41
+ * @returns {Promise<{ id: string, downloadUrl: string } | null>} Object containing file's id and downloadUrl, or null if timed out
37
42
  */
38
- waitForDownload(sessionId: string, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
43
+ waitForDownload(sessionId: string, configuration?: {
44
+ includePriorEvents?: boolean;
45
+ lookbackSeconds?: number;
46
+ }, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
39
47
  id: string;
40
48
  downloadUrl: string;
41
49
  } | null>;
42
50
  /**
43
51
  * Waits for a file download to start in a session
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 {Object} params - The parameters for the function
54
+ * @param {string} params.sessionId - The ID of the session to monitor
55
+ * @param {boolean} [params.includePriorEvents=false] - Whether to include prior events in the wait
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, includePriorEvents }: {
60
+ sessionId: string;
61
+ includePriorEvents?: boolean;
62
+ }, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
50
63
  id: string;
51
64
  downloadUrl: string;
52
65
  } | null>;
53
66
  /**
54
67
  * Downloads the next file from a session as soon as it starts to become available
55
68
  *
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
69
+ * @param {Object} params - The parameters for the function
70
+ * @param {string} params.sessionId - The ID of the session to download from
71
+ * @param {string} params.destinationPath - The local path where the file should be saved
72
+ * @param {function} [params.onProgress] - Optional callback to track download progress
73
+ * @param {boolean} [params.includePriorEvents=false] - Whether to include prior events in the wait
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, destinationPath, onProgress, includePriorEvents, }: {
78
+ sessionId: string;
79
+ destinationPath: string;
80
+ onProgress?: (downloadedBytes: number, totalBytes: number) => void;
81
+ includePriorEvents?: boolean;
82
+ }, requestOptions?: SessionsNamespace.RequestOptions): Promise<void>;
63
83
  }
@@ -152,14 +152,21 @@ 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 `includePriorEvents` and `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 {Object} params - The parameters for the function
160
+ * @param {string} params.sessionId - The ID of the session to monitor
161
+ * @param {boolean} [params.includePriorEvents=true] - Whether to include prior events in the wait. Default `true`.
162
+ * @param {number} [params.lookbackSeconds=5] - The number of seconds to look back for prior events. Default `5`.
163
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
164
+ * @returns {Promise<{ id: string, downloadUrl: string } | null>} Object containing file's id and downloadUrl, or null if timed out
160
165
  */
161
- waitForDownload(sessionId, requestOptions) {
166
+ waitForDownload(sessionId, configuration, requestOptions) {
162
167
  return __awaiter(this, void 0, void 0, function* () {
168
+ const { includePriorEvents = true, lookbackSeconds = 5 } = configuration || {};
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) => {
@@ -168,7 +175,7 @@ class AirtopSessions extends Client_1.Sessions {
168
175
  // Create a promise for the event processing
169
176
  const processEventsPromise = (() => __awaiter(this, void 0, void 0, function* () {
170
177
  var _a, e_2, _b, _c;
171
- const sessionEvents = yield this.events(sessionId, {}, Object.assign({ timeoutInSeconds: timeoutSeconds }, (requestOptions || {})));
178
+ const sessionEvents = yield this.events(sessionId, { all: includePriorEvents }, Object.assign({ timeoutInSeconds: timeoutSeconds }, (requestOptions || {})));
172
179
  try {
173
180
  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
181
  _c = sessionEvents_2_1.value;
@@ -176,8 +183,14 @@ class AirtopSessions extends Client_1.Sessions {
176
183
  const event = _c;
177
184
  const e = event;
178
185
  if (e.event === 'file_status') {
179
- this.log(`file_status message received:\n${JSON.stringify(event, null, 2)}`);
180
186
  if (e.status === 'available') {
187
+ const eventTime = Date.parse(e.eventTime);
188
+ this.log(`file_status message received:\n${JSON.stringify(event, null, 2)}`);
189
+ const thresholdTime = startTime.getTime() - lookbackSeconds * 1000;
190
+ if (eventTime < thresholdTime) {
191
+ this.log(`skipping file available event for ${e.fileId} because its timestamp is earlier than lookbackSeconds`);
192
+ continue;
193
+ }
181
194
  return {
182
195
  id: e.fileId,
183
196
  downloadUrl: e.downloadUrl,
@@ -202,12 +215,14 @@ class AirtopSessions extends Client_1.Sessions {
202
215
  /**
203
216
  * Waits for a file download to start in a session
204
217
  *
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
218
+ * @param {Object} params - The parameters for the function
219
+ * @param {string} params.sessionId - The ID of the session to monitor
220
+ * @param {boolean} [params.includePriorEvents=false] - Whether to include prior events in the wait
221
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
222
+ * @returns {Promise<{ id: string, downloadUrl: string } | null>} Object containing file's id and downloadUrl, or null if timed out
208
223
  */
209
- waitForDownloadStart(sessionId, requestOptions) {
210
- return __awaiter(this, void 0, void 0, function* () {
224
+ waitForDownloadStart(_a, requestOptions_1) {
225
+ return __awaiter(this, arguments, void 0, function* ({ sessionId, includePriorEvents = false }, requestOptions) {
211
226
  const timeoutSeconds = (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) || 60;
212
227
  // Create a promise that resolves to null after the timeout
213
228
  const timeoutPromise = new Promise((resolve) => {
@@ -216,7 +231,7 @@ class AirtopSessions extends Client_1.Sessions {
216
231
  // Create a promise for the event processing
217
232
  const processEventsPromise = (() => __awaiter(this, void 0, void 0, function* () {
218
233
  var _a, e_3, _b, _c;
219
- const sessionEvents = yield this.events(sessionId, {}, Object.assign({ timeoutInSeconds: timeoutSeconds }, (requestOptions || {})));
234
+ const sessionEvents = yield this.events(sessionId, { all: includePriorEvents }, Object.assign({ timeoutInSeconds: timeoutSeconds }, (requestOptions || {})));
220
235
  try {
221
236
  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
237
  _c = sessionEvents_3_1.value;
@@ -250,16 +265,18 @@ class AirtopSessions extends Client_1.Sessions {
250
265
  /**
251
266
  * Downloads the next file from a session as soon as it starts to become available
252
267
  *
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
268
+ * @param {Object} params - The parameters for the function
269
+ * @param {string} params.sessionId - The ID of the session to download from
270
+ * @param {string} params.destinationPath - The local path where the file should be saved
271
+ * @param {function} [params.onProgress] - Optional callback to track download progress
272
+ * @param {boolean} [params.includePriorEvents=false] - Whether to include prior events in the wait
273
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
257
274
  * @throws Error if no file is available to download within the timeout period
258
275
  */
259
- downloadNextFile(sessionId, destinationPath, onProgress, requestOptions) {
260
- return __awaiter(this, void 0, void 0, function* () {
261
- var _a;
262
- const nextFile = yield this.waitForDownload(sessionId, requestOptions);
276
+ downloadNextFile(_a, requestOptions_1) {
277
+ return __awaiter(this, arguments, void 0, function* ({ sessionId, destinationPath, onProgress, includePriorEvents = false, }, requestOptions) {
278
+ var _b;
279
+ const nextFile = yield this.waitForDownload(sessionId, { includePriorEvents }, requestOptions);
263
280
  if (!nextFile) {
264
281
  throw new Error('No file to download within timeout');
265
282
  }
@@ -267,7 +284,7 @@ class AirtopSessions extends Client_1.Sessions {
267
284
  if (!downloadResponse.ok) {
268
285
  throw new Error(`Failed to download file: ${downloadResponse.statusText}`);
269
286
  }
270
- const totalBytes = Number.parseInt((_a = downloadResponse.headers.get('content-length')) !== null && _a !== void 0 ? _a : '0', 10);
287
+ const totalBytes = Number.parseInt((_b = downloadResponse.headers.get('content-length')) !== null && _b !== void 0 ? _b : '0', 10);
271
288
  let downloadedBytes = 0;
272
289
  fs.mkdirSync(path.dirname(destinationPath), { recursive: true });
273
290
  const fileStream = fs.createWriteStream(destinationPath);
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-beta1",
4
4
  "private": false,
5
5
  "repository": "https://github.com/airtop-ai/airtop-node-sdk",
6
6
  "main": "./index.js",
@@ -4,14 +4,20 @@
4
4
  import * as serializers from "../../../index";
5
5
  import * as Airtop from "../../../../api/index";
6
6
  import * as core from "../../../../core";
7
+ import { SessionsEventsResponseSessionEvent } from "./SessionsEventsResponseSessionEvent";
8
+ import { SessionsEventsResponseFileEvent } from "./SessionsEventsResponseFileEvent";
7
9
  import { SessionsEventsResponseStatus } from "./SessionsEventsResponseStatus";
8
10
  import { SessionsEventsResponseError } from "./SessionsEventsResponseError";
9
11
  import { SessionsEventsResponseWindowEvent } from "./SessionsEventsResponseWindowEvent";
10
- import { SessionsEventsResponseSessionEvent } from "./SessionsEventsResponseSessionEvent";
11
- import { SessionsEventsResponseFileEvent } from "./SessionsEventsResponseFileEvent";
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;
14
+ type Raw = SessionsEventsResponse.SessionEvent | SessionsEventsResponse.FileEvent | SessionsEventsResponse.Status | SessionsEventsResponse.Error | SessionsEventsResponse.WindowEvent;
15
+ interface SessionEvent extends SessionsEventsResponseSessionEvent.Raw {
16
+ event: "sessionEvent";
17
+ }
18
+ interface FileEvent extends SessionsEventsResponseFileEvent.Raw {
19
+ event: "fileEvent";
20
+ }
15
21
  interface Status extends SessionsEventsResponseStatus.Raw {
16
22
  event: "status";
17
23
  }
@@ -21,10 +27,4 @@ export declare namespace SessionsEventsResponse {
21
27
  interface WindowEvent extends SessionsEventsResponseWindowEvent.Raw {
22
28
  event: "windowEvent";
23
29
  }
24
- interface SessionEvent extends SessionsEventsResponseSessionEvent.Raw {
25
- event: "sessionEvent";
26
- }
27
- interface FileEvent extends SessionsEventsResponseFileEvent.Raw {
28
- event: "fileEvent";
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 SessionsEventsResponseSessionEvent_1 = require("./SessionsEventsResponseSessionEvent");
42
+ const SessionsEventsResponseFileEvent_1 = require("./SessionsEventsResponseFileEvent");
41
43
  const SessionsEventsResponseStatus_1 = require("./SessionsEventsResponseStatus");
42
44
  const SessionsEventsResponseError_1 = require("./SessionsEventsResponseError");
43
45
  const SessionsEventsResponseWindowEvent_1 = require("./SessionsEventsResponseWindowEvent");
44
- const SessionsEventsResponseSessionEvent_1 = require("./SessionsEventsResponseSessionEvent");
45
- const SessionsEventsResponseFileEvent_1 = require("./SessionsEventsResponseFileEvent");
46
46
  exports.SessionsEventsResponse = core.serialization
47
47
  .union("event", {
48
+ sessionEvent: SessionsEventsResponseSessionEvent_1.SessionsEventsResponseSessionEvent,
49
+ fileEvent: SessionsEventsResponseFileEvent_1.SessionsEventsResponseFileEvent,
48
50
  status: SessionsEventsResponseStatus_1.SessionsEventsResponseStatus,
49
51
  error: SessionsEventsResponseError_1.SessionsEventsResponseError,
50
52
  windowEvent: SessionsEventsResponseWindowEvent_1.SessionsEventsResponseWindowEvent,
51
- sessionEvent: SessionsEventsResponseSessionEvent_1.SessionsEventsResponseSessionEvent,
52
- fileEvent: SessionsEventsResponseFileEvent_1.SessionsEventsResponseFileEvent,
53
53
  })
54
54
  .transform({
55
55
  transform: (value) => value,
@@ -1,7 +1,7 @@
1
1
  export * from "./SessionsListRequestStatus";
2
+ export * from "./SessionsEventsResponseSessionEvent";
3
+ export * from "./SessionsEventsResponseFileEvent";
2
4
  export * from "./SessionsEventsResponseStatus";
3
5
  export * from "./SessionsEventsResponseError";
4
6
  export * from "./SessionsEventsResponseWindowEvent";
5
- export * from "./SessionsEventsResponseSessionEvent";
6
- export * from "./SessionsEventsResponseFileEvent";
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("./SessionsEventsResponseSessionEvent"), exports);
19
+ __exportStar(require("./SessionsEventsResponseFileEvent"), exports);
18
20
  __exportStar(require("./SessionsEventsResponseStatus"), exports);
19
21
  __exportStar(require("./SessionsEventsResponseError"), exports);
20
22
  __exportStar(require("./SessionsEventsResponseWindowEvent"), exports);
21
- __exportStar(require("./SessionsEventsResponseSessionEvent"), exports);
22
- __exportStar(require("./SessionsEventsResponseFileEvent"), 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-beta1";
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-beta1";
@@ -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,55 @@ 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 `includePriorEvents` and `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 {Object} params - The parameters for the function
37
+ * @param {string} params.sessionId - The ID of the session to monitor
38
+ * @param {boolean} [params.includePriorEvents=true] - Whether to include prior events in the wait. Default `true`.
39
+ * @param {number} [params.lookbackSeconds=5] - The number of seconds to look back for prior events. Default `5`.
40
+ * @param {Sessions.RequestOptions} [requestOptions] - Optional request configuration including timeout
41
+ * @returns {Promise<{ id: string, downloadUrl: string } | null>} Object containing file's id and downloadUrl, or null if timed out
37
42
  */
38
- waitForDownload(sessionId: string, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
43
+ waitForDownload(sessionId: string, configuration?: {
44
+ includePriorEvents?: boolean;
45
+ lookbackSeconds?: number;
46
+ }, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
39
47
  id: string;
40
48
  downloadUrl: string;
41
49
  } | null>;
42
50
  /**
43
51
  * Waits for a file download to start in a session
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 {Object} params - The parameters for the function
54
+ * @param {string} params.sessionId - The ID of the session to monitor
55
+ * @param {boolean} [params.includePriorEvents=false] - Whether to include prior events in the wait
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, includePriorEvents }: {
60
+ sessionId: string;
61
+ includePriorEvents?: boolean;
62
+ }, requestOptions?: SessionsNamespace.RequestOptions): Promise<{
50
63
  id: string;
51
64
  downloadUrl: string;
52
65
  } | null>;
53
66
  /**
54
67
  * Downloads the next file from a session as soon as it starts to become available
55
68
  *
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
69
+ * @param {Object} params - The parameters for the function
70
+ * @param {string} params.sessionId - The ID of the session to download from
71
+ * @param {string} params.destinationPath - The local path where the file should be saved
72
+ * @param {function} [params.onProgress] - Optional callback to track download progress
73
+ * @param {boolean} [params.includePriorEvents=false] - Whether to include prior events in the wait
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, destinationPath, onProgress, includePriorEvents, }: {
78
+ sessionId: string;
79
+ destinationPath: string;
80
+ onProgress?: (downloadedBytes: number, totalBytes: number) => void;
81
+ includePriorEvents?: boolean;
82
+ }, requestOptions?: SessionsNamespace.RequestOptions): Promise<void>;
63
83
  }