{"_id":"@aeontek/eventservice","_rev":"1-ac53319fa21a4823e4c588c0b5ca1aec","name":"@aeontek/eventservice","dist-tags":{"latest":"1.0.16"},"versions":{"1.0.12":{"name":"@aeontek/eventservice","version":"1.0.12","description":"A service for creating, sending, and handling an event pattern implementation either locally or with WebSockets","main":"dist/EventService.js","types":"dist/EventService.d.ts","scripts":{"build":"npx tsc && npx jsdoc2md --files dist/* > README.md","test":"npx ts-node test.ts"},"repository":{"type":"git","url":"git+https://github.com/aeontek/EventService.git"},"author":{"name":"Drew Long"},"license":"MIT","dependencies":{"@aeontek/dictionary":"^1.0.5","ts-node":"^10.9.1","uuid":"^9.0.1","ws":"^8.14.1"},"devDependencies":{"@types/node":"^20.6.1","@types/uuid":"^9.0.4","@types/ws":"^8.5.5","jest":"^29.7.0","jsdoc-to-markdown":"^8.0.0","typescript":"^5.2.2"},"_id":"@aeontek/eventservice@1.0.12","bugs":{"url":"https://github.com/aeontek/EventService/issues"},"homepage":"https://github.com/aeontek/EventService#readme","_nodeVersion":"18.18.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-wvous9BpZr3BHMNI2MQL5a/tVFd1PkPoaCcaqLJ6nxwBOIHRg70fn+r/DQDWuIpgWrI/drg3ogOc8g46wENK9g==","shasum":"7bde98febd00ed9852b89029e0060c9f419dc3aa","tarball":"https://registry.npmjs.org/@aeontek/eventservice/-/eventservice-1.0.12.tgz","fileCount":30,"unpackedSize":59350,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIByoha21tVVJ2lcPDvNtkVMbt3Y+l6iq6CzVonhmGQYbAiEA+RtYMIkQug0VC01fgwT7M7S1WSQal6g8wJxdVqf6m0I="}]},"_npmUser":{"name":"attanai","email":"drew@aeontek.org"},"directories":{},"maintainers":[{"name":"attanai","email":"drew@aeontek.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eventservice_1.0.12_1696719497717_0.45264756722318933"},"_hasShrinkwrap":false},"1.0.16":{"name":"@aeontek/eventservice","version":"1.0.16","description":"A service for creating, sending, and handling an event pattern implementation either locally or with WebSockets","main":"dist/EventService.js","types":"dist/EventService.d.ts","scripts":{"build":"npx tsc && npx jsdoc2md --files dist/* > README.md","test":"npx ts-node test.ts"},"repository":{"type":"git","url":"git+https://github.com/aeontek/EventService.git"},"author":{"name":"Drew Long"},"license":"MIT","dependencies":{"@aeontek/dictionary":"^1.0.5","uuid":"^9.0.1","ws":"^8.14.1"},"devDependencies":{"@types/node":"^20.6.1","@types/uuid":"^9.0.4","@types/ws":"^8.5.5","jest":"^29.7.0","jsdoc-to-markdown":"^8.0.0","ts-node":"^10.9.1","typescript":"^5.2.2"},"_id":"@aeontek/eventservice@1.0.16","bugs":{"url":"https://github.com/aeontek/EventService/issues"},"homepage":"https://github.com/aeontek/EventService#readme","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-1iDOSTXjlPfbpkXxtD8IUb3aGFmpw0Eq9d9CWBG0AMDZDczsvv3Qts9ZgnW50aVf8wu/otGhYGHk/4CXgxt2Jg==","shasum":"21a0212e416b0a638d29ab502cf71d7140124873","tarball":"https://registry.npmjs.org/@aeontek/eventservice/-/eventservice-1.0.16.tgz","fileCount":30,"unpackedSize":65791,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC1z3f+ZAhxGJiiXe5VquCqOriNTwcuxRae5bd3XGYAYwIhAIxWLwMxBH1vuaSWFsxvlitkUa+vJPBFxCFzSMdtcJhG"}]},"_npmUser":{"name":"attanai","email":"drew@aeontek.org"},"directories":{},"maintainers":[{"name":"attanai","email":"drew@aeontek.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eventservice_1.0.16_1698444570340_0.3191916788566571"},"_hasShrinkwrap":false}},"time":{"created":"2023-10-07T22:58:17.619Z","1.0.12":"2023-10-07T22:58:17.923Z","modified":"2023-10-27T22:09:30.793Z","1.0.16":"2023-10-27T22:09:30.600Z"},"maintainers":[{"name":"attanai","email":"drew@aeontek.org"}],"description":"A service for creating, sending, and handling an event pattern implementation either locally or with WebSockets","homepage":"https://github.com/aeontek/EventService#readme","repository":{"type":"git","url":"git+https://github.com/aeontek/EventService.git"},"author":{"name":"Drew Long"},"bugs":{"url":"https://github.com/aeontek/EventService/issues"},"license":"MIT","readme":"## Classes\n\n<dl>\n<dt><a href=\"#Client\">Client</a></dt>\n<dd><p>Client\nCreates a WebSocket Client for handling events across different applications. Requires a running <a href=\"#Server\">Server</a>.</p>\n</dd>\n<dt><a href=\"#Event\">Event</a></dt>\n<dd><p>Event\nThe Event class contains methods for creating and managing event handlers.</p>\n</dd>\n<dt><a href=\"#EventService\">EventService</a></dt>\n<dd><p>Service that handles the creation and management of events.</p>\n</dd>\n<dt><a href=\"#Server\">Server</a></dt>\n<dd><p>Server\nCreates a WebSocket Server for the managing of events across multiple applications. Allows connections only from <a href=\"#Client\">Client</a>s that have been registered using server.registerService(serviceName).</p>\n</dd>\n</dl>\n\n## Interfaces\n\n<dl>\n<dt><a href=\"#Message\">Message</a></dt>\n<dd></dd>\n</dl>\n\n<a name=\"Message\"></a>\n\n## Message\n**Kind**: global interface  \n**Properties**\n\n| Name | Type | Description |\n| --- | --- | --- |\n| id | <code>string</code> | The unique identifier for this message. This may be valuable for distinguising between iterations of a single event that it called multiple times. |\n| destination | <code>string</code> \\| <code>undefined</code> | Optional. The intended recipient service of this message. If the service is not registered with the Server, the message will be ignored. If this argument is omitted, it is assumed that the [Event](#Event) is meant to be handled locally. |\n| origin | <code>string</code> | The service that the [Event](#Event) originated from. |\n| eventId | <code>string</code> | An identifier for the [Event](#Event). While the identifier must be unique for Events on a service, different services may share Event identifiers. It is also possible for a single event to be raised multiple times. |\n| payload | <code>T</code> | Optional. If provided, this generic ([T](T)) object will be passed to events at the destination service as the data for event handlers. |\n\n<a name=\"Client\"></a>\n\n## Client\nClient\nCreates a WebSocket Client for handling events across different applications. Requires a running [Server](#Server).\n\n**Kind**: global class  \n\n* [Client](#Client)\n    * [.run(port, serviceName, ip)](#Client+run)\n    * [.send(message)](#Client+send)\n    * [.stop()](#Client+stop)\n\n<a name=\"Client+run\"></a>\n\n### client.run(port, serviceName, ip)\nInitializes the EventService Client.\n\n**Kind**: instance method of [<code>Client</code>](#Client)  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| port | <code>number</code> | The port number to connect to. |\n| serviceName | <code>string</code> | The name of the service. Must be unique, and must be registered with the server. |\n| ip | <code>string</code> | If provided, the IP address of the WebSocket Server. If this is left null, then the Client will assume the WebSocket Server is hosted at localhost. |\n\n<a name=\"Client+send\"></a>\n\n### client.send(message)\nSends a [Message](#Message) to the\nServer, which will route the message to its destination.\n\n**Kind**: instance method of [<code>Client</code>](#Client)  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| message | [<code>Message</code>](#Message) | The message object which contains the parameters needed to handle the message, as well as the message itself. |\n\n<a name=\"Client+stop\"></a>\n\n### client.stop()\nStops the client\n\n**Kind**: instance method of [<code>Client</code>](#Client)  \n<a name=\"Event\"></a>\n\n## Event\nEvent\nThe Event class contains methods for creating and managing event handlers.\n\n**Kind**: global class  \n\n* [Event](#Event)\n    * [.addListener(callback, id)](#Event+addListener) ⇒ <code>string</code>\n    * [.removeListener(id)](#Event+removeListener)\n    * [.raise(data, destination)](#Event+raise)\n    * [.listListeners()](#Event+listListeners) ⇒ <code>Array.&lt;string&gt;</code>\n\n<a name=\"Event+addListener\"></a>\n\n### event.addListener(callback, id) ⇒ <code>string</code>\nAdds a listener to the [Event](#Event). If the [Event](#Event) is [raise](raise)d,\nthen any registered listeners will be called.\n\n**Kind**: instance method of [<code>Event</code>](#Event)  \n**Returns**: <code>string</code> - Returns the unique identifier of the event handler, which\ncan be used to remove the listener.  \n**Throws**:\n\n- Invalid Identifier error if id is not unique\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| callback | <code>function</code> | The function to call when the [Event](#Event) is [raise](raise)d. |\n| id | <code>string</code> | If provided, will act as the identifier for this event handler. The id _must_ be uniquem or an error will be thrown. |\n\n<a name=\"Event+removeListener\"></a>\n\n### event.removeListener(id)\nRemoves a litener using its unique identifier\n\n**Kind**: instance method of [<code>Event</code>](#Event)  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| id | <code>string</code> | The unique identifier of the event to be removed. |\n\n<a name=\"Event+raise\"></a>\n\n### event.raise(data, destination)\nRaises the [Event](#Event). When an [Event](#Event) is raised, all of its event handlers\nare called.\n\n**Kind**: instance method of [<code>Event</code>](#Event)  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| data | <code>any</code> | The data that is sent along to an event handler as an argument |\n| destination | <code>string</code> | If a destination is specified _and_ the service has been initalized as either a server or a client, then this will direct the server to forward this event to the correct service, given that the service is registered with the server. |\n\n<a name=\"Event+listListeners\"></a>\n\n### event.listListeners() ⇒ <code>Array.&lt;string&gt;</code>\nLists the unique identifiers of the current listeners.\n\n**Kind**: instance method of [<code>Event</code>](#Event)  \n<a name=\"EventService\"></a>\n\n## EventService\nService that handles the creation and management of events.\n\n**Kind**: global class  \n<a name=\"EventService.Event\"></a>\n\n### EventService.Event(id) ⇒ [<code>Event</code>](#Event)\nEvent factory.\n\nIf called with the id of an existing [Event](#Event), will\nreturn that [Event](#Event). Otherwise, will create and return a\nnew [Event](#Event). If the service has been initalized as either a client\nor server, this will also add an event handler for pushing event data\nto the appropriate WebSockets.\n\n**Kind**: static method of [<code>EventService</code>](#EventService)  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| id | <code>string</code> | The unique identifier for the event. |\n\n<a name=\"Server\"></a>\n\n## Server\nServer\nCreates a WebSocket Server for the managing of events across multiple applications. Allows connections only from [Client](#Client)s that have been registered using server.registerService(serviceName).\n\n**Kind**: global class  \n\n* [Server](#Server)\n    * [.run(port)](#Server+run)\n    * [.registerService(serviceName)](#Server+registerService)\n    * [.send(message)](#Server+send)\n    * [.stop()](#Server+stop)\n\n<a name=\"Server+run\"></a>\n\n### server.run(port)\nRuns the WebSocket Server, which listens for, processes, and emits the events that makes all the different\nservices communicate. In order for the EventService to function between applications, exactly one _must_\nbe functioning as a server.\n\n**Kind**: instance method of [<code>Server</code>](#Server)  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| port | <code>number</code> | The port to host the Server on. |\n\n<a name=\"Server+registerService\"></a>\n\n### server.registerService(serviceName)\nAdds the given service name to the list of registered services.\n\n**Kind**: instance method of [<code>Server</code>](#Server)  \n**Throws**:\n\n- \"Invalid Identifier\" if the entry already exists.\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| serviceName | <code>string</code> | The name of the service being added. |\n\n<a name=\"Server+send\"></a>\n\n### server.send(message)\nSends a [Message](#Message) to the appropriate service, based on the\n[Message.destination](Message.destination).\n\n**Kind**: instance method of [<code>Server</code>](#Server)  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| message | [<code>Message</code>](#Message) | The message object which contains the parameters needed to handle the message, as well as the message itself. |\n\n<a name=\"Server+stop\"></a>\n\n### server.stop()\nStops the server\n\n**Kind**: instance method of [<code>Server</code>](#Server)  \n","readmeFilename":"README.md"}