@worktables/n8n-nodes-worktables 12.41.0 → 12.60.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +1131 -268
- 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, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61;
|
|
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(),
|
|
@@ -4249,19 +4637,62 @@ class Worktables {
|
|
|
4249
4637
|
column_values: "${escapedColumnValues}"
|
|
4250
4638
|
) {
|
|
4251
4639
|
id
|
|
4640
|
+
name
|
|
4252
4641
|
url
|
|
4253
4642
|
board {
|
|
4254
4643
|
id
|
|
4255
4644
|
}
|
|
4645
|
+
column_values {
|
|
4646
|
+
id
|
|
4647
|
+
text
|
|
4648
|
+
type
|
|
4649
|
+
value
|
|
4650
|
+
... on BoardRelationValue {
|
|
4651
|
+
display_value
|
|
4652
|
+
linked_item_ids
|
|
4653
|
+
}
|
|
4654
|
+
... on MirrorValue {
|
|
4655
|
+
display_value
|
|
4656
|
+
mirrored_items {
|
|
4657
|
+
linked_board_id
|
|
4658
|
+
}
|
|
4659
|
+
}
|
|
4660
|
+
... on DependencyValue {
|
|
4661
|
+
display_value
|
|
4662
|
+
linked_item_ids
|
|
4663
|
+
linked_items {
|
|
4664
|
+
id
|
|
4665
|
+
name
|
|
4666
|
+
}
|
|
4667
|
+
}
|
|
4668
|
+
}
|
|
4256
4669
|
}
|
|
4257
4670
|
}`;
|
|
4258
4671
|
console.log('Generated Mutation:', mutation);
|
|
4259
|
-
|
|
4672
|
+
const updateResponseRaw = await this.helpers.request({
|
|
4260
4673
|
method: 'POST',
|
|
4261
4674
|
url: 'https://api.monday.com/v2',
|
|
4262
4675
|
headers,
|
|
4263
4676
|
body: { query: mutation },
|
|
4264
4677
|
});
|
|
4678
|
+
const parsedUpdate = JSON.parse(updateResponseRaw);
|
|
4679
|
+
const parsedUpdateData = (_q = parsedUpdate === null || parsedUpdate === void 0 ? void 0 : parsedUpdate.data) === null || _q === void 0 ? void 0 : _q.change_multiple_column_values;
|
|
4680
|
+
const formattedUpdateResponse = {
|
|
4681
|
+
id: parsedUpdateData === null || parsedUpdateData === void 0 ? void 0 : parsedUpdateData.id,
|
|
4682
|
+
name: parsedUpdateData === null || parsedUpdateData === void 0 ? void 0 : parsedUpdateData.name,
|
|
4683
|
+
url: parsedUpdateData === null || parsedUpdateData === void 0 ? void 0 : parsedUpdateData.url,
|
|
4684
|
+
board: (_r = parsedUpdateData === null || parsedUpdateData === void 0 ? void 0 : parsedUpdateData.board) === null || _r === void 0 ? void 0 : _r.id,
|
|
4685
|
+
column_values: {},
|
|
4686
|
+
};
|
|
4687
|
+
if ((_s = parsedUpdateData === null || parsedUpdateData === void 0 ? void 0 : parsedUpdateData.column_values) === null || _s === void 0 ? void 0 : _s.length) {
|
|
4688
|
+
for (const col of parsedUpdateData.column_values) {
|
|
4689
|
+
const formattedCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
|
|
4690
|
+
if (formattedCol) {
|
|
4691
|
+
formattedUpdateResponse.column_values[col.id] = formattedCol;
|
|
4692
|
+
}
|
|
4693
|
+
}
|
|
4694
|
+
}
|
|
4695
|
+
response = JSON.stringify(formattedUpdateResponse);
|
|
4265
4696
|
break;
|
|
4266
4697
|
}
|
|
4267
4698
|
case 'createItem': {
|
|
@@ -4280,6 +4711,7 @@ class Worktables {
|
|
|
4280
4711
|
headers: {
|
|
4281
4712
|
Authorization: `Bearer ${apiKey}`,
|
|
4282
4713
|
'Content-Type': 'application/json',
|
|
4714
|
+
'API-Version': API_VERSION,
|
|
4283
4715
|
},
|
|
4284
4716
|
body: {
|
|
4285
4717
|
query: `query {
|
|
@@ -4383,8 +4815,8 @@ class Worktables {
|
|
|
4383
4815
|
break;
|
|
4384
4816
|
case 'timeline':
|
|
4385
4817
|
{
|
|
4386
|
-
const from = ((
|
|
4387
|
-
const to = ((
|
|
4818
|
+
const from = ((_t = col.startDate) === null || _t === void 0 ? void 0 : _t.split('T')[0]) || '';
|
|
4819
|
+
const to = ((_u = col.endDate) === null || _u === void 0 ? void 0 : _u.split('T')[0]) || '';
|
|
4388
4820
|
column_values_object[columnId] = { from, to };
|
|
4389
4821
|
}
|
|
4390
4822
|
break;
|
|
@@ -4422,8 +4854,8 @@ class Worktables {
|
|
|
4422
4854
|
break;
|
|
4423
4855
|
case 'phone':
|
|
4424
4856
|
column_values_object[columnId] = {
|
|
4425
|
-
phone: `${(
|
|
4426
|
-
countryShortName: ((
|
|
4857
|
+
phone: `${(_v = col.countryCode) === null || _v === void 0 ? void 0 : _v.split(' ')[0]}${col.phoneValue || ''}`.replace(/[^\d+]/g, ''),
|
|
4858
|
+
countryShortName: ((_w = col.countryCode) === null || _w === void 0 ? void 0 : _w.split(' ')[1]) || '',
|
|
4427
4859
|
};
|
|
4428
4860
|
break;
|
|
4429
4861
|
case 'file':
|
|
@@ -4439,7 +4871,7 @@ class Worktables {
|
|
|
4439
4871
|
break;
|
|
4440
4872
|
case 'dropdown':
|
|
4441
4873
|
{
|
|
4442
|
-
const labels = (
|
|
4874
|
+
const labels = (_x = col.dropdownValue) === null || _x === void 0 ? void 0 : _x.split(',').map((t) => t.trim()).filter((t) => t);
|
|
4443
4875
|
if (labels && labels.length) {
|
|
4444
4876
|
column_values_object[columnId] = { labels };
|
|
4445
4877
|
}
|
|
@@ -4493,6 +4925,7 @@ class Worktables {
|
|
|
4493
4925
|
headers: {
|
|
4494
4926
|
Authorization: `Bearer ${apiKey}`,
|
|
4495
4927
|
'Content-Type': 'application/json',
|
|
4928
|
+
'API-Version': API_VERSION,
|
|
4496
4929
|
},
|
|
4497
4930
|
body: {
|
|
4498
4931
|
query: `query {
|
|
@@ -4525,8 +4958,25 @@ class Worktables {
|
|
|
4525
4958
|
id
|
|
4526
4959
|
text
|
|
4527
4960
|
type
|
|
4528
|
-
|
|
4529
4961
|
value
|
|
4962
|
+
... on BoardRelationValue {
|
|
4963
|
+
display_value
|
|
4964
|
+
linked_item_ids
|
|
4965
|
+
}
|
|
4966
|
+
... on MirrorValue {
|
|
4967
|
+
display_value
|
|
4968
|
+
mirrored_items {
|
|
4969
|
+
linked_board_id
|
|
4970
|
+
}
|
|
4971
|
+
}
|
|
4972
|
+
... on DependencyValue {
|
|
4973
|
+
display_value
|
|
4974
|
+
linked_item_ids
|
|
4975
|
+
linked_items {
|
|
4976
|
+
id
|
|
4977
|
+
name
|
|
4978
|
+
}
|
|
4979
|
+
}
|
|
4530
4980
|
}}
|
|
4531
4981
|
}`
|
|
4532
4982
|
: `mutation {
|
|
@@ -4544,7 +4994,24 @@ class Worktables {
|
|
|
4544
4994
|
text
|
|
4545
4995
|
type
|
|
4546
4996
|
value
|
|
4547
|
-
|
|
4997
|
+
... on BoardRelationValue {
|
|
4998
|
+
display_value
|
|
4999
|
+
linked_item_ids
|
|
5000
|
+
}
|
|
5001
|
+
... on MirrorValue {
|
|
5002
|
+
display_value
|
|
5003
|
+
mirrored_items {
|
|
5004
|
+
linked_board_id
|
|
5005
|
+
}
|
|
5006
|
+
}
|
|
5007
|
+
... on DependencyValue {
|
|
5008
|
+
display_value
|
|
5009
|
+
linked_item_ids
|
|
5010
|
+
linked_items {
|
|
5011
|
+
id
|
|
5012
|
+
name
|
|
5013
|
+
}
|
|
5014
|
+
}
|
|
4548
5015
|
}}
|
|
4549
5016
|
}`;
|
|
4550
5017
|
console.log('Mutation:', mutation);
|
|
@@ -4554,6 +5021,7 @@ class Worktables {
|
|
|
4554
5021
|
headers: {
|
|
4555
5022
|
Authorization: `Bearer ${apiKey}`,
|
|
4556
5023
|
'Content-Type': 'application/json',
|
|
5024
|
+
'API-Version': API_VERSION,
|
|
4557
5025
|
},
|
|
4558
5026
|
body: { query: mutation },
|
|
4559
5027
|
});
|
|
@@ -4583,15 +5051,55 @@ class Worktables {
|
|
|
4583
5051
|
}
|
|
4584
5052
|
}
|
|
4585
5053
|
const parsedResponse = JSON.parse(responseRaw);
|
|
4586
|
-
const itemData = ((
|
|
5054
|
+
const itemData = ((_y = parsedResponse.data) === null || _y === void 0 ? void 0 : _y.create_item) || ((_z = parsedResponse.data) === null || _z === void 0 ? void 0 : _z.create_subitem);
|
|
5055
|
+
const createdItemId = itemData.id;
|
|
5056
|
+
const fetchItemQuery = `{
|
|
5057
|
+
items(ids: ["${createdItemId}"]) {
|
|
5058
|
+
id
|
|
5059
|
+
name
|
|
5060
|
+
url
|
|
5061
|
+
board { id }
|
|
5062
|
+
column_values {
|
|
5063
|
+
id
|
|
5064
|
+
text
|
|
5065
|
+
value
|
|
5066
|
+
type
|
|
5067
|
+
... on BoardRelationValue {
|
|
5068
|
+
display_value
|
|
5069
|
+
linked_item_ids
|
|
5070
|
+
}
|
|
5071
|
+
... on MirrorValue {
|
|
5072
|
+
display_value
|
|
5073
|
+
mirrored_items {
|
|
5074
|
+
linked_board_id
|
|
5075
|
+
}
|
|
5076
|
+
}
|
|
5077
|
+
... on DependencyValue {
|
|
5078
|
+
display_value
|
|
5079
|
+
linked_item_ids
|
|
5080
|
+
linked_items {
|
|
5081
|
+
id
|
|
5082
|
+
name
|
|
5083
|
+
}
|
|
5084
|
+
}
|
|
5085
|
+
}
|
|
5086
|
+
}
|
|
5087
|
+
}`;
|
|
5088
|
+
const fetchResponse = await this.helpers.request({
|
|
5089
|
+
method: 'POST',
|
|
5090
|
+
url: 'https://api.monday.com/v2',
|
|
5091
|
+
headers,
|
|
5092
|
+
body: { query: fetchItemQuery },
|
|
5093
|
+
});
|
|
5094
|
+
const fetchedItem = ((_2 = (_1 = (_0 = JSON.parse(fetchResponse)) === null || _0 === void 0 ? void 0 : _0.data) === null || _1 === void 0 ? void 0 : _1.items) === null || _2 === void 0 ? void 0 : _2[0]) || itemData;
|
|
4587
5095
|
const formattedResponse = {
|
|
4588
|
-
id:
|
|
4589
|
-
name: itemName,
|
|
4590
|
-
url:
|
|
4591
|
-
board: itemData.board.id,
|
|
5096
|
+
id: fetchedItem.id,
|
|
5097
|
+
name: (_3 = fetchedItem.name) !== null && _3 !== void 0 ? _3 : itemName,
|
|
5098
|
+
url: fetchedItem.url,
|
|
5099
|
+
board: (_5 = (_4 = fetchedItem.board) === null || _4 === void 0 ? void 0 : _4.id) !== null && _5 !== void 0 ? _5 : (_6 = itemData.board) === null || _6 === void 0 ? void 0 : _6.id,
|
|
4592
5100
|
column_values: {},
|
|
4593
5101
|
};
|
|
4594
|
-
for (const col of
|
|
5102
|
+
for (const col of fetchedItem.column_values || []) {
|
|
4595
5103
|
const formattedCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
|
|
4596
5104
|
if (formattedCol) {
|
|
4597
5105
|
formattedResponse.column_values[col.id] = formattedCol;
|
|
@@ -4646,9 +5154,9 @@ class Worktables {
|
|
|
4646
5154
|
body: { query: discoverQuery },
|
|
4647
5155
|
});
|
|
4648
5156
|
const discoverData = JSON.parse(discoverResponse);
|
|
4649
|
-
const items = ((
|
|
5157
|
+
const items = ((_10 = (_9 = (_8 = (_7 = discoverData === null || discoverData === void 0 ? void 0 : discoverData.data) === null || _7 === void 0 ? void 0 : _7.boards) === null || _8 === void 0 ? void 0 : _8[0]) === null || _9 === void 0 ? void 0 : _9.items_page) === null || _10 === void 0 ? void 0 : _10.items) || [];
|
|
4650
5158
|
if (items.length > 0 && items[0].subitems && items[0].subitems.length > 0) {
|
|
4651
|
-
searchBoardId = ((
|
|
5159
|
+
searchBoardId = ((_11 = items[0].subitems[0].board) === null || _11 === void 0 ? void 0 : _11.id) || boardId;
|
|
4652
5160
|
console.log(`Discovered subitem board ID: ${searchBoardId}`);
|
|
4653
5161
|
}
|
|
4654
5162
|
}
|
|
@@ -4673,7 +5181,7 @@ class Worktables {
|
|
|
4673
5181
|
body: { query: columnTypeQuery },
|
|
4674
5182
|
});
|
|
4675
5183
|
const columnTypeData = JSON.parse(columnTypeResponse);
|
|
4676
|
-
const columns = ((
|
|
5184
|
+
const columns = ((_14 = (_13 = (_12 = columnTypeData === null || columnTypeData === void 0 ? void 0 : columnTypeData.data) === null || _12 === void 0 ? void 0 : _12.boards) === null || _13 === void 0 ? void 0 : _13[0]) === null || _14 === void 0 ? void 0 : _14.columns) || [];
|
|
4677
5185
|
if (columns.length > 0) {
|
|
4678
5186
|
columnType = columns[0].type;
|
|
4679
5187
|
console.log(`Column type detected: ${columnType}`);
|
|
@@ -4711,6 +5219,12 @@ class Worktables {
|
|
|
4711
5219
|
... on MirrorValue {
|
|
4712
5220
|
display_value
|
|
4713
5221
|
}
|
|
5222
|
+
... on DependencyValue {
|
|
5223
|
+
display_value
|
|
5224
|
+
}
|
|
5225
|
+
... on MirrorValue {
|
|
5226
|
+
display_value
|
|
5227
|
+
}
|
|
4714
5228
|
... on StatusValue {
|
|
4715
5229
|
text
|
|
4716
5230
|
index
|
|
@@ -4726,7 +5240,7 @@ class Worktables {
|
|
|
4726
5240
|
body: { query: parentQuery },
|
|
4727
5241
|
});
|
|
4728
5242
|
const searchData = JSON.parse(searchResponse);
|
|
4729
|
-
const items = ((
|
|
5243
|
+
const items = ((_15 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _15 === void 0 ? void 0 : _15.items) || [];
|
|
4730
5244
|
if (items.length > 0 && items[0].subitems) {
|
|
4731
5245
|
const subitems = items[0].subitems;
|
|
4732
5246
|
console.log(`🔍 Searching subitems of parent ${parentId}, found ${subitems.length} subitem(s)`);
|
|
@@ -4738,7 +5252,7 @@ class Worktables {
|
|
|
4738
5252
|
matches = subitemName === searchValue;
|
|
4739
5253
|
}
|
|
4740
5254
|
else {
|
|
4741
|
-
const colValue = (
|
|
5255
|
+
const colValue = (_16 = subitem.column_values) === null || _16 === void 0 ? void 0 : _16.find((cv) => cv.id === identifierColumn);
|
|
4742
5256
|
if (colValue) {
|
|
4743
5257
|
const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
|
|
4744
5258
|
const isStatusColumn = colValue.type === 'status';
|
|
@@ -4756,7 +5270,7 @@ class Worktables {
|
|
|
4756
5270
|
}
|
|
4757
5271
|
if (matches) {
|
|
4758
5272
|
foundItemId = subitem.id;
|
|
4759
|
-
foundItemBoardId = ((
|
|
5273
|
+
foundItemBoardId = ((_17 = subitem.board) === null || _17 === void 0 ? void 0 : _17.id) || null;
|
|
4760
5274
|
console.log(`✓ Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
|
|
4761
5275
|
break;
|
|
4762
5276
|
}
|
|
@@ -4793,6 +5307,9 @@ class Worktables {
|
|
|
4793
5307
|
... on MirrorValue {
|
|
4794
5308
|
display_value
|
|
4795
5309
|
}
|
|
5310
|
+
... on DependencyValue {
|
|
5311
|
+
display_value
|
|
5312
|
+
}
|
|
4796
5313
|
... on StatusValue {
|
|
4797
5314
|
text
|
|
4798
5315
|
index
|
|
@@ -4810,7 +5327,7 @@ class Worktables {
|
|
|
4810
5327
|
body: { query },
|
|
4811
5328
|
});
|
|
4812
5329
|
const searchData = JSON.parse(searchResponse);
|
|
4813
|
-
const itemsPage = (
|
|
5330
|
+
const itemsPage = (_20 = (_19 = (_18 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _18 === void 0 ? void 0 : _18.boards) === null || _19 === void 0 ? void 0 : _19[0]) === null || _20 === void 0 ? void 0 : _20.items_page;
|
|
4814
5331
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
4815
5332
|
console.log(`🔍 Optimized search found ${items.length} item(s) matching identifier`);
|
|
4816
5333
|
for (const item of items) {
|
|
@@ -4821,7 +5338,7 @@ class Worktables {
|
|
|
4821
5338
|
matches = itemName === searchValue;
|
|
4822
5339
|
}
|
|
4823
5340
|
else {
|
|
4824
|
-
const colValue = (
|
|
5341
|
+
const colValue = (_21 = item.column_values) === null || _21 === void 0 ? void 0 : _21.find((cv) => cv.id === identifierColumn);
|
|
4825
5342
|
if (colValue) {
|
|
4826
5343
|
const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
|
|
4827
5344
|
const isStatusColumn = colValue.type === 'status';
|
|
@@ -4894,7 +5411,7 @@ class Worktables {
|
|
|
4894
5411
|
id: itemData.id,
|
|
4895
5412
|
url: itemData.url || '',
|
|
4896
5413
|
operation: 'update',
|
|
4897
|
-
board_id: ((
|
|
5414
|
+
board_id: ((_22 = itemData.board) === null || _22 === void 0 ? void 0 : _22.id) || boardId,
|
|
4898
5415
|
column_values: column_values_object,
|
|
4899
5416
|
};
|
|
4900
5417
|
itemUpdated = true;
|
|
@@ -4990,8 +5507,8 @@ class Worktables {
|
|
|
4990
5507
|
});
|
|
4991
5508
|
}
|
|
4992
5509
|
const itemData = isSubitem && parentId
|
|
4993
|
-
? (
|
|
4994
|
-
: (
|
|
5510
|
+
? (_23 = responseData.data) === null || _23 === void 0 ? void 0 : _23.create_subitem
|
|
5511
|
+
: (_24 = responseData.data) === null || _24 === void 0 ? void 0 : _24.create_item;
|
|
4995
5512
|
if (!itemData || !itemData.id) {
|
|
4996
5513
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
4997
5514
|
message: `Error creating ${isSubitem ? 'subitem' : 'item'}: No item data returned`,
|
|
@@ -5002,7 +5519,7 @@ class Worktables {
|
|
|
5002
5519
|
name: itemData.name || itemName,
|
|
5003
5520
|
url: itemData.url || '',
|
|
5004
5521
|
operation: 'create',
|
|
5005
|
-
board_id: ((
|
|
5522
|
+
board_id: ((_25 = itemData.board) === null || _25 === void 0 ? void 0 : _25.id) || boardId,
|
|
5006
5523
|
column_values: column_values_object,
|
|
5007
5524
|
};
|
|
5008
5525
|
if (isSubitem && parentId) {
|
|
@@ -5015,6 +5532,7 @@ class Worktables {
|
|
|
5015
5532
|
const itemId = this.getNodeParameter('itemId', 0);
|
|
5016
5533
|
const from = this.getNodeParameter('from', 0, '');
|
|
5017
5534
|
const to = this.getNodeParameter('to', 0, '');
|
|
5535
|
+
const limit = this.getNodeParameter('limit', 0, 50);
|
|
5018
5536
|
if (!itemId) {
|
|
5019
5537
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Item ID is required.' });
|
|
5020
5538
|
}
|
|
@@ -5043,56 +5561,82 @@ class Worktables {
|
|
|
5043
5561
|
if (itemParsed.errors) {
|
|
5044
5562
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(itemParsed.errors) });
|
|
5045
5563
|
}
|
|
5046
|
-
const items = ((
|
|
5564
|
+
const items = ((_26 = itemParsed === null || itemParsed === void 0 ? void 0 : itemParsed.data) === null || _26 === void 0 ? void 0 : _26.items) || [];
|
|
5047
5565
|
if (items.length === 0) {
|
|
5048
5566
|
return [[{ json: { item_id: itemId, activity_logs: [] } }]];
|
|
5049
5567
|
}
|
|
5050
5568
|
const item = items[0];
|
|
5051
|
-
const boardId = (
|
|
5569
|
+
const boardId = (_27 = item.board) === null || _27 === void 0 ? void 0 : _27.id;
|
|
5052
5570
|
if (!boardId) {
|
|
5053
5571
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Could not retrieve board ID for the item.' });
|
|
5054
5572
|
}
|
|
5055
|
-
const
|
|
5573
|
+
const baseParams = [`item_ids: ["${itemId}"]`];
|
|
5056
5574
|
if (from) {
|
|
5057
|
-
|
|
5575
|
+
baseParams.push(`from: "${from}Z"`);
|
|
5058
5576
|
}
|
|
5059
5577
|
if (to) {
|
|
5060
|
-
|
|
5578
|
+
baseParams.push(`to: "${to}Z"`);
|
|
5061
5579
|
}
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5580
|
+
let allLogs = [];
|
|
5581
|
+
let page = 1;
|
|
5582
|
+
const pageLimit = 100;
|
|
5583
|
+
do {
|
|
5584
|
+
const params = [...baseParams];
|
|
5585
|
+
params.push(`page: ${page}`);
|
|
5586
|
+
if (limit === 0) {
|
|
5587
|
+
params.push(`limit: ${pageLimit}`);
|
|
5588
|
+
}
|
|
5589
|
+
else {
|
|
5590
|
+
const remaining = limit - allLogs.length;
|
|
5591
|
+
const currentLimit = remaining > pageLimit ? pageLimit : remaining;
|
|
5592
|
+
params.push(`limit: ${currentLimit}`);
|
|
5593
|
+
}
|
|
5594
|
+
const paramsString = params.join(', ');
|
|
5595
|
+
const query = `
|
|
5596
|
+
query {
|
|
5597
|
+
boards(ids: [${boardId}]) {
|
|
5598
|
+
activity_logs(${paramsString}) {
|
|
5599
|
+
id
|
|
5600
|
+
user_id
|
|
5601
|
+
entity
|
|
5602
|
+
event
|
|
5603
|
+
data
|
|
5604
|
+
account_id
|
|
5605
|
+
created_at
|
|
5606
|
+
}
|
|
5074
5607
|
}
|
|
5075
5608
|
}
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5609
|
+
`;
|
|
5610
|
+
console.log('Activity Logs Query: ', query);
|
|
5611
|
+
const rawResponse = await this.helpers.request({
|
|
5612
|
+
method: 'POST',
|
|
5613
|
+
url: 'https://api.monday.com/v2',
|
|
5614
|
+
headers,
|
|
5615
|
+
body: { query },
|
|
5616
|
+
});
|
|
5617
|
+
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
5618
|
+
if (parsed.errors) {
|
|
5619
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(parsed.errors) });
|
|
5620
|
+
}
|
|
5621
|
+
const boards = ((_28 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _28 === void 0 ? void 0 : _28.boards) || [];
|
|
5622
|
+
const logs = boards.length > 0 ? (boards[0].activity_logs || []) : [];
|
|
5623
|
+
allLogs = allLogs.concat(logs);
|
|
5624
|
+
if (logs.length < pageLimit) {
|
|
5625
|
+
break;
|
|
5626
|
+
}
|
|
5627
|
+
if (limit > 0 && allLogs.length >= limit) {
|
|
5628
|
+
if (allLogs.length > limit) {
|
|
5629
|
+
allLogs = allLogs.slice(0, limit);
|
|
5630
|
+
}
|
|
5631
|
+
break;
|
|
5632
|
+
}
|
|
5633
|
+
page++;
|
|
5634
|
+
} while (true);
|
|
5091
5635
|
const formatted = {
|
|
5092
5636
|
item_id: item.id,
|
|
5093
5637
|
item_name: item.name,
|
|
5094
5638
|
board_id: boardId,
|
|
5095
|
-
activity_logs:
|
|
5639
|
+
activity_logs: allLogs.map((log) => {
|
|
5096
5640
|
let parsedData = log.data;
|
|
5097
5641
|
if (typeof log.data === 'string') {
|
|
5098
5642
|
try {
|
|
@@ -5164,27 +5708,72 @@ class Worktables {
|
|
|
5164
5708
|
console.log('List items in a board');
|
|
5165
5709
|
const boardId = this.getNodeParameter('boardId', 0);
|
|
5166
5710
|
const limit = this.getNodeParameter('limit', 0);
|
|
5711
|
+
const fetchAllColumns = this.getNodeParameter('fetchAllColumns', 0, true);
|
|
5712
|
+
const columnIdsRaw = this.getNodeParameter('columnIds', 0, '');
|
|
5167
5713
|
if (!boardId) {
|
|
5168
5714
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Board ID is required.' });
|
|
5169
5715
|
}
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5716
|
+
let queryColumnValues = '';
|
|
5717
|
+
if (fetchAllColumns) {
|
|
5718
|
+
queryColumnValues = `
|
|
5719
|
+
column_values {
|
|
5720
|
+
id
|
|
5721
|
+
text
|
|
5722
|
+
value
|
|
5723
|
+
type
|
|
5724
|
+
... on BoardRelationValue {
|
|
5725
|
+
display_value
|
|
5726
|
+
linked_item_ids
|
|
5727
|
+
}
|
|
5728
|
+
... on MirrorValue {
|
|
5729
|
+
display_value
|
|
5730
|
+
mirrored_items {
|
|
5731
|
+
linked_board_id
|
|
5732
|
+
}
|
|
5733
|
+
}
|
|
5734
|
+
... on DependencyValue {
|
|
5735
|
+
display_value
|
|
5736
|
+
linked_item_ids
|
|
5737
|
+
linked_items {
|
|
5738
|
+
id
|
|
5739
|
+
name
|
|
5740
|
+
}
|
|
5184
5741
|
}
|
|
5185
5742
|
}
|
|
5186
|
-
|
|
5187
|
-
|
|
5743
|
+
`;
|
|
5744
|
+
}
|
|
5745
|
+
else if (columnIdsRaw && columnIdsRaw.trim()) {
|
|
5746
|
+
const specificColumnIds = columnIdsRaw.split(',').map(id => id.trim()).filter(id => id);
|
|
5747
|
+
if (specificColumnIds.length > 0) {
|
|
5748
|
+
const columnIdsString = specificColumnIds.map(id => `"${id}"`).join(', ');
|
|
5749
|
+
queryColumnValues = `
|
|
5750
|
+
column_values(ids: [${columnIdsString}]) {
|
|
5751
|
+
id
|
|
5752
|
+
text
|
|
5753
|
+
value
|
|
5754
|
+
type
|
|
5755
|
+
... on BoardRelationValue {
|
|
5756
|
+
display_value
|
|
5757
|
+
linked_item_ids
|
|
5758
|
+
}
|
|
5759
|
+
... on MirrorValue {
|
|
5760
|
+
display_value
|
|
5761
|
+
mirrored_items {
|
|
5762
|
+
linked_board_id
|
|
5763
|
+
}
|
|
5764
|
+
}
|
|
5765
|
+
... on DependencyValue {
|
|
5766
|
+
display_value
|
|
5767
|
+
linked_item_ids
|
|
5768
|
+
linked_items {
|
|
5769
|
+
id
|
|
5770
|
+
name
|
|
5771
|
+
}
|
|
5772
|
+
}
|
|
5773
|
+
}
|
|
5774
|
+
`;
|
|
5775
|
+
}
|
|
5776
|
+
}
|
|
5188
5777
|
const querySubitems = `
|
|
5189
5778
|
subitems {
|
|
5190
5779
|
id
|
|
@@ -5245,7 +5834,7 @@ class Worktables {
|
|
|
5245
5834
|
body: { query },
|
|
5246
5835
|
});
|
|
5247
5836
|
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
5248
|
-
const itemsPage = (
|
|
5837
|
+
const itemsPage = (_31 = (_30 = (_29 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _29 === void 0 ? void 0 : _29.boards) === null || _30 === void 0 ? void 0 : _30[0]) === null || _31 === void 0 ? void 0 : _31.items_page;
|
|
5249
5838
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5250
5839
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
5251
5840
|
allItems = allItems.concat(items);
|
|
@@ -5320,11 +5909,13 @@ class Worktables {
|
|
|
5320
5909
|
case 'searchItems': {
|
|
5321
5910
|
const boardId = this.getNodeParameter('boardId', 0);
|
|
5322
5911
|
const fetchColumnValues = this.getNodeParameter('fetchColumnValues', 0, false);
|
|
5912
|
+
const fetchAllColumns = this.getNodeParameter('fetchAllColumns', 0, true);
|
|
5913
|
+
const columnIdsRaw = this.getNodeParameter('columnIds', 0, '');
|
|
5323
5914
|
const filterRules = this.getNodeParameter('filterRules', 0);
|
|
5324
5915
|
const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
|
|
5325
5916
|
const logicalOperator = this.getNodeParameter('logicalOperator', 0);
|
|
5326
5917
|
let rulesArray = [];
|
|
5327
|
-
if (((
|
|
5918
|
+
if (((_32 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _32 === void 0 ? void 0 : _32.length) > 0) {
|
|
5328
5919
|
rulesArray = filterRules.rule.map((rule) => {
|
|
5329
5920
|
let formattedValue;
|
|
5330
5921
|
if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
|
|
@@ -5368,7 +5959,7 @@ class Worktables {
|
|
|
5368
5959
|
});
|
|
5369
5960
|
}
|
|
5370
5961
|
const orderByArray = [];
|
|
5371
|
-
if (((
|
|
5962
|
+
if (((_33 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _33 === void 0 ? void 0 : _33.length) > 0) {
|
|
5372
5963
|
sortOptions.sortBy.forEach((sort) => {
|
|
5373
5964
|
orderByArray.push(`{
|
|
5374
5965
|
column_id: "${sort.columnId}",
|
|
@@ -5376,17 +5967,42 @@ class Worktables {
|
|
|
5376
5967
|
}`);
|
|
5377
5968
|
});
|
|
5378
5969
|
}
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
${orderByArray.length > 0 ? `order_by: [${orderByArray.join(', ')}]` : ''}
|
|
5385
|
-
}) {
|
|
5386
|
-
items {
|
|
5970
|
+
let queryColumnValues = '';
|
|
5971
|
+
if (fetchColumnValues) {
|
|
5972
|
+
if (fetchAllColumns) {
|
|
5973
|
+
queryColumnValues = `
|
|
5974
|
+
column_values {
|
|
5387
5975
|
id
|
|
5388
|
-
|
|
5389
|
-
|
|
5976
|
+
text
|
|
5977
|
+
value
|
|
5978
|
+
type
|
|
5979
|
+
... on BoardRelationValue {
|
|
5980
|
+
display_value
|
|
5981
|
+
linked_item_ids
|
|
5982
|
+
}
|
|
5983
|
+
... on MirrorValue {
|
|
5984
|
+
display_value
|
|
5985
|
+
mirrored_items {
|
|
5986
|
+
linked_board_id
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5989
|
+
... on DependencyValue {
|
|
5990
|
+
display_value
|
|
5991
|
+
linked_item_ids
|
|
5992
|
+
linked_items {
|
|
5993
|
+
id
|
|
5994
|
+
name
|
|
5995
|
+
}
|
|
5996
|
+
}
|
|
5997
|
+
}
|
|
5998
|
+
`;
|
|
5999
|
+
}
|
|
6000
|
+
else if (columnIdsRaw && columnIdsRaw.trim()) {
|
|
6001
|
+
const specificColumnIds = columnIdsRaw.split(',').map(id => id.trim()).filter(id => id);
|
|
6002
|
+
if (specificColumnIds.length > 0) {
|
|
6003
|
+
const columnIdsString = specificColumnIds.map(id => `"${id}"`).join(', ');
|
|
6004
|
+
queryColumnValues = `
|
|
6005
|
+
column_values(ids: [${columnIdsString}]) {
|
|
5390
6006
|
id
|
|
5391
6007
|
text
|
|
5392
6008
|
value
|
|
@@ -5401,7 +6017,30 @@ class Worktables {
|
|
|
5401
6017
|
linked_board_id
|
|
5402
6018
|
}
|
|
5403
6019
|
}
|
|
6020
|
+
... on DependencyValue {
|
|
6021
|
+
display_value
|
|
6022
|
+
linked_item_ids
|
|
6023
|
+
linked_items {
|
|
6024
|
+
id
|
|
6025
|
+
name
|
|
6026
|
+
}
|
|
6027
|
+
}
|
|
5404
6028
|
}
|
|
6029
|
+
`;
|
|
6030
|
+
}
|
|
6031
|
+
}
|
|
6032
|
+
}
|
|
6033
|
+
const query = `query {
|
|
6034
|
+
boards(ids: [${boardId}]) {
|
|
6035
|
+
items_page(limit: 100, query_params: {
|
|
6036
|
+
${logicalOperator ? `operator: ${logicalOperator},` : ''}
|
|
6037
|
+
${rulesArray.length > 0 ? `rules: [${rulesArray.join(', ')}],` : ''}
|
|
6038
|
+
${orderByArray.length > 0 ? `order_by: [${orderByArray.join(', ')}]` : ''}
|
|
6039
|
+
}) {
|
|
6040
|
+
items {
|
|
6041
|
+
id
|
|
6042
|
+
name
|
|
6043
|
+
${queryColumnValues}
|
|
5405
6044
|
group {
|
|
5406
6045
|
id
|
|
5407
6046
|
title
|
|
@@ -5424,7 +6063,7 @@ class Worktables {
|
|
|
5424
6063
|
body: { query },
|
|
5425
6064
|
});
|
|
5426
6065
|
const parsed = JSON.parse(rawResponse);
|
|
5427
|
-
const items = ((
|
|
6066
|
+
const items = ((_37 = (_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) === null || _37 === void 0 ? void 0 : _37.items) || [];
|
|
5428
6067
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
5429
6068
|
const formatted = {
|
|
5430
6069
|
id: item.id,
|
|
@@ -5458,7 +6097,7 @@ class Worktables {
|
|
|
5458
6097
|
const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
|
|
5459
6098
|
const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
|
|
5460
6099
|
let rulesArray = [];
|
|
5461
|
-
if (((
|
|
6100
|
+
if (((_38 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _38 === void 0 ? void 0 : _38.length) > 0) {
|
|
5462
6101
|
console.log('Processing filter rules:', advancedFilterRules.rule);
|
|
5463
6102
|
rulesArray = advancedFilterRules.rule.map((rule) => {
|
|
5464
6103
|
let formattedValue;
|
|
@@ -5674,7 +6313,7 @@ class Worktables {
|
|
|
5674
6313
|
});
|
|
5675
6314
|
}
|
|
5676
6315
|
const orderByArray = [];
|
|
5677
|
-
if (((
|
|
6316
|
+
if (((_39 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _39 === void 0 ? void 0 : _39.length) > 0) {
|
|
5678
6317
|
advancedSortOptions.sortBy.forEach((sort) => {
|
|
5679
6318
|
orderByArray.push(`{
|
|
5680
6319
|
column_id: "${sort.columnId}",
|
|
@@ -5708,6 +6347,14 @@ class Worktables {
|
|
|
5708
6347
|
linked_board_id
|
|
5709
6348
|
}
|
|
5710
6349
|
}
|
|
6350
|
+
... on DependencyValue {
|
|
6351
|
+
display_value
|
|
6352
|
+
linked_item_ids
|
|
6353
|
+
linked_items {
|
|
6354
|
+
id
|
|
6355
|
+
name
|
|
6356
|
+
}
|
|
6357
|
+
}
|
|
5711
6358
|
}
|
|
5712
6359
|
group {
|
|
5713
6360
|
id
|
|
@@ -5756,7 +6403,7 @@ class Worktables {
|
|
|
5756
6403
|
body: { query: testQuery },
|
|
5757
6404
|
});
|
|
5758
6405
|
const testParsed = JSON.parse(testResponse);
|
|
5759
|
-
const testItems = ((
|
|
6406
|
+
const testItems = ((_43 = (_42 = (_41 = (_40 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.data) === null || _40 === void 0 ? void 0 : _40.boards) === null || _41 === void 0 ? void 0 : _41[0]) === null || _42 === void 0 ? void 0 : _42.items_page) === null || _43 === void 0 ? void 0 : _43.items) || [];
|
|
5760
6407
|
console.log('Test - Items in board (no filters):', testItems.length);
|
|
5761
6408
|
if (testItems.length > 0) {
|
|
5762
6409
|
console.log('Sample item column values:', testItems[0].column_values);
|
|
@@ -5768,7 +6415,7 @@ class Worktables {
|
|
|
5768
6415
|
body: { query },
|
|
5769
6416
|
});
|
|
5770
6417
|
const parsed = JSON.parse(rawResponse);
|
|
5771
|
-
const itemsPage = (
|
|
6418
|
+
const itemsPage = (_46 = (_45 = (_44 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _44 === void 0 ? void 0 : _44.boards) === null || _45 === void 0 ? void 0 : _45[0]) === null || _46 === void 0 ? void 0 : _46.items_page;
|
|
5772
6419
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5773
6420
|
const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
|
|
5774
6421
|
const hasMore = nextCursor ? true : false;
|
|
@@ -5847,16 +6494,17 @@ class Worktables {
|
|
|
5847
6494
|
console.warn(`Binary field '${binaryName}' not found. Skipping.`);
|
|
5848
6495
|
continue;
|
|
5849
6496
|
}
|
|
5850
|
-
const fileBuffer =
|
|
6497
|
+
const fileBuffer = await this.helpers.getBinaryDataBuffer(0, binaryName);
|
|
5851
6498
|
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension);
|
|
5852
|
-
console.log('Binary
|
|
6499
|
+
console.log('Binary Meta:', binaryData);
|
|
5853
6500
|
console.log('fileName:', fileName);
|
|
6501
|
+
console.log('buffer length:', fileBuffer.length);
|
|
5854
6502
|
const form = new form_data_1.default();
|
|
5855
6503
|
form.append('query', `mutation ($file: File!) {
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
6504
|
+
add_file_to_column (file: $file, item_id: ${itemId}, column_id: "${columnId}") {
|
|
6505
|
+
id
|
|
6506
|
+
}
|
|
6507
|
+
}`);
|
|
5860
6508
|
form.append('variables[file]', fileBuffer, {
|
|
5861
6509
|
filename: fileName,
|
|
5862
6510
|
contentType: binaryData.mimeType || 'application/octet-stream',
|
|
@@ -5864,13 +6512,14 @@ class Worktables {
|
|
|
5864
6512
|
const uploadFile = await axios_1.default.post('https://api.monday.com/v2/file', form, {
|
|
5865
6513
|
headers: {
|
|
5866
6514
|
Authorization: headers.Authorization,
|
|
5867
|
-
'API-Version':
|
|
6515
|
+
'API-Version': API_VERSION,
|
|
5868
6516
|
...form.getHeaders(),
|
|
5869
6517
|
},
|
|
5870
6518
|
maxContentLength: Infinity,
|
|
5871
6519
|
maxBodyLength: Infinity,
|
|
5872
6520
|
});
|
|
5873
6521
|
console.log(`Upload response for '${binaryName}':`, uploadFile.data);
|
|
6522
|
+
console.log('HERRRRRRROOOOO');
|
|
5874
6523
|
response = JSON.stringify(uploadFile.data);
|
|
5875
6524
|
}
|
|
5876
6525
|
break;
|
|
@@ -5879,29 +6528,74 @@ class Worktables {
|
|
|
5879
6528
|
const boardId = this.getNodeParameter('boardId', 0);
|
|
5880
6529
|
const groupId = this.getNodeParameter('groupId', 0);
|
|
5881
6530
|
const limit = this.getNodeParameter('limit', 0);
|
|
6531
|
+
const fetchAllColumns = this.getNodeParameter('fetchAllColumns', 0, true);
|
|
6532
|
+
const columnIdsRaw = this.getNodeParameter('columnIds', 0, '');
|
|
5882
6533
|
if (!boardId || !groupId) {
|
|
5883
6534
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5884
6535
|
message: 'Board ID and Group ID are required.',
|
|
5885
6536
|
});
|
|
5886
6537
|
}
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
6538
|
+
let queryColumnValues = '';
|
|
6539
|
+
if (fetchAllColumns) {
|
|
6540
|
+
queryColumnValues = `
|
|
6541
|
+
column_values {
|
|
6542
|
+
id
|
|
6543
|
+
text
|
|
6544
|
+
value
|
|
6545
|
+
type
|
|
6546
|
+
... on BoardRelationValue {
|
|
6547
|
+
display_value
|
|
6548
|
+
linked_item_ids
|
|
6549
|
+
}
|
|
6550
|
+
... on MirrorValue {
|
|
6551
|
+
display_value
|
|
6552
|
+
mirrored_items {
|
|
6553
|
+
linked_board_id
|
|
6554
|
+
}
|
|
6555
|
+
}
|
|
6556
|
+
... on DependencyValue {
|
|
6557
|
+
display_value
|
|
6558
|
+
linked_item_ids
|
|
6559
|
+
linked_items {
|
|
6560
|
+
id
|
|
6561
|
+
name
|
|
6562
|
+
}
|
|
5901
6563
|
}
|
|
5902
6564
|
}
|
|
5903
|
-
|
|
5904
|
-
|
|
6565
|
+
`;
|
|
6566
|
+
}
|
|
6567
|
+
else if (columnIdsRaw && columnIdsRaw.trim()) {
|
|
6568
|
+
const specificColumnIds = columnIdsRaw.split(',').map(id => id.trim()).filter(id => id);
|
|
6569
|
+
if (specificColumnIds.length > 0) {
|
|
6570
|
+
const columnIdsString = specificColumnIds.map(id => `"${id}"`).join(', ');
|
|
6571
|
+
queryColumnValues = `
|
|
6572
|
+
column_values(ids: [${columnIdsString}]) {
|
|
6573
|
+
id
|
|
6574
|
+
text
|
|
6575
|
+
value
|
|
6576
|
+
type
|
|
6577
|
+
... on BoardRelationValue {
|
|
6578
|
+
display_value
|
|
6579
|
+
linked_item_ids
|
|
6580
|
+
}
|
|
6581
|
+
... on MirrorValue {
|
|
6582
|
+
display_value
|
|
6583
|
+
mirrored_items {
|
|
6584
|
+
linked_board_id
|
|
6585
|
+
}
|
|
6586
|
+
}
|
|
6587
|
+
... on DependencyValue {
|
|
6588
|
+
display_value
|
|
6589
|
+
linked_item_ids
|
|
6590
|
+
linked_items {
|
|
6591
|
+
id
|
|
6592
|
+
name
|
|
6593
|
+
}
|
|
6594
|
+
}
|
|
6595
|
+
}
|
|
6596
|
+
`;
|
|
6597
|
+
}
|
|
6598
|
+
}
|
|
5905
6599
|
let allItems = [];
|
|
5906
6600
|
let cursor = null;
|
|
5907
6601
|
const pageLimit = 100;
|
|
@@ -5950,7 +6644,7 @@ class Worktables {
|
|
|
5950
6644
|
body: { query },
|
|
5951
6645
|
});
|
|
5952
6646
|
const parsed = JSON.parse(rawResponse);
|
|
5953
|
-
const itemsPage = (
|
|
6647
|
+
const itemsPage = (_51 = (_50 = (_49 = (_48 = (_47 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _47 === void 0 ? void 0 : _47.boards) === null || _48 === void 0 ? void 0 : _48[0]) === null || _49 === void 0 ? void 0 : _49.groups) === null || _50 === void 0 ? void 0 : _50[0]) === null || _51 === void 0 ? void 0 : _51.items_page;
|
|
5954
6648
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5955
6649
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
5956
6650
|
allItems = allItems.concat(items);
|
|
@@ -6003,84 +6697,121 @@ class Worktables {
|
|
|
6003
6697
|
break;
|
|
6004
6698
|
}
|
|
6005
6699
|
case 'update': {
|
|
6700
|
+
console.log(`>>>>>> UPDATE RESOURCE - operation: "${operation}" - v1.0.28 <<<<<<`);
|
|
6006
6701
|
switch (operation) {
|
|
6007
6702
|
case 'listUpdates': {
|
|
6008
6703
|
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
|
-
|
|
6704
|
+
const limit = this.getNodeParameter('limit', 0, 25);
|
|
6705
|
+
const fromDate = this.getNodeParameter('fromDate', 0, '');
|
|
6706
|
+
const toDate = this.getNodeParameter('toDate', 0, '');
|
|
6707
|
+
const updatesParams = [];
|
|
6708
|
+
if (limit > 0) {
|
|
6709
|
+
updatesParams.push(`limit: ${limit}`);
|
|
6710
|
+
}
|
|
6711
|
+
let allUpdates = [];
|
|
6712
|
+
let page = 1;
|
|
6713
|
+
const pageLimit = limit === 0 ? 100 : limit;
|
|
6714
|
+
do {
|
|
6715
|
+
const currentParams = [...updatesParams];
|
|
6716
|
+
if (limit === 0) {
|
|
6717
|
+
currentParams.push(`limit: ${pageLimit}`);
|
|
6718
|
+
currentParams.push(`page: ${page}`);
|
|
6719
|
+
}
|
|
6720
|
+
const paramsString = currentParams.length > 0 ? `(${currentParams.join(', ')})` : '';
|
|
6721
|
+
const query = `
|
|
6722
|
+
query {
|
|
6723
|
+
items (ids: [${itemId}]) {
|
|
6724
|
+
updates${paramsString} {
|
|
6725
|
+
id
|
|
6726
|
+
text_body
|
|
6727
|
+
created_at
|
|
6728
|
+
updated_at
|
|
6729
|
+
creator {
|
|
6730
|
+
id
|
|
6731
|
+
name
|
|
6732
|
+
}
|
|
6733
|
+
assets {
|
|
6734
|
+
name
|
|
6735
|
+
public_url
|
|
6736
|
+
file_size
|
|
6737
|
+
}
|
|
6738
|
+
replies {
|
|
6739
|
+
text_body
|
|
6740
|
+
created_at
|
|
6741
|
+
creator {
|
|
6742
|
+
name
|
|
6743
|
+
}
|
|
6744
|
+
}
|
|
6745
|
+
pinned_to_top {
|
|
6746
|
+
item_id
|
|
6747
|
+
}
|
|
6031
6748
|
}
|
|
6032
6749
|
}
|
|
6033
|
-
pinned_to_top {
|
|
6034
|
-
item_id
|
|
6035
|
-
}
|
|
6036
|
-
}
|
|
6037
6750
|
}
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
headers,
|
|
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
|
-
};
|
|
6751
|
+
`;
|
|
6752
|
+
const rawResponse = await this.helpers.request({
|
|
6753
|
+
method: 'POST',
|
|
6754
|
+
url: 'https://api.monday.com/v2',
|
|
6755
|
+
headers,
|
|
6756
|
+
body: { query },
|
|
6058
6757
|
});
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6758
|
+
const parsedResponse = await (0, isErrorResponse_1.parseApiResponse)(rawResponse);
|
|
6759
|
+
if (!parsedResponse.success) {
|
|
6760
|
+
const parsed = JSON.parse(parsedResponse.data);
|
|
6761
|
+
const firstError = parsed.errors || { message: 'Unknown error' };
|
|
6762
|
+
const errorData = Array.isArray(firstError) ? firstError[0] : firstError;
|
|
6763
|
+
const continueOnFail = this.continueOnFail();
|
|
6764
|
+
if (continueOnFail) {
|
|
6765
|
+
return [[{
|
|
6766
|
+
json: {
|
|
6767
|
+
error: {
|
|
6768
|
+
message: errorData.message || 'Unknown error',
|
|
6769
|
+
details: errorData,
|
|
6770
|
+
}
|
|
6072
6771
|
}
|
|
6073
|
-
}
|
|
6074
|
-
|
|
6772
|
+
}]];
|
|
6773
|
+
}
|
|
6774
|
+
else {
|
|
6775
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6776
|
+
message: errorData.message || 'Failed to list updates',
|
|
6777
|
+
});
|
|
6778
|
+
}
|
|
6075
6779
|
}
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6780
|
+
const parsed = JSON.parse(parsedResponse.data);
|
|
6781
|
+
const updates = ((_54 = (_53 = (_52 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _52 === void 0 ? void 0 : _52.items) === null || _53 === void 0 ? void 0 : _53[0]) === null || _54 === void 0 ? void 0 : _54.updates) || [];
|
|
6782
|
+
if (updates.length === 0) {
|
|
6783
|
+
break;
|
|
6784
|
+
}
|
|
6785
|
+
allUpdates = allUpdates.concat(updates);
|
|
6786
|
+
page++;
|
|
6787
|
+
if (limit > 0 || updates.length < pageLimit) {
|
|
6788
|
+
break;
|
|
6082
6789
|
}
|
|
6790
|
+
} while (limit === 0);
|
|
6791
|
+
let filteredUpdates = allUpdates;
|
|
6792
|
+
if (fromDate) {
|
|
6793
|
+
const fromDateTime = new Date(fromDate).getTime();
|
|
6794
|
+
filteredUpdates = filteredUpdates.filter((update) => {
|
|
6795
|
+
const updateDate = new Date(update.created_at).getTime();
|
|
6796
|
+
return updateDate >= fromDateTime;
|
|
6797
|
+
});
|
|
6083
6798
|
}
|
|
6799
|
+
if (toDate) {
|
|
6800
|
+
const toDateTime = new Date(toDate).getTime();
|
|
6801
|
+
filteredUpdates = filteredUpdates.filter((update) => {
|
|
6802
|
+
const updateDate = new Date(update.created_at).getTime();
|
|
6803
|
+
return updateDate <= toDateTime;
|
|
6804
|
+
});
|
|
6805
|
+
}
|
|
6806
|
+
const formattedUpdates = filteredUpdates.map((update) => {
|
|
6807
|
+
const pinnedToTop = update.pinned_to_top || [];
|
|
6808
|
+
const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
|
|
6809
|
+
return {
|
|
6810
|
+
...update,
|
|
6811
|
+
pinned_to_top: isPinnedToTop,
|
|
6812
|
+
};
|
|
6813
|
+
});
|
|
6814
|
+
return [formattedUpdates.map((update) => ({ json: update }))];
|
|
6084
6815
|
}
|
|
6085
6816
|
case 'createUpdate': {
|
|
6086
6817
|
const items = this.getInputData();
|
|
@@ -6128,7 +6859,7 @@ class Worktables {
|
|
|
6128
6859
|
console.log('variables:', variables);
|
|
6129
6860
|
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
6130
6861
|
console.log('Create Update Result:', JSON.stringify(response, null, 2));
|
|
6131
|
-
const updateId = (
|
|
6862
|
+
const updateId = (_56 = (_55 = JSON.parse(response).data) === null || _55 === void 0 ? void 0 : _55.create_update) === null || _56 === void 0 ? void 0 : _56.id;
|
|
6132
6863
|
if (!updateId) {
|
|
6133
6864
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6134
6865
|
message: 'Error creating update: Update not created, no ID returned',
|
|
@@ -6161,8 +6892,17 @@ class Worktables {
|
|
|
6161
6892
|
console.warn(`Item ${i}: Binary field '${binaryName}' not found. Skipping.`);
|
|
6162
6893
|
continue;
|
|
6163
6894
|
}
|
|
6164
|
-
const fileBuffer =
|
|
6165
|
-
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension
|
|
6895
|
+
const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryName);
|
|
6896
|
+
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension);
|
|
6897
|
+
console.log(`[createUpdate] Item ${i} - Binary '${binaryName}' info:`, {
|
|
6898
|
+
fileName,
|
|
6899
|
+
originalName: binaryData.fileName,
|
|
6900
|
+
extension: binaryData.fileExtension,
|
|
6901
|
+
mimeType: binaryData.mimeType,
|
|
6902
|
+
bufferLength: fileBuffer.length,
|
|
6903
|
+
isBuffer: Buffer.isBuffer(fileBuffer),
|
|
6904
|
+
firstBytes: fileBuffer.slice(0, 16).toString('hex'),
|
|
6905
|
+
});
|
|
6166
6906
|
const form = new form_data_1.default();
|
|
6167
6907
|
form.append('query', `mutation ($file: File!) {
|
|
6168
6908
|
add_file_to_update (update_id: ${updateId}, file: $file) {
|
|
@@ -6170,19 +6910,20 @@ class Worktables {
|
|
|
6170
6910
|
}
|
|
6171
6911
|
}`);
|
|
6172
6912
|
form.append('variables[file]', fileBuffer, {
|
|
6173
|
-
filename:
|
|
6913
|
+
filename: fileName,
|
|
6174
6914
|
contentType: binaryData.mimeType || 'application/octet-stream',
|
|
6175
6915
|
});
|
|
6176
6916
|
const uploadResponse = await axios_1.default.post('https://api.monday.com/v2/file', form, {
|
|
6177
6917
|
headers: {
|
|
6178
6918
|
Authorization: headers.Authorization,
|
|
6179
|
-
'API-Version':
|
|
6919
|
+
'API-Version': API_VERSION,
|
|
6180
6920
|
...form.getHeaders(),
|
|
6181
6921
|
},
|
|
6182
6922
|
maxContentLength: Infinity,
|
|
6183
6923
|
maxBodyLength: Infinity,
|
|
6184
6924
|
});
|
|
6185
|
-
console.log(
|
|
6925
|
+
console.log('HERRRRRRROOOOO');
|
|
6926
|
+
console.log(`[createUpdate] Item ${i} - Upload response for '${binaryName}':`, JSON.stringify(uploadResponse.data));
|
|
6186
6927
|
}
|
|
6187
6928
|
}
|
|
6188
6929
|
break;
|
|
@@ -6214,6 +6955,7 @@ class Worktables {
|
|
|
6214
6955
|
const attachmentsString = this.getNodeParameter('attachmentsUpdate', i);
|
|
6215
6956
|
const binaryNames = (0, worktablesHelpers_1.parseBinaryNames)(attachmentsString);
|
|
6216
6957
|
console.log(`Item ${i} - Binary names to process:`, binaryNames);
|
|
6958
|
+
console.log('HEREEEEEEE:', updateId);
|
|
6217
6959
|
for (const binaryName of binaryNames) {
|
|
6218
6960
|
let binaryData;
|
|
6219
6961
|
try {
|
|
@@ -6223,28 +6965,38 @@ class Worktables {
|
|
|
6223
6965
|
console.warn(`Item ${i}: Binary field '${binaryName}' not found. Skipping.`);
|
|
6224
6966
|
continue;
|
|
6225
6967
|
}
|
|
6226
|
-
const fileBuffer =
|
|
6227
|
-
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension
|
|
6968
|
+
const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryName);
|
|
6969
|
+
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension);
|
|
6970
|
+
console.log(`[updateUpdate] Item ${i} - Binary '${binaryName}' info:`, {
|
|
6971
|
+
fileName,
|
|
6972
|
+
originalName: binaryData.fileName,
|
|
6973
|
+
extension: binaryData.fileExtension,
|
|
6974
|
+
mimeType: binaryData.mimeType,
|
|
6975
|
+
bufferLength: fileBuffer.length,
|
|
6976
|
+
isBuffer: Buffer.isBuffer(fileBuffer),
|
|
6977
|
+
firstBytes: fileBuffer.slice(0, 16).toString('hex'),
|
|
6978
|
+
});
|
|
6228
6979
|
const form = new form_data_1.default();
|
|
6229
6980
|
form.append('query', `mutation ($file: File!) {
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6981
|
+
add_file_to_update (update_id: ${updateId}, file: $file) {
|
|
6982
|
+
id
|
|
6983
|
+
}
|
|
6984
|
+
}`);
|
|
6234
6985
|
form.append('variables[file]', fileBuffer, {
|
|
6235
|
-
filename:
|
|
6986
|
+
filename: fileName,
|
|
6236
6987
|
contentType: binaryData.mimeType || 'application/octet-stream',
|
|
6237
6988
|
});
|
|
6238
6989
|
const uploadResponse = await axios_1.default.post('https://api.monday.com/v2/file', form, {
|
|
6239
6990
|
headers: {
|
|
6240
6991
|
Authorization: headers.Authorization,
|
|
6241
|
-
'API-Version':
|
|
6992
|
+
'API-Version': API_VERSION,
|
|
6242
6993
|
...form.getHeaders(),
|
|
6243
6994
|
},
|
|
6244
6995
|
maxContentLength: Infinity,
|
|
6245
6996
|
maxBodyLength: Infinity,
|
|
6246
6997
|
});
|
|
6247
|
-
console.log(
|
|
6998
|
+
console.log('HERRRRRRROOOOO');
|
|
6999
|
+
console.log(`[updateUpdate] Item ${i} - Upload response for '${binaryName}':`, JSON.stringify(uploadResponse.data));
|
|
6248
7000
|
}
|
|
6249
7001
|
}
|
|
6250
7002
|
break;
|
|
@@ -6312,9 +7064,11 @@ class Worktables {
|
|
|
6312
7064
|
return [[{ json: JSON.parse(response) }]];
|
|
6313
7065
|
}
|
|
6314
7066
|
case 'uploadFile': {
|
|
7067
|
+
console.log('>>>>>> UPLOAD FILE OPERATION ENTERED v1.0.27 <<<<<<');
|
|
6315
7068
|
const items = this.getInputData();
|
|
6316
7069
|
const updateId = this.getNodeParameter('updateId', 0);
|
|
6317
7070
|
const attachmentsRaw = this.getNodeParameter('attachmentsUpdate', 0);
|
|
7071
|
+
console.log('>>>>>> uploadFile params:', { updateId, attachmentsRaw, itemsCount: items.length });
|
|
6318
7072
|
if (!updateId || !attachmentsRaw) {
|
|
6319
7073
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6320
7074
|
message: 'Update ID and attachmentsUpdate (binary names) are required.',
|
|
@@ -6331,9 +7085,17 @@ class Worktables {
|
|
|
6331
7085
|
console.warn(`Item ${i}: Binary field '${binaryName}' not found. Skipping.`);
|
|
6332
7086
|
continue;
|
|
6333
7087
|
}
|
|
6334
|
-
const fileBuffer =
|
|
7088
|
+
const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryName);
|
|
6335
7089
|
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension);
|
|
6336
|
-
console.log(`Item ${i} -
|
|
7090
|
+
console.log(`[uploadFile] Item ${i} - Binary '${binaryName}' info:`, {
|
|
7091
|
+
fileName,
|
|
7092
|
+
originalName: binaryData.fileName,
|
|
7093
|
+
extension: binaryData.fileExtension,
|
|
7094
|
+
mimeType: binaryData.mimeType,
|
|
7095
|
+
bufferLength: fileBuffer.length,
|
|
7096
|
+
isBuffer: Buffer.isBuffer(fileBuffer),
|
|
7097
|
+
firstBytes: fileBuffer.slice(0, 16).toString('hex'),
|
|
7098
|
+
});
|
|
6337
7099
|
const form = new form_data_1.default();
|
|
6338
7100
|
form.append('query', `mutation ($file: File!) {
|
|
6339
7101
|
add_file_to_update (update_id: ${updateId}, file: $file) {
|
|
@@ -6347,13 +7109,14 @@ class Worktables {
|
|
|
6347
7109
|
const uploadResponse = await axios_1.default.post('https://api.monday.com/v2/file', form, {
|
|
6348
7110
|
headers: {
|
|
6349
7111
|
Authorization: headers.Authorization,
|
|
6350
|
-
'API-Version':
|
|
7112
|
+
'API-Version': API_VERSION,
|
|
6351
7113
|
...form.getHeaders(),
|
|
6352
7114
|
},
|
|
6353
7115
|
maxContentLength: Infinity,
|
|
6354
7116
|
maxBodyLength: Infinity,
|
|
6355
7117
|
});
|
|
6356
|
-
console.log(
|
|
7118
|
+
console.log('HERRRRRRROOOOO');
|
|
7119
|
+
console.log(`[uploadFile] Item ${i} - Upload response for '${binaryName}':`, JSON.stringify(uploadResponse.data));
|
|
6357
7120
|
response = JSON.stringify(uploadResponse.data);
|
|
6358
7121
|
}
|
|
6359
7122
|
}
|
|
@@ -6496,7 +7259,7 @@ class Worktables {
|
|
|
6496
7259
|
body: { query },
|
|
6497
7260
|
json: true,
|
|
6498
7261
|
});
|
|
6499
|
-
const asset = (
|
|
7262
|
+
const asset = (_58 = (_57 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _57 === void 0 ? void 0 : _57.assets) === null || _58 === void 0 ? void 0 : _58[0];
|
|
6500
7263
|
if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
|
|
6501
7264
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6502
7265
|
message: 'Public URL not found for the given file ID.',
|
|
@@ -6525,23 +7288,91 @@ class Worktables {
|
|
|
6525
7288
|
case 'query': {
|
|
6526
7289
|
const runQuery = this.getNodeParameter('runQuery', 0);
|
|
6527
7290
|
const apiVersion = this.getNodeParameter('apiVersion', 0);
|
|
7291
|
+
const includePagination = this.getNodeParameter('includePagination', 0);
|
|
7292
|
+
console.log('HERRRRRRROOOOO');
|
|
6528
7293
|
if (!runQuery) {
|
|
6529
7294
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Invalid item data.' });
|
|
6530
7295
|
}
|
|
6531
7296
|
switch (operation) {
|
|
6532
7297
|
case 'query': {
|
|
6533
|
-
console.log('Run Query:', runQuery);
|
|
6534
7298
|
const apiUrl = `https://api.monday.com/v2`;
|
|
6535
7299
|
const queryHeaders = {
|
|
6536
7300
|
...headers,
|
|
6537
7301
|
'API-Version': apiVersion,
|
|
6538
7302
|
};
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
7303
|
+
if (includePagination) {
|
|
7304
|
+
const paginationType = this.getNodeParameter('paginationType', 0);
|
|
7305
|
+
let allData = [];
|
|
7306
|
+
if (paginationType === 'cursor') {
|
|
7307
|
+
let cursor = null;
|
|
7308
|
+
let currentQuery = runQuery;
|
|
7309
|
+
do {
|
|
7310
|
+
if (cursor) {
|
|
7311
|
+
currentQuery = runQuery.replace(/cursor:\s*"[^"]*"/, `cursor: "${cursor}"`);
|
|
7312
|
+
if (!runQuery.includes('cursor:')) {
|
|
7313
|
+
currentQuery = runQuery.replace(/(items_page\s*\([^)]*)(limit:\s*\d+)/, `$1$2, cursor: "${cursor}"`);
|
|
7314
|
+
}
|
|
7315
|
+
}
|
|
7316
|
+
const rawResponse = await this.helpers.request({
|
|
7317
|
+
method: 'POST',
|
|
7318
|
+
url: apiUrl,
|
|
7319
|
+
headers: queryHeaders,
|
|
7320
|
+
body: { query: currentQuery },
|
|
7321
|
+
});
|
|
7322
|
+
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
7323
|
+
const itemsPage = (_61 = (_60 = (_59 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _59 === void 0 ? void 0 : _59.boards) === null || _60 === void 0 ? void 0 : _60[0]) === null || _61 === void 0 ? void 0 : _61.items_page;
|
|
7324
|
+
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
7325
|
+
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
7326
|
+
allData = allData.concat(items);
|
|
7327
|
+
} while (cursor);
|
|
7328
|
+
response = JSON.stringify({ data: { items: allData }, totalCount: allData.length });
|
|
7329
|
+
}
|
|
7330
|
+
else {
|
|
7331
|
+
let page = 1;
|
|
7332
|
+
while (true) {
|
|
7333
|
+
const currentQuery = runQuery.replace(/page:\s*\d+/, `page: ${page}`);
|
|
7334
|
+
console.log(`[Pagination] Fetching page ${page}`);
|
|
7335
|
+
console.log(`[Pagination] Query: ${currentQuery}`);
|
|
7336
|
+
const rawResponse = await this.helpers.request({
|
|
7337
|
+
method: 'POST',
|
|
7338
|
+
url: apiUrl,
|
|
7339
|
+
headers: queryHeaders,
|
|
7340
|
+
body: { query: currentQuery },
|
|
7341
|
+
});
|
|
7342
|
+
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
7343
|
+
if ((parsed === null || parsed === void 0 ? void 0 : parsed.errors) && parsed.errors.length > 0) {
|
|
7344
|
+
console.log(`[Pagination] API Error on page ${page}:`, JSON.stringify(parsed.errors));
|
|
7345
|
+
break;
|
|
7346
|
+
}
|
|
7347
|
+
let data = [];
|
|
7348
|
+
if (parsed === null || parsed === void 0 ? void 0 : parsed.data) {
|
|
7349
|
+
for (const key of Object.keys(parsed.data)) {
|
|
7350
|
+
if (Array.isArray(parsed.data[key])) {
|
|
7351
|
+
data = parsed.data[key];
|
|
7352
|
+
console.log(`[Pagination] Page ${page}: found ${data.length} items in "${key}"`);
|
|
7353
|
+
break;
|
|
7354
|
+
}
|
|
7355
|
+
}
|
|
7356
|
+
}
|
|
7357
|
+
if (data.length === 0) {
|
|
7358
|
+
console.log(`[Pagination] Page ${page}: empty data, stopping`);
|
|
7359
|
+
break;
|
|
7360
|
+
}
|
|
7361
|
+
allData = allData.concat(data);
|
|
7362
|
+
page++;
|
|
7363
|
+
}
|
|
7364
|
+
console.log(`[Pagination] Total fetched: ${allData.length} items`);
|
|
7365
|
+
response = JSON.stringify({ data: allData, totalCount: allData.length });
|
|
7366
|
+
}
|
|
7367
|
+
}
|
|
7368
|
+
else {
|
|
7369
|
+
response = await this.helpers.request({
|
|
7370
|
+
method: 'POST',
|
|
7371
|
+
url: apiUrl,
|
|
7372
|
+
headers: queryHeaders,
|
|
7373
|
+
body: { query: runQuery },
|
|
7374
|
+
});
|
|
7375
|
+
}
|
|
6545
7376
|
break;
|
|
6546
7377
|
}
|
|
6547
7378
|
default:
|
|
@@ -6560,6 +7391,7 @@ class Worktables {
|
|
|
6560
7391
|
headers: {
|
|
6561
7392
|
Authorization: `Bearer ${apiKey}`,
|
|
6562
7393
|
'Content-Type': 'application/json',
|
|
7394
|
+
'API-Version': API_VERSION,
|
|
6563
7395
|
},
|
|
6564
7396
|
body: {
|
|
6565
7397
|
query: `{
|
|
@@ -6591,6 +7423,7 @@ class Worktables {
|
|
|
6591
7423
|
headers: {
|
|
6592
7424
|
Authorization: `Bearer ${apiKey}`,
|
|
6593
7425
|
'Content-Type': 'application/json',
|
|
7426
|
+
'API-Version': API_VERSION,
|
|
6594
7427
|
},
|
|
6595
7428
|
body: {
|
|
6596
7429
|
query: `{
|
|
@@ -6617,6 +7450,36 @@ class Worktables {
|
|
|
6617
7450
|
}
|
|
6618
7451
|
break;
|
|
6619
7452
|
}
|
|
7453
|
+
case 'notification': {
|
|
7454
|
+
switch (operation) {
|
|
7455
|
+
case 'sendNotification': {
|
|
7456
|
+
const userId = this.getNodeParameter('notificationUserId', 0);
|
|
7457
|
+
const targetId = this.getNodeParameter('notificationTargetId', 0);
|
|
7458
|
+
const targetType = this.getNodeParameter('notificationTargetType', 0);
|
|
7459
|
+
const text = this.getNodeParameter('notificationMessage', 0);
|
|
7460
|
+
const escapedText = (0, worktablesHelpers_1.escapeGraphQLString)(text);
|
|
7461
|
+
const mutation = `mutation {
|
|
7462
|
+
create_notification(
|
|
7463
|
+
text: "${escapedText}",
|
|
7464
|
+
user_id: ${parseInt(userId, 10)},
|
|
7465
|
+
target_id: ${parseInt(targetId, 10)},
|
|
7466
|
+
target_type: ${targetType}
|
|
7467
|
+
) {
|
|
7468
|
+
id
|
|
7469
|
+
text
|
|
7470
|
+
}
|
|
7471
|
+
}`;
|
|
7472
|
+
response = await this.helpers.request({
|
|
7473
|
+
method: 'POST',
|
|
7474
|
+
url: 'https://api.monday.com/v2',
|
|
7475
|
+
headers,
|
|
7476
|
+
body: { query: mutation },
|
|
7477
|
+
});
|
|
7478
|
+
break;
|
|
7479
|
+
}
|
|
7480
|
+
}
|
|
7481
|
+
break;
|
|
7482
|
+
}
|
|
6620
7483
|
default:
|
|
6621
7484
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: `Unsupported resource: ${resource}` });
|
|
6622
7485
|
}
|