@worktables/n8n-nodes-worktables 12.41.0 → 12.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nodes/Worktables/MondayWebhook.node.js +18 -0
- package/dist/nodes/Worktables/MondayWebhook.node.js.map +1 -1
- package/dist/nodes/Worktables/Worktables.node.js +1006 -260
- package/dist/nodes/Worktables/Worktables.node.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/isErrorResponse.js +12 -1
- package/dist/utils/isErrorResponse.js.map +1 -1
- package/dist/utils/test.json +1119 -0
- package/dist/utils/worktablesHelpers.js +16 -2
- package/dist/utils/worktablesHelpers.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
11
11
|
const parseValue_1 = require("../../utils/parseValue");
|
|
12
12
|
const worktablesHelpers_1 = require("../../utils/worktablesHelpers");
|
|
13
13
|
const country_codes_json_1 = __importDefault(require("../../utils/country_codes.json"));
|
|
14
|
+
const API_VERSION = '2026-01';
|
|
14
15
|
class Worktables {
|
|
15
16
|
constructor() {
|
|
16
17
|
this.description = {
|
|
@@ -37,7 +38,7 @@ class Worktables {
|
|
|
37
38
|
baseURL: 'https://api.monday.com/v2',
|
|
38
39
|
headers: {
|
|
39
40
|
'Content-Type': 'application/json',
|
|
40
|
-
'API-Version':
|
|
41
|
+
'API-Version': API_VERSION,
|
|
41
42
|
},
|
|
42
43
|
},
|
|
43
44
|
codex: {
|
|
@@ -72,6 +73,7 @@ class Worktables {
|
|
|
72
73
|
{ name: 'Update', value: 'update', description: 'Operations related to updates' },
|
|
73
74
|
{ name: 'Team', value: 'team', description: 'Operations related to teams' },
|
|
74
75
|
{ name: 'User', value: 'user', description: 'Operations related to users' },
|
|
76
|
+
{ name: 'Notification', value: 'notification', description: 'Send notifications to users' },
|
|
75
77
|
{
|
|
76
78
|
name: 'Download File',
|
|
77
79
|
value: 'downloadFile',
|
|
@@ -138,10 +140,10 @@ class Worktables {
|
|
|
138
140
|
action: 'Duplicate a board',
|
|
139
141
|
},
|
|
140
142
|
{
|
|
141
|
-
name: 'List
|
|
143
|
+
name: 'List Activity Logs',
|
|
142
144
|
value: 'listBoardActivityLogs',
|
|
143
|
-
description: 'Retrieve activity logs of a board',
|
|
144
|
-
action: 'List
|
|
145
|
+
description: 'Retrieve activity logs of a board with optional filters',
|
|
146
|
+
action: 'List activity logs',
|
|
145
147
|
},
|
|
146
148
|
{
|
|
147
149
|
name: 'List Board Subscribers',
|
|
@@ -277,10 +279,9 @@ class Worktables {
|
|
|
277
279
|
noDataExpression: true,
|
|
278
280
|
options: [
|
|
279
281
|
{
|
|
280
|
-
name: 'List',
|
|
282
|
+
name: 'List Updates in an Item',
|
|
281
283
|
value: 'listUpdates',
|
|
282
|
-
|
|
283
|
-
action: 'Get an update',
|
|
284
|
+
action: 'List updates in an item',
|
|
284
285
|
},
|
|
285
286
|
{
|
|
286
287
|
name: 'Create',
|
|
@@ -418,6 +419,88 @@ class Worktables {
|
|
|
418
419
|
show: { resource: ['user'] },
|
|
419
420
|
},
|
|
420
421
|
},
|
|
422
|
+
{
|
|
423
|
+
displayName: 'Operation',
|
|
424
|
+
name: 'operation',
|
|
425
|
+
type: 'options',
|
|
426
|
+
noDataExpression: true,
|
|
427
|
+
options: [
|
|
428
|
+
{
|
|
429
|
+
name: 'Send Notification',
|
|
430
|
+
value: 'sendNotification',
|
|
431
|
+
description: 'Send a notification to a user',
|
|
432
|
+
action: 'Send a notification',
|
|
433
|
+
},
|
|
434
|
+
],
|
|
435
|
+
default: 'sendNotification',
|
|
436
|
+
required: true,
|
|
437
|
+
displayOptions: {
|
|
438
|
+
show: { resource: ['notification'] },
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
displayName: 'User ID',
|
|
443
|
+
name: 'notificationUserId',
|
|
444
|
+
type: 'string',
|
|
445
|
+
default: '',
|
|
446
|
+
required: true,
|
|
447
|
+
description: 'The ID of the user to send the notification to',
|
|
448
|
+
displayOptions: {
|
|
449
|
+
show: {
|
|
450
|
+
resource: ['notification'],
|
|
451
|
+
operation: ['sendNotification'],
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
displayName: 'Target ID',
|
|
457
|
+
name: 'notificationTargetId',
|
|
458
|
+
type: 'string',
|
|
459
|
+
default: '',
|
|
460
|
+
required: true,
|
|
461
|
+
description: 'The ID of the target item (e.g. item ID)',
|
|
462
|
+
displayOptions: {
|
|
463
|
+
show: {
|
|
464
|
+
resource: ['notification'],
|
|
465
|
+
operation: ['sendNotification'],
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
displayName: 'Target Type',
|
|
471
|
+
name: 'notificationTargetType',
|
|
472
|
+
type: 'options',
|
|
473
|
+
options: [
|
|
474
|
+
{ name: 'Project', value: 'Project' },
|
|
475
|
+
{ name: 'Post', value: 'Post' },
|
|
476
|
+
],
|
|
477
|
+
default: 'Project',
|
|
478
|
+
required: true,
|
|
479
|
+
description: 'The type of the target',
|
|
480
|
+
displayOptions: {
|
|
481
|
+
show: {
|
|
482
|
+
resource: ['notification'],
|
|
483
|
+
operation: ['sendNotification'],
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
displayName: 'Message',
|
|
489
|
+
name: 'notificationMessage',
|
|
490
|
+
type: 'string',
|
|
491
|
+
typeOptions: {
|
|
492
|
+
rows: 4,
|
|
493
|
+
},
|
|
494
|
+
default: '',
|
|
495
|
+
required: true,
|
|
496
|
+
description: 'The notification text to send',
|
|
497
|
+
displayOptions: {
|
|
498
|
+
show: {
|
|
499
|
+
resource: ['notification'],
|
|
500
|
+
operation: ['sendNotification'],
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
},
|
|
421
504
|
{
|
|
422
505
|
displayName: 'Query',
|
|
423
506
|
name: 'runQuery',
|
|
@@ -430,10 +513,37 @@ class Worktables {
|
|
|
430
513
|
displayName: 'API Version',
|
|
431
514
|
name: 'apiVersion',
|
|
432
515
|
type: 'string',
|
|
433
|
-
default:
|
|
516
|
+
default: API_VERSION,
|
|
434
517
|
description: 'Monday.com API version (e.g., 2025-01, 2024-10)',
|
|
435
518
|
displayOptions: { show: { resource: ['query'] } },
|
|
436
519
|
},
|
|
520
|
+
{
|
|
521
|
+
displayName: 'Include Pagination',
|
|
522
|
+
name: 'includePagination',
|
|
523
|
+
type: 'boolean',
|
|
524
|
+
default: false,
|
|
525
|
+
description: 'Whether to automatically fetch all pages of data',
|
|
526
|
+
displayOptions: { show: { resource: ['query'] } },
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
displayName: 'Make sure your query includes a limit parameter (e.g., limit: 100) for pagination to work correctly. Note: the maximum limit may vary depending on the query type — check the <a href="https://developer.monday.com/api-reference">official Monday.com API documentation</a> for details.',
|
|
530
|
+
name: 'paginationNotice',
|
|
531
|
+
type: 'notice',
|
|
532
|
+
default: '',
|
|
533
|
+
displayOptions: { show: { resource: ['query'], includePagination: [true] } },
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
displayName: 'Pagination Type',
|
|
537
|
+
name: 'paginationType',
|
|
538
|
+
type: 'options',
|
|
539
|
+
options: [
|
|
540
|
+
{ name: 'Page', value: 'page' },
|
|
541
|
+
{ name: 'Cursor', value: 'cursor' },
|
|
542
|
+
],
|
|
543
|
+
default: 'cursor',
|
|
544
|
+
description: 'Type of pagination used in your query',
|
|
545
|
+
displayOptions: { show: { resource: ['query'], includePagination: [true] } },
|
|
546
|
+
},
|
|
437
547
|
{
|
|
438
548
|
displayName: 'Operation',
|
|
439
549
|
name: 'operation',
|
|
@@ -945,6 +1055,68 @@ class Worktables {
|
|
|
945
1055
|
show: { operation: ['listBoardActivityLogs', 'getItemActivityLogs'] },
|
|
946
1056
|
},
|
|
947
1057
|
},
|
|
1058
|
+
{
|
|
1059
|
+
displayName: 'Item IDs',
|
|
1060
|
+
name: 'itemIds',
|
|
1061
|
+
type: 'string',
|
|
1062
|
+
default: '',
|
|
1063
|
+
placeholder: '123456789, 987654321',
|
|
1064
|
+
description: 'Comma-separated list of item IDs to filter activity logs',
|
|
1065
|
+
displayOptions: {
|
|
1066
|
+
show: { operation: ['listBoardActivityLogs'] },
|
|
1067
|
+
},
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
displayName: 'Column IDs',
|
|
1071
|
+
name: 'columnIdsFilter',
|
|
1072
|
+
type: 'string',
|
|
1073
|
+
default: '',
|
|
1074
|
+
placeholder: 'status, person, date',
|
|
1075
|
+
description: 'Comma-separated list of column IDs to filter activity logs',
|
|
1076
|
+
displayOptions: {
|
|
1077
|
+
show: { operation: ['listBoardActivityLogs'] },
|
|
1078
|
+
},
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
displayName: 'Group IDs',
|
|
1082
|
+
name: 'groupIdsFilter',
|
|
1083
|
+
type: 'string',
|
|
1084
|
+
default: '',
|
|
1085
|
+
placeholder: 'new_group, topics',
|
|
1086
|
+
description: 'Comma-separated list of group IDs to filter activity logs',
|
|
1087
|
+
displayOptions: {
|
|
1088
|
+
show: { operation: ['listBoardActivityLogs'] },
|
|
1089
|
+
},
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
displayName: 'User IDs',
|
|
1093
|
+
name: 'userIdsFilter',
|
|
1094
|
+
type: 'multiOptions',
|
|
1095
|
+
typeOptions: {
|
|
1096
|
+
loadOptionsMethod: 'getUsers',
|
|
1097
|
+
},
|
|
1098
|
+
default: [],
|
|
1099
|
+
description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
|
1100
|
+
displayOptions: {
|
|
1101
|
+
show: { operation: ['listBoardActivityLogs'] },
|
|
1102
|
+
},
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
displayName: 'Limit',
|
|
1106
|
+
name: 'limit',
|
|
1107
|
+
type: 'number',
|
|
1108
|
+
typeOptions: {
|
|
1109
|
+
minValue: 0,
|
|
1110
|
+
},
|
|
1111
|
+
default: 50,
|
|
1112
|
+
description: 'Max number of results to return',
|
|
1113
|
+
hint: 'If 0 is provided, all activity logs will be returned. This may take longer for large boards.',
|
|
1114
|
+
displayOptions: {
|
|
1115
|
+
show: {
|
|
1116
|
+
operation: ['listBoardActivityLogs', 'getItemActivityLogs'],
|
|
1117
|
+
},
|
|
1118
|
+
},
|
|
1119
|
+
},
|
|
948
1120
|
{
|
|
949
1121
|
displayName: 'Archived',
|
|
950
1122
|
name: 'archiveGroup',
|
|
@@ -1097,6 +1269,45 @@ class Worktables {
|
|
|
1097
1269
|
},
|
|
1098
1270
|
},
|
|
1099
1271
|
},
|
|
1272
|
+
{
|
|
1273
|
+
displayName: 'Limit',
|
|
1274
|
+
name: 'limit',
|
|
1275
|
+
type: 'number',
|
|
1276
|
+
default: 50,
|
|
1277
|
+
description: 'Max number of results to return',
|
|
1278
|
+
displayOptions: {
|
|
1279
|
+
show: {
|
|
1280
|
+
operation: ['listUpdates'],
|
|
1281
|
+
},
|
|
1282
|
+
},
|
|
1283
|
+
typeOptions: {
|
|
1284
|
+
minValue: 0,
|
|
1285
|
+
},
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
displayName: 'From Date',
|
|
1289
|
+
name: 'fromDate',
|
|
1290
|
+
type: 'dateTime',
|
|
1291
|
+
default: '',
|
|
1292
|
+
description: 'Filter updates created on or after this date',
|
|
1293
|
+
displayOptions: {
|
|
1294
|
+
show: {
|
|
1295
|
+
operation: ['listUpdates'],
|
|
1296
|
+
},
|
|
1297
|
+
},
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
displayName: 'To Date',
|
|
1301
|
+
name: 'toDate',
|
|
1302
|
+
type: 'dateTime',
|
|
1303
|
+
default: '',
|
|
1304
|
+
description: 'Filter updates created on or before this date',
|
|
1305
|
+
displayOptions: {
|
|
1306
|
+
show: {
|
|
1307
|
+
operation: ['listUpdates'],
|
|
1308
|
+
},
|
|
1309
|
+
},
|
|
1310
|
+
},
|
|
1100
1311
|
{
|
|
1101
1312
|
displayName: 'Board',
|
|
1102
1313
|
name: 'boardId',
|
|
@@ -1705,6 +1916,34 @@ class Worktables {
|
|
|
1705
1916
|
},
|
|
1706
1917
|
},
|
|
1707
1918
|
},
|
|
1919
|
+
{
|
|
1920
|
+
displayName: 'Fetch All Columns',
|
|
1921
|
+
name: 'fetchAllColumns',
|
|
1922
|
+
type: 'boolean',
|
|
1923
|
+
default: true,
|
|
1924
|
+
description: 'When true, returns all columns; otherwise, only specified Column IDs',
|
|
1925
|
+
displayOptions: {
|
|
1926
|
+
show: {
|
|
1927
|
+
operation: ['searchItems'],
|
|
1928
|
+
fetchColumnValues: [true],
|
|
1929
|
+
},
|
|
1930
|
+
},
|
|
1931
|
+
},
|
|
1932
|
+
{
|
|
1933
|
+
displayName: 'Column IDs',
|
|
1934
|
+
name: 'columnIds',
|
|
1935
|
+
type: 'string',
|
|
1936
|
+
default: '',
|
|
1937
|
+
placeholder: 'status,owner,date',
|
|
1938
|
+
description: 'Comma-separated column IDs to fetch. Leave empty to fetch all columns.',
|
|
1939
|
+
displayOptions: {
|
|
1940
|
+
show: {
|
|
1941
|
+
operation: ['searchItems'],
|
|
1942
|
+
fetchColumnValues: [true],
|
|
1943
|
+
fetchAllColumns: [false],
|
|
1944
|
+
},
|
|
1945
|
+
},
|
|
1946
|
+
},
|
|
1708
1947
|
{
|
|
1709
1948
|
displayName: 'Limit',
|
|
1710
1949
|
name: 'limit',
|
|
@@ -2271,6 +2510,32 @@ class Worktables {
|
|
|
2271
2510
|
},
|
|
2272
2511
|
},
|
|
2273
2512
|
},
|
|
2513
|
+
{
|
|
2514
|
+
displayName: 'Fetch All Columns',
|
|
2515
|
+
name: 'fetchAllColumns',
|
|
2516
|
+
type: 'boolean',
|
|
2517
|
+
default: true,
|
|
2518
|
+
description: 'When true, returns all columns; otherwise, only specified Column IDs',
|
|
2519
|
+
displayOptions: {
|
|
2520
|
+
show: {
|
|
2521
|
+
operation: ['listBoardItems', 'listGroupItems'],
|
|
2522
|
+
},
|
|
2523
|
+
},
|
|
2524
|
+
},
|
|
2525
|
+
{
|
|
2526
|
+
displayName: 'Column IDs',
|
|
2527
|
+
name: 'columnIds',
|
|
2528
|
+
type: 'string',
|
|
2529
|
+
default: '',
|
|
2530
|
+
placeholder: 'status,owner,date',
|
|
2531
|
+
description: 'Comma-separated column IDs to fetch. Leave empty to fetch all columns.',
|
|
2532
|
+
displayOptions: {
|
|
2533
|
+
show: {
|
|
2534
|
+
operation: ['listBoardItems', 'listGroupItems'],
|
|
2535
|
+
fetchAllColumns: [false],
|
|
2536
|
+
},
|
|
2537
|
+
},
|
|
2538
|
+
},
|
|
2274
2539
|
],
|
|
2275
2540
|
};
|
|
2276
2541
|
this.methods = {
|
|
@@ -2292,7 +2557,7 @@ class Worktables {
|
|
|
2292
2557
|
headers: {
|
|
2293
2558
|
Authorization: `Bearer ${apiKey}`,
|
|
2294
2559
|
'Content-Type': 'application/json',
|
|
2295
|
-
'API-Version':
|
|
2560
|
+
'API-Version': API_VERSION,
|
|
2296
2561
|
},
|
|
2297
2562
|
body: JSON.stringify({
|
|
2298
2563
|
query: `{ workspaces (limit: ${limit}, page: ${page}) { id name } }`,
|
|
@@ -2355,7 +2620,7 @@ class Worktables {
|
|
|
2355
2620
|
headers: {
|
|
2356
2621
|
Authorization: `Bearer ${apiKey}`,
|
|
2357
2622
|
'Content-Type': 'application/json',
|
|
2358
|
-
'API-Version':
|
|
2623
|
+
'API-Version': API_VERSION,
|
|
2359
2624
|
},
|
|
2360
2625
|
body: currentQuery,
|
|
2361
2626
|
});
|
|
@@ -2390,6 +2655,7 @@ class Worktables {
|
|
|
2390
2655
|
headers: {
|
|
2391
2656
|
Authorization: `Bearer ${apiKey}`,
|
|
2392
2657
|
'Content-Type': 'application/json',
|
|
2658
|
+
'API-Version': API_VERSION,
|
|
2393
2659
|
},
|
|
2394
2660
|
body: {
|
|
2395
2661
|
query: `query { boards(ids: ${boardId} ) { groups { id title color position archived deleted} } }`,
|
|
@@ -2418,6 +2684,7 @@ class Worktables {
|
|
|
2418
2684
|
headers: {
|
|
2419
2685
|
Authorization: `Bearer ${apiKey}`,
|
|
2420
2686
|
'Content-Type': 'application/json',
|
|
2687
|
+
'API-Version': API_VERSION,
|
|
2421
2688
|
},
|
|
2422
2689
|
body: {
|
|
2423
2690
|
query: `query {
|
|
@@ -2449,6 +2716,7 @@ class Worktables {
|
|
|
2449
2716
|
headers: {
|
|
2450
2717
|
Authorization: `Bearer ${apiKey}`,
|
|
2451
2718
|
'Content-Type': 'application/json',
|
|
2719
|
+
'API-Version': API_VERSION,
|
|
2452
2720
|
},
|
|
2453
2721
|
body: {
|
|
2454
2722
|
query: `query { boards(ids: ${parentBoardId ? parentBoardId : boardId}) { items_page (limit: 500) { items { id name } } } }`,
|
|
@@ -2481,6 +2749,7 @@ class Worktables {
|
|
|
2481
2749
|
headers: {
|
|
2482
2750
|
Authorization: `Bearer ${apiKey}`,
|
|
2483
2751
|
'Content-Type': 'application/json',
|
|
2752
|
+
'API-Version': API_VERSION,
|
|
2484
2753
|
},
|
|
2485
2754
|
body: {
|
|
2486
2755
|
query: `query { boards(ids: ${boardId}) { items_page (limit: 500) { items { id name } } } }`,
|
|
@@ -2496,6 +2765,7 @@ class Worktables {
|
|
|
2496
2765
|
return items;
|
|
2497
2766
|
},
|
|
2498
2767
|
async getSubitemFromItem() {
|
|
2768
|
+
var _a, _b;
|
|
2499
2769
|
console.log('Getting Subitems');
|
|
2500
2770
|
const itemId = this.getNodeParameter('itemId', 0);
|
|
2501
2771
|
const parentId = this.getNodeParameter('parentId', 0);
|
|
@@ -2513,6 +2783,7 @@ class Worktables {
|
|
|
2513
2783
|
headers: {
|
|
2514
2784
|
Authorization: `Bearer ${apiKey}`,
|
|
2515
2785
|
'Content-Type': 'application/json',
|
|
2786
|
+
'API-Version': API_VERSION,
|
|
2516
2787
|
},
|
|
2517
2788
|
body: {
|
|
2518
2789
|
query: `{
|
|
@@ -2527,9 +2798,13 @@ class Worktables {
|
|
|
2527
2798
|
});
|
|
2528
2799
|
const parsedResponse = JSON.parse(response);
|
|
2529
2800
|
console.log(JSON.stringify(parsedResponse, null, 2));
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2801
|
+
const item = (_b = (_a = parsedResponse.data) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b[0];
|
|
2802
|
+
if (!item || item.subitems === null || !Array.isArray(item.subitems) || item.subitems.length === 0) {
|
|
2803
|
+
return [];
|
|
2804
|
+
}
|
|
2805
|
+
return item.subitems.map((subitem) => ({
|
|
2806
|
+
name: subitem.name,
|
|
2807
|
+
value: subitem.id,
|
|
2533
2808
|
}));
|
|
2534
2809
|
},
|
|
2535
2810
|
async getColumnsFromBoard() {
|
|
@@ -2550,6 +2825,7 @@ class Worktables {
|
|
|
2550
2825
|
headers: {
|
|
2551
2826
|
Authorization: `Bearer ${apiKey}`,
|
|
2552
2827
|
'Content-Type': 'application/json',
|
|
2828
|
+
'API-Version': API_VERSION,
|
|
2553
2829
|
},
|
|
2554
2830
|
body: JSON.stringify({
|
|
2555
2831
|
query: `query { boards(ids: ${boardId}) { columns { id title type } } }`,
|
|
@@ -2588,6 +2864,7 @@ class Worktables {
|
|
|
2588
2864
|
headers: {
|
|
2589
2865
|
Authorization: `Bearer ${apiKey}`,
|
|
2590
2866
|
'Content-Type': 'application/json',
|
|
2867
|
+
'API-Version': API_VERSION,
|
|
2591
2868
|
},
|
|
2592
2869
|
body: JSON.stringify({
|
|
2593
2870
|
query: `query { boards(ids: ${boardId}) { subscribers { id name } } }`,
|
|
@@ -2600,6 +2877,7 @@ class Worktables {
|
|
|
2600
2877
|
}));
|
|
2601
2878
|
},
|
|
2602
2879
|
async getSubitems() {
|
|
2880
|
+
var _a, _b;
|
|
2603
2881
|
const itemId = this.getNodeParameter('parentId');
|
|
2604
2882
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
2605
2883
|
const apiKey = credentials === null || credentials === void 0 ? void 0 : credentials.apiKey;
|
|
@@ -2612,6 +2890,7 @@ class Worktables {
|
|
|
2612
2890
|
headers: {
|
|
2613
2891
|
Authorization: `Bearer ${apiKey}`,
|
|
2614
2892
|
'Content-Type': 'application/json',
|
|
2893
|
+
'API-Version': API_VERSION,
|
|
2615
2894
|
},
|
|
2616
2895
|
body: JSON.stringify({
|
|
2617
2896
|
query: `query {
|
|
@@ -2625,7 +2904,11 @@ class Worktables {
|
|
|
2625
2904
|
}),
|
|
2626
2905
|
});
|
|
2627
2906
|
const parsedResponse = JSON.parse(response);
|
|
2628
|
-
|
|
2907
|
+
const item = (_b = (_a = parsedResponse.data) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b[0];
|
|
2908
|
+
if (!item || item.subitems === null || !Array.isArray(item.subitems) || item.subitems.length === 0) {
|
|
2909
|
+
return [];
|
|
2910
|
+
}
|
|
2911
|
+
return item.subitems.map((subitem) => ({
|
|
2629
2912
|
name: subitem.name,
|
|
2630
2913
|
value: subitem.id,
|
|
2631
2914
|
}));
|
|
@@ -2640,6 +2923,7 @@ class Worktables {
|
|
|
2640
2923
|
headers: {
|
|
2641
2924
|
Authorization: `Bearer ${apiKey}`,
|
|
2642
2925
|
'Content-Type': 'application/json',
|
|
2926
|
+
'API-Version': API_VERSION,
|
|
2643
2927
|
},
|
|
2644
2928
|
body: JSON.stringify({
|
|
2645
2929
|
query: `query {
|
|
@@ -2705,7 +2989,7 @@ class Worktables {
|
|
|
2705
2989
|
headers: {
|
|
2706
2990
|
Authorization: `Bearer ${apiKey}`,
|
|
2707
2991
|
'Content-Type': 'application/json',
|
|
2708
|
-
'API-Version':
|
|
2992
|
+
'API-Version': API_VERSION,
|
|
2709
2993
|
},
|
|
2710
2994
|
body: JSON.stringify({
|
|
2711
2995
|
query: `query {
|
|
@@ -2740,7 +3024,7 @@ class Worktables {
|
|
|
2740
3024
|
headers: {
|
|
2741
3025
|
Authorization: `Bearer ${apiKey}`,
|
|
2742
3026
|
'Content-Type': 'application/json',
|
|
2743
|
-
'API-Version':
|
|
3027
|
+
'API-Version': API_VERSION,
|
|
2744
3028
|
},
|
|
2745
3029
|
body: JSON.stringify({
|
|
2746
3030
|
query: `query {
|
|
@@ -2764,9 +3048,20 @@ class Worktables {
|
|
|
2764
3048
|
}),
|
|
2765
3049
|
});
|
|
2766
3050
|
const parsedResponse = JSON.parse(response);
|
|
3051
|
+
if (parsedResponse.errors) {
|
|
3052
|
+
const fieldLimitError = parsedResponse.errors.find((err) => { var _a; return ((_a = err.extensions) === null || _a === void 0 ? void 0 : _a.code) === 'FIELD_LIMIT_EXCEEDED'; });
|
|
3053
|
+
if (fieldLimitError) {
|
|
3054
|
+
console.log('Subitems field concurrency limit exceeded. Consider paginating results.');
|
|
3055
|
+
return [];
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
2767
3058
|
const items = ((_e = (_d = (_c = (_b = parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.data) === null || _b === void 0 ? void 0 : _b.boards) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.items_page) === null || _e === void 0 ? void 0 : _e.items) || [];
|
|
2768
3059
|
for (const item of items) {
|
|
2769
|
-
if (item.subitems
|
|
3060
|
+
if (item.subitems === null) {
|
|
3061
|
+
console.log('Subitems returned null - board may be deleted');
|
|
3062
|
+
continue;
|
|
3063
|
+
}
|
|
3064
|
+
if (item.subitems && Array.isArray(item.subitems) && item.subitems.length > 0) {
|
|
2770
3065
|
const subitem = item.subitems[0];
|
|
2771
3066
|
if (subitem.board && subitem.board.columns) {
|
|
2772
3067
|
subitemBoardColumns = subitem.board.columns;
|
|
@@ -2805,7 +3100,7 @@ class Worktables {
|
|
|
2805
3100
|
headers: {
|
|
2806
3101
|
Authorization: `Bearer ${apiKey}`,
|
|
2807
3102
|
'Content-Type': 'application/json',
|
|
2808
|
-
'API-Version':
|
|
3103
|
+
'API-Version': API_VERSION,
|
|
2809
3104
|
},
|
|
2810
3105
|
body: JSON.stringify({
|
|
2811
3106
|
query: `query {
|
|
@@ -2861,7 +3156,7 @@ class Worktables {
|
|
|
2861
3156
|
headers: {
|
|
2862
3157
|
Authorization: `Bearer ${apiKey}`,
|
|
2863
3158
|
'Content-Type': 'application/json',
|
|
2864
|
-
'API-Version':
|
|
3159
|
+
'API-Version': API_VERSION,
|
|
2865
3160
|
},
|
|
2866
3161
|
body: JSON.stringify({
|
|
2867
3162
|
query: `query {
|
|
@@ -2896,7 +3191,7 @@ class Worktables {
|
|
|
2896
3191
|
headers: {
|
|
2897
3192
|
Authorization: `Bearer ${apiKey}`,
|
|
2898
3193
|
'Content-Type': 'application/json',
|
|
2899
|
-
'API-Version':
|
|
3194
|
+
'API-Version': API_VERSION,
|
|
2900
3195
|
},
|
|
2901
3196
|
body: JSON.stringify({
|
|
2902
3197
|
query: `query {
|
|
@@ -2961,7 +3256,7 @@ class Worktables {
|
|
|
2961
3256
|
headers: {
|
|
2962
3257
|
Authorization: `Bearer ${apiKey}`,
|
|
2963
3258
|
'Content-Type': 'application/json',
|
|
2964
|
-
'API-Version':
|
|
3259
|
+
'API-Version': API_VERSION,
|
|
2965
3260
|
},
|
|
2966
3261
|
body: JSON.stringify({
|
|
2967
3262
|
query: `query {
|
|
@@ -3016,7 +3311,7 @@ class Worktables {
|
|
|
3016
3311
|
headers: {
|
|
3017
3312
|
Authorization: `Bearer ${apiKey}`,
|
|
3018
3313
|
'Content-Type': 'application/json',
|
|
3019
|
-
'API-Version':
|
|
3314
|
+
'API-Version': API_VERSION,
|
|
3020
3315
|
},
|
|
3021
3316
|
body: {
|
|
3022
3317
|
query: `{ folders (limit: ${limit}, page: ${page}, workspace_ids: ${workspaceId}) { id name } }`,
|
|
@@ -3053,7 +3348,7 @@ class Worktables {
|
|
|
3053
3348
|
headers: {
|
|
3054
3349
|
Authorization: `Bearer ${apiKey}`,
|
|
3055
3350
|
'Content-Type': 'application/json',
|
|
3056
|
-
'API-Version':
|
|
3351
|
+
'API-Version': API_VERSION,
|
|
3057
3352
|
},
|
|
3058
3353
|
body: {
|
|
3059
3354
|
query: `{ users (limit: ${limit}, page: ${page}) { id name } }`,
|
|
@@ -3085,6 +3380,7 @@ class Worktables {
|
|
|
3085
3380
|
headers: {
|
|
3086
3381
|
Authorization: `Bearer ${apiKey}`,
|
|
3087
3382
|
'Content-Type': 'application/json',
|
|
3383
|
+
'API-Version': API_VERSION,
|
|
3088
3384
|
},
|
|
3089
3385
|
body: {
|
|
3090
3386
|
query: `{ teams { id name } }`,
|
|
@@ -3108,6 +3404,7 @@ class Worktables {
|
|
|
3108
3404
|
headers: {
|
|
3109
3405
|
Authorization: `Bearer ${apiKey}`,
|
|
3110
3406
|
'Content-Type': 'application/json',
|
|
3407
|
+
'API-Version': API_VERSION,
|
|
3111
3408
|
},
|
|
3112
3409
|
body: JSON.stringify({
|
|
3113
3410
|
query: `query { boards(ids: ${boardId}) { columns { id title type } } }`,
|
|
@@ -3134,6 +3431,7 @@ class Worktables {
|
|
|
3134
3431
|
headers: {
|
|
3135
3432
|
Authorization: `Bearer ${apiKey}`,
|
|
3136
3433
|
'Content-Type': 'application/json',
|
|
3434
|
+
'API-Version': API_VERSION,
|
|
3137
3435
|
},
|
|
3138
3436
|
body: JSON.stringify({
|
|
3139
3437
|
query: `query { boards(ids: ${boardId}) { updates { id body } } }`,
|
|
@@ -3171,6 +3469,7 @@ class Worktables {
|
|
|
3171
3469
|
headers: {
|
|
3172
3470
|
Authorization: `Bearer ${apiKey}`,
|
|
3173
3471
|
'Content-Type': 'application/json',
|
|
3472
|
+
'API-Version': API_VERSION,
|
|
3174
3473
|
},
|
|
3175
3474
|
body: JSON.stringify({
|
|
3176
3475
|
query: `query {
|
|
@@ -3203,9 +3502,10 @@ class Worktables {
|
|
|
3203
3502
|
};
|
|
3204
3503
|
}
|
|
3205
3504
|
async execute() {
|
|
3206
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47;
|
|
3505
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51;
|
|
3207
3506
|
const resource = this.getNodeParameter('resource', 0);
|
|
3208
3507
|
const operation = this.getNodeParameter('operation', 0);
|
|
3508
|
+
console.log('Testing... v1.0.29');
|
|
3209
3509
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
3210
3510
|
const apiKey = credentials === null || credentials === void 0 ? void 0 : credentials.apiKey;
|
|
3211
3511
|
if (!apiKey) {
|
|
@@ -3215,7 +3515,7 @@ class Worktables {
|
|
|
3215
3515
|
const headers = {
|
|
3216
3516
|
Authorization: `Bearer ${apiKey}`,
|
|
3217
3517
|
'Content-Type': 'application/json',
|
|
3218
|
-
'API-Version':
|
|
3518
|
+
'API-Version': API_VERSION,
|
|
3219
3519
|
};
|
|
3220
3520
|
switch (resource) {
|
|
3221
3521
|
case 'board': {
|
|
@@ -3665,30 +3965,99 @@ class Worktables {
|
|
|
3665
3965
|
}
|
|
3666
3966
|
case 'listBoardActivityLogs': {
|
|
3667
3967
|
const boardId = this.getNodeParameter('boardId', 0);
|
|
3668
|
-
const from = this.getNodeParameter('from', 0);
|
|
3669
|
-
const to = this.getNodeParameter('to', 0);
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
const
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3968
|
+
const from = this.getNodeParameter('from', 0, '');
|
|
3969
|
+
const to = this.getNodeParameter('to', 0, '');
|
|
3970
|
+
const limit = this.getNodeParameter('limit', 0, 50);
|
|
3971
|
+
const itemIdsRaw = this.getNodeParameter('itemIds', 0, '');
|
|
3972
|
+
const columnIdsRaw = this.getNodeParameter('columnIdsFilter', 0, '');
|
|
3973
|
+
const groupIdsRaw = this.getNodeParameter('groupIdsFilter', 0, '');
|
|
3974
|
+
const userIdsFilter = this.getNodeParameter('userIdsFilter', 0, []);
|
|
3975
|
+
const baseParams = [];
|
|
3976
|
+
if (from) {
|
|
3977
|
+
baseParams.push(`from: "${from}Z"`);
|
|
3978
|
+
}
|
|
3979
|
+
if (to) {
|
|
3980
|
+
baseParams.push(`to: "${to}Z"`);
|
|
3981
|
+
}
|
|
3982
|
+
if (itemIdsRaw && itemIdsRaw.trim()) {
|
|
3983
|
+
const itemIds = itemIdsRaw.split(',').map(id => `"${id.trim()}"`).filter(id => id !== '""');
|
|
3984
|
+
if (itemIds.length > 0) {
|
|
3985
|
+
baseParams.push(`item_ids: [${itemIds.join(', ')}]`);
|
|
3986
|
+
}
|
|
3987
|
+
}
|
|
3988
|
+
if (columnIdsRaw && columnIdsRaw.trim()) {
|
|
3989
|
+
const columnIds = columnIdsRaw.split(',').map(id => `"${id.trim()}"`).filter(id => id !== '""');
|
|
3990
|
+
if (columnIds.length > 0) {
|
|
3991
|
+
baseParams.push(`column_ids: [${columnIds.join(', ')}]`);
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
if (groupIdsRaw && groupIdsRaw.trim()) {
|
|
3995
|
+
const groupIds = groupIdsRaw.split(',').map(id => `"${id.trim()}"`).filter(id => id !== '""');
|
|
3996
|
+
if (groupIds.length > 0) {
|
|
3997
|
+
baseParams.push(`group_ids: [${groupIds.join(', ')}]`);
|
|
3998
|
+
}
|
|
3999
|
+
}
|
|
4000
|
+
if (userIdsFilter && userIdsFilter.length > 0) {
|
|
4001
|
+
const userIds = userIdsFilter.map(id => `"${id}"`);
|
|
4002
|
+
baseParams.push(`user_ids: [${userIds.join(', ')}]`);
|
|
4003
|
+
}
|
|
4004
|
+
let allLogs = [];
|
|
4005
|
+
let page = 1;
|
|
4006
|
+
const pageLimit = 100;
|
|
4007
|
+
do {
|
|
4008
|
+
const params = [...baseParams];
|
|
4009
|
+
params.push(`page: ${page}`);
|
|
4010
|
+
if (limit === 0) {
|
|
4011
|
+
params.push(`limit: ${pageLimit}`);
|
|
4012
|
+
}
|
|
4013
|
+
else {
|
|
4014
|
+
const remaining = limit - allLogs.length;
|
|
4015
|
+
const currentLimit = remaining > pageLimit ? pageLimit : remaining;
|
|
4016
|
+
params.push(`limit: ${currentLimit}`);
|
|
4017
|
+
}
|
|
4018
|
+
const paramsString = `(${params.join(', ')})`;
|
|
4019
|
+
const query = `
|
|
4020
|
+
query {
|
|
4021
|
+
boards(ids: [${boardId}]) {
|
|
4022
|
+
activity_logs${paramsString} {
|
|
4023
|
+
id
|
|
4024
|
+
user_id
|
|
4025
|
+
entity
|
|
4026
|
+
event
|
|
4027
|
+
data
|
|
4028
|
+
created_at
|
|
4029
|
+
}
|
|
3682
4030
|
}
|
|
3683
4031
|
}
|
|
3684
|
-
}
|
|
3685
4032
|
`;
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
4033
|
+
console.log('Activity Logs Query: ', query);
|
|
4034
|
+
const rawResponse = await this.helpers.request({
|
|
4035
|
+
method: 'POST',
|
|
4036
|
+
url: 'https://api.monday.com/v2',
|
|
4037
|
+
headers,
|
|
4038
|
+
body: { query },
|
|
4039
|
+
});
|
|
4040
|
+
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
4041
|
+
const boards = ((_a = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _a === void 0 ? void 0 : _a.boards) || [];
|
|
4042
|
+
const logs = boards.length > 0 ? (boards[0].activity_logs || []) : [];
|
|
4043
|
+
allLogs = allLogs.concat(logs);
|
|
4044
|
+
if (logs.length < pageLimit) {
|
|
4045
|
+
break;
|
|
4046
|
+
}
|
|
4047
|
+
if (limit > 0 && allLogs.length >= limit) {
|
|
4048
|
+
if (allLogs.length > limit) {
|
|
4049
|
+
allLogs = allLogs.slice(0, limit);
|
|
4050
|
+
}
|
|
4051
|
+
break;
|
|
4052
|
+
}
|
|
4053
|
+
page++;
|
|
4054
|
+
} while (true);
|
|
4055
|
+
response = JSON.stringify({
|
|
4056
|
+
data: {
|
|
4057
|
+
boards: [{
|
|
4058
|
+
activity_logs: allLogs,
|
|
4059
|
+
}],
|
|
4060
|
+
},
|
|
3692
4061
|
});
|
|
3693
4062
|
break;
|
|
3694
4063
|
}
|
|
@@ -3842,6 +4211,14 @@ class Worktables {
|
|
|
3842
4211
|
linked_board_id
|
|
3843
4212
|
}
|
|
3844
4213
|
}
|
|
4214
|
+
... on DependencyValue {
|
|
4215
|
+
display_value
|
|
4216
|
+
linked_item_ids
|
|
4217
|
+
linked_items {
|
|
4218
|
+
id
|
|
4219
|
+
name
|
|
4220
|
+
}
|
|
4221
|
+
}
|
|
3845
4222
|
}
|
|
3846
4223
|
`;
|
|
3847
4224
|
}
|
|
@@ -3865,8 +4242,16 @@ class Worktables {
|
|
|
3865
4242
|
linked_board_id
|
|
3866
4243
|
}
|
|
3867
4244
|
}
|
|
3868
|
-
|
|
3869
|
-
|
|
4245
|
+
... on DependencyValue {
|
|
4246
|
+
display_value
|
|
4247
|
+
linked_item_ids
|
|
4248
|
+
linked_items {
|
|
4249
|
+
id
|
|
4250
|
+
name
|
|
4251
|
+
}
|
|
4252
|
+
}
|
|
4253
|
+
}
|
|
4254
|
+
`;
|
|
3870
4255
|
}
|
|
3871
4256
|
}
|
|
3872
4257
|
const querySubitems = `
|
|
@@ -3926,7 +4311,7 @@ class Worktables {
|
|
|
3926
4311
|
body: { query },
|
|
3927
4312
|
});
|
|
3928
4313
|
const parsed = JSON.parse(rawResponse);
|
|
3929
|
-
const items = (
|
|
4314
|
+
const items = (_b = parsed.data) === null || _b === void 0 ? void 0 : _b.items;
|
|
3930
4315
|
const item = items === null || items === void 0 ? void 0 : items[0];
|
|
3931
4316
|
if (!item || !items || items.length === 0) {
|
|
3932
4317
|
return [[]];
|
|
@@ -4075,10 +4460,13 @@ class Worktables {
|
|
|
4075
4460
|
const itemConnectionResponse = await this.helpers.request({
|
|
4076
4461
|
method: 'POST',
|
|
4077
4462
|
url: 'https://api.monday.com/v2',
|
|
4078
|
-
headers
|
|
4463
|
+
headers: {
|
|
4464
|
+
...headers,
|
|
4465
|
+
'API-Version': API_VERSION,
|
|
4466
|
+
},
|
|
4079
4467
|
body: { query: mutation },
|
|
4080
4468
|
});
|
|
4081
|
-
const existingIds = ((_g = (_f = (_e = (_d = (_c =
|
|
4469
|
+
const existingIds = ((_h = (_g = (_f = (_e = (_d = (_c = JSON.parse(itemConnectionResponse)) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.items) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.column_values) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.linked_item_ids) || [];
|
|
4082
4470
|
console.log('Existing IDs:', existingIds);
|
|
4083
4471
|
const newIds = columnValue.split(',').map((id) => id.trim());
|
|
4084
4472
|
const mergedIds = Array.from(new Set([...existingIds, ...newIds]));
|
|
@@ -4118,8 +4506,8 @@ class Worktables {
|
|
|
4118
4506
|
break;
|
|
4119
4507
|
case 'timeline':
|
|
4120
4508
|
column_values_object[columnId] = {
|
|
4121
|
-
from: (
|
|
4122
|
-
to: (
|
|
4509
|
+
from: (_j = col.startDate) === null || _j === void 0 ? void 0 : _j.split('T')[0],
|
|
4510
|
+
to: (_k = col.endDate) === null || _k === void 0 ? void 0 : _k.split('T')[0],
|
|
4123
4511
|
};
|
|
4124
4512
|
break;
|
|
4125
4513
|
case 'checkbox':
|
|
@@ -4140,7 +4528,7 @@ class Worktables {
|
|
|
4140
4528
|
};
|
|
4141
4529
|
break;
|
|
4142
4530
|
case 'dropdown':
|
|
4143
|
-
const dropdownLabels = (
|
|
4531
|
+
const dropdownLabels = (_l = col.dropdownValue) === null || _l === void 0 ? void 0 : _l.split(',').map((label) => label.trim()).filter(Boolean);
|
|
4144
4532
|
if (dropdownLabels === null || dropdownLabels === void 0 ? void 0 : dropdownLabels.length) {
|
|
4145
4533
|
column_values_object[columnId] = { labels: dropdownLabels };
|
|
4146
4534
|
}
|
|
@@ -4179,8 +4567,8 @@ class Worktables {
|
|
|
4179
4567
|
break;
|
|
4180
4568
|
case 'phone':
|
|
4181
4569
|
column_values_object[columnId] = {
|
|
4182
|
-
phone: `${(
|
|
4183
|
-
countryShortName: ((
|
|
4570
|
+
phone: `${(_m = col.countryCode) === null || _m === void 0 ? void 0 : _m.split(' ')[0]}${col.phoneValue || ''}`.replace(/[^\d+]/g, ''),
|
|
4571
|
+
countryShortName: ((_o = col.countryCode) === null || _o === void 0 ? void 0 : _o.split(' ')[1]) || '',
|
|
4184
4572
|
};
|
|
4185
4573
|
break;
|
|
4186
4574
|
case 'fileLink':
|
|
@@ -4213,7 +4601,7 @@ class Worktables {
|
|
|
4213
4601
|
});
|
|
4214
4602
|
try {
|
|
4215
4603
|
const buttonValue = JSON.parse(buttonResponse).data.items[0].column_values[0].value;
|
|
4216
|
-
const clicks = ((
|
|
4604
|
+
const clicks = ((_p = JSON.parse(buttonValue)) === null || _p === void 0 ? void 0 : _p.clicks) || 0;
|
|
4217
4605
|
column_values_object[columnId] = {
|
|
4218
4606
|
clicks: clicks + 1,
|
|
4219
4607
|
changed_at: new Date().toISOString(),
|
|
@@ -4280,6 +4668,7 @@ class Worktables {
|
|
|
4280
4668
|
headers: {
|
|
4281
4669
|
Authorization: `Bearer ${apiKey}`,
|
|
4282
4670
|
'Content-Type': 'application/json',
|
|
4671
|
+
'API-Version': API_VERSION,
|
|
4283
4672
|
},
|
|
4284
4673
|
body: {
|
|
4285
4674
|
query: `query {
|
|
@@ -4383,8 +4772,8 @@ class Worktables {
|
|
|
4383
4772
|
break;
|
|
4384
4773
|
case 'timeline':
|
|
4385
4774
|
{
|
|
4386
|
-
const from = ((
|
|
4387
|
-
const to = ((
|
|
4775
|
+
const from = ((_q = col.startDate) === null || _q === void 0 ? void 0 : _q.split('T')[0]) || '';
|
|
4776
|
+
const to = ((_r = col.endDate) === null || _r === void 0 ? void 0 : _r.split('T')[0]) || '';
|
|
4388
4777
|
column_values_object[columnId] = { from, to };
|
|
4389
4778
|
}
|
|
4390
4779
|
break;
|
|
@@ -4422,8 +4811,8 @@ class Worktables {
|
|
|
4422
4811
|
break;
|
|
4423
4812
|
case 'phone':
|
|
4424
4813
|
column_values_object[columnId] = {
|
|
4425
|
-
phone: `${(
|
|
4426
|
-
countryShortName: ((
|
|
4814
|
+
phone: `${(_s = col.countryCode) === null || _s === void 0 ? void 0 : _s.split(' ')[0]}${col.phoneValue || ''}`.replace(/[^\d+]/g, ''),
|
|
4815
|
+
countryShortName: ((_t = col.countryCode) === null || _t === void 0 ? void 0 : _t.split(' ')[1]) || '',
|
|
4427
4816
|
};
|
|
4428
4817
|
break;
|
|
4429
4818
|
case 'file':
|
|
@@ -4439,7 +4828,7 @@ class Worktables {
|
|
|
4439
4828
|
break;
|
|
4440
4829
|
case 'dropdown':
|
|
4441
4830
|
{
|
|
4442
|
-
const labels = (
|
|
4831
|
+
const labels = (_u = col.dropdownValue) === null || _u === void 0 ? void 0 : _u.split(',').map((t) => t.trim()).filter((t) => t);
|
|
4443
4832
|
if (labels && labels.length) {
|
|
4444
4833
|
column_values_object[columnId] = { labels };
|
|
4445
4834
|
}
|
|
@@ -4493,6 +4882,7 @@ class Worktables {
|
|
|
4493
4882
|
headers: {
|
|
4494
4883
|
Authorization: `Bearer ${apiKey}`,
|
|
4495
4884
|
'Content-Type': 'application/json',
|
|
4885
|
+
'API-Version': API_VERSION,
|
|
4496
4886
|
},
|
|
4497
4887
|
body: {
|
|
4498
4888
|
query: `query {
|
|
@@ -4554,6 +4944,7 @@ class Worktables {
|
|
|
4554
4944
|
headers: {
|
|
4555
4945
|
Authorization: `Bearer ${apiKey}`,
|
|
4556
4946
|
'Content-Type': 'application/json',
|
|
4947
|
+
'API-Version': API_VERSION,
|
|
4557
4948
|
},
|
|
4558
4949
|
body: { query: mutation },
|
|
4559
4950
|
});
|
|
@@ -4583,7 +4974,7 @@ class Worktables {
|
|
|
4583
4974
|
}
|
|
4584
4975
|
}
|
|
4585
4976
|
const parsedResponse = JSON.parse(responseRaw);
|
|
4586
|
-
const itemData = ((
|
|
4977
|
+
const itemData = ((_v = parsedResponse.data) === null || _v === void 0 ? void 0 : _v.create_item) || ((_w = parsedResponse.data) === null || _w === void 0 ? void 0 : _w.create_subitem);
|
|
4587
4978
|
const formattedResponse = {
|
|
4588
4979
|
id: itemData.id,
|
|
4589
4980
|
name: itemName,
|
|
@@ -4646,9 +5037,9 @@ class Worktables {
|
|
|
4646
5037
|
body: { query: discoverQuery },
|
|
4647
5038
|
});
|
|
4648
5039
|
const discoverData = JSON.parse(discoverResponse);
|
|
4649
|
-
const items = ((
|
|
5040
|
+
const items = ((_0 = (_z = (_y = (_x = discoverData === null || discoverData === void 0 ? void 0 : discoverData.data) === null || _x === void 0 ? void 0 : _x.boards) === null || _y === void 0 ? void 0 : _y[0]) === null || _z === void 0 ? void 0 : _z.items_page) === null || _0 === void 0 ? void 0 : _0.items) || [];
|
|
4650
5041
|
if (items.length > 0 && items[0].subitems && items[0].subitems.length > 0) {
|
|
4651
|
-
searchBoardId = ((
|
|
5042
|
+
searchBoardId = ((_1 = items[0].subitems[0].board) === null || _1 === void 0 ? void 0 : _1.id) || boardId;
|
|
4652
5043
|
console.log(`Discovered subitem board ID: ${searchBoardId}`);
|
|
4653
5044
|
}
|
|
4654
5045
|
}
|
|
@@ -4673,7 +5064,7 @@ class Worktables {
|
|
|
4673
5064
|
body: { query: columnTypeQuery },
|
|
4674
5065
|
});
|
|
4675
5066
|
const columnTypeData = JSON.parse(columnTypeResponse);
|
|
4676
|
-
const columns = ((
|
|
5067
|
+
const columns = ((_4 = (_3 = (_2 = columnTypeData === null || columnTypeData === void 0 ? void 0 : columnTypeData.data) === null || _2 === void 0 ? void 0 : _2.boards) === null || _3 === void 0 ? void 0 : _3[0]) === null || _4 === void 0 ? void 0 : _4.columns) || [];
|
|
4677
5068
|
if (columns.length > 0) {
|
|
4678
5069
|
columnType = columns[0].type;
|
|
4679
5070
|
console.log(`Column type detected: ${columnType}`);
|
|
@@ -4711,6 +5102,12 @@ class Worktables {
|
|
|
4711
5102
|
... on MirrorValue {
|
|
4712
5103
|
display_value
|
|
4713
5104
|
}
|
|
5105
|
+
... on DependencyValue {
|
|
5106
|
+
display_value
|
|
5107
|
+
}
|
|
5108
|
+
... on MirrorValue {
|
|
5109
|
+
display_value
|
|
5110
|
+
}
|
|
4714
5111
|
... on StatusValue {
|
|
4715
5112
|
text
|
|
4716
5113
|
index
|
|
@@ -4726,7 +5123,7 @@ class Worktables {
|
|
|
4726
5123
|
body: { query: parentQuery },
|
|
4727
5124
|
});
|
|
4728
5125
|
const searchData = JSON.parse(searchResponse);
|
|
4729
|
-
const items = ((
|
|
5126
|
+
const items = ((_5 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _5 === void 0 ? void 0 : _5.items) || [];
|
|
4730
5127
|
if (items.length > 0 && items[0].subitems) {
|
|
4731
5128
|
const subitems = items[0].subitems;
|
|
4732
5129
|
console.log(`🔍 Searching subitems of parent ${parentId}, found ${subitems.length} subitem(s)`);
|
|
@@ -4738,7 +5135,7 @@ class Worktables {
|
|
|
4738
5135
|
matches = subitemName === searchValue;
|
|
4739
5136
|
}
|
|
4740
5137
|
else {
|
|
4741
|
-
const colValue = (
|
|
5138
|
+
const colValue = (_6 = subitem.column_values) === null || _6 === void 0 ? void 0 : _6.find((cv) => cv.id === identifierColumn);
|
|
4742
5139
|
if (colValue) {
|
|
4743
5140
|
const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
|
|
4744
5141
|
const isStatusColumn = colValue.type === 'status';
|
|
@@ -4756,7 +5153,7 @@ class Worktables {
|
|
|
4756
5153
|
}
|
|
4757
5154
|
if (matches) {
|
|
4758
5155
|
foundItemId = subitem.id;
|
|
4759
|
-
foundItemBoardId = ((
|
|
5156
|
+
foundItemBoardId = ((_7 = subitem.board) === null || _7 === void 0 ? void 0 : _7.id) || null;
|
|
4760
5157
|
console.log(`✓ Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
|
|
4761
5158
|
break;
|
|
4762
5159
|
}
|
|
@@ -4793,6 +5190,9 @@ class Worktables {
|
|
|
4793
5190
|
... on MirrorValue {
|
|
4794
5191
|
display_value
|
|
4795
5192
|
}
|
|
5193
|
+
... on DependencyValue {
|
|
5194
|
+
display_value
|
|
5195
|
+
}
|
|
4796
5196
|
... on StatusValue {
|
|
4797
5197
|
text
|
|
4798
5198
|
index
|
|
@@ -4810,7 +5210,7 @@ class Worktables {
|
|
|
4810
5210
|
body: { query },
|
|
4811
5211
|
});
|
|
4812
5212
|
const searchData = JSON.parse(searchResponse);
|
|
4813
|
-
const itemsPage = (
|
|
5213
|
+
const itemsPage = (_10 = (_9 = (_8 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _8 === void 0 ? void 0 : _8.boards) === null || _9 === void 0 ? void 0 : _9[0]) === null || _10 === void 0 ? void 0 : _10.items_page;
|
|
4814
5214
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
4815
5215
|
console.log(`🔍 Optimized search found ${items.length} item(s) matching identifier`);
|
|
4816
5216
|
for (const item of items) {
|
|
@@ -4821,7 +5221,7 @@ class Worktables {
|
|
|
4821
5221
|
matches = itemName === searchValue;
|
|
4822
5222
|
}
|
|
4823
5223
|
else {
|
|
4824
|
-
const colValue = (
|
|
5224
|
+
const colValue = (_11 = item.column_values) === null || _11 === void 0 ? void 0 : _11.find((cv) => cv.id === identifierColumn);
|
|
4825
5225
|
if (colValue) {
|
|
4826
5226
|
const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
|
|
4827
5227
|
const isStatusColumn = colValue.type === 'status';
|
|
@@ -4894,7 +5294,7 @@ class Worktables {
|
|
|
4894
5294
|
id: itemData.id,
|
|
4895
5295
|
url: itemData.url || '',
|
|
4896
5296
|
operation: 'update',
|
|
4897
|
-
board_id: ((
|
|
5297
|
+
board_id: ((_12 = itemData.board) === null || _12 === void 0 ? void 0 : _12.id) || boardId,
|
|
4898
5298
|
column_values: column_values_object,
|
|
4899
5299
|
};
|
|
4900
5300
|
itemUpdated = true;
|
|
@@ -4990,8 +5390,8 @@ class Worktables {
|
|
|
4990
5390
|
});
|
|
4991
5391
|
}
|
|
4992
5392
|
const itemData = isSubitem && parentId
|
|
4993
|
-
? (
|
|
4994
|
-
: (
|
|
5393
|
+
? (_13 = responseData.data) === null || _13 === void 0 ? void 0 : _13.create_subitem
|
|
5394
|
+
: (_14 = responseData.data) === null || _14 === void 0 ? void 0 : _14.create_item;
|
|
4995
5395
|
if (!itemData || !itemData.id) {
|
|
4996
5396
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
4997
5397
|
message: `Error creating ${isSubitem ? 'subitem' : 'item'}: No item data returned`,
|
|
@@ -5002,7 +5402,7 @@ class Worktables {
|
|
|
5002
5402
|
name: itemData.name || itemName,
|
|
5003
5403
|
url: itemData.url || '',
|
|
5004
5404
|
operation: 'create',
|
|
5005
|
-
board_id: ((
|
|
5405
|
+
board_id: ((_15 = itemData.board) === null || _15 === void 0 ? void 0 : _15.id) || boardId,
|
|
5006
5406
|
column_values: column_values_object,
|
|
5007
5407
|
};
|
|
5008
5408
|
if (isSubitem && parentId) {
|
|
@@ -5015,6 +5415,7 @@ class Worktables {
|
|
|
5015
5415
|
const itemId = this.getNodeParameter('itemId', 0);
|
|
5016
5416
|
const from = this.getNodeParameter('from', 0, '');
|
|
5017
5417
|
const to = this.getNodeParameter('to', 0, '');
|
|
5418
|
+
const limit = this.getNodeParameter('limit', 0, 50);
|
|
5018
5419
|
if (!itemId) {
|
|
5019
5420
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Item ID is required.' });
|
|
5020
5421
|
}
|
|
@@ -5043,56 +5444,82 @@ class Worktables {
|
|
|
5043
5444
|
if (itemParsed.errors) {
|
|
5044
5445
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(itemParsed.errors) });
|
|
5045
5446
|
}
|
|
5046
|
-
const items = ((
|
|
5447
|
+
const items = ((_16 = itemParsed === null || itemParsed === void 0 ? void 0 : itemParsed.data) === null || _16 === void 0 ? void 0 : _16.items) || [];
|
|
5047
5448
|
if (items.length === 0) {
|
|
5048
5449
|
return [[{ json: { item_id: itemId, activity_logs: [] } }]];
|
|
5049
5450
|
}
|
|
5050
5451
|
const item = items[0];
|
|
5051
|
-
const boardId = (
|
|
5452
|
+
const boardId = (_17 = item.board) === null || _17 === void 0 ? void 0 : _17.id;
|
|
5052
5453
|
if (!boardId) {
|
|
5053
5454
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Could not retrieve board ID for the item.' });
|
|
5054
5455
|
}
|
|
5055
|
-
const
|
|
5456
|
+
const baseParams = [`item_ids: ["${itemId}"]`];
|
|
5056
5457
|
if (from) {
|
|
5057
|
-
|
|
5458
|
+
baseParams.push(`from: "${from}Z"`);
|
|
5058
5459
|
}
|
|
5059
5460
|
if (to) {
|
|
5060
|
-
|
|
5461
|
+
baseParams.push(`to: "${to}Z"`);
|
|
5061
5462
|
}
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5463
|
+
let allLogs = [];
|
|
5464
|
+
let page = 1;
|
|
5465
|
+
const pageLimit = 100;
|
|
5466
|
+
do {
|
|
5467
|
+
const params = [...baseParams];
|
|
5468
|
+
params.push(`page: ${page}`);
|
|
5469
|
+
if (limit === 0) {
|
|
5470
|
+
params.push(`limit: ${pageLimit}`);
|
|
5471
|
+
}
|
|
5472
|
+
else {
|
|
5473
|
+
const remaining = limit - allLogs.length;
|
|
5474
|
+
const currentLimit = remaining > pageLimit ? pageLimit : remaining;
|
|
5475
|
+
params.push(`limit: ${currentLimit}`);
|
|
5476
|
+
}
|
|
5477
|
+
const paramsString = params.join(', ');
|
|
5478
|
+
const query = `
|
|
5479
|
+
query {
|
|
5480
|
+
boards(ids: [${boardId}]) {
|
|
5481
|
+
activity_logs(${paramsString}) {
|
|
5482
|
+
id
|
|
5483
|
+
user_id
|
|
5484
|
+
entity
|
|
5485
|
+
event
|
|
5486
|
+
data
|
|
5487
|
+
account_id
|
|
5488
|
+
created_at
|
|
5489
|
+
}
|
|
5074
5490
|
}
|
|
5075
5491
|
}
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5492
|
+
`;
|
|
5493
|
+
console.log('Activity Logs Query: ', query);
|
|
5494
|
+
const rawResponse = await this.helpers.request({
|
|
5495
|
+
method: 'POST',
|
|
5496
|
+
url: 'https://api.monday.com/v2',
|
|
5497
|
+
headers,
|
|
5498
|
+
body: { query },
|
|
5499
|
+
});
|
|
5500
|
+
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
5501
|
+
if (parsed.errors) {
|
|
5502
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(parsed.errors) });
|
|
5503
|
+
}
|
|
5504
|
+
const boards = ((_18 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _18 === void 0 ? void 0 : _18.boards) || [];
|
|
5505
|
+
const logs = boards.length > 0 ? (boards[0].activity_logs || []) : [];
|
|
5506
|
+
allLogs = allLogs.concat(logs);
|
|
5507
|
+
if (logs.length < pageLimit) {
|
|
5508
|
+
break;
|
|
5509
|
+
}
|
|
5510
|
+
if (limit > 0 && allLogs.length >= limit) {
|
|
5511
|
+
if (allLogs.length > limit) {
|
|
5512
|
+
allLogs = allLogs.slice(0, limit);
|
|
5513
|
+
}
|
|
5514
|
+
break;
|
|
5515
|
+
}
|
|
5516
|
+
page++;
|
|
5517
|
+
} while (true);
|
|
5091
5518
|
const formatted = {
|
|
5092
5519
|
item_id: item.id,
|
|
5093
5520
|
item_name: item.name,
|
|
5094
5521
|
board_id: boardId,
|
|
5095
|
-
activity_logs:
|
|
5522
|
+
activity_logs: allLogs.map((log) => {
|
|
5096
5523
|
let parsedData = log.data;
|
|
5097
5524
|
if (typeof log.data === 'string') {
|
|
5098
5525
|
try {
|
|
@@ -5164,27 +5591,72 @@ class Worktables {
|
|
|
5164
5591
|
console.log('List items in a board');
|
|
5165
5592
|
const boardId = this.getNodeParameter('boardId', 0);
|
|
5166
5593
|
const limit = this.getNodeParameter('limit', 0);
|
|
5594
|
+
const fetchAllColumns = this.getNodeParameter('fetchAllColumns', 0, true);
|
|
5595
|
+
const columnIdsRaw = this.getNodeParameter('columnIds', 0, '');
|
|
5167
5596
|
if (!boardId) {
|
|
5168
5597
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Board ID is required.' });
|
|
5169
5598
|
}
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5599
|
+
let queryColumnValues = '';
|
|
5600
|
+
if (fetchAllColumns) {
|
|
5601
|
+
queryColumnValues = `
|
|
5602
|
+
column_values {
|
|
5603
|
+
id
|
|
5604
|
+
text
|
|
5605
|
+
value
|
|
5606
|
+
type
|
|
5607
|
+
... on BoardRelationValue {
|
|
5608
|
+
display_value
|
|
5609
|
+
linked_item_ids
|
|
5610
|
+
}
|
|
5611
|
+
... on MirrorValue {
|
|
5612
|
+
display_value
|
|
5613
|
+
mirrored_items {
|
|
5614
|
+
linked_board_id
|
|
5615
|
+
}
|
|
5616
|
+
}
|
|
5617
|
+
... on DependencyValue {
|
|
5618
|
+
display_value
|
|
5619
|
+
linked_item_ids
|
|
5620
|
+
linked_items {
|
|
5621
|
+
id
|
|
5622
|
+
name
|
|
5623
|
+
}
|
|
5184
5624
|
}
|
|
5185
5625
|
}
|
|
5186
|
-
|
|
5187
|
-
|
|
5626
|
+
`;
|
|
5627
|
+
}
|
|
5628
|
+
else if (columnIdsRaw && columnIdsRaw.trim()) {
|
|
5629
|
+
const specificColumnIds = columnIdsRaw.split(',').map(id => id.trim()).filter(id => id);
|
|
5630
|
+
if (specificColumnIds.length > 0) {
|
|
5631
|
+
const columnIdsString = specificColumnIds.map(id => `"${id}"`).join(', ');
|
|
5632
|
+
queryColumnValues = `
|
|
5633
|
+
column_values(ids: [${columnIdsString}]) {
|
|
5634
|
+
id
|
|
5635
|
+
text
|
|
5636
|
+
value
|
|
5637
|
+
type
|
|
5638
|
+
... on BoardRelationValue {
|
|
5639
|
+
display_value
|
|
5640
|
+
linked_item_ids
|
|
5641
|
+
}
|
|
5642
|
+
... on MirrorValue {
|
|
5643
|
+
display_value
|
|
5644
|
+
mirrored_items {
|
|
5645
|
+
linked_board_id
|
|
5646
|
+
}
|
|
5647
|
+
}
|
|
5648
|
+
... on DependencyValue {
|
|
5649
|
+
display_value
|
|
5650
|
+
linked_item_ids
|
|
5651
|
+
linked_items {
|
|
5652
|
+
id
|
|
5653
|
+
name
|
|
5654
|
+
}
|
|
5655
|
+
}
|
|
5656
|
+
}
|
|
5657
|
+
`;
|
|
5658
|
+
}
|
|
5659
|
+
}
|
|
5188
5660
|
const querySubitems = `
|
|
5189
5661
|
subitems {
|
|
5190
5662
|
id
|
|
@@ -5245,7 +5717,7 @@ class Worktables {
|
|
|
5245
5717
|
body: { query },
|
|
5246
5718
|
});
|
|
5247
5719
|
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
5248
|
-
const itemsPage = (
|
|
5720
|
+
const itemsPage = (_21 = (_20 = (_19 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _19 === void 0 ? void 0 : _19.boards) === null || _20 === void 0 ? void 0 : _20[0]) === null || _21 === void 0 ? void 0 : _21.items_page;
|
|
5249
5721
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5250
5722
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
5251
5723
|
allItems = allItems.concat(items);
|
|
@@ -5320,11 +5792,13 @@ class Worktables {
|
|
|
5320
5792
|
case 'searchItems': {
|
|
5321
5793
|
const boardId = this.getNodeParameter('boardId', 0);
|
|
5322
5794
|
const fetchColumnValues = this.getNodeParameter('fetchColumnValues', 0, false);
|
|
5795
|
+
const fetchAllColumns = this.getNodeParameter('fetchAllColumns', 0, true);
|
|
5796
|
+
const columnIdsRaw = this.getNodeParameter('columnIds', 0, '');
|
|
5323
5797
|
const filterRules = this.getNodeParameter('filterRules', 0);
|
|
5324
5798
|
const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
|
|
5325
5799
|
const logicalOperator = this.getNodeParameter('logicalOperator', 0);
|
|
5326
5800
|
let rulesArray = [];
|
|
5327
|
-
if (((
|
|
5801
|
+
if (((_22 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _22 === void 0 ? void 0 : _22.length) > 0) {
|
|
5328
5802
|
rulesArray = filterRules.rule.map((rule) => {
|
|
5329
5803
|
let formattedValue;
|
|
5330
5804
|
if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
|
|
@@ -5368,7 +5842,7 @@ class Worktables {
|
|
|
5368
5842
|
});
|
|
5369
5843
|
}
|
|
5370
5844
|
const orderByArray = [];
|
|
5371
|
-
if (((
|
|
5845
|
+
if (((_23 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _23 === void 0 ? void 0 : _23.length) > 0) {
|
|
5372
5846
|
sortOptions.sortBy.forEach((sort) => {
|
|
5373
5847
|
orderByArray.push(`{
|
|
5374
5848
|
column_id: "${sort.columnId}",
|
|
@@ -5376,17 +5850,42 @@ class Worktables {
|
|
|
5376
5850
|
}`);
|
|
5377
5851
|
});
|
|
5378
5852
|
}
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
${orderByArray.length > 0 ? `order_by: [${orderByArray.join(', ')}]` : ''}
|
|
5385
|
-
}) {
|
|
5386
|
-
items {
|
|
5853
|
+
let queryColumnValues = '';
|
|
5854
|
+
if (fetchColumnValues) {
|
|
5855
|
+
if (fetchAllColumns) {
|
|
5856
|
+
queryColumnValues = `
|
|
5857
|
+
column_values {
|
|
5387
5858
|
id
|
|
5388
|
-
|
|
5389
|
-
|
|
5859
|
+
text
|
|
5860
|
+
value
|
|
5861
|
+
type
|
|
5862
|
+
... on BoardRelationValue {
|
|
5863
|
+
display_value
|
|
5864
|
+
linked_item_ids
|
|
5865
|
+
}
|
|
5866
|
+
... on MirrorValue {
|
|
5867
|
+
display_value
|
|
5868
|
+
mirrored_items {
|
|
5869
|
+
linked_board_id
|
|
5870
|
+
}
|
|
5871
|
+
}
|
|
5872
|
+
... on DependencyValue {
|
|
5873
|
+
display_value
|
|
5874
|
+
linked_item_ids
|
|
5875
|
+
linked_items {
|
|
5876
|
+
id
|
|
5877
|
+
name
|
|
5878
|
+
}
|
|
5879
|
+
}
|
|
5880
|
+
}
|
|
5881
|
+
`;
|
|
5882
|
+
}
|
|
5883
|
+
else if (columnIdsRaw && columnIdsRaw.trim()) {
|
|
5884
|
+
const specificColumnIds = columnIdsRaw.split(',').map(id => id.trim()).filter(id => id);
|
|
5885
|
+
if (specificColumnIds.length > 0) {
|
|
5886
|
+
const columnIdsString = specificColumnIds.map(id => `"${id}"`).join(', ');
|
|
5887
|
+
queryColumnValues = `
|
|
5888
|
+
column_values(ids: [${columnIdsString}]) {
|
|
5390
5889
|
id
|
|
5391
5890
|
text
|
|
5392
5891
|
value
|
|
@@ -5401,7 +5900,30 @@ class Worktables {
|
|
|
5401
5900
|
linked_board_id
|
|
5402
5901
|
}
|
|
5403
5902
|
}
|
|
5903
|
+
... on DependencyValue {
|
|
5904
|
+
display_value
|
|
5905
|
+
linked_item_ids
|
|
5906
|
+
linked_items {
|
|
5907
|
+
id
|
|
5908
|
+
name
|
|
5909
|
+
}
|
|
5910
|
+
}
|
|
5404
5911
|
}
|
|
5912
|
+
`;
|
|
5913
|
+
}
|
|
5914
|
+
}
|
|
5915
|
+
}
|
|
5916
|
+
const query = `query {
|
|
5917
|
+
boards(ids: [${boardId}]) {
|
|
5918
|
+
items_page(limit: 100, query_params: {
|
|
5919
|
+
${logicalOperator ? `operator: ${logicalOperator},` : ''}
|
|
5920
|
+
${rulesArray.length > 0 ? `rules: [${rulesArray.join(', ')}],` : ''}
|
|
5921
|
+
${orderByArray.length > 0 ? `order_by: [${orderByArray.join(', ')}]` : ''}
|
|
5922
|
+
}) {
|
|
5923
|
+
items {
|
|
5924
|
+
id
|
|
5925
|
+
name
|
|
5926
|
+
${queryColumnValues}
|
|
5405
5927
|
group {
|
|
5406
5928
|
id
|
|
5407
5929
|
title
|
|
@@ -5424,7 +5946,7 @@ class Worktables {
|
|
|
5424
5946
|
body: { query },
|
|
5425
5947
|
});
|
|
5426
5948
|
const parsed = JSON.parse(rawResponse);
|
|
5427
|
-
const items = ((
|
|
5949
|
+
const items = ((_27 = (_26 = (_25 = (_24 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _24 === void 0 ? void 0 : _24.boards) === null || _25 === void 0 ? void 0 : _25[0]) === null || _26 === void 0 ? void 0 : _26.items_page) === null || _27 === void 0 ? void 0 : _27.items) || [];
|
|
5428
5950
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
5429
5951
|
const formatted = {
|
|
5430
5952
|
id: item.id,
|
|
@@ -5458,7 +5980,7 @@ class Worktables {
|
|
|
5458
5980
|
const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
|
|
5459
5981
|
const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
|
|
5460
5982
|
let rulesArray = [];
|
|
5461
|
-
if (((
|
|
5983
|
+
if (((_28 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _28 === void 0 ? void 0 : _28.length) > 0) {
|
|
5462
5984
|
console.log('Processing filter rules:', advancedFilterRules.rule);
|
|
5463
5985
|
rulesArray = advancedFilterRules.rule.map((rule) => {
|
|
5464
5986
|
let formattedValue;
|
|
@@ -5674,7 +6196,7 @@ class Worktables {
|
|
|
5674
6196
|
});
|
|
5675
6197
|
}
|
|
5676
6198
|
const orderByArray = [];
|
|
5677
|
-
if (((
|
|
6199
|
+
if (((_29 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _29 === void 0 ? void 0 : _29.length) > 0) {
|
|
5678
6200
|
advancedSortOptions.sortBy.forEach((sort) => {
|
|
5679
6201
|
orderByArray.push(`{
|
|
5680
6202
|
column_id: "${sort.columnId}",
|
|
@@ -5708,6 +6230,14 @@ class Worktables {
|
|
|
5708
6230
|
linked_board_id
|
|
5709
6231
|
}
|
|
5710
6232
|
}
|
|
6233
|
+
... on DependencyValue {
|
|
6234
|
+
display_value
|
|
6235
|
+
linked_item_ids
|
|
6236
|
+
linked_items {
|
|
6237
|
+
id
|
|
6238
|
+
name
|
|
6239
|
+
}
|
|
6240
|
+
}
|
|
5711
6241
|
}
|
|
5712
6242
|
group {
|
|
5713
6243
|
id
|
|
@@ -5756,7 +6286,7 @@ class Worktables {
|
|
|
5756
6286
|
body: { query: testQuery },
|
|
5757
6287
|
});
|
|
5758
6288
|
const testParsed = JSON.parse(testResponse);
|
|
5759
|
-
const testItems = ((
|
|
6289
|
+
const testItems = ((_33 = (_32 = (_31 = (_30 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.data) === null || _30 === void 0 ? void 0 : _30.boards) === null || _31 === void 0 ? void 0 : _31[0]) === null || _32 === void 0 ? void 0 : _32.items_page) === null || _33 === void 0 ? void 0 : _33.items) || [];
|
|
5760
6290
|
console.log('Test - Items in board (no filters):', testItems.length);
|
|
5761
6291
|
if (testItems.length > 0) {
|
|
5762
6292
|
console.log('Sample item column values:', testItems[0].column_values);
|
|
@@ -5768,7 +6298,7 @@ class Worktables {
|
|
|
5768
6298
|
body: { query },
|
|
5769
6299
|
});
|
|
5770
6300
|
const parsed = JSON.parse(rawResponse);
|
|
5771
|
-
const itemsPage = (
|
|
6301
|
+
const itemsPage = (_36 = (_35 = (_34 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _34 === void 0 ? void 0 : _34.boards) === null || _35 === void 0 ? void 0 : _35[0]) === null || _36 === void 0 ? void 0 : _36.items_page;
|
|
5772
6302
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5773
6303
|
const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
|
|
5774
6304
|
const hasMore = nextCursor ? true : false;
|
|
@@ -5847,16 +6377,17 @@ class Worktables {
|
|
|
5847
6377
|
console.warn(`Binary field '${binaryName}' not found. Skipping.`);
|
|
5848
6378
|
continue;
|
|
5849
6379
|
}
|
|
5850
|
-
const fileBuffer =
|
|
6380
|
+
const fileBuffer = await this.helpers.getBinaryDataBuffer(0, binaryName);
|
|
5851
6381
|
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension);
|
|
5852
|
-
console.log('Binary
|
|
6382
|
+
console.log('Binary Meta:', binaryData);
|
|
5853
6383
|
console.log('fileName:', fileName);
|
|
6384
|
+
console.log('buffer length:', fileBuffer.length);
|
|
5854
6385
|
const form = new form_data_1.default();
|
|
5855
6386
|
form.append('query', `mutation ($file: File!) {
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
6387
|
+
add_file_to_column (file: $file, item_id: ${itemId}, column_id: "${columnId}") {
|
|
6388
|
+
id
|
|
6389
|
+
}
|
|
6390
|
+
}`);
|
|
5860
6391
|
form.append('variables[file]', fileBuffer, {
|
|
5861
6392
|
filename: fileName,
|
|
5862
6393
|
contentType: binaryData.mimeType || 'application/octet-stream',
|
|
@@ -5864,13 +6395,14 @@ class Worktables {
|
|
|
5864
6395
|
const uploadFile = await axios_1.default.post('https://api.monday.com/v2/file', form, {
|
|
5865
6396
|
headers: {
|
|
5866
6397
|
Authorization: headers.Authorization,
|
|
5867
|
-
'API-Version':
|
|
6398
|
+
'API-Version': API_VERSION,
|
|
5868
6399
|
...form.getHeaders(),
|
|
5869
6400
|
},
|
|
5870
6401
|
maxContentLength: Infinity,
|
|
5871
6402
|
maxBodyLength: Infinity,
|
|
5872
6403
|
});
|
|
5873
6404
|
console.log(`Upload response for '${binaryName}':`, uploadFile.data);
|
|
6405
|
+
console.log('HERRRRRRROOOOO');
|
|
5874
6406
|
response = JSON.stringify(uploadFile.data);
|
|
5875
6407
|
}
|
|
5876
6408
|
break;
|
|
@@ -5879,29 +6411,74 @@ class Worktables {
|
|
|
5879
6411
|
const boardId = this.getNodeParameter('boardId', 0);
|
|
5880
6412
|
const groupId = this.getNodeParameter('groupId', 0);
|
|
5881
6413
|
const limit = this.getNodeParameter('limit', 0);
|
|
6414
|
+
const fetchAllColumns = this.getNodeParameter('fetchAllColumns', 0, true);
|
|
6415
|
+
const columnIdsRaw = this.getNodeParameter('columnIds', 0, '');
|
|
5882
6416
|
if (!boardId || !groupId) {
|
|
5883
6417
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5884
6418
|
message: 'Board ID and Group ID are required.',
|
|
5885
6419
|
});
|
|
5886
6420
|
}
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
6421
|
+
let queryColumnValues = '';
|
|
6422
|
+
if (fetchAllColumns) {
|
|
6423
|
+
queryColumnValues = `
|
|
6424
|
+
column_values {
|
|
6425
|
+
id
|
|
6426
|
+
text
|
|
6427
|
+
value
|
|
6428
|
+
type
|
|
6429
|
+
... on BoardRelationValue {
|
|
6430
|
+
display_value
|
|
6431
|
+
linked_item_ids
|
|
6432
|
+
}
|
|
6433
|
+
... on MirrorValue {
|
|
6434
|
+
display_value
|
|
6435
|
+
mirrored_items {
|
|
6436
|
+
linked_board_id
|
|
6437
|
+
}
|
|
6438
|
+
}
|
|
6439
|
+
... on DependencyValue {
|
|
6440
|
+
display_value
|
|
6441
|
+
linked_item_ids
|
|
6442
|
+
linked_items {
|
|
6443
|
+
id
|
|
6444
|
+
name
|
|
6445
|
+
}
|
|
5901
6446
|
}
|
|
5902
6447
|
}
|
|
5903
|
-
|
|
5904
|
-
|
|
6448
|
+
`;
|
|
6449
|
+
}
|
|
6450
|
+
else if (columnIdsRaw && columnIdsRaw.trim()) {
|
|
6451
|
+
const specificColumnIds = columnIdsRaw.split(',').map(id => id.trim()).filter(id => id);
|
|
6452
|
+
if (specificColumnIds.length > 0) {
|
|
6453
|
+
const columnIdsString = specificColumnIds.map(id => `"${id}"`).join(', ');
|
|
6454
|
+
queryColumnValues = `
|
|
6455
|
+
column_values(ids: [${columnIdsString}]) {
|
|
6456
|
+
id
|
|
6457
|
+
text
|
|
6458
|
+
value
|
|
6459
|
+
type
|
|
6460
|
+
... on BoardRelationValue {
|
|
6461
|
+
display_value
|
|
6462
|
+
linked_item_ids
|
|
6463
|
+
}
|
|
6464
|
+
... on MirrorValue {
|
|
6465
|
+
display_value
|
|
6466
|
+
mirrored_items {
|
|
6467
|
+
linked_board_id
|
|
6468
|
+
}
|
|
6469
|
+
}
|
|
6470
|
+
... on DependencyValue {
|
|
6471
|
+
display_value
|
|
6472
|
+
linked_item_ids
|
|
6473
|
+
linked_items {
|
|
6474
|
+
id
|
|
6475
|
+
name
|
|
6476
|
+
}
|
|
6477
|
+
}
|
|
6478
|
+
}
|
|
6479
|
+
`;
|
|
6480
|
+
}
|
|
6481
|
+
}
|
|
5905
6482
|
let allItems = [];
|
|
5906
6483
|
let cursor = null;
|
|
5907
6484
|
const pageLimit = 100;
|
|
@@ -5950,7 +6527,7 @@ class Worktables {
|
|
|
5950
6527
|
body: { query },
|
|
5951
6528
|
});
|
|
5952
6529
|
const parsed = JSON.parse(rawResponse);
|
|
5953
|
-
const itemsPage = (_40 = (_39 = (_38 = (_37 =
|
|
6530
|
+
const itemsPage = (_41 = (_40 = (_39 = (_38 = (_37 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _37 === void 0 ? void 0 : _37.boards) === null || _38 === void 0 ? void 0 : _38[0]) === null || _39 === void 0 ? void 0 : _39.groups) === null || _40 === void 0 ? void 0 : _40[0]) === null || _41 === void 0 ? void 0 : _41.items_page;
|
|
5954
6531
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5955
6532
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
5956
6533
|
allItems = allItems.concat(items);
|
|
@@ -6003,84 +6580,121 @@ class Worktables {
|
|
|
6003
6580
|
break;
|
|
6004
6581
|
}
|
|
6005
6582
|
case 'update': {
|
|
6583
|
+
console.log(`>>>>>> UPDATE RESOURCE - operation: "${operation}" - v1.0.28 <<<<<<`);
|
|
6006
6584
|
switch (operation) {
|
|
6007
6585
|
case 'listUpdates': {
|
|
6008
6586
|
const itemId = this.getNodeParameter('itemId', 0);
|
|
6009
|
-
const
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6587
|
+
const limit = this.getNodeParameter('limit', 0, 25);
|
|
6588
|
+
const fromDate = this.getNodeParameter('fromDate', 0, '');
|
|
6589
|
+
const toDate = this.getNodeParameter('toDate', 0, '');
|
|
6590
|
+
const updatesParams = [];
|
|
6591
|
+
if (limit > 0) {
|
|
6592
|
+
updatesParams.push(`limit: ${limit}`);
|
|
6593
|
+
}
|
|
6594
|
+
let allUpdates = [];
|
|
6595
|
+
let page = 1;
|
|
6596
|
+
const pageLimit = limit === 0 ? 100 : limit;
|
|
6597
|
+
do {
|
|
6598
|
+
const currentParams = [...updatesParams];
|
|
6599
|
+
if (limit === 0) {
|
|
6600
|
+
currentParams.push(`limit: ${pageLimit}`);
|
|
6601
|
+
currentParams.push(`page: ${page}`);
|
|
6602
|
+
}
|
|
6603
|
+
const paramsString = currentParams.length > 0 ? `(${currentParams.join(', ')})` : '';
|
|
6604
|
+
const query = `
|
|
6605
|
+
query {
|
|
6606
|
+
items (ids: [${itemId}]) {
|
|
6607
|
+
updates${paramsString} {
|
|
6608
|
+
id
|
|
6609
|
+
text_body
|
|
6610
|
+
created_at
|
|
6611
|
+
updated_at
|
|
6612
|
+
creator {
|
|
6613
|
+
id
|
|
6614
|
+
name
|
|
6615
|
+
}
|
|
6616
|
+
assets {
|
|
6617
|
+
name
|
|
6618
|
+
public_url
|
|
6619
|
+
file_size
|
|
6620
|
+
}
|
|
6621
|
+
replies {
|
|
6622
|
+
text_body
|
|
6623
|
+
created_at
|
|
6624
|
+
creator {
|
|
6625
|
+
name
|
|
6626
|
+
}
|
|
6627
|
+
}
|
|
6628
|
+
pinned_to_top {
|
|
6629
|
+
item_id
|
|
6630
|
+
}
|
|
6031
6631
|
}
|
|
6032
6632
|
}
|
|
6033
|
-
pinned_to_top {
|
|
6034
|
-
item_id
|
|
6035
|
-
}
|
|
6036
|
-
}
|
|
6037
|
-
}
|
|
6038
6633
|
}
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
body: { query },
|
|
6046
|
-
});
|
|
6047
|
-
response = await (0, isErrorResponse_1.parseApiResponse)(response);
|
|
6048
|
-
if (response.success) {
|
|
6049
|
-
const parsed = JSON.parse(response.data);
|
|
6050
|
-
const updates = ((_43 = (_42 = (_41 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _41 === void 0 ? void 0 : _41.items) === null || _42 === void 0 ? void 0 : _42[0]) === null || _43 === void 0 ? void 0 : _43.updates) || [];
|
|
6051
|
-
const formattedUpdates = updates.map((update) => {
|
|
6052
|
-
const pinnedToTop = update.pinned_to_top || [];
|
|
6053
|
-
const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
|
|
6054
|
-
return {
|
|
6055
|
-
...update,
|
|
6056
|
-
pinned_to_top: isPinnedToTop,
|
|
6057
|
-
};
|
|
6634
|
+
`;
|
|
6635
|
+
const rawResponse = await this.helpers.request({
|
|
6636
|
+
method: 'POST',
|
|
6637
|
+
url: 'https://api.monday.com/v2',
|
|
6638
|
+
headers,
|
|
6639
|
+
body: { query },
|
|
6058
6640
|
});
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6641
|
+
const parsedResponse = await (0, isErrorResponse_1.parseApiResponse)(rawResponse);
|
|
6642
|
+
if (!parsedResponse.success) {
|
|
6643
|
+
const parsed = JSON.parse(parsedResponse.data);
|
|
6644
|
+
const firstError = parsed.errors || { message: 'Unknown error' };
|
|
6645
|
+
const errorData = Array.isArray(firstError) ? firstError[0] : firstError;
|
|
6646
|
+
const continueOnFail = this.continueOnFail();
|
|
6647
|
+
if (continueOnFail) {
|
|
6648
|
+
return [[{
|
|
6649
|
+
json: {
|
|
6650
|
+
error: {
|
|
6651
|
+
message: errorData.message || 'Unknown error',
|
|
6652
|
+
details: errorData,
|
|
6653
|
+
}
|
|
6072
6654
|
}
|
|
6073
|
-
}
|
|
6074
|
-
|
|
6655
|
+
}]];
|
|
6656
|
+
}
|
|
6657
|
+
else {
|
|
6658
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6659
|
+
message: errorData.message || 'Failed to list updates',
|
|
6660
|
+
});
|
|
6661
|
+
}
|
|
6075
6662
|
}
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6663
|
+
const parsed = JSON.parse(parsedResponse.data);
|
|
6664
|
+
const updates = ((_44 = (_43 = (_42 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _42 === void 0 ? void 0 : _42.items) === null || _43 === void 0 ? void 0 : _43[0]) === null || _44 === void 0 ? void 0 : _44.updates) || [];
|
|
6665
|
+
if (updates.length === 0) {
|
|
6666
|
+
break;
|
|
6667
|
+
}
|
|
6668
|
+
allUpdates = allUpdates.concat(updates);
|
|
6669
|
+
page++;
|
|
6670
|
+
if (limit > 0 || updates.length < pageLimit) {
|
|
6671
|
+
break;
|
|
6082
6672
|
}
|
|
6673
|
+
} while (limit === 0);
|
|
6674
|
+
let filteredUpdates = allUpdates;
|
|
6675
|
+
if (fromDate) {
|
|
6676
|
+
const fromDateTime = new Date(fromDate).getTime();
|
|
6677
|
+
filteredUpdates = filteredUpdates.filter((update) => {
|
|
6678
|
+
const updateDate = new Date(update.created_at).getTime();
|
|
6679
|
+
return updateDate >= fromDateTime;
|
|
6680
|
+
});
|
|
6681
|
+
}
|
|
6682
|
+
if (toDate) {
|
|
6683
|
+
const toDateTime = new Date(toDate).getTime();
|
|
6684
|
+
filteredUpdates = filteredUpdates.filter((update) => {
|
|
6685
|
+
const updateDate = new Date(update.created_at).getTime();
|
|
6686
|
+
return updateDate <= toDateTime;
|
|
6687
|
+
});
|
|
6083
6688
|
}
|
|
6689
|
+
const formattedUpdates = filteredUpdates.map((update) => {
|
|
6690
|
+
const pinnedToTop = update.pinned_to_top || [];
|
|
6691
|
+
const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
|
|
6692
|
+
return {
|
|
6693
|
+
...update,
|
|
6694
|
+
pinned_to_top: isPinnedToTop,
|
|
6695
|
+
};
|
|
6696
|
+
});
|
|
6697
|
+
return [formattedUpdates.map((update) => ({ json: update }))];
|
|
6084
6698
|
}
|
|
6085
6699
|
case 'createUpdate': {
|
|
6086
6700
|
const items = this.getInputData();
|
|
@@ -6128,7 +6742,7 @@ class Worktables {
|
|
|
6128
6742
|
console.log('variables:', variables);
|
|
6129
6743
|
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
6130
6744
|
console.log('Create Update Result:', JSON.stringify(response, null, 2));
|
|
6131
|
-
const updateId = (
|
|
6745
|
+
const updateId = (_46 = (_45 = JSON.parse(response).data) === null || _45 === void 0 ? void 0 : _45.create_update) === null || _46 === void 0 ? void 0 : _46.id;
|
|
6132
6746
|
if (!updateId) {
|
|
6133
6747
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6134
6748
|
message: 'Error creating update: Update not created, no ID returned',
|
|
@@ -6161,8 +6775,17 @@ class Worktables {
|
|
|
6161
6775
|
console.warn(`Item ${i}: Binary field '${binaryName}' not found. Skipping.`);
|
|
6162
6776
|
continue;
|
|
6163
6777
|
}
|
|
6164
|
-
const fileBuffer =
|
|
6165
|
-
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension
|
|
6778
|
+
const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryName);
|
|
6779
|
+
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension);
|
|
6780
|
+
console.log(`[createUpdate] Item ${i} - Binary '${binaryName}' info:`, {
|
|
6781
|
+
fileName,
|
|
6782
|
+
originalName: binaryData.fileName,
|
|
6783
|
+
extension: binaryData.fileExtension,
|
|
6784
|
+
mimeType: binaryData.mimeType,
|
|
6785
|
+
bufferLength: fileBuffer.length,
|
|
6786
|
+
isBuffer: Buffer.isBuffer(fileBuffer),
|
|
6787
|
+
firstBytes: fileBuffer.slice(0, 16).toString('hex'),
|
|
6788
|
+
});
|
|
6166
6789
|
const form = new form_data_1.default();
|
|
6167
6790
|
form.append('query', `mutation ($file: File!) {
|
|
6168
6791
|
add_file_to_update (update_id: ${updateId}, file: $file) {
|
|
@@ -6170,19 +6793,20 @@ class Worktables {
|
|
|
6170
6793
|
}
|
|
6171
6794
|
}`);
|
|
6172
6795
|
form.append('variables[file]', fileBuffer, {
|
|
6173
|
-
filename:
|
|
6796
|
+
filename: fileName,
|
|
6174
6797
|
contentType: binaryData.mimeType || 'application/octet-stream',
|
|
6175
6798
|
});
|
|
6176
6799
|
const uploadResponse = await axios_1.default.post('https://api.monday.com/v2/file', form, {
|
|
6177
6800
|
headers: {
|
|
6178
6801
|
Authorization: headers.Authorization,
|
|
6179
|
-
'API-Version':
|
|
6802
|
+
'API-Version': API_VERSION,
|
|
6180
6803
|
...form.getHeaders(),
|
|
6181
6804
|
},
|
|
6182
6805
|
maxContentLength: Infinity,
|
|
6183
6806
|
maxBodyLength: Infinity,
|
|
6184
6807
|
});
|
|
6185
|
-
console.log(
|
|
6808
|
+
console.log('HERRRRRRROOOOO');
|
|
6809
|
+
console.log(`[createUpdate] Item ${i} - Upload response for '${binaryName}':`, JSON.stringify(uploadResponse.data));
|
|
6186
6810
|
}
|
|
6187
6811
|
}
|
|
6188
6812
|
break;
|
|
@@ -6214,6 +6838,7 @@ class Worktables {
|
|
|
6214
6838
|
const attachmentsString = this.getNodeParameter('attachmentsUpdate', i);
|
|
6215
6839
|
const binaryNames = (0, worktablesHelpers_1.parseBinaryNames)(attachmentsString);
|
|
6216
6840
|
console.log(`Item ${i} - Binary names to process:`, binaryNames);
|
|
6841
|
+
console.log('HEREEEEEEE:', updateId);
|
|
6217
6842
|
for (const binaryName of binaryNames) {
|
|
6218
6843
|
let binaryData;
|
|
6219
6844
|
try {
|
|
@@ -6223,28 +6848,38 @@ class Worktables {
|
|
|
6223
6848
|
console.warn(`Item ${i}: Binary field '${binaryName}' not found. Skipping.`);
|
|
6224
6849
|
continue;
|
|
6225
6850
|
}
|
|
6226
|
-
const fileBuffer =
|
|
6227
|
-
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension
|
|
6851
|
+
const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryName);
|
|
6852
|
+
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension);
|
|
6853
|
+
console.log(`[updateUpdate] Item ${i} - Binary '${binaryName}' info:`, {
|
|
6854
|
+
fileName,
|
|
6855
|
+
originalName: binaryData.fileName,
|
|
6856
|
+
extension: binaryData.fileExtension,
|
|
6857
|
+
mimeType: binaryData.mimeType,
|
|
6858
|
+
bufferLength: fileBuffer.length,
|
|
6859
|
+
isBuffer: Buffer.isBuffer(fileBuffer),
|
|
6860
|
+
firstBytes: fileBuffer.slice(0, 16).toString('hex'),
|
|
6861
|
+
});
|
|
6228
6862
|
const form = new form_data_1.default();
|
|
6229
6863
|
form.append('query', `mutation ($file: File!) {
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6864
|
+
add_file_to_update (update_id: ${updateId}, file: $file) {
|
|
6865
|
+
id
|
|
6866
|
+
}
|
|
6867
|
+
}`);
|
|
6234
6868
|
form.append('variables[file]', fileBuffer, {
|
|
6235
|
-
filename:
|
|
6869
|
+
filename: fileName,
|
|
6236
6870
|
contentType: binaryData.mimeType || 'application/octet-stream',
|
|
6237
6871
|
});
|
|
6238
6872
|
const uploadResponse = await axios_1.default.post('https://api.monday.com/v2/file', form, {
|
|
6239
6873
|
headers: {
|
|
6240
6874
|
Authorization: headers.Authorization,
|
|
6241
|
-
'API-Version':
|
|
6875
|
+
'API-Version': API_VERSION,
|
|
6242
6876
|
...form.getHeaders(),
|
|
6243
6877
|
},
|
|
6244
6878
|
maxContentLength: Infinity,
|
|
6245
6879
|
maxBodyLength: Infinity,
|
|
6246
6880
|
});
|
|
6247
|
-
console.log(
|
|
6881
|
+
console.log('HERRRRRRROOOOO');
|
|
6882
|
+
console.log(`[updateUpdate] Item ${i} - Upload response for '${binaryName}':`, JSON.stringify(uploadResponse.data));
|
|
6248
6883
|
}
|
|
6249
6884
|
}
|
|
6250
6885
|
break;
|
|
@@ -6312,9 +6947,11 @@ class Worktables {
|
|
|
6312
6947
|
return [[{ json: JSON.parse(response) }]];
|
|
6313
6948
|
}
|
|
6314
6949
|
case 'uploadFile': {
|
|
6950
|
+
console.log('>>>>>> UPLOAD FILE OPERATION ENTERED v1.0.27 <<<<<<');
|
|
6315
6951
|
const items = this.getInputData();
|
|
6316
6952
|
const updateId = this.getNodeParameter('updateId', 0);
|
|
6317
6953
|
const attachmentsRaw = this.getNodeParameter('attachmentsUpdate', 0);
|
|
6954
|
+
console.log('>>>>>> uploadFile params:', { updateId, attachmentsRaw, itemsCount: items.length });
|
|
6318
6955
|
if (!updateId || !attachmentsRaw) {
|
|
6319
6956
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6320
6957
|
message: 'Update ID and attachmentsUpdate (binary names) are required.',
|
|
@@ -6331,9 +6968,17 @@ class Worktables {
|
|
|
6331
6968
|
console.warn(`Item ${i}: Binary field '${binaryName}' not found. Skipping.`);
|
|
6332
6969
|
continue;
|
|
6333
6970
|
}
|
|
6334
|
-
const fileBuffer =
|
|
6971
|
+
const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryName);
|
|
6335
6972
|
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension);
|
|
6336
|
-
console.log(`Item ${i} -
|
|
6973
|
+
console.log(`[uploadFile] Item ${i} - Binary '${binaryName}' info:`, {
|
|
6974
|
+
fileName,
|
|
6975
|
+
originalName: binaryData.fileName,
|
|
6976
|
+
extension: binaryData.fileExtension,
|
|
6977
|
+
mimeType: binaryData.mimeType,
|
|
6978
|
+
bufferLength: fileBuffer.length,
|
|
6979
|
+
isBuffer: Buffer.isBuffer(fileBuffer),
|
|
6980
|
+
firstBytes: fileBuffer.slice(0, 16).toString('hex'),
|
|
6981
|
+
});
|
|
6337
6982
|
const form = new form_data_1.default();
|
|
6338
6983
|
form.append('query', `mutation ($file: File!) {
|
|
6339
6984
|
add_file_to_update (update_id: ${updateId}, file: $file) {
|
|
@@ -6347,13 +6992,14 @@ class Worktables {
|
|
|
6347
6992
|
const uploadResponse = await axios_1.default.post('https://api.monday.com/v2/file', form, {
|
|
6348
6993
|
headers: {
|
|
6349
6994
|
Authorization: headers.Authorization,
|
|
6350
|
-
'API-Version':
|
|
6995
|
+
'API-Version': API_VERSION,
|
|
6351
6996
|
...form.getHeaders(),
|
|
6352
6997
|
},
|
|
6353
6998
|
maxContentLength: Infinity,
|
|
6354
6999
|
maxBodyLength: Infinity,
|
|
6355
7000
|
});
|
|
6356
|
-
console.log(
|
|
7001
|
+
console.log('HERRRRRRROOOOO');
|
|
7002
|
+
console.log(`[uploadFile] Item ${i} - Upload response for '${binaryName}':`, JSON.stringify(uploadResponse.data));
|
|
6357
7003
|
response = JSON.stringify(uploadResponse.data);
|
|
6358
7004
|
}
|
|
6359
7005
|
}
|
|
@@ -6496,7 +7142,7 @@ class Worktables {
|
|
|
6496
7142
|
body: { query },
|
|
6497
7143
|
json: true,
|
|
6498
7144
|
});
|
|
6499
|
-
const asset = (
|
|
7145
|
+
const asset = (_48 = (_47 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _47 === void 0 ? void 0 : _47.assets) === null || _48 === void 0 ? void 0 : _48[0];
|
|
6500
7146
|
if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
|
|
6501
7147
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6502
7148
|
message: 'Public URL not found for the given file ID.',
|
|
@@ -6525,23 +7171,91 @@ class Worktables {
|
|
|
6525
7171
|
case 'query': {
|
|
6526
7172
|
const runQuery = this.getNodeParameter('runQuery', 0);
|
|
6527
7173
|
const apiVersion = this.getNodeParameter('apiVersion', 0);
|
|
7174
|
+
const includePagination = this.getNodeParameter('includePagination', 0);
|
|
7175
|
+
console.log('HERRRRRRROOOOO');
|
|
6528
7176
|
if (!runQuery) {
|
|
6529
7177
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Invalid item data.' });
|
|
6530
7178
|
}
|
|
6531
7179
|
switch (operation) {
|
|
6532
7180
|
case 'query': {
|
|
6533
|
-
console.log('Run Query:', runQuery);
|
|
6534
7181
|
const apiUrl = `https://api.monday.com/v2`;
|
|
6535
7182
|
const queryHeaders = {
|
|
6536
7183
|
...headers,
|
|
6537
7184
|
'API-Version': apiVersion,
|
|
6538
7185
|
};
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
7186
|
+
if (includePagination) {
|
|
7187
|
+
const paginationType = this.getNodeParameter('paginationType', 0);
|
|
7188
|
+
let allData = [];
|
|
7189
|
+
if (paginationType === 'cursor') {
|
|
7190
|
+
let cursor = null;
|
|
7191
|
+
let currentQuery = runQuery;
|
|
7192
|
+
do {
|
|
7193
|
+
if (cursor) {
|
|
7194
|
+
currentQuery = runQuery.replace(/cursor:\s*"[^"]*"/, `cursor: "${cursor}"`);
|
|
7195
|
+
if (!runQuery.includes('cursor:')) {
|
|
7196
|
+
currentQuery = runQuery.replace(/(items_page\s*\([^)]*)(limit:\s*\d+)/, `$1$2, cursor: "${cursor}"`);
|
|
7197
|
+
}
|
|
7198
|
+
}
|
|
7199
|
+
const rawResponse = await this.helpers.request({
|
|
7200
|
+
method: 'POST',
|
|
7201
|
+
url: apiUrl,
|
|
7202
|
+
headers: queryHeaders,
|
|
7203
|
+
body: { query: currentQuery },
|
|
7204
|
+
});
|
|
7205
|
+
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
7206
|
+
const itemsPage = (_51 = (_50 = (_49 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _49 === void 0 ? void 0 : _49.boards) === null || _50 === void 0 ? void 0 : _50[0]) === null || _51 === void 0 ? void 0 : _51.items_page;
|
|
7207
|
+
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
7208
|
+
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
7209
|
+
allData = allData.concat(items);
|
|
7210
|
+
} while (cursor);
|
|
7211
|
+
response = JSON.stringify({ data: { items: allData }, totalCount: allData.length });
|
|
7212
|
+
}
|
|
7213
|
+
else {
|
|
7214
|
+
let page = 1;
|
|
7215
|
+
while (true) {
|
|
7216
|
+
const currentQuery = runQuery.replace(/page:\s*\d+/, `page: ${page}`);
|
|
7217
|
+
console.log(`[Pagination] Fetching page ${page}`);
|
|
7218
|
+
console.log(`[Pagination] Query: ${currentQuery}`);
|
|
7219
|
+
const rawResponse = await this.helpers.request({
|
|
7220
|
+
method: 'POST',
|
|
7221
|
+
url: apiUrl,
|
|
7222
|
+
headers: queryHeaders,
|
|
7223
|
+
body: { query: currentQuery },
|
|
7224
|
+
});
|
|
7225
|
+
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
7226
|
+
if ((parsed === null || parsed === void 0 ? void 0 : parsed.errors) && parsed.errors.length > 0) {
|
|
7227
|
+
console.log(`[Pagination] API Error on page ${page}:`, JSON.stringify(parsed.errors));
|
|
7228
|
+
break;
|
|
7229
|
+
}
|
|
7230
|
+
let data = [];
|
|
7231
|
+
if (parsed === null || parsed === void 0 ? void 0 : parsed.data) {
|
|
7232
|
+
for (const key of Object.keys(parsed.data)) {
|
|
7233
|
+
if (Array.isArray(parsed.data[key])) {
|
|
7234
|
+
data = parsed.data[key];
|
|
7235
|
+
console.log(`[Pagination] Page ${page}: found ${data.length} items in "${key}"`);
|
|
7236
|
+
break;
|
|
7237
|
+
}
|
|
7238
|
+
}
|
|
7239
|
+
}
|
|
7240
|
+
if (data.length === 0) {
|
|
7241
|
+
console.log(`[Pagination] Page ${page}: empty data, stopping`);
|
|
7242
|
+
break;
|
|
7243
|
+
}
|
|
7244
|
+
allData = allData.concat(data);
|
|
7245
|
+
page++;
|
|
7246
|
+
}
|
|
7247
|
+
console.log(`[Pagination] Total fetched: ${allData.length} items`);
|
|
7248
|
+
response = JSON.stringify({ data: allData, totalCount: allData.length });
|
|
7249
|
+
}
|
|
7250
|
+
}
|
|
7251
|
+
else {
|
|
7252
|
+
response = await this.helpers.request({
|
|
7253
|
+
method: 'POST',
|
|
7254
|
+
url: apiUrl,
|
|
7255
|
+
headers: queryHeaders,
|
|
7256
|
+
body: { query: runQuery },
|
|
7257
|
+
});
|
|
7258
|
+
}
|
|
6545
7259
|
break;
|
|
6546
7260
|
}
|
|
6547
7261
|
default:
|
|
@@ -6560,6 +7274,7 @@ class Worktables {
|
|
|
6560
7274
|
headers: {
|
|
6561
7275
|
Authorization: `Bearer ${apiKey}`,
|
|
6562
7276
|
'Content-Type': 'application/json',
|
|
7277
|
+
'API-Version': API_VERSION,
|
|
6563
7278
|
},
|
|
6564
7279
|
body: {
|
|
6565
7280
|
query: `{
|
|
@@ -6591,6 +7306,7 @@ class Worktables {
|
|
|
6591
7306
|
headers: {
|
|
6592
7307
|
Authorization: `Bearer ${apiKey}`,
|
|
6593
7308
|
'Content-Type': 'application/json',
|
|
7309
|
+
'API-Version': API_VERSION,
|
|
6594
7310
|
},
|
|
6595
7311
|
body: {
|
|
6596
7312
|
query: `{
|
|
@@ -6617,6 +7333,36 @@ class Worktables {
|
|
|
6617
7333
|
}
|
|
6618
7334
|
break;
|
|
6619
7335
|
}
|
|
7336
|
+
case 'notification': {
|
|
7337
|
+
switch (operation) {
|
|
7338
|
+
case 'sendNotification': {
|
|
7339
|
+
const userId = this.getNodeParameter('notificationUserId', 0);
|
|
7340
|
+
const targetId = this.getNodeParameter('notificationTargetId', 0);
|
|
7341
|
+
const targetType = this.getNodeParameter('notificationTargetType', 0);
|
|
7342
|
+
const text = this.getNodeParameter('notificationMessage', 0);
|
|
7343
|
+
const escapedText = (0, worktablesHelpers_1.escapeGraphQLString)(text);
|
|
7344
|
+
const mutation = `mutation {
|
|
7345
|
+
create_notification(
|
|
7346
|
+
text: "${escapedText}",
|
|
7347
|
+
user_id: ${parseInt(userId, 10)},
|
|
7348
|
+
target_id: ${parseInt(targetId, 10)},
|
|
7349
|
+
target_type: ${targetType}
|
|
7350
|
+
) {
|
|
7351
|
+
id
|
|
7352
|
+
text
|
|
7353
|
+
}
|
|
7354
|
+
}`;
|
|
7355
|
+
response = await this.helpers.request({
|
|
7356
|
+
method: 'POST',
|
|
7357
|
+
url: 'https://api.monday.com/v2',
|
|
7358
|
+
headers,
|
|
7359
|
+
body: { query: mutation },
|
|
7360
|
+
});
|
|
7361
|
+
break;
|
|
7362
|
+
}
|
|
7363
|
+
}
|
|
7364
|
+
break;
|
|
7365
|
+
}
|
|
6620
7366
|
default:
|
|
6621
7367
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: `Unsupported resource: ${resource}` });
|
|
6622
7368
|
}
|