Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ export const messages = {
websocketClosedError: 'The websocket was closed due to an error',
websocketClosedUnexpect: 'The websocket was closed unexpectedly',
websocketNotReady: 'The websocket is not ready. Run init first',
httpNotAvailable: 'IBM Aspera HTTP Gateway is not available',
};
9 changes: 9 additions & 0 deletions src/http-gateway/core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* HTTP Gateway Core Logic
* - File/Folder picking
* - Starting and testing
*
* @remarks
* Most logic is called directly by Desktop SDK functions
* You may not need to import anything from this file.
*/
23 changes: 23 additions & 0 deletions src/http-gateway/download.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {AsperaSdkTransfer, TransferSpec} from '../models/models';
import {asperaSdk} from '../index';
import {throwError} from '../helpers/helpers';
import {messages} from '../constants/messages';

/**
* HTTP Gateway Download Logic
*
* @param transferSpec - TransferSpec for the download
*
* @returns Promise that resolves on success invoke or rejects if unable to start
*
* @remarks
* Most logic is called directly by Desktop SDK functions
* You may not need to import anything from this file.
*/
export const httpDownload = (transferSpec: TransferSpec): Promise<AsperaSdkTransfer> => {
if (!asperaSdk.supportsHttpGateway) {
return throwError(messages.serverNotVerified, {type: 'download'});
}

return Promise.reject('TODO: HTTP Download Not Ready');
};
15 changes: 15 additions & 0 deletions src/http-gateway/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {httpDownload} from './download';
import {httpUpload} from './upload';

/**
* HTTP Gateway Exports
*
* @remarks
* Most logic is called directly by Desktop SDK functions
* You may not need to import anything from this file.
*/

export {
httpUpload,
httpDownload,
};
23 changes: 23 additions & 0 deletions src/http-gateway/upload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {AsperaSdkTransfer, TransferSpec} from '../models/models';
import {asperaSdk} from '../index';
import {throwError} from '../helpers/helpers';
import {messages} from '../constants/messages';

/**
* HTTP Gateway Upload Logic
*
* @param transferSpec - TransferSpec for the upload
*
* @returns Promise that resolves on success invoke or rejects if unable to start
*
* @remarks
* Most logic is called directly by Desktop SDK functions
* You may not need to import anything from this file.
*/
export const httpUpload = (transferSpec: TransferSpec): Promise<AsperaSdkTransfer> => {
if (!asperaSdk.supportsHttpGateway) {
return throwError(messages.serverNotVerified, {type: 'upload'});
}

return Promise.reject('TODO: HTTP Upload Not Ready');
};
8 changes: 8 additions & 0 deletions src/models/aspera-sdk.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class AsperaSdkGlobals {
sessionId?: string;
/** Map of drop zones created by querySelector */
dropZonesCreated: Map<string, {event: string; callback: (event: any) => void}[]> = new Map();
/** HTTP Gateway URL after successful passing */
httpGatewayUrl?: string;


backupLaunchMethod(url: string): void {
window.alert(messages.loadingProtocol);
Expand Down Expand Up @@ -396,4 +399,9 @@ export class AsperaSdk {
get isReady(): boolean {
return this.globals.asperaAppVerified && this.globals.appId !== '';
}

/** Indicate that HTTP Gateway is available. */
get supportsHttpGateway(): boolean {
return !!this.globals.httpGatewayUrl;
}
}