@limetech/n8n-nodes-lime 0.1.0 → 0.2.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.
Files changed (192) hide show
  1. package/nodes/lime-crm/LimeCrm.node.json +16 -16
  2. package/package.json +47 -47
  3. package/{dist/tsconfig.tsbuildinfo → tsconfig.tsbuildinfo} +1 -1
  4. package/.eslintrc.js +0 -58
  5. package/.github/copilot-instructions.md +0 -20
  6. package/.github/workflows/publish.yml +0 -34
  7. package/README.md +0 -79
  8. package/credentials/LimeCrmApi.credentials.ts +0 -57
  9. package/credentials/LimeGoApi.credentials.ts +0 -31
  10. package/dist/nodes/lime-crm/LimeCrm.node.json +0 -18
  11. package/dist/nodes/lime-crm/lime-crm.svg +0 -1
  12. package/dist/nodes/lime-go/lime-go.svg +0 -1
  13. package/dist/package.json +0 -49
  14. package/docker-compose.yml +0 -44
  15. package/index.js +0 -3
  16. package/nodes/lime-crm/GenericTypes.ts +0 -114
  17. package/nodes/lime-crm/LimeCrmNode.node.ts +0 -154
  18. package/nodes/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.ts +0 -461
  19. package/nodes/lime-crm/LimeCrmTrigger.node.ts +0 -505
  20. package/nodes/lime-crm/methods/getAllSortableFields.ts +0 -73
  21. package/nodes/lime-crm/methods/getLimeTypeProperties.ts +0 -48
  22. package/nodes/lime-crm/methods/getLimeTypeRelations.ts +0 -32
  23. package/nodes/lime-crm/methods/getLimeTypes.ts +0 -33
  24. package/nodes/lime-crm/methods/getRelatedTypeProperties.ts +0 -47
  25. package/nodes/lime-crm/methods/index.ts +0 -5
  26. package/nodes/lime-crm/resources/limeObject/commonFields.ts +0 -179
  27. package/nodes/lime-crm/resources/limeObject/index.ts +0 -64
  28. package/nodes/lime-crm/resources/limeObject/operations/common.operation.ts +0 -35
  29. package/nodes/lime-crm/resources/limeObject/operations/create.operation.ts +0 -234
  30. package/nodes/lime-crm/resources/limeObject/operations/delete.operation.ts +0 -136
  31. package/nodes/lime-crm/resources/limeObject/operations/get.operation.ts +0 -124
  32. package/nodes/lime-crm/resources/limeObject/operations/getAll.operation.ts +0 -242
  33. package/nodes/lime-crm/resources/limeObject/operations/search.operation.ts +0 -242
  34. package/nodes/lime-crm/resources/limeObject/operations/update.operation.ts +0 -201
  35. package/nodes/lime-crm/resources/limeType/index.ts +0 -66
  36. package/nodes/lime-crm/resources/limeType/operations/getProperties.operation.ts +0 -105
  37. package/nodes/lime-crm/resources/limeType/operations/getRelations.operation.ts +0 -105
  38. package/nodes/lime-crm/resources/limeType/operations/getType.operation.ts +0 -58
  39. package/nodes/lime-crm/resources/limeType/operations/listTypes.operation.ts +0 -76
  40. package/nodes/lime-crm/resources/queryApi/index.ts +0 -42
  41. package/nodes/lime-crm/resources/queryApi/operations/executeQuery.operation.ts +0 -605
  42. package/nodes/lime-crm/transport/index.ts +0 -74
  43. package/nodes/lime-go/LimeGo.node.ts +0 -146
  44. package/nodes/lime-go/actions/organization/get.operation.ts +0 -42
  45. package/nodes/lime-go/actions/organization/getByExternalKey.operation.ts +0 -57
  46. package/nodes/lime-go/actions/organization/index.ts +0 -69
  47. package/nodes/lime-go/actions/organization/organizationFields.ts +0 -160
  48. package/nodes/lime-go/actions/organization/search.operation.ts +0 -73
  49. package/nodes/lime-go/actions/organization/update.operation.ts +0 -140
  50. package/nodes/lime-go/actions/person/createMail.operation.ts +0 -140
  51. package/nodes/lime-go/actions/person/get.operation.ts +0 -51
  52. package/nodes/lime-go/actions/person/index.ts +0 -69
  53. package/nodes/lime-go/actions/person/personFields.ts +0 -132
  54. package/nodes/lime-go/actions/person/search.operation.ts +0 -88
  55. package/nodes/lime-go/actions/person/update.operation.ts +0 -122
  56. package/nodes/lime-go/transport/graphqlRequest.ts +0 -30
  57. package/tsconfig.json +0 -30
  58. /package/{dist/credentials → credentials}/LimeCrmApi.credentials.d.ts +0 -0
  59. /package/{dist/credentials → credentials}/LimeCrmApi.credentials.js +0 -0
  60. /package/{dist/credentials → credentials}/LimeCrmApi.credentials.js.map +0 -0
  61. /package/{dist/credentials → credentials}/LimeGoApi.credentials.d.ts +0 -0
  62. /package/{dist/credentials → credentials}/LimeGoApi.credentials.js +0 -0
  63. /package/{dist/credentials → credentials}/LimeGoApi.credentials.js.map +0 -0
  64. /package/{dist/nodes → nodes}/lime-crm/GenericTypes.d.ts +0 -0
  65. /package/{dist/nodes → nodes}/lime-crm/GenericTypes.js +0 -0
  66. /package/{dist/nodes → nodes}/lime-crm/GenericTypes.js.map +0 -0
  67. /package/{dist/nodes → nodes}/lime-crm/LimeCrmNode.node.d.ts +0 -0
  68. /package/{dist/nodes → nodes}/lime-crm/LimeCrmNode.node.js +0 -0
  69. /package/{dist/nodes → nodes}/lime-crm/LimeCrmNode.node.js.map +0 -0
  70. /package/{dist/nodes → nodes}/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.d.ts +0 -0
  71. /package/{dist/nodes → nodes}/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.js +0 -0
  72. /package/{dist/nodes → nodes}/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.js.map +0 -0
  73. /package/{dist/nodes → nodes}/lime-crm/LimeCrmTrigger.node.d.ts +0 -0
  74. /package/{dist/nodes → nodes}/lime-crm/LimeCrmTrigger.node.js +0 -0
  75. /package/{dist/nodes → nodes}/lime-crm/LimeCrmTrigger.node.js.map +0 -0
  76. /package/{dist/nodes → nodes}/lime-crm/methods/getAllSortableFields.d.ts +0 -0
  77. /package/{dist/nodes → nodes}/lime-crm/methods/getAllSortableFields.js +0 -0
  78. /package/{dist/nodes → nodes}/lime-crm/methods/getAllSortableFields.js.map +0 -0
  79. /package/{dist/nodes → nodes}/lime-crm/methods/getLimeTypeProperties.d.ts +0 -0
  80. /package/{dist/nodes → nodes}/lime-crm/methods/getLimeTypeProperties.js +0 -0
  81. /package/{dist/nodes → nodes}/lime-crm/methods/getLimeTypeProperties.js.map +0 -0
  82. /package/{dist/nodes → nodes}/lime-crm/methods/getLimeTypeRelations.d.ts +0 -0
  83. /package/{dist/nodes → nodes}/lime-crm/methods/getLimeTypeRelations.js +0 -0
  84. /package/{dist/nodes → nodes}/lime-crm/methods/getLimeTypeRelations.js.map +0 -0
  85. /package/{dist/nodes → nodes}/lime-crm/methods/getLimeTypes.d.ts +0 -0
  86. /package/{dist/nodes → nodes}/lime-crm/methods/getLimeTypes.js +0 -0
  87. /package/{dist/nodes → nodes}/lime-crm/methods/getLimeTypes.js.map +0 -0
  88. /package/{dist/nodes → nodes}/lime-crm/methods/getRelatedTypeProperties.d.ts +0 -0
  89. /package/{dist/nodes → nodes}/lime-crm/methods/getRelatedTypeProperties.js +0 -0
  90. /package/{dist/nodes → nodes}/lime-crm/methods/getRelatedTypeProperties.js.map +0 -0
  91. /package/{dist/nodes → nodes}/lime-crm/methods/index.d.ts +0 -0
  92. /package/{dist/nodes → nodes}/lime-crm/methods/index.js +0 -0
  93. /package/{dist/nodes → nodes}/lime-crm/methods/index.js.map +0 -0
  94. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/commonFields.d.ts +0 -0
  95. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/commonFields.js +0 -0
  96. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/commonFields.js.map +0 -0
  97. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/index.d.ts +0 -0
  98. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/index.js +0 -0
  99. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/index.js.map +0 -0
  100. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/common.operation.d.ts +0 -0
  101. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/common.operation.js +0 -0
  102. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/common.operation.js.map +0 -0
  103. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/create.operation.d.ts +0 -0
  104. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/create.operation.js +0 -0
  105. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/create.operation.js.map +0 -0
  106. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/delete.operation.d.ts +0 -0
  107. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/delete.operation.js +0 -0
  108. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/delete.operation.js.map +0 -0
  109. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/get.operation.d.ts +0 -0
  110. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/get.operation.js +0 -0
  111. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/get.operation.js.map +0 -0
  112. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/getAll.operation.d.ts +0 -0
  113. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/getAll.operation.js +0 -0
  114. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/getAll.operation.js.map +0 -0
  115. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/search.operation.d.ts +0 -0
  116. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/search.operation.js +0 -0
  117. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/search.operation.js.map +0 -0
  118. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/update.operation.d.ts +0 -0
  119. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/update.operation.js +0 -0
  120. /package/{dist/nodes → nodes}/lime-crm/resources/limeObject/operations/update.operation.js.map +0 -0
  121. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/index.d.ts +0 -0
  122. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/index.js +0 -0
  123. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/index.js.map +0 -0
  124. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/operations/getProperties.operation.d.ts +0 -0
  125. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/operations/getProperties.operation.js +0 -0
  126. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/operations/getProperties.operation.js.map +0 -0
  127. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/operations/getRelations.operation.d.ts +0 -0
  128. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/operations/getRelations.operation.js +0 -0
  129. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/operations/getRelations.operation.js.map +0 -0
  130. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/operations/getType.operation.d.ts +0 -0
  131. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/operations/getType.operation.js +0 -0
  132. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/operations/getType.operation.js.map +0 -0
  133. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/operations/listTypes.operation.d.ts +0 -0
  134. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/operations/listTypes.operation.js +0 -0
  135. /package/{dist/nodes → nodes}/lime-crm/resources/limeType/operations/listTypes.operation.js.map +0 -0
  136. /package/{dist/nodes → nodes}/lime-crm/resources/queryApi/index.d.ts +0 -0
  137. /package/{dist/nodes → nodes}/lime-crm/resources/queryApi/index.js +0 -0
  138. /package/{dist/nodes → nodes}/lime-crm/resources/queryApi/index.js.map +0 -0
  139. /package/{dist/nodes → nodes}/lime-crm/resources/queryApi/operations/executeQuery.operation.d.ts +0 -0
  140. /package/{dist/nodes → nodes}/lime-crm/resources/queryApi/operations/executeQuery.operation.js +0 -0
  141. /package/{dist/nodes → nodes}/lime-crm/resources/queryApi/operations/executeQuery.operation.js.map +0 -0
  142. /package/{dist/nodes → nodes}/lime-crm/transport/index.d.ts +0 -0
  143. /package/{dist/nodes → nodes}/lime-crm/transport/index.js +0 -0
  144. /package/{dist/nodes → nodes}/lime-crm/transport/index.js.map +0 -0
  145. /package/{dist/nodes → nodes}/lime-go/LimeGo.node.d.ts +0 -0
  146. /package/{dist/nodes → nodes}/lime-go/LimeGo.node.js +0 -0
  147. /package/{dist/nodes → nodes}/lime-go/LimeGo.node.js.map +0 -0
  148. /package/{dist/nodes → nodes}/lime-go/actions/organization/get.operation.d.ts +0 -0
  149. /package/{dist/nodes → nodes}/lime-go/actions/organization/get.operation.js +0 -0
  150. /package/{dist/nodes → nodes}/lime-go/actions/organization/get.operation.js.map +0 -0
  151. /package/{dist/nodes → nodes}/lime-go/actions/organization/getByExternalKey.operation.d.ts +0 -0
  152. /package/{dist/nodes → nodes}/lime-go/actions/organization/getByExternalKey.operation.js +0 -0
  153. /package/{dist/nodes → nodes}/lime-go/actions/organization/getByExternalKey.operation.js.map +0 -0
  154. /package/{dist/nodes → nodes}/lime-go/actions/organization/index.d.ts +0 -0
  155. /package/{dist/nodes → nodes}/lime-go/actions/organization/index.js +0 -0
  156. /package/{dist/nodes → nodes}/lime-go/actions/organization/index.js.map +0 -0
  157. /package/{dist/nodes → nodes}/lime-go/actions/organization/organizationFields.d.ts +0 -0
  158. /package/{dist/nodes → nodes}/lime-go/actions/organization/organizationFields.js +0 -0
  159. /package/{dist/nodes → nodes}/lime-go/actions/organization/organizationFields.js.map +0 -0
  160. /package/{dist/nodes → nodes}/lime-go/actions/organization/search.operation.d.ts +0 -0
  161. /package/{dist/nodes → nodes}/lime-go/actions/organization/search.operation.js +0 -0
  162. /package/{dist/nodes → nodes}/lime-go/actions/organization/search.operation.js.map +0 -0
  163. /package/{dist/nodes → nodes}/lime-go/actions/organization/update.operation.d.ts +0 -0
  164. /package/{dist/nodes → nodes}/lime-go/actions/organization/update.operation.js +0 -0
  165. /package/{dist/nodes → nodes}/lime-go/actions/organization/update.operation.js.map +0 -0
  166. /package/{dist/nodes → nodes}/lime-go/actions/person/createMail.operation.d.ts +0 -0
  167. /package/{dist/nodes → nodes}/lime-go/actions/person/createMail.operation.js +0 -0
  168. /package/{dist/nodes → nodes}/lime-go/actions/person/createMail.operation.js.map +0 -0
  169. /package/{dist/nodes → nodes}/lime-go/actions/person/get.operation.d.ts +0 -0
  170. /package/{dist/nodes → nodes}/lime-go/actions/person/get.operation.js +0 -0
  171. /package/{dist/nodes → nodes}/lime-go/actions/person/get.operation.js.map +0 -0
  172. /package/{dist/nodes → nodes}/lime-go/actions/person/index.d.ts +0 -0
  173. /package/{dist/nodes → nodes}/lime-go/actions/person/index.js +0 -0
  174. /package/{dist/nodes → nodes}/lime-go/actions/person/index.js.map +0 -0
  175. /package/{dist/nodes → nodes}/lime-go/actions/person/personFields.d.ts +0 -0
  176. /package/{dist/nodes → nodes}/lime-go/actions/person/personFields.js +0 -0
  177. /package/{dist/nodes → nodes}/lime-go/actions/person/personFields.js.map +0 -0
  178. /package/{dist/nodes → nodes}/lime-go/actions/person/search.operation.d.ts +0 -0
  179. /package/{dist/nodes → nodes}/lime-go/actions/person/search.operation.js +0 -0
  180. /package/{dist/nodes → nodes}/lime-go/actions/person/search.operation.js.map +0 -0
  181. /package/{dist/nodes → nodes}/lime-go/actions/person/update.operation.d.ts +0 -0
  182. /package/{dist/nodes → nodes}/lime-go/actions/person/update.operation.js +0 -0
  183. /package/{dist/nodes → nodes}/lime-go/actions/person/update.operation.js.map +0 -0
  184. /package/{dist/nodes → nodes}/lime-go/transport/graphqlRequest.d.ts +0 -0
  185. /package/{dist/nodes → nodes}/lime-go/transport/graphqlRequest.js +0 -0
  186. /package/{dist/nodes → nodes}/lime-go/transport/graphqlRequest.js.map +0 -0
  187. /package/{dist/nodes → nodes}/lime-go/transport/transport.d.ts +0 -0
  188. /package/{dist/nodes → nodes}/lime-go/transport/transport.js +0 -0
  189. /package/{dist/nodes → nodes}/lime-go/transport/transport.js.map +0 -0
  190. /package/{dist/nodes → nodes}/lime-go/triggers/webhook.d.ts +0 -0
  191. /package/{dist/nodes → nodes}/lime-go/triggers/webhook.js +0 -0
  192. /package/{dist/nodes → nodes}/lime-go/triggers/webhook.js.map +0 -0
