@js4cytoscape/ndex-client 0.3.2 → 0.4.3-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,7 @@ eval("function _classCallCheck(instance, Constructor) { if (!(instance instanceo
25
25
  \*********************/
26
26
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
27
27
 
28
- 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/index.js\");\n\nvar CX1_HEADER = {\n numberVerification: [{\n \"longNumber\": 283213721732712\n }]\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 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: \".concat(hostprefix));\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 (this._authType === 'b') {\n config['auth'] = {\n username: this.username,\n password: this.password\n };\n } else if (this.authenticationType === 'g') {\n var idToken = this._getIdToken();\n\n if (config['headers'] === undefined) {\n config['headers'] = {};\n }\n\n config['headers']['Authorization'] = 'Bearer ' + idToken;\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: \"_httpPutObj\",\n value: function _httpPutObj(URL, parameters, data) {\n var config = {\n method: 'put',\n url: URL,\n baseURL: this.host\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: \"_httpDeleteObj\",\n value: function _httpDeleteObj(URL, parameters, data) {\n var config = {\n method: 'delete',\n url: URL,\n baseURL: this.host\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: \"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 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\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 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\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: \"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(_ref) {\n var _this5 = this;\n\n var name = _ref.name,\n description = _ref.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, _ref2) {\n var _this6 = this;\n\n var name = _ref2.name,\n description = _ref2.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\n return NDEx;\n}();\n\nmodule.exports = {\n NDEx: NDEx\n};\n\n//# sourceURL=webpack://@js4cytoscape/ndex-client/./src/NDEx.js?");
28
+ 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/index.js\");\n\nvar CX1_HEADER = {\n numberVerification: [{\n \"longNumber\": 283213721732712\n }]\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 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: \".concat(hostprefix));\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 (this._authType === 'b') {\n config['auth'] = {\n username: this.username,\n password: this.password\n };\n } else if (this.authenticationType === 'g') {\n var idToken = this._getIdToken();\n\n if (config['headers'] === undefined) {\n config['headers'] = {};\n }\n\n config['headers']['Authorization'] = 'Bearer ' + idToken;\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: \"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 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\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 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\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: \"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(_ref) {\n var _this5 = this;\n\n var name = _ref.name,\n description = _ref.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, _ref2) {\n var _this6 = this;\n\n var name = _ref2.name,\n description = _ref2.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: \"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 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: \"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?");
29
29
 
30
30
  /***/ }),
31
31
 
@@ -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/index.js\");\n\nvar CX1_HEADER = {\n numberVerification: [{\n \"longNumber\": 283213721732712\n }]\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 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: \".concat(hostprefix));\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 (this._authType === 'b') {\n config['auth'] = {\n username: this.username,\n password: this.password\n };\n } else if (this.authenticationType === 'g') {\n var idToken = this._getIdToken();\n\n if (config['headers'] === undefined) {\n config['headers'] = {};\n }\n\n config['headers']['Authorization'] = 'Bearer ' + idToken;\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: \"_httpPutObj\",\n value: function _httpPutObj(URL, parameters, data) {\n var config = {\n method: 'put',\n url: URL,\n baseURL: this.host\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: \"_httpDeleteObj\",\n value: function _httpDeleteObj(URL, parameters, data) {\n var config = {\n method: 'delete',\n url: URL,\n baseURL: this.host\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: \"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 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\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 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\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: \"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(_ref) {\n var _this5 = this;\n\n var name = _ref.name,\n description = _ref.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, _ref2) {\n var _this6 = this;\n\n var name = _ref2.name,\n description = _ref2.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\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/index.js\");\n\nvar CX1_HEADER = {\n numberVerification: [{\n \"longNumber\": 283213721732712\n }]\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 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: \".concat(hostprefix));\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 (this._authType === 'b') {\n config['auth'] = {\n username: this.username,\n password: this.password\n };\n } else if (this.authenticationType === 'g') {\n var idToken = this._getIdToken();\n\n if (config['headers'] === undefined) {\n config['headers'] = {};\n }\n\n config['headers']['Authorization'] = 'Bearer ' + idToken;\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: \"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 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\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 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\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: \"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(_ref) {\n var _this5 = this;\n\n var name = _ref.name,\n description = _ref.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, _ref2) {\n var _this6 = this;\n\n var name = _ref2.name,\n description = _ref2.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: \"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 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: \"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?");
30
30
 
