97 lines
3.2 KiB
TypeScript
97 lines
3.2 KiB
TypeScript
import Node from './Node';
|
|
import KnowledgeDatabase from './KnowledgeDatabase';
|
|
export declare type ErrCallback = (err) => void;
|
|
export declare type NodeCallback = (err, node?: Node) => void;
|
|
/**
|
|
* @description KB service client version of KnowledgeDatabase Class.
|
|
*
|
|
* @class WebClient
|
|
* @memberof jibo.kb
|
|
* @extends {jibo.kb.KnowledgeDatabase}
|
|
* @param {string} kbName Name of this KB slice.
|
|
* @param {string} Base URL of KB service to attach to.
|
|
* @internal
|
|
*/
|
|
export default class WebClient extends KnowledgeDatabase {
|
|
httpUrl: string;
|
|
constructor(kbName: string, httpUrl: string);
|
|
/**
|
|
* Initalize this KnowledgeDatabase slice - currenty does
|
|
* nothing, you do not need to call this.
|
|
*
|
|
* @method jibo.kb.WebClient#init
|
|
* @param {Function} callback Called when finshed.
|
|
* @internal
|
|
*/
|
|
init(callback: ErrCallback): void;
|
|
/**
|
|
* Load a node of a given ID.
|
|
*
|
|
* @method jibo.kb.WebClient#load
|
|
* @param {string} id ID of node to load via the KB service.
|
|
* @param {Function} callback Called with (err, node).
|
|
* @internal
|
|
*/
|
|
load(id: string, callback: NodeCallback): void;
|
|
/**
|
|
* Load the root node of this KB slice.
|
|
*
|
|
* @method jibo.kb.WebClient#loadRoot
|
|
* @param {Function} callback Called with (err, rootNode).
|
|
* @internal
|
|
*/
|
|
loadRoot(callback: NodeCallback): void;
|
|
/**
|
|
* Save a given node into this KB slice.
|
|
*
|
|
* @method jibo.kb.WebClient#save
|
|
* @param {jibo.kb.Node} node The node to be saved.
|
|
* @param {Function} callback Called with (err) when done.
|
|
* @internal
|
|
*/
|
|
save(node: Node, callback: ErrCallback): void;
|
|
/**
|
|
* Remove a node from this KB slice.
|
|
*
|
|
* @method jibo.kb.WebClient#remove
|
|
* @param {string|jibo.kb.Node} idOrNode ID string or Node object to be removed.
|
|
* @param {Function} callback Called with (err) when done.
|
|
* @internal
|
|
*/
|
|
remove(idOrNode: string | Node, callback: ErrCallback): void;
|
|
/**
|
|
* Returns the root directory for this KB slice. Not needed for
|
|
* this Web Client version.
|
|
*
|
|
* @method jibo.kb.WebClient#getDirectory
|
|
* @returns {string} URL for this KB slice just in case something
|
|
* calls this expecting a directory.
|
|
* @internal
|
|
*/
|
|
getDirectory(): string;
|
|
/**
|
|
* Assemble URL from base URL provided to constructor and add the
|
|
* API version and kb name to the path.
|
|
*
|
|
* @method jibo.kb.WebClient#_makeUrl
|
|
* @param {string} addPath Additional path to add to URL after the KB name.
|
|
* @returns {string} Assembled URL.
|
|
* @private
|
|
* @internal
|
|
*/
|
|
private _makeUrl(addPath?);
|
|
/**
|
|
* Check http request result for null error object and 2xx result code and
|
|
* generate an error object if not (or pass through non null error object).
|
|
*
|
|
* @method jibo.kb.WebClient#_checkStatusCode
|
|
* @param {Error} err Error object returned from request.
|
|
* @param {Object} res Http request result object.
|
|
* @param {string} [message] Message to add to error object.
|
|
* @returns {Error} Error object or null.
|
|
* @private
|
|
* @internal
|
|
*/
|
|
private _checkStatusCode(err, res, message?);
|
|
}
|