Initial commit — jibo-cli v3.0.7 with bundled node_modules

This commit is contained in:
pasketti
2026-04-05 18:40:18 -04:00
commit b2569b4ce4
10488 changed files with 1631271 additions and 0 deletions

195
node_modules/jibo-kb/lib/dts/Asset.d.ts generated vendored Normal file
View File

@@ -0,0 +1,195 @@
import * as stream from 'stream';
export declare type ErrCallback = (err) => void;
export declare type DataCallback = (err?: any, data?: any) => void;
export declare type BlobCallback = (err?: any, blob?: Blob) => void;
export declare type FilenameCallback = (err?: any, filename?: string) => void;
export declare type FilenameOrUrlCallback = (err?: any, filenameOrUrl?: string) => void;
/** Asset storage object. Assets are binary files attached to a node.
* Use `node.createAsset()` to create an asset object. Asset objects have
* minimal meta information about the asset file: just subtype and
* file extension. All other metadata should be stored in the node it
* is attached to.
*
* @class Asset
* @memberof jibo.kb
* @param {string} [filenameOrUrl] Filename to asset on disk, or url
* to asset via KB service.
* @param {string} [subtype] Subtype name of asset. Defaults to `asset`.
* @param {string} [ext] Optional filename extension.
*/
export default class Asset {
_id: string;
subtype: string;
ext: string;
rootDir: string;
constructor(filenameOrURL?: string, subtype?: string, ext?: string);
/** Set root directory for this asset.
*
* @method jibo.kb.Asset#setRootDir
* @param {string} rootDir The full directory name or base URL
* that points to the storage area for this asset in its KB slice
* (which must be the same as the node it is attached to).
* @internal
*/
setRootDir(rootDir: string): void;
/** The filename for this asset, without any directory
* information. Format of the filename is:
*
* `{$_id}.{$subtype}.{$ext}`.
*
* If the asset doesn't have an extension, `{$ext}` (and its dot
* seperator) will be absent.
*
* @method jibo.kb.Asset#filename
* @returns {string} The filename.
*/
filename(): string;
/** Full path to the asset file on disk or a URL to fetch it
* via the KB service.
*
* @method jibo.kb.Asset#fullFilenameOrURL
* @returns {string} Full path filename or URL.
*/
fullFilenameOrURL(): string;
/** Print useful console logs from asset objects.
*
* @method jibo.kb.Asset#toString
* @returns {string} Full path filename or URL.
*/
toString(): string;
/** Write out the data for this asset file. Data can be provided
* as a readable stream, buffer, or blob.
*
* @method jibo.kb.Asset#save
* @param {Stream|Buffer|Blob} data Data to be saved in asset file.
* @param {Function} [callback] Called when done. If callback is
* omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
*/
save(data: any, callback: FilenameOrUrlCallback): any;
save(data: any): Promise<string>;
/** Set up an asset object by parsing an asset filename or
* URL. Sets the `_id`, `subtype`, and `ext`. Set rootDir if full
* path filename or URL.
*
* @method jibo.kb.Asset#setSelfFromFilenameOrURL
* @param {string} filenameOrUrl Filename, full path filename, or URL.
*/
setSelfFromFilenameOrURL(filenameOrURL: string): void;
/** Load the binary file pointed to by this asset object.
* Returns a buffer (via callback) with the contents (data) of the file.
*
* @method jibo.kb.Asset#load
* @param {Function} [callback] Called with (err, data) when
* done. If callback is omitted a promise that resolves to `data`
* is returned instead.
* @returns {Promise} A promise that resolves with the value of
* `data` if the callback is omitted.
*/
load(callback: DataCallback): any;
load(): Promise<any>;
/** Create a stream of the binary file this asset object points to.
* Return a stream (via callback) of the contents (data)
* of the file.
*
* @method jibo.kb.Asset#loadStream
* @returns {Stream} Stream of binary asset data.
*/
loadStream(): stream.Stream;
/** Load the binary file pointed to by this asset object.
* Returns a blob (via callback) with the contents (data) of the file.
*
* @method jibo.kb.Asset#loadBlob
* @param {Function} [callback] Called with (err, data) when
* done. If callback is omitted a promise that resolves to `data`
* is returned instead.
* @returns {Promise} A promise that resolves with the value of
* `data` if the callback is omitted.
*/
loadBlob(callback: BlobCallback): any;
loadBlob(): Promise<Blob>;
/** Remove the asset file from disk.
*
* @method jibo.kb.Asset#remove
* @param {Function} [callback] Called when done. If callback is
* omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
*/
remove(callback: ErrCallback): any;
remove(): Promise<any>;
/** Assemble the URL for this asset.
*
* @method jibo.kb.Asset#_url
* @returns {string} URL
* @private
*/
private _url();
/** Saves the asset data via the KB service web interface.
*
* @method jibo.kb.Asset#_saveViaWeb
* @private
*/
private _saveViaWeb(data, callback);
/** Set up an asset by parsing a filename
*
* @method jibo.kb.Asset#_setSelfFromFilename
* @param {string} filename Filename or full path filename
* @private
*/
private _setSelfFromFilename(filename);
/** Set up an asset from a URL
*
* @method jibo.kb.Asset#_setSelfFromURL
* @param {string} URL
* @private
*/
private _setSelfFromURL(httpurl);
/** Remove the asset file from disk via KB service.
*
* @method jibo.kb.Asset#_removeViaWeb
* @param {Function} callback Called when done
* @private
*/
private _removeViaWeb(callback);
/** Save asset file from buffer.
*
* @method jibo.kb.Asset#_saveBuffer
* @param {Buffer} buffer Data to be saved in asset file
* @param {Function} callback Called when done
* @private
*/
private _saveBuffer(buffer, callback);
/** Save asset file from stream.
*
* @method jibo.kb.Asset#_saveStream
* @param {Stream} stream Data to be saved in asset file
* @param {Function} callback Called when done
* @private
*/
private _saveStream(stream, callback);
/** Loads the asset via the KB service.
*
* @method jibo.kb.Asset#_loadBufferViaWeb
* @param {Function} callback Called with (err, data) when done
* @private
*/
private _loadBufferViaWeb(callback);
/** Loads a stream of the asset via the KB service.
*
* @method jibo.kb.Asset#_loadStreamViaWeb
* @returns {Stream} Stream of asset
* @private
*/
private _loadStreamViaWeb();
/** 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.Asset#_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
*/
private _checkStatusCode(err, res, message?);
}

75
node_modules/jibo-kb/lib/dts/Cache.d.ts generated vendored Normal file
View File

