@limetech/n8n-nodes-lime 0.2.0 → 0.2.2
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.
- package/dist/package.json +11 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -5
- package/.eslintrc.js +0 -58
- package/.github/copilot-instructions.md +0 -20
- package/.github/workflows/publish.yml +0 -34
- package/credentials/LimeCrmApi.credentials.ts +0 -57
- package/credentials/LimeGoApi.credentials.ts +0 -31
- package/docker-compose.yml +0 -44
- package/nodes/lime-crm/GenericTypes.ts +0 -114
- package/nodes/lime-crm/LimeCrm.node.json +0 -18
- package/nodes/lime-crm/LimeCrmNode.node.ts +0 -154
- package/nodes/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.ts +0 -461
- package/nodes/lime-crm/LimeCrmTrigger.node.ts +0 -505
- package/nodes/lime-crm/lime-crm.svg +0 -1
- package/nodes/lime-crm/methods/getAllSortableFields.ts +0 -73
- package/nodes/lime-crm/methods/getLimeTypeProperties.ts +0 -48
- package/nodes/lime-crm/methods/getLimeTypeRelations.ts +0 -32
- package/nodes/lime-crm/methods/getLimeTypes.ts +0 -33
- package/nodes/lime-crm/methods/getRelatedTypeProperties.ts +0 -47
- package/nodes/lime-crm/methods/index.ts +0 -5
- package/nodes/lime-crm/resources/limeObject/commonFields.ts +0 -179
- package/nodes/lime-crm/resources/limeObject/index.ts +0 -64
- package/nodes/lime-crm/resources/limeObject/operations/common.operation.ts +0 -35
- package/nodes/lime-crm/resources/limeObject/operations/create.operation.ts +0 -234
- package/nodes/lime-crm/resources/limeObject/operations/delete.operation.ts +0 -136
- package/nodes/lime-crm/resources/limeObject/operations/get.operation.ts +0 -124
- package/nodes/lime-crm/resources/limeObject/operations/getAll.operation.ts +0 -242
- package/nodes/lime-crm/resources/limeObject/operations/search.operation.ts +0 -242
- package/nodes/lime-crm/resources/limeObject/operations/update.operation.ts +0 -201
- package/nodes/lime-crm/resources/limeType/index.ts +0 -66
- package/nodes/lime-crm/resources/limeType/operations/getProperties.operation.ts +0 -105
- package/nodes/lime-crm/resources/limeType/operations/getRelations.operation.ts +0 -105
- package/nodes/lime-crm/resources/limeType/operations/getType.operation.ts +0 -58
- package/nodes/lime-crm/resources/limeType/operations/listTypes.operation.ts +0 -76
- package/nodes/lime-crm/resources/queryApi/index.ts +0 -42
- package/nodes/lime-crm/resources/queryApi/operations/executeQuery.operation.ts +0 -605
- package/nodes/lime-crm/transport/index.ts +0 -74
- package/nodes/lime-go/LimeGo.node.ts +0 -146
- package/nodes/lime-go/actions/organization/get.operation.ts +0 -42
- package/nodes/lime-go/actions/organization/getByExternalKey.operation.ts +0 -57
- package/nodes/lime-go/actions/organization/index.ts +0 -69
- package/nodes/lime-go/actions/organization/organizationFields.ts +0 -160
- package/nodes/lime-go/actions/organization/search.operation.ts +0 -73
- package/nodes/lime-go/actions/organization/update.operation.ts +0 -140
- package/nodes/lime-go/actions/person/createMail.operation.ts +0 -140
- package/nodes/lime-go/actions/person/get.operation.ts +0 -51
- package/nodes/lime-go/actions/person/index.ts +0 -69
- package/nodes/lime-go/actions/person/personFields.ts +0 -132
- package/nodes/lime-go/actions/person/search.operation.ts +0 -88
- package/nodes/lime-go/actions/person/update.operation.ts +0 -122
- package/nodes/lime-go/lime-go.svg +0 -1
- package/nodes/lime-go/transport/graphqlRequest.ts +0 -30
- package/tsconfig.json +0 -30
|
@@ -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
|
-
}
|