@ibm-aspera/sdk 0.19.1 → 0.20.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.
- package/dist/commonjs/app/core.d.ts +27 -10
- package/dist/commonjs/app/core.js +124 -21
- package/dist/commonjs/app/status.d.ts +11 -1
- package/dist/commonjs/app/status.js +35 -4
- package/dist/commonjs/connect/core.js +3 -0
- package/dist/commonjs/helpers/connect-extension.d.ts +8 -0
- package/dist/commonjs/helpers/connect-extension.js +58 -0
- package/dist/commonjs/helpers/helpers.d.ts +6 -0
- package/dist/commonjs/helpers/helpers.js +19 -1
- package/dist/commonjs/helpers/ws.d.ts +11 -0
- package/dist/commonjs/helpers/ws.js +35 -2
- package/dist/commonjs/http-gateway/core.js +10 -12
- package/dist/commonjs/http-gateway/download.js +2 -2
- package/dist/commonjs/http-gateway/upload.js +2 -2
- package/dist/commonjs/http-gateway/v2/app/core.d.ts +84 -0
- package/dist/commonjs/http-gateway/v2/app/core.js +170 -0
- package/dist/commonjs/http-gateway/v2/app/download.d.ts +15 -0
- package/dist/commonjs/http-gateway/v2/app/download.js +68 -0
- package/dist/commonjs/http-gateway/v2/app/upload.d.ts +169 -0
- package/dist/commonjs/http-gateway/v2/app/upload.js +601 -0
- package/dist/commonjs/http-gateway/v2/constants/constants.d.ts +6 -0
- package/dist/commonjs/http-gateway/v2/constants/constants.js +9 -0
- package/dist/commonjs/http-gateway/v2/constants/messages.d.ts +35 -0
- package/dist/commonjs/http-gateway/v2/constants/messages.js +38 -0
- package/dist/commonjs/http-gateway/v2/helpers/helpers.d.ts +121 -0
- package/dist/commonjs/http-gateway/v2/helpers/helpers.js +294 -0
- package/dist/commonjs/http-gateway/v2/helpers/http.d.ts +86 -0
- package/dist/commonjs/http-gateway/v2/helpers/http.js +153 -0
- package/dist/commonjs/http-gateway/v2/index.d.ts +35 -0
- package/dist/commonjs/http-gateway/v2/index.js +70 -0
- package/dist/commonjs/http-gateway/v2/models/http-gateway-global.model.d.ts +254 -0
- package/dist/commonjs/http-gateway/v2/models/http-gateway-global.model.js +367 -0
- package/dist/commonjs/http-gateway/v2/models/models.d.ts +127 -0
- package/dist/commonjs/http-gateway/v2/models/models.js +87 -0
- package/dist/commonjs/index.d.ts +3 -3
- package/dist/commonjs/index.js +3 -1
- package/dist/commonjs/models/aspera-sdk.model.d.ts +2 -1
- package/dist/commonjs/models/aspera-sdk.model.js +8 -0
- package/dist/commonjs/models/models.d.ts +10 -1
- package/dist/js/aspera-sdk.js +1 -1
- package/dist/js/aspera-sdk.js.LICENSE.txt +1 -1
- package/dist/js/aspera-sdk.js.map +1 -1
- package/package.json +1 -2
|
@@ -4,7 +4,7 @@ exports.httpGatewayReadChunkAsArrayBuffer = exports.httpGatewayReadAsArrayBuffer
|
|
|
4
4
|
var messages_1 = require("../constants/messages");
|
|
5
5
|
var helpers_1 = require("../helpers/helpers");
|
|
6
6
|
var index_1 = require("../index");
|
|
7
|
-
var
|
|
7
|
+
var v2_1 = require("./v2");
|
|
8
8
|
// Maximum file size for generating image previews for files. 50MiB matches the limits in both Connect and IBM Aspera for desktop.
|
|
9
9
|
var MAX_FILE_SIZE = 50 * 1024 * 1024;
|
|
10
10
|
/**
|
|
@@ -45,17 +45,14 @@ var initHttpGateway = function (response) {
|
|
|
45
45
|
index_1.asperaSdk.globals.httpGatewayRoutePrefix = majorVersion >= 3 ? '/v3' : '';
|
|
46
46
|
if (index_1.asperaSdk.useOldHttpGateway) {
|
|
47
47
|
// Watch for old HTTP Gateway transfers in case used.
|
|
48
|
-
(0,
|
|
48
|
+
(0, v2_1.registerActivityCallback)(function (oldHttpTransfers) {
|
|
49
49
|
oldHttpTransfers.transfers.forEach(function (oldHttpTransfer) {
|
|
50
50
|
var transfer = oldHttpTransfer;
|
|
51
|
-
|
|
52
|
-
if (transfer.status === 'canceled') {
|
|
53
|
-
transfer.status = 'cancelled';
|
|
54
|
-
}
|
|
51
|
+
transfer.transfer_client = 'http-gateway';
|
|
55
52
|
(0, exports.sendTransferUpdate)(transfer);
|
|
56
53
|
});
|
|
57
54
|
});
|
|
58
|
-
return (0,
|
|
55
|
+
return (0, v2_1.initHttpGateway)(index_1.asperaSdk.globals.httpGatewayUrl).then(function () { });
|
|
59
56
|
}
|
|
60
57
|
var iframeContainer = document.createElement('div');
|
|
61
58
|
iframeContainer.id = 'aspera-http-gateway-iframes';
|
|
@@ -107,7 +104,7 @@ exports.setupHttpGateway = setupHttpGateway;
|
|
|
107
104
|
*/
|
|
108
105
|
var httpStopTransfer = function (id) {
|
|
109
106
|
if (index_1.asperaSdk.useOldHttpGateway) {
|
|
110
|
-
(0,
|
|
107
|
+
(0, v2_1.cancelTransfer)(id);
|
|
111
108
|
return Promise.resolve();
|
|
112
109
|
}
|
|
113
110
|
var transfer = index_1.asperaSdk.httpGatewayTransferStore.get(id);
|
|
@@ -135,7 +132,7 @@ exports.httpStopTransfer = httpStopTransfer;
|
|
|
135
132
|
*/
|
|
136
133
|
var httpRemoveTransfer = function (id) {
|
|
137
134
|
if (index_1.asperaSdk.useOldHttpGateway) {
|
|
138
|
-
(0,
|
|
135
|
+
(0, v2_1.removeTransfer)(id);
|
|
139
136
|
return Promise.resolve({ removed: true });
|
|
140
137
|
}
|
|
141
138
|
/* Cancel the transfer before removing it.
|
|
@@ -159,7 +156,7 @@ exports.httpRemoveTransfer = httpRemoveTransfer;
|
|
|
159
156
|
*/
|
|
160
157
|
var httpGetAllTransfers = function () {
|
|
161
158
|
if (index_1.asperaSdk.useOldHttpGateway) {
|
|
162
|
-
return (0,
|
|
159
|
+
return (0, v2_1.getAllTransfers)().transfers;
|
|
163
160
|
}
|
|
164
161
|
return Array.from(index_1.asperaSdk.httpGatewayTransferStore.values());
|
|
165
162
|
};
|
|
@@ -171,7 +168,7 @@ exports.httpGetAllTransfers = httpGetAllTransfers;
|
|
|
171
168
|
*/
|
|
172
169
|
var httpGetTransfer = function (id) {
|
|
173
170
|
if (index_1.asperaSdk.useOldHttpGateway) {
|
|
174
|
-
return (0,
|
|
171
|
+
return (0, v2_1.getTransferById)(id);
|
|
175
172
|
}
|
|
176
173
|
return index_1.asperaSdk.httpGatewayTransferStore.get(id);
|
|
177
174
|
};
|
|
@@ -251,7 +248,7 @@ exports.handleHttpGatewayDrop = handleHttpGatewayDrop;
|
|
|
251
248
|
*/
|
|
252
249
|
var httpGatewaySelectFileFolderDialog = function (options, folder) {
|
|
253
250
|
if (index_1.asperaSdk.useOldHttpGateway) {
|
|
254
|
-
return (folder ? (0,
|
|
251
|
+
return (folder ? (0, v2_1.getFoldersForUploadPromise)((options === null || options === void 0 ? void 0 : options.http_gateway_v2_transfer_id) || '') : (0, v2_1.getFilesForUploadPromise)((options === null || options === void 0 ? void 0 : options.http_gateway_v2_transfer_id) || ''));
|
|
255
252
|
}
|
|
256
253
|
var _a = (0, helpers_1.generatePromiseObjects)(), promise = _a.promise, rejecter = _a.rejecter, resolver = _a.resolver;
|
|
257
254
|
var element = (0, exports.createHtmlInputElement)();
|
|
@@ -315,6 +312,7 @@ var getSdkTransfer = function (transferSpec) {
|
|
|
315
312
|
percentage: 0,
|
|
316
313
|
title: '',
|
|
317
314
|
remaining_usec: 0,
|
|
315
|
+
transfer_client: 'http-gateway',
|
|
318
316
|
httpGatewayTransfer: true,
|
|
319
317
|
httpDownloadExternalHandle: false,
|
|
320
318
|
};
|
|
@@ -5,7 +5,7 @@ var index_1 = require("../index");
|
|
|
5
5
|
var helpers_1 = require("../helpers/helpers");
|
|
6
6
|
var messages_1 = require("../constants/messages");
|
|
7
7
|
var core_1 = require("./core");
|
|
8
|
-
var
|
|
8
|
+
var v2_1 = require("./v2");
|
|
9
9
|
/**
|
|
10
10
|
* HTTP Gateway Download Logic for presigned flow
|
|
11
11
|
* Presigned flow is when used files are too large or unknown file size
|
|
@@ -173,7 +173,7 @@ var httpDownload = function (transferSpec, asperaSdkSpec) {
|
|
|
173
173
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified, { type: 'download' });
|
|
174
174
|
}
|
|
175
175
|
if (index_1.asperaSdk.useOldHttpGateway) {
|
|
176
|
-
return (0,
|
|
176
|
+
return (0, v2_1.download)(transferSpec);
|
|
177
177
|
}
|
|
178
178
|
if (transferSpec.tags &&
|
|
179
179
|
transferSpec.tags.aspera &&
|
|
@@ -5,7 +5,7 @@ var index_1 = require("../index");
|
|
|
5
5
|
var helpers_1 = require("../helpers/helpers");
|
|
6
6
|
var messages_1 = require("../constants/messages");
|
|
7
7
|
var core_1 = require("./core");
|
|
8
|
-
var
|
|
8
|
+
var v2_1 = require("./v2");
|
|
9
9
|
/**
|
|
10
10
|
* HTTP Gateway Upload Logic
|
|
11
11
|
*
|
|
@@ -23,7 +23,7 @@ var httpUpload = function (transferSpec, asperaSdkSpec) {
|
|
|
23
23
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified, { type: 'upload' });
|
|
24
24
|
}
|
|
25
25
|
if (index_1.asperaSdk.useOldHttpGateway) {
|
|
26
|
-
return (0,
|
|
26
|
+
return (0, v2_1.upload)(transferSpec, (asperaSdkSpec === null || asperaSdkSpec === void 0 ? void 0 : asperaSdkSpec.http_gateway_v2_transfer_id) || '');
|
|
27
27
|
}
|
|
28
28
|
var promiseInfo = (0, helpers_1.generatePromiseObjects)();
|
|
29
29
|
var request = new XMLHttpRequest();
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { TransferResponse } from '../models/http-gateway-global.model';
|
|
2
|
+
import { HttpTransfer } from '../models/models';
|
|
3
|
+
/**
|
|
4
|
+
* Check if HTTP Gateway server connection works. This function is called by init
|
|
5
|
+
* when initializing the SDK. This function can be used at any point for sanity checking.
|
|
6
|
+
*
|
|
7
|
+
* @returns promise that resolves if server can connect or rejects if server unable to connect
|
|
8
|
+
*/
|
|
9
|
+
export declare const testHttpGatewayConnection: () => Promise<any>;
|
|
10
|
+
export declare const cleanupServerUrl: (serverUrl: string) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Initialize HTTP gateway client. If client cannot (reject/catch)
|
|
13
|
+
* client should attempt fixing server URL or trying again. If still fails disable UI elements.
|
|
14
|
+
* If supportMultipleServers is used the failure of the first test will not lock out the SDK.
|
|
15
|
+
*
|
|
16
|
+
* @param serverUrl URL indicating location of the HTTP server
|
|
17
|
+
* @param softwareMode indicate if the SDK should run in software mode instead of DOM mode
|
|
18
|
+
* @param supportMultipleServers indicates if the SDK should support multiple servers (not restricting to setup server)
|
|
19
|
+
*
|
|
20
|
+
* @returns a promise that resolves if HTTP Gateway is running properly or rejects if unable to load
|
|
21
|
+
*/
|
|
22
|
+
export declare const initHttpGateway: (serverUrl: string, softwareMode?: boolean, supportMultipleServers?: boolean) => Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Register a callback event for getting transfer data
|
|
25
|
+
*
|
|
26
|
+
* @param callback callback function to receive transfers
|
|
27
|
+
*
|
|
28
|
+
* @returns ID representing the callback for deregistration purposes
|
|
29
|
+
*/
|
|
30
|
+
export declare const registerActivityCallback: (callback: (transfers: TransferResponse) => void) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Remove a callback from the transfer callback
|
|
33
|
+
* @param id the ID returned by `registerActivityCallback`
|
|
34
|
+
*/
|
|
35
|
+
export declare const deregisterActivityCallback: (id: string) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the transfer requested based on the uuid of the transfer.
|
|
38
|
+
* NOTE: transferId from Node is not accepted as an ID. It must be the ID used by the HTTP Gateway.
|
|
39
|
+
*
|
|
40
|
+
* @param id gateway based ID of the HTTP part of the transfer
|
|
41
|
+
*
|
|
42
|
+
* @returns an object containing the transfer (or undefined if not found) located at key `transfer_info`
|
|
43
|
+
*/
|
|
44
|
+
export declare const getTransferById: (id: string) => {
|
|
45
|
+
transfer_info: HttpTransfer;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Get transfer response object including all transfers
|
|
49
|
+
*
|
|
50
|
+
* @returns transfer data object with transfers array
|
|
51
|
+
*/
|
|
52
|
+
export declare const getAllTransfers: () => TransferResponse;
|
|
53
|
+
/**
|
|
54
|
+
* Remove all transfers that are not active
|
|
55
|
+
*/
|
|
56
|
+
export declare const clearNonActiveTransfers: () => void;
|
|
57
|
+
/**
|
|
58
|
+
* Removes a transfer from the transfers list in HTTP Gateway
|
|
59
|
+
* If an active transfer is removed it will continue to be uploaded/downloaded but progress will not be tracked
|
|
60
|
+
*
|
|
61
|
+
* @param id HTTP Gateway transfer uuid
|
|
62
|
+
*/
|
|
63
|
+
export declare const removeTransfer: (id: string) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Cancel a transfer from the transfers list in HTTP Gateway
|
|
66
|
+
*
|
|
67
|
+
* @param id HTTP Gateway transfer uuid
|
|
68
|
+
*/
|
|
69
|
+
export declare const cancelTransfer: (id: string) => void;
|
|
70
|
+
declare const _default: {
|
|
71
|
+
initHttpGateway: (serverUrl: string, softwareMode?: boolean, supportMultipleServers?: boolean) => Promise<any>;
|
|
72
|
+
testHttpGatewayConnection: () => Promise<any>;
|
|
73
|
+
registerActivityCallback: (callback: (transfers: TransferResponse) => void) => string;
|
|
74
|
+
cleanupServerUrl: (serverUrl: string) => string;
|
|
75
|
+
deregisterActivityCallback: (id: string) => void;
|
|
76
|
+
getTransferById: (id: string) => {
|
|
77
|
+
transfer_info: HttpTransfer;
|
|
78
|
+
};
|
|
79
|
+
getAllTransfers: () => TransferResponse;
|
|
80
|
+
clearNonActiveTransfers: () => void;
|
|
81
|
+
removeTransfer: (id: string) => void;
|
|
82
|
+
cancelTransfer: (id: string) => void;
|
|
83
|
+
};
|
|
84
|
+
export default _default;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cancelTransfer = exports.removeTransfer = exports.clearNonActiveTransfers = exports.getAllTransfers = exports.getTransferById = exports.deregisterActivityCallback = exports.registerActivityCallback = exports.initHttpGateway = exports.cleanupServerUrl = exports.testHttpGatewayConnection = void 0;
|
|
4
|
+
var index_1 = require("../index");
|
|
5
|
+
var helpers_1 = require("../helpers/helpers");
|
|
6
|
+
var messages_1 = require("../constants/messages");
|
|
7
|
+
var http_1 = require("../helpers/http");
|
|
8
|
+
/**
|
|
9
|
+
* Check if HTTP Gateway server connection works. This function is called by init
|
|
10
|
+
* when initializing the SDK. This function can be used at any point for sanity checking.
|
|
11
|
+
*
|
|
12
|
+
* @returns promise that resolves if server can connect or rejects if server unable to connect
|
|
13
|
+
*/
|
|
14
|
+
var testHttpGatewayConnection = function () {
|
|
15
|
+
if (!index_1.asperaHttpGateway.globals.serverUrl && !index_1.asperaHttpGateway.globals.supportMultipleServers) {
|
|
16
|
+
(0, helpers_1.errorLog)(messages_1.messages.serverUrlNotSet);
|
|
17
|
+
return new Promise(function (resolve, reject) {
|
|
18
|
+
reject((0, helpers_1.generateErrorBody)(messages_1.messages.serverUrlNotSet));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
var promiseInfo = (0, helpers_1.generatePromiseObjects)();
|
|
22
|
+
var backupServerData = {
|
|
23
|
+
endpoints: [
|
|
24
|
+
'/aspera/http-gwy/v1/info',
|
|
25
|
+
'/aspera/http-gwy/v1/upload',
|
|
26
|
+
'/aspera/http-gwy/v2/upload',
|
|
27
|
+
'/aspera/http-gwy/v1/download'
|
|
28
|
+
],
|
|
29
|
+
name: 'IBM Aspera HTTP Gateway',
|
|
30
|
+
version: '2.3.0',
|
|
31
|
+
sdkVerificationFailed: true,
|
|
32
|
+
};
|
|
33
|
+
(0, http_1.apiGet)("".concat(index_1.asperaHttpGateway.globals.serverUrl || '', "/v1/info")).then(function (response) {
|
|
34
|
+
response.json().then(function (data) {
|
|
35
|
+
index_1.asperaHttpGateway.globals.serverInfo = data;
|
|
36
|
+
index_1.asperaHttpGateway.globals.serverVerified = true;
|
|
37
|
+
if (Number(index_1.asperaHttpGateway.globals.serverInfo.version.split('.')[0] || 0) >= 3) {
|
|
38
|
+
promiseInfo.rejecter((0, helpers_1.generateErrorBody)(messages_1.messages.versionNotsupported, data));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
console.warn(messages_1.messages.deprecationWarning);
|
|
42
|
+
promiseInfo.resolver(data);
|
|
43
|
+
});
|
|
44
|
+
}).catch(function (error) {
|
|
45
|
+
(0, helpers_1.errorLog)(messages_1.messages.serverError, error);
|
|
46
|
+
if (index_1.asperaHttpGateway.globals.supportMultipleServers) {
|
|
47
|
+
index_1.asperaHttpGateway.globals.serverInfo = backupServerData;
|
|
48
|
+
index_1.asperaHttpGateway.globals.serverVerified = true;
|
|
49
|
+
promiseInfo.resolver(backupServerData);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
index_1.asperaHttpGateway.globals.serverVerified = false;
|
|
53
|
+
promiseInfo.rejecter((0, helpers_1.generateErrorBody)(messages_1.messages.serverError, error));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return promiseInfo.promise;
|
|
57
|
+
};
|
|
58
|
+
exports.testHttpGatewayConnection = testHttpGatewayConnection;
|
|
59
|
+
var cleanupServerUrl = function (serverUrl) {
|
|
60
|
+
if (typeof serverUrl !== 'string') {
|
|
61
|
+
return '';
|
|
62
|
+
}
|
|
63
|
+
if (serverUrl[serverUrl.length - 1] === '/') {
|
|
64
|
+
serverUrl = serverUrl.slice(0, -1);
|
|
65
|
+
}
|
|
66
|
+
return serverUrl.replace('/v1', '/').replace(/\/$/, '').replace(/\/$/, '');
|
|
67
|
+
};
|
|
68
|
+
exports.cleanupServerUrl = cleanupServerUrl;
|
|
69
|
+
/**
|
|
70
|
+
* Initialize HTTP gateway client. If client cannot (reject/catch)
|
|
71
|
+
* client should attempt fixing server URL or trying again. If still fails disable UI elements.
|
|
72
|
+
* If supportMultipleServers is used the failure of the first test will not lock out the SDK.
|
|
73
|
+
*
|
|
74
|
+
* @param serverUrl URL indicating location of the HTTP server
|
|
75
|
+
* @param softwareMode indicate if the SDK should run in software mode instead of DOM mode
|
|
76
|
+
* @param supportMultipleServers indicates if the SDK should support multiple servers (not restricting to setup server)
|
|
77
|
+
*
|
|
78
|
+
* @returns a promise that resolves if HTTP Gateway is running properly or rejects if unable to load
|
|
79
|
+
*/
|
|
80
|
+
var initHttpGateway = function (serverUrl, softwareMode, supportMultipleServers) {
|
|
81
|
+
if (!(0, helpers_1.isValidUrl)(serverUrl)) {
|
|
82
|
+
return new Promise(function (resolve, reject) {
|
|
83
|
+
reject((0, helpers_1.generateErrorBody)(messages_1.messages.invalidServerUrl));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
index_1.asperaHttpGateway.globals.setUpServer((0, exports.cleanupServerUrl)(serverUrl), softwareMode, supportMultipleServers);
|
|
87
|
+
return (0, exports.testHttpGatewayConnection)();
|
|
88
|
+
};
|
|
89
|
+
exports.initHttpGateway = initHttpGateway;
|
|
90
|
+
/**
|
|
91
|
+
* Register a callback event for getting transfer data
|
|
92
|
+
*
|
|
93
|
+
* @param callback callback function to receive transfers
|
|
94
|
+
*
|
|
95
|
+
* @returns ID representing the callback for deregistration purposes
|
|
96
|
+
*/
|
|
97
|
+
var registerActivityCallback = function (callback) {
|
|
98
|
+
return index_1.asperaHttpGateway.activityTracking.setCallback(callback);
|
|
99
|
+
};
|
|
100
|
+
exports.registerActivityCallback = registerActivityCallback;
|
|
101
|
+
/**
|
|
102
|
+
* Remove a callback from the transfer callback
|
|
103
|
+
* @param id the ID returned by `registerActivityCallback`
|
|
104
|
+
*/
|
|
105
|
+
var deregisterActivityCallback = function (id) {
|
|
106
|
+
index_1.asperaHttpGateway.activityTracking.removeCallback(id);
|
|
107
|
+
};
|
|
108
|
+
exports.deregisterActivityCallback = deregisterActivityCallback;
|
|
109
|
+
/**
|
|
110
|
+
* Returns the transfer requested based on the uuid of the transfer.
|
|
111
|
+
* NOTE: transferId from Node is not accepted as an ID. It must be the ID used by the HTTP Gateway.
|
|
112
|
+
*
|
|
113
|
+
* @param id gateway based ID of the HTTP part of the transfer
|
|
114
|
+
*
|
|
115
|
+
* @returns an object containing the transfer (or undefined if not found) located at key `transfer_info`
|
|
116
|
+
*/
|
|
117
|
+
var getTransferById = function (id) {
|
|
118
|
+
return { transfer_info: index_1.asperaHttpGateway.activityTracking.getTransferById(id) };
|
|
119
|
+
};
|
|
120
|
+
exports.getTransferById = getTransferById;
|
|
121
|
+
/**
|
|
122
|
+
* Get transfer response object including all transfers
|
|
123
|
+
*
|
|
124
|
+
* @returns transfer data object with transfers array
|
|
125
|
+
*/
|
|
126
|
+
var getAllTransfers = function () {
|
|
127
|
+
return index_1.asperaHttpGateway.activityTracking.getAllTransfersResponse();
|
|
128
|
+
};
|
|
129
|
+
exports.getAllTransfers = getAllTransfers;
|
|
130
|
+
/**
|
|
131
|
+
* Remove all transfers that are not active
|
|
132
|
+
*/
|
|
133
|
+
var clearNonActiveTransfers = function () {
|
|
134
|
+
index_1.asperaHttpGateway.activityTracking.clearNonActiveTransfers();
|
|
135
|
+
};
|
|
136
|
+
exports.clearNonActiveTransfers = clearNonActiveTransfers;
|
|
137
|
+
/**
|
|
138
|
+
* Removes a transfer from the transfers list in HTTP Gateway
|
|
139
|
+
* If an active transfer is removed it will continue to be uploaded/downloaded but progress will not be tracked
|
|
140
|
+
*
|
|
141
|
+
* @param id HTTP Gateway transfer uuid
|
|
142
|
+
*/
|
|
143
|
+
var removeTransfer = function (id) {
|
|
144
|
+
index_1.asperaHttpGateway.activityTracking.removeTransfer(id);
|
|
145
|
+
};
|
|
146
|
+
exports.removeTransfer = removeTransfer;
|
|
147
|
+
/**
|
|
148
|
+
* Cancel a transfer from the transfers list in HTTP Gateway
|
|
149
|
+
*
|
|
150
|
+
* @param id HTTP Gateway transfer uuid
|
|
151
|
+
*/
|
|
152
|
+
var cancelTransfer = function (id) {
|
|
153
|
+
var transfer = index_1.asperaHttpGateway.activityTracking.getTransferById(id);
|
|
154
|
+
if (transfer) {
|
|
155
|
+
transfer.status = 'cancelled';
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
exports.cancelTransfer = cancelTransfer;
|
|
159
|
+
exports.default = {
|
|
160
|
+
initHttpGateway: exports.initHttpGateway,
|
|
161
|
+
testHttpGatewayConnection: exports.testHttpGatewayConnection,
|
|
162
|
+
registerActivityCallback: exports.registerActivityCallback,
|
|
163
|
+
cleanupServerUrl: exports.cleanupServerUrl,
|
|
164
|
+
deregisterActivityCallback: exports.deregisterActivityCallback,
|
|
165
|
+
getTransferById: exports.getTransferById,
|
|
166
|
+
getAllTransfers: exports.getAllTransfers,
|
|
167
|
+
clearNonActiveTransfers: exports.clearNonActiveTransfers,
|
|
168
|
+
removeTransfer: exports.removeTransfer,
|
|
169
|
+
cancelTransfer: exports.cancelTransfer
|
|
170
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DownloadOptions, TransferSpec } from '../models/models';
|
|
2
|
+
/**
|
|
3
|
+
* Start a HTTP Gateway download. Progress is not provided on downloads, browser handles download directly
|
|
4
|
+
* When in software mode the promise will return transfer_spec_id and the URL. The URL has not been used
|
|
5
|
+
* therefore a client can open it and start the download using software specific methods (like file reader).
|
|
6
|
+
*
|
|
7
|
+
* @param transferSpec standard Connect transferSpec for downloading
|
|
8
|
+
*
|
|
9
|
+
* @returns a promise that resolves if download is started successfully or rejects if error occurs
|
|
10
|
+
*/
|
|
11
|
+
export declare const download: (transferSpec: TransferSpec, options?: DownloadOptions) => Promise<any>;
|
|
12
|
+
declare const _default: {
|
|
13
|
+
download: (transferSpec: TransferSpec, options?: DownloadOptions) => Promise<any>;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.download = void 0;
|
|
4
|
+
var http_1 = require("../helpers/http");
|
|
5
|
+
var index_1 = require("../index");
|
|
6
|
+
var helpers_1 = require("../helpers/helpers");
|
|
7
|
+
var messages_1 = require("../constants/messages");
|
|
8
|
+
var core_1 = require("./core");
|
|
9
|
+
/**
|
|
10
|
+
* Start a HTTP Gateway download. Progress is not provided on downloads, browser handles download directly
|
|
11
|
+
* When in software mode the promise will return transfer_spec_id and the URL. The URL has not been used
|
|
12
|
+
* therefore a client can open it and start the download using software specific methods (like file reader).
|
|
13
|
+
*
|
|
14
|
+
* @param transferSpec standard Connect transferSpec for downloading
|
|
15
|
+
*
|
|
16
|
+
* @returns a promise that resolves if download is started successfully or rejects if error occurs
|
|
17
|
+
*/
|
|
18
|
+
var download = function (transferSpec, options) {
|
|
19
|
+
if (options === void 0) { options = {}; }
|
|
20
|
+
if (!index_1.asperaHttpGateway.isReady) {
|
|
21
|
+
(0, helpers_1.errorLog)(messages_1.messages.serverNotVerified);
|
|
22
|
+
return new Promise(function (resolve, reject) {
|
|
23
|
+
reject((0, helpers_1.generateErrorBody)(messages_1.messages.serverNotVerified));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (!(0, helpers_1.isValidTransferSpec)(transferSpec)) {
|
|
27
|
+
(0, helpers_1.errorLog)(messages_1.messages.notValidTransferSpec);
|
|
28
|
+
return new Promise(function (resolve, reject) {
|
|
29
|
+
reject((0, helpers_1.generateErrorBody)(messages_1.messages.notValidTransferSpec, { transferSpec: transferSpec }));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
var promiseInfo = (0, helpers_1.generatePromiseObjects)();
|
|
33
|
+
if (typeof options.zipRequire === 'boolean') {
|
|
34
|
+
transferSpec.zip_required = options.zipRequire;
|
|
35
|
+
}
|
|
36
|
+
var payload = {
|
|
37
|
+
transfer_spec: transferSpec
|
|
38
|
+
};
|
|
39
|
+
var finalServerUrl = options.serverUrlOverride ? (0, core_1.cleanupServerUrl)(options.serverUrlOverride) : index_1.asperaHttpGateway.globals.serverUrl;
|
|
40
|
+
(0, http_1.apiPost)("".concat(finalServerUrl, "/v1/download"), payload).then(function (response) {
|
|
41
|
+
response.json().then(function (data) {
|
|
42
|
+
if (data.transfer_spec_id) {
|
|
43
|
+
var downloadUrl = "".concat(finalServerUrl, "/v1/download/").concat(data.transfer_spec_id);
|
|
44
|
+
if (index_1.asperaHttpGateway.globals.softwareMode || (options === null || options === void 0 ? void 0 : options.disableAutoDownload)) {
|
|
45
|
+
promiseInfo.resolver({
|
|
46
|
+
transfer_spec_id: data.transfer_spec_id,
|
|
47
|
+
url: downloadUrl,
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
index_1.asperaHttpGateway.globals.triggerDownloadFromUrl(downloadUrl);
|
|
52
|
+
promiseInfo.resolver();
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
(0, helpers_1.errorLog)(messages_1.messages.failedToGetDownloadUrl, { response: data });
|
|
56
|
+
promiseInfo.rejecter((0, helpers_1.generateErrorBody)(messages_1.messages.failedToGetDownloadUrl, { response: data }));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}).catch(function (error) {
|
|
60
|
+
(0, helpers_1.errorLog)(messages_1.messages.downloadFailed, error);
|
|
61
|
+
promiseInfo.rejecter((0, helpers_1.generateErrorBody)(messages_1.messages.downloadFailed, error));
|
|
62
|
+
});
|
|
63
|
+
return promiseInfo.promise;
|
|
64
|
+
};
|
|
65
|
+
exports.download = download;
|
|
66
|
+
exports.default = {
|
|
67
|
+
download: exports.download
|
|
68
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { TransferSpec, DataTransferResponse, ConnectStyleFile, PromiseObject, TransferStatus, UploadOptions } from '../models/models';
|
|
2
|
+
/**
|
|
3
|
+
* Used to update the transfer in the activity monitor for a specific transfer. If transfer not found it is ignored
|
|
4
|
+
*
|
|
5
|
+
* @param id the id of the transfer to update
|
|
6
|
+
* @param status the status of the transfer
|
|
7
|
+
* @param total the total bytes of the transfer
|
|
8
|
+
* @param current the amount of bytes transferred thus far
|
|
9
|
+
* @param error error body
|
|
10
|
+
* @param currentFile the current file being transferred
|
|
11
|
+
*/
|
|
12
|
+
export declare const updateTransferActivity: (id: string, status: TransferStatus, total?: number, current?: number, error?: any, currentFile?: File) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Slice a file and read it in with FileReader. This uses the callback to send the read event.
|
|
15
|
+
* This function supports falling back to vendor prefix versions
|
|
16
|
+
* of the slice function for older Firefox and Webkit browsers.
|
|
17
|
+
*
|
|
18
|
+
* @param file the file to slice
|
|
19
|
+
* @param filePosition the start position of the file to slice
|
|
20
|
+
* @param chunksize the end position of the file to slice
|
|
21
|
+
* @param callback the callback to use for FileReader
|
|
22
|
+
* @param fileReader the FileReader to use for reading in data
|
|
23
|
+
*/
|
|
24
|
+
export declare const handleBlobSlicing: (file: File, filePosition: number, chunksize: number, callback: any, fileReader: FileReader) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Software mode version of `handleBlobSlicing` for dealing with Buffer instead of File API
|
|
27
|
+
*
|
|
28
|
+
* @param file the file to slice (data string is a FileSystem readFile in binary format)
|
|
29
|
+
* @param filePosition the start position of the file to slice
|
|
30
|
+
* @param chunksize the end position of the file to slice
|
|
31
|
+
* @param callback the callback to use for triggering event on slice
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```javascript
|
|
35
|
+
* const fileInfo = fs.statSync(filePointer);
|
|
36
|
+
* const file = {
|
|
37
|
+
* data: fs.readFileSync(filePointer, {encoding: 'binary'}),
|
|
38
|
+
* size: fileInfo.size,
|
|
39
|
+
* type: 'file',
|
|
40
|
+
* lastModified: fileInfo.mtime.toISOString(),
|
|
41
|
+
* name: filePointer,
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare const handleSoftwareModeSlicing: (file: {
|
|
46
|
+
name: string;
|
|
47
|
+
data: string;
|
|
48
|
+
type: string;
|
|
49
|
+
lastModified: string;
|
|
50
|
+
}, filePosition: number, chunksize: number, callback: any) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Start sending chunked data through the opened websocket
|
|
53
|
+
*
|
|
54
|
+
* @param socket the WebSocket to use for data transfer
|
|
55
|
+
* @param transferSpec the transferSpec to send for the upload
|
|
56
|
+
* @param id the ID of the transfer for monitoring
|
|
57
|
+
* @param queue the array of functions to call for sending data
|
|
58
|
+
* @param fileReaderToUse the file reader to use for this transfer
|
|
59
|
+
*/
|
|
60
|
+
export declare const startSendingData: (socket: WebSocket, transferSpec: TransferSpec, files: File[], id: string, queue: (() => void)[], fileReaderToUse: FileReader) => void;
|
|
61
|
+
/**
|
|
62
|
+
* Add file input to a form for getting files from the local computer
|
|
63
|
+
*
|
|
64
|
+
* @param form form to add new file input to
|
|
65
|
+
*/
|
|
66
|
+
export declare const addFilePickerToForm: (form: HTMLFormElement) => HTMLElement;
|
|
67
|
+
/**
|
|
68
|
+
* Add file input to a form with folder support for getting folders from the local computer
|
|
69
|
+
*
|
|
70
|
+
* NOTE: this cannot stop files from being picked.
|
|
71
|
+
*
|
|
72
|
+
* @param form form to add new file input to
|
|
73
|
+
*/
|
|
74
|
+
export declare const addFolderPickerToForm: (form: HTMLFormElement) => HTMLElement;
|
|
75
|
+
/**
|
|
76
|
+
* Request file picker for choosing files
|
|
77
|
+
*
|
|
78
|
+
* @param id the ID of the form to use (must be unique to each transfer grouping)
|
|
79
|
+
* @param callback the function to call once the files are added
|
|
80
|
+
*/
|
|
81
|
+
export declare const getFilesForUpload: (callback: (data: DataTransferResponse) => void, id: string) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Request file picker for choosing files and use promise.
|
|
84
|
+
* Uses `getFilesForUpload` logic wrapped in a Promise
|
|
85
|
+
*
|
|
86
|
+
* @param id the ID of the form to use (must be unique to each transfer grouping)
|
|
87
|
+
*
|
|
88
|
+
* @returns promise that resolves with the files (error state is never used)
|
|
89
|
+
*/
|
|
90
|
+
export declare const getFilesForUploadPromise: (id: string) => Promise<DataTransferResponse>;
|
|
91
|
+
/**
|
|
92
|
+
* Request folder picker for choosing folders
|
|
93
|
+
* @remarks Feature not supported. Will be introduced in future release.
|
|
94
|
+
*
|
|
95
|
+
* @param id the ID of the form to use (must be unique to each transfer grouping)
|
|
96
|
+
* @param callback the function to call once the folders are added
|
|
97
|
+
*/
|
|
98
|
+
export declare const getFoldersForUpload: (callback: (data: DataTransferResponse) => void, id: string) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Request folder picker for choosing folders and use promise.
|
|
101
|
+
* Uses `getFoldersForUpload` logic wrapped in a Promise
|
|
102
|
+
* @remarks Feature not supported. Will be introduced in future release.
|
|
103
|
+
*
|
|
104
|
+
* @param id the ID of the form to use (must be unique to each transfer grouping)
|
|
105
|
+
*
|
|
106
|
+
* @returns promise that resolves with the folders/file list (error state is never used)
|
|
107
|
+
*/
|
|
108
|
+
export declare const getFoldersForUploadPromise: (id: string) => Promise<DataTransferResponse>;
|
|
109
|
+
/**
|
|
110
|
+
* Start the Websockets and transfer
|
|
111
|
+
*
|
|
112
|
+
* @param id the ID to use for the transfer
|
|
113
|
+
* @param transferSpec the transferSpec of the transfer
|
|
114
|
+
* @param files the files to transfer
|
|
115
|
+
* @param promiseInfo the promise data to resolve for the transfer if needed
|
|
116
|
+
*/
|
|
117
|
+
export declare const startWebSocketTransfer: (id: string, transferSpec: TransferSpec, files: File[], promiseInfo?: PromiseObject, options?: UploadOptions) => void;
|
|
118
|
+
/**
|
|
119
|
+
* Start a HTTP Gateway upload.
|
|
120
|
+
*
|
|
121
|
+
* @param transferSpec standard Connect transferSpec for uploading
|
|
122
|
+
* @param id the ID of the form group to use for files
|
|
123
|
+
* @param memoryFilesToLoad array of files from memory to use. These will be used all the time and if transferSpec does not contain them an error will raise.
|
|
124
|
+
* @param options options for customizing the upload
|
|
125
|
+
*
|
|
126
|
+
* @returns a promise that resolves if upload is successful and rejects if upload cannot be started
|
|
127
|
+
*/
|
|
128
|
+
export declare const upload: (transferSpec: TransferSpec, id: string, memoryFilesToLoad?: File[], options?: UploadOptions) => Promise<any>;
|
|
129
|
+
/**
|
|
130
|
+
* Create a dropzone linked to a form grouping.
|
|
131
|
+
* All drops are stored in same place to allow body drops.
|
|
132
|
+
*
|
|
133
|
+
* @param callback the function to call once the files are dropped
|
|
134
|
+
* @param elementSelector the selector of the element on the page that should watch for drop events
|
|
135
|
+
*/
|
|
136
|
+
export declare const createDropzone: (callback: (data: {
|
|
137
|
+
event: any;
|
|
138
|
+
files: {
|
|
139
|
+
dataTransfer: {
|
|
140
|
+
files: ConnectStyleFile[];
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
}) => void, elementSelector: string) => void;
|
|
144
|
+
/**
|
|
145
|
+
* Remove dropzone added by gateway.
|
|
146
|
+
*
|
|
147
|
+
* @param elementSelector the selector of the element on the page that should remove
|
|
148
|
+
*/
|
|
149
|
+
export declare const removeDropzone: (elementSelector: string) => void;
|
|
150
|
+
declare const _default: {
|
|
151
|
+
upload: (transferSpec: TransferSpec, id: string, memoryFilesToLoad?: File[], options?: UploadOptions) => Promise<any>;
|
|
152
|
+
updateTransferActivity: (id: string, status: TransferStatus, total?: number, current?: number, error?: any, currentFile?: File) => void;
|
|
153
|
+
startSendingData: (socket: WebSocket, transferSpec: TransferSpec, files: File[], id: string, queue: (() => void)[], fileReaderToUse: FileReader) => void;
|
|
154
|
+
addFilePickerToForm: (form: HTMLFormElement) => HTMLElement;
|
|
155
|
+
createDropzone: (callback: (data: {
|
|
156
|
+
event: any;
|
|
157
|
+
files: {
|
|
158
|
+
dataTransfer: {
|
|
159
|
+
files: ConnectStyleFile[];
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
}) => void, elementSelector: string) => void;
|
|
163
|
+
removeDropzone: (elementSelector: string) => void;
|
|
164
|
+
getFilesForUploadPromise: (id: string) => Promise<DataTransferResponse>;
|
|
165
|
+
getFilesForUpload: (callback: (data: DataTransferResponse) => void, id: string) => void;
|
|
166
|
+
getFoldersForUploadPromise: (id: string) => Promise<DataTransferResponse>;
|
|
167
|
+
getFoldersForUpload: (callback: (data: DataTransferResponse) => void, id: string) => void;
|
|
168
|
+
};
|
|
169
|
+
export default _default;
|