Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trails #71

Open
wants to merge 29 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f10e971
First commit for the new Trails implementation
Aug 12, 2021
b01ee37
Avoid exposing List class from Trail module
Aug 12, 2021
bb80264
only exporting trail in trail.js
raphael-melo Aug 18, 2021
f6df1d8
Removing List from require
Aug 18, 2021
c717128
Adding in-memory functions
Aug 24, 2021
906b5ad
Adding fetch trail to hkdatasource
Aug 25, 2021
89dbdeb
Merge branch 'trails' of https://github.com/ibm-hyperknowledge/hklib …
Aug 25, 2021
6f1709c
Sorting actions based on timestamps
Sep 1, 2021
748073c
Trail Internals now appear on the Inspector
GabrielaPC Sep 8, 2021
1e62956
Improving use of linked-list lib for in-memory operations
Sep 21, 2021
97b10dd
Improving Action load with linked list
Sep 22, 2021
8bf4efa
Improving action class and its loading and sorting
Sep 24, 2021
07c724c
Removing unused require
Sep 25, 2021
8892edf
Added actions to hkgraph
GabrielaPC Nov 24, 2021
e47309f
Merge pull request #39 from ibm-hyperknowledge/actions
rbrandao Nov 24, 2021
f1af0da
this.actions.toArray is not a function bugfix
GabrielaPC Dec 13, 2021
ba8161d
Bugfix Trail.out not working with only one action
GabrielaPC Jan 19, 2022
dbb4b26
Merge remote-tracking branch 'origin/dev' into trails
Jun 15, 2022
43823a4
Merge bugfix
Jun 28, 2022
32c8870
Identation fix
eltonfss Jun 29, 2022
66c0f80
Added linked-list to HKLib
Jun 30, 2022
4cd8929
Merge branch 'trails-merge' of https://github.com/ibm-hyperknowledge/…
Jun 30, 2022
9e6f618
Trail build bugfix
Jun 30, 2022
7d229eb
fixed indentation
Jul 1, 2022
f0ab249
mend
Jul 1, 2022
adf93a0
undo mend
Jul 1, 2022
b3d170b
Merge branch 'trails-merge' of https://github.com/ibm-hyperknowledge/…
Jul 6, 2022
a43ca6d
Updated trail from function to class
Jul 11, 2022
c8e1c1f
edited linked-list import
Jul 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dist/connector.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ declare class Connector extends HKEntity {
public roles: {
[x: string]: string;
};
properties: any;
metaProperties: any;
/**
* Adds a new role to this connector.
*
Expand Down Expand Up @@ -96,6 +98,6 @@ declare class Connector extends HKEntity {
};
}
declare namespace Connector {
const type: string;
const type: "connector";
}
import HKEntity = require("./hkentity");
14 changes: 7 additions & 7 deletions dist/connectorclass.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* Copyright (c) 2016-present, IBM Research
* Licensed under The MIT License [see LICENSE for details]
*/
export var HIERARCHY: string;
export var FACTS: string;
export var REASONING: string;
export var CONSTRAINT: string;
export var CAUSAL: string;
export var POSSIBILITY: string;
export var POSSIBILITYRESOLVER: string;
export const HIERARCHY: "h";
export const FACTS: "f";
export const REASONING: "r";
export const CONSTRAINT: "c";
export const CAUSAL: "C";
export const POSSIBILITY: "p";
export const POSSIBILITYRESOLVER: "P";
4 changes: 2 additions & 2 deletions dist/constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
* Copyright (c) 2016-present, IBM Research
* Licensed under The MIT License [see LICENSE for details]
*/
export var LAMBDA: string;
export var MIMETYPE: string;
export const LAMBDA: "λ";
export const MIMETYPE: "hk:mimeType";
3 changes: 2 additions & 1 deletion dist/context.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ declare class Context extends Node {
* @param {string | null} [parent] Parent id.
*/
constructor(id?: string | null | undefined, parent?: string | null | undefined);
type: "context";
}
declare namespace Context {
const type: string;
const type: "context";
}
import Node = require("./node");
12 changes: 12 additions & 0 deletions dist/datasource/hkdatasource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ declare class HKDatasource {
}, payload: object, callback: (err: string, entities: {
[x: string]: HKEntity;
}) => any): void;
/**
* @callback GetTrailCallback
* @param {string} err An error object that indicate if the operation was succesful or not
* @param {object} trail
*/
/**
* Fetch trail
*
* @param {string} trailId The trail id to retrieve their nested entities.
* @param {GetTrailCallback} callback Callback with the entities
*/
fetchTrail(trailId: string, callback?: (err: string, trail: object) => any): void;
/**
* Filter entities using CSS pattern `(TODO: document it better)`
*
Expand Down
34 changes: 34 additions & 0 deletions dist/datasource/hkdatasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,40 @@ class HKDatasource {
}
});
}
/**
* @callback GetTrailCallback
* @param {string} err An error object that indicate if the operation was succesful or not
* @param {object} trail
*/
/**
* Fetch trail
*
* @param {string} trailId The trail id to retrieve their nested entities.
* @param {GetTrailCallback} callback Callback with the entities
*/
fetchTrail(trailId, callback = () => { }) {
let url = this.url + "repository/" + this.graphName + "/trail/" + encodeURIComponent(trailId);
request.get(url, this.options, (err, res) => {
// console.log(res.body);
if (!err) {
if (requestCompletedWithSuccess(res.statusCode)) {
try {
let entities = convertEntities(res.body);
callback(null, entities[trailId]);
}
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)`
*
Expand Down
8 changes: 4 additions & 4 deletions dist/datasource/observer/clients/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2016-present, IBM Research
* Licensed under The MIT License [see LICENSE for details]
*/
export var DefaultObserverClient: typeof import("./observerclient");
export var ConfigurableObserverClient: typeof import("./configurableobserverclient");
export var RestObserverClient: typeof import("./restobserverclient");
export var RabbitMQObserverClient: typeof import("./rabbitmqobserverclient");
export const DefaultObserverClient: typeof import("./observerclient");
export const ConfigurableObserverClient: typeof import("./configurableobserverclient");
export const RestObserverClient: typeof import("./restobserverclient");
export const RabbitMQObserverClient: typeof import("./rabbitmqobserverclient");
2 changes: 2 additions & 0 deletions dist/datasource/observer/clients/rabbitmqobserverclient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ declare class RabbitMQObserverClient extends ConfigurableObserverClient {
_channelWrapper: any;
_setupFunction: ((channel: any) => Promise<void>) | null;
_queueName: any;
init(): Promise<void>;
_init(exchangeName: any): Promise<void>;
_isInitialized: boolean | undefined;
deinit(): Promise<void>;
}
import ConfigurableObserverClient = require("./configurableobserverclient");
1 change: 1 addition & 0 deletions dist/datasource/observer/clients/restobserverclient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ declare class RestObserverClient extends ConfigurableObserverClient {
_address: string;
_listeningPath: string | null;
_server: any;
deinit(): Promise<void>;
}
import ConfigurableObserverClient = require("./configurableobserverclient");
4 changes: 2 additions & 2 deletions dist/fi/fioperator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
*/
export = FIOperator;
declare const FIOperator: Readonly<{
NONE: string;
DESCRIPTION: string;
NONE: "";
DESCRIPTION: "*";
}>;
17 changes: 9 additions & 8 deletions dist/hkgraph.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ declare class HKGraph {
connectors: {};
refs: {};
trails: {};
actions: {};
bindsMap: {};
linkMap: {};
virtualLinkMap: {};
Expand Down Expand Up @@ -75,14 +76,14 @@ declare class HKGraph {
deserialize(str: any): HKGraph;
}
declare namespace HKGraph {
const NODE_TYPE: string;
const VIRTUAL_NODE_TYPE: string;
const CONTEXT_TYPE: string;
const VIRTUAL_CONTEXT_TYPE: string;
const LINK_TYPE: string;
const VIRTUAL_LINK_TYPE: string;
const CONNECTOR_TYPE: string;
const INTERFACE: string;
const NODE_TYPE: "node";
const VIRTUAL_NODE_TYPE: "virtualnode";
const CONTEXT_TYPE: "context";
const VIRTUAL_CONTEXT_TYPE: "virtualcontext";
const LINK_TYPE: "link";
const VIRTUAL_LINK_TYPE: "virtuallink";
const CONNECTOR_TYPE: "connector";
const INTERFACE: "interface";
}
declare function generateId(model: any, length: any): any;
import HKEntity = require("./hkentity");
27 changes: 24 additions & 3 deletions dist/hkgraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const Reference = require("./reference");
const Trail = require("./trail");
const HKTypes = require("./types");
const shortId = require('shortid');
const { Action } = require("./trail");
const VirtualContext = require("./virtualcontext");
const HKEntity = require("./hkentity");
const VirtualNode = require("./virtualnode");
Expand All @@ -26,6 +27,7 @@ class HKGraph {
this.connectors = {};
this.refs = {};
this.trails = {};
this.actions = {};
// Auxiliar maps
this.bindsMap = {};
this.linkMap = {};
Expand All @@ -47,7 +49,8 @@ class HKGraph {
this.links.hasOwnProperty(id) ||
this.connectors.hasOwnProperty(id) ||
this.refs.hasOwnProperty(id) ||
this.trails.hasOwnProperty(id);
this.trails.hasOwnProperty(id) ||
this.actions.hasOwnProperty(id);
}
/**
* Update an entity
Expand All @@ -66,7 +69,7 @@ class HKGraph {
oldEntity.roles = entity.roles;
oldEntity.className = entity.className;
}
if (entity.type === HKTypes.NODE || entity.type === HKTypes.REFERENCE || entity.type === HKTypes.CONTEXT || entity.type === HKTypes.VIRTUAL_NODE || entity.type === HKTypes.VIRTUAL_CONTEXT) {
if (entity.type === HKTypes.NODE || entity.type === HKTypes.TRAIL || entity.type === HKTypes.REFERENCE || entity.type === HKTypes.CONTEXT || entity.type === HKTypes.VIRTUAL_NODE || entity.type === HKTypes.VIRTUAL_CONTEXT || entity.type === HKTypes.ACTION) {
oldEntity.interfaces = entity.interfaces;
}
// Update parent
Expand Down Expand Up @@ -173,6 +176,19 @@ class HKGraph {
if (Trail.isValid(entity)) {
newEntity = new Trail(entity);
this.trails[entity.id] = newEntity;
this.contextMap[entity.id] = {};
if (this.orphans.hasOwnProperty(entity.id)) {
this.contextMap[entity.id] = this.orphans[entity.id];
delete this.orphans[entity.id];
}
}
break;
}
case HKTypes.ACTION:
{
if (entity instanceof Trail.Action) {
newEntity = entity;
this.actions[entity.id] = newEntity;
}
break;
}
Expand Down Expand Up @@ -356,8 +372,13 @@ class HKGraph {
{
/* delete children trails? */
delete this.trails[id];
delete this.contextMap[entity.id];
break;
}
case Action.type:
{
delete this.actions[id];
}
}
if (this.orphans.hasOwnProperty(entity.parent)) {
delete this.orphans[entity.parent][id];
Expand Down Expand Up @@ -480,7 +501,7 @@ class HKGraph {
c.id = null;
return c;
}
return this.nodes[id] || this.virtualNodes[id] || this.contexts[id] || this.virtualContexts[id] || this.virtualLinks[id] || this.links[id] || this.connectors[id] || this.refs[id] || this.trails[id] || null;
return this.nodes[id] || this.virtualNodes[id] || this.contexts[id] || this.virtualContexts[id] || this.virtualLinks[id] || this.links[id] || this.connectors[id] || this.refs[id] || this.trails[id] || this.actions[id] || null;
}
/**
* Returns HK entities in this graph indexed by id.
Expand Down
1 change: 1 addition & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ exports.CONNECTOR_TYPE = require("./types").CONNECTOR;
exports.BIND_TYPE = require("./types").BIND;
exports.INTERFACE = require("./types").INTERFACE;
exports.TRAIL_TYPE = require("./types").TRAIL;
exports.ACTION_TYPE = require("./types").ACTION;
exports.VIRTUAL_NODE_TYPE = require("./types").VIRTUAL_NODE;
exports.VIRTUAL_CONTEXT_TYPE = require("./types").VIRTUAL_CONTEXT;
exports.VIRTUAL_LINK_TYPE = require("./types").VIRTUAL_LINK;
Expand Down
4 changes: 3 additions & 1 deletion dist/link.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ declare class Link extends HKEntity {
[x: string]: Object;
};
};
properties: any;
metaProperties: any;
/**
* Adds a new bind to this role;
*
Expand Down Expand Up @@ -91,6 +93,6 @@ declare class Link extends HKEntity {
};
}
declare namespace Link {
const type: string;
const type: "link";
}
import HKEntity = require("./hkentity");
10 changes: 9 additions & 1 deletion dist/node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ declare class Node extends HKEntity {
};
};
};
/**
* @public
* @type {Object.<string, string | number | Object>
*/
public properties: {
[x: string]: string | number | Object;
};
metaProperties: any;
/**
*
* @param {string} key Id of the interface
Expand Down Expand Up @@ -88,7 +96,7 @@ declare class Node extends HKEntity {
};
}
declare namespace Node {
const type: string;
const type: "node";
}
import HKEntity = require("./hkentity");
import FI = require("./fi/fi");
Expand Down
9 changes: 8 additions & 1 deletion dist/reference.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ declare class Reference extends Node {
*
*/
public ref: string | null;
type: "ref";
serialize: () => {
id: any;
type: "ref";
ref: any;
parent: any;
};
}
declare namespace Reference {
const type: string;
const type: "ref";
}
import Node = require("./node");
10 changes: 5 additions & 5 deletions dist/roletypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Copyright (c) 2016-present, IBM Research
* Licensed under The MIT License [see LICENSE for details]
*/
export var NONE: string;
export var SUBJECT: string;
export var OBJECT: string;
export var PARENT: string;
export var CHILD: string;
export const NONE: "n";
export const SUBJECT: "s";
export const OBJECT: "o";
export const PARENT: "p";
export const CHILD: "c";
Loading