Skip to content

Engine.nucleus

Sebastien Filion edited this page Jun 14, 2018 · 2 revisions

Classes

NucleusEngine

Members

ID : String
name : String

Functions

parseNucleusTag(docletTagList)Object

Parses the Nucleus doclet tags.

retrieveAllDocletsInPath(path)Promise.<Array.<doclet>>

Retrieves all doclets in path.

Typedefs

actionConfiguration : Object
extendableActionConfiguration : Object
resourceStructure : Object

NucleusEngine

Kind: global class

new NucleusEngine(name, options)

Creates a Nucleus engine. The constructor returns a Proxy that interfaces the class and a Promise that resolves once the engine is ready. If no datastore is passed in the option, a default connection will be created.

Param Type Default
name String
options Object
[options.$actionDatastore] NucleusDatastore
[options.$engineDatastore] NucleusDatastore
[options.$eventDatastore] NucleusDatastore
[options.$resourceRelationshipDatastore] NucleusResourceRelationshipDatastore
[options.$logger] NucleusDatastore
[options.automaticallyAutodiscover] Boolean false
[options.automaticallyManageResourceRelationship] Boolean false
[options.automaticallyRetrievePendingActions] Boolean false
[options.defaultActionQueueName] String <Engine's name>

nucleusEngine.autodiscover() ⇒ Promise.<{actionConfigurationList: Array.<actionConfiguration>, extendableActionConfigurationList: Array.<extendableActionConfiguration>, resourceStructureList: Array.<resourceStructure>}>

Autodiscovers the module's actions.

Kind: instance method of NucleusEngine

nucleusEngine.destroy() ⇒ Promise

Destroys the engine and the related datastores.

Kind: instance method of NucleusEngine

nucleusEngine.executeAction($action) ⇒ Promise.<NucleusAction>

Executes a pending action.

Kind: instance method of NucleusEngine

Param Type
$action NucleusAction

nucleusEngine.executeMethodInContext($action, actionSignature, contextName, filePath, methodName) ⇒ Promise.<Object>

Executes the action given its context.

Kind: instance method of NucleusEngine

Param Type Default
$action NucleusAction
actionSignature Array.<String>
contextName String Self
filePath String
methodName String

nucleusEngine.fixDatastoreIssues() ⇒ Promise

Fixes issues with the datastore; trying to normalize the data to avoid flushing everything when a change is made.

Kind: instance method of NucleusEngine

nucleusEngine.fulfilActionSignature($action, actionSignatureList, argumentConfigurationByArgumentName) ⇒ Array.<String>

Fulfils an action signature given different options and the argument configuration.

Kind: instance method of NucleusEngine

Param Type
$action NucleusAction
actionSignatureList Array.<Array>
argumentConfigurationByArgumentName Object

nucleusEngine.generateResourceModelFromResourceStructureByResourceType(resourceType) ⇒ Promise.<function()>

Generates a Resource Model from a resource structure given the resource type.

Kind: instance method of NucleusEngine

Param Type
resourceType String

nucleusEngine.publishActionToQueueByName(actionQueueName, $action) ⇒ Promise.<Object>

Publishes an action given a queue name.

Kind: instance method of NucleusEngine

Param Type
actionQueueName String
$action NucleusAction

Example

const queueName = 'Dummy';
const $action = new NucleusAction('DummyAction', {});

$engine.publishActionToQueueByName(queueName, $action);

nucleusEngine.publishActionByNameAndHandleResponse(actionName, actionMessage, originUserID) ⇒ Promise.<Object>

Publishes an action given its name and a message, then handle the response.

Kind: instance method of NucleusEngine

Param Type
actionName String
actionMessage Object
originUserID String

Example

const { dummy } = await $engine.publishActionByNameAndHandleResponse('RetrieveDummyByID', { dummyID }, originUserID);

nucleusEngine.handleActionChannelRedisEvent($actionSubscriberDatastore, resolve, reject, channelName, redisCommand) ⇒ Promise.<void>

Handles an action channel's Redis events. This is used to trigger a check of the action's status in the attempt of resolving a publisher's request. This method is tightly coupled with the #publishActionByNameAndHandleResponse and should be refactored.

Kind: instance method of NucleusEngine

Param Type Description
$actionSubscriberDatastore NucleusDatastore
resolve Promise.resolve The resolver to call when the action is completed.
reject Promise.reject The rejecter to call when the action is failed.
channelName String
redisCommand String

nucleusEngine.handleActionStatusUpdated(actionItemKey, actionID, actionName, [resolve], [reject]) ⇒ Promise

Handles an action's status update. This method is tightly coupled with the #publishActionByNameAndHandleResponse and should be refactored.

Kind: instance method of NucleusEngine

Param Type
actionItemKey String
actionID String
actionName String
[resolve] Promise.resolve
[reject] Promise.reject

