@ibm-aspera/sdk 0.11.0 → 0.19.0

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.
@@ -12,6 +12,7 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.AsperaSdk = exports.ActivityTracking = exports.AsperaSdkGlobals = void 0;
15
+ var status_1 = require("../app/status");
15
16
  var constants_1 = require("../constants/constants");
16
17
  var messages_1 = require("../constants/messages");
17
18
  var safari_client_1 = require("../helpers/client/safari-client");
@@ -88,12 +89,6 @@ var ActivityTracking = /** @class */ (function () {
88
89
  function ActivityTracking() {
89
90
  /** Map of callbacks that receive transfer update events */
90
91
  this.activity_callbacks = new Map();
91
- /** Map of callbacks that receive connection events */
92
- this.event_callbacks = new Map();
93
- /** Keep track of the last WebSocket event **/
94
- this.lastWebSocketEvent = 'CLOSED';
95
- /** Keep track of the last notified WebSocket event **/
96
- this.lastNotifiedWebSocketEvent = undefined;
97
92
  }
98
93
  /**
99
94
  * Notify all consumers when a message is received from the transfer client.
@@ -113,41 +108,27 @@ var ActivityTracking = /** @class */ (function () {
113
108
  }
114
109
  };
115
110
  /**
116
- * Handle and notify if needed when a connection webSocketEvent occurs. For example, when the SDK
111
+ * Handle and notify when a connection webSocketEvent occurs. For example, when the SDK
117
112
  * websocket connection to IBM Aspera App is closed or reconnected.
118
113
  *
114
+ * Bridges WebSocket events to StatusService as SdkStatus values.
115
+ *
119
116
  * @param webSocketEvent the event type.
120
117
  */
121
118
  ActivityTracking.prototype.handleWebSocketEvents = function (webSocketEvent) {
122
- if (this.lastWebSocketEvent === webSocketEvent) {
123
- return;
119
+ if (webSocketEvent === 'CLOSED') {
120
+ status_1.statusService.setStatus('DISCONNECTED');
121
+ }
122
+ else if (webSocketEvent === 'RECONNECT') {
123
+ status_1.statusService.setStatus('RUNNING');
124
124
  }
125
- this.lastWebSocketEvent = webSocketEvent;
126
- this.notifyWebSocketEvent(webSocketEvent);
127
125
  };
128
126
  /**
129
- * Notify all consumers when a connection webSocketEvent occurs.
130
- *
131
- * @param webSocketEvent the event type.
127
+ * Trigger manual event for other event types (e.g. Connect status strings).
128
+ * Bridges to StatusService.
132
129
  */
133
- ActivityTracking.prototype.notifyWebSocketEvent = function (webSocketEvent) {
134
- if (this.lastNotifiedWebSocketEvent === webSocketEvent) {
135
- return;
136
- }
137
- this.lastNotifiedWebSocketEvent = webSocketEvent;
138
- this.event_callbacks.forEach(function (callback) {
139
- if (typeof callback === 'function') {
140
- callback(webSocketEvent);
141
- }
142
- });
143
- };
144
- /** Trigger manual event for other event types. */
145
130
  ActivityTracking.prototype.sendManualEventCallback = function (status) {
146
- this.event_callbacks.forEach(function (callback) {
147
- if (typeof callback === 'function') {
148
- callback(status);
149
- }
150
- });
131
+ status_1.statusService.setStatus(status);
151
132
  };
152
133
  /**
153
134
  * Notify all consumers when the client changes status. For example, when
@@ -156,14 +137,9 @@ var ActivityTracking = /** @class */ (function () {
156
137
  * @param running whether the client is running or not.
157
138
  */
158
139
  ActivityTracking.prototype.handleClientEvents = function (running) {
159
- var webSocketEvent;
160
140
  if (!running) {
161
- webSocketEvent = 'CLOSED';
162
- }
163
- else {
164
- webSocketEvent = this.lastWebSocketEvent;
141
+ status_1.statusService.setStatus('DISCONNECTED');
165
142
  }
166
- this.notifyWebSocketEvent(webSocketEvent);
167
143
  };
168
144
  /**
169
145
  * Notify all consumers when a Safari extension safariExtensionEvent occurs (enabled/disabled).
@@ -249,31 +225,6 @@ var ActivityTracking = /** @class */ (function () {
249
225
  ActivityTracking.prototype.removeCallback = function (id) {
250
226
  this.activity_callbacks.delete(id);
251
227
  };
252
- /**
253
- * Register a callback for getting websocket events back to the consumer
254
- *
255
- * @param callback the function to call with the websocket event
256
- *
257
- * @returns the ID of the callback index
258
- */
259
- ActivityTracking.prototype.setWebSocketEventCallback = function (callback) {
260
- if (typeof callback !== 'function') {
261
- (0, helpers_1.errorLog)(messages_1.messages.callbackIsNotFunction);
262
- return;
263
- }
264
- var id = "callback-".concat(this.event_callbacks.size + 1);
265
- this.event_callbacks.set(id, callback);
266
- callback(this.lastWebSocketEvent);
267
- return id;
268
- };
269
- /**
270
- * Remove the callback (deregister) from the list of callbacks
271
- *
272
- * @param id the string of the callback to remove
273
- */
274
- ActivityTracking.prototype.removeWebSocketEventCallback = function (id) {
275
- this.event_callbacks.delete(id);
276
- };
277
228
  ActivityTracking.prototype.registerDesktopAppSession = function () {
278
229
  var iframe = document.createElement('iframe');
279
230
  iframe.style.display = 'none';
@@ -306,9 +257,9 @@ var AsperaSdk = /** @class */ (function () {
306
257
  }
307
258
  Object.defineProperty(AsperaSdk.prototype, "isReady", {
308
259
  /**
309
- * Check if IBM Aspera is ready to be used and has been verified.
260
+ * Check if IBM Aspera for desktop is ready to be used and has been verified.
310
261
  *
311
- * @returns a boolean indicating if SDK can be used for requests
262
+ * @returns a boolean indicating if IBM Aspera for desktop can be used for requests
312
263
  */
313
264
  get: function () {
314
265
  return this.globals.asperaAppVerified && this.globals.appId !== '';
@@ -28,6 +28,14 @@ export interface FolderDialogOptions {
28
28
  /** Allow user to select multiple folders */
29
29
  multiple?: boolean;
30
30
  }
31
+ export interface SaveFileDialogOptions {
32
+ /** Filter the files displayed by file extension. */
33
+ allowedFileTypes?: any;
34
+ /** The filename to pre-fill the dialog with. */
35
+ suggestedName?: string;
36
+ /** The name of the dialog window. */
37
+ title?: string;
38
+ }
31
39
  /**
32
40
  * Options related to fetching the latest Aspera installer information.
33
41
  *
@@ -176,7 +184,23 @@ export interface DirectoryListFilters {
176
184
  /** Whether to include hidden files and directories in the results. */
177
185
  hidden?: boolean;
178
186
  }
187
+ /** Options for testing SSH port connectivity to a transfer server. */
188
+ export interface TestSshPortsOptions {
189
+ /** Domain name of the transfer server */
190
+ remote_host: string;
191
+ /** SSH port */
192
+ ssh_port?: number;
193
+ /** Timeout value in seconds */
194
+ timeout_sec?: number;
195
+ }
179
196
  /** Options for reading directory contents */
197
+ /** Valid page names for the preferences page. */
198
+ export type PreferencesPage = 'general' | 'transfers' | 'network' | 'bandwidth' | 'security';
199
+ /** Options for opening the preferences page to a specific tab. */
200
+ export interface ShowPreferencesPageOptions {
201
+ /** The preferences page (tab) to open. */
202
+ page: PreferencesPage;
203
+ }
180
204
  export interface ReadDirectoryOptions {
181
205
  /** Absolute path to the directory to enumerate. Must have been previously allowed via dialog selection or drag-drop. */
182
206
  path: string;
@@ -364,6 +388,15 @@ export interface TransferSpec {
364
388
  delete_source?: boolean;
365
389
  /** Directon of transfer, whether send (upload) or receive (download) */
366
390
  direction?: 'send' | 'receive';
391
+ /**
392
+ * The name of the ZIP file created when downloading more than one file.
393
+ * For example, `download_name: 'project_files'` results in `project_files.zip`.
394
+ *
395
+ * Only applicable when `zip_required` is `true` or downloading multiple files.
396
+ *
397
+ * This field is only used by HTTP Gateway and is ignored by other transfer clients.
398
+ */
399
+ download_name?: string;
367
400
  /**
368
401
  * Exclude files (but not directories) that are newer than a specific time from the transfer, based on when the file was last modified.
369
402
  * Express in ISO 8601 format (for exanple, 2006-01-02T15:04:05Z) or as number of seconds elapsed since 00:00:00 UTC on 1 January 1970.
@@ -550,8 +583,18 @@ export interface TransferSpec {
550
583
  token?: string;
551
584
  /** Use ascp4 as the transfer engine. */
552
585
  use_ascp4?: boolean;
586
+ /**
587
+ * **Required when downloading a folder via HTTP Gateway.** Set to `true` to have
588
+ * HTTP Gateway stream the folder contents back as a ZIP archive. Without this flag,
589
+ * HTTP Gateway cannot serve folder downloads.
590
+ *
591
+ * Use `download_name` to control the filename of the resulting ZIP (defaults to `download.zip`).
592
+ *
593
+ * This field is only used by HTTP Gateway and is ignored by other transfer clients.
594
+ */
595
+ zip_required?: boolean;
553
596
  }
554
- export type TransferStatus = 'failed' | 'completed' | 'running' | 'queued' | 'removed' | 'canceled' | 'orphaned' | 'paused';
597
+ export type TransferStatus = 'initiating' | 'failed' | 'completed' | 'running' | 'queued' | 'removed' | 'cancelled' | 'orphaned' | 'paused' | 'willretry';
555
598
  /** Pagination options for paginated API requests. */
556
599
  export interface Pagination {
557
600
  /** Maximum number of entries to return. (Default: 1000) */
@@ -664,6 +707,7 @@ export interface InstallerInfoResponse {
664
707
  export type WebsocketTopics = 'subscribe_transfer_activity' | 'transfer_activity';
665
708
  export type WebsocketEvent = 'CLOSED' | 'RECONNECT';
666
709
  export type SafariExtensionEvent = 'ENABLED' | 'DISABLED';
710
+ export type SdkStatus = 'INITIALIZING' | 'RETRYING' | 'RUNNING' | 'DEGRADED' | 'FAILED' | 'OUTDATED' | 'EXTENSION_INSTALL' | 'DISCONNECTED';
667
711
  export interface WebsocketMessage {
668
712
  jsonrpc: '2.0';
669
713
  method: WebsocketTopics;
@@ -861,6 +905,10 @@ export interface InitOptions {
861
905
  appId?: string;
862
906
  /** Indicate if the computer is running multiple users possibly (avoid port crossing). */
863
907
  supportMultipleUsers?: boolean;
908
+ /** Timeout in ms before status transitions to FAILED. Default: 5000. */
909
+ retryTimeout?: number;
910
+ /** Interval in ms between detection attempts. Default: 2000. */
911
+ retryInterval?: number;
864
912
  /** HTTP Gateway Settings */
865
913
  httpGatewaySettings?: {
866
914
  /** Aspera HTTP Gateway URL to use if desktop is not available. Include gateway route but not versions (example: https://example.com/aspera/http-gwy). */
@@ -938,6 +986,34 @@ export interface SdkCapabilities {
938
986
  * but not HTTP Gateway.
939
987
  */
940
988
  showTransferManager: boolean;
989
+ /**
990
+ * Whether the transfer client supports showing the transfer rate monitor.
991
+ *
992
+ * This is supported when using Connect or IBM Aspera for desktop with the required RPC methods,
993
+ * but not HTTP Gateway.
994
+ */
995
+ showTransferMonitor: boolean;
996
+ /**
997
+ * Whether the transfer client supports authenticating a transfer specification.
998
+ *
999
+ * This is supported when using Connect or IBM Aspera for desktop with the required RPC methods,
1000
+ * but not HTTP Gateway.
1001
+ */
1002
+ authenticate: boolean;
1003
+ /**
1004
+ * Whether the transfer client supports testing SSH port connectivity.
1005
+ *
1006
+ * This is supported when using Connect or IBM Aspera for desktop with the required RPC methods,
1007
+ * but not HTTP Gateway.
1008
+ */
1009
+ testSshPorts: boolean;
1010
+ /**
1011
+ * Whether the transfer client supports showing the save file dialog.
1012
+ *
1013
+ * This is supported when using Connect or IBM Aspera for desktop with the required RPC methods,
1014
+ * but not HTTP Gateway.
1015
+ */
1016
+ showSaveFileDialog: boolean;
941
1017
  /**
942
1018
  * Whether the SDK can read directory contents.
943
1019
  *