-
Notifications
You must be signed in to change notification settings - Fork 9
Engine.nucleus
-
parseNucleusTag(docletTagList) ⇒
Object -
Parses the Nucleus doclet tags.
-
retrieveAllDocletsInPath(path) ⇒
Promise.<Array.<doclet>> -
Retrieves all doclets in path.
-
actionConfiguration :
Object -
extendableActionConfiguration :
Object -
resourceStructure :
Object
Kind: global class
-
NucleusEngine
- new NucleusEngine(name, options)
-
instance
-
.autodiscover() ⇒
Promise.<{actionConfigurationList: Array.<actionConfiguration>, extendableActionConfigurationList: Array.<extendableActionConfiguration>, resourceStructureList: Array.<resourceStructure>}> -
.destroy() ⇒
Promise -
.executeAction($action) ⇒
Promise.<NucleusAction> -
.executeMethodInContext($action, actionSignature, contextName, filePath, methodName) ⇒
Promise.<Object> -
.fixDatastoreIssues() ⇒
Promise -
.fulfilActionSignature($action, actionSignatureList, argumentConfigurationByArgumentName) ⇒
Array.<String> -
.generateResourceModelFromResourceStructureByResourceType(resourceType) ⇒
Promise.<function()> -
.publishActionToQueueByName(actionQueueName, $action) ⇒
Promise.<Object> -
.publishActionByNameAndHandleResponse(actionName, actionMessage, originUserID) ⇒
Promise.<Object> -
.handleActionChannelRedisEvent($actionSubscriberDatastore, resolve, reject, channelName, redisCommand) ⇒
Promise.<void> -
.handleActionStatusUpdated(actionItemKey, actionID, actionName, [resolve], [reject]) ⇒
Promise -
.publishEventToChannelByName(channelName, $event) ⇒
Promise.<Object> -
.retrieveActionConfigurationByActionName(actionName) ⇒
Promise.<actionConfiguration> -
.retrieveExtendableActionConfigurationByActionName(actionName) ⇒
Promise.<extendableActionConfiguration> -
.retrievePendingAction(actionQueueName) ⇒
Promise.<void> -
.retrieveResourceStructureByResourceType(resourceType) ⇒
Promise.<resourceStructure> -
.storeActionConfiguration(defaultActionQueueName, actionConfiguration) ⇒
Promise -
.storeExtendableActionConfiguration(extendableActionConfiguration) ⇒
Promise -
.storeResourceStructure(resourceStructure) ⇒
Promise -
.subscribeToActionQueueUpdate(actionQueueName) ⇒
Promise.<void> -
.subscribeToEventChannelByName(channelName) ⇒
Promise.<void> -
.unsubscribeFromEventChannelByName(channelName) ⇒
Promise.<void> -
.verifyRedisConfiguration() ⇒
Promise.<void>
-
.autodiscover() ⇒
-
static
-
.parseTemplateString(context, string) ⇒
Promise|* -
.retrieveModuleDirectoryPath([moduleNode], [moduleNode]) ⇒
String
-
.parseTemplateString(context, string) ⇒
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
Destroys the engine and the related datastores.
Kind: instance method of NucleusEngine
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 |
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 |
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 |
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 |
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 |
Stores an action configuration.
Kind: instance method of NucleusEngine
| Param | Type |
|---|---|
| defaultActionQueueName | String |
| actionConfiguration | actionConfiguration |
Stores an extendable action configuration.
Kind: instance method of NucleusEngine
| Param | Type |
|---|---|
| extendableActionConfiguration | extendableActionConfiguration |
Stores a resource structure.
Kind: instance method of NucleusEngine
| Param | Type |
|---|---|
| resourceStructure | resourceStructure |
Subscribe to the action queue updates given its name.
Kind: instance method of NucleusEngine
| Param | Type |
|---|---|
| actionQueueName | String |
Subscribes to a channel given its name.
Kind: instance method of NucleusEngine
| Param | Type |
|---|---|
| channelName | String |
Unsubscribes to a channel given its name.
Kind: instance method of NucleusEngine
| Param | Type |
|---|---|
| channelName | String |
Verifies that the Redises connection are configured correctly.
Kind: instance method of NucleusEngine
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!'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. |
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 |
Retrieves all doclets in path.
Kind: global function
See: JSDoc Doclet|
| Param | Type |
|---|---|
| path | String |
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 |
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 |
Kind: global typedef
Properties
| Name | Type | Default |
|---|---|---|
| contextName | String |
Self |
| fileName | String |
|
| filePath | String |
|
| propertiesByArgumentName | Object |
|
| resourceAPIName | String |
|
| resourceType | String |
-
parseNucleusTag(docletTagList) ⇒
Object -
Parses the Nucleus doclet tags.
-
retrieveAllDocletsInPath(path) ⇒
Promise.<Array.<doclet>> -
Retrieves all doclets in path.
-
actionConfiguration :
Object -
extendableActionConfiguration :
Object -
resourceStructure :
Object
Kind: global class
-
NucleusEngine
- new NucleusEngine(name, options)
-
instance
-
.autodiscover() ⇒
Promise.<{actionConfigurationList: Array.<actionConfiguration>, extendableActionConfigurationList: Array.<extendableActionConfiguration>, resourceStructureList: Array.<resourceStructure>}> -
.destroy() ⇒
Promise -
.executeAction($action) ⇒
Promise.<NucleusAction> -
.executeMethodInContext($action, actionSignature, contextName, filePath, methodName) ⇒
Promise.<Object> -
.fixDatastoreIssues() ⇒
Promise -
.fulfilActionSignature($action, actionSignatureList, argumentConfigurationByArgumentName) ⇒
Array.<String> -
.generateResourceModelFromResourceStructureByResourceType(resourceType) ⇒
Promise.<function()> -
.publishActionToQueueByName(actionQueueName, $action) ⇒
Promise.<Object> -
.publishActionByNameAndHandleResponse(actionName, actionMessage, originUserID) ⇒
Promise.<Object> -
.handleActionChannelRedisEvent($actionSubscriberDatastore, resolve, reject, channelName, redisCommand) ⇒
Promise.<void> -
.handleActionStatusUpdated(actionItemKey, actionID, actionName, [resolve], [reject]) ⇒
Promise -
.publishEventToChannelByName(channelName, $event) ⇒
Promise.<Object> -
.retrieveActionConfigurationByActionName(actionName) ⇒
Promise.<actionConfiguration> -
.retrieveExtendableActionConfigurationByActionName(actionName) ⇒
Promise.<extendableActionConfiguration> -
.retrievePendingAction(actionQueueName) ⇒
Promise.<void> -
.retrieveResourceStructureByResourceType(resourceType) ⇒
Promise.<resourceStructure> -
.storeActionConfiguration(defaultActionQueueName, actionConfiguration) ⇒
Promise -
.storeExtendableActionConfiguration(extendableActionConfiguration) ⇒
Promise -
.storeResourceStructure(resourceStructure) ⇒
Promise -
.subscribeToActionQueueUpdate(actionQueueName) ⇒
Promise.<void> -
.subscribeToEventChannelByName(channelName) ⇒
Promise.<void> -
.unsubscribeFromEventChannelByName(channelName) ⇒
Promise.<void> -
.verifyRedisConfiguration() ⇒
Promise.<void>
-
.autodiscover() ⇒
-
static
-
.parseTemplateString(context, string) ⇒
Promise|* -
.retrieveModuleDirectoryPath([moduleNode], [moduleNode]) ⇒
String
-
.parseTemplateString(context, string) ⇒
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
Destroys the engine and the related datastores.
Kind: instance method of NucleusEngine
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 |
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 |
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 |
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 |
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 |
Stores an action configuration.
Kind: instance method of NucleusEngine
| Param | Type |
|---|---|
| defaultActionQueueName | String |
| actionConfiguration | actionConfiguration |
Stores an extendable action configuration.
Kind: instance method of NucleusEngine
| Param | Type |
|---|---|
| extendableActionConfiguration | extendableActionConfiguration |
Stores a resource structure.
Kind: instance method of NucleusEngine
| Param | Type |
|---|---|
| resourceStructure | resourceStructure |
Subscribe to the action queue updates given its name.
Kind: instance method of NucleusEngine
| Param | Type |
|---|---|
| actionQueueName | String |
Subscribes to a channel given its name.
Kind: instance method of NucleusEngine
| Param | Type |
|---|---|
| channelName | String |
Unsubscribes to a channel given its name.
Kind: instance method of NucleusEngine
| Param | Type |
|---|---|
| channelName | String |
Verifies that the Redises connection are configured correctly.
Kind: instance method of NucleusEngine
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!'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. |
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 |
Retrieves all doclets in path.
Kind: global function
See: JSDoc Doclet|
| Param | Type |
|---|---|
| path | String |
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 |
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 |
Kind: global typedef
Properties
| Name | Type | Default |
|---|---|---|
| contextName | String |
Self |
| fileName | String |
|
| filePath | String |
|
| propertiesByArgumentName | Object |
|
| resourceAPIName | String |
|
| resourceType | String |