@js4cytoscape/ndex-client 0.6.0-alpha.1 → 0.6.0-alpha.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@js4cytoscape/ndex-client",
3
- "version": "0.6.0-alpha.1",
3
+ "version": "0.6.0-alpha.3",
4
4
  "description": "NDEx client library - Modern TypeScript implementation",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,8 @@
12
12
  "homepage": "https://github.com/cytoscape/js4cytoscape",
13
13
  "main": "./dist/index.js",
14
14
  "module": "./dist/index.mjs",
15
- "umd": "./dist/index.umd.js",
15
+ "unpkg": "./dist/index.global.js",
16
+ "jsdelivr": "./dist/index.global.js",
16
17
  "types": "./dist/index.d.ts",
17
18
  "exports": {
18
19
  ".": {
@@ -23,7 +24,6 @@
23
24
  },
24
25
  "files": [
25
26
  "dist",
26
- "src",
27
27
  "README.md",
28
28
  "LICENSE"
29
29
  ],
@@ -32,16 +32,23 @@
32
32
  "build": "tsup",
33
33
  "build:docs": "typedoc",
34
34
  "docs:api": "npm run build:docs",
35
- "docs:site": "cd docs-site && npm install && npm run build",
36
- "docs:serve": "cd docs-site && npm run start",
35
+ "docs:site": "cd docs-root/guide && npm install && npm run build",
36
+ "docs:serve": "cd docs-root/guide && npm run start",
37
37
  "docs:build": "npm run docs:api && npm run docs:site",
38
- "docs:clean": "rimraf docs docs-site/build docs-site/docs/api",
38
+ "docs:clean": "rimraf docs-root/api docs-root/guide/build",
39
39
  "test": "npm run test:unit",
40
40
  "test:unit": "jest --config jest.unit.config.js",
41
- "test:integration": "jest --config jest.integration.config.js",
41
+ "test:integration": "npm run test:integration:all",
42
+ "test:integration:node": "jest --config jest.integration.node.config.js",
43
+ "test:integration:browser": "jest --config jest.integration.browser.config.js",
44
+ "test:integration:all": "npm run test:integration:node && npm run test:integration:browser",
45
+ "test:integration:parallel": "jest --config jest.integration.node.config.js & jest --config jest.integration.browser.config.js",
42
46
  "test:all": "npm run test:unit && npm run test:integration",
43
47
  "test:watch": "npm run test:unit -- --watch",
48
+ "test:watch:integration:node": "npm run test:integration:node -- --watch",
49
+ "test:watch:integration:browser": "npm run test:integration:browser -- --watch",
44
50
  "test:coverage": "npm run test:unit -- --coverage",
51
+ "test:coverage:integration": "npm run test:integration:node -- --coverage && npm run test:integration:browser -- --coverage",
45
52
  "test:ci": "npm run test:all -- --coverage",
46
53
  "debug:integration": "node --inspect-brk ./node_modules/.bin/jest --config jest.integration.config.js --runInBand --no-cache",
47
54
  "debug:unit": "node --inspect-brk ./node_modules/.bin/jest --config jest.unit.config.js --runInBand --no-cache",
@@ -57,7 +64,7 @@
57
64
  "author": "Jing Chen",
58
65
  "license": "MIT",
59
66
  "engines": {
60
- "node": ">=16.0.0"
67
+ "node": ">=18"
61
68
  },
62
69
  "keywords": [
63
70
  "ndex",
@@ -69,7 +76,8 @@
69
76
  "typescript"
70
77
  ],
71
78
  "dependencies": {
72
- "axios": "^1.11.0"
79
+ "axios": "^1.11.0",
80
+ "form-data": "^4.0.4"
73
81
  },
74
82
  "devDependencies": {
75
83
  "@changesets/cli": "^2.27.1",
@@ -88,8 +96,9 @@
88
96
  "rimraf": "^5.0.5",
89
97
  "ts-jest": "^29.1.2",
90
98
  "tsup": "^8.0.2",
91
- "typedoc": "^0.25.12",
92
- "typedoc-plugin-markdown": "^3.17.1",
99
+ "typedoc": "^0.28.12",
100
+ "typedoc-material-theme": "^1.4.0",
101
+ "typedoc-plugin-markdown": "^4.8.1",
93
102
  "typescript": "^5.4.2"
94
103
  },
95
104
  "peerDependencies": {
package/src/CyNDEx.js DELETED
@@ -1,178 +0,0 @@
1
- const CY_REST_BASE_URL = 'http://127.0.0.1';
2
-
3
- import { default as axios } from 'axios';
4
-
5
- class CyNDEx {
6
-
7
- constructor(port = 1234) {
8
- this._port = port;
9
- }
10
- get port() { return this._port; }
11
-
12
- static get cyRestBaseURL() {
13
- return CY_REST_BASE_URL;
14
- }
15
-
16
- setNDExServer(ndexServer) {
17
- if (ndexServer !== undefined && ndexServer != null && ndexServer !== '') {
18
- this._ndexServer = ndexServer;
19
- }
20
- }
21
-
22
- getNDExServer() {
23
- return this._ndexServer ? this._ndexServer : 'https://www.ndexbio.org';
24
- }
25
-
26
- setGoogleAuth(googleAuthObj) {
27
- if (googleAuthObj !== undefined) {
28
- this._googleAuth = googleAuthObj;
29
- this._authType = 'g'; // valid values are 'g','b' or undefined
30
- }
31
- }
32
-
33
- setAuthToken(authToken) {
34
- if (authToken !== undefined ) {
35
- this._authToken = authToken;
36
- this._authType = 'g'; // valid values are 'g','b' or undefined
37
- }
38
- }
39
-
40
- setBasicAuth(username, password) {
41
- if (username !== undefined && username != null && username !== '') {
42
- this._username = username;
43
- this._password = password;
44
- this._authType = 'b';
45
- }
46
- }
47
-
48
- cyRestURL() {
49
- return CY_REST_BASE_URL + ':' + this._port;
50
- }
51
-
52
- _getIdToken() {
53
- return this._authToken ? this._authToken : this._googleAuth.getAuthInstance().currentUser.get().getAuthResponse().id_token;
54
- }
55
-
56
- _getAuthorizationFields() {
57
- switch (this._authType) {
58
- case 'b' : return {
59
- username : this._username,
60
- password : this._password
61
- };
62
- case 'g' : return {
63
- idToken : this._getIdToken()
64
- };
65
- default : return {};
66
- }
67
- }
68
-
69
- _httpGet(url) {
70
-
71
- const baseURL = this.cyRestURL();
72
-
73
- return new Promise(function (resolve, reject) {
74
- axios({
75
- method: 'get',
76
- url: url,
77
- baseURL: baseURL
78
- }).then((response) => {
79
- if (response.status === 200) {
80
- return resolve(response.data);
81
- }
82
- return reject(response);
83
- },
84
- (response) => { return reject(response); }
85
- );
86
- });
87
- }
88
-
89
- _httpPut(url, parameters, data) {
90
- return this._http('put', url, parameters, data);
91
- }
92
-
93
- _httpPost(url, parameters, data) {
94
- return this._http('post', url, parameters, data);
95
- }
96
-
97
- _http(method, url, parameters, data) {
98
-
99
- const baseURL = this.cyRestURL();
100
-
101
- let config = {
102
- method: method,
103
- url: url,
104
- baseURL: baseURL
105
- };
106
-
107
- if (parameters !== undefined) {
108
- config['params'] = parameters;
109
- }
110
-
111
- config.data = data;
112
- return new Promise(function (resolve, reject) {
113
- axios(config).then((response) => {
114
- if (response.status >= 200 && response.status <= 299) {
115
- return resolve(response.data);
116
- }
117
- return reject(response);
118
- },
119
- (response) => {
120
- return reject(response);
121
- }
122
- );
123
- });
124
-
125
- }
126
-
127
- getCyNDExStatus() {
128
- return this._httpGet('/cyndex2/v1');
129
- }
130
-
131
- getCytoscapeNetworkSummary(suid = 'current') {
132
- return this._httpGet('/cyndex2/v1/networks/' + suid);
133
- }
134
-
135
- postNDExNetworkToCytoscape(uuid, accessKey, createView = undefined) {
136
- const importParams = {
137
- serverUrl: this.getNDExServer() + '/v2',
138
- uuid: uuid,
139
- accessKey: accessKey,
140
- createView: createView
141
- };
142
-
143
- const authorizationFields = this._getAuthorizationFields();
144
-
145
- return this._httpPost('/cyndex2/v1/networks', undefined, Object.assign(importParams, authorizationFields));
146
- }
147
-
148
- postCXNetworkToCytoscape(cx) {
149
- return this._httpPost('/cyndex2/v1/networks/cx', undefined, cx);
150
- }
151
-
152
- postCX2NetworkToCytoscape(cx2_string, title, collection_name) {
153
- return this._httpPost('/v1/networks',{ 'format': 'cx2', 'collection': collection_name, 'title':title}, cx2_string);
154
- }
155
-
156
- postCytoscapeNetworkToNDEx(suid = 'current') {
157
- const saveParams = {
158
- serverUrl: this.getNDExServer() + '/v2',
159
- };
160
-
161
- const authorizationFields = this._getAuthorizationFields();
162
-
163
- return this._httpPost('/cyndex2/v1/networks/' + suid, undefined, Object.assign(saveParams, authorizationFields));
164
- }
165
-
166
- putCytoscapeNetworkInNDEx(suid = 'current', uuid) {
167
- const saveParams = {
168
- serverUrl: this.getNDExServer() + '/v2',
169
- uuid: uuid
170
- };
171
-
172
- const authorizationFields = this._getAuthorizationFields();
173
-
174
- return this._httpPut('/cyndex2/v1/networks/' + suid, undefined, Object.assign(saveParams, authorizationFields));
175
- }
176
- }
177
-
178
- export default CyNDEx ;
package/src/CyNDEx.js.bak DELETED
@@ -1,178 +0,0 @@
1
- const CY_REST_BASE_URL = 'http://127.0.0.1';
2
-
3
- import { default as axios } from 'axios';
4
-
5
- class CyNDEx {
6
-
7
- constructor(port = 1234) {
8
- this._port = port;
9
- }
10
- get port() { return this._port; }
11
-
12
- static get cyRestBaseURL() {
13
- return CY_REST_BASE_URL;
14
- }
15
-
16
- setNDExServer(ndexServer) {
17
- if (ndexServer !== undefined && ndexServer != null && ndexServer !== '') {
18
- this._ndexServer = ndexServer;
19
- }
20
- }
21
-
22
- getNDExServer() {
23
- return this._ndexServer ? this._ndexServer : 'https://www.ndexbio.org';
24
- }
25
-
26
- setGoogleAuth(googleAuthObj) {
27
- if (googleAuthObj !== undefined) {
28
- this._googleAuth = googleAuthObj;
29
- this._authType = 'g'; // valid values are 'g','b' or undefined
30
- }
31
- }
32
-
33
- setAuthToken(authToken) {
34
- if (authToken !== undefined ) {
35
- this._authToken = authToken;
36
- this._authType = 'g'; // valid values are 'g','b' or undefined
37
- }
38
- }
39
-
40
- setBasicAuth(username, password) {
41
- if (username !== undefined && username != null && username !== '') {
42
- this._username = username;
43
- this._password = password;
44
- this._authType = 'b';
45
- }
46
- }
47
-
48
- cyRestURL() {
49
- return CY_REST_BASE_URL + ':' + this._port;
50
- }
51
-
52
- _getIdToken() {
53
- return this._authToken ? this._authToken : this._googleAuth.getAuthInstance().currentUser.get().getAuthResponse().id_token;
54
- }
55
-
56
- _getAuthorizationFields() {
57
- switch (this._authType) {
58
- case 'b' : return {
59
- username : this._username,
60
- password : this._password
61
- };
62
- case 'g' : return {
63
- idToken : this._getIdToken()
64
- };
65
- default : return {};
66
- }
67
- }
68
-
69
- _httpGet(url) {
70
-
71
- const baseURL = this.cyRestURL();
72
-
73
- return new Promise(function (resolve, reject) {
74
- axios({
75
- method: 'get',
76
- url: url,
77
- baseURL: baseURL
78
- }).then((response) => {
79
- if (response.status === 200) {
80
- return resolve(response.data);
81
- }
82
- return reject(response);
83
- },
84
- (response) => { return reject(response); }
85
- );
86
- });
87
- }
88
-
89
- _httpPut(url, parameters, data) {
90
- return this._http('put', url, parameters, data);
91
- }
92
-
93
- _httpPost(url, parameters, data) {
94
- return this._http('post', url, parameters, data);
95
- }
96
-
97
- _http(method, url, parameters, data) {
98
-
99
- const baseURL = this.cyRestURL();
100
-
101
- let config = {
102
- method: method,
103
- url: url,
104
- baseURL: baseURL
105
- };
106
-
107
- if (parameters !== undefined) {
108
- config['params'] = parameters;
109
- }
110
-
111
- config.data = data;
112
- return new Promise(function (resolve, reject) {
113
- axios(config).then((response) => {
114
- if (response.status >= 200 && response.status <= 299) {
115
- return resolve(response.data);
116
- }
117
- return reject(response);
118
- },
119
- (response) => {
120
- return reject(response);
121
- }
122
- );
123
- });
124
-
125
- }
126
-
127
- getCyNDExStatus() {
128
- return this._httpGet('/cyndex2/v1');
129
- }
130
-
131
- getCytoscapeNetworkSummary(suid = 'current') {
132
- return this._httpGet('/cyndex2/v1/networks/' + suid);
133
- }
134
-
135
- postNDExNetworkToCytoscape(uuid, accessKey, createView = undefined) {
136
- const importParams = {
137
- serverUrl: this.getNDExServer() + '/v2',
138
- uuid: uuid,
139
- accessKey: accessKey,
140
- createView: createView
141
- };
142
-
143
- const authorizationFields = this._getAuthorizationFields();
144
-
145
- return this._httpPost('/cyndex2/v1/networks', undefined, Object.assign(importParams, authorizationFields));
146
- }
147
-
148
- postCXNetworkToCytoscape(cx) {
149
- return this._httpPost('/cyndex2/v1/networks/cx', undefined, cx);
150
- }
151
-
152
- postCX2NetworkToCytoscape(cx2_string, title, collection_name) {
153
- return this._httpPost('/v1/networks',{ 'format': 'cx2', 'collection': collection_name, 'title':title}, cx2_string);
154
- }
155
-
156
- postCytoscapeNetworkToNDEx(suid = 'current') {
157
- const saveParams = {
158
- serverUrl: this.getNDExServer() + '/v2',
159
- };
160
-
161
- const authorizationFields = this._getAuthorizationFields();
162
-
163
- return this._httpPost('/cyndex2/v1/networks/' + suid, undefined, Object.assign(saveParams, authorizationFields));
164
- }
165
-
166
- putCytoscapeNetworkInNDEx(suid = 'current', uuid) {
167
- const saveParams = {
168
- serverUrl: this.getNDExServer() + '/v2',
169
- uuid: uuid
170
- };
171
-
172
- const authorizationFields = this._getAuthorizationFields();
173
-
174
- return this._httpPut('/cyndex2/v1/networks/' + suid, undefined, Object.assign(saveParams, authorizationFields));
175
- }
176
- }
177
-
178
- export default CyNDEx ;