@@ -0,0 +1,75 @@
import Node from './Node';
export declare type NodeCallback = (err, node?: Node) => void;
export declare type LoadCallback = (id: string, callback: NodeCallback) => void;
/** Cache Class. Holds loaded nodes for a model that `begin()` has been
* called on.
*
* @class Cache
* @memberof jibo.kb
* @internal
*/
declare class Cache {
/** Retreive a node object from the cache.
*
* @method jibo.kb.Cache#fetch
* @param {string} id ID of node to fetch.
* @param {boolean} [quietly=false] Suppress warning message about node not found in cache.
* @returns {jibo.kb.Node} Node object if found in cache or undefined if not.
* @internal
*/
fetch(id: string, quietly?: boolean): Node;
/** Add a node object to the cache.
*
* @method jibo.kb.Cache#add
* @param {jibo.kb.Node} node Node object to add.
* @param {boolean} [quietly=false] Suppress warning message if node was already in cache (first in cache wins).
* @internal
*/
add(node: Node, quietly?: boolean): void;
/** Remove a node object from the cache.
*
* @method jibo.kb.Cache#remove
* @param {string|jibo.kb.Node} idOrNode ID string or Node object to be removed.
* @param {boolean} [quietly=false] Suppress warning message about node not found in cache.
* @internal
*/
remove(idOrNode: string | Node, quietly?: boolean): void;
/** Check if node is present in cache.
*
* @method jibo.kb.Cache#isPresent
* @param {string|jibo.kb.Node} idOrNode ID string or Node object to check cache for.
* @returns {boolean} `true` if node is in cache.
*/
isPresent(idOrNode: string | Node): boolean;
/** If a node is present in cache, return it (via callback),
* otherwise use the given `load` function to load it and put the
* loaded node into the cache before calling `callback`.
*
* @method jibo.kb.Cache#interceptLoad
* @param {string} id ID of node to fetch or load.
* @param {Function} callback Called with found or loaded node, (err, node).
* @param {Function} load Function to call to load the node if not already in cache, (id, callback).
* @internal
*/
interceptLoad(id: string, callback: NodeCallback, load: LoadCallback): void;
/** Add a value the cache.
*
* @method jibo.kb.Cache#_add
* @param {string} id Id of value to add.
* @param {any} value Value to be added to cache.
* @param {boolean} [quietly=false] Suppress warning message if node was already in cache (first in cache wins).
* @private
* @internal
*/
private _add(_id, value, quietly?);
/** Convert an idOrNode parameter to an id if it's a node.
*
* @method jibo.kb.Cache#_toId
* @param {string|Node} Id string, or node with an ._id property
* @returns {string} Id
* @private
* @internal
*/
private _toId(idOrNode);
}
export default Cache;

76
node_modules/jibo-kb/lib/dts/Database.d.ts generated vendored Normal file
View File

@@ -0,0 +1,76 @@
import Node from './Node';
export declare type CountCallback = (err, count?: number) => void;
export declare type NodeCallback = (err, node?: Node) => void;
export declare type NodesCallback = (err, nodes?: Node[]) => void;
/**
* Database Class. Interface to Node Embedded Database (NeDB).
*
* @class Database
* @memberof jibo.kb
* @param {string} filename Full path filename to NeDB file.
* @internal
*/
export default class Database {
filename: string;
nodes: any;
constructor(filename: string);
/** Attach to the NeDB filename given in constructor. File is
* compacted upon opening, or created if it doesn't exist.
*
* @method jibo.kb.Database#init
* @param {Function} callback Called when done compacting/creating/attaching.
* @internal
*/
init(callback: CountCallback): void;
/** Load node of given id. Returns null (via callback) if
* not found.
*
* @method jibo.kb.Database#load
* @param {string} id ID of node to load.
* @param {Function} callback Called with (err, node). Node (and err) is null if not found.
* @internal
*/
load(id: string, callback: NodeCallback): void;
/** Load one node of a given type. Used to find the 'root' node.
*
* @method jibo.kb.Database#loadNodeOfType
* @param {string} nodeType Node type to load.
* @param {Function} callback Called with (err, node). Node (and err) is null if not found.
* @internal
*/
loadNodeOfType(nodeType: string, callback: NodeCallback): void;
/** Load every node (in this kb slice) of a given type.
*
* @method jibo.kb.Database#loadNodesOfType
* @param {string} nodeType Node type to load.
* @param {Function} callback Called with (err, nodes) where nodes
* is an array of the found nodes.
* @internal
*/
loadNodesOfType(nodeType: string, callback: NodesCallback): void;
/** Save a given node.
*
* @method jibo.kb.Database#save
* @param {jibo.kb.Node} node The node to be saved.
* @param {Function} callback Called with (err, node) when finished.
* @internal
*/
save(node: Node, callback: NodeCallback): void;
/** Remove a node from this kb slice.
*
* @method jibo.kb.Database#remove
* @param {string|jibo.kb.Node} idOrNode Id string or Node object to be removed.
* @param {Function} callback Called with (err, numRemoved) when finished.
* @internal
*/
remove(idOrNode: string | Node, callback: CountCallback): void;
/** Convert an idOrNode parameter to an id if it's a node.
*
* @method jibo.kb.Database#_toId
* @param {string|jibo.kb.Node} ID string, or node with an ._id property.
* @returns {string} ID
* @private
* @internal
*/
private _toId(idOrNode);
}

60
node_modules/jibo-kb/lib/dts/DatabaseManager.d.ts generated vendored Normal file
View File

@@ -0,0 +1,60 @@
import KnowledgeDatabase from './KnowledgeDatabase';
export declare type CreateCallback = (err, created?: boolean) => void;
export declare type ExistsCallback = (err, exists?: boolean) => void;
export declare type KnowledgeDatabaseCallback = (err, database?: KnowledgeDatabase) => void;
/** Manager to keep track of created KnowledgeDatabase objects by name
* to ensure they have a single instance. Only important for file
* based KnowledgeDatabases, not really needed for the Web Client.
*
* Instantiated once as a singleton when imported by {@link jibo.kb.Model}.
*
* @class DatabaseManager
* @memberof jibo.kb
* @internal
*/
export declare class DatabaseManager {
static databases: {
[kbName: string]: KnowledgeDatabase;
};
static get(kbName: string, callback: KnowledgeDatabaseCallback): void;
static exists(kbName: string, callback: ExistsCallback): void;
readonly databases: {
[kbName: string]: KnowledgeDatabase;
};
/** Create a KB slice if it doesn't exist.
*
* @method jibo.kb.DatabaseManager#create
* @param {string} kbName KB slice name.
* @param {Function} callback Called when done with (err,
* created). `created` will be `true` if the KB slice needed to be
* created, `false` if it already existsed.
* @internal
*/
create(kbName: string, callback: CreateCallback): void;
/** Check if a KB slice was already created.
*
* @method jibo.kb.DatabaseManager#exists
* @param {string} kbName KB slice name.
* @param {Function} callback Called when done with (err, exists).
* @internal
*/
exists(kbName: string, callback: ExistsCallback): void;
/** Fetch or instantiate a new
* [KnowledgeDatabase]{@link jibo.kb.KnowledgeDatabase}
* based on the name. The KB slice must already exist.
*
* @method jibo.kb.DatabaseManager#get
* @param {string} kbName KB slice name.
* @param {Function} callback Called when done with (err, database).
* @internal
*/
get(kbName: string, callback: KnowledgeDatabaseCallback): void;
/** Delete a KnowledgeDatabase from the in-memory cache.
*
* @method jibo.kb.DatabaseManager#release
* @param {string} kbName Name of kb slice to release.
* @internal
*/
release(kbName: string): void;
}
export default DatabaseManager;

237
node_modules/jibo-kb/lib/dts/KnowledgeBase.d.ts generated vendored Normal file
View File

