@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,461 +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
- import { getLimeTypes } from '../methods';
19
-
20
- export class LimeCrmTrigger implements INodeType {
21
- description: INodeTypeDescription = {
22
- displayName: 'Lime CRM Trigger',
23
- name: 'limeCrmTrigger',
24
- icon: 'file:lime.svg',
25
- group: ['trigger'],
26
- version: 1,
27
- description: 'Handle Lime CRM webhook events',
28
- defaults: {
29
- name: 'Lime CRM Trigger',
30
- },
31
- inputs: [],
32
- outputs: [NodeConnectionType.Main],
33
- credentials: [
34
- {
35
- name: 'limeCrmApi',
36
- required: true,
37
- },
38
- ],
39
- webhooks: [
40
- {
41
- name: 'default',
42
- httpMethod: 'POST',
43
- responseMode: 'onReceived',
44
- path: 'webhook',
45
- },
46
- ],
47
- properties: [
48
- {
49
- displayName: 'Events',
50
- name: 'events',
51
- type: 'fixedCollection',
52
- typeOptions: {
53
- multipleValues: true,
54
- required: true,
55
- },
56
- default: {},
57
- placeholder: 'Add Event',
58
- description: 'Events to subscribe to',
59
- options: [
60
- {
61
- name: 'event',
62
- displayName: 'Event',
63
- values: [
64
- {
65
- displayName: 'Lime Type',
66
- name: 'limeType',
67
- type: 'options',
68
- typeOptions: {
69
- loadOptionsMethod: 'getLimeTypes',
70
- },
71
- default: '',
72
- description: 'Lime Type to subscribe to events for',
73
- },
74
- {
75
- displayName: 'Event Type',
76
- name: 'eventType',
77
- type: 'options',
78
- options: [
79
- {
80
- name: 'New',
81
- value: 'new',
82
- description: 'When a new record is created',
83
- },
84
- {
85
- name: 'Update',
86
- value: 'update',
87
- description: 'When a record is updated',
88
- },
89
- {
90
- name: 'Delete',
91
- value: 'delete',
92
- description: 'When a record is deleted',
93
- },
94
- ],
95
- default: 'new',
96
- description: 'Type of event to subscribe to',
97
- },
98
- ],
99
- },
100
- ],
101
- },
102
- {
103
- displayName: 'Name',
104
- name: 'name',
105
- type: 'string',
106
- default: '',
107
- placeholder: 'my-lime-webhook',
108
- required: true,
109
- description: 'Name for this webhook subscription',
110
- },
111
- {
112
- displayName: 'Options',
113
- name: 'options',
114
- type: 'collection',
115
- placeholder: 'Add Option',
116
- default: {},
117
- options: [
118
- {
119
- displayName: 'Include Headers',
120
- name: 'includeHeaders',
121
- type: 'fixedCollection',
122
- typeOptions: {
123
- multipleValues: true,
124
- },
125
- default: {},
126
- placeholder: 'Add Header',
127
- description: 'Headers to add to webhook requests',
128
- options: [
129
- {
130
- name: 'header',
131
- displayName: 'Header',
132
- values: [
133
- {
134
- displayName: 'Name',
135
- name: 'name',
136
- type: 'string',
137
- default: '',
138
- description: 'Name of the header',
139
- },
140
- {
141
- displayName: 'Value',
142
- name: 'value',
143
- type: 'string',
144
- default: '',
145
- description: 'Value of the header',
146
- },
147
- {
148
- displayName: 'Is Secret',
149
- name: 'isSecret',
150
- type: 'boolean',
151
- default: false,
152
- description: 'Whether this value is a secret',
153
- },
154
- ],
155
- },
156
- ],
157
- },
158
- {
159
- displayName: 'Secret',
160
- name: 'secret',
161
- type: 'string',
162
- typeOptions: {
163
- password: true,
164
- },
165
- default: '',
166
- description: 'Secret to verify the authenticity of received data',
167
- },
168
- ],
169
- },
170
- ],
171
- };
172
-
173
- methods = {
174
- loadOptions: {
175
- // Load available Lime types
176
- async getLimeTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
177
- return getLimeTypes.call(this);
178
- },
179
- },
180
- };
181
-
182
- webhookMethods = {
183
- default: {
184
- async checkExists(this: IHookFunctions): Promise<boolean> {
185
- const nodeId = this.getNode().id;
186
- const workflowId = this.getWorkflow().id;
187
- const workflowName = this.getWorkflow().name;
188
- const webhookData = this.getWorkflowStaticData('node');
189
- const webhookUrl = this.getNodeWebhookUrl('default');
190
-
191
- // If we have a webhook ID stored, check if it still exists
192
- if (webhookData.webhookId) {
193
- try {
194
- // Get credentials for the API
195
- const credentials = await this.getCredentials('limeCrmApi');
196
- if (!credentials) {
197
- throw new Error('No credentials provided');
198
- }
199
-
200
- // Fetch the webhook to see if it exists
201
- const currentWebhook = await this.helpers.requestWithAuthentication.call(
202
- this,
203
- 'limeCrmApi',
204
- {
205
- method: 'GET',
206
- uri: `/api/v1/subscription/${webhookData.webhookId}/`,
207
- json: true,
208
- baseURL: credentials.url as string,
209
- headers: {
210
- 'X-API-Key': credentials.apiKey as string,
211
- 'Accept': 'application/json',
212
- },
213
- },
214
- );
215
-
216
- // Check if the webhook exists and has the right URL
217
- if (currentWebhook && currentWebhook.target_url === webhookUrl) {
218
- Logger.debug(`Webhook exists: ${webhookData.webhookId}`, { webhookId: webhookData.webhookId, nodeId, workflowId, workflowName });
219
- return true;
220
- }
221
- } catch (error) {
222
- // If we get an error, the webhook likely doesn't exist
223
- Logger.warn(`Webhook check failed: ${error}`, { webhookId: webhookData.webhookId, nodeId, workflowId, workflowName, error });
224
- delete webhookData.webhookId;
225
- return false;
226
- }
227
- }
228
-
229
- return false;
230
- },
231
-
232
- async create(this: IHookFunctions): Promise<boolean> {
233
- const nodeId = this.getNode().id;
234
- const workflowId = this.getWorkflow().id;
235
- const workflowName = this.getWorkflow().name;
236
- const webhookData = this.getWorkflowStaticData('node');
237
- const webhookUrl = this.getNodeWebhookUrl('default');
238
-
239
- if (!webhookUrl) {
240
- throw new NodeOperationError(this.getNode(), 'No webhook URL was returned by the system');
241
- }
242
-
243
- const name = this.getNodeParameter('name') as string;
244
- const eventsCollection = this.getNodeParameter('events.event', []) as Array<{ limeType: string, eventType: string }>;
245
- const options = this.getNodeParameter('options', {}) as IDataObject;
246
-
247
- // Get credentials for the API
248
- const credentials = await this.getCredentials('limeCrmApi');
249
- if (!credentials) {
250
- throw new Error('No credentials provided');
251
- }
252
-
253
- // Format events array for the Lime CRM API format
254
- const events: string[] = [];
255
- for (const eventItem of eventsCollection) {
256
- events.push(`${eventItem.limeType}.${eventItem.eventType}`);
257
- }
258
-
259
- // Sort events for consistent comparison
260
- events.sort();
261
-
262
- // Format headers if they exist
263
- const headersCollection = (options.includeHeaders as IDataObject || {}).header as Array<{ name: string; value: string; isSecret: boolean }> || [];
264
- const headers: Array<{ name: string; value: string; secret_value?: string; type: string }> = [];
265
-
266
- for (const header of headersCollection) {
267
- if (header.isSecret) {
268
- headers.push({
269
- name: header.name,
270
- value: '',
271
- secret_value: header.value,
272
- type: 'text',
273
- });
274
- } else {
275
- headers.push({
276
- name: header.name,
277
- value: header.value,
278
- type: 'text',
279
- });
280
- }
281
- }
282
-
283
- // Prepare request body
284
- const body: IWebhookObject = {
285
- name,
286
- events,
287
- target_url: webhookUrl,
288
- enabled: true,
289
- headers,
290
- };
291
-
292
- // If a secret is provided, add it
293
- const secret = options.secret as string;
294
- if (secret) {
295
- body.secret = secret;
296
- }
297
-
298
- try {
299
- // Create the webhook
300
- Logger.info('Creating new webhook subscription', { nodeId, workflowId, workflowName });
301
- const webhookResponse = await this.helpers.requestWithAuthentication.call(
302
- this,
303
- 'limeCrmApi',
304
- {
305
- method: 'POST',
306
- uri: '/api/v1/subscription/',
307
- body,
308
- json: true,
309
- baseURL: credentials.url as string,
310
- headers: {
311
- 'X-API-Key': credentials.apiKey as string,
312
- 'Accept': 'application/json',
313
- 'Content-Type': 'application/json',
314
- },
315
- },
316
- );
317
-
318
- // Store webhook ID in workflow data for later use
319
- if (webhookResponse.id) {
320
- webhookData.webhookId = webhookResponse.id;
321
- Logger.info(`Created webhook with ID: ${webhookResponse.id}`, { webhookId: webhookResponse.id, nodeId, workflowId, workflowName });
322
- return true;
323
- }
324
-
325
- throw new NodeOperationError(this.getNode(), 'Webhook creation failed: No ID was returned');
326
- } catch (error) {
327
- Logger.error(`Webhook creation failed: ${error}`, { nodeId, workflowId, workflowName, error });
328
- throw new NodeOperationError(this.getNode(), `Webhook creation failed: ${error}`);
329
- }
330
- },
331
-
332
- async delete(this: IHookFunctions): Promise<boolean> {
333
- const nodeId = this.getNode().id;
334
- const workflowId = this.getWorkflow().id;
335
- const workflowName = this.getWorkflow().name;
336
- const webhookData = this.getWorkflowStaticData('node');
337
- const webhookId = webhookData.webhookId as string | undefined;
338
-
339
- if (webhookId !== undefined) {
340
- try {
341
- Logger.info(`Deleting webhook with ID: ${webhookId}`, { webhookId, nodeId, workflowId, workflowName });
342
- // Get credentials for the API
343
- const credentials = await this.getCredentials('limeCrmApi');
344
- if (!credentials) {
345
- throw new Error('No credentials provided');
346
- }
347
-
348
- await this.helpers.requestWithAuthentication.call(
349
- this,
350
- 'limeCrmApi',
351
- {
352
- method: 'DELETE' as 'DELETE',
353
- uri: `/api/v1/subscription/${webhookId}/`,
354
- json: true,
355
- baseURL: credentials.url as string,
356
- headers: {
357
- 'X-API-Key': credentials.apiKey as string,
358
- 'Accept': 'application/json',
359
- },
360
- },
361
- );
362
-
363
- delete webhookData.webhookId;
364
- Logger.info('Webhook deleted successfully', { webhookId, nodeId, workflowId, workflowName });
365
- return true;
366
- } catch (error) {
367
- Logger.error(`Webhook deletion failed: ${error}`, { webhookId, nodeId, workflowId, workflowName, error });
368
- return false;
369
- }
370
- }
371
-
372
- return true;
373
- },
374
- },
375
- };
376
-
377
- async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
378
- const nodeId = this.getNode().id;
379
- const workflowId = this.getWorkflow().id;
380
- const workflowName = this.getWorkflow().name;
381
-
382
- Logger.info('Webhook received. Starting webhook processing...', { nodeId, workflowId, workflowName });
383
- try {
384
- const options = this.getNodeParameter('options', {}) as IDataObject;
385
- const secret = options.secret as string;
386
-
387
- const bodyData = this.getBodyData();
388
- const headerData = this.getHeaderData();
389
-
390
- // If a secret is set, verify the signature
391
- if (secret && headerData['x-lime-signature']) {
392
- Logger.debug('Verifying webhook signature...', { nodeId, workflowId, workflowName });
393
- const signature = headerData['x-lime-signature'] as string;
394
-
395
- const req = this.getRequestObject();
396
- const rawBody = req.rawBody || JSON.stringify(bodyData);
397
-
398
- // Create the expected signature
399
- const hmac = crypto.createHmac('sha256', secret);
400
- hmac.update(rawBody);
401
- const expectedSignature = hmac.digest('hex');
402
-
403
- // Compare signatures
404
- if (signature !== expectedSignature) {
405
- Logger.warn('Signature verification FAILED!', { nodeId, workflowId, workflowName });
406
- throw new NodeOperationError(this.getNode(), 'Invalid webhook signature');
407
- }
408
- Logger.debug('Signature verification successful', { nodeId, workflowId, workflowName });
409
- }
410
-
411
- // Cast bodyData to expected type after logging
412
- const typedBodyData = bodyData as unknown as IWebhookEventData;
413
-
414
- // Extract the relevant data
415
- if (!typedBodyData || !typedBodyData.event || !typedBodyData.body) {
416
- Logger.warn('Webhook data is invalid. Missing event or body', { nodeId, workflowId, workflowName });
417
- throw new NodeOperationError(this.getNode(), 'Webhook data is invalid');
418
- }
419
-
420
- // Process the event
421
- const eventParts = typedBodyData.event.split('.');
422
- if (eventParts.length !== 2) {
423
- Logger.warn(`Invalid event format: ${typedBodyData.event}`, { nodeId, workflowId, workflowName, event: typedBodyData.event });
424
- throw new NodeOperationError(this.getNode(), `Invalid event format: ${typedBodyData.event}`);
425
- }
426
-
427
- const limeType = eventParts[0];
428
- const eventType = eventParts[1];
429
- Logger.info(`Processing ${limeType}.${eventType} event for ID: ${typedBodyData.body.id}`, {
430
- limeType,
431
- eventType,
432
- recordId: typedBodyData.body.id,
433
- nodeId,
434
- workflowId,
435
- workflowName
436
- });
437
-
438
- // Create a standardized response as a single object instead of an array
439
- const data: INodeExecutionData[] = [
440
- {
441
- json: {
442
- limeType,
443
- eventType,
444
- id: typedBodyData.body.id,
445
- data: typedBodyData.body.values || {}, // Ensure values is an object, default to empty object if null
446
- rawEvent: typedBodyData,
447
- },
448
- },
449
- ];
450
-
451
- Logger.debug('Webhook processing complete', { nodeId, workflowId, workflowName });
452
-
453
- return {
454
- workflowData: [data],
455
- };
456
- } catch (error) {
457
- Logger.error('Error in webhook execution', { error, nodeId, workflowId, workflowName });
458
- throw error;
459
- }
460
- }
461
- }