@couleetech/n8n-nodes-enlightenedmsp 1.7.0 → 1.7.2

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.
@@ -12,23 +12,6 @@ const DEFAULT_FIELDS = `id
12
12
  active
13
13
  isOwnCompany
14
14
  autotaskCompanyId`;
15
- const searchCompaniesSchema = zod_1.z.object({
16
- name: zod_1.z.string().optional().describe('Company name to search for'),
17
- nameOperation: zod_1.z.enum(['equals', 'notEquals', 'contains', 'notContains']).optional().describe('How to match the company name'),
18
- defaultTicketLevel: zod_1.z.string().optional().describe('Default ticket level to filter by'),
19
- defaultTicketLevelOperation: zod_1.z.enum(['equals', 'notEquals', 'contains', 'notContains']).optional().describe('How to match the ticket level'),
20
- defaultHourlyRate: zod_1.z.number().optional().describe('Default hourly rate to filter by'),
21
- defaultHourlyRateOperation: zod_1.z.enum(['equals', 'greaterThan', 'lessThan']).optional().describe('How to compare the hourly rate'),
22
- billingConfigured: zod_1.z.boolean().optional().describe('Filter by billing configured status'),
23
- active: zod_1.z.boolean().optional().describe('Filter by active status'),
24
- isOwnCompany: zod_1.z.boolean().optional().describe('Filter by own company status'),
25
- autotaskCompanyId: zod_1.z.number().optional().describe('Filter by Autotask company ID'),
26
- sortBy: zod_1.z.enum(['name', 'defaultHourlyRate', 'id']).optional().describe('Field to sort results by'),
27
- sortOrder: zod_1.z.enum(['ASC', 'DESC']).optional().describe('Sort order for the results'),
28
- page: zod_1.z.number().optional().describe('Page number for pagination'),
29
- limit: zod_1.z.number().optional().describe('Number of results per page'),
30
- fields: zod_1.z.string().optional().describe('Fields to return in the response')
31
- });
32
15
  class SearchCoreCompaniesGraphql extends GraphqlBase_1.GraphqlBase {
33
16
  async searchCompanies(variables) {
34
17
  const query = `
@@ -43,7 +26,7 @@ class SearchCoreCompaniesGraphql extends GraphqlBase_1.GraphqlBase {
43
26
  $active: BooleanProp
44
27
  $isOwnCompany: BooleanProp
45
28
  $autotaskCompanyId: NumberProp
46
- $order: SortCoreCompaniesArgs
29
+ $order: SortInput
47
30
  ) {
48
31
  findCoreCompaniesPaginated(
49
32
  page: $page
@@ -91,19 +74,6 @@ class SearchCoreCompanies {
91
74
  required: true,
92
75
  },
93
76
  ],
94
- codex: {
95
- categories: ['AI'],
96
- subcategories: {
97
- AI: ['Tools'],
98
- },
99
- resources: {
100
- primaryDocumentation: [
101
- {
102
- url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.searchcorecompanies/',
103
- },
104
- ],
105
- },
106
- },
107
77
  properties: [
108
78
  {
109
79
  displayName: 'Name Filter',
@@ -361,87 +331,115 @@ active`,
361
331
  async execute() {
362
332
  const items = this.getInputData();
363
333
  const returnData = [];
364
- const length = items.length;
365
- const { endpoint, apiKey } = await GraphqlBase_1.GraphqlBase.getCredentials(this);
366
- const searchCompaniesGraphql = new SearchCoreCompaniesGraphql(endpoint, apiKey);
367
334
  const searchCompaniesTool = new tools_1.DynamicStructuredTool({
368
- name: 'searchCompanies',
335
+ name: 'search_companies',
369
336
  description: 'Search for companies in EnlightenedMSP with various filters and sorting options',
370
- schema: searchCompaniesSchema,
337
+ schema: zod_1.z.object({
338
+ name: zod_1.z.object({
339
+ operation: zod_1.z.enum(['equals', 'notEquals', 'contains', 'notContains']).optional().describe('Operation to apply on company name'),
340
+ value: zod_1.z.string().optional().describe('Value to filter company name by')
341
+ }).optional().describe('Filter by company name'),
342
+ defaultTicketLevel: zod_1.z.object({
343
+ operation: zod_1.z.enum(['equals', 'notEquals', 'contains', 'notContains']).optional().describe('Operation to apply on ticket level'),
344
+ value: zod_1.z.string().optional().describe('Value to filter ticket level by')
345
+ }).optional().describe('Filter by default ticket level'),
346
+ defaultHourlyRate: zod_1.z.object({
347
+ operation: zod_1.z.enum(['equals', 'greaterThan', 'lessThan']).optional().describe('Operation to apply on hourly rate'),
348
+ value: zod_1.z.number().optional().describe('Value to filter hourly rate by')
349
+ }).optional().describe('Filter by default hourly rate'),
350
+ billingConfigured: zod_1.z.boolean().optional().describe('Filter by billing configured status'),
351
+ active: zod_1.z.boolean().optional().describe('Filter by active status'),
352
+ isOwnCompany: zod_1.z.boolean().optional().describe('Filter by own company status'),
353
+ autotaskCompanyId: zod_1.z.number().optional().describe('Filter by Autotask company ID'),
354
+ sortBy: zod_1.z.enum(['name', 'defaultHourlyRate', 'id']).optional().describe('Field to sort results by'),
355
+ sortOrder: zod_1.z.enum(['ASC', 'DESC']).optional().describe('Sort order for results'),
356
+ page: zod_1.z.number().optional().describe('Page number for pagination'),
357
+ limit: zod_1.z.number().optional().describe('Number of results per page'),
358
+ fields: zod_1.z.string().optional().describe('Fields to return in the response')
359
+ }),
371
360
  func: async (args) => {
372
- const variables = {
373
- page: args.page || 1,
374
- limit: args.limit || 10,
375
- fields: args.fields || DEFAULT_FIELDS,
376
- order: args.sortBy ? { [args.sortBy]: args.sortOrder || 'ASC' } : { name: 'ASC' }
377
- };
378
- if (args.name) {
379
- switch (args.nameOperation) {
380
- case 'equals':
381
- variables.name = { eq: args.name };
382
- break;
383
- case 'notEquals':
384
- variables.name = { not: args.name };
385
- break;
386
- case 'contains':
387
- variables.name = { like: args.name };
388
- break;
389
- case 'notContains':
390
- variables.name = { notlike: args.name };
391
- break;
361
+ try {
362
+ const { endpoint, apiKey } = await GraphqlBase_1.GraphqlBase.getCredentials(this);
363
+ const searchCompaniesGraphql = new SearchCoreCompaniesGraphql(endpoint, apiKey);
364
+ const variables = {
365
+ page: args.page || 1,
366
+ limit: args.limit || 10,
367
+ fields: args.fields || DEFAULT_FIELDS,
368
+ order: args.sortBy ? { field: args.sortBy, direction: args.sortOrder || 'ASC' } : undefined
369
+ };
370
+ if (args.name) {
371
+ switch (args.name.operation) {
372
+ case 'equals':
373
+ variables.name = { eq: args.name.value };
374
+ break;
375
+ case 'notEquals':
376
+ variables.name = { not: args.name.value };
377
+ break;
378
+ case 'contains':
379
+ variables.name = { like: args.name.value };
380
+ break;
381
+ case 'notContains':
382
+ variables.name = { notlike: args.name.value };
383
+ break;
384
+ }
392
385
  }
393
- }
394
- if (args.defaultTicketLevel) {
395
- switch (args.defaultTicketLevelOperation) {
396
- case 'equals':
397
- variables.defaultTicketLevel = { eq: args.defaultTicketLevel };
398
- break;
399
- case 'notEquals':
400
- variables.defaultTicketLevel = { not: args.defaultTicketLevel };
401
- break;
402
- case 'contains':
403
- variables.defaultTicketLevel = { like: args.defaultTicketLevel };
404
- break;
405
- case 'notContains':
406
- variables.defaultTicketLevel = { notlike: args.defaultTicketLevel };
407
- break;
386
+ if (args.defaultTicketLevel) {
387
+ switch (args.defaultTicketLevel.operation) {
388
+ case 'equals':
389
+ variables.defaultTicketLevel = { eq: args.defaultTicketLevel.value };
390
+ break;
391
+ case 'notEquals':
392
+ variables.defaultTicketLevel = { not: args.defaultTicketLevel.value };
393
+ break;
394
+ case 'contains':
395
+ variables.defaultTicketLevel = { like: args.defaultTicketLevel.value };
396
+ break;
397
+ case 'notContains':
398
+ variables.defaultTicketLevel = { notlike: args.defaultTicketLevel.value };
399
+ break;
400
+ }
408
401
  }
409
- }
410
- if (args.defaultHourlyRate !== undefined) {
411
- switch (args.defaultHourlyRateOperation) {
412
- case 'equals':
413
- variables.defaultHourlyRate = { eq: args.defaultHourlyRate };
414
- break;
415
- case 'greaterThan':
416
- variables.defaultHourlyRate = { gte: args.defaultHourlyRate };
417
- break;
418
- case 'lessThan':
419
- variables.defaultHourlyRate = { lte: args.defaultHourlyRate };
420
- break;
402
+ if (args.defaultHourlyRate) {
403
+ switch (args.defaultHourlyRate.operation) {
404
+ case 'equals':
405
+ variables.defaultHourlyRate = { eq: args.defaultHourlyRate.value };
406
+ break;
407
+ case 'greaterThan':
408
+ variables.defaultHourlyRate = { gte: args.defaultHourlyRate.value };
409
+ break;
410
+ case 'lessThan':
411
+ variables.defaultHourlyRate = { lte: args.defaultHourlyRate.value };
412
+ break;
413
+ }
421
414
  }
415
+ if (args.billingConfigured !== undefined) {
416
+ variables.billingConfigured = { eq: args.billingConfigured };
417
+ }
418
+ if (args.active !== undefined) {
419
+ variables.active = { eq: args.active };
420
+ }
421
+ if (args.isOwnCompany !== undefined) {
422
+ variables.isOwnCompany = { eq: args.isOwnCompany };
423
+ }
424
+ if (args.autotaskCompanyId) {
425
+ variables.autotaskCompanyId = { eq: args.autotaskCompanyId };
426
+ }
427
+ const result = await searchCompaniesGraphql.searchCompanies(variables);
428
+ return JSON.stringify({
429
+ companies: result.findCoreCompaniesPaginated.data,
430
+ totalCount: result.findCoreCompaniesPaginated.totalCount,
431
+ page: result.findCoreCompaniesPaginated.page,
432
+ limit: result.findCoreCompaniesPaginated.limit
433
+ });
422
434
  }
423
- if (args.billingConfigured !== undefined) {
424
- variables.billingConfigured = { eq: args.billingConfigured };
425
- }
426
- if (args.active !== undefined) {
427
- variables.active = { eq: args.active };
428
- }
429
- if (args.isOwnCompany !== undefined) {
430
- variables.isOwnCompany = { eq: args.isOwnCompany };
431
- }
432
- if (args.autotaskCompanyId) {
433
- variables.autotaskCompanyId = { eq: args.autotaskCompanyId };
435
+ catch (error) {
436
+ throw new Error(`Failed to search companies: ${error.message}`);
434
437
  }
435
- const result = await searchCompaniesGraphql.searchCompanies(variables);
436
- return JSON.stringify({
437
- companies: result.findCoreCompaniesPaginated.data,
438
- totalCount: result.findCoreCompaniesPaginated.totalCount,
439
- page: result.findCoreCompaniesPaginated.page,
440
- limit: result.findCoreCompaniesPaginated.limit,
441
- });
442
438
  }
443
439
  });
444
- for (let i = 0; i < length; i++) {
440
+ const { endpoint, apiKey } = await GraphqlBase_1.GraphqlBase.getCredentials(this);
441
+ const searchCompaniesGraphql = new SearchCoreCompaniesGraphql(endpoint, apiKey);
442
+ for (let i = 0; i < items.length; i++) {
445
443
  try {
446
444
  const nameFilter = this.getNodeParameter('nameFilter', i, {});
447
445
  const defaultTicketLevelFilter = this.getNodeParameter('defaultTicketLevelFilter', i, {});
@@ -462,7 +460,7 @@ active`,
462
460
  billingConfigured: { eq: billingConfigured },
463
461
  active: { eq: active },
464
462
  isOwnCompany: { eq: isOwnCompany },
465
- order: { [sortBy]: sortOrder },
463
+ order: { field: sortBy, direction: sortOrder },
466
464
  };
467
465
  if (nameFilter.filter) {
468
466
  switch (nameFilter.filter.operation) {
@@ -516,28 +514,27 @@ active`,
516
514
  returnData.push({
517
515
  json: result.findCoreCompaniesPaginated,
518
516
  });
519
- void this.addOutputData("ai_tool", i, [[{
520
- json: {
521
- tool: searchCompaniesTool,
522
- data: result.findCoreCompaniesPaginated,
523
- },
524
- }]]);
525
517
  }
526
518
  catch (error) {
527
519
  if (this.continueOnFail()) {
528
- const errorOutput = {
520
+ returnData.push({
529
521
  json: {
530
522
  error: error.message,
531
523
  },
532
- };
533
- returnData.push(errorOutput);
534
- void this.addOutputData("ai_tool", i, [[errorOutput]]);
524
+ });
535
525
  continue;
536
526
  }
537
527
  throw error;
538
528
  }
539
529
  }
540
- return [returnData];
530
+ const firstItem = returnData[0] || { json: {} };
531
+ return [[{
532
+ ...firstItem,
533
+ json: {
534
+ ...firstItem.json,
535
+ tools: [searchCompaniesTool]
536
+ }
537
+ }]];
541
538
  }
542
539
  }
543
540
  exports.SearchCoreCompanies = SearchCoreCompanies;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@couleetech/n8n-nodes-enlightenedmsp",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "n8n node for EnlightenedMSP ticketing and workflow automation",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",