@limetech/n8n-nodes-lime 0.1.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.
Files changed (194) hide show
  1. package/.eslintrc.js +58 -0
  2. package/.github/copilot-instructions.md +20 -0
  3. package/.github/workflows/publish.yml +34 -0
  4. package/README.md +79 -0
  5. package/credentials/LimeCrmApi.credentials.ts +57 -0
  6. package/credentials/LimeGoApi.credentials.ts +31 -0
  7. package/dist/credentials/LimeCrmApi.credentials.d.ts +9 -0
  8. package/dist/credentials/LimeCrmApi.credentials.js +53 -0
  9. package/dist/credentials/LimeCrmApi.credentials.js.map +1 -0
  10. package/dist/credentials/LimeGoApi.credentials.d.ts +15 -0
  11. package/dist/credentials/LimeGoApi.credentials.js +32 -0
  12. package/dist/credentials/LimeGoApi.credentials.js.map +1 -0
  13. package/dist/nodes/lime-crm/GenericTypes.d.ts +80 -0
  14. package/dist/nodes/lime-crm/GenericTypes.js +7 -0
  15. package/dist/nodes/lime-crm/GenericTypes.js.map +1 -0
  16. package/dist/nodes/lime-crm/LimeCrm.node.json +18 -0
  17. package/dist/nodes/lime-crm/LimeCrmNode.node.d.ts +17 -0
  18. package/dist/nodes/lime-crm/LimeCrmNode.node.js +114 -0
  19. package/dist/nodes/lime-crm/LimeCrmNode.node.js.map +1 -0
  20. package/dist/nodes/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.d.ts +17 -0
  21. package/dist/nodes/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.js +408 -0
  22. package/dist/nodes/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.js.map +1 -0
  23. package/dist/nodes/lime-crm/LimeCrmTrigger.node.d.ts +17 -0
  24. package/dist/nodes/lime-crm/LimeCrmTrigger.node.js +439 -0
  25. package/dist/nodes/lime-crm/LimeCrmTrigger.node.js.map +1 -0
  26. package/dist/nodes/lime-crm/lime-crm.svg +1 -0
  27. package/dist/nodes/lime-crm/methods/getAllSortableFields.d.ts +7 -0
  28. package/dist/nodes/lime-crm/methods/getAllSortableFields.js +53 -0
  29. package/dist/nodes/lime-crm/methods/getAllSortableFields.js.map +1 -0
  30. package/dist/nodes/lime-crm/methods/getLimeTypeProperties.d.ts +3 -0
  31. package/dist/nodes/lime-crm/methods/getLimeTypeProperties.js +40 -0
  32. package/dist/nodes/lime-crm/methods/getLimeTypeProperties.js.map +1 -0
  33. package/dist/nodes/lime-crm/methods/getLimeTypeRelations.d.ts +7 -0
  34. package/dist/nodes/lime-crm/methods/getLimeTypeRelations.js +30 -0
  35. package/dist/nodes/lime-crm/methods/getLimeTypeRelations.js.map +1 -0
  36. package/dist/nodes/lime-crm/methods/getLimeTypes.d.ts +3 -0
  37. package/dist/nodes/lime-crm/methods/getLimeTypes.js +33 -0
  38. package/dist/nodes/lime-crm/methods/getLimeTypes.js.map +1 -0
  39. package/dist/nodes/lime-crm/methods/getRelatedTypeProperties.d.ts +7 -0
  40. package/dist/nodes/lime-crm/methods/getRelatedTypeProperties.js +39 -0
  41. package/dist/nodes/lime-crm/methods/getRelatedTypeProperties.js.map +1 -0
  42. package/dist/nodes/lime-crm/methods/index.d.ts +5 -0
  43. package/dist/nodes/lime-crm/methods/index.js +14 -0
  44. package/dist/nodes/lime-crm/methods/index.js.map +1 -0
  45. package/dist/nodes/lime-crm/resources/limeObject/commonFields.d.ts +4 -0
  46. package/dist/nodes/lime-crm/resources/limeObject/commonFields.js +165 -0
  47. package/dist/nodes/lime-crm/resources/limeObject/commonFields.js.map +1 -0
  48. package/dist/nodes/lime-crm/resources/limeObject/index.d.ts +6 -0
  49. package/dist/nodes/lime-crm/resources/limeObject/index.js +79 -0
  50. package/dist/nodes/lime-crm/resources/limeObject/index.js.map +1 -0
  51. package/dist/nodes/lime-crm/resources/limeObject/operations/common.operation.d.ts +2 -0
  52. package/dist/nodes/lime-crm/resources/limeObject/operations/common.operation.js +36 -0
  53. package/dist/nodes/lime-crm/resources/limeObject/operations/common.operation.js.map +1 -0
  54. package/dist/nodes/lime-crm/resources/limeObject/operations/create.operation.d.ts +9 -0
  55. package/dist/nodes/lime-crm/resources/limeObject/operations/create.operation.js +234 -0
  56. package/dist/nodes/lime-crm/resources/limeObject/operations/create.operation.js.map +1 -0
  57. package/dist/nodes/lime-crm/resources/limeObject/operations/delete.operation.d.ts +9 -0
  58. package/dist/nodes/lime-crm/resources/limeObject/operations/delete.operation.js +136 -0
  59. package/dist/nodes/lime-crm/resources/limeObject/operations/delete.operation.js.map +1 -0
  60. package/dist/nodes/lime-crm/resources/limeObject/operations/get.operation.d.ts +9 -0
  61. package/dist/nodes/lime-crm/resources/limeObject/operations/get.operation.js +125 -0
  62. package/dist/nodes/lime-crm/resources/limeObject/operations/get.operation.js.map +1 -0
  63. package/dist/nodes/lime-crm/resources/limeObject/operations/getAll.operation.d.ts +3 -0
  64. package/dist/nodes/lime-crm/resources/limeObject/operations/getAll.operation.js +212 -0
  65. package/dist/nodes/lime-crm/resources/limeObject/operations/getAll.operation.js.map +1 -0
  66. package/dist/nodes/lime-crm/resources/limeObject/operations/search.operation.d.ts +9 -0
  67. package/dist/nodes/lime-crm/resources/limeObject/operations/search.operation.js +232 -0
  68. package/dist/nodes/lime-crm/resources/limeObject/operations/search.operation.js.map +1 -0
  69. package/dist/nodes/lime-crm/resources/limeObject/operations/update.operation.d.ts +9 -0
  70. package/dist/nodes/lime-crm/resources/limeObject/operations/update.operation.js +186 -0
  71. package/dist/nodes/lime-crm/resources/limeObject/operations/update.operation.js.map +1 -0
  72. package/dist/nodes/lime-crm/resources/limeType/index.d.ts +6 -0
  73. package/dist/nodes/lime-crm/resources/limeType/index.js +81 -0
  74. package/dist/nodes/lime-crm/resources/limeType/index.js.map +1 -0
  75. package/dist/nodes/lime-crm/resources/limeType/operations/getProperties.operation.d.ts +9 -0
  76. package/dist/nodes/lime-crm/resources/limeType/operations/getProperties.operation.js +112 -0
  77. package/dist/nodes/lime-crm/resources/limeType/operations/getProperties.operation.js.map +1 -0
  78. package/dist/nodes/lime-crm/resources/limeType/operations/getRelations.operation.d.ts +9 -0
  79. package/dist/nodes/lime-crm/resources/limeType/operations/getRelations.operation.js +112 -0
  80. package/dist/nodes/lime-crm/resources/limeType/operations/getRelations.operation.js.map +1 -0
  81. package/dist/nodes/lime-crm/resources/limeType/operations/getType.operation.d.ts +9 -0
  82. package/dist/nodes/lime-crm/resources/limeType/operations/getType.operation.js +70 -0
  83. package/dist/nodes/lime-crm/resources/limeType/operations/getType.operation.js.map +1 -0
  84. package/dist/nodes/lime-crm/resources/limeType/operations/listTypes.operation.d.ts +9 -0
  85. package/dist/nodes/lime-crm/resources/limeType/operations/listTypes.operation.js +86 -0
  86. package/dist/nodes/lime-crm/resources/limeType/operations/listTypes.operation.js.map +1 -0
  87. package/dist/nodes/lime-crm/resources/queryApi/index.d.ts +6 -0
  88. package/dist/nodes/lime-crm/resources/queryApi/index.js +57 -0
  89. package/dist/nodes/lime-crm/resources/queryApi/index.js.map +1 -0
  90. package/dist/nodes/lime-crm/resources/queryApi/operations/executeQuery.operation.d.ts +9 -0
  91. package/dist/nodes/lime-crm/resources/queryApi/operations/executeQuery.operation.js +559 -0
  92. package/dist/nodes/lime-crm/resources/queryApi/operations/executeQuery.operation.js.map +1 -0
  93. package/dist/nodes/lime-crm/transport/index.d.ts +2 -0
  94. package/dist/nodes/lime-crm/transport/index.js +50 -0
  95. package/dist/nodes/lime-crm/transport/index.js.map +1 -0
  96. package/dist/nodes/lime-go/LimeGo.node.d.ts +8 -0
  97. package/dist/nodes/lime-go/LimeGo.node.js +123 -0
  98. package/dist/nodes/lime-go/LimeGo.node.js.map +1 -0
  99. package/dist/nodes/lime-go/actions/organization/get.operation.d.ts +5 -0
  100. package/dist/nodes/lime-go/actions/organization/get.operation.js +39 -0
  101. package/dist/nodes/lime-go/actions/organization/get.operation.js.map +1 -0
  102. package/dist/nodes/lime-go/actions/organization/getByExternalKey.operation.d.ts +5 -0
  103. package/dist/nodes/lime-go/actions/organization/getByExternalKey.operation.js +54 -0
  104. package/dist/nodes/lime-go/actions/organization/getByExternalKey.operation.js.map +1 -0
  105. package/dist/nodes/lime-go/actions/organization/index.d.ts +7 -0
  106. package/dist/nodes/lime-go/actions/organization/index.js +92 -0
  107. package/dist/nodes/lime-go/actions/organization/index.js.map +1 -0
  108. package/dist/nodes/lime-go/actions/organization/organizationFields.d.ts +2 -0
  109. package/dist/nodes/lime-go/actions/organization/organizationFields.js +162 -0
  110. package/dist/nodes/lime-go/actions/organization/organizationFields.js.map +1 -0
  111. package/dist/nodes/lime-go/actions/organization/search.operation.d.ts +5 -0
  112. package/dist/nodes/lime-go/actions/organization/search.operation.js +70 -0
  113. package/dist/nodes/lime-go/actions/organization/search.operation.js.map +1 -0
  114. package/dist/nodes/lime-go/actions/organization/update.operation.d.ts +5 -0
  115. package/dist/nodes/lime-go/actions/organization/update.operation.js +125 -0
  116. package/dist/nodes/lime-go/actions/organization/update.operation.js.map +1 -0
  117. package/dist/nodes/lime-go/actions/person/createMail.operation.d.ts +7 -0
  118. package/dist/nodes/lime-go/actions/person/createMail.operation.js +130 -0
  119. package/dist/nodes/lime-go/actions/person/createMail.operation.js.map +1 -0
  120. package/dist/nodes/lime-go/actions/person/get.operation.d.ts +7 -0
  121. package/dist/nodes/lime-go/actions/person/get.operation.js +45 -0
  122. package/dist/nodes/lime-go/actions/person/get.operation.js.map +1 -0
  123. package/dist/nodes/lime-go/actions/person/index.d.ts +7 -0
  124. package/dist/nodes/lime-go/actions/person/index.js +92 -0
  125. package/dist/nodes/lime-go/actions/person/index.js.map +1 -0
  126. package/dist/nodes/lime-go/actions/person/personFields.d.ts +2 -0
  127. package/dist/nodes/lime-go/actions/person/personFields.js +134 -0
  128. package/dist/nodes/lime-go/actions/person/personFields.js.map +1 -0
  129. package/dist/nodes/lime-go/actions/person/search.operation.d.ts +7 -0
  130. package/dist/nodes/lime-go/actions/person/search.operation.js +81 -0
  131. package/dist/nodes/lime-go/actions/person/search.operation.js.map +1 -0
  132. package/dist/nodes/lime-go/actions/person/update.operation.d.ts +7 -0
  133. package/dist/nodes/lime-go/actions/person/update.operation.js +104 -0
  134. package/dist/nodes/lime-go/actions/person/update.operation.js.map +1 -0
  135. package/dist/nodes/lime-go/lime-go.svg +1 -0
  136. package/dist/nodes/lime-go/transport/graphqlRequest.d.ts +2 -0
  137. package/dist/nodes/lime-go/transport/graphqlRequest.js +23 -0
  138. package/dist/nodes/lime-go/transport/graphqlRequest.js.map +1 -0
  139. package/dist/nodes/lime-go/transport/transport.d.ts +3 -0
  140. package/dist/nodes/lime-go/transport/transport.js +58 -0
  141. package/dist/nodes/lime-go/transport/transport.js.map +1 -0
  142. package/dist/nodes/lime-go/triggers/webhook.d.ts +10 -0
  143. package/dist/nodes/lime-go/triggers/webhook.js +92 -0
  144. package/dist/nodes/lime-go/triggers/webhook.js.map +1 -0
  145. package/dist/package.json +49 -0
  146. package/dist/tsconfig.tsbuildinfo +1 -0
  147. package/docker-compose.yml +44 -0
  148. package/index.js +3 -0
  149. package/nodes/lime-crm/GenericTypes.ts +114 -0
  150. package/nodes/lime-crm/LimeCrm.node.json +18 -0
  151. package/nodes/lime-crm/LimeCrmNode.node.ts +154 -0
  152. package/nodes/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.ts +461 -0
  153. package/nodes/lime-crm/LimeCrmTrigger.node.ts +505 -0
  154. package/nodes/lime-crm/lime-crm.svg +1 -0
  155. package/nodes/lime-crm/methods/getAllSortableFields.ts +73 -0
  156. package/nodes/lime-crm/methods/getLimeTypeProperties.ts +48 -0
  157. package/nodes/lime-crm/methods/getLimeTypeRelations.ts +32 -0
  158. package/nodes/lime-crm/methods/getLimeTypes.ts +33 -0
  159. package/nodes/lime-crm/methods/getRelatedTypeProperties.ts +47 -0
  160. package/nodes/lime-crm/methods/index.ts +5 -0
  161. package/nodes/lime-crm/resources/limeObject/commonFields.ts +179 -0
  162. package/nodes/lime-crm/resources/limeObject/index.ts +64 -0
  163. package/nodes/lime-crm/resources/limeObject/operations/common.operation.ts +35 -0
  164. package/nodes/lime-crm/resources/limeObject/operations/create.operation.ts +234 -0
  165. package/nodes/lime-crm/resources/limeObject/operations/delete.operation.ts +136 -0
  166. package/nodes/lime-crm/resources/limeObject/operations/get.operation.ts +124 -0
  167. package/nodes/lime-crm/resources/limeObject/operations/getAll.operation.ts +242 -0
  168. package/nodes/lime-crm/resources/limeObject/operations/search.operation.ts +242 -0
  169. package/nodes/lime-crm/resources/limeObject/operations/update.operation.ts +201 -0
  170. package/nodes/lime-crm/resources/limeType/index.ts +66 -0
  171. package/nodes/lime-crm/resources/limeType/operations/getProperties.operation.ts +105 -0
  172. package/nodes/lime-crm/resources/limeType/operations/getRelations.operation.ts +105 -0
  173. package/nodes/lime-crm/resources/limeType/operations/getType.operation.ts +58 -0
  174. package/nodes/lime-crm/resources/limeType/operations/listTypes.operation.ts +76 -0
  175. package/nodes/lime-crm/resources/queryApi/index.ts +42 -0
  176. package/nodes/lime-crm/resources/queryApi/operations/executeQuery.operation.ts +605 -0
  177. package/nodes/lime-crm/transport/index.ts +74 -0
  178. package/nodes/lime-go/LimeGo.node.ts +146 -0
  179. package/nodes/lime-go/actions/organization/get.operation.ts +42 -0
  180. package/nodes/lime-go/actions/organization/getByExternalKey.operation.ts +57 -0
  181. package/nodes/lime-go/actions/organization/index.ts +69 -0
  182. package/nodes/lime-go/actions/organization/organizationFields.ts +160 -0
  183. package/nodes/lime-go/actions/organization/search.operation.ts +73 -0
  184. package/nodes/lime-go/actions/organization/update.operation.ts +140 -0
  185. package/nodes/lime-go/actions/person/createMail.operation.ts +140 -0
  186. package/nodes/lime-go/actions/person/get.operation.ts +51 -0
  187. package/nodes/lime-go/actions/person/index.ts +69 -0
  188. package/nodes/lime-go/actions/person/personFields.ts +132 -0
  189. package/nodes/lime-go/actions/person/search.operation.ts +88 -0
  190. package/nodes/lime-go/actions/person/update.operation.ts +122 -0
  191. package/nodes/lime-go/lime-go.svg +1 -0
  192. package/nodes/lime-go/transport/graphqlRequest.ts +30 -0
  193. package/package.json +50 -0
  194. package/tsconfig.json +30 -0
