@ibm-aspera/sdk 0.2.29 → 0.4.12
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.
- package/README.md +17 -13
- package/dist/commonjs/app/core.d.ts +234 -0
- package/dist/commonjs/app/core.js +812 -0
- package/dist/commonjs/app/installer.d.ts +9 -0
- package/dist/commonjs/app/installer.js +50 -0
- package/dist/commonjs/connect/core.d.ts +11 -0
- package/dist/commonjs/connect/core.js +73 -0
- package/dist/commonjs/constants/constants.d.ts +8 -0
- package/dist/commonjs/constants/constants.js +11 -0
- package/dist/commonjs/constants/messages.d.ts +38 -0
- package/dist/commonjs/constants/messages.js +41 -0
- package/dist/commonjs/helpers/client/client.d.ts +5 -0
- package/dist/commonjs/helpers/client/client.js +7 -0
- package/dist/commonjs/helpers/client/http-client.d.ts +42 -0
- package/dist/commonjs/helpers/client/http-client.js +84 -0
- package/dist/commonjs/helpers/client/safari-client.d.ts +101 -0
- package/dist/commonjs/helpers/client/safari-client.js +264 -0
- package/dist/commonjs/helpers/helpers.d.ts +109 -0
- package/dist/commonjs/helpers/helpers.js +249 -0
- package/dist/commonjs/helpers/http.d.ts +16 -0
- package/dist/commonjs/helpers/http.js +42 -0
- package/dist/commonjs/helpers/ws.d.ts +62 -0
- package/dist/commonjs/helpers/ws.js +161 -0
- package/dist/commonjs/http-gateway/core.d.ts +98 -0
- package/dist/commonjs/http-gateway/core.js +388 -0
- package/dist/commonjs/http-gateway/download.d.ts +14 -0
- package/dist/commonjs/http-gateway/download.js +187 -0
- package/dist/commonjs/http-gateway/index.d.ts +11 -0
- package/dist/commonjs/http-gateway/index.js +11 -0
- package/dist/commonjs/http-gateway/models.d.ts +16 -0
- package/dist/commonjs/http-gateway/models.js +2 -0
- package/dist/commonjs/http-gateway/upload.d.ts +14 -0
- package/dist/commonjs/http-gateway/upload.js +124 -0
- package/dist/commonjs/index.d.ts +12 -0
- package/dist/commonjs/index.js +109 -0
- package/dist/commonjs/models/aspera-sdk.model.d.ts +259 -0
- package/dist/commonjs/models/aspera-sdk.model.js +349 -0
- package/dist/commonjs/models/models.d.ts +760 -0
- package/dist/commonjs/models/models.js +2 -0
- package/dist/js/aspera-sdk.js +3 -0
- package/dist/js/aspera-sdk.js.LICENSE.txt +15 -0
- package/dist/js/aspera-sdk.js.map +1 -0
- package/package.json +8 -5
- package/.editorconfig +0 -13
- package/.github/CODEOWNERS +0 -1
- package/.github/CODE_OF_CONDUCT.md +0 -128
- package/.github/CONTRIBUTING.md +0 -147
- package/.github/dependabot.yml +0 -10
- package/.github/workflows/ci.yml +0 -39
- package/.github/workflows/documentation.yml +0 -44
- package/.github/workflows/publish.yml +0 -23
- package/.github/workflows/version.yml +0 -32
- package/.whitesource +0 -3
- package/CHANGELOG.md +0 -204
- package/docs/DEVELOPMENT.md +0 -38
- package/eslint.config.js +0 -104
- package/example/README.md +0 -7
- package/example/index.html +0 -14
- package/example/package-lock.json +0 -2989
- package/example/package.json +0 -30
- package/example/public/404.html +0 -5
- package/example/public/sdk-code.js +0 -326
- package/example/src/App/App.scss +0 -40
- package/example/src/App/index.tsx +0 -196
- package/example/src/Views/AllTogether.tsx +0 -26
- package/example/src/Views/DragDrop.tsx +0 -23
- package/example/src/Views/Home.tsx +0 -10
- package/example/src/Views/Initialize.tsx +0 -31
- package/example/src/Views/Installer.tsx +0 -154
- package/example/src/Views/MonitorTransfers.tsx +0 -88
- package/example/src/Views/Other.tsx +0 -24
- package/example/src/Views/SelectItems.tsx +0 -46
- package/example/src/Views/StartTransfer.tsx +0 -37
- package/example/src/Views/Test.tsx +0 -20
- package/example/src/Views/Views.scss +0 -111
- package/example/src/helpers/index.ts +0 -19
- package/example/src/index.scss +0 -47
- package/example/src/main.tsx +0 -17
- package/example/src/vite-env.d.ts +0 -2
- package/example/tsconfig.json +0 -30
- package/example/vite.config.ts +0 -23
- package/jest.config.js +0 -19
- package/jest.setup.js +0 -0
- package/renovate.json +0 -12
- package/src/app/core.ts +0 -765
- package/src/app/installer.ts +0 -53
- package/src/connect/core.ts +0 -83
- package/src/constants/constants.ts +0 -19
- package/src/constants/messages.ts +0 -35
- package/src/helpers/client/client.ts +0 -11
- package/src/helpers/client/http-client.ts +0 -92
- package/src/helpers/client/safari-client.ts +0 -334
- package/src/helpers/helpers.ts +0 -253
- package/src/helpers/http.ts +0 -39
- package/src/helpers/ws.ts +0 -191
- package/src/http-gateway/core.ts +0 -273
- package/src/http-gateway/download.ts +0 -217
- package/src/http-gateway/index.ts +0 -19
- package/src/http-gateway/models.ts +0 -20
- package/src/http-gateway/upload.ts +0 -148
- package/src/index.ts +0 -72
- package/src/models/aspera-sdk.model.ts +0 -446
- package/src/models/models.ts +0 -740
- package/tests/client.spec.ts +0 -52
- package/tests/core.spec.ts +0 -13
- package/tests/helpers.spec.ts +0 -127
- package/tests/http.spec.ts +0 -14
- package/tests/installer.spec.ts +0 -135
- package/tests/mocks.ts +0 -11
- package/tsconfig.json +0 -14
- package/tsconfig.module.json +0 -16
- package/typedoc.js +0 -7
- package/webpack.config.js +0 -35
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { WebsocketTopics } from '../models/models';
|
|
2
|
+
export declare class WebsocketService {
|
|
3
|
+
/** The main websocket connection to Aspera App*/
|
|
4
|
+
private globalSocket;
|
|
5
|
+
/** A map of requested subscription names and the callback for them */
|
|
6
|
+
private sockets;
|
|
7
|
+
/** The callback for websocket events */
|
|
8
|
+
private eventListener;
|
|
9
|
+
/** Indicator if the websocket is already connected */
|
|
10
|
+
private isConnected;
|
|
11
|
+
/** Global promise object that resolves when init completes */
|
|
12
|
+
private initPromise;
|
|
13
|
+
/** Log call for not being ready */
|
|
14
|
+
private handleNotReady;
|
|
15
|
+
/**
|
|
16
|
+
* This function handles when a connection is opened
|
|
17
|
+
*/
|
|
18
|
+
private handleOpen;
|
|
19
|
+
/**
|
|
20
|
+
* This function handles completed subscription
|
|
21
|
+
*/
|
|
22
|
+
private handleClose;
|
|
23
|
+
/**
|
|
24
|
+
* This function handles errors received from the websocket
|
|
25
|
+
*/
|
|
26
|
+
private handleError;
|
|
27
|
+
/**
|
|
28
|
+
* This function handles messages received from the websocket
|
|
29
|
+
*/
|
|
30
|
+
private handleMessage;
|
|
31
|
+
/**
|
|
32
|
+
* This function joins the channel to be able to subscribe to events
|
|
33
|
+
*/
|
|
34
|
+
private joinChannel;
|
|
35
|
+
/**
|
|
36
|
+
* This function registers clients to listen to a certain message name. Returns any to allow functions to declare proper type
|
|
37
|
+
*
|
|
38
|
+
* @param messageName - the name of messages to listen to (one message name per subscription)
|
|
39
|
+
* @param callback - the callback function
|
|
40
|
+
*/
|
|
41
|
+
registerMessage(messageName: WebsocketTopics, callback: Function): void;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param callback This function registers clients to a certain WebSocket event.
|
|
45
|
+
*
|
|
46
|
+
* @param callback - the callback function to call with the event name.
|
|
47
|
+
*/
|
|
48
|
+
registerEvent(callback: Function): void;
|
|
49
|
+
/**
|
|
50
|
+
* This function starts the websocket subscription with the websocket provider
|
|
51
|
+
*
|
|
52
|
+
* @returns a promise that resolves when the websocket connection is established
|
|
53
|
+
*/
|
|
54
|
+
init(): Promise<unknown>;
|
|
55
|
+
private connect;
|
|
56
|
+
private reconnect;
|
|
57
|
+
private getWebSocketConnection;
|
|
58
|
+
private notifyEvent;
|
|
59
|
+
private updateRpcPort;
|
|
60
|
+
}
|
|
61
|
+
export declare const websocketService: WebsocketService;
|
|
62
|
+
export default WebsocketService;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.websocketService = exports.WebsocketService = void 0;
|
|
4
|
+
var helpers_1 = require("./helpers");
|
|
5
|
+
var messages_1 = require("../constants/messages");
|
|
6
|
+
var index_1 = require("../index");
|
|
7
|
+
var WebsocketService = /** @class */ (function () {
|
|
8
|
+
function WebsocketService() {
|
|
9
|
+
var _this = this;
|
|
10
|
+
/** A map of requested subscription names and the callback for them */
|
|
11
|
+
this.sockets = new Map();
|
|
12
|
+
/** Indicator if the websocket is already connected */
|
|
13
|
+
this.isConnected = false;
|
|
14
|
+
/** Global promise object that resolves when init completes */
|
|
15
|
+
this.initPromise = (0, helpers_1.generatePromiseObjects)();
|
|
16
|
+
/**
|
|
17
|
+
* This function handles when a connection is opened
|
|
18
|
+
*/
|
|
19
|
+
this.handleOpen = function () {
|
|
20
|
+
if (_this.isConnected || !_this.joinChannel()) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
_this.isConnected = true;
|
|
24
|
+
_this.updateRpcPort();
|
|
25
|
+
_this.notifyEvent('RECONNECT');
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* This function handles completed subscription
|
|
29
|
+
*/
|
|
30
|
+
this.handleClose = function () {
|
|
31
|
+
if (_this.isConnected) {
|
|
32
|
+
_this.isConnected = false;
|
|
33
|
+
_this.notifyEvent('CLOSED');
|
|
34
|
+
}
|
|
35
|
+
if (!_this.globalSocket) {
|
|
36
|
+
_this.handleNotReady();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
_this.reconnect();
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* This function handles errors received from the websocket
|
|
43
|
+
*/
|
|
44
|
+
this.handleError = function () {
|
|
45
|
+
(0, helpers_1.errorLog)(messages_1.messages.websocketClosedError);
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* This function handles messages received from the websocket
|
|
49
|
+
*/
|
|
50
|
+
this.handleMessage = function (message) {
|
|
51
|
+
var data = (0, helpers_1.safeJsonParse)(message.data);
|
|
52
|
+
// Message we get on subscription
|
|
53
|
+
if (data && data.id === 1) {
|
|
54
|
+
_this.initPromise.resolver(data);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
var socket = _this.sockets.get(data.method);
|
|
58
|
+
if (typeof socket === 'function' && data.params) {
|
|
59
|
+
socket(data.params);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Log call for not being ready */
|
|
64
|
+
WebsocketService.prototype.handleNotReady = function () {
|
|
65
|
+
(0, helpers_1.errorLog)(messages_1.messages.websocketNotReady);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* This function joins the channel to be able to subscribe to events
|
|
69
|
+
*/
|
|
70
|
+
WebsocketService.prototype.joinChannel = function () {
|
|
71
|
+
if (!this.globalSocket) {
|
|
72
|
+
this.handleNotReady();
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
this.globalSocket.send((0, helpers_1.safeJsonString)({ jsonrpc: '2.0', method: 'subscribe_transfer_activity', params: [index_1.asperaSdk.globals.appId], id: 1 }));
|
|
76
|
+
return true;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* This function registers clients to listen to a certain message name. Returns any to allow functions to declare proper type
|
|
80
|
+
*
|
|
81
|
+
* @param messageName - the name of messages to listen to (one message name per subscription)
|
|
82
|
+
* @param callback - the callback function
|
|
83
|
+
*/
|
|
84
|
+
WebsocketService.prototype.registerMessage = function (messageName, callback) {
|
|
85
|
+
if (!this.sockets.get(messageName)) {
|
|
86
|
+
this.sockets.set(messageName, function (data) {
|
|
87
|
+
callback(data.result);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @param callback This function registers clients to a certain WebSocket event.
|
|
94
|
+
*
|
|
95
|
+
* @param callback - the callback function to call with the event name.
|
|
96
|
+
*/
|
|
97
|
+
WebsocketService.prototype.registerEvent = function (callback) {
|
|
98
|
+
this.eventListener = callback;
|
|
99
|
+
this.eventListener(this.isConnected ? 'RECONNECT' : 'CLOSED');
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* This function starts the websocket subscription with the websocket provider
|
|
103
|
+
*
|
|
104
|
+
* @returns a promise that resolves when the websocket connection is established
|
|
105
|
+
*/
|
|
106
|
+
WebsocketService.prototype.init = function () {
|
|
107
|
+
this.connect();
|
|
108
|
+
return this.initPromise.promise;
|
|
109
|
+
};
|
|
110
|
+
WebsocketService.prototype.connect = function () {
|
|
111
|
+
var _this = this;
|
|
112
|
+
this.getWebSocketConnection(index_1.asperaSdk.globals.rpcPort)
|
|
113
|
+
.then(function (webSocket) {
|
|
114
|
+
_this.globalSocket = webSocket;
|
|
115
|
+
_this.globalSocket.onerror = _this.handleError;
|
|
116
|
+
_this.globalSocket.onclose = _this.handleClose;
|
|
117
|
+
_this.globalSocket.onopen = _this.handleOpen;
|
|
118
|
+
_this.globalSocket.onmessage = _this.handleMessage;
|
|
119
|
+
_this.handleOpen();
|
|
120
|
+
}).catch(function () {
|
|
121
|
+
_this.reconnect();
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
WebsocketService.prototype.reconnect = function () {
|
|
125
|
+
var _this = this;
|
|
126
|
+
if (this.globalSocket) {
|
|
127
|
+
this.globalSocket.close();
|
|
128
|
+
}
|
|
129
|
+
setTimeout(function () {
|
|
130
|
+
_this.connect();
|
|
131
|
+
}, 1000);
|
|
132
|
+
};
|
|
133
|
+
WebsocketService.prototype.getWebSocketConnection = function (port) {
|
|
134
|
+
var webSocketUrl = (0, helpers_1.getWebsocketUrl)(index_1.asperaSdk.globals.asperaAppUrl);
|
|
135
|
+
return new Promise(function (resolve, reject) {
|
|
136
|
+
var webSocket = new WebSocket("".concat(webSocketUrl, ":").concat(port));
|
|
137
|
+
webSocket.onopen = function () {
|
|
138
|
+
resolve(webSocket);
|
|
139
|
+
};
|
|
140
|
+
webSocket.onerror = function () {
|
|
141
|
+
reject("Connection failed on port ".concat(port));
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
WebsocketService.prototype.notifyEvent = function (event) {
|
|
146
|
+
if (typeof this.eventListener === 'function') {
|
|
147
|
+
this.eventListener(event);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
WebsocketService.prototype.updateRpcPort = function () {
|
|
151
|
+
if (!this.globalSocket) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
var url = new URL(this.globalSocket.url);
|
|
155
|
+
index_1.asperaSdk.globals.rpcPort = Number(url.port);
|
|
156
|
+
};
|
|
157
|
+
return WebsocketService;
|
|
158
|
+
}());
|
|
159
|
+
exports.WebsocketService = WebsocketService;
|
|
160
|
+
exports.websocketService = new WebsocketService();
|
|
161
|
+
exports.default = WebsocketService;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { FileDialogOptions, DataTransferResponse, TransferSpec, AsperaSdkTransfer, ReadAsArrayBufferResponse, ReadChunkAsArrayBufferResponse } from '../models/models';
|
|
2
|
+
/**
|
|
3
|
+
* HTTP Gateway Core Logic
|
|
4
|
+
* - File/Folder picking
|
|
5
|
+
* - Starting and testing
|
|
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
|
+
* Remove a transfer from HTTP Gateway systems
|
|
13
|
+
* @param id - ID of the transfer
|
|
14
|
+
*
|
|
15
|
+
* @returns Promise indicating success
|
|
16
|
+
*/
|
|
17
|
+
export declare const httpRemoveTransfer: (id: string) => Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* Get the list of http gateway transfers
|
|
20
|
+
*
|
|
21
|
+
* @returns list of HTTP Gateway
|
|
22
|
+
*/
|
|
23
|
+
export declare const httpGetAllTransfers: () => AsperaSdkTransfer[];
|
|
24
|
+
/**
|
|
25
|
+
* Get a HTTP Gateway transfer by ID
|
|
26
|
+
*
|
|
27
|
+
* @returns a transfer or null
|
|
28
|
+
*/
|
|
29
|
+
export declare const httpGetTransfer: (id: string) => AsperaSdkTransfer | null;
|
|
30
|
+
/**
|
|
31
|
+
* Create HTML input element for file picking
|
|
32
|
+
*/
|
|
33
|
+
export declare const createHtmlInputElement: () => HTMLInputElement;
|
|
34
|
+
/**
|
|
35
|
+
* Handle drop events and store files for HTTP Gateway
|
|
36
|
+
* This works on top of desktop.
|
|
37
|
+
*/
|
|
38
|
+
export declare const handleHttpGatewayDrop: (items: DataTransferItemList, callback: (data: {
|
|
39
|
+
event: DragEvent;
|
|
40
|
+
files: DataTransferResponse;
|
|
41
|
+
}) => void, event: DragEvent) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Open native browser file or folder picker for files
|
|
44
|
+
*
|
|
45
|
+
* @param options - File picker options
|
|
46
|
+
* @param folder - Indicate if choosing folders
|
|
47
|
+
*
|
|
48
|
+
* @returns Promise that resolves with info about the files picked
|
|
49
|
+
*/
|
|
50
|
+
export declare const httpGatewaySelectFileFolderDialog: (options?: FileDialogOptions, folder?: boolean) => Promise<DataTransferResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Get a generic transfer object for HTTP Gateway transfers.
|
|
53
|
+
*
|
|
54
|
+
* @param transferSpec - TransferSpec being provided for the HTTP Gateway transfer
|
|
55
|
+
*
|
|
56
|
+
* @returns a transfer object to track status and send to consumers
|
|
57
|
+
*/
|
|
58
|
+
export declare const getSdkTransfer: (transferSpec: TransferSpec) => AsperaSdkTransfer;
|
|
59
|
+
/**
|
|
60
|
+
* Send a transfer update through the SDK
|
|
61
|
+
*
|
|
62
|
+
* @param transfer - Transsfer object to send to consumers
|
|
63
|
+
*/
|
|
64
|
+
export declare const sendTransferUpdate: (transfer: AsperaSdkTransfer) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Try to parse and get a useful string from API calls for HTTP Gateway
|
|
67
|
+
*
|
|
68
|
+
* @param error - Error from API call for Gateway
|
|
69
|
+
*
|
|
70
|
+
* @returns a string to use for errors
|
|
71
|
+
*/
|
|
72
|
+
export declare const getMessageFromError: (error: any) => {
|
|
73
|
+
message: string;
|
|
74
|
+
code: number;
|
|
75
|
+
};
|
|
76
|
+
export declare const base64Encoding: (jsonString: string) => string;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the specified file's contents as a base64-encoded string.
|
|
79
|
+
*
|
|
80
|
+
* Note: The maximum file size allowed is 50 MiB.
|
|
81
|
+
*
|
|
82
|
+
* @param path path to the file to read
|
|
83
|
+
*
|
|
84
|
+
* @returns a promise that resolves with the file data as a base64-encoded string and mime type
|
|
85
|
+
*/
|
|
86
|
+
export declare const httpGatewayReadAsArrayBuffer: (path: string) => Promise<ReadAsArrayBufferResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Read a chunk of a file as a base64-encoded string.
|
|
89
|
+
*
|
|
90
|
+
* Note: The maximum chunk size allowed is 50 MiB.
|
|
91
|
+
*
|
|
92
|
+
* @param path path to the file to read. For pure JS this will just be the filename.
|
|
93
|
+
* @param offset offset to start reading the file, in bytes
|
|
94
|
+
* @param chunkSize the size of the chunk to read, in bytes
|
|
95
|
+
*
|
|
96
|
+
* @returns a promise that resolves with the file chunk data as a base64-encoded string and mime type
|
|
97
|
+
*/
|
|
98
|
+
export declare const httpGatewayReadChunkAsArrayBuffer: (path: string, offset: number, chunkSize: number) => Promise<ReadChunkAsArrayBufferResponse>;
|