@@ -1,505 +0,0 @@
1
- import {
2
- IHookFunctions,
3
- IWebhookFunctions,
4
- IDataObject,
5
- INodeType,
6
- INodeTypeDescription,
7
- IWebhookResponseData,
8
- NodeOperationError,
9
- ILoadOptionsFunctions,
10
- INodePropertyOptions,
11
- INodeExecutionData,
12
- NodeConnectionType,
13
- LoggerProxy as Logger
14
- } from 'n8n-workflow';
15
-
16
- import { IWebhookObject, IWebhookEventData } from './GenericTypes';
17
- import * as crypto from 'crypto';
18
-
19
- export class LimeCrmTrigger implements INodeType {
20
- description: INodeTypeDescription = {
21
- displayName: 'Lime CRM Trigger',
22
- name: 'limeCrmTrigger',
23
- icon: 'file:lime.svg',
24
- group: ['trigger'],
25
- version: 1,
26
- description: 'Handle Lime CRM webhook events',
27
- defaults: {
28
- name: 'Lime CRM Trigger',
29
- },
30
- inputs: [],
31
- outputs: [NodeConnectionType.Main],
32
- credentials: [
33
- {
34
- name: 'limeCrmApi',
35
- required: true,
36
- },
37
- ],
38
- webhooks: [
39
- {
40
- name: 'default',
41
- httpMethod: 'POST',
42
- responseMode: 'onReceived',
43
- path: 'webhook',
44
- },
45
- ],
46
- properties: [
47
- {
48
- displayName: 'Events',
49
- name: 'events',
50
- type: 'fixedCollection',
51
- typeOptions: {
52
- multipleValues: true,
53
- required: true,
54
- },
55
- default: {},
56
- placeholder: 'Add Event',
57
- description: 'Events to subscribe to',
58
- options: [
59
- {
60
- name: 'event',
61
- displayName: 'Event',
62
- values: [
63
- {
64
- displayName: 'Lime Type',
65
- name: 'limeType',
66
- type: 'options',
67
- typeOptions: {
68
- loadOptionsMethod: 'getLimeTypes',
69
- },
70
- default: '',
71
- description: 'Lime Type to subscribe to events for',
72
- },
73
- {
74
- displayName: 'Event Type',
75
- name: 'eventType',
76
- type: 'options',
77
- options: [
78
- {
79
- name: 'New',
80
- value: 'new',
81
- description: 'When a new record is created',
82
- },
83
- {
84
- name: 'Update',
85
- value: 'update',
86
- description: 'When a record is updated',
87
- },
88
- {
89
- name: 'Delete',
90
- value: 'delete',
91
- description: 'When a record is deleted',
92
- },
93
- ],
94
- default: 'new',
95
- description: 'Type of event to subscribe to',
96
- },
97
- ],
98
- },
99
- ],
100
- },
101
- {
102
- displayName: 'Name',
103
- name: 'name',
104
- type: 'string',
105
- default: '',
106
- placeholder: 'my-lime-webhook',
107
- required: true,
108
- description: 'Name for this webhook subscription',
109
- },
110
- {
111
- displayName: 'Options',
112
- name: 'options',
113
- type: 'collection',
114
- placeholder: 'Add Option',
115
- default: {},
116
- options: [
117
- {
118
- displayName: 'Include Headers',
119
- name: 'includeHeaders',
120
- type: 'fixedCollection',
121
- typeOptions: {
122
- multipleValues: true,
123
- },
124
- default: {},
125
- placeholder: 'Add Header',
126
- description: 'Headers to add to webhook requests',
127
- options: [
128
- {
129
- name: 'header',
130
- displayName: 'Header',
131
- values: [
132
- {
133
- displayName: 'Name',
134
- name: 'name',
135
- type: 'string',
136
- default: '',
137
- description: 'Name of the header',
138
- },
139
- {
140
- displayName: 'Value',
141
- name: 'value',
142
- type: 'string',
143
- default: '',
144
- description: 'Value of the header',
145
- },
146
- {
147
- displayName: 'Is Secret',
148
- name: 'isSecret',
149
- type: 'boolean',
150
- default: false,
151
- description: 'Whether this value is a secret',
152
- },
153
- ],
154
- },
155
- ],
156
- },
157
- {
158
- displayName: 'Secret',
159
- name: 'secret',
160
- type: 'string',
161
- typeOptions: {
162
- password: true,
163
- },
164
- default: '',
165
- description: 'Secret to verify the authenticity of received data',
166
- },
167
- ],
168
- },
169
- ],
170
- };
171
-
172
- methods = {
173
- loadOptions: {
174
- // Load available Lime types
175
- async getLimeTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
176
- const returnData: INodePropertyOptions[] = [];
177
-
178
- try {
179
- // Get credentials for the API
180
- const credentials = await this.getCredentials('limeCrmApi');
181
-
182
- if (!credentials) {
183
- throw new Error('No credentials provided');
184
- }
185
-
186
- const endpoint = '/api/v1/limetype/';
187
-
188
- // Make sure baseURL is properly configured
189
- const options = {
190
- method: 'GET' as 'GET',
191
- uri: endpoint,
192
- json: true,
193
- baseURL: credentials.url as string, // Add the base URL from credentials
194
- headers: {
195
- 'X-API-Key': credentials.apiKey as string,
196
- 'Accept': 'application/json',
197
- },
198
- };
199
-
200
- const response = await this.helpers.requestWithAuthentication.call(
201
- this,
202
- 'limeCrmApi',
203
- options,
204
- );
205
-
206
- if (response._links && response._links.limetypes) {
207
- // Parse response to extract lime types
208
- for (const limeType of response._links.limetypes) {
209
- if (limeType.name) {
210
- returnData.push({
211
- name: limeType.name,
212
- value: limeType.name,
213
- });
214
- }
215
- }
216
- }
217
-
218
- return returnData;
219
- } catch (error) {
220
- throw new NodeOperationError(this.getNode(), `Failed to load Lime Types: ${error}`);
221
- }
222
- },
223
- },
224
- };
225
-
226
- webhookMethods = {
227
- default: {
228
- async checkExists(this: IHookFunctions): Promise<boolean> {
229
- const nodeId = this.getNode().id;
230
- const workflowId = this.getWorkflow().id;
231
- const workflowName = this.getWorkflow().name;
232
- const webhookData = this.getWorkflowStaticData('node');
233
- const webhookUrl = this.getNodeWebhookUrl('default');
234
-
235
- // If we have a webhook ID stored, check if it still exists
236
- if (webhookData.webhookId) {
237
- try {
238
- // Get credentials for the API
239
- const credentials = await this.getCredentials('limeCrmApi');
240
- if (!credentials) {
241
- throw new Error('No credentials provided');
242
- }
243
-
244
- // Fetch the webhook to see if it exists
245
- const currentWebhook = await this.helpers.requestWithAuthentication.call(
246
- this,
247
- 'limeCrmApi',
248
- {
249
- method: 'GET',
250
- uri: `/api/v1/subscription/${webhookData.webhookId}/`,
251
- json: true,
252
- baseURL: credentials.url as string,
253
- headers: {
254
- 'X-API-Key': credentials.apiKey as string,
255
- 'Accept': 'application/json',
256
- },
257
- },
258
- );
259
-
260
- // Check if the webhook exists and has the right URL
261
- if (currentWebhook && currentWebhook.target_url === webhookUrl) {
262
- Logger.debug(`Webhook exists: ${webhookData.webhookId}`, { webhookId: webhookData.webhookId, nodeId, workflowId, workflowName });
263
- return true;
264
- }
265
- } catch (error) {
266
- // If we get an error, the webhook likely doesn't exist
267
- Logger.warn(`Webhook check failed: ${error}`, { webhookId: webhookData.webhookId, nodeId, workflowId, workflowName, error });
268
- delete webhookData.webhookId;
269
- return false;
270
- }
271
- }
272
-
273
- return false;
274
- },
275
-
276
- async create(this: IHookFunctions): Promise<boolean> {
277
- const nodeId = this.getNode().id;
278
- const workflowId = this.getWorkflow().id;
279
- const workflowName = this.getWorkflow().name;
280
- const webhookData = this.getWorkflowStaticData('node');
281
- const webhookUrl = this.getNodeWebhookUrl('default');
282
-
283
- if (!webhookUrl) {
284
- throw new NodeOperationError(this.getNode(), 'No webhook URL was returned by the system');
285
- }
286
-
287
- const name = this.getNodeParameter('name') as string;
288
- const eventsCollection = this.getNodeParameter('events.event', []) as Array<{ limeType: string, eventType: string }>;
289
- const options = this.getNodeParameter('options', {}) as IDataObject;
290
-
291
- // Get credentials for the API
292
- const credentials = await this.getCredentials('limeCrmApi');
293
- if (!credentials) {
294
- throw new Error('No credentials provided');
295
- }
296
-
297
- // Format events array for the Lime CRM API format
298
- const events: string[] = [];
299
- for (const eventItem of eventsCollection) {
300
- events.push(`${eventItem.limeType}.${eventItem.eventType}`);
301
- }
302
-
303
- // Sort events for consistent comparison
304
- events.sort();
305
-
306
- // Format headers if they exist
307
- const headersCollection = (options.includeHeaders as IDataObject || {}).header as Array<{ name: string; value: string; isSecret: boolean }> || [];
308
- const headers: Array<{ name: string; value: string; secret_value?: string; type: string }> = [];
309
-
310
- for (const header of headersCollection) {
311
- if (header.isSecret) {
312
- headers.push({
313
- name: header.name,
314
- value: '',
315
- secret_value: header.value,
316
- type: 'text',
317
- });
318
- } else {
319
- headers.push({
320
- name: header.name,
321
- value: header.value,
322
- type: 'text',
323
- });
324
- }
325
- }
326
-
327
- // Prepare request body
328
- const body: IWebhookObject = {
329
- name,
330
- events,
331
- target_url: webhookUrl,
332
- enabled: true,
333
- headers,
334
- };
335
-
336
- // If a secret is provided, add it
337
- const secret = options.secret as string;
338
- if (secret) {
339
- body.secret = secret;
340
- }
341
-
342
- try {
343
- // Create the webhook
344
- Logger.info('Creating new webhook subscription', { nodeId, workflowId, workflowName });
345
- const webhookResponse = await this.helpers.requestWithAuthentication.call(
346
- this,
347
- 'limeCrmApi',
348
- {
349
- method: 'POST',
350
- uri: '/api/v1/subscription/',
351
- body,
352
- json: true,
353
- baseURL: credentials.url as string,
354
- headers: {
355
- 'X-API-Key': credentials.apiKey as string,
356
- 'Accept': 'application/json',
357
- 'Content-Type': 'application/json',
358
- },
359
- },
360
- );
361
-
362
- // Store webhook ID in workflow data for later use
363
- if (webhookResponse.id) {
364
- webhookData.webhookId = webhookResponse.id;
365
- Logger.info(`Created webhook with ID: ${webhookResponse.id}`, { webhookId: webhookResponse.id, nodeId, workflowId, workflowName });
366
- return true;
367
- }
368
-
369
- throw new NodeOperationError(this.getNode(), 'Webhook creation failed: No ID was returned');
370
- } catch (error) {
371
- Logger.error(`Webhook creation failed: ${error}`, { nodeId, workflowId, workflowName, error });
372
- throw new NodeOperationError(this.getNode(), `Webhook creation failed: ${error}`);
373
- }
374
- },
375
-
376
- async delete(this: IHookFunctions): Promise<boolean> {
377
- const nodeId = this.getNode().id;
378
- const workflowId = this.getWorkflow().id;
379
- const workflowName = this.getWorkflow().name;
380
- const webhookData = this.getWorkflowStaticData('node');
381
- const webhookId = webhookData.webhookId as string | undefined;
382
-
383
- if (webhookId !== undefined) {
384
- try {
385
- Logger.info(`Deleting webhook with ID: ${webhookId}`, { webhookId, nodeId, workflowId, workflowName });
386
- // Get credentials for the API
387
- const credentials = await this.getCredentials('limeCrmApi');
388
- if (!credentials) {
389
- throw new Error('No credentials provided');
390
- }
391
-
392
- await this.helpers.requestWithAuthentication.call(
393
- this,
394
- 'limeCrmApi',
395
- {
396
- method: 'DELETE' as 'DELETE',
397
- uri: `/api/v1/subscription/${webhookId}/`,
398
- json: true,
399
- baseURL: credentials.url as string,
400
- headers: {
401
- 'X-API-Key': credentials.apiKey as string,
402
- 'Accept': 'application/json',
403
- },
404
- },
405
- );
406
-
407
- delete webhookData.webhookId;
408
- Logger.info('Webhook deleted successfully', { webhookId, nodeId, workflowId, workflowName });
409
- return true;
410
- } catch (error) {
411
- Logger.error(`Webhook deletion failed: ${error}`, { webhookId, nodeId, workflowId, workflowName, error });
412
- return false;
413
- }
414
- }
415
-
416
- return true;
417
- },
418
- },
419
- };
420
-
421
- async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
422
- const nodeId = this.getNode().id;
423
- const workflowId = this.getWorkflow().id;
424
- const workflowName = this.getWorkflow().name;
425
-
426
- Logger.info('Webhook received. Starting webhook processing...', { nodeId, workflowId, workflowName });
427
- try {
428
- const options = this.getNodeParameter('options', {}) as IDataObject;
429
- const secret = options.secret as string;
430
-
431
- const bodyData = this.getBodyData();
432
- const headerData = this.getHeaderData();
433
-
434
- // If a secret is set, verify the signature
435
- if (secret && headerData['x-lime-signature']) {
436
- Logger.debug('Verifying webhook signature...', { nodeId, workflowId, workflowName });
437
- const signature = headerData['x-lime-signature'] as string;
438
-
439
- const req = this.getRequestObject();
440
- const rawBody = req.rawBody || JSON.stringify(bodyData);
441
-
442
- // Create the expected signature
443
- const hmac = crypto.createHmac('sha256', secret);
444
- hmac.update(rawBody);
445
- const expectedSignature = hmac.digest('hex');
446
-
447
- // Compare signatures
448
- if (signature !== expectedSignature) {
449
- Logger.warn('Signature verification FAILED!', { nodeId, workflowId, workflowName });
450
- throw new NodeOperationError(this.getNode(), 'Invalid webhook signature');
451
- }
452
- Logger.debug('Signature verification successful', { nodeId, workflowId, workflowName });
453
- }
454
-
455
- // Cast bodyData to expected type after logging
456
- const typedBodyData = bodyData as unknown as IWebhookEventData;
457
-
458
- // Extract the relevant data
459
- if (!typedBodyData || !typedBodyData.event || !typedBodyData.body) {
460
- Logger.warn('Webhook data is invalid. Missing event or body', { nodeId, workflowId, workflowName });
461
- throw new NodeOperationError(this.getNode(), 'Webhook data is invalid');
462
- }
463
-
464
- // Process the event
465
- const eventParts = typedBodyData.event.split('.');
466
- if (eventParts.length !== 2) {
467
- Logger.warn(`Invalid event format: ${typedBodyData.event}`, { nodeId, workflowId, workflowName, event: typedBodyData.event });
468
- throw new NodeOperationError(this.getNode(), `Invalid event format: ${typedBodyData.event}`);
469
- }
470
-
471
- const limeType = eventParts[0];
472
- const eventType = eventParts[1];
473
- Logger.info(`Processing ${limeType}.${eventType} event for ID: ${typedBodyData.body.id}`, {
474
- limeType,
475
- eventType,
476
- recordId: typedBodyData.body.id,
477
- nodeId,
478
- workflowId,
479
- workflowName
480
- });
481
-
482
- // Create a standardized response as a single object instead of an array
483
- const data: INodeExecutionData[] = [
484
- {
485
- json: {
486
- limeType,
487
- eventType,
488
- id: typedBodyData.body.id,
489
- data: typedBodyData.body.values || {}, // Ensure values is an object, default to empty object if null
490
- rawEvent: typedBodyData,
491
- },
492
- },
493
- ];
494
-
495
- Logger.debug('Webhook processing complete', { nodeId, workflowId, workflowName });
496
-
497
- return {
498
- workflowData: [data],
499
- };
500
- } catch (error) {
501
- Logger.error('Error in webhook execution', { error, nodeId, workflowId, workflowName });
502
- throw error;
503
- }
504
- }
505
- }
@@ -1,73 +0,0 @@
1
- import { ILoadOptionsFunctions, IDataObject } from 'n8n-workflow';
2
- import { apiRequest } from '../transport';
3
-
4
- /**
5
- * Interface for sortable fields
6
- */
7
- interface SortableField {
8
- name: string;
9
- value: string;
10
- }
11
-
12
- /**
13
- * Get all sortable fields (properties from main type and related types)
14
- */
15
- export async function getAllSortableFields(this: ILoadOptionsFunctions): Promise<SortableField[]> {
16
- const limeType = this.getNodeParameter('limetype', '') as string;
17
- const includeRelations = this.getNodeParameter('includeRelations', false) as boolean;
18
-
19
- if (!limeType) return [];
20
-
21
- try {
22
- // Get main type properties
23
- const propertiesResponse = await apiRequest.call(this, {
24
- method: 'GET',
25
- endpoint: `/api/v1/limetype/${limeType}/property`,
26
- });
27
-
28
- let sortableFields: SortableField[] = [];
29
-
30
- if (propertiesResponse && Array.isArray(propertiesResponse)) {
31
- sortableFields = propertiesResponse.map((property: IDataObject) => ({
32
- name: property.name as string,
33
- value: property.name as string,
34
- }));
35
- }
36
-
37
- // If includeRelations is true, get related type properties
38
- if (includeRelations) {
39
- const relationsResponse = await apiRequest.call(this, {
40
- method: 'GET',
41
- endpoint: `/api/v1/limetype/${limeType}/relation`,
42
- });
43
-
44
- if (relationsResponse && Array.isArray(relationsResponse)) {
45
- for (const relation of relationsResponse) {
46
- const targetType = relation.targettype as string;
47
- const relationName = relation.name as string;
48
-
49
- const targetPropertiesResponse = await apiRequest.call(this, {
50
- method: 'GET',
51
- endpoint: `/api/v1/limetype/${targetType}/property`,
52
- });
53
-
54
- if (targetPropertiesResponse && Array.isArray(targetPropertiesResponse)) {
55
- sortableFields.push(
56
- ...targetPropertiesResponse.map((property: IDataObject) => ({
57
- name: `${relationName}.${property.name}`,
58
- value: `${relationName}.${property.name}`,
59
- }))
60
- );
61
- }
62
- }
63
- }
64
- }
65
-
66
- return sortableFields;
67
- } catch (error) {
68
- console.error(`Error loading sortable fields for ${limeType}:`, error);
69
- return [];
70
- }
71
- }
72
-
73
- export default getAllSortableFields;
@@ -1,48 +0,0 @@
1
- import { ILoadOptionsFunctions, IDataObject, INodePropertyOptions } from 'n8n-workflow';
2
- import { apiRequest } from '../transport';
3
-
4
- /**
5
- * Load properties for a selected Lime type
6
- */
7
- export async function getLimeTypeProperties(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
8
- const limeType = this.getNodeParameter('limeType', '') as string;
9
- console.log('Fetching properties for Lime type:', limeType); // Log the Lime type being fetched
10
- if (!limeType) return [];
11
-
12
- try {
13
- const response = await apiRequest.call(this, {
14
- method: 'GET',
15
- endpoint: `/api/v1/limetype/${limeType}/`,
16
- qs: {
17
- _embed: 'properties',
18
- },
19
- });
20
-
21
- // Define the system properties that should always be included
22
- const systemProperties: INodePropertyOptions[] = [
23
- { name: 'ID', value: 'id', description: 'Unique identifier (integer)' },
24
- { name: 'Updated (System)', value: 'timestamp', description: 'Last update timestamp (datetime)' },
25
- { name: 'Created (System)', value: 'createdtime', description: 'Creation timestamp (datetime)' },
26
- { name: 'Created By', value: 'createduser', description: 'User ID that created the record (integer)' },
27
- { name: 'Updated By', value: 'updateduser', description: 'User ID that last updated the record (integer)' },
28
- ];
29
-
30
- // Handle API response properties
31
- let apiProperties: INodePropertyOptions[] = [];
32
-
33
- // Check if response contains embedded properties
34
- apiProperties = response._embedded.properties.map((property: IDataObject) => ({
35
- name: (property.localname as string) || (property.name as string),
36
- value: property.name as string,
37
- description: `Type: ${property.type as string}${(property.required as boolean) ? ' (Required)' : ''} | DB: ${property.name as string}`,
38
- }));
39
-
40
- // Combine system properties with API properties
41
- return [...systemProperties, ...apiProperties];
42
- } catch (error) {
43
- console.error(`Error loading properties for ${limeType}:`, error);
44
- return [];
45
- }
46
- }
47
-
48
- export default getLimeTypeProperties;
@@ -1,32 +0,0 @@
1
- import { ILoadOptionsFunctions, IDataObject } from 'n8n-workflow';
2
- import { apiRequest } from '../transport';
3
-
4
- /**
5
- * Load relations for a selected Lime type
6
- */
7
- export async function getLimeTypeRelations(this: ILoadOptionsFunctions) {
8
- const limeType = this.getNodeParameter('limetype', '') as string;
9
- if (!limeType) return [];
10
-
11
- try {
12
- const response = await apiRequest.call(this, {
13
- method: 'GET',
14
- endpoint: `/api/v1/limetype/${limeType}/`,
15
- });
16
-
17
- if (!response || !Array.isArray(response)) {
18
- return [];
19
- }
20
-
21
- return response.map((relation: IDataObject) => ({
22
- name: relation.name as string,
23
- value: relation.name as string,
24
- description: `Target: ${relation.targettype}`,
25
- }));
26
- } catch (error) {
27
- console.error(`Error loading relations for ${limeType}:`, error);
28
- return [];
29
- }
30
- }
31
-
32
- export default getLimeTypeRelations;