@@ -0,0 +1,237 @@
import Model from './Model';
import KnowledgeDatabase from './KnowledgeDatabase';
import Node from './Node';
import Asset from './Asset';
import DatabaseManager from './DatabaseManager';
import LoopModel from './LoopModel';
import UserNode from './UserNode';
export declare type ErrCallback = (err: Error) => void;
export declare type CreateCallback = (err: Error, created?: boolean) => void;
export declare type ExistsCallback = (err: Error, exists?: boolean) => void;
export declare type NodeConstructor = new (...args: any[]) => Node;
export declare type ModelConstructor = new (kbNames: string | string[], httpUrl: string) => Model;
export declare type ServiceObject = {
host: string;
port: string | number;
};
/**
* @description KnowledgeBase Class.
*
* @deprecated since version 3.0.0
* @class KnowledgeBase
* @memberof jibo.kb
*/
/** The Knowledge Base API.
*
* Can be accessed via `jibo.kb` (or `import {kb} from 'jibo'`).
*
* @namespace jibo.kb
*
* @example
* let model = jibo.kb.createModel('/skillname');
*
*/
declare class KnowledgeBase {
httpUrl: string;
Asset: typeof Asset;
KnowledgeDatabase: typeof KnowledgeDatabase;
Model: typeof Model;
Node: typeof Node;
UserNode: typeof UserNode;
databaseManager: DatabaseManager;
config: any;
onInitCallbacks: ErrCallback[];
/**
* Loop model information.
* @name jibo.kb#loop
* @type {jibo.kb.loop.LoopModel}
*/
loop: LoopModel;
/**
* Media list model information.
* @name jibo.kb#media
* @type {jibo.kb.media.MediaModel}
*/
media: any;
constructor();
/** Initialize the kb API singleton object.
*
* @method jibo.kb#init
* @param {Object} service Service object with host and port of the KB service.
* @param {Function} callback Called when done.
* @internal
*/
init(service: ServiceObject, callback?: ErrCallback): void;
/** Provides a callback when the KB is initialized. This allows utilities to load KB in
* their own initialization without knowledge of what the skill is doing.
*
* @method jibo.kb#onInit
* @param {Function} callback Called when done. If callback is omitted a promise that resolves
* once the KB has been initialized is returned.
* @returns {Promise} A promise that resolves once the KB has been initialized is returned if
* the callback is omitted.
* @internal
*/
onInit(callback: ErrCallback): any;
onInit(): Promise<void>;
/** Optionally attach a loop model as `kb.loop`.
* Call this only after init() has been called.
*
* @method jibo.kb#initLoop
* @internal
*/
initLoop(): void;
/** Optionally attach a media model as `kb.media`.
* Call this only after init() has been called.
*
* @method jibo.kb#initMedia
* @internal
*/
initMedia(): void;
/** Create a KB slice. KB slices must be created before they are
* used the first time. This method creates the KB slice, or does
* nothing if it has already been created. The callback is
* supplied with a boolen indicating if the slice needed to be
* created. If callback is omitted a promise is returned instead.
*
* @method jibo.kb#createSlice
* @param {string} sliceName Name of KB slice to create.
* KB name must start with a `/`, followed by the skill name.
* @param {string} [httpUrl] Base URL of KB service. Defaults to
* URL generated from the service object given to `init()`.
* @param {Function} [callback] Called with `(err, created)`
* arguments. `created` is `false` if the KB slice already
* existed. If callback is omitted a promise that returns
* `created` is returned instead.
* @returns {Promise} A promise that resolves with the value of
* `created` if the callback is omitted.
*/
createSlice(sliceName: string, callback: CreateCallback): any;
createSlice(sliceName: string, httpUrl: string, callback: CreateCallback): any;
createSlice(sliceName: string, httpUrl?: string): Promise<boolean>;
/** Check if a KB slice exists. The callback is supplied with a
* boolen indicating if the slice exists. If callback is omitted a
* promise is returned instead.
*
* @method jibo.kb#existsSlice
* @param {string} sliceName Name of KB slice to check.
* KB name must start with a `/`, followed by the skill name.
* @param {string} [httpUrl] Base URL of KB service. Defaults to
* URL generated from the service object given to `init()`.
* @param {Function} [callback] Called with `(err, exists)`
* arguments. `exists` is `true` if the KB slice exists. If
* callback is omitted a promise that returns `exists` is returned
* instead.
* @returns {Promise} A promise that resolves with the value of
* `exists` if the callback is omitted.
*/
existsSlice(sliceName: string, callback: ExistsCallback): void;
existsSlice(sliceName: string, httpUrl: string, callback: ExistsCallback): void;
existsSlice(sliceName: string, httpUrl?: string): Promise<boolean>;
/** Create a new Model object. Models are the primary interface
* to the knowledge base.
*
* @method jibo.kb#createModel
* @param {string|string[]} kbNames Array of knowledge base slice
* names to include in model, in order of precedence. A single
* KB name can be given as a string instead of an array of strings.
* KB names must start with a `/`, followed by the skill name.
* @param {string} [httpUrl] Base URL of KB.
* service. Defaults to URL generated from the service object
* given to `init()`.
* @param {string} [httpUrl] Base URL of KB service. Defaults to
* URL generated from the service object given to `init()`.
* @returns {jibo.kb.Model} New Model object.
*/
createModel(kbNames: string | string[], httpUrl?: string): Model;
/** Register a Node subclass to be instantiated when a node of a
* given type is loaded or created.
*
* @method jibo.kb#registerNodeClass
* @param {string|string[]} nodeType Node type to use this
* subclass for.
* @param {Function} classConstruction The constructor function
* for the subclass.
* @param {string} [kbName] Name of KB to limit the use
* of this subclass to. Defaults to all KBs.
*/
registerNodeClass(nodeType: string, classConstructor: NodeConstructor, kbName?: string): void;
/** Register a Model subclass to be instantiated for a given KB name
* list.
*
* @method jibo.kb#registerModelClass
* @param {string|string[]} kbNames KB name or name list use this
* subclass for.
* @param {Function} classConstructor The constructor function for
* the subclass.
*/
registerModelClass(kbNames: string | string[], classConstructor: ModelConstructor): void;
/** Use the node type to find a Node subclass in the Node Class
* registry. Default to the plain `Node` object if nothing
* matches.
*
* @method jibo.kb#findNodeClass
* @param {string} nodeType Type of node.
* @param {string} kbName Name of KB slice.
* @returns {Function} Node class constructor.
*/
findNodeClass(nodeType: string, kbName: string): NodeConstructor;
/** Use the given KB slice names to find a Model subclass in the
* Model subclass registry. Defaults to the plain `Model` object
* if nothing matches.
*
* @method jibo.kb#findModelClass
* @param {string|string[]} kbNames Array of knowledge base slice
* names.
* @returns {Function} Model class constructor.
*/
findModelClass(kbNames: string | string[]): ModelConstructor;
/** Unload a given kb slice from the Skills Service Manager memory
* and remove it from disk. Also removes any sub-kbs inside this
* slice. For example, if you remove `/jibo`, that would also
* remove `/jibo/loop`, `/jibo/settings` and all other kb slices
* under `/jibo`. If callback is omitted a promise is returned
* instead.
*
* @method jibo.kb#removeSlice
* @param {string} sliceName Name of kb slice to be removed,
* including all of its sub-slices (if any).
* @param {Function} [callback] Called when done, with `err`
* parameter if there was an error. If callback is omitted a
* promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
*/
removeSlice(sliceName: string, callback: ErrCallback): any;
removeSlice(sliceName: string): Promise<any>;
/** Unload all kb slices from the Skills Service Manager memory,
* stop the Loop Manager, and delete the ENTIRE KNOWLEDGEBASE!
*
* @method jibo.kb#removeAll
* @param {Function} [callback] Called when done, with `err`
* parameter if there was an error. If callback is omitted a
* promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
* @internal
*/
removeAll(callback: ErrCallback): any;
removeAll(): Promise<any>;
/** 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
*/
private _checkStatusCode(err, res, message?);
/** Convert a single item to an array for arguments that may be a
* single thing or an array of things.
*
* @method jibo.kb#_toArray
* @private
*/
private _toArray<T>(items);
}
export default KnowledgeBase;

