@ibm-aspera/sdk 0.2.9 → 0.2.29
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/.editorconfig +13 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/CODE_OF_CONDUCT.md +128 -0
- package/.github/CONTRIBUTING.md +147 -0
- package/.github/dependabot.yml +10 -0
- package/.github/workflows/ci.yml +39 -0
- package/.github/workflows/documentation.yml +44 -0
- package/.github/workflows/publish.yml +23 -0
- package/.github/workflows/version.yml +32 -0
- package/CHANGELOG.md +204 -0
- package/docs/DEVELOPMENT.md +38 -0
- package/eslint.config.js +104 -0
- package/example/README.md +7 -0
- package/example/index.html +14 -0
- package/example/package-lock.json +2989 -0
- package/example/package.json +30 -0
- package/example/public/404.html +5 -0
- package/example/public/sdk-code.js +326 -0
- package/example/src/App/App.scss +40 -0
- package/example/src/App/index.tsx +196 -0
- package/example/src/Views/AllTogether.tsx +26 -0
- package/example/src/Views/DragDrop.tsx +23 -0
- package/example/src/Views/Home.tsx +10 -0
- package/example/src/Views/Initialize.tsx +31 -0
- package/example/src/Views/Installer.tsx +154 -0
- package/example/src/Views/MonitorTransfers.tsx +88 -0
- package/example/src/Views/Other.tsx +24 -0
- package/example/src/Views/SelectItems.tsx +46 -0
- package/example/src/Views/StartTransfer.tsx +37 -0
- package/example/src/Views/Test.tsx +20 -0
- package/example/src/Views/Views.scss +111 -0
- package/example/src/helpers/index.ts +19 -0
- package/example/src/index.scss +47 -0
- package/example/src/main.tsx +17 -0
- package/example/src/vite-env.d.ts +2 -0
- package/example/tsconfig.json +30 -0
- package/example/vite.config.ts +23 -0
- package/jest.config.js +19 -0
- package/jest.setup.js +0 -0
- package/package.json +15 -21
- package/renovate.json +12 -0
- package/scripts/version.sh +24 -0
- package/src/app/core.ts +765 -0
- package/src/app/installer.ts +53 -0
- package/src/connect/core.ts +83 -0
- package/src/constants/constants.ts +19 -0
- package/src/constants/messages.ts +35 -0
- package/src/helpers/client/client.ts +11 -0
- package/src/helpers/client/http-client.ts +92 -0
- package/src/helpers/client/safari-client.ts +334 -0
- package/src/helpers/helpers.ts +253 -0
- package/src/helpers/http.ts +39 -0
- package/src/helpers/ws.ts +191 -0
- package/src/http-gateway/core.ts +273 -0
- package/src/http-gateway/download.ts +217 -0
- package/src/http-gateway/index.ts +19 -0
- package/src/http-gateway/models.ts +20 -0
- package/src/http-gateway/upload.ts +148 -0
- package/src/index.ts +72 -0
- package/src/models/aspera-sdk.model.ts +446 -0
- package/src/models/models.ts +740 -0
- package/tests/client.spec.ts +52 -0
- package/tests/core.spec.ts +13 -0
- package/tests/helpers.spec.ts +127 -0
- package/tests/http.spec.ts +14 -0
- package/tests/installer.spec.ts +135 -0
- package/tests/mocks.ts +11 -0
- package/tsconfig.json +14 -0
- package/tsconfig.module.json +16 -0
- package/typedoc.js +7 -0
- package/webpack.config.js +35 -0
- package/dist/commonjs/app/core.d.ts +0 -205
- package/dist/commonjs/app/core.js +0 -615
- package/dist/commonjs/app/installer.d.ts +0 -9
- package/dist/commonjs/app/installer.js +0 -50
- package/dist/commonjs/constants/constants.d.ts +0 -8
- package/dist/commonjs/constants/constants.js +0 -11
- package/dist/commonjs/constants/messages.d.ts +0 -35
- package/dist/commonjs/constants/messages.js +0 -38
- package/dist/commonjs/helpers/client/client.d.ts +0 -5
- package/dist/commonjs/helpers/client/client.js +0 -7
- package/dist/commonjs/helpers/client/http-client.d.ts +0 -42
- package/dist/commonjs/helpers/client/http-client.js +0 -84
- package/dist/commonjs/helpers/client/safari-client.d.ts +0 -101
- package/dist/commonjs/helpers/client/safari-client.js +0 -264
- package/dist/commonjs/helpers/helpers.d.ts +0 -109
- package/dist/commonjs/helpers/helpers.js +0 -249
- package/dist/commonjs/helpers/http.d.ts +0 -16
- package/dist/commonjs/helpers/http.js +0 -42
- package/dist/commonjs/helpers/ws.d.ts +0 -62
- package/dist/commonjs/helpers/ws.js +0 -176
- package/dist/commonjs/http-gateway/core.d.ts +0 -76
- package/dist/commonjs/http-gateway/core.js +0 -254
- package/dist/commonjs/http-gateway/download.d.ts +0 -14
- package/dist/commonjs/http-gateway/download.js +0 -186
- package/dist/commonjs/http-gateway/index.d.ts +0 -11
- package/dist/commonjs/http-gateway/index.js +0 -11
- package/dist/commonjs/http-gateway/models.d.ts +0 -16
- package/dist/commonjs/http-gateway/models.js +0 -2
- package/dist/commonjs/http-gateway/upload.d.ts +0 -14
- package/dist/commonjs/http-gateway/upload.js +0 -124
- package/dist/commonjs/index.d.ts +0 -8
- package/dist/commonjs/index.js +0 -104
- package/dist/commonjs/models/aspera-sdk.model.d.ts +0 -244
- package/dist/commonjs/models/aspera-sdk.model.js +0 -324
- package/dist/commonjs/models/models.d.ts +0 -692
- package/dist/commonjs/models/models.js +0 -2
- package/dist/js/aspera-sdk.js +0 -3
- package/dist/js/aspera-sdk.js.LICENSE.txt +0 -15
- package/dist/js/aspera-sdk.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {mockFetch} from './mocks';
|
|
2
|
+
import {httpClient, getRpcServerUrl} from '../src/helpers/client/http-client';
|
|
3
|
+
|
|
4
|
+
let id = 0;
|
|
5
|
+
|
|
6
|
+
const getHeaders = () => {
|
|
7
|
+
return {
|
|
8
|
+
'content-type': 'application/json',
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const getMethod = () => {
|
|
13
|
+
return 'POST';
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const getBody = (method: string, params: any = {}) => {
|
|
17
|
+
return JSON.stringify({
|
|
18
|
+
jsonrpc: '2.0',
|
|
19
|
+
id,
|
|
20
|
+
method,
|
|
21
|
+
params,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const getExpectedRequest = (method: string, params: any = {}) => {
|
|
26
|
+
id++;
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
method: getMethod(),
|
|
30
|
+
headers: getHeaders(),
|
|
31
|
+
body: getBody(method, params),
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
describe('request', () => {
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
(<any>global).fetch = mockFetch({});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const fakeData = {data: 'testing'};
|
|
41
|
+
const rpcServerURL = getRpcServerUrl();
|
|
42
|
+
|
|
43
|
+
test('POST with no params should call url with no params', () => {
|
|
44
|
+
httpClient.request('fake');
|
|
45
|
+
expect(fetch).toHaveBeenCalledWith(rpcServerURL, getExpectedRequest('fake'));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('POST with params should call url with params', () => {
|
|
49
|
+
httpClient.request('fake', fakeData);
|
|
50
|
+
expect(fetch).toHaveBeenCalledWith(rpcServerURL, getExpectedRequest('fake', fakeData));
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {mockFetch} from './mocks';
|
|
2
|
+
import {init} from '../src';
|
|
3
|
+
|
|
4
|
+
describe('initHttpGateway', () => {
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
(<any>global).fetch = mockFetch({});
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('calls default URL', async () => {
|
|
10
|
+
init({appId: 'fake'}).catch(() => {});
|
|
11
|
+
// expect(fetch).toBeCalled();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {JSONRPCErrorException} from 'json-rpc-2.0';
|
|
2
|
+
import {
|
|
3
|
+
errorLog,
|
|
4
|
+
generateErrorBody,
|
|
5
|
+
generatePromiseObjects,
|
|
6
|
+
isValidTransferSpec,
|
|
7
|
+
isValidURL
|
|
8
|
+
} from '../src/helpers/helpers';
|
|
9
|
+
import {TransferSpec} from '../src/models/models';
|
|
10
|
+
|
|
11
|
+
describe('generatePromiseObjects', () => {
|
|
12
|
+
|
|
13
|
+
test('returns object containg promise, rejecter and resolver', () => {
|
|
14
|
+
const promiseItem = generatePromiseObjects();
|
|
15
|
+
expect(typeof promiseItem.promise.then).toBe('function');
|
|
16
|
+
expect(typeof promiseItem.resolver).toBe('function');
|
|
17
|
+
expect(typeof promiseItem.rejecter).toBe('function');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('errorLog', () => {
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
(<any>window).asperaSdkLogs = undefined;
|
|
25
|
+
jest.spyOn(global.console, 'warn');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('with message and no debug data should store in array and console', () => {
|
|
29
|
+
const consoleWarnCall = jest.fn();
|
|
30
|
+
console.warn = consoleWarnCall;
|
|
31
|
+
const testMessage = 'Test message';
|
|
32
|
+
expect((<any>window).asperaSdkLogs).toBe(undefined);
|
|
33
|
+
errorLog(testMessage);
|
|
34
|
+
expect(consoleWarnCall).toHaveBeenCalled();
|
|
35
|
+
expect((<any>window).asperaSdkLogs[0].message).toBe(testMessage);
|
|
36
|
+
expect((<any>window).asperaSdkLogs[0].debugData).toBe(undefined);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('with message and debug data should store in array and console', () => {
|
|
40
|
+
const consoleWarnCall = jest.fn();
|
|
41
|
+
console.warn = consoleWarnCall;
|
|
42
|
+
const testMessage = 'Test message';
|
|
43
|
+
expect((<any>window).asperaSdkLogs).toBe(undefined);
|
|
44
|
+
const error = {error: true};
|
|
45
|
+
errorLog(testMessage, {error: true});
|
|
46
|
+
expect(consoleWarnCall).toHaveBeenLastCalledWith('Aspera SDK: Test message', error);
|
|
47
|
+
expect((<any>window).asperaSdkLogs[0].message).toBe(testMessage);
|
|
48
|
+
expect((<any>window).asperaSdkLogs[0].debugData.error).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('generateErrorBody', () => {
|
|
53
|
+
|
|
54
|
+
test('should return error object without debugData if nothing is passed', () => {
|
|
55
|
+
const errorResponse = generateErrorBody('testing');
|
|
56
|
+
expect(errorResponse.message).toBe('testing');
|
|
57
|
+
expect(errorResponse.error).toBe(true);
|
|
58
|
+
expect(errorResponse.debugData).toBe(undefined);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('should return error object with debugData if data is passed', () => {
|
|
62
|
+
const errorTest = new JSONRPCErrorException('testing error body', -32002, {foo: 'bar'});
|
|
63
|
+
const errorResponse = generateErrorBody('testing', errorTest);
|
|
64
|
+
expect(errorResponse.message).toBe('testing');
|
|
65
|
+
expect(errorResponse.error).toBe(true);
|
|
66
|
+
expect(errorResponse.debugData.message).toBe('testing error body');
|
|
67
|
+
expect(errorResponse.debugData.code).toBe(-32002);
|
|
68
|
+
expect(errorResponse.debugData.data).toStrictEqual({foo: 'bar'});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('isValidTransferSpec', () => {
|
|
73
|
+
const transferSpec: TransferSpec = {
|
|
74
|
+
authentication: 'token',
|
|
75
|
+
paths: [
|
|
76
|
+
{
|
|
77
|
+
source: '/foo'
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
direction: 'receive',
|
|
81
|
+
remote_host: 'localhost'
|
|
82
|
+
};
|
|
83
|
+
const invalidTransferSpecs: any[] = [
|
|
84
|
+
null,
|
|
85
|
+
undefined,
|
|
86
|
+
'transfer',
|
|
87
|
+
85
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
test('should return true if valid transferSpec', () => {
|
|
91
|
+
expect(isValidTransferSpec(transferSpec)).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('should return false if invalid transferSpec', () => {
|
|
95
|
+
invalidTransferSpecs.forEach(element => {
|
|
96
|
+
expect(isValidTransferSpec(element)).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('isValidURL', () => {
|
|
102
|
+
const validUrls = [
|
|
103
|
+
'http://www.aspera.us',
|
|
104
|
+
'https://www.aspera.us',
|
|
105
|
+
'https://aspera.us',
|
|
106
|
+
'https://aspera.us/aspera/sdk/latest.json',
|
|
107
|
+
'https://aspera.us///aspera/sdk',
|
|
108
|
+
];
|
|
109
|
+
const invalidUrls = [
|
|
110
|
+
'aspera.us',
|
|
111
|
+
'/aspera/sdk',
|
|
112
|
+
'aspera',
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
test('should return true if valid url', () => {
|
|
116
|
+
validUrls.forEach(url => {
|
|
117
|
+
expect(isValidURL(url)).toBe(true);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('should return false if invalid url', () => {
|
|
122
|
+
invalidUrls.forEach(url => {
|
|
123
|
+
expect(isValidURL(url)).toBe(false);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {apiGet} from '../src/helpers/http';
|
|
2
|
+
import {mockFetch} from './mocks';
|
|
3
|
+
|
|
4
|
+
describe('apiGet', () => {
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
(<any>global).fetch = mockFetch({});
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('GET should call url', () => {
|
|
11
|
+
apiGet('aspera.us');
|
|
12
|
+
expect(fetch).toHaveBeenCalledWith('aspera.us', {headers: {'Content-Type': 'application/json'}});
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {getInstallerInfo} from '../src/app/installer';
|
|
2
|
+
import {installerUrl} from '../src/constants/constants';
|
|
3
|
+
import {mockFetch} from './mocks';
|
|
4
|
+
|
|
5
|
+
describe('getInstallerInfo', () => {
|
|
6
|
+
const defaultHeaders = {headers: {'Content-Type': 'application/json'}};
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
const response = {
|
|
10
|
+
entries: [
|
|
11
|
+
{
|
|
12
|
+
'version': '1.2.0',
|
|
13
|
+
'platform': 'macos',
|
|
14
|
+
'type': 'dmg',
|
|
15
|
+
'arch': 'universal',
|
|
16
|
+
'url': 'https://downloads.ibmaspera.com/downloads/desktop/macos/1.2.0/stable/universal/ibm-aspera-sdk_1.2.0_macos.dmg'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
'version': '1.2.0',
|
|
20
|
+
'platform': 'windows',
|
|
21
|
+
'type': 'msi',
|
|
22
|
+
'arch': 'x64',
|
|
23
|
+
'url': 'https://downloads.ibmaspera.com/downloads/desktop/windows/1.2.0/stable/x64/ibm-aspera-sdk_1.2.0.msi'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
'version': '1.1.9',
|
|
27
|
+
'platform': 'linux',
|
|
28
|
+
'type': 'rpm',
|
|
29
|
+
'arch': 'x64',
|
|
30
|
+
'url': 'https://downloads.ibmaspera.com/downloads/desktop/linux/1.1.9/stable/x64/ibm-aspera-sdk_1.1.9.rpm'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
'version': '1.1.9',
|
|
34
|
+
'platform': 'linux',
|
|
35
|
+
'type': 'appimage',
|
|
36
|
+
'arch': 'x64',
|
|
37
|
+
'url': 'https://downloads.ibmaspera.com/downloads/desktop/linux/1.1.9/stable/x64/ibm-aspera-sdk_1.1.9.AppImage'
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
};
|
|
41
|
+
(<any>global).fetch = mockFetch(response);
|
|
42
|
+
console.warn = jest.fn();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('called with no options fetches from downloads server by default', () => {
|
|
46
|
+
getInstallerInfo().catch(() => {});
|
|
47
|
+
expect(fetch).toHaveBeenCalledWith(`${installerUrl}/latest.json`, defaultHeaders);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('called with no options returns results for specific platform', async () => {
|
|
51
|
+
Object.defineProperty(window.navigator, 'userAgent', {value : 'Macintosh'});
|
|
52
|
+
const exp = [
|
|
53
|
+
{
|
|
54
|
+
'version': '1.2.0',
|
|
55
|
+
'platform': 'macos',
|
|
56
|
+
'type': 'dmg',
|
|
57
|
+
'arch': 'universal',
|
|
58
|
+
'url': 'https://downloads.ibmaspera.com/downloads/desktop/macos/1.2.0/stable/universal/ibm-aspera-sdk_1.2.0_macos.dmg'
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
const data = await getInstallerInfo();
|
|
62
|
+
expect(data.entries).toEqual(exp);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('called with all returns results for all platforms', async () => {
|
|
66
|
+
const data = await getInstallerInfo({all: true});
|
|
67
|
+
expect(data.entries.length).toBe(4);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('called with endpoint', () => {
|
|
71
|
+
getInstallerInfo({endpoint: 'https://aspera.us/aspera/sdk'}).catch(() => {});
|
|
72
|
+
expect(fetch).toHaveBeenCalledWith('https://aspera.us/aspera/sdk/latest.json', defaultHeaders);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('called with endpoint with trailing json file', () => {
|
|
76
|
+
getInstallerInfo({endpoint: 'https://aspera.us/aspera/sdk/latest.json'}).catch(() => {});
|
|
77
|
+
expect(fetch).toHaveBeenCalledWith('https://aspera.us/aspera/sdk/latest.json', defaultHeaders);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('called with endpoint returns URLs relative to endpoint', async () => {
|
|
81
|
+
const response = {
|
|
82
|
+
entries: [
|
|
83
|
+
{
|
|
84
|
+
'version': '1.2.0',
|
|
85
|
+
'platform': 'macos',
|
|
86
|
+
'type': 'dmg',
|
|
87
|
+
'arch': 'universal',
|
|
88
|
+
'url': 'downloads/ibm-aspera-sdk_1.2.0_macos.dmg'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
'version': '1.2.0',
|
|
92
|
+
'platform': 'windows',
|
|
93
|
+
'type': 'msi',
|
|
94
|
+
'arch': 'x64',
|
|
95
|
+
'url': 'downloads/ibm-aspera-sdk_1.2.0.msi'
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
'version': '1.1.9',
|
|
99
|
+
'platform': 'linux',
|
|
100
|
+
'type': 'rpm',
|
|
101
|
+
'arch': 'x64',
|
|
102
|
+
'url': 'downloads/ibm-aspera-sdk_1.1.9.rpm'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
'version': '1.1.9',
|
|
106
|
+
'platform': 'linux',
|
|
107
|
+
'type': 'appimage',
|
|
108
|
+
'arch': 'x64',
|
|
109
|
+
'url': 'downloads/ibm-aspera-sdk_1.1.9.AppImage'
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
};
|
|
113
|
+
(<any>global).fetch = mockFetch(response);
|
|
114
|
+
const data = await getInstallerInfo({endpoint: 'https://aspera.us/aspera/sdk', all: true});
|
|
115
|
+
for (const entry of data.entries) {
|
|
116
|
+
expect(entry.url.startsWith('https://aspera.us/aspera/sdk/downloads/ibm-aspera-sdk')).toBe(true);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('called with invalid endpoint rejects', () => {
|
|
121
|
+
const response = {
|
|
122
|
+
entries: [
|
|
123
|
+
{
|
|
124
|
+
'version': '1.2.0',
|
|
125
|
+
'platform': 'macos',
|
|
126
|
+
'type': 'dmg',
|
|
127
|
+
'arch': 'universal',
|
|
128
|
+
'url': 'downloads/ibm-aspera-sdk_1.2.0_macos.dmg'
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
};
|
|
132
|
+
(<any>global).fetch = mockFetch(response);
|
|
133
|
+
return expect(getInstallerInfo({endpoint: 'aspera.us'})).rejects.toMatchObject({error: true});
|
|
134
|
+
});
|
|
135
|
+
});
|
package/tests/mocks.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const mockFetch = (data: any) => {
|
|
2
|
+
const returnPromise = new Promise(resolver => {
|
|
3
|
+
resolver(data);
|
|
4
|
+
});
|
|
5
|
+
return jest.fn().mockImplementation(() => {
|
|
6
|
+
return Promise.resolve({
|
|
7
|
+
ok: true,
|
|
8
|
+
json:() => returnPromise.catch(() => {}),
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["es2017", "es7", "es6", "dom"],
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"outDir": "dist/commonjs",
|
|
8
|
+
"esModuleInterop": true
|
|
9
|
+
},
|
|
10
|
+
"exclude": [
|
|
11
|
+
"node_modules",
|
|
12
|
+
"example",
|
|
13
|
+
"dist",
|
|
14
|
+
"tests"
|
|
15
|
+
]
|
|
16
|
+
}
|
package/typedoc.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const webpack = require('webpack');
|
|
3
|
+
|
|
4
|
+
const packageFile = require('./package.json');
|
|
5
|
+
let version = '';
|
|
6
|
+
|
|
7
|
+
if (packageFile.version) {
|
|
8
|
+
version = `v${packageFile.version}`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const banner = `IBM Aspera SDK ${version}\nLicensed Materials – Property of IBM\n© Copyright IBM Corp. 2024, 2025\nU.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by\nGSA ADP Schedule Contract with IBM Corp.`;
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
entry: './src/index.ts',
|
|
15
|
+
devtool: 'source-map',
|
|
16
|
+
output: {
|
|
17
|
+
path: path.resolve(__dirname, 'dist/js'),
|
|
18
|
+
filename: 'aspera-sdk.js'
|
|
19
|
+
},
|
|
20
|
+
resolve: {
|
|
21
|
+
extensions: ['.tsx', '.ts', '.js', '.json']
|
|
22
|
+
},
|
|
23
|
+
module: {
|
|
24
|
+
rules: [
|
|
25
|
+
{
|
|
26
|
+
test: /\.tsx?$/,
|
|
27
|
+
use: ['ts-loader'],
|
|
28
|
+
exclude: /node_modules/
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
plugins: [
|
|
33
|
+
new webpack.BannerPlugin(banner)
|
|
34
|
+
]
|
|
35
|
+
};
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { AsperaSdkInfo, TransferResponse } from '../models/aspera-sdk.model';
|
|
2
|
-
import { CustomBrandingOptions, DataTransferResponse, AsperaSdkSpec, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, InitOptions, ModifyTransferOptions, ResumeTransferOptions, TransferSpec, WebsocketEvent } from '../models/models';
|
|
3
|
-
/**
|
|
4
|
-
* Check if IBM Aspera for Desktop connection works. This function is called by init
|
|
5
|
-
* when initializing the SDK. This function can be used at any point for checking.
|
|
6
|
-
*
|
|
7
|
-
* @returns a promise that resolves if server can connect or rejects if not
|
|
8
|
-
*/
|
|
9
|
-
export declare const testConnection: () => Promise<any>;
|
|
10
|
-
/**
|
|
11
|
-
* Initialize drag and drop. HTTP Gateway does not need to init.
|
|
12
|
-
* Ignore if only HTTP Gateway
|
|
13
|
-
* @param initCall - Indicate if called via init flow and should not reject
|
|
14
|
-
*
|
|
15
|
-
* @returns a promise that resolves if the initialization was successful or not
|
|
16
|
-
*/
|
|
17
|
-
export declare const initDragDrop: (initCall?: boolean) => Promise<boolean>;
|
|
18
|
-
/**
|
|
19
|
-
* Initialize IBM Aspera client. If client cannot (reject/catch), then
|
|
20
|
-
* client should attempt fixing server URL or trying again. If still fails disable UI elements.
|
|
21
|
-
*
|
|
22
|
-
* @param options initialization options:
|
|
23
|
-
*
|
|
24
|
-
* - `appId` the unique ID for the website. Transfers initiated during this session
|
|
25
|
-
* will be associated with this ID. It is recommended to use a unique ID to keep transfer
|
|
26
|
-
* information private from other websites.
|
|
27
|
-
*
|
|
28
|
-
* - `supportMultipleUsers` when enabled (defaults to false), the SDK will iterate over a port
|
|
29
|
-
* range and generate a session id to determine the running instance of the desktop app for the
|
|
30
|
-
* current user. This is needed when multiple users may be logged into the same machine
|
|
31
|
-
* simultaneously, for example on a Windows Server.
|
|
32
|
-
*
|
|
33
|
-
* @returns a promise that resolves if IBM Aspera Desktop is running properly or
|
|
34
|
-
* rejects if unable to connect
|
|
35
|
-
*/
|
|
36
|
-
export declare const init: (options?: InitOptions) => Promise<any>;
|
|
37
|
-
/**
|
|
38
|
-
* Start a transfer
|
|
39
|
-
*
|
|
40
|
-
* @param transferSpec standard transferSpec for transfer
|
|
41
|
-
* @param asperaSdkSpec IBM Aspera settings when starting a transfer.
|
|
42
|
-
*
|
|
43
|
-
* @returns a promise that resolves if transfer initiation is successful and rejects if transfer cannot be started
|
|
44
|
-
*/
|
|
45
|
-
export declare const startTransfer: (transferSpec: TransferSpec, asperaSdkSpec: AsperaSdkSpec) => Promise<AsperaSdkTransfer>;
|
|
46
|
-
/**
|
|
47
|
-
* Register a callback event for getting transfer updates
|
|
48
|
-
*
|
|
49
|
-
* @param callback callback function to receive transfers
|
|
50
|
-
*
|
|
51
|
-
* @returns ID representing the callback for deregistration purposes
|
|
52
|
-
*/
|
|
53
|
-
export declare const registerActivityCallback: (callback: (transfers: TransferResponse) => void) => string;
|
|
54
|
-
/**
|
|
55
|
-
* Remove a callback from the transfer callback
|
|
56
|
-
*
|
|
57
|
-
* @param id the ID returned by `registerActivityCallback`
|
|
58
|
-
*/
|
|
59
|
-
export declare const deregisterActivityCallback: (id: string) => void;
|
|
60
|
-
/**
|
|
61
|
-
* Register a callback event for when a user removes or cancels a transfer
|
|
62
|
-
* directly from IBM Aspera. This may also be called if IBM Aspera
|
|
63
|
-
* is configured to automatically remove completed transfers.
|
|
64
|
-
*
|
|
65
|
-
* @param callback callback function to receive transfers
|
|
66
|
-
*
|
|
67
|
-
* @returns ID representing the callback for deregistration purposes
|
|
68
|
-
*/
|
|
69
|
-
export declare const registerRemovedCallback: (callback: (transfer: AsperaSdkTransfer) => void) => string;
|
|
70
|
-
/**
|
|
71
|
-
* Remove a callback from the removed transfer callback
|
|
72
|
-
*
|
|
73
|
-
* @param id the ID returned by `registerRemovedCallback`
|
|
74
|
-
*/
|
|
75
|
-
export declare const deregisterRemovedCallback: (id: string) => void;
|
|
76
|
-
/**
|
|
77
|
-
* Register a callback for getting updates about the connection status of IBM Aspera SDK.
|
|
78
|
-
*
|
|
79
|
-
* For example, to be notified of when the SDK loses connection with the application or connection
|
|
80
|
-
* is re-established. This can be useful if you want to handle the case where the user quits IBM Aspera
|
|
81
|
-
* after `init` has already been called, and want to prompt the user to relaunch the application.
|
|
82
|
-
*
|
|
83
|
-
* @param callback callback function to receive events
|
|
84
|
-
*
|
|
85
|
-
* @returns ID representing the callback for deregistration purposes
|
|
86
|
-
*/
|
|
87
|
-
export declare const registerStatusCallback: (callback: (status: WebsocketEvent) => void) => string;
|
|
88
|
-
/**
|
|
89
|
-
* Remove a callback from getting connection status events.
|
|
90
|
-
*
|
|
91
|
-
* @param id the ID returned by `registerStatusCallback`
|
|
92
|
-
*/
|
|
93
|
-
export declare const deregisterStatusCallback: (id: string) => void;
|
|
94
|
-
/**
|
|
95
|
-
* Remove a transfer. This will stop the transfer if it is in progress.
|
|
96
|
-
*
|
|
97
|
-
* @param id transfer uuid
|
|
98
|
-
*
|
|
99
|
-
* @returns a promise that resolves if transfer is removed and rejects if transfer cannot be removed
|
|
100
|
-
*/
|
|
101
|
-
export declare const removeTransfer: (id: string) => Promise<any>;
|
|
102
|
-
/**
|
|
103
|
-
* Stop a transfer.
|
|
104
|
-
*
|
|
105
|
-
* @param id transfer uuid
|
|
106
|
-
*
|
|
107
|
-
* @returns a promise that resolves if transfer is stopped and rejects if transfer cannot be stopped
|
|
108
|
-
*/
|
|
109
|
-
export declare const stopTransfer: (id: string) => Promise<any>;
|
|
110
|
-
/**
|
|
111
|
-
* Resume a paused or failed transfer.
|
|
112
|
-
*
|
|
113
|
-
* @param id transfer uuid
|
|
114
|
-
* @param options resume transfer options
|
|
115
|
-
*
|
|
116
|
-
* @returns a promise that resolves with the new transfer object if transfer is resumed
|
|
117
|
-
*/
|
|
118
|
-
export declare const resumeTransfer: (id: string, options?: ResumeTransferOptions) => Promise<AsperaSdkTransfer>;
|
|
119
|
-
/**
|
|
120
|
-
* Displays a file browser dialog for the user to select files.
|
|
121
|
-
*
|
|
122
|
-
* @param options file dialog options
|
|
123
|
-
*
|
|
124
|
-
* @returns a promise that resolves with the selected file(s) and rejects if user cancels dialog
|
|
125
|
-
*/
|
|
126
|
-
export declare const showSelectFileDialog: (options?: FileDialogOptions) => Promise<DataTransferResponse>;
|
|
127
|
-
/**
|
|
128
|
-
* Displays a folder browser dialog for the user to select folders.
|
|
129
|
-
*
|
|
130
|
-
* @param options folder dialog options
|
|
131
|
-
*
|
|
132
|
-
* @returns a promise that resolves with the selected folder(s) and rejects if user cancels dialog
|
|
133
|
-
*/
|
|
134
|
-
export declare const showSelectFolderDialog: (options?: FolderDialogOptions) => Promise<DataTransferResponse>;
|
|
135
|
-
/**
|
|
136
|
-
* Opens the IBM Aspera preferences page.
|
|
137
|
-
*
|
|
138
|
-
* @returns a promise that resolves when the preferences page is opened.
|
|
139
|
-
*/
|
|
140
|
-
export declare const showPreferences: () => Promise<any>;
|
|
141
|
-
/**
|
|
142
|
-
* Get all transfers associated with the current application.
|
|
143
|
-
*
|
|
144
|
-
* @returns a promise that resolves with an array of transfers.
|
|
145
|
-
*/
|
|
146
|
-
export declare const getAllTransfers: () => Promise<AsperaSdkTransfer[]>;
|
|
147
|
-
/**
|
|
148
|
-
* Get a specific transfer by ID.
|
|
149
|
-
*
|
|
150
|
-
* @param id transfer uuid
|
|
151
|
-
*
|
|
152
|
-
* @returns a promise that resolves with the transfer.
|
|
153
|
-
*/
|
|
154
|
-
export declare const getTransfer: (id: string) => Promise<AsperaSdkTransfer>;
|
|
155
|
-
/**
|
|
156
|
-
* Opens and highlights the downloaded file in Finder or Windows Explorer. If multiple files,
|
|
157
|
-
* then only the first file will be selected.
|
|
158
|
-
*
|
|
159
|
-
* @param id transfer uuid
|
|
160
|
-
*
|
|
161
|
-
* @returns a promise that resolves if the file can be shown and rejects if not
|
|
162
|
-
*/
|
|
163
|
-
export declare const showDirectory: (id: string) => Promise<any>;
|
|
164
|
-
/**
|
|
165
|
-
* Modify the speed of a running transfer.
|
|
166
|
-
*
|
|
167
|
-
* @param id transfer uuid
|
|
168
|
-
* @param options transfer rate options
|
|
169
|
-
*
|
|
170
|
-
* @returns a promise that resolves if the transfer rate can be modified and rejects if not
|
|
171
|
-
*/
|
|
172
|
-
export declare const modifyTransfer: (id: string, options: ModifyTransferOptions) => Promise<AsperaSdkTransfer>;
|
|
173
|
-
/**
|
|
174
|
-
* Set the custom branding template to be used by IBM Aspera. If the app is already
|
|
175
|
-
* configured to use a different branding, then the branding template you specify will be
|
|
176
|
-
* stored by the app, allowing the end user to switch at any point.
|
|
177
|
-
*
|
|
178
|
-
* @param id custom branding template id. This should be consistent across page loads.
|
|
179
|
-
* @param options custom branding options
|
|
180
|
-
*
|
|
181
|
-
* @returns a promise that resolves if the branding was properly set.
|
|
182
|
-
*/
|
|
183
|
-
export declare const setBranding: (id: string, options: CustomBrandingOptions) => Promise<any>;
|
|
184
|
-
/**
|
|
185
|
-
* Create a dropzone for the given element selector.
|
|
186
|
-
*
|
|
187
|
-
* @param callback the function to call once the files are dropped
|
|
188
|
-
* @param elementSelector the selector of the element on the page that should watch for drop events
|
|
189
|
-
*/
|
|
190
|
-
export declare const createDropzone: (callback: (data: {
|
|
191
|
-
event: DragEvent;
|
|
192
|
-
files: DataTransferResponse;
|
|
193
|
-
}) => void, elementSelector: string) => void;
|
|
194
|
-
/**
|
|
195
|
-
* Remove dropzone.
|
|
196
|
-
*
|
|
197
|
-
* @param elementSelector the selector of the element on the page that should remove
|
|
198
|
-
*/
|
|
199
|
-
export declare const removeDropzone: (elementSelector: string) => void;
|
|
200
|
-
/**
|
|
201
|
-
* Get metadata about the IBM Aspera installation.
|
|
202
|
-
*
|
|
203
|
-
* @returns a promise that returns information about the user's IBM Aspera installation.
|
|
204
|
-
*/
|
|
205
|
-
export declare const getInfo: () => Promise<AsperaSdkInfo>;
|