nucleusEngine.publishEventToChannelByName(channelName, $event) ⇒ Promise.<Object>

Publishes an event given a channel name.

Kind: instance method of NucleusEngine

Param Type
channelName String
$event NucleusEvent

Example

const channelName = 'Dummy';
const $event = new NucleusEvent('DummyEvent', {});

$engine.publishEventToChannelByName(channelName, $event);

nucleusEngine.retrieveActionConfigurationByActionName(actionName) ⇒ Promise.<actionConfiguration>

Retrieves the action configurations given an action name.

Kind: instance method of NucleusEngine

Param Type
actionName String

nucleusEngine.retrieveExtendableActionConfigurationByActionName(actionName) ⇒ Promise.<extendableActionConfiguration>

Retrieves the extendable action configurations given an action name.

Kind: instance method of NucleusEngine

Param Type
actionName String

nucleusEngine.retrievePendingAction(actionQueueName) ⇒ Promise.<void>

Retrieves a pending action name and call the execution.

Kind: instance method of NucleusEngine

Param Type
actionQueueName String

nucleusEngine.retrieveResourceStructureByResourceType(resourceType) ⇒ Promise.<resourceStructure>

Retrieves the resource structure given a resource type.

Kind: instance method of NucleusEngine

Param Type
resourceType String

nucleusEngine.storeActionConfiguration(defaultActionQueueName, actionConfiguration) ⇒ Promise

Stores an action configuration.

Kind: instance method of NucleusEngine

Param Type
defaultActionQueueName String
actionConfiguration actionConfiguration

nucleusEngine.storeExtendableActionConfiguration(extendableActionConfiguration) ⇒ Promise

Stores an extendable action configuration.

Kind: instance method of NucleusEngine

Param Type
extendableActionConfiguration extendableActionConfiguration

nucleusEngine.storeResourceStructure(resourceStructure) ⇒ Promise

Stores a resource structure.

Kind: instance method of NucleusEngine

Param Type
resourceStructure resourceStructure

nucleusEngine.subscribeToActionQueueUpdate(actionQueueName) ⇒ Promise.<void>

Subscribe to the action queue updates given its name.

Kind: instance method of NucleusEngine

Param Type
actionQueueName String

nucleusEngine.subscribeToEventChannelByName(channelName) ⇒ Promise.<void>

Subscribes to a channel given its name.

Kind: instance method of NucleusEngine

Param Type
channelName String

nucleusEngine.unsubscribeFromEventChannelByName(channelName) ⇒ Promise.<void>

Unsubscribes to a channel given its name.

Kind: instance method of NucleusEngine

Param Type
channelName String

nucleusEngine.verifyRedisConfiguration() ⇒ Promise.<void>

Verifies that the Redises connection are configured correctly.

Kind: instance method of NucleusEngine

NucleusEngine.parseTemplateString(context, string) ⇒ Promise | *

Parses a template string.

Kind: static method of NucleusEngine

Param Type
context Object
string String

Example

const parsedString = Nucleus.parseTemplateString({ world: "World" }, "`Hello ${world}!`");
// parsedString === 'Hello World!'

NucleusEngine.retrieveModuleDirectoryPath([moduleNode], [moduleNode]) ⇒ String

Retrieves the current module directory path.

Kind: static method of NucleusEngine

Param Type Default Description
[moduleNode] Object module.parent Used for recursion.
[moduleNode] Object Used for recursion.

ID : String

Kind: global variable

name : String

Kind: global variable

parseNucleusTag(docletTagList) ⇒ Object

Parses the Nucleus doclet tags.

Kind: global function

Param Type Default
docletTagList Array
docletTagList[].originalTitle String Nucleus
docletTagList[].title String nucleus
docletTagList[].text String
docletTagList[].value String

retrieveAllDocletsInPath(path) ⇒ Promise.<Array.<doclet>>

Retrieves all doclets in path.

Kind: global function
See: JSDoc Doclet|

Param Type
path String

actionConfiguration : Object

Kind: global typedef
Properties

Name Type Default
actionName String
[alternativeActionSignature] Array.<String>
[actionSignature] Array.<String>
[argumentConfigurationByArgumentName] Object
contextName String Self
[eventName] String
fileName String
filePath String
methodName String

extendableActionConfiguration : Object

Kind: global typedef
Properties

Name Type Default
extendableActionArgumentDefault Object
actionName String
[alternativeActionSignature] Array.<String>
[actionSignature] Array.<String>
[argumentConfigurationByArgumentName] Object
[extendableActionAlternativeSignature] Array.<String>
extendableActionName String
[extendableEventName] String
contextName String Self
fileName String
filePath String
methodName String

resourceStructure : Object

Kind: global typedef
Properties

Name Type Default
contextName String Self
fileName String
filePath String
propertiesByArgumentName Object
resourceAPIName String
resourceType String