178
node_modules/jibo-kb/lib/dts/KnowledgeDatabase.d.ts generated vendored Normal file
View File

@@ -0,0 +1,178 @@
import Database from './Database';
import Node from './Node';
export declare type ErrCallback = (err) => void;
export declare type NodeCallback = (err, node?: Node) => void;
export declare type CountCallback = (err, count?: number) => void;
export declare type NodeConstructor = new (...args: any[]) => Node;
/** KnowledgeDatabase Class. Represents a single KB instance or
* "slice" (e.g. `/jibo.loop` or `/snap`) with all it's nodes and
* assets. Uses a Database class instance (i.e. Node Embedded Database [NeDB]) to load/store
* the nodes.
*
* Not usually used directly. Instead A Model assembles one or more
* KnowledgeDatabase objects into a model and interaction with the
* databases is done through the Model.
*
* This version of the class is intended for the server side of the KB
* service which maniplates the on disk files using the Database class
* (which uses itself NeDB). WebClient is a subclass of this class
* and is what is used client side.
*
* @class KnowledgeDatabase
* @memberof jibo.kb
* @param {string} kbName Name of this KB slice.
* @internal
*/
declare class KnowledgeDatabase {
kbName: string;
dbDirectory: string;
dbFilename: string;
database: Database;
/** Return the root directory for all KnowledgeDatabases.
*
* @method jibo.kb.KnowledgeDatabase.getRootDirectory
* @static
* @returns {string} Full path to the root directory of all
* KnowledgeDatabases.
* @internal
*/
static getRootDirectory(): string;
/** Calculate the full path to the directory of a KB slice.
*
* @method jibo.kb.KnowledgeDatabase.getKbDirectory
* @static
* @param {string} kbName Name of KB slice.
* @returns {string} Full path to the KB slice directory.
* @internal
*/
static getKbDirectory(kbName: string): string;
/** Calculate the full path to the NeDB file of a KB slice.
*
* @method jibo.kb.KnowledgeDatabase.getKbFilename
* @static
* @param {string} kbName Name of KB slice.
* @returns {string} Full path to the NeDB `nodes` file.
* @internal
*/
static getKbFilename(kbName: string): string;
/** Validate the kbName. We are starting out very conservatively.
* Throws an error if the name doesn't pass.
*
* @method jibo.kb.KnowledgeDatabase.validateKbName
* @static
* @param {string} kbName Name of KB slice.
* @private
* @internal
*/
private static _validateKbName(kbName);
/** Determine if we are running on the robot or in the simulator.
*
* @method jibo.kb.KnowledgeDatabase#_onRobot
* @returns {boolean} `true` if on robot. `false` if in simulator.
* @static
* @private
* @internal
*/
private static _onRobot();
constructor(kbName: string);
/** Initalize this KnowledgeDatabase slice - Attach to or create
* the underlying file on disk (via the Database class).
*
* @method jibo.kb.KnowledgeDatabase#init
* @param {Function} callback Called with (err) when done.
*/
init(callback: ErrCallback): void;
/** Load a node of a given ID.
*
* @method jibo.kb.KnowledgeDatabase#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.KnowledgeDatabase#loadRoot
* @param {Function} callback Called with (err, rootNode).
* @internal
*/
loadRoot(callback: NodeCallback): void;
/** Save a given node into this KB slice.
*
* @method jibo.kb.KnowledgeDatabase#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.KnowledgeDatabase#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: CountCallback): void;
/** Given an object from a Database (or from a web request),
* convert into a full Node object. Uses the Node Class registry
* on the `kb` object to find the proper Node subclass, if any.
* Also binds the Node to this KnowledgeDatabase.
*
* @method jibo.kb.KnowledgeDatabase#createNodeFromObject
* @param {Object} object Object to be converted to a Node
* object. Must have an `_id` property, should have a `type`
* property (defaults to `node`).
* @returns {jibo.kb.Node} The Node object, or a Node subclass object.
* @internal
*/
createNodeFromObject(object: {
type: string;
}): Node;
/** Create a new Node object. Uses the Node Class registry on the
* `kb` object to find a proper Node subclass, if any. Also binds
* the Node to this KnowledgeDatabase.
*
* @method jibo.kb.KnowledgeDatabase#createNode
* @param {string|Class} nodeTypeOrClass A string stating the node
* type, or a Node Class constructor.
* @param {Object} [data] Inital node.data.
* @returns {jibo.kb.Node} The new Node or Node subclass object.
* @internal
*/
createNode(nodeTypeOrClass: string | NodeConstructor, data?: any): Node;
/** Bind a given node to this KB slice.
*
* @method jibo.kb.KnowledgeDatabase#adoptNodeAsOurOwn
* @param {jibo.kb.Node} node Node to be adopted.
* @internal
*/
adoptNodeAsOurOwn(node: Node): void;
/** Return the directory for this KnowledgeDatabase.
*
* @method jibo.kb.KnowledgeDatabase#getDirectory
* @returns {string} Full path to the directory of this
* KnowledgeDatabase.
* @internal
*/
getDirectory(): string;
/** Convert an idOrNode parameter to an id if it's a node.
*
* @method jibo.kb.KnowledgeDatabase#toId
* @param {string|jibo.kb.Node} Id string, or node with an ._id property.
* @returns {string} ID
* @private
* @internal
*/
protected toId(idOrNode: string | Node): string;
/** Create directory for this KnowledgeDatabase if it doesn't
* exist.
*
* @method jibo.kb.KnowledgeDatabase#_setupDirectory
* @param {Function} callback Called with (err) when done.
* @private
* @internal
*/
private _setupDirectory(callback);
}
export default KnowledgeDatabase;

226
node_modules/jibo-kb/lib/dts/LoopModel.d.ts generated vendored Normal file
View File

