New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hklib

Package Overview
Dependencies
Maintainers
7
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hklib - npm Package Compare versions

Comparing version 2.9.0 to 2.10.0

50

datasource/hkdatasource.js

@@ -507,2 +507,52 @@ /*

/**
* Fetch entities from a context
*
* @param {string} context The context id to retrieve their nested entities. May be null to get the `body` context.
* @param {object} payload A dictionary containing options when returning the entities from the context.
* @param {GetEntitiesCallback} callback Callback with the entities
*/
HKDatasource.prototype.getContextChildrenLazy = function(context, payload, callback = () => {})
{
let url = `${this.url}repository/${this.graphName}/context/${context}/lazy`;
Object.assign(payload, this.options);
const options = {
method: 'POST',
url: url,
headers: {
'Content-Type': 'application/json',
},
body: payload,
json: true
};
request(options, (err, res) =>
{
if(!err)
{
if(requestCompletedWithSuccess (res.statusCode))
{
try
{
callback(null, res.body);
}
catch(exp)
{
callback(exp);
}
}
else
{
callback(`Server responded with ${res.statusCode}. ${res.body}`);
}
}
else
{
callback(err);
}
});
}
/**
* Filter entities using CSS pattern `(TODO: document it better)`

@@ -509,0 +559,0 @@ *

4

package.json
{
"name": "hklib",
"version": "2.9.0",
"version": "2.10.0",
"main": "index.js",

@@ -41,4 +41,4 @@ "author": "IBM Research",

"dependencies": {
"amqp-connection-manager": "~3.2.2",
"amqplib": "^0.8.0",
"amqp-connection-manager": "~3.2.2",
"body-parser": "^1.19.0",

@@ -45,0 +45,0 @@ "express": "^4.17.1",

@@ -9,2 +9,3 @@ "use strict";

const Context = require("../../context");
const Node = require("../../node");
const VContext = require("../../virtualcontext");

@@ -18,3 +19,3 @@ const HKEntity = require("../../hkentity");

before(done => {
beforeEach(done => {
HKDatasource.createRepository((err, data)=>

@@ -28,3 +29,3 @@ {

after(done => {
afterEach(done => {
HKDatasource.dropRepository((err, data)=> {

@@ -46,6 +47,5 @@ if (err) throw err;

it("Add Virtual Context'", done => {
it("Add Virtual Context", done => {
const vContext = new VContext("VContext", "http://dbpedia.org/sparql");
console.log(vContext);
HKDatasource.saveEntities([vContext], (err, data)=> {

@@ -58,2 +58,98 @@ if (err) throw err;

});
it("Test fetch context children including context", done => {
const context = new Context("Parent");
const node = new Node("Son", context.id);
HKDatasource.saveEntities([context, node], (err, data)=> {
if (err) throw err;
const payload = {
"hkTypes": [],
"nested": false,
"includeContextOnResults": true
}
HKDatasource.getContextChildrenLazy(context.id, payload, (err, data)=>{
if (err) throw err;
expect([context.id, node.id].sort()).to.be.deep.equal(Object.keys(data).sort());
done();
})
});
});
it("Test fetch context children not including context", done => {
const context = new Context("Parent");
const node = new Node("Son", context.id);
HKDatasource.saveEntities([context, node], (err, data)=> {
if (err) throw err;
const payload = {
"hkTypes": [],
"nested": false,
"includeContextOnResults": false
}
HKDatasource.getContextChildrenLazy(context.id, payload, (err, data)=>{
if (err) throw err;
expect([node.id]).to.be.deep.equal(Object.keys(data));
done();
})
});
});
it("Test fetch context nodes children", done => {
const context = new Context("Parent");
const node = new Node("Son", context.id);
const nested = new Context("Nested", context.id);
HKDatasource.saveEntities([context, node, nested], (err, data)=> {
if (err) throw err;
const payload = {
"hkTypes": ["node"],
"nested": false,
"includeContextOnResults": false
}
HKDatasource.getContextChildrenLazy(context.id, payload, (err, data)=>{
if (err) throw err;
expect([node.id]).to.be.deep.equal(Object.keys(data));
done();
})
});
});
it("Test fetch context nodes children", done => {
const context = new Context("Parent");
const vContext = new VContext("VContext", "http://dbpedia.org/sparql", "Parent")
HKDatasource.saveEntities([context, vContext], (err, data)=> {
if (err) throw err;
const payload = {
"hkTypes": ["context"],
"nested": false,
"includeContextOnResults": false,
"fieldsToInclude": { "fields": ["id", "parent"], "properties": ["virtualsrc"]}
}
HKDatasource.getContextChildrenLazy(context.id, payload, (err, data)=>{
if (err) throw err;
expect(vContext.id).to.be.deep.equal(Object.values(data)[0].id);
expect(vContext.parent).to.be.deep.equal(Object.values(data)[0].parent);
expect(vContext.properties["virtualsrc"]).to.be.equal(Object.values(data)[0].properties["virtualsrc"]);
done();
})
});
});
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc