Comparing version 2.2.0 to 2.2.3
/* | ||
* Copyright (c) 2016-present, IBM Research | ||
* Licensed under The MIT License [see LICENSE for details] | ||
* copyright: IBM Confidential | ||
* copyright: OCO Source Materials | ||
* copyright: © IBM Corp. All Rights Reserved | ||
* date: 2020 | ||
* | ||
* IBM Certificate of Originality | ||
*/ | ||
"use strict"; | ||
@@ -13,2 +16,4 @@ | ||
exports.CONSTRAINT = "c"; | ||
exports.CAUSAL = "C"; | ||
exports.CAUSAL = "C"; | ||
exports.POSSIBILITY = "p"; | ||
exports.POSSIBILITYRESOLVER = "P"; |
@@ -497,2 +497,67 @@ /* | ||
/** | ||
* Filter entities Ids using CSS pattern `(TODO: document it better)` | ||
* | ||
* Examples: | ||
* | ||
* `{"parent" : "bar"}` - filter entities ids from a context bar | ||
* | ||
* `{"type" : "node"}` - filter entities ids of type node | ||
* | ||
* `{"properties" : {"name" : "bar"}` - filter entities ids with property name which it is bar | ||
* | ||
* `{"parent":"parent_context", {"properties" : {"name" : "bar"}` - Combined filter | ||
* | ||
* @param {object} filter The CSS filter | ||
* @param {GetEntitiesCallback} callback Callback with the entities ids | ||
*/ | ||
HKDatasource.prototype.filterEntitiesLazy = function(filter, callback = () => {}) | ||
{ | ||
let url = this.url + "repository/" + this.graphName + "/entity/lazy"; | ||
let params = {} | ||
if(typeof filter === "object") | ||
{ | ||
params.headers = {"content-type": "application/json"}; | ||
params.body = JSON.stringify(filter); | ||
} | ||
else if(typeof filter === "string") | ||
{ | ||
params.headers = {"content-type": "text/plain"}; | ||
params.body = filter; | ||
} | ||
Object.assign(params, this.options); | ||
request.post(url, params, (err, res) => | ||
{ | ||
if(!err) | ||
{ | ||
if(requestCompletedWithSuccess (res.statusCode)) | ||
{ | ||
try | ||
{ | ||
callback(null, JSON.parse(res.body)); | ||
} | ||
catch(exp) | ||
{ | ||
callback(exp); | ||
} | ||
} | ||
else | ||
{ | ||
callback(`Server responded with ${res.statusCode}. ${res.body}`); | ||
} | ||
} | ||
else | ||
{ | ||
callback(err); | ||
} | ||
}); | ||
} | ||
/** | ||
* @callback QueryResultsCallback | ||
@@ -499,0 +564,0 @@ * @param err An error object that indicate if the operation was succesful or not |
11
index.js
/* | ||
* Copyright (c) 2016-present, IBM Research | ||
* Licensed under The MIT License [see LICENSE for details] | ||
* copyright: IBM Confidential | ||
* copyright: OCO Source Materials | ||
* copyright: © IBM Corp. All Rights Reserved | ||
* date: 2020 | ||
* | ||
* IBM Certificate of Originality | ||
*/ | ||
"use strict"; | ||
@@ -42,2 +45,4 @@ | ||
exports.CAUSAL = ConnectorClass.CAUSAL; | ||
exports.POSSIBILITY = ConnectorClass.POSSIBILITY; | ||
exports.POSSIBILITYRESOLVER = ConnectorClass.POSSIBILITYRESOLVER; | ||
@@ -44,0 +49,0 @@ |
{ | ||
"name": "hklib", | ||
"version": "2.2.0", | ||
"version": "2.2.3", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "author": "IBM Research", |
94165
3434