@@ -0,0 +1,226 @@
import UserNode from './UserNode';
import Model from './Model';
import Node from './Node';
export declare type ErrCallback = (err) => void;
export declare type UsersCallback = (err, users?: UserNode[]) => void;
export declare type UserCallback = (err: string, user?: UserNode) => void;
export declare type UserNameCallback = (err: string, userName?: string) => void;
export interface EnrollmentParams {
memberId: string;
loopId?: string;
voice?: boolean;
face?: boolean;
}
/**
* Jibo KB Loop API
* @namespace jibo.kb.loop
*/
/** LoopModel Class. The Loop Model subclass
*
* @class LoopModel
* @extends jibo.kb.Model
* @memberof jibo.kb.loop
* @example
* let model = jibo.kb.loop.createModel('/skillname');
*/
export default class LoopModel extends Model {
/** Load status `accepted` loop members. These are the current
* loop members. If callback is omitted a promise is returned
* instead.
*
* @method jibo.kb.loop.LoopModel#loadLoop
* @param {Function} [callback] Called with (err, loop). If callback
* is omitted a promise that resolves to `loop` is returned
* instead.
* @returns {Promise} A promise that resolves with the value of
* `loop` if the callback is omitted.
*/
loadLoop(callback: UsersCallback): any;
loadLoop(): Promise<UserNode[]>;
/** Load status `invited` loop members. These are loop the
* members who have not yet accepted their invitation to join the
* loop. If callback is omitted a promise is returned instead.
*
* @method jibo.kb.loop.LoopModel#loadLoopInvited
* @param {Function} [callback] Called with (err, loop). If callback
* is omitted a promise that resolves to `loop` is returned
* instead.
* @returns {Promise} A promise that resolves with the value of
* `loop` if the callback is omitted.
*/
loadLoopInvited(callback: UsersCallback): any;
loadLoopInvited(): Promise<UserNode[]>;
/** Load `isActive` loop members.
*
* @method jibo.kb.loop.LoopModel#loadLoopActive
* @param {Function} [callback] Called with (err, loop). If callback
* is omitted a promise that resolves to `loop` is returned
* instead.
* @returns {Promise} A promise that resolves with the value of
* `loop` if the callback is omitted.
*/
loadLoopActive(callback: UsersCallback): any;
loadLoopActive(): Promise<any>;
/** Load all loop members, including where `status` is `deleted`.
*
* @method jibo.kb.loop.LoopModel#loadLoopAll
* @param {Function} [callback] Called with (err, loop). If callback
* is omitted a promise that resolves to `loop` is returned
* instead.
* @returns {Promise} A promise that resolves with the value of
* `loop` if the callback is omitted.
*/
loadLoopAll(callback: UsersCallback): any;
loadLoopAll(): Promise<UserNode[]>;
/** Retrieve loop member's node.
*
* @method jibo.kb.loop.LoopModel#getUserNodeById
* @param {String} id The loop member's ID.
* @param {Function} [callback] Called with (err, node). If callback
* is omitted a promise that resolves to `node` is returned
* instead.
* @returns {Promise} A promise that resolves with the value of
* `node` if the callback is omitted.
* @internal
*/
getUserNodeById(id: string, callback: UserCallback): any;
getUserNodeById(id: string): Promise<UserNode>;
/** Retrieve loop member's written name.
*
* @method jibo.kb.loop.LoopModel#getWrittenNameById
* @param {String} id The loop member's ID.
* @param {Function} [callback] Called with (err, name). If
* callback is omitted a promise that resolves to `name` is
* returned instead.
* @returns {Promise} A promise that resolves with the value of
* `name` if the callback is omitted.
*/
getWrittenNameById(id: string, callback: UserNameCallback): any;
getWrittenNameById(id: string): Promise<string>;
/** Retrieve loop member's spoken name.
*
* @method jibo.kb.loop.LoopModel#getSpokenNameById
* @param {String} id The loop member's ID.
* @param {Function} [callback] Called with (err, name). If callback
* is omitted a promise that resolves to `name` is returned
* instead.
* @returns {Promise} A promise that resolves with the value of
* `name` if the callback is omitted.
*/
getSpokenNameById(id: string, callback: UserNameCallback): any;
getSpokenNameById(id: string): Promise<string>;
/** Fetch status `accepted` loop members from the
* cache. These are the current loop members.
*
* @method jibo.kb.loop.LoopModel#fetchLoop
* @returns {jibo.kb.loop.UserNode[]} Array of loop members.
*/
fetchLoop(): UserNode[];
/** Fetch status `invited` loop members from the
* cache. These are the loop members who have not yet accepted
* their invitation to join the loop.
*
* @method jibo.kb.loop.LoopModel#fetchLoopInvited
* @returns {jibo.kb.loop.UserNode[]} Array of invited loop members.
*/
fetchLoopInvited(): UserNode[];
/** Fetch `isActive` loop members from the cache.
*
* @method jibo.kb.loop.LoopModel#fetchLoopActive
* @returns {jibo.kb.loop.UserNode[]} Array of active loop members.
*/
fetchLoopActive(): UserNode[];
/** Fetch all loop members from the cache, including where status
* is `deleted`.
*
* @method jibo.kb.loop.LoopModel#fetchLoopAll
* @returns {jibo.kb.loop.UserNode[]} Array of all loop members.
*/
fetchLoopAll(): UserNode[];
/** Set the phonetic name of a loop member in the cloud.
*
* @method jibo.kb.loop.LoopModel#setPhoneticName
* @param {string|jibo.kb.Node} idOrNode The loop member's
* ID or Node.
* @param {String} phoneticName The phonetic name value.
* @param {Function} [callback] Called when done. If callback is
* omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
* @internal
*/
setPhoneticName(idOrNode: string | Node, phoneticName: string, callback: ErrCallback): any;
setPhoneticName(idOrNode: string | Node, phoneticName: string): Promise<any>;
/** Set the face enrollment flag of a loop member in the cloud.
*
* @method jibo.kb.loop.LoopModel#setEnrollmentFace
* @param {string|jibo.kb.Node} idOrNode The loop member's
* ID or Node.
* @param {boolean} face The face enrollment flag.
* @param {Function} [callback] Called when done. If callback is
* omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
* @internal
*/
setEnrollmentFace(idOrNode: string | Node, face: boolean, callback: ErrCallback): any;
setEnrollmentFace(idOrNode: string | Node, face: boolean): Promise<any>;
/** Set the voice enrollment flag of a loop member in the cloud.
*
* @method jibo.kb.loop.LoopModel#setEnrollmentVoice
* @param {string|jibo.kb.Node} idOrNode The loop member's
* ID or Node.
* @param {boolean} voice The voice enrollment flag.
* @param {Function} [callback] Called when done. If callback is
* omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
* @internal
*/
setEnrollmentVoice(idOrNode: string | Node, voice: boolean, callback: ErrCallback): any;
setEnrollmentVoice(idOrNode: string | Node, voice: boolean): Promise<any>;
/** Set the enrollment flag(s) of a loop member in the cloud.
*
* @method jibo.kb.loop.LoopModel#setEnrollment
* @param {Object} params Enrollment
* parameters (memberId and face/voice flags)
* @param {Function} [callback] Called when done. If callback is
* omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
* @internal
*/
setEnrollment(params: EnrollmentParams, callback: ErrCallback): any;
setEnrollment(params: EnrollmentParams): Promise<any>;
/** Filter out loop members that have not accepted yet.
*
* @method jibo.kb.loop.LoopModel#_onlyAccepted
* @param {jibo.kb.loop.UserNode[]} loop Loop nodes to filter.
* @returns {jibo.kb.loop.UserNode[]} Loop nodes where `status` is 'accepted'.
* @private
*/
private _onlyAccepted(loop);
/** Filter out loop members that don't have a pending invitation.
*
* @method jibo.kb.loop.LoopModel#_onlyInvited
* @param {jibo.kb.loop.UserNode[]} loop Loop nodes to filter.
* @returns {jibo.kb.loop.UserNode[]} Loop nodes where `status` is 'invited'.
* @private
*/
private _onlyInvited(loop);
/** Filter out loop members that are not `isActive`.
*
* @method jibo.kb.loop.LoopModel#_onlyActive
* @param {jibo.kb.loop.UserNode[]} loop Loop nodes to filter.
* @returns {jibo.kb.loop.UserNode[]} Loop nodes where `isActive` is true.
* @private
*/
private _onlyActive(loop);
/** 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
*/
private _checkStatusCode(err, res, message?);
}

