@couleetech/n8n-nodes-enlightenedmsp 1.5.0 → 1.6.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 { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class SearchCoreCompanies implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,451 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SearchCoreCompanies = void 0;
4
+ const GraphqlBase_1 = require("./GraphqlBase");
5
+ const DEFAULT_FIELDS = `id
6
+ name
7
+ defaultTicketLevel
8
+ defaultHourlyRate
9
+ billingConfigured
10
+ active
11
+ isOwnCompany
12
+ autotaskCompanyId`;
13
+ class SearchCoreCompaniesGraphql extends GraphqlBase_1.GraphqlBase {
14
+ async searchCompanies(variables) {
15
+ const query = `
16
+ query SearchCoreCompanies(
17
+ $page: Int
18
+ $limit: Int
19
+ $id: NumberProp
20
+ $name: StringProp
21
+ $defaultTicketLevel: StringProp
22
+ $defaultHourlyRate: NumberProp
23
+ $billingConfigured: BooleanProp
24
+ $active: BooleanProp
25
+ $isOwnCompany: BooleanProp
26
+ $autotaskCompanyId: NumberProp
27
+ $order: SortCoreCompaniesArgs
28
+ ) {
29
+ findCoreCompaniesPaginated(
30
+ page: $page
31
+ limit: $limit
32
+ id: $id
33
+ name: $name
34
+ defaultTicketLevel: $defaultTicketLevel
35
+ defaultHourlyRate: $defaultHourlyRate
36
+ billingConfigured: $billingConfigured
37
+ active: $active
38
+ isOwnCompany: $isOwnCompany
39
+ autotaskCompanyId: $autotaskCompanyId
40
+ order: $order
41
+ ) {
42
+ data {
43
+ ${variables.fields || DEFAULT_FIELDS}
44
+ }
45
+ totalCount
46
+ page
47
+ limit
48
+ }
49
+ }
50
+ `;
51
+ return this.executeGraphql(query, variables);
52
+ }
53
+ }
54
+ class SearchCoreCompanies {
55
+ constructor() {
56
+ this.description = {
57
+ displayName: 'Search Core Companies',
58
+ name: 'searchCoreCompanies',
59
+ icon: 'file:enlightenedmsp.svg',
60
+ group: ['transform'],
61
+ version: 1,
62
+ description: 'Search for companies in EnlightenedMSP',
63
+ defaults: {
64
+ name: 'Search Core Companies',
65
+ },
66
+ inputs: ['main'],
67
+ outputs: ['main', "ai_tool"],
68
+ outputNames: ['Output', 'Tool'],
69
+ credentials: [
70
+ {
71
+ name: 'enlightenedMspGraphql',
72
+ required: true,
73
+ },
74
+ ],
75
+ codex: {
76
+ categories: ['AI'],
77
+ subcategories: {
78
+ AI: ['Tools'],
79
+ },
80
+ resources: {
81
+ primaryDocumentation: [
82
+ {
83
+ url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.searchcorecompanies/',
84
+ },
85
+ ],
86
+ },
87
+ },
88
+ properties: [
89
+ {
90
+ displayName: 'Name Filter',
91
+ name: 'nameFilter',
92
+ type: 'fixedCollection',
93
+ default: {},
94
+ options: [
95
+ {
96
+ displayName: 'Filter',
97
+ name: 'filter',
98
+ values: [
99
+ {
100
+ displayName: 'Operation',
101
+ name: 'operation',
102
+ type: 'options',
103
+ options: [
104
+ {
105
+ name: 'Equals',
106
+ value: 'equals',
107
+ },
108
+ {
109
+ name: 'Not Equals',
110
+ value: 'notEquals',
111
+ },
112
+ {
113
+ name: 'Contains',
114
+ value: 'contains',
115
+ },
116
+ {
117
+ name: 'Not Contains',
118
+ value: 'notContains',
119
+ },
120
+ ],
121
+ default: 'equals',
122
+ typeOptions: {
123
+ minWidth: '100px',
124
+ display: 'inline',
125
+ },
126
+ },
127
+ {
128
+ displayName: 'Value',
129
+ name: 'value',
130
+ type: 'string',
131
+ default: '',
132
+ typeOptions: {
133
+ minWidth: '100px',
134
+ display: 'inline',
135
+ },
136
+ },
137
+ ],
138
+ },
139
+ ],
140
+ },
141
+ {
142
+ displayName: 'Default Ticket Level Filter',
143
+ name: 'defaultTicketLevelFilter',
144
+ type: 'fixedCollection',
145
+ default: {},
146
+ options: [
147
+ {
148
+ displayName: 'Filter',
149
+ name: 'filter',
150
+ values: [
151
+ {
152
+ displayName: 'Operation',
153
+ name: 'operation',
154
+ type: 'options',
155
+ options: [
156
+ {
157
+ name: 'Equals',
158
+ value: 'equals',
159
+ },
160
+ {
161
+ name: 'Not Equals',
162
+ value: 'notEquals',
163
+ },
164
+ {
165
+ name: 'Contains',
166
+ value: 'contains',
167
+ },
168
+ {
169
+ name: 'Not Contains',
170
+ value: 'notContains',
171
+ },
172
+ ],
173
+ default: 'equals',
174
+ typeOptions: {
175
+ minWidth: '100px',
176
+ display: 'inline',
177
+ },
178
+ },
179
+ {
180
+ displayName: 'Value',
181
+ name: 'value',
182
+ type: 'string',
183
+ default: '',
184
+ typeOptions: {
185
+ minWidth: '100px',
186
+ display: 'inline',
187
+ },
188
+ },
189
+ ],
190
+ },
191
+ ],
192
+ },
193
+ {
194
+ displayName: 'Default Hourly Rate Filter',
195
+ name: 'defaultHourlyRateFilter',
196
+ type: 'fixedCollection',
197
+ default: {},
198
+ options: [
199
+ {
200
+ displayName: 'Filter',
201
+ name: 'filter',
202
+ values: [
203
+ {
204
+ displayName: 'Operation',
205
+ name: 'operation',
206
+ type: 'options',
207
+ options: [
208
+ {
209
+ name: 'Equals',
210
+ value: 'equals',
211
+ },
212
+ {
213
+ name: 'Greater Than',
214
+ value: 'greaterThan',
215
+ },
216
+ {
217
+ name: 'Less Than',
218
+ value: 'lessThan',
219
+ },
220
+ ],
221
+ default: 'equals',
222
+ typeOptions: {
223
+ minWidth: '100px',
224
+ display: 'inline',
225
+ },
226
+ },
227
+ {
228
+ displayName: 'Value',
229
+ name: 'value',
230
+ type: 'number',
231
+ default: 0,
232
+ typeOptions: {
233
+ minWidth: '100px',
234
+ display: 'inline',
235
+ },
236
+ },
237
+ ],
238
+ },
239
+ ],
240
+ },
241
+ {
242
+ displayName: 'Billing Configured',
243
+ name: 'billingConfigured',
244
+ type: 'boolean',
245
+ default: false,
246
+ description: 'Filter by billing configured status',
247
+ },
248
+ {
249
+ displayName: 'Active',
250
+ name: 'active',
251
+ type: 'boolean',
252
+ default: true,
253
+ description: 'Filter by active status',
254
+ },
255
+ {
256
+ displayName: 'Is Own Company',
257
+ name: 'isOwnCompany',
258
+ type: 'boolean',
259
+ default: false,
260
+ description: 'Filter by own company status',
261
+ },
262
+ {
263
+ displayName: 'Autotask Company ID',
264
+ name: 'autotaskCompanyId',
265
+ type: 'number',
266
+ default: 0,
267
+ description: 'Filter by Autotask company ID',
268
+ },
269
+ {
270
+ displayName: 'Sort By',
271
+ name: 'sortBy',
272
+ type: 'options',
273
+ options: [
274
+ {
275
+ name: 'Company Name',
276
+ value: 'name',
277
+ },
278
+ {
279
+ name: 'Default Hourly Rate',
280
+ value: 'defaultHourlyRate',
281
+ },
282
+ {
283
+ name: 'ID',
284
+ value: 'id',
285
+ },
286
+ ],
287
+ default: 'name',
288
+ description: 'Field to sort results by',
289
+ },
290
+ {
291
+ displayName: 'Sort Order',
292
+ name: 'sortOrder',
293
+ type: 'options',
294
+ options: [
295
+ {
296
+ name: 'Ascending',
297
+ value: 'ASC',
298
+ },
299
+ {
300
+ name: 'Descending',
301
+ value: 'DESC',
302
+ },
303
+ ],
304
+ default: 'ASC',
305
+ description: 'Sort order for the results',
306
+ },
307
+ {
308
+ displayName: 'Page',
309
+ name: 'page',
310
+ type: 'number',
311
+ default: 1,
312
+ description: 'Page number for pagination',
313
+ },
314
+ {
315
+ displayName: 'Limit',
316
+ name: 'limit',
317
+ type: 'number',
318
+ default: 10,
319
+ description: 'Number of results per page',
320
+ },
321
+ {
322
+ displayName: 'Data Selection',
323
+ name: 'dataSelection',
324
+ type: 'string',
325
+ typeOptions: {
326
+ rows: 8,
327
+ },
328
+ default: DEFAULT_FIELDS,
329
+ required: false,
330
+ noDataExpression: true,
331
+ description: 'Fields to return in the response. Leave empty to use default fields.',
332
+ placeholder: `Example fields:
333
+ id
334
+ name
335
+ defaultTicketLevel
336
+ defaultHourlyRate
337
+ active`,
338
+ },
339
+ ],
340
+ };
341
+ }
342
+ async execute() {
343
+ const items = this.getInputData();
344
+ const returnData = [];
345
+ const length = items.length;
346
+ const { endpoint, apiKey } = await GraphqlBase_1.GraphqlBase.getCredentials(this);
347
+ const searchCompaniesGraphql = new SearchCoreCompaniesGraphql(endpoint, apiKey);
348
+ for (let i = 0; i < length; i++) {
349
+ try {
350
+ const nameFilter = this.getNodeParameter('nameFilter', i, {});
351
+ const defaultTicketLevelFilter = this.getNodeParameter('defaultTicketLevelFilter', i, {});
352
+ const defaultHourlyRateFilter = this.getNodeParameter('defaultHourlyRateFilter', i, {});
353
+ const billingConfigured = this.getNodeParameter('billingConfigured', i);
354
+ const active = this.getNodeParameter('active', i);
355
+ const isOwnCompany = this.getNodeParameter('isOwnCompany', i);
356
+ const autotaskCompanyId = this.getNodeParameter('autotaskCompanyId', i);
357
+ const sortBy = this.getNodeParameter('sortBy', i);
358
+ const sortOrder = this.getNodeParameter('sortOrder', i);
359
+ const page = this.getNodeParameter('page', i);
360
+ const limit = this.getNodeParameter('limit', i);
361
+ const dataSelection = this.getNodeParameter('dataSelection', i, DEFAULT_FIELDS);
362
+ const variables = {
363
+ page,
364
+ limit,
365
+ fields: dataSelection,
366
+ billingConfigured: { eq: billingConfigured },
367
+ active: { eq: active },
368
+ isOwnCompany: { eq: isOwnCompany },
369
+ order: { [sortBy]: sortOrder },
370
+ };
371
+ if (nameFilter.filter) {
372
+ switch (nameFilter.filter.operation) {
373
+ case 'equals':
374
+ variables.name = { eq: nameFilter.filter.value };
375
+ break;
376
+ case 'notEquals':
377
+ variables.name = { not: nameFilter.filter.value };
378
+ break;
379
+ case 'contains':
380
+ variables.name = { like: nameFilter.filter.value };
381
+ break;
382
+ case 'notContains':
383
+ variables.name = { notlike: nameFilter.filter.value };
384
+ break;
385
+ }
386
+ }
387
+ if (defaultTicketLevelFilter.filter) {
388
+ switch (defaultTicketLevelFilter.filter.operation) {
389
+ case 'equals':
390
+ variables.defaultTicketLevel = { eq: defaultTicketLevelFilter.filter.value };
391
+ break;
392
+ case 'notEquals':
393
+ variables.defaultTicketLevel = { not: defaultTicketLevelFilter.filter.value };
394
+ break;
395
+ case 'contains':
396
+ variables.defaultTicketLevel = { like: defaultTicketLevelFilter.filter.value };
397
+ break;
398
+ case 'notContains':
399
+ variables.defaultTicketLevel = { notlike: defaultTicketLevelFilter.filter.value };
400
+ break;
401
+ }
402
+ }
403
+ if (defaultHourlyRateFilter.filter) {
404
+ switch (defaultHourlyRateFilter.filter.operation) {
405
+ case 'equals':
406
+ variables.defaultHourlyRate = { eq: defaultHourlyRateFilter.filter.value };
407
+ break;
408
+ case 'greaterThan':
409
+ variables.defaultHourlyRate = { gte: defaultHourlyRateFilter.filter.value };
410
+ break;
411
+ case 'lessThan':
412
+ variables.defaultHourlyRate = { lte: defaultHourlyRateFilter.filter.value };
413
+ break;
414
+ }
415
+ }
416
+ if (autotaskCompanyId) {
417
+ variables.autotaskCompanyId = { eq: autotaskCompanyId };
418
+ }
419
+ const result = await searchCompaniesGraphql.searchCompanies(variables);
420
+ const outputItem = {
421
+ json: result.findCoreCompaniesPaginated,
422
+ };
423
+ returnData.push(outputItem);
424
+ const aiToolOutput = {
425
+ json: {
426
+ companies: result.findCoreCompaniesPaginated.data,
427
+ totalCount: result.findCoreCompaniesPaginated.totalCount,
428
+ page: result.findCoreCompaniesPaginated.page,
429
+ limit: result.findCoreCompaniesPaginated.limit,
430
+ },
431
+ };
432
+ void this.addOutputData("ai_tool", i, [[aiToolOutput]]);
433
+ }
434
+ catch (error) {
435
+ if (this.continueOnFail()) {
436
+ const errorOutput = {
437
+ json: {
438
+ error: error.message,
439
+ },
440
+ };
441
+ returnData.push(errorOutput);
442
+ void this.addOutputData("ai_tool", i, [[errorOutput]]);
443
+ continue;
444
+ }
445
+ throw error;
446
+ }
447
+ }
448
+ return [returnData];
449
+ }
450
+ }
451
+ exports.SearchCoreCompanies = SearchCoreCompanies;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@couleetech/n8n-nodes-enlightenedmsp",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "n8n node for EnlightenedMSP ticketing and workflow automation",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -43,7 +43,8 @@
43
43
  "dist/nodes/EnlightenedMsp/TicketCreated.node.js",
44
44
  "dist/nodes/EnlightenedMsp/TimeclockClockIn.node.js",
45
45
  "dist/nodes/EnlightenedMsp/TimeclockClockOut.node.js",
46
- "dist/nodes/EnlightenedMsp/SearchDattormmDevices.node.js"
46
+ "dist/nodes/EnlightenedMsp/SearchDattormmDevices.node.js",
47
+ "dist/nodes/EnlightenedMsp/SearchCoreCompanies.node.js"
47
48
  ],
48
49
  "credentials": [
49
50
  "dist/credentials/EnlightenedMspApi.credentials.js",