Classes

NucleusEngine

Members

ID : String
name : String

Functions

parseNucleusTag(docletTagList)Object

Parses the Nucleus doclet tags.

retrieveAllDocletsInPath(path)Promise.<Array.<doclet>>

Retrieves all doclets in path.

Typedefs

actionConfiguration : Object
extendableActionConfiguration : Object
resourceStructure : Object

NucleusEngine

Kind: global class

new NucleusEngine(name, options)

Creates a Nucleus engine. The constructor returns a Proxy that interfaces the class and a Promise that resolves once the engine is ready. If no datastore is passed in the option, a default connection will be created.

Param Type Default
name String
options Object
[options.$actionDatastore] NucleusDatastore
[options.$engineDatastore] NucleusDatastore
[options.$eventDatastore] NucleusDatastore
[options.$resourceRelationshipDatastore] NucleusResourceRelationshipDatastore
[options.$logger] NucleusDatastore
[options.automaticallyAutodiscover] Boolean false
[options.automaticallyManageResourceRelationship] Boolean false
[options.automaticallyRetrievePendingActions] Boolean false
[options.defaultActionQueueName] String <Engine's name>

nucleusEngine.autodiscover() ⇒ Promise.<{actionConfigurationList: Array.<actionConfiguration>, extendableActionConfigurationList: Array.<extendableActionConfiguration>, resourceStructureList: Array.<resourceStructure>}>

Autodiscovers the module's actions.

Kind: instance method of NucleusEngine

nucleusEngine.destroy() ⇒ Promise

Destroys the engine and the related datastores.

Kind: instance method of NucleusEngine

nucleusEngine.executeAction($action) ⇒ Promise.<NucleusAction>

Executes a pending action.

Kind: instance method of NucleusEngine

Param Type
$action NucleusAction

nucleusEngine.executeMethodInContext($action, actionSignature, contextName, filePath, methodName) ⇒ Promise.<Object>

Executes the action given its context.

Kind: instance method of NucleusEngine

Param Type Default
$action NucleusAction
actionSignature Array.<String>
contextName String Self
filePath String
methodName String

nucleusEngine.fixDatastoreIssues() ⇒ Promise

Fixes issues with the datastore; trying to normalize the data to avoid flushing everything when a change is made.

Kind: instance method of NucleusEngine

nucleusEngine.fulfilActionSignature($action, actionSignatureList, argumentConfigurationByArgumentName) ⇒ Array.<String>

Fulfils an action signature given different options and the argument configuration.

Kind: instance method of NucleusEngine

Param Type
$action NucleusAction
actionSignatureList Array.<Array>
argumentConfigurationByArgumentName Object

nucleusEngine.generateResourceModelFromResourceStructureByResourceType(resourceType) ⇒ Promise.<function()>

Generates a Resource Model from a resource structure given the resource type.

Kind: instance method of NucleusEngine

Param Type
resourceType String

nucleusEngine.publishActionToQueueByName(actionQueueName, $action) ⇒ Promise.<Object>

Publishes an action given a queue name.

Kind: instance method of NucleusEngine

Param Type
actionQueueName String
$action NucleusAction

Example

const queueName = 'Dummy';
const $action = new NucleusAction('DummyAction', {});

$engine.publishActionToQueueByName(queueName, $action);

nucleusEngine.publishActionByNameAndHandleResponse(actionName, actionMessage, originUserID) ⇒ Promise.<Object>

Publishes an action given its name and a message, then handle the response.

Kind: instance method of NucleusEngine

Param Type
actionName String
actionMessage Object
originUserID String

Example

const { dummy } = await $engine.publishActionByNameAndHandleResponse('RetrieveDummyByID', { dummyID }, originUserID);

nucleusEngine.handleActionChannelRedisEvent($actionSubscriberDatastore, resolve, reject, channelName, redisCommand) ⇒ Promise.<void>

Handles an action channel's Redis events. This is used to trigger a check of the action's status in the attempt of resolving a publisher's request. This method is tightly coupled with the #publishActionByNameAndHandleResponse and should be refactored.

Kind: instance method of NucleusEngine

Param Type Description
$actionSubscriberDatastore NucleusDatastore
resolve Promise.resolve The resolver to call when the action is completed.
reject Promise.reject The rejecter to call when the action is failed.
channelName String
redisCommand String

nucleusEngine.handleActionStatusUpdated(actionItemKey, actionID, actionName, [resolve], [reject]) ⇒ Promise

Handles an action's status update. This method is tightly coupled with the #publishActionByNameAndHandleResponse and should be refactored.

Kind: instance method of NucleusEngine

Param Type
actionItemKey String
actionID String
actionName String
[resolve] Promise.resolve
[reject] Promise.reject

nucleusEngine.publishEventToChannelByName(channelName, $event) ⇒ Promise.<Object>