265
node_modules/jibo-kb/lib/dts/Model.d.ts generated vendored Normal file
View File

@@ -0,0 +1,265 @@
import Cache from './Cache';
import KnowledgeDatabase from './KnowledgeDatabase';
import Node from './Node';
export declare type ErrCallback = (err) => void;
export declare type NodeCallback = (err, node?: Node) => void;
export declare type NodesCallback = (err, nodes?: Node[]) => void;
export declare type ModelConstructor = new (kbNames: string | string[], httpUrl: string) => Model;
/** Combine multiple KB slices into one. Model instances are the main
* interaction point with the Knowledge Base. Methods for following
* edges between nodes are here.
*
* Extend this class to add model specific methods to a Model.
*
* @class Model
* @memberof jibo.kb
* @param {string|string[]} kbNames KB slice names to use in this
* model.
* @param {string} httpUrl Base URL of KB service to use.
*/
export default class Model {
private static modelClassRegistry;
pool: KnowledgeDatabase[];
cache: Cache;
roots: {
[kbName: string]: Node;
};
kbNames: string[];
httpUrl: string;
/** Register a Model subclass to be instantiated for a given KB name
* list.
*
* @method jibo.kb.Model.registerModelClass
* @static
* @param {string|string[]} kbNames KB name or name list use this
* subclass for.
* @param {Function} classConstructor The constructor function for
* the subclass.
* @internal
*/
static registerModelClass(kbNames: string | string[], classConstructor: ModelConstructor): void;
/** Use the given KB slice names to find a Model subclass in the
* Model subclass registry. Defaults to the plain `Model` object
* if nothing matches.
*
* @method jibo.kb.Model.findModelClass
* @static
* @param {string|string[]} kbNames Array of knowledge base slice
* names.
* @returns {Function} Model class constructor.
* @internal
*/
static findModelClass(kbNames: string | string[]): ModelConstructor;
constructor(kbNames: string | string[], httpUrl?: string);
/** Initalize the model and all its kb slices.
* Not needed when using the KB service as a client.
*
* @method jibo.kb.Model#init
* @param {Function} callback Callback for the method.
* @internal
*/
init(callback: ErrCallback): void;
/** Create a new Model object.
*
* This behaves the same as `kb.createModel()`, except the KB
* names are not required to start with /. KB names that don't
* start with / will be relative to this Model. Specifically, they
* will relative to the KB name of the first KB in this model.
*
* For example, if this Model has the KB names `['/snap',
* '/snap/albums']` and this method is called as
* `model.createModel(['history', '/jibo.loop'])`, then the new
* model returned by this method will have the KB names
* `['/snap/history', '/jibo.loop']`.
*
* @method jibo.kb.Model#createModel
* @param {string|string[]} kbNames KB slice names to use in new
* model.
* @param {string} [httpUrl] Base URL of KB service to use
* (defaults to same URL as `this`).
* @returns {jibo.kb.Model} New Model object
*/
createModel(kbNames: string | string[], httpUrl?: string): Model;
/** Create a new empty node on this Model. Will be attached to the
* first KB in this Model.
*
* @method jibo.kb.Model#createNode
* @param {string} nodeType Node type.
* @param {Object} [data] Initial data.
* @returns {jibo.kb.Node} New node object
*/
createNode(nodeType: string, data?: any): Node;
/** Load a node or array of nodes, by their IDs. All KBs in this
* Model slices are searched in order until found. If node is not
* found result will be `null`. If an array is supplied, then
* multiple IDs are searched for, and an array of results is
* returned. If callback is omitted, a promise is returned
* instead.
*
* @method jibo.kb.Model#load
* @param {string|string[]} ids ID or array of IDs to load.
* @param {Function} [callback] `(err, nodes) => {}`. If callback is
* omitted, a promise that resolves to `nodes` is returned instead.
* @returns {Promise} A promise that resolves with the value of
* `node` if the callback is omitted.
*/
load(id: string, callback: NodeCallback): any;
load(ids: string[], callback: NodesCallback): any;
load(id: string): Promise<Node>;
load(ids: string[]): Promise<Node[]>;
loadList(ids: string[], callback: NodesCallback): any;
fetchList(ids: string[], quietly?: boolean): Node[];
/** Load the root node of the first KB. If a KB slice name is
* given, then load the root node for that KB instead. If callback
* is omitted a promise is returned instead.
*
* @method jibo.kb.Model#loadRoot
* @param {string} [kbName] Name of KB slice to load root node
* from. Default is first slice.
* @param {Function} [callback] (err, rootNode) => {}. If callback
* is omitted a promise that resolves to `rootNode` is returned
* instead.
* @returns {Promise} A promise that resolves with the value of
* `rootNode` if the callback is omitted.
*/
loadRoot(callback: NodeCallback): any;
loadRoot(kbName: string, callback: NodeCallback): any;
loadRoot(): Promise<Node>;
loadRoot(kbName: string): Promise<Node>;
/** Preload all nodes connected by the layer names into the
* cache. Does not return the nodes. If callback is omitted a
* promise is returned instead.
*
* @method jibo.kb.Model#loadLayers
* @param {jibo.kb.Node} node Initial node to start from.
* @param {string|string[]} layers Edge names to follow.
* @param {Function} [callback] Callback for the method. If callback
* is omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
*/
loadLayers(node: Node, layers: string | string[], callback: Function): any;
loadLayers(node: Node, layers: string | string[]): Promise<any>;
/** Save all nodes connected by the layer names. Only used after
* activating the cache and preloading the given layers with
* loadLayers(). If callback is omitted a promise is returned
* instead.
*
* @method jibo.kb.Model#saveLayers
* @param {jibo.kb.Node} node Initial node to start from.
* @param {string|string[]} layers Edge names to follow.
* @param {Function} [callback] Callback for the method. If callback
* is omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
*/
saveLayers(node: Node, layers: string | string[], callback: Function): any;
saveLayers(node: Node, layers: string | string[]): Promise<any>;
/** Load all nodes connected by the layer names. Execute the given
* action once on each node. If callback is omitted a promise is
* returned instead.
*
* @method jibo.kb.Model#visitLayers
* @param {jibo.kb.Node} node Initial node to start from.
* @param {string|string[]} layers Edge names to follow.
* @param {Function} action `(eachNode, callback) => {}`
* @param {Function} [callback] Callback for the method. If callback
* is omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
*/
visitLayers(node: Node, layers: string | string[], action: Function, callback: Function): any;
visitLayers(node: Node, layers: string | string[], action: Function): Promise<any>;
/** Create a clone of this Model object and its slices, but with
* the cache enabled. Cache based operations are intended to be
* short term in nature. Release the clone for garbage collection
* when finished.
*
* @method jibo.kb.Model#begin
* @returns {jibo.kb.Model} A new Model object.
*/
begin(): Model;
/** Synchronously fetch a node, or array of nodes, from the
* cache. Use on models created with `begin()` and preloaded with
* nodes. Nodes searched for but not found during preloading will
* be null. Nodes not preloaded will be undefined.
*
* @method jibo.kb.Model#fetch
* @param {string|string[]} ids ID or array of IDs node to fetch.
* @param {boolean} [quietly] Suppress warning if node not found
* in cache.
* @throws Exception if cache is not enabled.
* @returns {jibo.kb.Node} Node or `null` if not found. If
* an array of IDs is supplied, then an array of nodes is
* returned.
*/
fetch(id: string, quietly?: boolean): Node;
fetch(ids: string[], quietly?: boolean): Node[];
/** Synchronously fetch the root node of the first KB from cache.
* If a KB slice name is given, then load the root node for that
* KB instead.
*
* @method jibo.kb.Model#fetchRoot
* @param {string} [kbName] Name of KB slice to load root node
* from. Default is first slice.
* @param {boolean} [quietly] Suppress warning if root node not
* found in cache.
* @throws Exception if cache is not enabled.
* @returns {jibo.kb.Node} Root node or `null` if not in cache.
*/
fetchRoot(kbName?: string, quietly?: boolean): Node;
/** Turn on the cache. Don't call this directly, use begin() instead.
* @method jibo.kb.Model#enableCache
* @private
*/
protected enableCache(): void;
/** Actual load command. Wrapped by interceptLoad when cache is
* enabled.
*
* @method jibo.kb.Model#_load
* @param {string} id Id of node to load
* @param {Function} callback (err, node) => {}
* @private
*/
private _load(id, callback);
/** Load a single node by its id. All KBs in this
* Model will be searched in order until found. Null returned (via
* callback) if not found.
*
* @method jibo.kb.Model#_loadOne
* @param {string} id ID to load.
* @param {Function} [callback] (err, node) => {}.
* @private
*/
private _loadOne(id, callback);
/** Load an array of nodes by id. All KBs in this Model will be
* searched, in order, for each id in the array. An empty array is
* returned (via callback) if none of the ids are found.
*
* @method jibo.kb.Model#_loadArray
* @param {string[]} ids Array of IDs of nodes to load.
* @param {Function} [callback] (err, nodes) => {}.
* @private
*/
private _loadArray(ids, callback);
/** Look through the pool and return the kb slice
* that has the given name
*
* @method jibo.kb.Model#_getKnowledgeDatabase
* @param {string} kbName Name of kb slice to find in pool
* @returns {jibo.kb.KnowledgeDatabase} Matching kb slice object, or
* undefined if not found
* @private
*/
private _getKnowledgeDatabase(kbName);
/** check if cache is enabled and throw exception if not
*
* @method jibo.kb.Model#_assertCache
* @private
*/
private _assertCache();
/** Convert a single item to an array for arguments that may be a
* single thing or an array of things
*
* @method jibo.kb.Model#<_toArray
* @private
*/
private _toArray<T>(items);
}

