@couleetech/n8n-nodes-enlightenedmsp 1.7.0 → 1.7.1

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 = `
@@ -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,119 @@ active`,
361
331
  async execute() {
362
332
  const items = this.getInputData();
363
333
  const returnData = [];
364
- const length = items.length;
365
334
  const { endpoint, apiKey } = await GraphqlBase_1.GraphqlBase.getCredentials(this);
366
335
  const searchCompaniesGraphql = new SearchCoreCompaniesGraphql(endpoint, apiKey);
367
336
  const searchCompaniesTool = new tools_1.DynamicStructuredTool({
368
- name: 'searchCompanies',
337
+ name: 'search_companies',
369
338
  description: 'Search for companies in EnlightenedMSP with various filters and sorting options',
370
- schema: searchCompaniesSchema,
339
+ schema: zod_1.z.object({
340
+ name: zod_1.z.object({
341
+ operation: zod_1.z.enum(['equals', 'notEquals', 'contains', 'notContains']),
342
+ value: zod_1.z.string()
343
+ }).optional().describe('Filter by company name'),
344
+ defaultTicketLevel: zod_1.z.object({
345
+ operation: zod_1.z.enum(['equals', 'notEquals', 'contains', 'notContains']),
346
+ value: zod_1.z.string()
347
+ }).optional().describe('Filter by default ticket level'),
348
+ defaultHourlyRate: zod_1.z.object({
349
+ operation: zod_1.z.enum(['equals', 'greaterThan', 'lessThan']),
350
+ value: zod_1.z.number()
351
+ }).optional().describe('Filter by default hourly rate'),
352
+ billingConfigured: zod_1.z.boolean().optional().describe('Filter by billing configured status'),
353
+ active: zod_1.z.boolean().optional().describe('Filter by active status'),
354
+ isOwnCompany: zod_1.z.boolean().optional().describe('Filter by own company status'),
355
+ autotaskCompanyId: zod_1.z.number().optional().describe('Filter by Autotask company ID'),
356
+ sortBy: zod_1.z.enum(['name', 'defaultHourlyRate', 'id']).optional().describe('Field to sort results by'),
357
+ sortOrder: zod_1.z.enum(['ASC', 'DESC']).optional().describe('Sort order for results'),
358
+ page: zod_1.z.number().optional().describe('Page number for pagination'),
359
+ limit: zod_1.z.number().optional().describe('Number of results per page'),
360
+ fields: zod_1.z.string().optional().describe('Fields to return in the response')
361
+ }),
371
362
  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;
363
+ try {
364
+ const variables = {
365
+ page: args.page || 1,
366
+ limit: args.limit || 10,
367
+ fields: args.fields || DEFAULT_FIELDS,
368
+ order: args.sortBy ? { [args.sortBy]: 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 toolOutput = {
441
+ json: {
442
+ tools: [searchCompaniesTool]
443
+ }
444
+ };
445
+ void this.addOutputData("ai_tool", 0, [[toolOutput]]);
446
+ for (let i = 0; i < items.length; i++) {
445
447
  try {
446
448
  const nameFilter = this.getNodeParameter('nameFilter', i, {});
447
449
  const defaultTicketLevelFilter = this.getNodeParameter('defaultTicketLevelFilter', i, {});
@@ -516,22 +518,14 @@ active`,
516
518
  returnData.push({
517
519
  json: result.findCoreCompaniesPaginated,
518
520
  });
519
- void this.addOutputData("ai_tool", i, [[{
520
- json: {
521
- tool: searchCompaniesTool,
522
- data: result.findCoreCompaniesPaginated,
523
- },
524
- }]]);
525
521
  }
526
522
  catch (error) {
527
523
  if (this.continueOnFail()) {
528
- const errorOutput = {
524
+ returnData.push({
529
525
  json: {
530
526
  error: error.message,
531
527
  },
532
- };
533
- returnData.push(errorOutput);
534
- void this.addOutputData("ai_tool", i, [[errorOutput]]);
528
+ });
535
529
  continue;
536
530
  }
537
531
  throw error;
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.1",
4
4
  "description": "n8n node for EnlightenedMSP ticketing and workflow automation",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",