@@ -0,0 +1,146 @@
1
+ import {
2
+ IExecuteFunctions,
3
+ INodeExecutionData,
4
+ INodeType,
5
+ INodeTypeDescription,
6
+ NodeConnectionType,
7
+ NodeOperationError,
8
+ } from 'n8n-workflow';
9
+
10
+ // Import resource operations
11
+ import { organization } from './actions/organization';
12
+ import { person } from './actions/person';
13
+
14
+ export class LimeGo implements INodeType {
15
+ description: INodeTypeDescription = {
16
+ displayName: 'Lime Go',
17
+ name: 'limeGo',
18
+ icon: 'file:lime-go.svg',
19
+ group: ['output'],
20
+ version: 1,
21
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
22
+ description: 'Consume Lime Go API',
23
+ defaults: {
24
+ name: 'Lime Go',
25
+ },
26
+ inputs: [NodeConnectionType.Main],
27
+ outputs: [NodeConnectionType.Main],
28
+ credentials: [
29
+ {
30
+ name: 'limeGoApi',
31
+ required: true,
32
+ },
33
+ ],
34
+ properties: [
35
+ {
36
+ displayName: 'Resource',
37
+ name: 'resource',
38
+ type: 'options',
39
+ noDataExpression: true,
40
+ options: [
41
+ {
42
+ name: 'Organization',
43
+ value: 'organization',
44
+ description: 'Work with organization data',
45
+ },
46
+ {
47
+ name: 'Person',
48
+ value: 'person',
49
+ description: 'Work with person data',
50
+ },
51
+ {
52
+ name: 'Test',
53
+ value: 'test',
54
+ description: 'Test the API',
55
+ },
56
+ ],
57
+ default: 'organization',
58
+ },
59
+ // Add resource-specific operations
60
+ ...organization.description,
61
+ ...person.description,
62
+ {
63
+ displayName: 'Operation',
64
+ name: 'operation',
65
+ type: 'options',
66
+ noDataExpression: true,
67
+ displayOptions: {
68
+ show: {
69
+ resource: ['test'],
70
+ },
71
+ },
72
+ options: [
73
+ {
74
+ name: 'Ping',
75
+ value: 'ping',
76
+ description: 'Test that the LIME Go API is alive and kicking.',
77
+ },
78
+ ],
79
+ default: 'ping',
80
+ },
81
+ ],
82
+ };
83
+
84
+ methods = {
85
+ loadOptions: {
86
+ // Add any load options methods here as needed
87
+ },
88
+ };
89
+
90
+ async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
91
+ const items = this.getInputData();
92
+ const returnData: INodeExecutionData[] = [];
93
+
94
+ // For each item, process the operation
95
+ for (let i = 0; i < items.length; i++) {
96
+ try {
97
+ const resource = this.getNodeParameter('resource', i) as string;
98
+ const operation = this.getNodeParameter('operation', i) as string;
99
+
100
+ let responseData;
101
+
102
+ // Handle different resources and operations
103
+ if (resource === 'organization') {
104
+ // Execute the appropriate operation for organization
105
+ responseData = await organization.execute.call(this, { i });
106
+ } else if (resource === 'person') {
107
+ // Execute the appropriate operation for person
108
+ responseData = await person.execute.call(this, { i });
109
+ } else if (resource === 'test' && operation === 'ping') {
110
+ // Using n8n's requestWithAuthentication helper
111
+ responseData = await this.helpers.requestWithAuthentication.call(
112
+ this,
113
+ 'limeGoApi',
114
+ {
115
+ method: 'GET',
116
+ url: 'https://api.lime-go.com/v1/ping',
117
+ json: true,
118
+ },
119
+ );
120
+ } else {
121
+ throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported for resource "${resource}"!`, {
122
+ itemIndex: i,
123
+ });
124
+ }
125
+
126
+ // Add the result to the returned items
127
+ const executionData = this.helpers.constructExecutionMetaData(
128
+ this.helpers.returnJsonArray([responseData]),
129
+ { itemData: { item: i } },
130
+ );
131
+ returnData.push(...executionData);
132
+
133
+ } catch (error) {
134
+ if (this.continueOnFail()) {
135
+ returnData.push({ json: { error: error.message } });
136
+ continue;
137
+ } else {
138
+ throw error;
139
+ }
140
+ }
141
+ }
142
+
143
+ return [returnData];
144
+ }
145
+ }
146
+
@@ -0,0 +1,42 @@
1
+ import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
2
+ import { graphqlRequest } from '../../transport/graphqlRequest';
3
+ import { organizationFields } from './organizationFields';
4
+
5
+ export const description: INodeProperties[] = [
6
+ {
7
+ displayName: 'Organization ID',
8
+ name: 'id',
9
+ type: 'string',
10
+ default: '',
11
+ required: true,
12
+ displayOptions: {
13
+ show: {
14
+ resource: ['organization'],
15
+ operation: ['get'],
16
+ },
17
+ },
18
+ description: 'The ID of the organization to retrieve',
19
+ },
20
+ ...organizationFields,
21
+ ];
22
+
23
+ export async function execute(this: IExecuteFunctions, { i }: { i: number }) {
24
+ const id = this.getNodeParameter('id', i) as string;
25
+ const returnFields = this.getNodeParameter('returnFields', i) as string[];
26
+
27
+ // Construct fields to return based on user selection
28
+ const fieldsToReturn = returnFields.join('\n');
29
+
30
+ const query = `
31
+ query ($id: ID!) {
32
+ organization(id: $id) {
33
+ ${fieldsToReturn}
34
+ }
35
+ }
36
+ `;
37
+
38
+ const variables = { id };
39
+ const responseData = await graphqlRequest.call(this, query, variables);
40
+
41
+ return responseData.organization;
42
+ }
@@ -0,0 +1,57 @@
1
+ import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
2
+ import { graphqlRequest } from '../../transport/graphqlRequest';
3
+ import { organizationFields } from './organizationFields';
4
+
5
+ export const description: INodeProperties[] = [
6
+ {
7
+ displayName: 'External Key Value',
8
+ name: 'id',
9
+ type: 'string',
10
+ default: '',
11
+ required: true,
12
+ displayOptions: {
13
+ show: {
14
+ resource: ['organization'],
15
+ operation: ['getByExternalKey'],
16
+ },
17
+ },
18
+ description: 'The external key value to lookup',
19
+ },
20
+ {
21
+ displayName: 'External Key Name',
22
+ name: 'externalKeyName',
23
+ type: 'string',
24
+ default: '',
25
+ required: true,
26
+ displayOptions: {
27
+ show: {
28
+ resource: ['organization'],
29
+ operation: ['getByExternalKey'],
30
+ },
31
+ },
32
+ description: 'The name of the custom field or __integrationid / __bisnodeid',
33
+ },
34
+ ...organizationFields,
35
+ ];
36
+
37
+ export async function execute(this: IExecuteFunctions, { i }: { i: number }) {
38
+ const id = this.getNodeParameter('id', i) as string;
39
+ const externalKeyName = this.getNodeParameter('externalKeyName', i) as string;
40
+ const returnFields = this.getNodeParameter('returnFields', i) as string[];
41
+
42
+ // Construct fields to return based on user selection
43
+ const fieldsToReturn = returnFields.join('\n');
44
+
45
+ const query = `
46
+ query ($id: String!, $externalKeyName: String!) {
47
+ organization(id: $id, externalKeyName: $externalKeyName) {
48
+ ${fieldsToReturn}
49
+ }
50
+ }
51
+ `;
52
+
53
+ const variables = { id, externalKeyName };
54
+ const responseData = await graphqlRequest.call(this, query, variables);
55
+
56
+ return responseData.organization;
57
+ }
@@ -0,0 +1,69 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+
3
+ import * as get from './get.operation';
4
+ import * as getByExternalKey from './getByExternalKey.operation';
5
+ import * as search from './search.operation';
6
+ import * as update from './update.operation';
7
+
8
+ export const organization = {
9
+ description: [
10
+ {
11
+ displayName: 'Operation',
12
+ name: 'operation',
13
+ type: 'options',
14
+ noDataExpression: true,
15
+ displayOptions: {
16
+ show: {
17
+ resource: ['organization'],
18
+ },
19
+ },
20
+ options: [
21
+ {
22
+ name: 'Get',
23
+ value: 'get',
24
+ description: 'Get a specific organization by ID',
25
+ action: 'Get an organization by ID',
26
+ },
27
+ {
28
+ name: 'Get by External Key',
29
+ value: 'getByExternalKey',
30
+ description: 'Get a specific organization by External Key',
31
+ action: 'Get an organization by external key',
32
+ },
33
+ {
34
+ name: 'Search',
35
+ value: 'search',
36
+ description: 'Search for organizations',
37
+ action: 'Search organizations',
38
+ },
39
+ {
40
+ name: 'Update',
41
+ value: 'update',
42
+ description: 'Update an organization',
43
+ action: 'Update an organization',
44
+ },
45
+ ],
46
+ default: 'get',
47
+ },
48
+ ...get.description,
49
+ ...getByExternalKey.description,
50
+ ...search.description,
51
+ ...update.description,
52
+ ] as INodeProperties[],
53
+ execute: async function (this: any, { i }: { i: number }) {
54
+ const operation = this.getNodeParameter('operation', i) as string;
55
+
56
+ switch (operation) {
57
+ case 'get':
58
+ return await get.execute.call(this, { i });
59
+ case 'getByExternalKey':
60
+ return await getByExternalKey.execute.call(this, { i });
61
+ case 'search':
62
+ return await search.execute.call(this, { i });
63
+ case 'update':
64
+ return await update.execute.call(this, { i });
65
+ default:
66
+ throw new Error(`The operation "${operation}" is not supported!`);
67
+ }
68
+ },
69
+ };
@@ -0,0 +1,160 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+
3
+ export const organizationFields: INodeProperties[] = [
4
+ {
5
+ displayName: 'Return Fields',
6
+ name: 'returnFields',
7
+ type: 'multiOptions',
8
+ options: [
9
+ {
10
+ name: 'ID',
11
+ value: 'id',
12
+ },
13
+ {
14
+ name: 'Name',
15
+ value: 'name',
16
+ },
17
+ {
18
+ name: 'City',
19
+ value: 'city',
20
+ },
21
+ {
22
+ name: 'Email',
23
+ value: 'email',
24
+ },
25
+ {
26
+ name: 'Phone Number',
27
+ value: 'phoneNumber',
28
+ },
29
+ {
30
+ name: 'Organization Number',
31
+ value: 'organizationNumber',
32
+ },
33
+ {
34
+ name: 'Integration ID',
35
+ value: 'integrationId',
36
+ },
37
+ {
38
+ name: 'Temperature',
39
+ value: 'temperature',
40
+ },
41
+ {
42
+ name: 'Customer Relation',
43
+ value: 'customerRelation',
44
+ },
45
+ {
46
+ name: 'Tags',
47
+ value: 'tags',
48
+ },
49
+ {
50
+ name: 'Turnover',
51
+ value: 'turnover',
52
+ },
53
+ {
54
+ name: 'Number of Employees',
55
+ value: 'numberOfEmployees',
56
+ },
57
+ {
58
+ name: 'Responsible Coworker',
59
+ value: 'responsibleCoworker { id name email phoneNumber }',
60
+ },
61
+ {
62
+ name: 'Custom Fields',
63
+ value: 'customFields { title type value }',
64
+ },
65
+ ],
66
+ default: ['id', 'name'],
67
+ description: 'The fields to return',
68
+ displayOptions: {
69
+ show: {
70
+ resource: ['organization'],
71
+ operation: ['get', 'getByExternalKey', 'search', 'update'],
72
+ },
73
+ },
74
+ },
75
+ {
76
+ displayName: 'Additional Options',
77
+ name: 'additionalOptions',
78
+ type: 'collection',
79
+ placeholder: 'Add Option',
80
+ default: {},
81
+ displayOptions: {
82
+ show: {
83
+ resource: ['organization'],
84
+ operation: ['get', 'getByExternalKey'],
85
+ },
86
+ },
87
+ options: [
88
+ {
89
+ displayName: 'Include Employees',
90
+ name: 'includeEmployees',
91
+ type: 'boolean',
92
+ default: false,
93
+ description: 'Whether to include employees connected to the organization',
94
+ },
95
+ {
96
+ displayName: 'Employee Search Query',
97
+ name: 'employeeQuery',
98
+ type: 'string',
99
+ default: '',
100
+ displayOptions: {
101
+ show: {
102
+ includeEmployees: [true],
103
+ },
104
+ },
105
+ description: 'Search query for filtering employees',
106
+ },
107
+ {
108
+ displayName: 'Employee Limit',
109
+ name: 'employeeLimit',
110
+ type: 'number',
111
+ default: 5,
112
+ typeOptions: {
113
+ minValue: 1,
114
+ maxValue: 20,
115
+ },
116
+ displayOptions: {
117
+ show: {
118
+ includeEmployees: [true],
119
+ },
120
+ },
121
+ description: 'Max number of employees to return',
122
+ },
123
+ {
124
+ displayName: 'Include Deals',
125
+ name: 'includeDeals',
126
+ type: 'boolean',
127
+ default: false,
128
+ description: 'Whether to include deals connected to the organization',
129
+ },
130
+ {
131
+ displayName: 'Deal Search Query',
132
+ name: 'dealQuery',
133
+ type: 'string',
134
+ default: '',
135
+ displayOptions: {
136
+ show: {
137
+ includeDeals: [true],
138
+ },
139
+ },
140
+ description: 'Search query for filtering deals',
141
+ },
142
+ {
143
+ displayName: 'Deal Limit',
144
+ name: 'dealLimit',
145
+ type: 'number',
146
+ default: 5,
147
+ typeOptions: {
148
+ minValue: 1,
149
+ maxValue: 20,
150
+ },
151
+ displayOptions: {
152
+ show: {
153
+ includeDeals: [true],
154
+ },
155
+ },
156
+ description: 'Max number of deals to return',
157
+ },
158
+ ],
159
+ },
160
+ ];
@@ -0,0 +1,73 @@
1
+ import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
2
+ import { graphqlRequest } from '../../transport/graphqlRequest';
3
+ import { organizationFields } from './organizationFields';
4
+
5
+ export const description: INodeProperties[] = [
6
+ {
7
+ displayName: 'Search Query',
8
+ name: 'query',
9
+ type: 'string',
10
+ default: '',
11
+ displayOptions: {
12
+ show: {
13
+ resource: ['organization'],
14
+ operation: ['search'],
15
+ },
16
+ },
17
+ description: 'Search text applied against organization name and address. Leave empty to return all organizations',
18
+ },
19
+ {
20
+ displayName: 'Limit',
21
+ name: 'limit',
22
+ type: 'number',
23
+ default: 10,
24
+ typeOptions: {
25
+ minValue: 1,
26
+ maxValue: 20,
27
+ },
28
+ displayOptions: {
29
+ show: {
30
+ resource: ['organization'],
31
+ operation: ['search'],
32
+ },
33
+ },
34
+ description: 'Max number of results to return (max: 20)',
35
+ },
36
+ {
37
+ displayName: 'Offset',
38
+ name: 'offset',
39
+ type: 'number',
40
+ default: 0,
41
+ displayOptions: {
42
+ show: {
43
+ resource: ['organization'],
44
+ operation: ['search'],
45
+ },
46
+ },
47
+ description: 'Offset results by this number',
48
+ },
49
+ ...organizationFields,
50
+ ];
51
+
52
+ export async function execute(this: IExecuteFunctions, { i }: { i: number }) {
53
+ const query = this.getNodeParameter('query', i) as string;
54
+ const limit = this.getNodeParameter('limit', i) as number;
55
+ const offset = this.getNodeParameter('offset', i) as number;
56
+ const returnFields = this.getNodeParameter('returnFields', i) as string[];
57
+
58
+ // Construct fields to return based on user selection
59
+ const fieldsToReturn = returnFields.join('\n');
60
+
61
+ const graphqlQuery = `
62
+ query ($query: String, $first: Int!, $offset: Int!) {
63
+ organizations(query: $query, first: $first, offset: $offset) {
64
+ ${fieldsToReturn}
65
+ }
66
+ }
67
+ `;
68
+
69
+ const variables = { query, first: limit, offset };
70
+ const responseData = await graphqlRequest.call(this, graphqlQuery, variables);
71
+
72
+ return responseData.organizations;
73
+ }
@@ -0,0 +1,140 @@
1
+ import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
2
+ import { graphqlRequest } from '../../transport/graphqlRequest';
3
+ import { organizationFields } from './organizationFields';
4
+
5
+ export const description: INodeProperties[] = [
6
+ {
7
+ displayName: 'Organization ID',
8
+ name: 'id',
9
+ type: 'string',
10
+ default: '',
11
+ required: true,
12
+ displayOptions: {
13
+ show: {
14
+ resource: ['organization'],
15
+ operation: ['update'],
16
+ },
17
+ },
18
+ description: 'The ID of the organization to update',
19
+ },
20
+ {
21
+ displayName: 'Update Fields',
22
+ name: 'updateFields',
23
+ type: 'collection',
24
+ placeholder: 'Add Field',
25
+ default: {},
26
+ displayOptions: {
27
+ show: {
28
+ resource: ['organization'],
29
+ operation: ['update'],
30
+ },
31
+ },
32
+ options: [
33
+ {
34
+ displayName: 'Customer Relation',
35
+ name: 'relation',
36
+ type: 'options',
37
+ options: [
38
+ {
39
+ name: 'Is a Customer',
40
+ value: 'IS_A_CUSTOMER',
41
+ },
42
+ {
43
+ name: 'Is a Lead',
44
+ value: 'IS_A_LEAD',
45
+ },
46
+ {
47
+ name: 'Is a Prospect',
48
+ value: 'IS_A_PROSPECT',
49
+ },
50
+ {
51
+ name: 'Not Interested',
52
+ value: 'NOT_INTERESTED',
53
+ },
54
+ ],
55
+ default: 'IS_A_CUSTOMER',
56
+ description: 'Set the customer relation',
57
+ },
58
+ {
59
+ displayName: 'Responsible Coworker Identifier',
60
+ name: 'responsibleCoworker',
61
+ type: 'string',
62
+ default: '',
63
+ description: 'Set the responsible coworker by their identifier',
64
+ },
65
+ {
66
+ displayName: 'Tags to Add',
67
+ name: 'addTags',
68
+ type: 'string',
69
+ default: '',
70
+ description: 'Comma-separated list of tags to add',
71
+ },
72
+ {
73
+ displayName: 'External Key Name',
74
+ name: 'externalKeyName',
75
+ type: 'string',
76
+ default: '',
77
+ description: 'Name of the external key field',
78
+ },
79
+ {
80
+ displayName: 'External Key Value',
81
+ name: 'externalKeyValue',
82
+ type: 'string',
83
+ default: '',
84
+ description: 'Value of the external key',
85
+ },
86
+ ],
87
+ },
88
+ ...organizationFields,
89
+ ];
90
+
91
+ export async function execute(this: IExecuteFunctions, { i }: { i: number }) {
92
+ const id = this.getNodeParameter('id', i) as string;
93
+ const updateFields = this.getNodeParameter('updateFields', i) as {
94
+ relation?: string;
95
+ responsibleCoworker?: string;
96
+ addTags?: string;
97
+ externalKeyName?: string;
98
+ externalKeyValue?: string;
99
+ };
100
+ const returnFields = this.getNodeParameter('returnFields', i) as string[];
101
+
102
+ // Construct fields to return based on user selection
103
+ const fieldsToReturn = returnFields.join('\n');
104
+
105
+ // Build input object for the mutation
106
+ const input: Record<string, any> = { id };
107
+
108
+ if (updateFields.relation) {
109
+ input.relation = updateFields.relation;
110
+ }
111
+
112
+ if (updateFields.responsibleCoworker) {
113
+ input.responsibleCoworker = { identifier: updateFields.responsibleCoworker };
114
+ }
115
+
116
+ if (updateFields.addTags) {
117
+ const tagList = updateFields.addTags.split(',').map(tag => tag.trim());
118
+ input.tags = { addTags: tagList };
119
+ }
120
+
121
+ if (updateFields.externalKeyName && updateFields.externalKeyValue) {
122
+ input.externalKey = {
123
+ name: updateFields.externalKeyName,
124
+ value: updateFields.externalKeyValue,
125
+ };
126
+ }
127
+
128
+ const query = `
129
+ mutation ($input: UpdateOrganizationInput!) {
130
+ updateOrganization(input: $input) {
131
+ ${fieldsToReturn}
132
+ }
133
+ }
134
+ `;
135
+
136
+ const variables = { input };
137
+ const responseData = await graphqlRequest.call(this, query, variables);
138
+
139
+ return responseData.updateOrganization;
140
+ }