222
node_modules/jibo-kb/lib/dts/Node.d.ts generated vendored Normal file
View File

@@ -0,0 +1,222 @@
import Asset from './Asset';
import KnowledgeDatabase from './KnowledgeDatabase';
export declare type ErrCallback = (err) => void;
export declare type NodeConstructor = new (...args: any[]) => Node;
/** Knowledge Base document store object. This is where data lives.
* Nodes have edges which point to other nodes in any KB slice
* (possibly even slices not in your current model). Edges have names
* to group them into layers.
*
* All user specified data goes into `node.data`.
*
* `model.createNode()` is typically used to create new nodes so the
* nodes will be bound to a KB slice for saving.
*
* @class Node
* @memberof jibo.kb
* @param {string} [nodeType] Type of node. Defaults to 'node'.
* @param {Object} [data] Initial data.
* @param {Object} [cloneFrom] Object or node to clone from.
*/
export default class Node {
private static nodeClassRegistry;
_id: string;
type: string;
data: any;
created: number;
updated: number;
edges: {
[id: string]: string[];
};
assets: {
[id: string]: string[];
};
getKb: () => KnowledgeDatabase;
/** Register a Node subclass to be instantiated when a node of a
* given type is loaded or created.
*
* @method jibo.kb.Node.registerNodeClass
* @static
* @param {string|string[]} nodeType Node type to use this
* subclass for.
* @param {Function} classConstruction The constructor function
* for the subclass.
* @param {string} [kbName] Name of KB to limit the use
* of this subclass to. Defaults to all KBs.
* @internal
*/
static registerNodeClass(nodeType: string, classConstructor: NodeConstructor, kbName?: string): void;
/** Use the node type to find a Node subclass in the Node Class
* registry. Default to the plain `Node` object if nothing
* matches.
*
* @method jibo.kb.Node.findNodeClass
* @static
* @param {string} nodeType Type of node.
* @param {string} kbName Name of KB slice.
* @returns {Function} Node class constructor.
* @internal
*/
static findNodeClass(nodeType: string, kbName: string): NodeConstructor;
constructor(nodeType?: string, data?: any, cloneFrom?: any);
/** Save the node into KB slice it is bound to.
* Also sets the `node.updated` timestamp.
*
* @method jibo.kb.Node#save
* @param {Function} [callback] Called when node is finished
* saving. If callback is omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
*/
save(callback: ErrCallback): any;
save(): Promise<any>;
/** Remove the node from KB slice it is bound to.
*
* @method jibo.kb.Node#remove
* @param {Function} [callback] Called when node is finished being
* removed. If callback is omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
*/
remove(callback: ErrCallback): any;
remove(): Promise<any>;
/** Add edges to this node. Edges will have the name given by
* layer, or will be taken from the node types (but nodes must be
* given in that case, no id strings).
*
* @method jibo.kb.Node#addEdges
* @param {string|jibo.kb.Node|string[]|jibo.kb.Node[]} idsOrNodes Ids of edges to
* add to this node. Ids will be gotten from any nodes provided.
* @param {string} [layer] Added edges will have this name. If
* Nodes are given and layer is not specified, the edge name will
* be taken from the node type.
*/
addEdges(idsOrNodes: string | string[] | Node | Node[], layer?: string): void;
/** Remove edges of the given layer name from this node. Layer can
* be omitted if nodes are given and the node types match the
* layer names of the edges to be removed.
*
* @method jibo.kb.Node#removeEdges
* @param {string|jibo.kb.Node|string[]|jibo.kb.Node[]} idsOrNodes Ids of edges to
* remove from this node. Ids will be gotten from any nodes
* provided.
* @param {string} [layer] Remove edges with this name. If Nodes
* are given and layer is not specified, the edge name will be
* taken from the node type for each node id.
*/
removeEdges(idsOrNodes: string | string[] | Node | Node[], layer?: string): void;
/** Remove all edges of a given name.
*
* @method jibo.kb.Node#clearEdges
* @param {string|string[]} layers The layer names (edge names) to remove.
*/
clearEdges(layers: string | string[]): void;
/** Get edges of given layer names. Duplicates are removed (this
* may change). Order of edges are preserved for a single layer
* name (except for duplicate removal). Order gets even messier for
* multiple layers (because of duplicate removal).
*
* @method jibo.kb.Node#getEdges
* @param {string|string[]} layers Nmes of layers to return edges for.
* @returns {string[]} Array of IDs.
*/
getEdges(layers: string | string[]): string[];
/** All layers (edge names) on this node
* @method jibo.kb.Node#getLayers
* @returns {string[]} Array of layer names.
*/
getLayers(): string[];
/** Create a new asset object and add it to the list of assets on
* this node.
*
* @method jibo.kb.Node#createAsset
* @param {string} [subtype] Subtype name for this asset.
* @param {string} [ext] Optional filename extension.
* @returns {jibo.kb.Asset} New asset object.
*/
createAsset(subtype?: string, ext?: string): Asset;
/** Add existing asset objects to the list of assets on this
* node. The asset objects root directory needs to match this node
* object.
*
* @method jibo.kb.Node#addAssets
* @param {jibo.kb.Asset|jibo.kb.Asset[]} assets Asset objects to add to node.
* @param {string} [subtype] Subtype string to force assets to be
* added as. Subtype comes from each asset object unless this is
* specified.
*/
addAssets(assets: Asset | Asset[], subtype?: string): void;
/** Get all asset objects of given subtype from the assets listed
* on this node.
*
* @method jibo.kb.Node#getAssets
* @param {string} [subtype] Asset subtype to get. Defaults to `asset`.
* @returns {jibo.kb.Asset[]} Array of asset objects.
*/
getAssets(subtype?: string): Asset[];
/** Get all asset objects from the assets listed on this node,
* regardless of subtype.
*
* @method jibo.kb.Node#getAllAssets
* @returns {jibo.kb.Asset[]} Array of asset objects.
*/
getAllAssets(): Asset[];
/** List of all asset subtypes on this node.
*
* @method jibo.kb.Node#getAssetSubtypes
* @returns {string[]} Array of subtype name strings.
*/
getAssetSubtypes(): string[];
/** Delete an asset from disk and remove it from this node.
*
* @method jibo.kb.Node#removeAsset
* @param {jibo.kb.Asset} asset Asset object to remove.
* @param {Function} [callback] Called when done. If callback is
* omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
*/
removeAsset(asset: Asset, callback: ErrCallback): any;
removeAsset(asset: Asset): Promise<any>;
/** Delete from disk and remove all assets from the node.
*
* @method jibo.kb.Node#removeAllAssets
* @param {Function} [callback] Called when done. If callback is
* omitted a promise is returned instead.
* @returns {Promise} A promise if the callback is omitted.
*/
removeAllAssets(callback: ErrCallback): any;
removeAllAssets(): Promise<any>;
/** Bind this node to a given KB slice.
*
* @method jibo.kb.Node#setKb
* @param {jibo.kb.KnowledgeDatabase} knowledgeDatabase KB "slice" to bind this node to
* @returns {jibo.kb.Node} `this`
* @internal
*/
setKb(knowledgeDatabase: KnowledgeDatabase): this;
/** Set the 'updated' timestamp on this node.
*
* @method jibo.kb.Node#setUpdated
* @param {number} [timestamp] Milliseconds since 1 January 1970
* 00:00:00 UTC. Defaults to now.
*/
setUpdated(timestamp?: number): void;
/** Decide if a given item is an id string or a node. If it is a
* node, extract the id, and set the layer to the node type if
* layer wasn't specified.
*
* @method jibo.kb.Node#_resolveIdAndLayer
* @param {string|jibo.kb.Node} idOrNode
* @param {string} [layer] User supplied layer name or undefined/null
* @param {string} methodName Name of calling method just for error reporting.
* @param {Object} {id, layer}
* @private
* @internal
*/
private _resolveIdAndLayer(idOrNode, layer, methodName);
/** Convert a single item to an array for arguments that may be a
* single thing or an array of things
*
* @method jibo.kb.Node#_toArray
* @private
*/
private _toArray<T>(items);
}

