Comparing version 4.1.0 to 4.2.0
@@ -441,3 +441,3 @@ /* | ||
filterEntities(filter, callback = () => { }) { | ||
let url = this.url + "repository/" + this.graphName + "/entity/"; | ||
let url = this.url + "repository/" + this.graphName + "/entity/filter/"; | ||
let params = {}; | ||
@@ -444,0 +444,0 @@ // { |
@@ -11,2 +11,3 @@ /* | ||
const VirtualContext = require("./virtualcontext"); | ||
const VirtualLink = require("./virtuallink"); | ||
const Connector = require("./connector"); | ||
@@ -34,2 +35,4 @@ const Reference = require("./reference"); | ||
return new Link(input); | ||
case Types.VIRTUAL_LINK: | ||
return new VirtualLink(input); | ||
case Types.REFERENCE: | ||
@@ -36,0 +39,0 @@ return new Reference(input); |
@@ -12,2 +12,3 @@ /** | ||
links: {}; | ||
virtualLinks: {}; | ||
connectors: {}; | ||
@@ -18,2 +19,3 @@ refs: {}; | ||
linkMap: {}; | ||
virtualLinkMap: {}; | ||
refMap: {}; | ||
@@ -39,2 +41,7 @@ orphans: {}; | ||
/** | ||
* Add a new entities to the graph | ||
* @param {object} entities The entities object to be added. | ||
*/ | ||
addEntities(entities: object): void; | ||
/** | ||
* @param {string} id the id of entity to be removed | ||
@@ -41,0 +48,0 @@ * @returns {object} the removed entity |
@@ -17,2 +17,3 @@ /* | ||
const VirtualNode = require("./virtualnode"); | ||
const VirtualLink = require("./virtuallink"); | ||
class HKGraph { | ||
@@ -25,2 +26,3 @@ constructor() { | ||
this.links = {}; | ||
this.virtualLinks = {}; | ||
this.connectors = {}; | ||
@@ -32,2 +34,3 @@ this.refs = {}; | ||
this.linkMap = {}; | ||
this.virtualLinkMap = {}; | ||
this.refMap = {}; | ||
@@ -200,2 +203,23 @@ this.orphans = {}; | ||
} | ||
case HKTypes.VIRTUAL_LINK: | ||
{ | ||
if (VirtualLink.isValid(entity)) { | ||
newEntity = new VirtualLink(entity); | ||
newEntity.id = id; | ||
this.virtualLinks[id] = newEntity; | ||
if (!this.virtualLinkMap.hasOwnProperty(newEntity.connector)) { | ||
this.virtualLinkMap[newEntity.connector] = {}; | ||
} | ||
this.virtualLinkMap[newEntity.connector][newEntity.id] = newEntity; | ||
this.bindsMap[newEntity.id] = new Set(); | ||
newEntity.forEachBind((__, comp) => { | ||
this.bindsMap[newEntity.id].add(comp); | ||
if (!this.bindsMap.hasOwnProperty(comp)) { | ||
this.bindsMap[comp] = new Set(); | ||
} | ||
this.bindsMap[comp].add(newEntity.id); | ||
}); | ||
} | ||
break; | ||
} | ||
case HKTypes.CONNECTOR: | ||
@@ -250,2 +274,9 @@ { | ||
/** | ||
* Add a new entities to the graph | ||
* @param {object} entities The entities object to be added. | ||
*/ | ||
addEntities(entities) { | ||
Object.values(entities).forEach(e => this.addEntity(e)); | ||
} | ||
/** | ||
* @param {string} id the id of entity to be removed | ||
@@ -252,0 +283,0 @@ * @returns {object} the removed entity |
@@ -30,2 +30,4 @@ /* | ||
export { default as HKVirtualContext } from "./virtualcontext"; | ||
export { default as VirtualLink } from "./virtuallink"; | ||
export { default as HKVirtualLink } from "./virtuallink"; | ||
@@ -71,3 +73,4 @@ export { default as Types } from "./types"; | ||
export { default as GraphBuilder } from "./graphbuilder"; | ||
export { default as BaseExternalDatasource } from "./abstract/baseexternaldatasource"; | ||
export { IExternalDatasource } from "./interfaces/iexternaldatasource"; | ||
@@ -24,2 +24,4 @@ /* | ||
exports.HKVirtualContext = require("./virtualcontext"); | ||
exports.VirtualLink = require("./virtuallink"); | ||
exports.HKVirtualLink = require("./virtuallink"); | ||
exports.Types = require("./types"); | ||
@@ -36,2 +38,3 @@ exports.HKTypes = require("./types"); | ||
exports.VIRTUAL_CONTEXT_TYPE = require("./types").VIRTUAL_CONTEXT; | ||
exports.VIRTUAL_LINK_TYPE = require("./types").VIRTUAL_LINK; | ||
exports.VIRTUAL_SOURCE_PROPERTY = "virtualsrc"; | ||
@@ -60,1 +63,2 @@ exports.RoleTypes = require("./roletypes"); | ||
exports.IExternalDatasource = require("./interfaces/iexternaldatasource"); | ||
exports.BaseExternalDatasource = require("./abstract/baseexternaldatasource"); |
@@ -5,9 +5,8 @@ /** | ||
*/ | ||
import HKEntity from "../hkentity"; | ||
export interface IExternalDatasource { | ||
endpoint: string; | ||
executeQuery(query: string, options: any): Promise<any>; | ||
transform(data?: any): Promise<Map<string, HKEntity>>; | ||
executeQuery(query: string, parent: any, options: any): Promise<any>; | ||
transform(data: any, context: any): any; | ||
getProperties(property?: string[]): any; | ||
getEntity(key: string, options: any): Promise<any>; | ||
getEntity(key: string, parentId: string, endpoint: string | undefined, options: any): Promise<any>; | ||
} |
@@ -15,3 +15,4 @@ /** | ||
export var VIRTUAL_CONTEXT: string; | ||
export var VIRTUAL_LINK: string; | ||
export var VIRTUAL_SOURCE_PROPERTY: string; | ||
export function isValidType(type: any): boolean; |
@@ -16,2 +16,3 @@ /* | ||
exports.VIRTUAL_CONTEXT = 'virtualcontext'; | ||
exports.VIRTUAL_LINK = 'virtuallink'; | ||
exports.VIRTUAL_SOURCE_PROPERTY = "virtualsrc"; | ||
@@ -18,0 +19,0 @@ exports.isValidType = function (type) { |
@@ -8,2 +8,8 @@ /** | ||
declare class VirtualContext extends Context { | ||
/** Constructs a new virtual context object. | ||
* | ||
* @param {string | null} [id] Some id string for this entity. | ||
* @param {string | null} [virtualSrc] Virtual endpoint to acceess information | ||
* @param {string | null} [parent] Parent id. | ||
*/ | ||
constructor(id: any, virtualSrc: string, parent?: string); | ||
@@ -10,0 +16,0 @@ static isValid(entity: VirtualContext): boolean; |
@@ -10,2 +10,8 @@ "use strict"; | ||
class VirtualContext extends context_1.default { | ||
/** Constructs a new virtual context object. | ||
* | ||
* @param {string | null} [id] Some id string for this entity. | ||
* @param {string | null} [virtualSrc] Virtual endpoint to acceess information | ||
* @param {string | null} [parent] Parent id. | ||
*/ | ||
constructor(id, virtualSrc, parent) { | ||
@@ -43,2 +49,3 @@ super(id, parent); | ||
} | ||
VirtualContext.type = types_1.VIRTUAL_CONTEXT; | ||
module.exports = VirtualContext; |
{ | ||
"name": "hklib", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "author": "IBM Research", |
225351
65
5882