@couleetech/n8n-nodes-enlightenedmsp 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ import { ITriggerFunctions, ITriggerResponse, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class EnlightenedEvent implements INodeType {
3
+ description: INodeTypeDescription;
4
+ trigger(this: ITriggerFunctions): Promise<ITriggerResponse>;
5
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.EnlightenedEvent = void 0;
27
+ class EnlightenedEvent {
28
+ constructor() {
29
+ this.description = {
30
+ displayName: 'Enlightened Event Trigger',
31
+ name: 'enlightenedEvent',
32
+ icon: 'file:enlightenedmsp.svg',
33
+ group: ['trigger'],
34
+ version: 1,
35
+ description: 'Triggers when an event is received from EnlightenedMSP',
36
+ defaults: {
37
+ name: 'Enlightened Event Trigger',
38
+ },
39
+ inputs: [],
40
+ outputs: ["main"],
41
+ credentials: [
42
+ {
43
+ name: 'enlightenedMspNats',
44
+ required: true,
45
+ },
46
+ ],
47
+ properties: [
48
+ {
49
+ displayName: 'Namespace',
50
+ name: 'namespace',
51
+ type: 'string',
52
+ default: '',
53
+ required: true,
54
+ description: 'The namespace for the NATS event (e.g., "production", "staging")',
55
+ },
56
+ {
57
+ displayName: 'Queue Group',
58
+ name: 'queue',
59
+ type: 'string',
60
+ default: '',
61
+ required: false,
62
+ description: 'Optional queue group name for load balancing',
63
+ },
64
+ {
65
+ displayName: 'Event',
66
+ name: 'event',
67
+ type: 'string',
68
+ default: '',
69
+ required: true,
70
+ description: 'The event to trigger on',
71
+ },
72
+ ],
73
+ };
74
+ }
75
+ async trigger() {
76
+ const namespace = this.getNodeParameter('namespace');
77
+ const queue = this.getNodeParameter('queue');
78
+ const event = this.getNodeParameter('event');
79
+ const credentials = await this.getCredentials('enlightenedMspNats');
80
+ const { connect } = await Promise.resolve().then(() => __importStar(require('nats')));
81
+ const natsConnection = await connect({
82
+ servers: credentials.natsServer,
83
+ user: credentials.username,
84
+ pass: credentials.password,
85
+ token: credentials.token,
86
+ });
87
+ const subject = `${namespace}.${event}`;
88
+ const subscription = queue
89
+ ? natsConnection.subscribe(subject, { queue })
90
+ : natsConnection.subscribe(subject);
91
+ (async () => {
92
+ for await (const message of subscription) {
93
+ try {
94
+ const payload = JSON.parse(new TextDecoder().decode(message.data));
95
+ this.emit([this.helpers.returnJsonArray([payload])]);
96
+ }
97
+ catch (error) {
98
+ console.error('Error processing NATS message:', error);
99
+ }
100
+ }
101
+ })();
102
+ async function closeFunction() {
103
+ await subscription.unsubscribe();
104
+ await natsConnection.close();
105
+ }
106
+ return {
107
+ closeFunction,
108
+ async manualTriggerFunction() {
109
+ },
110
+ };
111
+ }
112
+ }
113
+ exports.EnlightenedEvent = EnlightenedEvent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@couleetech/n8n-nodes-enlightenedmsp",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "n8n node for EnlightenedMSP ticketing and workflow automation",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -44,7 +44,9 @@
44
44
  "dist/nodes/EnlightenedMsp/TimeclockClockIn.node.js",
45
45
  "dist/nodes/EnlightenedMsp/TimeclockClockOut.node.js",
46
46
  "dist/nodes/EnlightenedMsp/SearchDattormmDevices.node.js",
47
- "dist/nodes/EnlightenedMsp/SearchCoreCompanies.node.js"
47
+ "dist/nodes/EnlightenedMsp/SearchCoreCompanies.node.js",
48
+ "dist/nodes/EnlightenedMsp/CreateTodo.node.js",
49
+ "dist/nodes/EnlightenedMsp/EnlightenedEvent.node.js"
48
50
  ],
49
51
  "credentials": [
50
52
  "dist/credentials/EnlightenedMspApi.credentials.js",