94
node_modules/jibo-kb/lib/dts/UserNode.d.ts generated vendored Normal file
View File

@@ -0,0 +1,94 @@
import Node from './Node';
export declare type AccountData = {
birthday: number;
email: string;
firstName: string;
gender: 'male' | 'female' | 'other';
lastName: string;
};
/**
* Specific type of node for members of the loop. All nodes returned by LoopModel should be UserNodes.
*
* @class UserNode
* @extends jibo.kb.Node
* @memberof jibo.kb.loop
*/
export default class UserNode extends Node {
data: {
account: AccountData;
birthday: number;
email: string;
enrolled: {
voice: boolean;
face: boolean;
};
facebookConnected: boolean;
firstName: string;
gender: 'male' | 'female' | 'other';
isActive: boolean;
lastName: string;
loopId: string;
memberId: string;
phoneticName: string;
photoUrl: string;
nickName: string;
status: string;
type: string;
};
/**
* UUID of the user.
* @name jibo.kb.loop.UserNode#id
* @type {String}
*/
readonly id: string;
/**
* First name of the user.
* @name jibo.kb.loop.UserNode#firstName
* @type {String}
*/
readonly firstName: string;
/**
* Last name of the user.
* @name jibo.kb.loop.UserNode#lastName
* @type {String}
*/
readonly lastName: string;
/**
* Nickname of the user.
* @name jibo.kb.loop.UserNode#nickName
* @type {String}
*/
readonly nickName: string;
/**
* Gender of the user.
* @name jibo.kb.loop.UserNode#gender
* @type {String}
*/
readonly gender: "male" | "female" | "other";
/**
* If this loop member is actually Jibo.
* @name jibo.kb.loop.UserNode#isJibo
* @type {Boolean}
*/
readonly isJibo: boolean;
/**
* The loop member's preferred written name. This will be the nickname or first name
* of the loop member.
* @method jibo.kb.loop.UserNode#getWrittenName
* @return {String} The loop member's preferred written name.
*/
getWrittenName(): string;
/**
* The loop member's preferred spoken name. This will be the `phoneticName`, nickname, or first name
* of the loop member.
* @method jibo.kb.loop.UserNode#toString
* @return {String} The loop member's preferred spoken name.
*/
toString(): string;
/**
* Calculate the initials of the loop member.
* @method jibo.kb.loop.UserNode#getInitials
* @return {String} The loop member's initials.
*/
getInitials(): string;
}

96
node_modules/jibo-kb/lib/dts/WebClient.d.ts generated vendored Normal file
View File

@@ -0,0 +1,96 @@
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?);
}

3
node_modules/jibo-kb/lib/dts/decorators.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
declare function promisify(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): any;
declare function promisify_4(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): any;
export { promisify, promisify_4 };

12
node_modules/jibo-kb/lib/dts/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
export * from './KnowledgeBase';
export { default as Asset } from './Asset';
export { default as Cache } from './Cache';
export { default as Database } from './Database';
export { default as DatabaseManager } from './DatabaseManager';
export { default as KnowledgeBase } from './KnowledgeBase';
export { default as KnowledgeDatabase } from './KnowledgeDatabase';
export { default as LoopModel } from './LoopModel';
export { default as Model } from './Model';
export { default as Node } from './Node';
export { default as UserNode } from './UserNode';
export { default as WebClient } from './WebClient';

10
node_modules/jibo-kb/lib/jibo-kb.js generated vendored Normal file

File diff suppressed because one or more lines are too long