@couleetech/n8n-nodes-enlightenedmsp 1.6.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.
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SearchCoreCompanies = void 0;
4
4
  const GraphqlBase_1 = require("./GraphqlBase");
5
+ const tools_1 = require("@langchain/core/tools");
6
+ const zod_1 = require("zod");
5
7
  const DEFAULT_FIELDS = `id
6
8
  name
7
9
  defaultTicketLevel
@@ -72,19 +74,6 @@ class SearchCoreCompanies {
72
74
  required: true,
73
75
  },
74
76
  ],
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
77
  properties: [
89
78
  {
90
79
  displayName: 'Name Filter',
@@ -342,10 +331,119 @@ active`,
342
331
  async execute() {
343
332
  const items = this.getInputData();
344
333
  const returnData = [];
345
- const length = items.length;
346
334
  const { endpoint, apiKey } = await GraphqlBase_1.GraphqlBase.getCredentials(this);
347
335
  const searchCompaniesGraphql = new SearchCoreCompaniesGraphql(endpoint, apiKey);
348
- for (let i = 0; i < length; i++) {
336
+ const searchCompaniesTool = new tools_1.DynamicStructuredTool({
337
+ name: 'search_companies',
338
+ description: 'Search for companies in EnlightenedMSP with various filters and sorting options',
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
+ }),
362
+ func: async (args) => {
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
+ }
385
+ }
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
+ }
401
+ }
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
+ }
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
+ });
434
+ }
435
+ catch (error) {
436
+ throw new Error(`Failed to search companies: ${error.message}`);
437
+ }
438
+ }
439
+ });
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++) {
349
447
  try {
350
448
  const nameFilter = this.getNodeParameter('nameFilter', i, {});
351
449
  const defaultTicketLevelFilter = this.getNodeParameter('defaultTicketLevelFilter', i, {});
@@ -417,29 +515,17 @@ active`,
417
515
  variables.autotaskCompanyId = { eq: autotaskCompanyId };
418
516
  }
419
517
  const result = await searchCompaniesGraphql.searchCompanies(variables);
420
- const outputItem = {
518
+ returnData.push({
421
519
  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]]);
520
+ });
433
521
  }
434
522
  catch (error) {
435
523
  if (this.continueOnFail()) {
436
- const errorOutput = {
524
+ returnData.push({
437
525
  json: {
438
526
  error: error.message,
439
527
  },
440
- };
441
- returnData.push(errorOutput);
442
- void this.addOutputData("ai_tool", i, [[errorOutput]]);
528
+ });
443
529
  continue;
444
530
  }
445
531
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@couleetech/n8n-nodes-enlightenedmsp",
3
- "version": "1.6.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",