@workbuddy/n8n-nodes-workbuddy-edge 1.0.0 → 1.0.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/nodes/WorkBuddy/WorkBuddy.node.js +4 -4
- package/dist/nodes/WorkBuddy/WorkBuddy.node.js.map +1 -1
- package/dist/nodes/WorkBuddy/WorkBuddyTrigger.node.d.ts +13 -0
- package/dist/nodes/WorkBuddy/WorkBuddyTrigger.node.d.ts.map +1 -0
- package/dist/nodes/WorkBuddy/WorkBuddyTrigger.node.js +931 -0
- package/dist/nodes/WorkBuddy/WorkBuddyTrigger.node.js.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,931 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkBuddyTrigger = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
// Entity category for each event (used for filter assembly)
|
|
6
|
+
const eventCategoryMap = {
|
|
7
|
+
'Job Created': 'job',
|
|
8
|
+
'Job Updated': 'job',
|
|
9
|
+
'Job Status Changed': 'job',
|
|
10
|
+
'Job Deleted': 'job',
|
|
11
|
+
'Stage Created': 'stage',
|
|
12
|
+
'Stage Updated': 'stage',
|
|
13
|
+
'Stage Status Changed': 'stage',
|
|
14
|
+
'Stage Deleted': 'stage',
|
|
15
|
+
'Activity Created': 'activity',
|
|
16
|
+
'Activity Updated': 'activity',
|
|
17
|
+
'Activity Deleted': 'activity',
|
|
18
|
+
'Invoice Created': 'invoice',
|
|
19
|
+
'Invoice Updated': 'invoice',
|
|
20
|
+
'Invoice Status Changed': 'invoice',
|
|
21
|
+
'Invoice Deleted': 'invoice',
|
|
22
|
+
'Bill Created': 'bill',
|
|
23
|
+
'Bill Updated': 'bill',
|
|
24
|
+
'Bill Status Changed': 'bill',
|
|
25
|
+
'Bill Deleted': 'bill',
|
|
26
|
+
'Quote Created': 'quote',
|
|
27
|
+
'Quote Updated': 'quote',
|
|
28
|
+
'Quote Status Changed': 'quote',
|
|
29
|
+
'Quote Deleted': 'quote',
|
|
30
|
+
'Opportunity Created': 'opportunity',
|
|
31
|
+
'Opportunity Updated': 'opportunity',
|
|
32
|
+
'Opportunity Status Changed': 'opportunity',
|
|
33
|
+
'Opportunity Deleted': 'opportunity',
|
|
34
|
+
'Lead Created': 'lead',
|
|
35
|
+
'Lead Updated': 'lead',
|
|
36
|
+
'Lead Status Changed': 'lead',
|
|
37
|
+
'Lead Deleted': 'lead',
|
|
38
|
+
'Task Created': 'task',
|
|
39
|
+
'Task Updated': 'task',
|
|
40
|
+
'Task Status Changed': 'task',
|
|
41
|
+
'Task Deleted': 'task',
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Get an OAuth2 access token using client credentials.
|
|
45
|
+
*/
|
|
46
|
+
async function getAccessToken(context) {
|
|
47
|
+
const credentials = await context.getCredentials('workBuddyApi');
|
|
48
|
+
const baseUrl = credentials.baseUrl;
|
|
49
|
+
const clientId = credentials.clientId;
|
|
50
|
+
const clientSecret = credentials.clientSecret;
|
|
51
|
+
const response = await context.helpers.httpRequest({
|
|
52
|
+
method: 'POST',
|
|
53
|
+
url: `${baseUrl}/api/oauth2/token`,
|
|
54
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
55
|
+
body: `grant_type=client_credentials&client_id=${encodeURIComponent(clientId)}&client_secret=${encodeURIComponent(clientSecret)}&scope=webhooks:manage`,
|
|
56
|
+
});
|
|
57
|
+
return response.access_token;
|
|
58
|
+
}
|
|
59
|
+
class WorkBuddyTrigger {
|
|
60
|
+
description = {
|
|
61
|
+
displayName: 'WorkBuddy Trigger',
|
|
62
|
+
name: 'workBuddyTrigger',
|
|
63
|
+
icon: 'file:workbuddy.svg',
|
|
64
|
+
group: ['trigger'],
|
|
65
|
+
version: 1,
|
|
66
|
+
subtitle: '={{$parameter["event"]}}',
|
|
67
|
+
description: 'Triggers when a WorkBuddy event occurs',
|
|
68
|
+
defaults: {
|
|
69
|
+
name: 'WorkBuddy Trigger',
|
|
70
|
+
},
|
|
71
|
+
inputs: [],
|
|
72
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
73
|
+
credentials: [
|
|
74
|
+
{
|
|
75
|
+
name: 'workBuddyApi',
|
|
76
|
+
required: true,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
webhooks: [
|
|
80
|
+
{
|
|
81
|
+
name: 'default',
|
|
82
|
+
httpMethod: 'POST',
|
|
83
|
+
responseMode: 'onReceived',
|
|
84
|
+
path: 'webhook',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
properties: [
|
|
88
|
+
{
|
|
89
|
+
displayName: 'Event',
|
|
90
|
+
name: 'event',
|
|
91
|
+
type: 'options',
|
|
92
|
+
noDataExpression: true,
|
|
93
|
+
required: true,
|
|
94
|
+
default: 'Job Created',
|
|
95
|
+
options: [
|
|
96
|
+
{
|
|
97
|
+
name: 'Job Created',
|
|
98
|
+
value: 'Job Created',
|
|
99
|
+
description: 'Triggered when a new job is created',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'Job Updated',
|
|
103
|
+
value: 'Job Updated',
|
|
104
|
+
description: 'Triggered when a job is updated',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'Job Status Changed',
|
|
108
|
+
value: 'Job Status Changed',
|
|
109
|
+
description: 'Triggered when a job status changes',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: 'Job Deleted',
|
|
113
|
+
value: 'Job Deleted',
|
|
114
|
+
description: 'Triggered when a job is deleted',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'Stage Created',
|
|
118
|
+
value: 'Stage Created',
|
|
119
|
+
description: 'Triggered when a new stage is created',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'Stage Updated',
|
|
123
|
+
value: 'Stage Updated',
|
|
124
|
+
description: 'Triggered when a stage is updated',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'Stage Status Changed',
|
|
128
|
+
value: 'Stage Status Changed',
|
|
129
|
+
description: 'Triggered when a stage status changes',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: 'Stage Deleted',
|
|
133
|
+
value: 'Stage Deleted',
|
|
134
|
+
description: 'Triggered when a stage is deleted',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'Activity Created',
|
|
138
|
+
value: 'Activity Created',
|
|
139
|
+
description: 'Triggered when a new activity is created',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'Activity Updated',
|
|
143
|
+
value: 'Activity Updated',
|
|
144
|
+
description: 'Triggered when an activity is updated',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'Activity Deleted',
|
|
148
|
+
value: 'Activity Deleted',
|
|
149
|
+
description: 'Triggered when an activity is deleted',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'Invoice Created',
|
|
153
|
+
value: 'Invoice Created',
|
|
154
|
+
description: 'Triggered when a new invoice is created',
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: 'Invoice Updated',
|
|
158
|
+
value: 'Invoice Updated',
|
|
159
|
+
description: 'Triggered when an invoice is updated',
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: 'Invoice Status Changed',
|
|
163
|
+
value: 'Invoice Status Changed',
|
|
164
|
+
description: 'Triggered when an invoice status changes',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: 'Invoice Deleted',
|
|
168
|
+
value: 'Invoice Deleted',
|
|
169
|
+
description: 'Triggered when an invoice is deleted',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: 'Bill Created',
|
|
173
|
+
value: 'Bill Created',
|
|
174
|
+
description: 'Triggered when a new bill is created',
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: 'Bill Updated',
|
|
178
|
+
value: 'Bill Updated',
|
|
179
|
+
description: 'Triggered when a bill is updated',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: 'Bill Status Changed',
|
|
183
|
+
value: 'Bill Status Changed',
|
|
184
|
+
description: 'Triggered when a bill status changes',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: 'Bill Deleted',
|
|
188
|
+
value: 'Bill Deleted',
|
|
189
|
+
description: 'Triggered when a bill is deleted',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'Quote Created',
|
|
193
|
+
value: 'Quote Created',
|
|
194
|
+
description: 'Triggered when a new quote is created',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: 'Quote Updated',
|
|
198
|
+
value: 'Quote Updated',
|
|
199
|
+
description: 'Triggered when a quote is updated',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: 'Quote Status Changed',
|
|
203
|
+
value: 'Quote Status Changed',
|
|
204
|
+
description: 'Triggered when a quote status changes',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: 'Quote Deleted',
|
|
208
|
+
value: 'Quote Deleted',
|
|
209
|
+
description: 'Triggered when a quote is deleted',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: 'Opportunity Created',
|
|
213
|
+
value: 'Opportunity Created',
|
|
214
|
+
description: 'Triggered when a new opportunity is created',
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: 'Opportunity Updated',
|
|
218
|
+
value: 'Opportunity Updated',
|
|
219
|
+
description: 'Triggered when an opportunity is updated',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: 'Opportunity Status Changed',
|
|
223
|
+
value: 'Opportunity Status Changed',
|
|
224
|
+
description: 'Triggered when an opportunity status changes',
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: 'Opportunity Deleted',
|
|
228
|
+
value: 'Opportunity Deleted',
|
|
229
|
+
description: 'Triggered when an opportunity is deleted',
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: 'Lead Created',
|
|
233
|
+
value: 'Lead Created',
|
|
234
|
+
description: 'Triggered when a new lead is created',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: 'Lead Updated',
|
|
238
|
+
value: 'Lead Updated',
|
|
239
|
+
description: 'Triggered when a lead is updated',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: 'Lead Status Changed',
|
|
243
|
+
value: 'Lead Status Changed',
|
|
244
|
+
description: 'Triggered when a lead status changes',
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: 'Lead Deleted',
|
|
248
|
+
value: 'Lead Deleted',
|
|
249
|
+
description: 'Triggered when a lead is deleted',
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: 'Task Created',
|
|
253
|
+
value: 'Task Created',
|
|
254
|
+
description: 'Triggered when a new task is created',
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: 'Task Updated',
|
|
258
|
+
value: 'Task Updated',
|
|
259
|
+
description: 'Triggered when a task is updated',
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: 'Task Status Changed',
|
|
263
|
+
value: 'Task Status Changed',
|
|
264
|
+
description: 'Triggered when a task status changes',
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: 'Task Deleted',
|
|
268
|
+
value: 'Task Deleted',
|
|
269
|
+
description: 'Triggered when a task is deleted',
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
description: 'The event to listen for',
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
displayName: 'Filter by Customer',
|
|
276
|
+
name: 'customer',
|
|
277
|
+
type: 'string',
|
|
278
|
+
default: '',
|
|
279
|
+
typeOptions: { multipleValues: true },
|
|
280
|
+
required: false,
|
|
281
|
+
description: 'Only trigger for specific customer IDs',
|
|
282
|
+
displayOptions: {
|
|
283
|
+
show: {
|
|
284
|
+
event: [
|
|
285
|
+
'Job Created',
|
|
286
|
+
'Job Updated',
|
|
287
|
+
'Job Status Changed',
|
|
288
|
+
'Job Deleted',
|
|
289
|
+
'Stage Created',
|
|
290
|
+
'Stage Updated',
|
|
291
|
+
'Stage Status Changed',
|
|
292
|
+
'Stage Deleted',
|
|
293
|
+
'Invoice Created',
|
|
294
|
+
'Invoice Updated',
|
|
295
|
+
'Invoice Status Changed',
|
|
296
|
+
'Invoice Deleted',
|
|
297
|
+
'Bill Created',
|
|
298
|
+
'Bill Updated',
|
|
299
|
+
'Bill Status Changed',
|
|
300
|
+
'Bill Deleted',
|
|
301
|
+
'Quote Created',
|
|
302
|
+
'Quote Updated',
|
|
303
|
+
'Quote Status Changed',
|
|
304
|
+
'Quote Deleted',
|
|
305
|
+
'Opportunity Created',
|
|
306
|
+
'Opportunity Updated',
|
|
307
|
+
'Opportunity Status Changed',
|
|
308
|
+
'Opportunity Deleted',
|
|
309
|
+
'Lead Created',
|
|
310
|
+
'Lead Updated',
|
|
311
|
+
'Lead Status Changed',
|
|
312
|
+
'Lead Deleted',
|
|
313
|
+
],
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
displayName: 'Filter by Billing Company',
|
|
319
|
+
name: 'billingCompany',
|
|
320
|
+
type: 'string',
|
|
321
|
+
default: '',
|
|
322
|
+
typeOptions: { multipleValues: true },
|
|
323
|
+
required: false,
|
|
324
|
+
description: 'Only trigger for specific billing company IDs',
|
|
325
|
+
displayOptions: {
|
|
326
|
+
show: {
|
|
327
|
+
event: [
|
|
328
|
+
'Job Created',
|
|
329
|
+
'Job Updated',
|
|
330
|
+
'Job Status Changed',
|
|
331
|
+
'Job Deleted',
|
|
332
|
+
'Stage Created',
|
|
333
|
+
'Stage Updated',
|
|
334
|
+
'Stage Status Changed',
|
|
335
|
+
'Stage Deleted',
|
|
336
|
+
'Invoice Created',
|
|
337
|
+
'Invoice Updated',
|
|
338
|
+
'Invoice Status Changed',
|
|
339
|
+
'Invoice Deleted',
|
|
340
|
+
'Bill Created',
|
|
341
|
+
'Bill Updated',
|
|
342
|
+
'Bill Status Changed',
|
|
343
|
+
'Bill Deleted',
|
|
344
|
+
'Quote Created',
|
|
345
|
+
'Quote Updated',
|
|
346
|
+
'Quote Status Changed',
|
|
347
|
+
'Quote Deleted',
|
|
348
|
+
'Opportunity Created',
|
|
349
|
+
'Opportunity Updated',
|
|
350
|
+
'Opportunity Status Changed',
|
|
351
|
+
'Opportunity Deleted',
|
|
352
|
+
'Lead Created',
|
|
353
|
+
'Lead Updated',
|
|
354
|
+
'Lead Status Changed',
|
|
355
|
+
'Lead Deleted',
|
|
356
|
+
],
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
displayName: 'Filter by Tags',
|
|
362
|
+
name: 'tag',
|
|
363
|
+
type: 'string',
|
|
364
|
+
default: '',
|
|
365
|
+
typeOptions: { multipleValues: true },
|
|
366
|
+
required: false,
|
|
367
|
+
description: 'Only trigger for specific tags IDs',
|
|
368
|
+
displayOptions: {
|
|
369
|
+
show: {
|
|
370
|
+
event: [
|
|
371
|
+
'Job Created',
|
|
372
|
+
'Job Updated',
|
|
373
|
+
'Job Status Changed',
|
|
374
|
+
'Job Deleted',
|
|
375
|
+
'Stage Created',
|
|
376
|
+
'Stage Updated',
|
|
377
|
+
'Stage Status Changed',
|
|
378
|
+
'Stage Deleted',
|
|
379
|
+
'Invoice Created',
|
|
380
|
+
'Invoice Updated',
|
|
381
|
+
'Invoice Status Changed',
|
|
382
|
+
'Invoice Deleted',
|
|
383
|
+
'Bill Created',
|
|
384
|
+
'Bill Updated',
|
|
385
|
+
'Bill Status Changed',
|
|
386
|
+
'Bill Deleted',
|
|
387
|
+
'Quote Created',
|
|
388
|
+
'Quote Updated',
|
|
389
|
+
'Quote Status Changed',
|
|
390
|
+
'Quote Deleted',
|
|
391
|
+
'Opportunity Created',
|
|
392
|
+
'Opportunity Updated',
|
|
393
|
+
'Opportunity Status Changed',
|
|
394
|
+
'Opportunity Deleted',
|
|
395
|
+
'Lead Created',
|
|
396
|
+
'Lead Updated',
|
|
397
|
+
'Lead Status Changed',
|
|
398
|
+
'Lead Deleted',
|
|
399
|
+
'Task Created',
|
|
400
|
+
'Task Updated',
|
|
401
|
+
'Task Status Changed',
|
|
402
|
+
'Task Deleted',
|
|
403
|
+
],
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
displayName: 'Filter by Site',
|
|
409
|
+
name: 'site',
|
|
410
|
+
type: 'string',
|
|
411
|
+
default: '',
|
|
412
|
+
typeOptions: { multipleValues: true },
|
|
413
|
+
required: false,
|
|
414
|
+
description: 'Only trigger for specific site IDs',
|
|
415
|
+
displayOptions: {
|
|
416
|
+
show: {
|
|
417
|
+
event: ['Job Created', 'Job Updated', 'Job Status Changed', 'Job Deleted'],
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
displayName: 'Filter by Job Type',
|
|
423
|
+
name: 'type',
|
|
424
|
+
type: 'string',
|
|
425
|
+
default: '',
|
|
426
|
+
typeOptions: { multipleValues: true },
|
|
427
|
+
required: false,
|
|
428
|
+
description: 'Only trigger for specific job type IDs',
|
|
429
|
+
displayOptions: {
|
|
430
|
+
show: {
|
|
431
|
+
event: [
|
|
432
|
+
'Job Created',
|
|
433
|
+
'Job Updated',
|
|
434
|
+
'Job Status Changed',
|
|
435
|
+
'Job Deleted',
|
|
436
|
+
'Lead Created',
|
|
437
|
+
'Lead Updated',
|
|
438
|
+
'Lead Status Changed',
|
|
439
|
+
'Lead Deleted',
|
|
440
|
+
],
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
displayName: 'Filter by Priority',
|
|
446
|
+
name: 'priority',
|
|
447
|
+
type: 'string',
|
|
448
|
+
default: '',
|
|
449
|
+
typeOptions: { multipleValues: true },
|
|
450
|
+
required: false,
|
|
451
|
+
description: 'Only trigger for specific priority IDs',
|
|
452
|
+
displayOptions: {
|
|
453
|
+
show: {
|
|
454
|
+
event: ['Job Created', 'Job Updated', 'Job Status Changed', 'Job Deleted'],
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
displayName: 'Filter by Owner',
|
|
460
|
+
name: 'owner',
|
|
461
|
+
type: 'string',
|
|
462
|
+
default: '',
|
|
463
|
+
typeOptions: { multipleValues: true },
|
|
464
|
+
required: false,
|
|
465
|
+
description: 'Only trigger for specific owner IDs',
|
|
466
|
+
displayOptions: {
|
|
467
|
+
show: {
|
|
468
|
+
event: [
|
|
469
|
+
'Job Created',
|
|
470
|
+
'Job Updated',
|
|
471
|
+
'Job Status Changed',
|
|
472
|
+
'Job Deleted',
|
|
473
|
+
'Opportunity Created',
|
|
474
|
+
'Opportunity Updated',
|
|
475
|
+
'Opportunity Status Changed',
|
|
476
|
+
'Opportunity Deleted',
|
|
477
|
+
'Lead Created',
|
|
478
|
+
'Lead Updated',
|
|
479
|
+
'Lead Status Changed',
|
|
480
|
+
'Lead Deleted',
|
|
481
|
+
],
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
displayName: 'Filter by Zone',
|
|
487
|
+
name: 'zone',
|
|
488
|
+
type: 'string',
|
|
489
|
+
default: '',
|
|
490
|
+
typeOptions: { multipleValues: true },
|
|
491
|
+
required: false,
|
|
492
|
+
description: 'Only trigger for specific zone IDs',
|
|
493
|
+
displayOptions: {
|
|
494
|
+
show: {
|
|
495
|
+
event: ['Job Created', 'Job Updated', 'Job Status Changed', 'Job Deleted'],
|
|
496
|
+
},
|
|
497
|
+
},
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
displayName: 'Filter by Status',
|
|
501
|
+
name: 'status',
|
|
502
|
+
type: 'multiOptions',
|
|
503
|
+
default: [],
|
|
504
|
+
options: [
|
|
505
|
+
{ name: 'Open', value: JSON.stringify({ match: 'systemStatus', value: 'Open' }) },
|
|
506
|
+
{ name: 'InProgress', value: JSON.stringify({ match: 'systemStatus', value: 'InProgress' }) },
|
|
507
|
+
{ name: 'Completed', value: JSON.stringify({ match: 'systemStatus', value: 'Completed' }) },
|
|
508
|
+
{ name: 'Closed', value: JSON.stringify({ match: 'systemStatus', value: 'Closed' }) },
|
|
509
|
+
{ name: 'Cancelled', value: JSON.stringify({ match: 'systemStatus', value: 'Cancelled' }) },
|
|
510
|
+
],
|
|
511
|
+
required: false,
|
|
512
|
+
description: 'Only trigger when the status matches one of these values',
|
|
513
|
+
displayOptions: {
|
|
514
|
+
show: {
|
|
515
|
+
event: [
|
|
516
|
+
'Job Created',
|
|
517
|
+
'Job Updated',
|
|
518
|
+
'Job Status Changed',
|
|
519
|
+
'Job Deleted',
|
|
520
|
+
'Invoice Created',
|
|
521
|
+
'Invoice Updated',
|
|
522
|
+
'Invoice Status Changed',
|
|
523
|
+
'Invoice Deleted',
|
|
524
|
+
'Bill Created',
|
|
525
|
+
'Bill Updated',
|
|
526
|
+
'Bill Status Changed',
|
|
527
|
+
'Bill Deleted',
|
|
528
|
+
'Quote Created',
|
|
529
|
+
'Quote Updated',
|
|
530
|
+
'Quote Status Changed',
|
|
531
|
+
'Quote Deleted',
|
|
532
|
+
],
|
|
533
|
+
},
|
|
534
|
+
},
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
displayName: 'Filter by Resource',
|
|
538
|
+
name: 'resource',
|
|
539
|
+
type: 'string',
|
|
540
|
+
default: '',
|
|
541
|
+
typeOptions: { multipleValues: true },
|
|
542
|
+
required: false,
|
|
543
|
+
description: 'Only trigger for specific resource IDs',
|
|
544
|
+
displayOptions: {
|
|
545
|
+
show: {
|
|
546
|
+
event: ['Stage Created', 'Stage Updated', 'Stage Status Changed', 'Stage Deleted'],
|
|
547
|
+
},
|
|
548
|
+
},
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
displayName: 'Filter by Work Category',
|
|
552
|
+
name: 'workCategory',
|
|
553
|
+
type: 'string',
|
|
554
|
+
default: '',
|
|
555
|
+
typeOptions: { multipleValues: true },
|
|
556
|
+
required: false,
|
|
557
|
+
description: 'Only trigger for specific work category IDs',
|
|
558
|
+
displayOptions: {
|
|
559
|
+
show: {
|
|
560
|
+
event: ['Stage Created', 'Stage Updated', 'Stage Status Changed', 'Stage Deleted'],
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
displayName: 'Filter by Status',
|
|
566
|
+
name: 'stageStatus',
|
|
567
|
+
type: 'multiOptions',
|
|
568
|
+
default: [],
|
|
569
|
+
options: [
|
|
570
|
+
{ name: 'Open', value: JSON.stringify({ match: 'systemStatus', value: 'Open' }) },
|
|
571
|
+
{ name: 'InProgress', value: JSON.stringify({ match: 'systemStatus', value: 'InProgress' }) },
|
|
572
|
+
{ name: 'Completed', value: JSON.stringify({ match: 'systemStatus', value: 'Completed' }) },
|
|
573
|
+
{ name: 'Closed', value: JSON.stringify({ match: 'systemStatus', value: 'Closed' }) },
|
|
574
|
+
{ name: 'Cancelled', value: JSON.stringify({ match: 'systemStatus', value: 'Cancelled' }) },
|
|
575
|
+
],
|
|
576
|
+
required: false,
|
|
577
|
+
description: 'Only trigger when the status matches one of these values',
|
|
578
|
+
displayOptions: {
|
|
579
|
+
show: {
|
|
580
|
+
event: ['Stage Created', 'Stage Updated', 'Stage Status Changed', 'Stage Deleted'],
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
displayName: 'Filter by Scheduling Tag',
|
|
586
|
+
name: 'schedulingTag',
|
|
587
|
+
type: 'string',
|
|
588
|
+
default: '',
|
|
589
|
+
typeOptions: { multipleValues: true },
|
|
590
|
+
required: false,
|
|
591
|
+
description: 'Only trigger for specific scheduling tag IDs',
|
|
592
|
+
displayOptions: {
|
|
593
|
+
show: {
|
|
594
|
+
event: ['Stage Created', 'Stage Updated', 'Stage Status Changed', 'Stage Deleted'],
|
|
595
|
+
},
|
|
596
|
+
},
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
displayName: 'Filter by Entity Type',
|
|
600
|
+
name: 'activityEntity',
|
|
601
|
+
type: 'string',
|
|
602
|
+
default: '',
|
|
603
|
+
typeOptions: { multipleValues: true },
|
|
604
|
+
required: false,
|
|
605
|
+
description: 'Only trigger when the entity type matches one of these values',
|
|
606
|
+
displayOptions: {
|
|
607
|
+
show: {
|
|
608
|
+
event: ['Activity Created', 'Activity Updated', 'Activity Deleted'],
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
displayName: 'Filter by Activity Kind',
|
|
614
|
+
name: 'activityKind',
|
|
615
|
+
type: 'string',
|
|
616
|
+
default: '',
|
|
617
|
+
typeOptions: { multipleValues: true },
|
|
618
|
+
required: false,
|
|
619
|
+
description: 'Only trigger when the activity kind matches one of these values',
|
|
620
|
+
displayOptions: {
|
|
621
|
+
show: {
|
|
622
|
+
event: ['Activity Created', 'Activity Updated', 'Activity Deleted'],
|
|
623
|
+
},
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
displayName: 'Filter by Stage',
|
|
628
|
+
name: 'opportunityStage',
|
|
629
|
+
type: 'string',
|
|
630
|
+
default: '',
|
|
631
|
+
typeOptions: { multipleValues: true },
|
|
632
|
+
required: false,
|
|
633
|
+
description: 'Only trigger for specific stage IDs',
|
|
634
|
+
displayOptions: {
|
|
635
|
+
show: {
|
|
636
|
+
event: ['Opportunity Created', 'Opportunity Updated', 'Opportunity Status Changed', 'Opportunity Deleted'],
|
|
637
|
+
},
|
|
638
|
+
},
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
displayName: 'Filter by Stage',
|
|
642
|
+
name: 'leadStage',
|
|
643
|
+
type: 'string',
|
|
644
|
+
default: '',
|
|
645
|
+
typeOptions: { multipleValues: true },
|
|
646
|
+
required: false,
|
|
647
|
+
description: 'Only trigger when the stage matches one of these values',
|
|
648
|
+
displayOptions: {
|
|
649
|
+
show: {
|
|
650
|
+
event: ['Lead Created', 'Lead Updated', 'Lead Status Changed', 'Lead Deleted'],
|
|
651
|
+
},
|
|
652
|
+
},
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
displayName: 'Filter by Source',
|
|
656
|
+
name: 'leadSource',
|
|
657
|
+
type: 'string',
|
|
658
|
+
default: '',
|
|
659
|
+
typeOptions: { multipleValues: true },
|
|
660
|
+
required: false,
|
|
661
|
+
description: 'Only trigger for specific source IDs',
|
|
662
|
+
displayOptions: {
|
|
663
|
+
show: {
|
|
664
|
+
event: ['Lead Created', 'Lead Updated', 'Lead Status Changed', 'Lead Deleted'],
|
|
665
|
+
},
|
|
666
|
+
},
|
|
667
|
+
},
|
|
668
|
+
],
|
|
669
|
+
};
|
|
670
|
+
webhookMethods = {
|
|
671
|
+
default: {
|
|
672
|
+
async checkExists() {
|
|
673
|
+
const webhookData = this.getWorkflowStaticData('node');
|
|
674
|
+
return webhookData.webhookId !== undefined;
|
|
675
|
+
},
|
|
676
|
+
async create() {
|
|
677
|
+
const webhookUrl = this.getNodeWebhookUrl('default');
|
|
678
|
+
const event = this.getNodeParameter('event');
|
|
679
|
+
const category = eventCategoryMap[event] || '';
|
|
680
|
+
const webhookData = this.getWorkflowStaticData('node');
|
|
681
|
+
const token = await getAccessToken(this);
|
|
682
|
+
const credentials = await this.getCredentials('workBuddyApi');
|
|
683
|
+
const baseUrl = credentials.baseUrl;
|
|
684
|
+
const filters = {};
|
|
685
|
+
try {
|
|
686
|
+
const v = this.getNodeParameter('customer');
|
|
687
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
688
|
+
filters.customer = Array.isArray(v)
|
|
689
|
+
? v
|
|
690
|
+
: v
|
|
691
|
+
.split(',')
|
|
692
|
+
.map((s) => s.trim())
|
|
693
|
+
.filter(Boolean);
|
|
694
|
+
}
|
|
695
|
+
catch { }
|
|
696
|
+
try {
|
|
697
|
+
const v = this.getNodeParameter('billingCompany');
|
|
698
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
699
|
+
filters.billingCompany = Array.isArray(v)
|
|
700
|
+
? v
|
|
701
|
+
: v
|
|
702
|
+
.split(',')
|
|
703
|
+
.map((s) => s.trim())
|
|
704
|
+
.filter(Boolean);
|
|
705
|
+
}
|
|
706
|
+
catch { }
|
|
707
|
+
try {
|
|
708
|
+
const v = this.getNodeParameter('tag');
|
|
709
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
710
|
+
filters.tag = Array.isArray(v)
|
|
711
|
+
? v
|
|
712
|
+
: v
|
|
713
|
+
.split(',')
|
|
714
|
+
.map((s) => s.trim())
|
|
715
|
+
.filter(Boolean);
|
|
716
|
+
}
|
|
717
|
+
catch { }
|
|
718
|
+
try {
|
|
719
|
+
const v = this.getNodeParameter('site');
|
|
720
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
721
|
+
filters.site = Array.isArray(v)
|
|
722
|
+
? v
|
|
723
|
+
: v
|
|
724
|
+
.split(',')
|
|
725
|
+
.map((s) => s.trim())
|
|
726
|
+
.filter(Boolean);
|
|
727
|
+
}
|
|
728
|
+
catch { }
|
|
729
|
+
try {
|
|
730
|
+
const v = this.getNodeParameter('type');
|
|
731
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
732
|
+
filters.type = Array.isArray(v)
|
|
733
|
+
? v
|
|
734
|
+
: v
|
|
735
|
+
.split(',')
|
|
736
|
+
.map((s) => s.trim())
|
|
737
|
+
.filter(Boolean);
|
|
738
|
+
}
|
|
739
|
+
catch { }
|
|
740
|
+
try {
|
|
741
|
+
const v = this.getNodeParameter('priority');
|
|
742
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
743
|
+
filters.priority = Array.isArray(v)
|
|
744
|
+
? v
|
|
745
|
+
: v
|
|
746
|
+
.split(',')
|
|
747
|
+
.map((s) => s.trim())
|
|
748
|
+
.filter(Boolean);
|
|
749
|
+
}
|
|
750
|
+
catch { }
|
|
751
|
+
try {
|
|
752
|
+
const v = this.getNodeParameter('owner');
|
|
753
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
754
|
+
filters.owner = Array.isArray(v)
|
|
755
|
+
? v
|
|
756
|
+
: v
|
|
757
|
+
.split(',')
|
|
758
|
+
.map((s) => s.trim())
|
|
759
|
+
.filter(Boolean);
|
|
760
|
+
}
|
|
761
|
+
catch { }
|
|
762
|
+
try {
|
|
763
|
+
const v = this.getNodeParameter('zone');
|
|
764
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
765
|
+
filters.zone = Array.isArray(v)
|
|
766
|
+
? v
|
|
767
|
+
: v
|
|
768
|
+
.split(',')
|
|
769
|
+
.map((s) => s.trim())
|
|
770
|
+
.filter(Boolean);
|
|
771
|
+
}
|
|
772
|
+
catch { }
|
|
773
|
+
try {
|
|
774
|
+
const v = this.getNodeParameter('status');
|
|
775
|
+
if (v?.length)
|
|
776
|
+
filters.status = v.map((s) => JSON.parse(s));
|
|
777
|
+
}
|
|
778
|
+
catch { }
|
|
779
|
+
try {
|
|
780
|
+
const v = this.getNodeParameter('resource');
|
|
781
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
782
|
+
filters.resource = Array.isArray(v)
|
|
783
|
+
? v
|
|
784
|
+
: v
|
|
785
|
+
.split(',')
|
|
786
|
+
.map((s) => s.trim())
|
|
787
|
+
.filter(Boolean);
|
|
788
|
+
}
|
|
789
|
+
catch { }
|
|
790
|
+
try {
|
|
791
|
+
const v = this.getNodeParameter('workCategory');
|
|
792
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
793
|
+
filters.workCategory = Array.isArray(v)
|
|
794
|
+
? v
|
|
795
|
+
: v
|
|
796
|
+
.split(',')
|
|
797
|
+
.map((s) => s.trim())
|
|
798
|
+
.filter(Boolean);
|
|
799
|
+
}
|
|
800
|
+
catch { }
|
|
801
|
+
try {
|
|
802
|
+
const v = this.getNodeParameter('stageStatus');
|
|
803
|
+
if (v?.length)
|
|
804
|
+
filters.stageStatus = v.map((s) => JSON.parse(s));
|
|
805
|
+
}
|
|
806
|
+
catch { }
|
|
807
|
+
try {
|
|
808
|
+
const v = this.getNodeParameter('schedulingTag');
|
|
809
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
810
|
+
filters.schedulingTag = Array.isArray(v)
|
|
811
|
+
? v
|
|
812
|
+
: v
|
|
813
|
+
.split(',')
|
|
814
|
+
.map((s) => s.trim())
|
|
815
|
+
.filter(Boolean);
|
|
816
|
+
}
|
|
817
|
+
catch { }
|
|
818
|
+
try {
|
|
819
|
+
const v = this.getNodeParameter('activityEntity');
|
|
820
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
821
|
+
filters.activityEntity = Array.isArray(v)
|
|
822
|
+
? v
|
|
823
|
+
: v
|
|
824
|
+
.split(',')
|
|
825
|
+
.map((s) => s.trim())
|
|
826
|
+
.filter(Boolean);
|
|
827
|
+
}
|
|
828
|
+
catch { }
|
|
829
|
+
try {
|
|
830
|
+
const v = this.getNodeParameter('activityKind');
|
|
831
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
832
|
+
filters.activityKind = Array.isArray(v)
|
|
833
|
+
? v
|
|
834
|
+
: v
|
|
835
|
+
.split(',')
|
|
836
|
+
.map((s) => s.trim())
|
|
837
|
+
.filter(Boolean);
|
|
838
|
+
}
|
|
839
|
+
catch { }
|
|
840
|
+
try {
|
|
841
|
+
const v = this.getNodeParameter('opportunityStage');
|
|
842
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
843
|
+
filters.opportunityStage = Array.isArray(v)
|
|
844
|
+
? v
|
|
845
|
+
: v
|
|
846
|
+
.split(',')
|
|
847
|
+
.map((s) => s.trim())
|
|
848
|
+
.filter(Boolean);
|
|
849
|
+
}
|
|
850
|
+
catch { }
|
|
851
|
+
try {
|
|
852
|
+
const v = this.getNodeParameter('leadStage');
|
|
853
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
854
|
+
filters.leadStage = Array.isArray(v)
|
|
855
|
+
? v
|
|
856
|
+
: v
|
|
857
|
+
.split(',')
|
|
858
|
+
.map((s) => s.trim())
|
|
859
|
+
.filter(Boolean);
|
|
860
|
+
}
|
|
861
|
+
catch { }
|
|
862
|
+
try {
|
|
863
|
+
const v = this.getNodeParameter('leadSource');
|
|
864
|
+
if (v && (Array.isArray(v) ? v.length > 0 : v !== ''))
|
|
865
|
+
filters.leadSource = Array.isArray(v)
|
|
866
|
+
? v
|
|
867
|
+
: v
|
|
868
|
+
.split(',')
|
|
869
|
+
.map((s) => s.trim())
|
|
870
|
+
.filter(Boolean);
|
|
871
|
+
}
|
|
872
|
+
catch { }
|
|
873
|
+
const response = await this.helpers.httpRequest({
|
|
874
|
+
method: 'POST',
|
|
875
|
+
url: `${baseUrl}/api/v2/public/webhooks`,
|
|
876
|
+
headers: {
|
|
877
|
+
Authorization: `Bearer ${token}`,
|
|
878
|
+
'Content-Type': 'application/json',
|
|
879
|
+
'X-WorkBuddy-Version': '2026-01',
|
|
880
|
+
},
|
|
881
|
+
body: {
|
|
882
|
+
name: `n8n: ${event}`,
|
|
883
|
+
url: webhookUrl,
|
|
884
|
+
entity: category,
|
|
885
|
+
events: [event],
|
|
886
|
+
...(Object.keys(filters).length > 0 ? { filters } : {}),
|
|
887
|
+
workflow: {
|
|
888
|
+
platform: 'n8n',
|
|
889
|
+
integrationId: webhookUrl,
|
|
890
|
+
},
|
|
891
|
+
},
|
|
892
|
+
});
|
|
893
|
+
webhookData.webhookId = response.data.id;
|
|
894
|
+
return true;
|
|
895
|
+
},
|
|
896
|
+
async delete() {
|
|
897
|
+
const webhookData = this.getWorkflowStaticData('node');
|
|
898
|
+
if (webhookData.webhookId) {
|
|
899
|
+
try {
|
|
900
|
+
const token = await getAccessToken(this);
|
|
901
|
+
const credentials = await this.getCredentials('workBuddyApi');
|
|
902
|
+
const baseUrl = credentials.baseUrl;
|
|
903
|
+
await this.helpers.httpRequest({
|
|
904
|
+
method: 'PATCH',
|
|
905
|
+
url: `${baseUrl}/api/v2/public/webhooks/${webhookData.webhookId}`,
|
|
906
|
+
headers: {
|
|
907
|
+
Authorization: `Bearer ${token}`,
|
|
908
|
+
'Content-Type': 'application/json',
|
|
909
|
+
'X-WorkBuddy-Version': '2026-01',
|
|
910
|
+
},
|
|
911
|
+
body: { status: 'paused' },
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
catch (error) {
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
917
|
+
delete webhookData.webhookId;
|
|
918
|
+
}
|
|
919
|
+
return true;
|
|
920
|
+
},
|
|
921
|
+
},
|
|
922
|
+
};
|
|
923
|
+
async webhook() {
|
|
924
|
+
const bodyData = this.getBodyData();
|
|
925
|
+
return {
|
|
926
|
+
workflowData: [this.helpers.returnJsonArray(bodyData)],
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
exports.WorkBuddyTrigger = WorkBuddyTrigger;
|
|
931
|
+
//# sourceMappingURL=WorkBuddyTrigger.node.js.map
|