@js4cytoscape/ndex-client 0.4.3-alpha.6 → 0.4.3-alpha.7
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/ndexClient.common.js +1 -1
- package/dist/ndexClient.common.js.LICENSE.txt +13 -0
- package/dist/ndexClient.js +1 -1
- package/package.json +1 -1
- package/src/NDEx.js +11 -0
|
@@ -125,7 +125,7 @@ eval("function _classCallCheck(instance, Constructor) { if (!(instance instanceo
|
|
|
125
125
|
\*********************/
|
|
126
126
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
127
127
|
|
|
128
|
-
eval("function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\nvar axios = __webpack_require__(/*! axios */ \"./node_modules/axios/dist/node/axios.cjs\");\n\nvar CX1_HEADER = {\n numberVerification: [{\n \"longNumber\": 283213721732712\n }]\n};\n/**\n * NDEx client class.\n */\n\nvar NDEx = /*#__PURE__*/function () {\n function NDEx(hostprefix) {\n _classCallCheck(this, NDEx);\n\n if (hostprefix === undefined || hostprefix === null || hostprefix === '') {\n throw new Error('NDEx server host name or endpoint base URL is required in client constructor.');\n } // axios needs http to be at the front of the url.\n // Otherwise any request will be redirected to localhost and fail\n // with an ambiguous reason\n\n\n var httpRegex = new RegExp(\"^(http|https)://\", \"i\");\n\n if (!httpRegex.test(hostprefix)) {\n // throw new Error(`\"http://\" or \"https://\" must be prefixed to the input url: ${hostprefix}`);\n // we assume it is a host name\n if (hostprefix.indexOf('/') > -1) throw new Error('\"/\" are not allowed in host name.');\n hostprefix = \"https://\" + hostprefix + \"/v2\";\n }\n\n this._host = hostprefix;\n this._v3baseURL = this._host.substring(0, this.host.lastIndexOf('v2')) + 'v3';\n }\n\n _createClass(NDEx, [{\n key: \"host\",\n get: function get() {\n return this._host;\n }\n }, {\n key: \"googleAuth\",\n get: function get() {\n return this._googleAuth;\n }\n }, {\n key: \"SetGoogleAuth\",\n value: function SetGoogleAuth(googleAuthObj) {\n if (googleAuthObj !== undefined) {\n this._googleAuth = googleAuthObj;\n this._authType = 'g'; // valid values are 'g','b' or undefined\n }\n }\n }, {\n key: \"setAuthToken\",\n value: function setAuthToken(authToken) {\n if (authToken !== undefined) {\n this._authToken = authToken;\n this._authType = 'g'; // valid values are 'g','b' or undefined\n }\n }\n }, {\n key: \"authenticationType\",\n get: function get() {\n return this._authType;\n }\n }, {\n key: \"username\",\n get: function get() {\n return this._username;\n } // get authStr() { return this._authStr;}\n\n }, {\n key: \"password\",\n get: function get() {\n return this._password;\n }\n }, {\n key: \"setBasicAuth\",\n value: function setBasicAuth(accountname, password) {\n if (accountname !== undefined && accountname != null && accountname !== '') {\n this._username = accountname;\n this._password = password;\n this._authType = 'b'; // this._authStr = 'Basic ' + btoa(username + ':' + password);\n\n return;\n }\n\n this._username = undefined;\n this._password = undefined;\n this._authType = undefined; // this._authStr = undefined;\n }\n }, {\n key: \"_httpGetOpenObj\",\n value: function _httpGetOpenObj(URL) {\n var APIEndPointPrefix = this.host;\n return new Promise(function (resolve, reject) {\n axios({\n method: 'get',\n url: URL,\n baseURL: APIEndPointPrefix\n }).then(function (response) {\n if (response.status === 200) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n } // access endpoints that supports authentication\n\n }, {\n key: \"_getIdToken\",\n value: function _getIdToken() {\n return this._authToken ? this._authToken : this._googleAuth.getAuthInstance().currentUser.get().getAuthResponse().id_token;\n }\n }, {\n key: \"_setAuthHeader\",\n value: function _setAuthHeader(config) {\n if (config['headers'] === undefined) {\n config['headers'] = {};\n }\n\n config['headers']['setAuthHeader'] = false;\n\n if (this._authType === 'b') {\n config['auth'] = {\n username: this.username,\n password: this.password\n };\n } else if (this.authenticationType === 'g') {\n config['headers']['Authorization'] = 'Bearer ' + this._getIdToken();\n }\n }\n }, {\n key: \"_httpGetProtectedObjAux\",\n value: function _httpGetProtectedObjAux(prefix, URL, parameters) {\n var config = {\n method: 'get',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status === 200) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n }, {\n key: \"_httpGetV3ProtectedObj\",\n value: function _httpGetV3ProtectedObj(URL, parameters) {\n return this._httpGetProtectedObjAux(this._v3baseURL, URL, parameters);\n }\n }, {\n key: \"_httpGetProtectedObj\",\n value: function _httpGetProtectedObj(URL, parameters) {\n return this._httpGetProtectedObjAux(this.host, URL, parameters);\n }\n }, {\n key: \"_httpPostProtectedObjAux\",\n value: function _httpPostProtectedObjAux(prefix, URL, parameters, data) {\n var config = {\n method: 'post',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n config.data = data;\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status >= 200 && response.status <= 299) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n }, {\n key: \"_httpPostProtectedObj\",\n value: function _httpPostProtectedObj(URL, parameters, data) {\n return this._httpPostProtectedObjAux(this.host, URL, parameters, data);\n }\n }, {\n key: \"_httpPostV3ProtectedObj\",\n value: function _httpPostV3ProtectedObj(URL, parameters, data) {\n return this._httpPostProtectedObjAux(this._v3baseURL, URL, parameters, data);\n }\n }, {\n key: \"_httpPutObjAux\",\n value: function _httpPutObjAux(prefix, URL, parameters, data) {\n var config = {\n method: 'put',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n config.data = data;\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status >= 200 && response.status <= 299) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n }, {\n key: \"_httpPutObj\",\n value: function _httpPutObj(URL, parameters, data) {\n return this._httpPutObjAux(this.host, URL, parameters, data);\n }\n }, {\n key: \"_httpPutV3Obj\",\n value: function _httpPutV3Obj(URL, parameters, data) {\n return this._httpPutObjAux(this._v3baseURL, URL, parameters, data);\n }\n }, {\n key: \"_httpDeleteObj\",\n value: function _httpDeleteObj(URL, parameters, data) {\n return this._httpDeleteObjAux(this.host, URL, parameters, data);\n }\n }, {\n key: \"_httpDeleteV3Obj\",\n value: function _httpDeleteV3Obj(URL, parameters) {\n return this._httpDeleteObjAux(this._v3baseURL, URL, parameters, undefined);\n }\n }, {\n key: \"_httpDeleteObjAux\",\n value: function _httpDeleteObjAux(prefix, URL, parameters, data) {\n var config = {\n method: 'delete',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n if (data !== undefined) {\n config['data'] = data;\n }\n\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status >= 200 && response.status <= 299) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n /* admin functions */\n\n }, {\n key: \"getStatus\",\n value: function getStatus() {\n return this._httpGetOpenObj('admin/status');\n }\n /* user functions */\n\n }, {\n key: \"getSignedInUser\",\n value: function getSignedInUser() {\n if (this._authType == null) {\n throw new Error('Authentication parameters are missing in NDEx client.');\n }\n\n return this._httpGetProtectedObj('user', {\n valid: true\n });\n }\n }, {\n key: \"getUser\",\n value: function getUser(uuid) {\n return this._httpGetProtectedObj('user/' + uuid);\n }\n }, {\n key: \"getAccountPageNetworks\",\n value: function getAccountPageNetworks(offset, limit) {\n var _this = this;\n\n return new Promise(function (resolve, reject) {\n _this.getSignedInUser().then(function (user) {\n var params = {};\n\n if (offset !== undefined) {\n params.offset = offset;\n }\n\n if (limit !== undefined) {\n params.limit = limit;\n }\n\n _this._httpGetProtectedObj('/user/' + user.externalId + '/networksummary', params).then(function (networkArray) {\n resolve(networkArray);\n }, function (err) {\n reject(err);\n });\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"getAccountPageNetworksByUUID\",\n value: function getAccountPageNetworksByUUID(uuid, offset, limit) {\n var params = {};\n\n if (offset !== undefined) {\n params.offset = offset;\n }\n\n if (limit !== undefined) {\n params.limit = limit;\n }\n\n return this._httpGetProtectedObj('user/' + uuid + '/networksummary', params);\n }\n /* group functions */\n // return the UUID of the created group to the resolver\n\n }, {\n key: \"createGroup\",\n value: function createGroup(group) {\n var _this2 = this;\n\n return new Promise(function (resolve, reject) {\n _this2._httpPostProtectedObj('group', undefined, group).then(function (response) {\n var uuidr = response.split('/');\n var uuid = uuidr[uuidr.length - 1];\n return resolve(uuid);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"getGroup\",\n value: function getGroup(uuid) {\n return this._httpGetProtectedObj('group/' + uuid);\n }\n }, {\n key: \"updateGroup\",\n value: function updateGroup(group) {\n var _this3 = this;\n\n return new Promise(function (resolve, reject) {\n _this3._httpPutObj('group/' + group.externalId, undefined, group).then(function (response) {\n return resolve(response);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"deleteGroup\",\n value: function deleteGroup(uuid) {\n return this._httpDeleteObj('group/' + uuid);\n }\n /* network functions */\n\n }, {\n key: \"getRawNetwork\",\n value: function getRawNetwork(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetProtectedObj('network/' + uuid, parameters);\n }\n }, {\n key: \"getCX2Network\",\n value: function getCX2Network(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid, parameters);\n }\n }, {\n key: \"getNetworkSummary\",\n value: function getNetworkSummary(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetProtectedObj('network/' + uuid + '/summary', parameters);\n }\n }, {\n key: \"getNetworkV3Summary\",\n value: function getNetworkV3Summary(uuid, accessKey, fmt) {\n var parameters = {\n format: fmt != null ? fmt : \"FULL\"\n };\n\n if (accessKey != null) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/summary', parameters);\n }\n }, {\n key: \"getAttributesOfSelectedNodes\",\n value: function getAttributesOfSelectedNodes(uuid, _ref, accessKey) {\n var nodeIds = _ref.ids,\n names = _ref.attributeNames;\n var parameters = {};\n\n if (accessKey != null) {\n parameters['accesskey'] = accessKey;\n }\n\n var data = {\n \"ids\": nodeIds,\n \"attributeNames\": names\n };\n return this._httpPostV3ProtectedObj('/search/networks/' + uuid + '/nodes', parameters, data);\n }\n }, {\n key: \"createNetworkFromRawCX\",\n value: function createNetworkFromRawCX(rawCX, parameters) {\n var _this4 = this;\n\n return new Promise(function (resolve, reject) {\n _this4._httpPostProtectedObj('network', parameters, rawCX).then(function (response) {\n var uuidr = response.split('/');\n var uuid = uuidr[uuidr.length - 1];\n return resolve(uuid);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"updateNetworkFromRawCX\",\n value: function updateNetworkFromRawCX(uuid, rawcx) {\n return this._httpPutObj('network/' + uuid, undefined, rawcx);\n }\n }, {\n key: \"deleteNetwork\",\n value: function deleteNetwork(uuid) {\n return this._httpDeleteObj('network/' + uuid);\n }\n /* task functions */\n\n /* search functions */\n\n }, {\n key: \"searchUsers\",\n value: function searchUsers(searchTerms, start, size) {\n var params = {};\n\n if (start !== undefined) {\n params.start = start;\n }\n\n if (size !== undefined) {\n params.limit = size;\n }\n\n var data = {\n searchString: searchTerms\n };\n return this._httpPostProtectedObj('search/user', params, data);\n }\n }, {\n key: \"searchGroups\",\n value: function searchGroups(searchTerms, start, size) {\n var params = {};\n\n if (start !== undefined) {\n params.start = start;\n }\n\n if (size !== undefined) {\n params.limit = size;\n }\n\n var data = {\n searchString: searchTerms\n };\n return this._httpPostProtectedObj('search/group', params, data);\n }\n }, {\n key: \"searchNetworks\",\n value: function searchNetworks(searchTerms, start, size, optionalParameters) {\n var params = {};\n\n if (start !== undefined) {\n params.start = start;\n }\n\n if (size !== undefined) {\n params.limit = size;\n }\n\n var data = {\n searchString: searchTerms\n };\n\n if (optionalParameters !== undefined) {\n if (optionalParameters.permission !== undefined) {\n data.permission = optionalParameters.permission;\n }\n\n if (optionalParameters.includeGroups !== undefined) {\n data.includeGroups = optionalParameters.includeGroups;\n }\n\n if (optionalParameters.accountName !== undefined) {\n data.accountName = optionalParameters.accountName;\n }\n }\n\n return this._httpPostProtectedObj('search/network', params, data);\n }\n }, {\n key: \"neighborhoodQuery\",\n value: function neighborhoodQuery(uuid, searchTerms, saveResult, parameters) {\n var outputCX2 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n var params = {};\n\n if (saveResult !== undefined && saveResult === true) {\n params.save = true;\n }\n\n var data = {\n searchString: searchTerms,\n searchDepth: 1\n };\n\n if (parameters !== undefined) {\n if (parameters.searchDepth !== undefined) {\n data.searchDepth = parameters.searchDepth;\n }\n\n if (parameters.edgeLimit !== undefined) {\n data.edgeLimit = parameters.edgeLimit;\n }\n\n if (parameters.errorWhenLimitIsOver !== undefined) {\n data.errorWhenLimitIsOver = parameters.errorWhenLimitIsOver;\n }\n\n if (parameters.directOnly !== undefined) {\n data.directOnly = parameters.directOnly;\n }\n\n if (parameters.nodeIds != null) {\n data.nodeIds = parameters.nodeIds;\n }\n }\n\n if (outputCX2) return this._httpPostV3ProtectedObj('search/network/' + uuid + '/query', params, data);\n return this._httpPostProtectedObj('search/network/' + uuid + '/query', params, data);\n }\n }, {\n key: \"interConnectQuery\",\n value: function interConnectQuery(uuid, searchTerms, saveResult, parameters) {\n var outputCX2 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n var params = {};\n\n if (saveResult !== undefined && saveResult === true) {\n params.save = true;\n }\n\n var data = {\n searchString: searchTerms\n };\n\n if (parameters !== undefined) {\n if (parameters.edgeLimit !== undefined) {\n data.edgeLimit = parameters.edgeLimit;\n }\n\n if (parameters.errorWhenLimitIsOver !== undefined) {\n data.errorWhenLimitIsOver = parameters.errorWhenLimitIsOver;\n }\n\n if (parameters.nodeIds != null) {\n data.nodeIds = parameters.nodeIds;\n }\n }\n\n if (outputCX2) return this._httpPostV3ProtectedObj('search/networks/' + uuid + '/interconnectquery', params, data);\n return this._httpPostProtectedObj('search/network/' + uuid + '/interconnectquery', params, data);\n }\n /* batch functions */\n\n }, {\n key: \"getUsersByUUIDs\",\n value: function getUsersByUUIDs(uuidList) {\n return this._httpPostProtectedObj('batch/user', undefined, uuidList);\n }\n }, {\n key: \"getGroupsByUUIDs\",\n value: function getGroupsByUUIDs(uuidList) {\n return this._httpPostProtectedObj('batch/group', undefined, uuidList);\n }\n }, {\n key: \"getNetworkSummariesByUUIDs\",\n value: function getNetworkSummariesByUUIDs(uuidList, accessKey) {\n var parameter = accessKey === undefined ? undefined : {\n accesskey: accessKey\n };\n return this._httpPostProtectedObj('batch/network/summary', parameter, uuidList);\n }\n }, {\n key: \"getNetworkSummariesV3ByUUIDs\",\n value: function getNetworkSummariesV3ByUUIDs(uuidList, accessKey, fmt) {\n var parameter = {\n format: fmt == undefined ? \"FULL\" : fmt\n };\n if (accessKey != null) parameter['accesskey'] = accessKey;\n return this._httpPostV3ProtectedObj('batch/networks/summary', parameter, uuidList);\n }\n }, {\n key: \"getNetworkPermissionsByUUIDs\",\n value: function getNetworkPermissionsByUUIDs(uuidList) {\n return this._httpPostProtectedObj('batch/network/permission', undefined, uuidList);\n }\n }, {\n key: \"exportNetworks\",\n value: function exportNetworks(exportJob) {\n return this._httpPostProtectedObj('batch/network/export', undefined, exportJob);\n }\n /* network set functions */\n\n }, {\n key: \"createNetworkSet\",\n value: function createNetworkSet(_ref2) {\n var _this5 = this;\n\n var name = _ref2.name,\n description = _ref2.description;\n return new Promise(function (resolve, reject) {\n _this5._httpPostProtectedObj('networkset', undefined, {\n name: name,\n description: description\n }).then(function (response) {\n var uuidr = response.split('/');\n var uuid = uuidr[uuidr.length - 1];\n return resolve(uuid);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"updateNetworkSet\",\n value: function updateNetworkSet(uuid, _ref3) {\n var _this6 = this;\n\n var name = _ref3.name,\n description = _ref3.description;\n return new Promise(function (resolve, reject) {\n _this6._httpPutObj('networkset/' + uuid, undefined, {\n uuid: uuid,\n name: name,\n description: description\n }).then(function (response) {\n return resolve(response);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"deleteNetworkSet\",\n value: function deleteNetworkSet(uuid) {\n return this._httpDeleteObj('networkset/' + uuid);\n }\n }, {\n key: \"getNetworkSet\",\n value: function getNetworkSet(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetProtectedObj('networkset/' + uuid, parameters);\n }\n }, {\n key: \"addToNetworkSet\",\n value: function addToNetworkSet(networkSetUUID, networkUUIDs) {\n return this._httpPostProtectedObj('networkset/' + networkSetUUID + '/members', undefined, networkUUIDs);\n }\n }, {\n key: \"deleteFromNetworkSet\",\n value: function deleteFromNetworkSet(networkSetUUID, networkUUIDS) {\n return this._httpDeleteObj('networkset/' + networkSetUUID + '/members', undefined, networkUUIDS);\n }\n }, {\n key: \"updateNetworkSetSystemProperty\",\n value: function updateNetworkSetSystemProperty(networksetUUID, data) {\n return this._httpPutObj('networkset/' + networksetUUID + '/systemproperty', undefined, data);\n }\n /* undocumented functions. Might be changed ... */\n // layout update is a list of objects:\n // [{ node: 1, x: 100, y: 100}, {node: 2, x: 1003, y: 200 }...]\n\n }, {\n key: \"updateCartesianLayoutAspect\",\n value: function updateCartesianLayoutAspect(uuid, nodePositions) {\n // 1. get node coordinates from cy.js model in the format of cartesian aspect\n // 2. generate CX for the put request\n // 3. example\n // [{\n // \"numberVerification\": [\n // {\n // \"longNumber\": 283213721732712\n // }\n // ]\n // }, {\n // \"metaData\": [{\n // \"name\": \"cartesianLayout\", \"elementCount\": 100 // num nodes here\n // }],\n // \"cartesianLayout\": [{\n // \"node\": 100, \"x\": 23213.12, \"y\": 3234.5\n // }]\n // }]\n var cartesianLayoutUpdate = [CX1_HEADER, {\n metaData: [{\n name: 'cartesianLayout',\n elementCount: nodePositions.length\n }]\n }, {\n cartesianLayout: nodePositions\n }, {\n status: [{\n error: '',\n success: true\n }]\n }];\n return this._httpPutObj(\"network/\".concat(uuid, \"/aspects\"), undefined, cartesianLayoutUpdate);\n } // new v3 functions\n\n }, {\n key: \"getRandomEdges\",\n value: function getRandomEdges(uuid, limit, accessKey) {\n if (limit <= 0) throw new Error(\"Value of parameter limit has to be greater than 0.\");\n var parameters = {\n size: limit,\n method: \"random\"\n };\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/aspects/edges', parameters);\n }\n }, {\n key: \"getMetaData\",\n value: function getMetaData(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetProtectedObj('network/' + uuid + '/aspect', parameters);\n }\n }, {\n key: \"getAspectElements\",\n value: function getAspectElements(uuid, aspectName, limit, accessKey) {\n var parameters = {};\n\n if (limit !== undefined) {\n parameters = {\n size: limit\n };\n }\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/aspects/' + aspectName, parameters);\n }\n }, {\n key: \"getFilteredEdges\",\n value: function getFilteredEdges(uuid, columnName, valueString, operator, limit, order, format, accessKey) {\n var parameters = {};\n\n if (limit !== undefined) {\n parameters = {\n size: limit\n };\n }\n\n if (order !== undefined) {\n parameters['order'] = order;\n }\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n if (format !== undefined) {\n parameters['format'] = format;\n }\n\n var data = {\n \"name\": columnName,\n \"value\": valueString,\n \"operator\": operator\n };\n return this._httpPostV3ProtectedObj('/search/networks/' + uuid + '/edges', parameters, data);\n }\n }, {\n key: \"getCX2MetaData\",\n value: function getCX2MetaData(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/aspects', parameters);\n }\n }, {\n key: \"cancelDOIRequest\",\n value: function cancelDOIRequest(uuid) {\n var cancelBody = {\n type: \"Cancel_DOI\",\n networkId: uuid\n };\n return this._httpPostProtectedObj('admin/request', {}, cancelBody);\n } // unstable function to upload CX2 to NDEx\n\n }, {\n key: \"createNetworkFromRawCX2\",\n value: function createNetworkFromRawCX2(rawCX2) {\n var makePublic = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var config = {\n method: 'post',\n url: 'networks',\n baseURL: this._v3baseURL,\n params: {\n visibility: makePublic ? 'PUBLIC' : 'PRIVATE'\n }\n };\n\n this._setAuthHeader(config);\n\n config.data = rawCX2;\n return axios(config).then(function (res) {\n var location = res.headers.location;\n var uuid = location.split('/').pop();\n return {\n uuid: uuid\n };\n });\n }\n }, {\n key: \"updateNetworkFromRawCX2\",\n value: function updateNetworkFromRawCX2(uuid, rawCX2) {\n return this._httpPutV3Obj('networks/' + uuid, undefined, rawCX2);\n }\n }, {\n key: \"createCyWebWorkspace\",\n value: function createCyWebWorkspace(workspace) {\n var _this7 = this;\n\n return new Promise(function (resolve, reject) {\n _this7._httpPostV3ProtectedObj('workspaces', undefined, workspace).then(function (response) {\n // let uuidr = response.split('/');\n // let uuid = uuidr[uuidr.length - 1];\n return resolve(response);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"getCyWebWorkspace\",\n value: function getCyWebWorkspace(workspaceId) {\n return this._httpGetV3ProtectedObj('workspaces/' + workspaceId, {});\n }\n }, {\n key: \"deleteCyWebWorkspace\",\n value: function deleteCyWebWorkspace(workspaceId) {\n return this._httpDeleteV3Obj('workspaces/' + workspaceId, undefined);\n }\n }, {\n key: \"updateCyWebWorkspace\",\n value: function updateCyWebWorkspace(workspaceId, workspaceObj) {\n return this._httpPutV3Obj('workspaces/' + workspaceId, undefined, workspaceObj);\n }\n }, {\n key: \"updateCyWebWorkspaceName\",\n value: function updateCyWebWorkspaceName(workspaceId, newName) {\n return this._httpPutV3Obj('workspaces/' + workspaceId + '/name', undefined, {\n 'name': newName\n });\n }\n }, {\n key: \"updateCyWebWorkspaceNetworks\",\n value: function updateCyWebWorkspaceNetworks(workspaceId, networkIds) {\n return this._httpPutV3Obj('workspaces/' + workspaceId + '/networkids', undefined, networkIds);\n }\n }]);\n\n return NDEx;\n}();\n\nmodule.exports = {\n NDEx: NDEx\n};\n\n//# sourceURL=webpack://@js4cytoscape/ndex-client/./src/NDEx.js?");
|
|
128
|
+
eval("function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\nvar axios = __webpack_require__(/*! axios */ \"./node_modules/axios/dist/node/axios.cjs\");\n\nvar CX1_HEADER = {\n numberVerification: [{\n \"longNumber\": 283213721732712\n }]\n};\n/**\n * NDEx client class.\n */\n\nvar NDEx = /*#__PURE__*/function () {\n function NDEx(hostprefix) {\n _classCallCheck(this, NDEx);\n\n if (hostprefix === undefined || hostprefix === null || hostprefix === '') {\n throw new Error('NDEx server host name or endpoint base URL is required in client constructor.');\n } // axios needs http to be at the front of the url.\n // Otherwise any request will be redirected to localhost and fail\n // with an ambiguous reason\n\n\n var httpRegex = new RegExp(\"^(http|https)://\", \"i\");\n\n if (!httpRegex.test(hostprefix)) {\n // throw new Error(`\"http://\" or \"https://\" must be prefixed to the input url: ${hostprefix}`);\n // we assume it is a host name\n if (hostprefix.indexOf('/') > -1) throw new Error('\"/\" are not allowed in host name.');\n hostprefix = \"https://\" + hostprefix + \"/v2\";\n }\n\n this._host = hostprefix;\n this._v3baseURL = this._host.substring(0, this.host.lastIndexOf('v2')) + 'v3';\n }\n\n _createClass(NDEx, [{\n key: \"host\",\n get: function get() {\n return this._host;\n }\n }, {\n key: \"googleAuth\",\n get: function get() {\n return this._googleAuth;\n }\n }, {\n key: \"SetGoogleAuth\",\n value: function SetGoogleAuth(googleAuthObj) {\n if (googleAuthObj !== undefined) {\n this._googleAuth = googleAuthObj;\n this._authType = 'g'; // valid values are 'g','b' or undefined\n }\n }\n }, {\n key: \"setAuthToken\",\n value: function setAuthToken(authToken) {\n if (authToken !== undefined) {\n this._authToken = authToken;\n this._authType = 'g'; // valid values are 'g','b' or undefined\n }\n }\n }, {\n key: \"authenticationType\",\n get: function get() {\n return this._authType;\n }\n }, {\n key: \"username\",\n get: function get() {\n return this._username;\n } // get authStr() { return this._authStr;}\n\n }, {\n key: \"password\",\n get: function get() {\n return this._password;\n }\n }, {\n key: \"setBasicAuth\",\n value: function setBasicAuth(accountname, password) {\n if (accountname !== undefined && accountname != null && accountname !== '') {\n this._username = accountname;\n this._password = password;\n this._authType = 'b'; // this._authStr = 'Basic ' + btoa(username + ':' + password);\n\n return;\n }\n\n this._username = undefined;\n this._password = undefined;\n this._authType = undefined; // this._authStr = undefined;\n }\n }, {\n key: \"_httpGetOpenObj\",\n value: function _httpGetOpenObj(URL) {\n var APIEndPointPrefix = this.host;\n return new Promise(function (resolve, reject) {\n axios({\n method: 'get',\n url: URL,\n baseURL: APIEndPointPrefix\n }).then(function (response) {\n if (response.status === 200) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n } // access endpoints that supports authentication\n\n }, {\n key: \"_getIdToken\",\n value: function _getIdToken() {\n return this._authToken ? this._authToken : this._googleAuth.getAuthInstance().currentUser.get().getAuthResponse().id_token;\n }\n }, {\n key: \"_setAuthHeader\",\n value: function _setAuthHeader(config) {\n if (config['headers'] === undefined) {\n config['headers'] = {};\n }\n\n config['headers']['setAuthHeader'] = false;\n\n if (this._authType === 'b') {\n config['auth'] = {\n username: this.username,\n password: this.password\n };\n } else if (this.authenticationType === 'g') {\n config['headers']['Authorization'] = 'Bearer ' + this._getIdToken();\n }\n }\n }, {\n key: \"_httpGetProtectedObjAux\",\n value: function _httpGetProtectedObjAux(prefix, URL, parameters) {\n var config = {\n method: 'get',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status === 200) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n }, {\n key: \"_httpGetV3ProtectedObj\",\n value: function _httpGetV3ProtectedObj(URL, parameters) {\n return this._httpGetProtectedObjAux(this._v3baseURL, URL, parameters);\n }\n }, {\n key: \"_httpGetProtectedObj\",\n value: function _httpGetProtectedObj(URL, parameters) {\n return this._httpGetProtectedObjAux(this.host, URL, parameters);\n }\n }, {\n key: \"_httpPostProtectedObjAux\",\n value: function _httpPostProtectedObjAux(prefix, URL, parameters, data) {\n var config = {\n method: 'post',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n config.data = data;\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status >= 200 && response.status <= 299) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n }, {\n key: \"_httpPostProtectedObj\",\n value: function _httpPostProtectedObj(URL, parameters, data) {\n return this._httpPostProtectedObjAux(this.host, URL, parameters, data);\n }\n }, {\n key: \"_httpPostV3ProtectedObj\",\n value: function _httpPostV3ProtectedObj(URL, parameters, data) {\n return this._httpPostProtectedObjAux(this._v3baseURL, URL, parameters, data);\n }\n }, {\n key: \"_httpPutObjAux\",\n value: function _httpPutObjAux(prefix, URL, parameters, data) {\n var config = {\n method: 'put',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n config.data = data;\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status >= 200 && response.status <= 299) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n }, {\n key: \"_httpPutObj\",\n value: function _httpPutObj(URL, parameters, data) {\n return this._httpPutObjAux(this.host, URL, parameters, data);\n }\n }, {\n key: \"_httpPutV3Obj\",\n value: function _httpPutV3Obj(URL, parameters, data) {\n return this._httpPutObjAux(this._v3baseURL, URL, parameters, data);\n }\n }, {\n key: \"_httpDeleteObj\",\n value: function _httpDeleteObj(URL, parameters, data) {\n return this._httpDeleteObjAux(this.host, URL, parameters, data);\n }\n }, {\n key: \"_httpDeleteV3Obj\",\n value: function _httpDeleteV3Obj(URL, parameters) {\n return this._httpDeleteObjAux(this._v3baseURL, URL, parameters, undefined);\n }\n }, {\n key: \"_httpDeleteObjAux\",\n value: function _httpDeleteObjAux(prefix, URL, parameters, data) {\n var config = {\n method: 'delete',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n if (data !== undefined) {\n config['data'] = data;\n }\n\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status >= 200 && response.status <= 299) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n /* admin functions */\n\n }, {\n key: \"getStatus\",\n value: function getStatus() {\n return this._httpGetOpenObj('admin/status');\n }\n /* user functions */\n\n }, {\n key: \"getSignedInUser\",\n value: function getSignedInUser() {\n if (this._authType == null) {\n throw new Error('Authentication parameters are missing in NDEx client.');\n }\n\n return this._httpGetProtectedObj('user', {\n valid: true\n });\n }\n }, {\n key: \"getUser\",\n value: function getUser(uuid) {\n return this._httpGetProtectedObj('user/' + uuid);\n }\n }, {\n key: \"getAccountPageNetworks\",\n value: function getAccountPageNetworks(offset, limit) {\n var _this = this;\n\n return new Promise(function (resolve, reject) {\n _this.getSignedInUser().then(function (user) {\n var params = {};\n\n if (offset !== undefined) {\n params.offset = offset;\n }\n\n if (limit !== undefined) {\n params.limit = limit;\n }\n\n _this._httpGetProtectedObj('/user/' + user.externalId + '/networksummary', params).then(function (networkArray) {\n resolve(networkArray);\n }, function (err) {\n reject(err);\n });\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"getAccountPageNetworksByUUID\",\n value: function getAccountPageNetworksByUUID(uuid, offset, limit) {\n var params = {};\n\n if (offset !== undefined) {\n params.offset = offset;\n }\n\n if (limit !== undefined) {\n params.limit = limit;\n }\n\n return this._httpGetProtectedObj('user/' + uuid + '/networksummary', params);\n }\n /* group functions */\n // return the UUID of the created group to the resolver\n\n }, {\n key: \"createGroup\",\n value: function createGroup(group) {\n var _this2 = this;\n\n return new Promise(function (resolve, reject) {\n _this2._httpPostProtectedObj('group', undefined, group).then(function (response) {\n var uuidr = response.split('/');\n var uuid = uuidr[uuidr.length - 1];\n return resolve(uuid);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"getGroup\",\n value: function getGroup(uuid) {\n return this._httpGetProtectedObj('group/' + uuid);\n }\n }, {\n key: \"updateGroup\",\n value: function updateGroup(group) {\n var _this3 = this;\n\n return new Promise(function (resolve, reject) {\n _this3._httpPutObj('group/' + group.externalId, undefined, group).then(function (response) {\n return resolve(response);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"deleteGroup\",\n value: function deleteGroup(uuid) {\n return this._httpDeleteObj('group/' + uuid);\n }\n /* network functions */\n\n }, {\n key: \"getRawNetwork\",\n value: function getRawNetwork(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetProtectedObj('network/' + uuid, parameters);\n }\n }, {\n key: \"getCX2Network\",\n value: function getCX2Network(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid, parameters);\n }\n }, {\n key: \"getNetworkSummary\",\n value: function getNetworkSummary(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetProtectedObj('network/' + uuid + '/summary', parameters);\n }\n }, {\n key: \"getNetworkV3Summary\",\n value: function getNetworkV3Summary(uuid, accessKey, fmt) {\n var parameters = {\n format: fmt != null ? fmt : \"FULL\"\n };\n\n if (accessKey != null) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/summary', parameters);\n }\n }, {\n key: \"getAttributesOfSelectedNodes\",\n value: function getAttributesOfSelectedNodes(uuid, _ref, accessKey) {\n var nodeIds = _ref.ids,\n names = _ref.attributeNames;\n var parameters = {};\n\n if (accessKey != null) {\n parameters['accesskey'] = accessKey;\n }\n\n var data = {\n \"ids\": nodeIds,\n \"attributeNames\": names\n };\n return this._httpPostV3ProtectedObj('/search/networks/' + uuid + '/nodes', parameters, data);\n }\n }, {\n key: \"createNetworkFromRawCX\",\n value: function createNetworkFromRawCX(rawCX, parameters) {\n var _this4 = this;\n\n return new Promise(function (resolve, reject) {\n _this4._httpPostProtectedObj('network', parameters, rawCX).then(function (response) {\n var uuidr = response.split('/');\n var uuid = uuidr[uuidr.length - 1];\n return resolve(uuid);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"updateNetworkFromRawCX\",\n value: function updateNetworkFromRawCX(uuid, rawcx) {\n return this._httpPutObj('network/' + uuid, undefined, rawcx);\n }\n }, {\n key: \"deleteNetwork\",\n value: function deleteNetwork(uuid) {\n return this._httpDeleteObj('network/' + uuid);\n }\n /* task functions */\n\n /* search functions */\n\n }, {\n key: \"searchUsers\",\n value: function searchUsers(searchTerms, start, size) {\n var params = {};\n\n if (start !== undefined) {\n params.start = start;\n }\n\n if (size !== undefined) {\n params.limit = size;\n }\n\n var data = {\n searchString: searchTerms\n };\n return this._httpPostProtectedObj('search/user', params, data);\n }\n }, {\n key: \"searchGroups\",\n value: function searchGroups(searchTerms, start, size) {\n var params = {};\n\n if (start !== undefined) {\n params.start = start;\n }\n\n if (size !== undefined) {\n params.limit = size;\n }\n\n var data = {\n searchString: searchTerms\n };\n return this._httpPostProtectedObj('search/group', params, data);\n }\n }, {\n key: \"searchNetworks\",\n value: function searchNetworks(searchTerms, start, size, optionalParameters) {\n var params = {};\n\n if (start !== undefined) {\n params.start = start;\n }\n\n if (size !== undefined) {\n params.limit = size;\n }\n\n var data = {\n searchString: searchTerms\n };\n\n if (optionalParameters !== undefined) {\n if (optionalParameters.permission !== undefined) {\n data.permission = optionalParameters.permission;\n }\n\n if (optionalParameters.includeGroups !== undefined) {\n data.includeGroups = optionalParameters.includeGroups;\n }\n\n if (optionalParameters.accountName !== undefined) {\n data.accountName = optionalParameters.accountName;\n }\n }\n\n return this._httpPostProtectedObj('search/network', params, data);\n }\n }, {\n key: \"neighborhoodQuery\",\n value: function neighborhoodQuery(uuid, searchTerms, saveResult, parameters) {\n var outputCX2 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n var params = {};\n\n if (saveResult !== undefined && saveResult === true) {\n params.save = true;\n }\n\n var data = {\n searchString: searchTerms,\n searchDepth: 1\n };\n\n if (parameters !== undefined) {\n if (parameters.searchDepth !== undefined) {\n data.searchDepth = parameters.searchDepth;\n }\n\n if (parameters.edgeLimit !== undefined) {\n data.edgeLimit = parameters.edgeLimit;\n }\n\n if (parameters.errorWhenLimitIsOver !== undefined) {\n data.errorWhenLimitIsOver = parameters.errorWhenLimitIsOver;\n }\n\n if (parameters.directOnly !== undefined) {\n data.directOnly = parameters.directOnly;\n }\n\n if (parameters.nodeIds != null) {\n data.nodeIds = parameters.nodeIds;\n }\n }\n\n if (outputCX2) return this._httpPostV3ProtectedObj('search/network/' + uuid + '/query', params, data);\n return this._httpPostProtectedObj('search/network/' + uuid + '/query', params, data);\n }\n }, {\n key: \"interConnectQuery\",\n value: function interConnectQuery(uuid, searchTerms, saveResult, parameters) {\n var outputCX2 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n var params = {};\n\n if (saveResult !== undefined && saveResult === true) {\n params.save = true;\n }\n\n var data = {\n searchString: searchTerms\n };\n\n if (parameters !== undefined) {\n if (parameters.edgeLimit !== undefined) {\n data.edgeLimit = parameters.edgeLimit;\n }\n\n if (parameters.errorWhenLimitIsOver !== undefined) {\n data.errorWhenLimitIsOver = parameters.errorWhenLimitIsOver;\n }\n\n if (parameters.nodeIds != null) {\n data.nodeIds = parameters.nodeIds;\n }\n }\n\n if (outputCX2) return this._httpPostV3ProtectedObj('search/networks/' + uuid + '/interconnectquery', params, data);\n return this._httpPostProtectedObj('search/network/' + uuid + '/interconnectquery', params, data);\n }\n /* batch functions */\n\n }, {\n key: \"getUsersByUUIDs\",\n value: function getUsersByUUIDs(uuidList) {\n return this._httpPostProtectedObj('batch/user', undefined, uuidList);\n }\n }, {\n key: \"getGroupsByUUIDs\",\n value: function getGroupsByUUIDs(uuidList) {\n return this._httpPostProtectedObj('batch/group', undefined, uuidList);\n }\n }, {\n key: \"getNetworkSummariesByUUIDs\",\n value: function getNetworkSummariesByUUIDs(uuidList, accessKey) {\n var parameter = accessKey === undefined ? undefined : {\n accesskey: accessKey\n };\n return this._httpPostProtectedObj('batch/network/summary', parameter, uuidList);\n }\n }, {\n key: \"getNetworkSummariesV3ByUUIDs\",\n value: function getNetworkSummariesV3ByUUIDs(uuidList, accessKey, fmt) {\n var parameter = {\n format: fmt == undefined ? \"FULL\" : fmt\n };\n if (accessKey != null) parameter['accesskey'] = accessKey;\n return this._httpPostV3ProtectedObj('batch/networks/summary', parameter, uuidList);\n }\n }, {\n key: \"getNetworkPermissionsByUUIDs\",\n value: function getNetworkPermissionsByUUIDs(uuidList) {\n return this._httpPostProtectedObj('batch/network/permission', undefined, uuidList);\n }\n }, {\n key: \"exportNetworks\",\n value: function exportNetworks(exportJob) {\n return this._httpPostProtectedObj('batch/network/export', undefined, exportJob);\n }\n /* network set functions */\n\n }, {\n key: \"createNetworkSet\",\n value: function createNetworkSet(_ref2) {\n var _this5 = this;\n\n var name = _ref2.name,\n description = _ref2.description;\n return new Promise(function (resolve, reject) {\n _this5._httpPostProtectedObj('networkset', undefined, {\n name: name,\n description: description\n }).then(function (response) {\n var uuidr = response.split('/');\n var uuid = uuidr[uuidr.length - 1];\n return resolve(uuid);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"updateNetworkSet\",\n value: function updateNetworkSet(uuid, _ref3) {\n var _this6 = this;\n\n var name = _ref3.name,\n description = _ref3.description;\n return new Promise(function (resolve, reject) {\n _this6._httpPutObj('networkset/' + uuid, undefined, {\n uuid: uuid,\n name: name,\n description: description\n }).then(function (response) {\n return resolve(response);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"deleteNetworkSet\",\n value: function deleteNetworkSet(uuid) {\n return this._httpDeleteObj('networkset/' + uuid);\n }\n }, {\n key: \"getNetworkSet\",\n value: function getNetworkSet(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetProtectedObj('networkset/' + uuid, parameters);\n }\n }, {\n key: \"addToNetworkSet\",\n value: function addToNetworkSet(networkSetUUID, networkUUIDs) {\n return this._httpPostProtectedObj('networkset/' + networkSetUUID + '/members', undefined, networkUUIDs);\n }\n }, {\n key: \"deleteFromNetworkSet\",\n value: function deleteFromNetworkSet(networkSetUUID, networkUUIDS) {\n return this._httpDeleteObj('networkset/' + networkSetUUID + '/members', undefined, networkUUIDS);\n }\n }, {\n key: \"updateNetworkSetSystemProperty\",\n value: function updateNetworkSetSystemProperty(networksetUUID, data) {\n return this._httpPutObj('networkset/' + networksetUUID + '/systemproperty', undefined, data);\n }\n /* undocumented functions. Might be changed ... */\n // layout update is a list of objects:\n // [{ node: 1, x: 100, y: 100}, {node: 2, x: 1003, y: 200 }...]\n\n }, {\n key: \"updateCartesianLayoutAspect\",\n value: function updateCartesianLayoutAspect(uuid, nodePositions) {\n // 1. get node coordinates from cy.js model in the format of cartesian aspect\n // 2. generate CX for the put request\n // 3. example\n // [{\n // \"numberVerification\": [\n // {\n // \"longNumber\": 283213721732712\n // }\n // ]\n // }, {\n // \"metaData\": [{\n // \"name\": \"cartesianLayout\", \"elementCount\": 100 // num nodes here\n // }],\n // \"cartesianLayout\": [{\n // \"node\": 100, \"x\": 23213.12, \"y\": 3234.5\n // }]\n // }]\n var cartesianLayoutUpdate = [CX1_HEADER, {\n metaData: [{\n name: 'cartesianLayout',\n elementCount: nodePositions.length\n }]\n }, {\n cartesianLayout: nodePositions\n }, {\n status: [{\n error: '',\n success: true\n }]\n }];\n return this._httpPutObj(\"network/\".concat(uuid, \"/aspects\"), undefined, cartesianLayoutUpdate);\n } // new v3 functions\n\n }, {\n key: \"getRandomEdges\",\n value: function getRandomEdges(uuid, limit, accessKey) {\n if (limit <= 0) throw new Error(\"Value of parameter limit has to be greater than 0.\");\n var parameters = {\n size: limit,\n method: \"random\"\n };\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/aspects/edges', parameters);\n }\n }, {\n key: \"getMetaData\",\n value: function getMetaData(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetProtectedObj('network/' + uuid + '/aspect', parameters);\n }\n }, {\n key: \"getAspectElements\",\n value: function getAspectElements(uuid, aspectName, limit, accessKey) {\n var parameters = {};\n\n if (limit !== undefined) {\n parameters = {\n size: limit\n };\n }\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/aspects/' + aspectName, parameters);\n }\n }, {\n key: \"getFilteredEdges\",\n value: function getFilteredEdges(uuid, columnName, valueString, operator, limit, order, format, accessKey) {\n var parameters = {};\n\n if (limit !== undefined) {\n parameters = {\n size: limit\n };\n }\n\n if (order !== undefined) {\n parameters['order'] = order;\n }\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n if (format !== undefined) {\n parameters['format'] = format;\n }\n\n var data = {\n \"name\": columnName,\n \"value\": valueString,\n \"operator\": operator\n };\n return this._httpPostV3ProtectedObj('/search/networks/' + uuid + '/edges', parameters, data);\n }\n }, {\n key: \"getCX2MetaData\",\n value: function getCX2MetaData(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/aspects', parameters);\n }\n }, {\n key: \"cancelDOIRequest\",\n value: function cancelDOIRequest(uuid) {\n var cancelBody = {\n type: \"Cancel_DOI\",\n networkId: uuid\n };\n return this._httpPostProtectedObj('admin/request', {}, cancelBody);\n } // unstable function to upload CX2 to NDEx\n\n }, {\n key: \"createNetworkFromRawCX2\",\n value: function createNetworkFromRawCX2(rawCX2) {\n var makePublic = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var config = {\n method: 'post',\n url: 'networks',\n baseURL: this._v3baseURL,\n params: {\n visibility: makePublic ? 'PUBLIC' : 'PRIVATE'\n }\n };\n\n this._setAuthHeader(config);\n\n config.data = rawCX2;\n return axios(config).then(function (res) {\n var location = res.headers.location;\n var uuid = location.split('/').pop();\n return {\n uuid: uuid\n };\n });\n }\n }, {\n key: \"updateNetworkFromRawCX2\",\n value: function updateNetworkFromRawCX2(uuid, rawCX2) {\n return this._httpPutV3Obj('networks/' + uuid, undefined, rawCX2);\n }\n }, {\n key: \"createCyWebWorkspace\",\n value: function createCyWebWorkspace(workspace) {\n var _this7 = this;\n\n return new Promise(function (resolve, reject) {\n _this7._httpPostV3ProtectedObj('workspaces', undefined, workspace).then(function (response) {\n // let uuidr = response.split('/');\n // let uuid = uuidr[uuidr.length - 1];\n return resolve(response);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"getCyWebWorkspace\",\n value: function getCyWebWorkspace(workspaceId) {\n return this._httpGetV3ProtectedObj('workspaces/' + workspaceId, {});\n }\n }, {\n key: \"deleteCyWebWorkspace\",\n value: function deleteCyWebWorkspace(workspaceId) {\n return this._httpDeleteV3Obj('workspaces/' + workspaceId, undefined);\n }\n }, {\n key: \"updateCyWebWorkspace\",\n value: function updateCyWebWorkspace(workspaceId, workspaceObj) {\n return this._httpPutV3Obj('workspaces/' + workspaceId, undefined, workspaceObj);\n }\n }, {\n key: \"updateCyWebWorkspaceName\",\n value: function updateCyWebWorkspaceName(workspaceId, newName) {\n return this._httpPutV3Obj('workspaces/' + workspaceId + '/name', undefined, {\n 'name': newName\n });\n }\n }, {\n key: \"updateCyWebWorkspaceNetworks\",\n value: function updateCyWebWorkspaceNetworks(workspaceId, networkIds) {\n return this._httpPutV3Obj('workspaces/' + workspaceId + '/networkids', undefined, networkIds);\n }\n }, {\n key: \"getUserCyWebWorkspaces\",\n value: function getUserCyWebWorkspaces() {\n var _this8 = this;\n\n return new Promise(function (resolve, reject) {\n _this8.getSignedInUser().then(function (user) {\n _this8._httpGetV3ProtectedObj('users/' + user.externalId + '/workspaces', {}).then(function (workspaceArray) {\n resolve(workspaceArray);\n }, function (err) {\n reject(err);\n });\n }, function (err) {\n reject(err);\n });\n });\n }\n }]);\n\n return NDEx;\n}();\n\nmodule.exports = {\n NDEx: NDEx\n};\n\n//# sourceURL=webpack://@js4cytoscape/ndex-client/./src/NDEx.js?");
|
|
129
129
|
|
|
130
130
|
/***/ }),
|
|
131
131
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* mime-db
|
|
3
|
+
* Copyright(c) 2014 Jonathan Ong
|
|
4
|
+
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
|
5
|
+
* MIT Licensed
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*!
|
|
9
|
+
* mime-types
|
|
10
|
+
* Copyright(c) 2014 Jonathan Ong
|
|
11
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
12
|
+
* MIT Licensed
|
|
13
|
+
*/
|
package/dist/ndexClient.js
CHANGED
|
@@ -26,7 +26,7 @@ eval("function _classCallCheck(instance, Constructor) { if (!(instance instanceo
|
|
|
26
26
|
\*********************/
|
|
27
27
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
28
28
|
|
|
29
|
-
eval("function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\nvar axios = __webpack_require__(/*! axios */ \"./node_modules/axios/dist/browser/axios.cjs\");\n\nvar CX1_HEADER = {\n numberVerification: [{\n \"longNumber\": 283213721732712\n }]\n};\n/**\n * NDEx client class.\n */\n\nvar NDEx = /*#__PURE__*/function () {\n function NDEx(hostprefix) {\n _classCallCheck(this, NDEx);\n\n if (hostprefix === undefined || hostprefix === null || hostprefix === '') {\n throw new Error('NDEx server host name or endpoint base URL is required in client constructor.');\n } // axios needs http to be at the front of the url.\n // Otherwise any request will be redirected to localhost and fail\n // with an ambiguous reason\n\n\n var httpRegex = new RegExp(\"^(http|https)://\", \"i\");\n\n if (!httpRegex.test(hostprefix)) {\n // throw new Error(`\"http://\" or \"https://\" must be prefixed to the input url: ${hostprefix}`);\n // we assume it is a host name\n if (hostprefix.indexOf('/') > -1) throw new Error('\"/\" are not allowed in host name.');\n hostprefix = \"https://\" + hostprefix + \"/v2\";\n }\n\n this._host = hostprefix;\n this._v3baseURL = this._host.substring(0, this.host.lastIndexOf('v2')) + 'v3';\n }\n\n _createClass(NDEx, [{\n key: \"host\",\n get: function get() {\n return this._host;\n }\n }, {\n key: \"googleAuth\",\n get: function get() {\n return this._googleAuth;\n }\n }, {\n key: \"SetGoogleAuth\",\n value: function SetGoogleAuth(googleAuthObj) {\n if (googleAuthObj !== undefined) {\n this._googleAuth = googleAuthObj;\n this._authType = 'g'; // valid values are 'g','b' or undefined\n }\n }\n }, {\n key: \"setAuthToken\",\n value: function setAuthToken(authToken) {\n if (authToken !== undefined) {\n this._authToken = authToken;\n this._authType = 'g'; // valid values are 'g','b' or undefined\n }\n }\n }, {\n key: \"authenticationType\",\n get: function get() {\n return this._authType;\n }\n }, {\n key: \"username\",\n get: function get() {\n return this._username;\n } // get authStr() { return this._authStr;}\n\n }, {\n key: \"password\",\n get: function get() {\n return this._password;\n }\n }, {\n key: \"setBasicAuth\",\n value: function setBasicAuth(accountname, password) {\n if (accountname !== undefined && accountname != null && accountname !== '') {\n this._username = accountname;\n this._password = password;\n this._authType = 'b'; // this._authStr = 'Basic ' + btoa(username + ':' + password);\n\n return;\n }\n\n this._username = undefined;\n this._password = undefined;\n this._authType = undefined; // this._authStr = undefined;\n }\n }, {\n key: \"_httpGetOpenObj\",\n value: function _httpGetOpenObj(URL) {\n var APIEndPointPrefix = this.host;\n return new Promise(function (resolve, reject) {\n axios({\n method: 'get',\n url: URL,\n baseURL: APIEndPointPrefix\n }).then(function (response) {\n if (response.status === 200) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n } // access endpoints that supports authentication\n\n }, {\n key: \"_getIdToken\",\n value: function _getIdToken() {\n return this._authToken ? this._authToken : this._googleAuth.getAuthInstance().currentUser.get().getAuthResponse().id_token;\n }\n }, {\n key: \"_setAuthHeader\",\n value: function _setAuthHeader(config) {\n if (config['headers'] === undefined) {\n config['headers'] = {};\n }\n\n config['headers']['setAuthHeader'] = false;\n\n if (this._authType === 'b') {\n config['auth'] = {\n username: this.username,\n password: this.password\n };\n } else if (this.authenticationType === 'g') {\n config['headers']['Authorization'] = 'Bearer ' + this._getIdToken();\n }\n }\n }, {\n key: \"_httpGetProtectedObjAux\",\n value: function _httpGetProtectedObjAux(prefix, URL, parameters) {\n var config = {\n method: 'get',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status === 200) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n }, {\n key: \"_httpGetV3ProtectedObj\",\n value: function _httpGetV3ProtectedObj(URL, parameters) {\n return this._httpGetProtectedObjAux(this._v3baseURL, URL, parameters);\n }\n }, {\n key: \"_httpGetProtectedObj\",\n value: function _httpGetProtectedObj(URL, parameters) {\n return this._httpGetProtectedObjAux(this.host, URL, parameters);\n }\n }, {\n key: \"_httpPostProtectedObjAux\",\n value: function _httpPostProtectedObjAux(prefix, URL, parameters, data) {\n var config = {\n method: 'post',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n config.data = data;\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status >= 200 && response.status <= 299) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n }, {\n key: \"_httpPostProtectedObj\",\n value: function _httpPostProtectedObj(URL, parameters, data) {\n return this._httpPostProtectedObjAux(this.host, URL, parameters, data);\n }\n }, {\n key: \"_httpPostV3ProtectedObj\",\n value: function _httpPostV3ProtectedObj(URL, parameters, data) {\n return this._httpPostProtectedObjAux(this._v3baseURL, URL, parameters, data);\n }\n }, {\n key: \"_httpPutObjAux\",\n value: function _httpPutObjAux(prefix, URL, parameters, data) {\n var config = {\n method: 'put',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n config.data = data;\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status >= 200 && response.status <= 299) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n }, {\n key: \"_httpPutObj\",\n value: function _httpPutObj(URL, parameters, data) {\n return this._httpPutObjAux(this.host, URL, parameters, data);\n }\n }, {\n key: \"_httpPutV3Obj\",\n value: function _httpPutV3Obj(URL, parameters, data) {\n return this._httpPutObjAux(this._v3baseURL, URL, parameters, data);\n }\n }, {\n key: \"_httpDeleteObj\",\n value: function _httpDeleteObj(URL, parameters, data) {\n return this._httpDeleteObjAux(this.host, URL, parameters, data);\n }\n }, {\n key: \"_httpDeleteV3Obj\",\n value: function _httpDeleteV3Obj(URL, parameters) {\n return this._httpDeleteObjAux(this._v3baseURL, URL, parameters, undefined);\n }\n }, {\n key: \"_httpDeleteObjAux\",\n value: function _httpDeleteObjAux(prefix, URL, parameters, data) {\n var config = {\n method: 'delete',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n if (data !== undefined) {\n config['data'] = data;\n }\n\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status >= 200 && response.status <= 299) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n /* admin functions */\n\n }, {\n key: \"getStatus\",\n value: function getStatus() {\n return this._httpGetOpenObj('admin/status');\n }\n /* user functions */\n\n }, {\n key: \"getSignedInUser\",\n value: function getSignedInUser() {\n if (this._authType == null) {\n throw new Error('Authentication parameters are missing in NDEx client.');\n }\n\n return this._httpGetProtectedObj('user', {\n valid: true\n });\n }\n }, {\n key: \"getUser\",\n value: function getUser(uuid) {\n return this._httpGetProtectedObj('user/' + uuid);\n }\n }, {\n key: \"getAccountPageNetworks\",\n value: function getAccountPageNetworks(offset, limit) {\n var _this = this;\n\n return new Promise(function (resolve, reject) {\n _this.getSignedInUser().then(function (user) {\n var params = {};\n\n if (offset !== undefined) {\n params.offset = offset;\n }\n\n if (limit !== undefined) {\n params.limit = limit;\n }\n\n _this._httpGetProtectedObj('/user/' + user.externalId + '/networksummary', params).then(function (networkArray) {\n resolve(networkArray);\n }, function (err) {\n reject(err);\n });\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"getAccountPageNetworksByUUID\",\n value: function getAccountPageNetworksByUUID(uuid, offset, limit) {\n var params = {};\n\n if (offset !== undefined) {\n params.offset = offset;\n }\n\n if (limit !== undefined) {\n params.limit = limit;\n }\n\n return this._httpGetProtectedObj('user/' + uuid + '/networksummary', params);\n }\n /* group functions */\n // return the UUID of the created group to the resolver\n\n }, {\n key: \"createGroup\",\n value: function createGroup(group) {\n var _this2 = this;\n\n return new Promise(function (resolve, reject) {\n _this2._httpPostProtectedObj('group', undefined, group).then(function (response) {\n var uuidr = response.split('/');\n var uuid = uuidr[uuidr.length - 1];\n return resolve(uuid);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"getGroup\",\n value: function getGroup(uuid) {\n return this._httpGetProtectedObj('group/' + uuid);\n }\n }, {\n key: \"updateGroup\",\n value: function updateGroup(group) {\n var _this3 = this;\n\n return new Promise(function (resolve, reject) {\n _this3._httpPutObj('group/' + group.externalId, undefined, group).then(function (response) {\n return resolve(response);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"deleteGroup\",\n value: function deleteGroup(uuid) {\n return this._httpDeleteObj('group/' + uuid);\n }\n /* network functions */\n\n }, {\n key: \"getRawNetwork\",\n value: function getRawNetwork(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetProtectedObj('network/' + uuid, parameters);\n }\n }, {\n key: \"getCX2Network\",\n value: function getCX2Network(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid, parameters);\n }\n }, {\n key: \"getNetworkSummary\",\n value: function getNetworkSummary(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetProtectedObj('network/' + uuid + '/summary', parameters);\n }\n }, {\n key: \"getNetworkV3Summary\",\n value: function getNetworkV3Summary(uuid, accessKey, fmt) {\n var parameters = {\n format: fmt != null ? fmt : \"FULL\"\n };\n\n if (accessKey != null) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/summary', parameters);\n }\n }, {\n key: \"getAttributesOfSelectedNodes\",\n value: function getAttributesOfSelectedNodes(uuid, _ref, accessKey) {\n var nodeIds = _ref.ids,\n names = _ref.attributeNames;\n var parameters = {};\n\n if (accessKey != null) {\n parameters['accesskey'] = accessKey;\n }\n\n var data = {\n \"ids\": nodeIds,\n \"attributeNames\": names\n };\n return this._httpPostV3ProtectedObj('/search/networks/' + uuid + '/nodes', parameters, data);\n }\n }, {\n key: \"createNetworkFromRawCX\",\n value: function createNetworkFromRawCX(rawCX, parameters) {\n var _this4 = this;\n\n return new Promise(function (resolve, reject) {\n _this4._httpPostProtectedObj('network', parameters, rawCX).then(function (response) {\n var uuidr = response.split('/');\n var uuid = uuidr[uuidr.length - 1];\n return resolve(uuid);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"updateNetworkFromRawCX\",\n value: function updateNetworkFromRawCX(uuid, rawcx) {\n return this._httpPutObj('network/' + uuid, undefined, rawcx);\n }\n }, {\n key: \"deleteNetwork\",\n value: function deleteNetwork(uuid) {\n return this._httpDeleteObj('network/' + uuid);\n }\n /* task functions */\n\n /* search functions */\n\n }, {\n key: \"searchUsers\",\n value: function searchUsers(searchTerms, start, size) {\n var params = {};\n\n if (start !== undefined) {\n params.start = start;\n }\n\n if (size !== undefined) {\n params.limit = size;\n }\n\n var data = {\n searchString: searchTerms\n };\n return this._httpPostProtectedObj('search/user', params, data);\n }\n }, {\n key: \"searchGroups\",\n value: function searchGroups(searchTerms, start, size) {\n var params = {};\n\n if (start !== undefined) {\n params.start = start;\n }\n\n if (size !== undefined) {\n params.limit = size;\n }\n\n var data = {\n searchString: searchTerms\n };\n return this._httpPostProtectedObj('search/group', params, data);\n }\n }, {\n key: \"searchNetworks\",\n value: function searchNetworks(searchTerms, start, size, optionalParameters) {\n var params = {};\n\n if (start !== undefined) {\n params.start = start;\n }\n\n if (size !== undefined) {\n params.limit = size;\n }\n\n var data = {\n searchString: searchTerms\n };\n\n if (optionalParameters !== undefined) {\n if (optionalParameters.permission !== undefined) {\n data.permission = optionalParameters.permission;\n }\n\n if (optionalParameters.includeGroups !== undefined) {\n data.includeGroups = optionalParameters.includeGroups;\n }\n\n if (optionalParameters.accountName !== undefined) {\n data.accountName = optionalParameters.accountName;\n }\n }\n\n return this._httpPostProtectedObj('search/network', params, data);\n }\n }, {\n key: \"neighborhoodQuery\",\n value: function neighborhoodQuery(uuid, searchTerms, saveResult, parameters) {\n var outputCX2 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n var params = {};\n\n if (saveResult !== undefined && saveResult === true) {\n params.save = true;\n }\n\n var data = {\n searchString: searchTerms,\n searchDepth: 1\n };\n\n if (parameters !== undefined) {\n if (parameters.searchDepth !== undefined) {\n data.searchDepth = parameters.searchDepth;\n }\n\n if (parameters.edgeLimit !== undefined) {\n data.edgeLimit = parameters.edgeLimit;\n }\n\n if (parameters.errorWhenLimitIsOver !== undefined) {\n data.errorWhenLimitIsOver = parameters.errorWhenLimitIsOver;\n }\n\n if (parameters.directOnly !== undefined) {\n data.directOnly = parameters.directOnly;\n }\n\n if (parameters.nodeIds != null) {\n data.nodeIds = parameters.nodeIds;\n }\n }\n\n if (outputCX2) return this._httpPostV3ProtectedObj('search/network/' + uuid + '/query', params, data);\n return this._httpPostProtectedObj('search/network/' + uuid + '/query', params, data);\n }\n }, {\n key: \"interConnectQuery\",\n value: function interConnectQuery(uuid, searchTerms, saveResult, parameters) {\n var outputCX2 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n var params = {};\n\n if (saveResult !== undefined && saveResult === true) {\n params.save = true;\n }\n\n var data = {\n searchString: searchTerms\n };\n\n if (parameters !== undefined) {\n if (parameters.edgeLimit !== undefined) {\n data.edgeLimit = parameters.edgeLimit;\n }\n\n if (parameters.errorWhenLimitIsOver !== undefined) {\n data.errorWhenLimitIsOver = parameters.errorWhenLimitIsOver;\n }\n\n if (parameters.nodeIds != null) {\n data.nodeIds = parameters.nodeIds;\n }\n }\n\n if (outputCX2) return this._httpPostV3ProtectedObj('search/networks/' + uuid + '/interconnectquery', params, data);\n return this._httpPostProtectedObj('search/network/' + uuid + '/interconnectquery', params, data);\n }\n /* batch functions */\n\n }, {\n key: \"getUsersByUUIDs\",\n value: function getUsersByUUIDs(uuidList) {\n return this._httpPostProtectedObj('batch/user', undefined, uuidList);\n }\n }, {\n key: \"getGroupsByUUIDs\",\n value: function getGroupsByUUIDs(uuidList) {\n return this._httpPostProtectedObj('batch/group', undefined, uuidList);\n }\n }, {\n key: \"getNetworkSummariesByUUIDs\",\n value: function getNetworkSummariesByUUIDs(uuidList, accessKey) {\n var parameter = accessKey === undefined ? undefined : {\n accesskey: accessKey\n };\n return this._httpPostProtectedObj('batch/network/summary', parameter, uuidList);\n }\n }, {\n key: \"getNetworkSummariesV3ByUUIDs\",\n value: function getNetworkSummariesV3ByUUIDs(uuidList, accessKey, fmt) {\n var parameter = {\n format: fmt == undefined ? \"FULL\" : fmt\n };\n if (accessKey != null) parameter['accesskey'] = accessKey;\n return this._httpPostV3ProtectedObj('batch/networks/summary', parameter, uuidList);\n }\n }, {\n key: \"getNetworkPermissionsByUUIDs\",\n value: function getNetworkPermissionsByUUIDs(uuidList) {\n return this._httpPostProtectedObj('batch/network/permission', undefined, uuidList);\n }\n }, {\n key: \"exportNetworks\",\n value: function exportNetworks(exportJob) {\n return this._httpPostProtectedObj('batch/network/export', undefined, exportJob);\n }\n /* network set functions */\n\n }, {\n key: \"createNetworkSet\",\n value: function createNetworkSet(_ref2) {\n var _this5 = this;\n\n var name = _ref2.name,\n description = _ref2.description;\n return new Promise(function (resolve, reject) {\n _this5._httpPostProtectedObj('networkset', undefined, {\n name: name,\n description: description\n }).then(function (response) {\n var uuidr = response.split('/');\n var uuid = uuidr[uuidr.length - 1];\n return resolve(uuid);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"updateNetworkSet\",\n value: function updateNetworkSet(uuid, _ref3) {\n var _this6 = this;\n\n var name = _ref3.name,\n description = _ref3.description;\n return new Promise(function (resolve, reject) {\n _this6._httpPutObj('networkset/' + uuid, undefined, {\n uuid: uuid,\n name: name,\n description: description\n }).then(function (response) {\n return resolve(response);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"deleteNetworkSet\",\n value: function deleteNetworkSet(uuid) {\n return this._httpDeleteObj('networkset/' + uuid);\n }\n }, {\n key: \"getNetworkSet\",\n value: function getNetworkSet(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetProtectedObj('networkset/' + uuid, parameters);\n }\n }, {\n key: \"addToNetworkSet\",\n value: function addToNetworkSet(networkSetUUID, networkUUIDs) {\n return this._httpPostProtectedObj('networkset/' + networkSetUUID + '/members', undefined, networkUUIDs);\n }\n }, {\n key: \"deleteFromNetworkSet\",\n value: function deleteFromNetworkSet(networkSetUUID, networkUUIDS) {\n return this._httpDeleteObj('networkset/' + networkSetUUID + '/members', undefined, networkUUIDS);\n }\n }, {\n key: \"updateNetworkSetSystemProperty\",\n value: function updateNetworkSetSystemProperty(networksetUUID, data) {\n return this._httpPutObj('networkset/' + networksetUUID + '/systemproperty', undefined, data);\n }\n /* undocumented functions. Might be changed ... */\n // layout update is a list of objects:\n // [{ node: 1, x: 100, y: 100}, {node: 2, x: 1003, y: 200 }...]\n\n }, {\n key: \"updateCartesianLayoutAspect\",\n value: function updateCartesianLayoutAspect(uuid, nodePositions) {\n // 1. get node coordinates from cy.js model in the format of cartesian aspect\n // 2. generate CX for the put request\n // 3. example\n // [{\n // \"numberVerification\": [\n // {\n // \"longNumber\": 283213721732712\n // }\n // ]\n // }, {\n // \"metaData\": [{\n // \"name\": \"cartesianLayout\", \"elementCount\": 100 // num nodes here\n // }],\n // \"cartesianLayout\": [{\n // \"node\": 100, \"x\": 23213.12, \"y\": 3234.5\n // }]\n // }]\n var cartesianLayoutUpdate = [CX1_HEADER, {\n metaData: [{\n name: 'cartesianLayout',\n elementCount: nodePositions.length\n }]\n }, {\n cartesianLayout: nodePositions\n }, {\n status: [{\n error: '',\n success: true\n }]\n }];\n return this._httpPutObj(\"network/\".concat(uuid, \"/aspects\"), undefined, cartesianLayoutUpdate);\n } // new v3 functions\n\n }, {\n key: \"getRandomEdges\",\n value: function getRandomEdges(uuid, limit, accessKey) {\n if (limit <= 0) throw new Error(\"Value of parameter limit has to be greater than 0.\");\n var parameters = {\n size: limit,\n method: \"random\"\n };\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/aspects/edges', parameters);\n }\n }, {\n key: \"getMetaData\",\n value: function getMetaData(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetProtectedObj('network/' + uuid + '/aspect', parameters);\n }\n }, {\n key: \"getAspectElements\",\n value: function getAspectElements(uuid, aspectName, limit, accessKey) {\n var parameters = {};\n\n if (limit !== undefined) {\n parameters = {\n size: limit\n };\n }\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/aspects/' + aspectName, parameters);\n }\n }, {\n key: \"getFilteredEdges\",\n value: function getFilteredEdges(uuid, columnName, valueString, operator, limit, order, format, accessKey) {\n var parameters = {};\n\n if (limit !== undefined) {\n parameters = {\n size: limit\n };\n }\n\n if (order !== undefined) {\n parameters['order'] = order;\n }\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n if (format !== undefined) {\n parameters['format'] = format;\n }\n\n var data = {\n \"name\": columnName,\n \"value\": valueString,\n \"operator\": operator\n };\n return this._httpPostV3ProtectedObj('/search/networks/' + uuid + '/edges', parameters, data);\n }\n }, {\n key: \"getCX2MetaData\",\n value: function getCX2MetaData(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/aspects', parameters);\n }\n }, {\n key: \"cancelDOIRequest\",\n value: function cancelDOIRequest(uuid) {\n var cancelBody = {\n type: \"Cancel_DOI\",\n networkId: uuid\n };\n return this._httpPostProtectedObj('admin/request', {}, cancelBody);\n } // unstable function to upload CX2 to NDEx\n\n }, {\n key: \"createNetworkFromRawCX2\",\n value: function createNetworkFromRawCX2(rawCX2) {\n var makePublic = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var config = {\n method: 'post',\n url: 'networks',\n baseURL: this._v3baseURL,\n params: {\n visibility: makePublic ? 'PUBLIC' : 'PRIVATE'\n }\n };\n\n this._setAuthHeader(config);\n\n config.data = rawCX2;\n return axios(config).then(function (res) {\n var location = res.headers.location;\n var uuid = location.split('/').pop();\n return {\n uuid: uuid\n };\n });\n }\n }, {\n key: \"updateNetworkFromRawCX2\",\n value: function updateNetworkFromRawCX2(uuid, rawCX2) {\n return this._httpPutV3Obj('networks/' + uuid, undefined, rawCX2);\n }\n }, {\n key: \"createCyWebWorkspace\",\n value: function createCyWebWorkspace(workspace) {\n var _this7 = this;\n\n return new Promise(function (resolve, reject) {\n _this7._httpPostV3ProtectedObj('workspaces', undefined, workspace).then(function (response) {\n // let uuidr = response.split('/');\n // let uuid = uuidr[uuidr.length - 1];\n return resolve(response);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"getCyWebWorkspace\",\n value: function getCyWebWorkspace(workspaceId) {\n return this._httpGetV3ProtectedObj('workspaces/' + workspaceId, {});\n }\n }, {\n key: \"deleteCyWebWorkspace\",\n value: function deleteCyWebWorkspace(workspaceId) {\n return this._httpDeleteV3Obj('workspaces/' + workspaceId, undefined);\n }\n }, {\n key: \"updateCyWebWorkspace\",\n value: function updateCyWebWorkspace(workspaceId, workspaceObj) {\n return this._httpPutV3Obj('workspaces/' + workspaceId, undefined, workspaceObj);\n }\n }, {\n key: \"updateCyWebWorkspaceName\",\n value: function updateCyWebWorkspaceName(workspaceId, newName) {\n return this._httpPutV3Obj('workspaces/' + workspaceId + '/name', undefined, {\n 'name': newName\n });\n }\n }, {\n key: \"updateCyWebWorkspaceNetworks\",\n value: function updateCyWebWorkspaceNetworks(workspaceId, networkIds) {\n return this._httpPutV3Obj('workspaces/' + workspaceId + '/networkids', undefined, networkIds);\n }\n }]);\n\n return NDEx;\n}();\n\nmodule.exports = {\n NDEx: NDEx\n};\n\n//# sourceURL=webpack://ndexClient/./src/NDEx.js?");
|
|
29
|
+
eval("function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\nvar axios = __webpack_require__(/*! axios */ \"./node_modules/axios/dist/browser/axios.cjs\");\n\nvar CX1_HEADER = {\n numberVerification: [{\n \"longNumber\": 283213721732712\n }]\n};\n/**\n * NDEx client class.\n */\n\nvar NDEx = /*#__PURE__*/function () {\n function NDEx(hostprefix) {\n _classCallCheck(this, NDEx);\n\n if (hostprefix === undefined || hostprefix === null || hostprefix === '') {\n throw new Error('NDEx server host name or endpoint base URL is required in client constructor.');\n } // axios needs http to be at the front of the url.\n // Otherwise any request will be redirected to localhost and fail\n // with an ambiguous reason\n\n\n var httpRegex = new RegExp(\"^(http|https)://\", \"i\");\n\n if (!httpRegex.test(hostprefix)) {\n // throw new Error(`\"http://\" or \"https://\" must be prefixed to the input url: ${hostprefix}`);\n // we assume it is a host name\n if (hostprefix.indexOf('/') > -1) throw new Error('\"/\" are not allowed in host name.');\n hostprefix = \"https://\" + hostprefix + \"/v2\";\n }\n\n this._host = hostprefix;\n this._v3baseURL = this._host.substring(0, this.host.lastIndexOf('v2')) + 'v3';\n }\n\n _createClass(NDEx, [{\n key: \"host\",\n get: function get() {\n return this._host;\n }\n }, {\n key: \"googleAuth\",\n get: function get() {\n return this._googleAuth;\n }\n }, {\n key: \"SetGoogleAuth\",\n value: function SetGoogleAuth(googleAuthObj) {\n if (googleAuthObj !== undefined) {\n this._googleAuth = googleAuthObj;\n this._authType = 'g'; // valid values are 'g','b' or undefined\n }\n }\n }, {\n key: \"setAuthToken\",\n value: function setAuthToken(authToken) {\n if (authToken !== undefined) {\n this._authToken = authToken;\n this._authType = 'g'; // valid values are 'g','b' or undefined\n }\n }\n }, {\n key: \"authenticationType\",\n get: function get() {\n return this._authType;\n }\n }, {\n key: \"username\",\n get: function get() {\n return this._username;\n } // get authStr() { return this._authStr;}\n\n }, {\n key: \"password\",\n get: function get() {\n return this._password;\n }\n }, {\n key: \"setBasicAuth\",\n value: function setBasicAuth(accountname, password) {\n if (accountname !== undefined && accountname != null && accountname !== '') {\n this._username = accountname;\n this._password = password;\n this._authType = 'b'; // this._authStr = 'Basic ' + btoa(username + ':' + password);\n\n return;\n }\n\n this._username = undefined;\n this._password = undefined;\n this._authType = undefined; // this._authStr = undefined;\n }\n }, {\n key: \"_httpGetOpenObj\",\n value: function _httpGetOpenObj(URL) {\n var APIEndPointPrefix = this.host;\n return new Promise(function (resolve, reject) {\n axios({\n method: 'get',\n url: URL,\n baseURL: APIEndPointPrefix\n }).then(function (response) {\n if (response.status === 200) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n } // access endpoints that supports authentication\n\n }, {\n key: \"_getIdToken\",\n value: function _getIdToken() {\n return this._authToken ? this._authToken : this._googleAuth.getAuthInstance().currentUser.get().getAuthResponse().id_token;\n }\n }, {\n key: \"_setAuthHeader\",\n value: function _setAuthHeader(config) {\n if (config['headers'] === undefined) {\n config['headers'] = {};\n }\n\n config['headers']['setAuthHeader'] = false;\n\n if (this._authType === 'b') {\n config['auth'] = {\n username: this.username,\n password: this.password\n };\n } else if (this.authenticationType === 'g') {\n config['headers']['Authorization'] = 'Bearer ' + this._getIdToken();\n }\n }\n }, {\n key: \"_httpGetProtectedObjAux\",\n value: function _httpGetProtectedObjAux(prefix, URL, parameters) {\n var config = {\n method: 'get',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status === 200) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n }, {\n key: \"_httpGetV3ProtectedObj\",\n value: function _httpGetV3ProtectedObj(URL, parameters) {\n return this._httpGetProtectedObjAux(this._v3baseURL, URL, parameters);\n }\n }, {\n key: \"_httpGetProtectedObj\",\n value: function _httpGetProtectedObj(URL, parameters) {\n return this._httpGetProtectedObjAux(this.host, URL, parameters);\n }\n }, {\n key: \"_httpPostProtectedObjAux\",\n value: function _httpPostProtectedObjAux(prefix, URL, parameters, data) {\n var config = {\n method: 'post',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n config.data = data;\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status >= 200 && response.status <= 299) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n }, {\n key: \"_httpPostProtectedObj\",\n value: function _httpPostProtectedObj(URL, parameters, data) {\n return this._httpPostProtectedObjAux(this.host, URL, parameters, data);\n }\n }, {\n key: \"_httpPostV3ProtectedObj\",\n value: function _httpPostV3ProtectedObj(URL, parameters, data) {\n return this._httpPostProtectedObjAux(this._v3baseURL, URL, parameters, data);\n }\n }, {\n key: \"_httpPutObjAux\",\n value: function _httpPutObjAux(prefix, URL, parameters, data) {\n var config = {\n method: 'put',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n config.data = data;\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status >= 200 && response.status <= 299) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n }, {\n key: \"_httpPutObj\",\n value: function _httpPutObj(URL, parameters, data) {\n return this._httpPutObjAux(this.host, URL, parameters, data);\n }\n }, {\n key: \"_httpPutV3Obj\",\n value: function _httpPutV3Obj(URL, parameters, data) {\n return this._httpPutObjAux(this._v3baseURL, URL, parameters, data);\n }\n }, {\n key: \"_httpDeleteObj\",\n value: function _httpDeleteObj(URL, parameters, data) {\n return this._httpDeleteObjAux(this.host, URL, parameters, data);\n }\n }, {\n key: \"_httpDeleteV3Obj\",\n value: function _httpDeleteV3Obj(URL, parameters) {\n return this._httpDeleteObjAux(this._v3baseURL, URL, parameters, undefined);\n }\n }, {\n key: \"_httpDeleteObjAux\",\n value: function _httpDeleteObjAux(prefix, URL, parameters, data) {\n var config = {\n method: 'delete',\n url: URL,\n baseURL: prefix\n };\n\n this._setAuthHeader(config);\n\n if (parameters !== undefined) {\n config['params'] = parameters;\n }\n\n if (data !== undefined) {\n config['data'] = data;\n }\n\n return new Promise(function (resolve, reject) {\n axios(config).then(function (response) {\n if (response.status >= 200 && response.status <= 299) {\n return resolve(response.data);\n }\n\n return reject(response);\n }, function (response) {\n return reject(response);\n });\n });\n }\n /* admin functions */\n\n }, {\n key: \"getStatus\",\n value: function getStatus() {\n return this._httpGetOpenObj('admin/status');\n }\n /* user functions */\n\n }, {\n key: \"getSignedInUser\",\n value: function getSignedInUser() {\n if (this._authType == null) {\n throw new Error('Authentication parameters are missing in NDEx client.');\n }\n\n return this._httpGetProtectedObj('user', {\n valid: true\n });\n }\n }, {\n key: \"getUser\",\n value: function getUser(uuid) {\n return this._httpGetProtectedObj('user/' + uuid);\n }\n }, {\n key: \"getAccountPageNetworks\",\n value: function getAccountPageNetworks(offset, limit) {\n var _this = this;\n\n return new Promise(function (resolve, reject) {\n _this.getSignedInUser().then(function (user) {\n var params = {};\n\n if (offset !== undefined) {\n params.offset = offset;\n }\n\n if (limit !== undefined) {\n params.limit = limit;\n }\n\n _this._httpGetProtectedObj('/user/' + user.externalId + '/networksummary', params).then(function (networkArray) {\n resolve(networkArray);\n }, function (err) {\n reject(err);\n });\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"getAccountPageNetworksByUUID\",\n value: function getAccountPageNetworksByUUID(uuid, offset, limit) {\n var params = {};\n\n if (offset !== undefined) {\n params.offset = offset;\n }\n\n if (limit !== undefined) {\n params.limit = limit;\n }\n\n return this._httpGetProtectedObj('user/' + uuid + '/networksummary', params);\n }\n /* group functions */\n // return the UUID of the created group to the resolver\n\n }, {\n key: \"createGroup\",\n value: function createGroup(group) {\n var _this2 = this;\n\n return new Promise(function (resolve, reject) {\n _this2._httpPostProtectedObj('group', undefined, group).then(function (response) {\n var uuidr = response.split('/');\n var uuid = uuidr[uuidr.length - 1];\n return resolve(uuid);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"getGroup\",\n value: function getGroup(uuid) {\n return this._httpGetProtectedObj('group/' + uuid);\n }\n }, {\n key: \"updateGroup\",\n value: function updateGroup(group) {\n var _this3 = this;\n\n return new Promise(function (resolve, reject) {\n _this3._httpPutObj('group/' + group.externalId, undefined, group).then(function (response) {\n return resolve(response);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"deleteGroup\",\n value: function deleteGroup(uuid) {\n return this._httpDeleteObj('group/' + uuid);\n }\n /* network functions */\n\n }, {\n key: \"getRawNetwork\",\n value: function getRawNetwork(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetProtectedObj('network/' + uuid, parameters);\n }\n }, {\n key: \"getCX2Network\",\n value: function getCX2Network(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid, parameters);\n }\n }, {\n key: \"getNetworkSummary\",\n value: function getNetworkSummary(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetProtectedObj('network/' + uuid + '/summary', parameters);\n }\n }, {\n key: \"getNetworkV3Summary\",\n value: function getNetworkV3Summary(uuid, accessKey, fmt) {\n var parameters = {\n format: fmt != null ? fmt : \"FULL\"\n };\n\n if (accessKey != null) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/summary', parameters);\n }\n }, {\n key: \"getAttributesOfSelectedNodes\",\n value: function getAttributesOfSelectedNodes(uuid, _ref, accessKey) {\n var nodeIds = _ref.ids,\n names = _ref.attributeNames;\n var parameters = {};\n\n if (accessKey != null) {\n parameters['accesskey'] = accessKey;\n }\n\n var data = {\n \"ids\": nodeIds,\n \"attributeNames\": names\n };\n return this._httpPostV3ProtectedObj('/search/networks/' + uuid + '/nodes', parameters, data);\n }\n }, {\n key: \"createNetworkFromRawCX\",\n value: function createNetworkFromRawCX(rawCX, parameters) {\n var _this4 = this;\n\n return new Promise(function (resolve, reject) {\n _this4._httpPostProtectedObj('network', parameters, rawCX).then(function (response) {\n var uuidr = response.split('/');\n var uuid = uuidr[uuidr.length - 1];\n return resolve(uuid);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"updateNetworkFromRawCX\",\n value: function updateNetworkFromRawCX(uuid, rawcx) {\n return this._httpPutObj('network/' + uuid, undefined, rawcx);\n }\n }, {\n key: \"deleteNetwork\",\n value: function deleteNetwork(uuid) {\n return this._httpDeleteObj('network/' + uuid);\n }\n /* task functions */\n\n /* search functions */\n\n }, {\n key: \"searchUsers\",\n value: function searchUsers(searchTerms, start, size) {\n var params = {};\n\n if (start !== undefined) {\n params.start = start;\n }\n\n if (size !== undefined) {\n params.limit = size;\n }\n\n var data = {\n searchString: searchTerms\n };\n return this._httpPostProtectedObj('search/user', params, data);\n }\n }, {\n key: \"searchGroups\",\n value: function searchGroups(searchTerms, start, size) {\n var params = {};\n\n if (start !== undefined) {\n params.start = start;\n }\n\n if (size !== undefined) {\n params.limit = size;\n }\n\n var data = {\n searchString: searchTerms\n };\n return this._httpPostProtectedObj('search/group', params, data);\n }\n }, {\n key: \"searchNetworks\",\n value: function searchNetworks(searchTerms, start, size, optionalParameters) {\n var params = {};\n\n if (start !== undefined) {\n params.start = start;\n }\n\n if (size !== undefined) {\n params.limit = size;\n }\n\n var data = {\n searchString: searchTerms\n };\n\n if (optionalParameters !== undefined) {\n if (optionalParameters.permission !== undefined) {\n data.permission = optionalParameters.permission;\n }\n\n if (optionalParameters.includeGroups !== undefined) {\n data.includeGroups = optionalParameters.includeGroups;\n }\n\n if (optionalParameters.accountName !== undefined) {\n data.accountName = optionalParameters.accountName;\n }\n }\n\n return this._httpPostProtectedObj('search/network', params, data);\n }\n }, {\n key: \"neighborhoodQuery\",\n value: function neighborhoodQuery(uuid, searchTerms, saveResult, parameters) {\n var outputCX2 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n var params = {};\n\n if (saveResult !== undefined && saveResult === true) {\n params.save = true;\n }\n\n var data = {\n searchString: searchTerms,\n searchDepth: 1\n };\n\n if (parameters !== undefined) {\n if (parameters.searchDepth !== undefined) {\n data.searchDepth = parameters.searchDepth;\n }\n\n if (parameters.edgeLimit !== undefined) {\n data.edgeLimit = parameters.edgeLimit;\n }\n\n if (parameters.errorWhenLimitIsOver !== undefined) {\n data.errorWhenLimitIsOver = parameters.errorWhenLimitIsOver;\n }\n\n if (parameters.directOnly !== undefined) {\n data.directOnly = parameters.directOnly;\n }\n\n if (parameters.nodeIds != null) {\n data.nodeIds = parameters.nodeIds;\n }\n }\n\n if (outputCX2) return this._httpPostV3ProtectedObj('search/network/' + uuid + '/query', params, data);\n return this._httpPostProtectedObj('search/network/' + uuid + '/query', params, data);\n }\n }, {\n key: \"interConnectQuery\",\n value: function interConnectQuery(uuid, searchTerms, saveResult, parameters) {\n var outputCX2 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n var params = {};\n\n if (saveResult !== undefined && saveResult === true) {\n params.save = true;\n }\n\n var data = {\n searchString: searchTerms\n };\n\n if (parameters !== undefined) {\n if (parameters.edgeLimit !== undefined) {\n data.edgeLimit = parameters.edgeLimit;\n }\n\n if (parameters.errorWhenLimitIsOver !== undefined) {\n data.errorWhenLimitIsOver = parameters.errorWhenLimitIsOver;\n }\n\n if (parameters.nodeIds != null) {\n data.nodeIds = parameters.nodeIds;\n }\n }\n\n if (outputCX2) return this._httpPostV3ProtectedObj('search/networks/' + uuid + '/interconnectquery', params, data);\n return this._httpPostProtectedObj('search/network/' + uuid + '/interconnectquery', params, data);\n }\n /* batch functions */\n\n }, {\n key: \"getUsersByUUIDs\",\n value: function getUsersByUUIDs(uuidList) {\n return this._httpPostProtectedObj('batch/user', undefined, uuidList);\n }\n }, {\n key: \"getGroupsByUUIDs\",\n value: function getGroupsByUUIDs(uuidList) {\n return this._httpPostProtectedObj('batch/group', undefined, uuidList);\n }\n }, {\n key: \"getNetworkSummariesByUUIDs\",\n value: function getNetworkSummariesByUUIDs(uuidList, accessKey) {\n var parameter = accessKey === undefined ? undefined : {\n accesskey: accessKey\n };\n return this._httpPostProtectedObj('batch/network/summary', parameter, uuidList);\n }\n }, {\n key: \"getNetworkSummariesV3ByUUIDs\",\n value: function getNetworkSummariesV3ByUUIDs(uuidList, accessKey, fmt) {\n var parameter = {\n format: fmt == undefined ? \"FULL\" : fmt\n };\n if (accessKey != null) parameter['accesskey'] = accessKey;\n return this._httpPostV3ProtectedObj('batch/networks/summary', parameter, uuidList);\n }\n }, {\n key: \"getNetworkPermissionsByUUIDs\",\n value: function getNetworkPermissionsByUUIDs(uuidList) {\n return this._httpPostProtectedObj('batch/network/permission', undefined, uuidList);\n }\n }, {\n key: \"exportNetworks\",\n value: function exportNetworks(exportJob) {\n return this._httpPostProtectedObj('batch/network/export', undefined, exportJob);\n }\n /* network set functions */\n\n }, {\n key: \"createNetworkSet\",\n value: function createNetworkSet(_ref2) {\n var _this5 = this;\n\n var name = _ref2.name,\n description = _ref2.description;\n return new Promise(function (resolve, reject) {\n _this5._httpPostProtectedObj('networkset', undefined, {\n name: name,\n description: description\n }).then(function (response) {\n var uuidr = response.split('/');\n var uuid = uuidr[uuidr.length - 1];\n return resolve(uuid);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"updateNetworkSet\",\n value: function updateNetworkSet(uuid, _ref3) {\n var _this6 = this;\n\n var name = _ref3.name,\n description = _ref3.description;\n return new Promise(function (resolve, reject) {\n _this6._httpPutObj('networkset/' + uuid, undefined, {\n uuid: uuid,\n name: name,\n description: description\n }).then(function (response) {\n return resolve(response);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"deleteNetworkSet\",\n value: function deleteNetworkSet(uuid) {\n return this._httpDeleteObj('networkset/' + uuid);\n }\n }, {\n key: \"getNetworkSet\",\n value: function getNetworkSet(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetProtectedObj('networkset/' + uuid, parameters);\n }\n }, {\n key: \"addToNetworkSet\",\n value: function addToNetworkSet(networkSetUUID, networkUUIDs) {\n return this._httpPostProtectedObj('networkset/' + networkSetUUID + '/members', undefined, networkUUIDs);\n }\n }, {\n key: \"deleteFromNetworkSet\",\n value: function deleteFromNetworkSet(networkSetUUID, networkUUIDS) {\n return this._httpDeleteObj('networkset/' + networkSetUUID + '/members', undefined, networkUUIDS);\n }\n }, {\n key: \"updateNetworkSetSystemProperty\",\n value: function updateNetworkSetSystemProperty(networksetUUID, data) {\n return this._httpPutObj('networkset/' + networksetUUID + '/systemproperty', undefined, data);\n }\n /* undocumented functions. Might be changed ... */\n // layout update is a list of objects:\n // [{ node: 1, x: 100, y: 100}, {node: 2, x: 1003, y: 200 }...]\n\n }, {\n key: \"updateCartesianLayoutAspect\",\n value: function updateCartesianLayoutAspect(uuid, nodePositions) {\n // 1. get node coordinates from cy.js model in the format of cartesian aspect\n // 2. generate CX for the put request\n // 3. example\n // [{\n // \"numberVerification\": [\n // {\n // \"longNumber\": 283213721732712\n // }\n // ]\n // }, {\n // \"metaData\": [{\n // \"name\": \"cartesianLayout\", \"elementCount\": 100 // num nodes here\n // }],\n // \"cartesianLayout\": [{\n // \"node\": 100, \"x\": 23213.12, \"y\": 3234.5\n // }]\n // }]\n var cartesianLayoutUpdate = [CX1_HEADER, {\n metaData: [{\n name: 'cartesianLayout',\n elementCount: nodePositions.length\n }]\n }, {\n cartesianLayout: nodePositions\n }, {\n status: [{\n error: '',\n success: true\n }]\n }];\n return this._httpPutObj(\"network/\".concat(uuid, \"/aspects\"), undefined, cartesianLayoutUpdate);\n } // new v3 functions\n\n }, {\n key: \"getRandomEdges\",\n value: function getRandomEdges(uuid, limit, accessKey) {\n if (limit <= 0) throw new Error(\"Value of parameter limit has to be greater than 0.\");\n var parameters = {\n size: limit,\n method: \"random\"\n };\n\n if (accessKey !== undefined) {\n parameters = {\n accesskey: accessKey\n };\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/aspects/edges', parameters);\n }\n }, {\n key: \"getMetaData\",\n value: function getMetaData(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetProtectedObj('network/' + uuid + '/aspect', parameters);\n }\n }, {\n key: \"getAspectElements\",\n value: function getAspectElements(uuid, aspectName, limit, accessKey) {\n var parameters = {};\n\n if (limit !== undefined) {\n parameters = {\n size: limit\n };\n }\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/aspects/' + aspectName, parameters);\n }\n }, {\n key: \"getFilteredEdges\",\n value: function getFilteredEdges(uuid, columnName, valueString, operator, limit, order, format, accessKey) {\n var parameters = {};\n\n if (limit !== undefined) {\n parameters = {\n size: limit\n };\n }\n\n if (order !== undefined) {\n parameters['order'] = order;\n }\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n if (format !== undefined) {\n parameters['format'] = format;\n }\n\n var data = {\n \"name\": columnName,\n \"value\": valueString,\n \"operator\": operator\n };\n return this._httpPostV3ProtectedObj('/search/networks/' + uuid + '/edges', parameters, data);\n }\n }, {\n key: \"getCX2MetaData\",\n value: function getCX2MetaData(uuid, accessKey) {\n var parameters = {};\n\n if (accessKey !== undefined) {\n parameters['accesskey'] = accessKey;\n }\n\n return this._httpGetV3ProtectedObj('networks/' + uuid + '/aspects', parameters);\n }\n }, {\n key: \"cancelDOIRequest\",\n value: function cancelDOIRequest(uuid) {\n var cancelBody = {\n type: \"Cancel_DOI\",\n networkId: uuid\n };\n return this._httpPostProtectedObj('admin/request', {}, cancelBody);\n } // unstable function to upload CX2 to NDEx\n\n }, {\n key: \"createNetworkFromRawCX2\",\n value: function createNetworkFromRawCX2(rawCX2) {\n var makePublic = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var config = {\n method: 'post',\n url: 'networks',\n baseURL: this._v3baseURL,\n params: {\n visibility: makePublic ? 'PUBLIC' : 'PRIVATE'\n }\n };\n\n this._setAuthHeader(config);\n\n config.data = rawCX2;\n return axios(config).then(function (res) {\n var location = res.headers.location;\n var uuid = location.split('/').pop();\n return {\n uuid: uuid\n };\n });\n }\n }, {\n key: \"updateNetworkFromRawCX2\",\n value: function updateNetworkFromRawCX2(uuid, rawCX2) {\n return this._httpPutV3Obj('networks/' + uuid, undefined, rawCX2);\n }\n }, {\n key: \"createCyWebWorkspace\",\n value: function createCyWebWorkspace(workspace) {\n var _this7 = this;\n\n return new Promise(function (resolve, reject) {\n _this7._httpPostV3ProtectedObj('workspaces', undefined, workspace).then(function (response) {\n // let uuidr = response.split('/');\n // let uuid = uuidr[uuidr.length - 1];\n return resolve(response);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"getCyWebWorkspace\",\n value: function getCyWebWorkspace(workspaceId) {\n return this._httpGetV3ProtectedObj('workspaces/' + workspaceId, {});\n }\n }, {\n key: \"deleteCyWebWorkspace\",\n value: function deleteCyWebWorkspace(workspaceId) {\n return this._httpDeleteV3Obj('workspaces/' + workspaceId, undefined);\n }\n }, {\n key: \"updateCyWebWorkspace\",\n value: function updateCyWebWorkspace(workspaceId, workspaceObj) {\n return this._httpPutV3Obj('workspaces/' + workspaceId, undefined, workspaceObj);\n }\n }, {\n key: \"updateCyWebWorkspaceName\",\n value: function updateCyWebWorkspaceName(workspaceId, newName) {\n return this._httpPutV3Obj('workspaces/' + workspaceId + '/name', undefined, {\n 'name': newName\n });\n }\n }, {\n key: \"updateCyWebWorkspaceNetworks\",\n value: function updateCyWebWorkspaceNetworks(workspaceId, networkIds) {\n return this._httpPutV3Obj('workspaces/' + workspaceId + '/networkids', undefined, networkIds);\n }\n }, {\n key: \"getUserCyWebWorkspaces\",\n value: function getUserCyWebWorkspaces() {\n var _this8 = this;\n\n return new Promise(function (resolve, reject) {\n _this8.getSignedInUser().then(function (user) {\n _this8._httpGetV3ProtectedObj('users/' + user.externalId + '/workspaces', {}).then(function (workspaceArray) {\n resolve(workspaceArray);\n }, function (err) {\n reject(err);\n });\n }, function (err) {\n reject(err);\n });\n });\n }\n }]);\n\n return NDEx;\n}();\n\nmodule.exports = {\n NDEx: NDEx\n};\n\n//# sourceURL=webpack://ndexClient/./src/NDEx.js?");
|
|
30
30
|
|
|
31
31
|
/***/ }),
|
|
32
32
|
|
package/package.json
CHANGED
package/src/NDEx.js
CHANGED
|
@@ -846,5 +846,16 @@ class NDEx {
|
|
|
846
846
|
return this._httpPutV3Obj('workspaces/'+workspaceId+'/networkids', undefined, networkIds);
|
|
847
847
|
}
|
|
848
848
|
|
|
849
|
+
getUserCyWebWorkspaces() {
|
|
850
|
+
return new Promise((resolve, reject) => {
|
|
851
|
+
this.getSignedInUser().then((user) => {
|
|
852
|
+
this._httpGetV3ProtectedObj('users/'+ user.externalId + '/workspaces', {}).then(
|
|
853
|
+
(workspaceArray) => {resolve(workspaceArray);}, (err) => {reject(err);}
|
|
854
|
+
);
|
|
855
|
+
}, (err) => {reject(err);});
|
|
856
|
+
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
|
|
849
860
|
}
|
|
850
861
|
module.exports = { NDEx };
|