Skip to content

Commit 633c8a4

Browse files
committed
fix: HTTP initial setup structure
1 parent a8844af commit 633c8a4

File tree

6 files changed

+79
-0
lines changed

6 files changed

+79
-0
lines changed

src/constants/messages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ export const messages = {
2727
websocketClosedError: 'The websocket was closed due to an error',
2828
websocketClosedUnexpect: 'The websocket was closed unexpectedly',
2929
websocketNotReady: 'The websocket is not ready. Run init first',
30+
httpNotAvailable: 'IBM Aspera HTTP Gateway is not available',
3031
};

src/http-gateway/core.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* HTTP Gateway Core Logic
3+
* - File/Folder picking
4+
* - Starting and testing
5+
*
6+
* @remarks
7+
* Most logic is called directly by Desktop SDK functions
8+
* You may not need to import anything from this file.
9+
*/

src/http-gateway/download.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {AsperaSdkTransfer, TransferSpec} from '../models/models';
2+
import {asperaSdk} from '../index';
3+
import {throwError} from '../helpers/helpers';
4+
import {messages} from '../constants/messages';
5+
6+
/**
7+
* HTTP Gateway Download Logic
8+
*
9+
* @param transferSpec - TransferSpec for the download
10+
*
11+
* @returns Promise that resolves on success invoke or rejects if unable to start
12+
*
13+
* @remarks
14+
* Most logic is called directly by Desktop SDK functions
15+
* You may not need to import anything from this file.
16+
*/
17+
export const httpDownload = (transferSpec: TransferSpec): Promise<AsperaSdkTransfer> => {
18+
if (!asperaSdk.supportsHttpGateway) {
19+
return throwError(messages.serverNotVerified, {type: 'download'});
20+
}
21+
22+
return Promise.reject('TODO: HTTP Download Not Ready');
23+
};

src/http-gateway/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {httpDownload} from './download';
2+
import {httpUpload} from './upload';
3+
4+
/**
5+
* HTTP Gateway Exports
6+
*
7+
* @remarks
8+
* Most logic is called directly by Desktop SDK functions
9+
* You may not need to import anything from this file.
10+
*/
11+
12+
export {
13+
httpUpload,
14+
httpDownload,
15+
};

src/http-gateway/upload.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {AsperaSdkTransfer, TransferSpec} from '../models/models';
2+
import {asperaSdk} from '../index';
3+
import {throwError} from '../helpers/helpers';
4+
import {messages} from '../constants/messages';
5+
6+
/**
7+
* HTTP Gateway Upload Logic
8+
*
9+
* @param transferSpec - TransferSpec for the upload
10+
*
11+
* @returns Promise that resolves on success invoke or rejects if unable to start
12+
*
13+
* @remarks
14+
* Most logic is called directly by Desktop SDK functions
15+
* You may not need to import anything from this file.
16+
*/
17+
export const httpUpload = (transferSpec: TransferSpec): Promise<AsperaSdkTransfer> => {
18+
if (!asperaSdk.supportsHttpGateway) {
19+
return throwError(messages.serverNotVerified, {type: 'upload'});
20+
}
21+
22+
return Promise.reject('TODO: HTTP Upload Not Ready');
23+
};

src/models/aspera-sdk.model.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class AsperaSdkGlobals {
2525
sessionId?: string;
2626
/** Map of drop zones created by querySelector */
2727
dropZonesCreated: Map<string, {event: string; callback: (event: any) => void}[]> = new Map();
28+
/** HTTP Gateway URL after successful passing */
29+
httpGatewayUrl?: string;
30+
2831

2932
backupLaunchMethod(url: string): void {
3033
window.alert(messages.loadingProtocol);
@@ -396,4 +399,9 @@ export class AsperaSdk {
396399
get isReady(): boolean {
397400
return this.globals.asperaAppVerified && this.globals.appId !== '';
398401
}
402+
403+
/** Indicate that HTTP Gateway is available. */
404+
get supportsHttpGateway(): boolean {
405+
return !!this.globals.httpGatewayUrl;
406+
}
399407
}

0 commit comments

Comments
 (0)