Publishes an event given a channel name.

Kind: instance method of NucleusEngine

Param Type
channelName String
$event NucleusEvent

Example

const channelName = 'Dummy';
const $event = new NucleusEvent('DummyEvent', {});

$engine.publishEventToChannelByName(channelName, $event);

nucleusEngine.retrieveActionConfigurationByActionName(actionName) ⇒ Promise.<actionConfiguration>

Retrieves the action configurations given an action name.

Kind: instance method of NucleusEngine

Param Type
actionName String

nucleusEngine.retrieveExtendableActionConfigurationByActionName(actionName) ⇒ Promise.<extendableActionConfiguration>

Retrieves the extendable action configurations given an action name.

Kind: instance method of NucleusEngine

Param Type
actionName String

nucleusEngine.retrievePendingAction(actionQueueName) ⇒ Promise.<void>

Retrieves a pending action name and call the execution.

Kind: instance method of NucleusEngine

Param Type
actionQueueName String

nucleusEngine.retrieveResourceStructureByResourceType(resourceType) ⇒ Promise.<resourceStructure>

Retrieves the resource structure given a resource type.

Kind: instance method of NucleusEngine

Param Type
resourceType String

nucleusEngine.storeActionConfiguration(defaultActionQueueName, actionConfiguration) ⇒ Promise

Stores an action configuration.

Kind: instance method of NucleusEngine

Param Type
defaultActionQueueName String
actionConfiguration actionConfiguration

nucleusEngine.storeExtendableActionConfiguration(extendableActionConfiguration) ⇒ Promise

Stores an extendable action configuration.

Kind: instance method of NucleusEngine

Param Type
extendableActionConfiguration extendableActionConfiguration

nucleusEngine.storeResourceStructure(resourceStructure) ⇒ Promise

Stores a resource structure.

Kind: instance method of NucleusEngine

Param Type
resourceStructure resourceStructure

nucleusEngine.subscribeToActionQueueUpdate(actionQueueName) ⇒ Promise.<void>

Subscribe to the action queue updates given its name.

Kind: instance method of NucleusEngine

Param Type
actionQueueName String

nucleusEngine.subscribeToEventChannelByName(channelName) ⇒ Promise.<void>

Subscribes to a channel given its name.

Kind: instance method of NucleusEngine

Param Type
channelName String

nucleusEngine.unsubscribeFromEventChannelByName(channelName) ⇒ Promise.<void>

Unsubscribes to a channel given its name.

Kind: instance method of NucleusEngine

Param Type
channelName String

nucleusEngine.verifyRedisConfiguration() ⇒ Promise.<void>

Verifies that the Redises connection are configured correctly.

Kind: instance method of NucleusEngine

NucleusEngine.parseTemplateString(context, string) ⇒ Promise | *

Parses a template string.

Kind: static method of NucleusEngine

Param Type
context Object
string String

Example

const parsedString = Nucleus.parseTemplateString({ world: "World" }, "`Hello ${world}!`");
// parsedString === 'Hello World!'

NucleusEngine.retrieveModuleDirectoryPath([moduleNode], [moduleNode]) ⇒ String

Retrieves the current module directory path.

Kind: static method of NucleusEngine

Param Type Default Description
[moduleNode] Object module.parent Used for recursion.
[moduleNode] Object Used for recursion.

ID : String

Kind: global variable

name : String

Kind: global variable

parseNucleusTag(docletTagList) ⇒ Object

Parses the Nucleus doclet tags.

Kind: global function

Param Type Default
docletTagList Array
docletTagList[].originalTitle String Nucleus
docletTagList[].title String nucleus
docletTagList[].text String
docletTagList[].value String

retrieveAllDocletsInPath(path) ⇒ Promise.<Array.<doclet>>

Retrieves all doclets in path.

Kind: global function
See: JSDoc Doclet|

Param Type
path String

actionConfiguration : Object

Kind: global typedef
Properties

Name Type Default
actionName String
[alternativeActionSignature] Array.<String>
[actionSignature] Array.<String>
[argumentConfigurationByArgumentName] Object
contextName String Self
[eventName] String
fileName String
filePath String
methodName String

extendableActionConfiguration : Object

Kind: global typedef
Properties

Name Type Default
extendableActionArgumentDefault Object
actionName String
[alternativeActionSignature] Array.<String>
[actionSignature] Array.<String>
[argumentConfigurationByArgumentName] Object
[extendableActionAlternativeSignature] Array.<String>
extendableActionName String
[extendableEventName] String
contextName String Self
fileName String
filePath String
methodName String

resourceStructure : Object

Kind: global typedef
Properties

Name Type Default
contextName String Self
fileName String
filePath String
propertiesByArgumentName Object
resourceAPIName String
resourceType String
Clone this wiki locally