31
31
  /***/ }),
32
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@js4cytoscape/ndex-client",
3
- "version": "0.3.2",
3
+ "version": "0.4.3-alpha.0",
4
4
  "description": "NDEx client library",
5
5
  "repository": {
6
6
  "type": "git",
package/src/NDEx.js CHANGED
@@ -176,11 +176,11 @@ class NDEx {
176
176
  return this._httpPostProtectedObjAux(this._v3baseURL,URL,parameters, data);
177
177
  }
178
178
 
179
- _httpPutObj(URL, parameters, data) {
179
+ _httpPutObjAux(prefix, URL, parameters, data) {
180
180
  let config = {
181
181
  method: 'put',
182
182
  url: URL,
183
- baseURL: this.host
183
+ baseURL: prefix
184
184
  };
185
185
 
186
186
  this._setAuthHeader(config);
@@ -204,11 +204,28 @@ class NDEx {
204
204
  });
205
205
  }
206
206
 
207
+ _httpPutObj(URL,parameters, data) {
208
+ return this._httpPutObjAux(this.host,URL, parameters, data);
209
+ }
210
+
211
+ _httpPutV3Obj(URL,parameters,data) {
212
+ return this._httpPutObjAux(this._v3baseURL,URL,parameters,data);
213
+ }
214
+
215
+
207
216
  _httpDeleteObj(URL, parameters, data) {
217
+ return this._httpDeleteObjAux(this.host,URL,parameters, data);
218
+ }
219
+
220
+ _httpDeleteV3Obj(URL, parameters) {
221
+ return this._httpDeleteObjAux(this._v3baseURL, URL, parameters, undefined);
222
+ }
223
+
224
+ _httpDeleteObjAux(prefix, URL, parameters, data) {
208
225
  let config = {
209
226
  method: 'delete',
210
227
  url: URL,
211
- baseURL: this.host
228
+ baseURL: prefix
212
229
  };
213
230
 
214
231
  this._setAuthHeader(config);
@@ -733,5 +750,41 @@ class NDEx {
733
750
  });
734
751
  }
735
752
 
753
+ createCyWebWorkspace(workspace) {
754
+ return new Promise((resolve, reject)=> {
755
+ this._httpPostV3ProtectedObj('workspaces', undefined, workspace).then(
756
+ (response) => {
757
+ let uuidr = response.split('/');
758
+
759
+ let uuid = uuidr[uuidr.length - 1];
760
+
761
+ return resolve(uuid);
762
+ },
763
+ (err) => {reject(err);}
764
+ );
765
+ });
766
+
767
+ }
768
+
769
+ getCyWebWorkspace(workspaceId) {
770
+ return this._httpGetV3ProtectedObj('workspaces/'+ workspaceId, {});
771
+ }
772
+
773
+ deleteCyWebWorkspace(workspaceId) {
774
+ return this._httpDeleteV3Obj('workspaces/'+ workspaceId, undefined);
775
+ }
776
+
777
+ updateCyWebWorkspace(workspaceId, workspaceObj) {
778
+ return this._httpPutV3Obj('workspaces/'+workspaceId, undefined, workspaceObj);
779
+ }
780
+
781
+ updateCyWebWorkspaceName(workspaceId, newName) {
782
+ return this._httpPutV3Obj('workspaces/'+workspaceId+'/name', undefined, {'name': newName});
783
+ }
784
+
785
+ updateCyWebWorkspaceNetworks(workspaceId, networkIds) {
786
+ return this._httpPutV3Obj('workspaces/'+workspaceId+'/networkids', undefined, networkIds);
787
+ }
788
+
736
789
  }
737
790
  module.exports = { NDEx };