@worktables/n8n-nodes-worktables-staging 1.0.3 → 1.0.6
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.
|
@@ -435,6 +435,26 @@ class Worktables {
|
|
|
435
435
|
description: 'Monday.com API version (e.g., 2025-01, 2024-10)',
|
|
436
436
|
displayOptions: { show: { resource: ['query'] } },
|
|
437
437
|
},
|
|
438
|
+
{
|
|
439
|
+
displayName: 'Include Pagination',
|
|
440
|
+
name: 'includePagination',
|
|
441
|
+
type: 'boolean',
|
|
442
|
+
default: false,
|
|
443
|
+
description: 'Whether to automatically fetch all pages of data',
|
|
444
|
+
displayOptions: { show: { resource: ['query'] } },
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
displayName: 'Pagination Type',
|
|
448
|
+
name: 'paginationType',
|
|
449
|
+
type: 'options',
|
|
450
|
+
options: [
|
|
451
|
+
{ name: 'Page', value: 'page' },
|
|
452
|
+
{ name: 'Cursor', value: 'cursor' },
|
|
453
|
+
],
|
|
454
|
+
default: 'cursor',
|
|
455
|
+
description: 'Type of pagination used in your query',
|
|
456
|
+
displayOptions: { show: { resource: ['query'], includePagination: [true] } },
|
|
457
|
+
},
|
|
438
458
|
{
|
|
439
459
|
displayName: 'Operation',
|
|
440
460
|
name: 'operation',
|
|
@@ -3238,7 +3258,7 @@ class Worktables {
|
|
|
3238
3258
|
};
|
|
3239
3259
|
}
|
|
3240
3260
|
async execute() {
|
|
3241
|
-
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;
|
|
3261
|
+
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;
|
|
3242
3262
|
const resource = this.getNodeParameter('resource', 0);
|
|
3243
3263
|
const operation = this.getNodeParameter('operation', 0);
|
|
3244
3264
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
@@ -6624,23 +6644,76 @@ class Worktables {
|
|
|
6624
6644
|
case 'query': {
|
|
6625
6645
|
const runQuery = this.getNodeParameter('runQuery', 0);
|
|
6626
6646
|
const apiVersion = this.getNodeParameter('apiVersion', 0);
|
|
6647
|
+
const includePagination = this.getNodeParameter('includePagination', 0);
|
|
6627
6648
|
if (!runQuery) {
|
|
6628
6649
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Invalid item data.' });
|
|
6629
6650
|
}
|
|
6630
6651
|
switch (operation) {
|
|
6631
6652
|
case 'query': {
|
|
6632
|
-
console.log('Run Query:', runQuery);
|
|
6633
6653
|
const apiUrl = `https://api.monday.com/v2`;
|
|
6634
6654
|
const queryHeaders = {
|
|
6635
6655
|
...headers,
|
|
6636
6656
|
'API-Version': apiVersion,
|
|
6637
6657
|
};
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6658
|
+
if (includePagination) {
|
|
6659
|
+
const paginationType = this.getNodeParameter('paginationType', 0);
|
|
6660
|
+
let allData = [];
|
|
6661
|
+
if (paginationType === 'cursor') {
|
|
6662
|
+
let cursor = null;
|
|
6663
|
+
let currentQuery = runQuery;
|
|
6664
|
+
do {
|
|
6665
|
+
if (cursor) {
|
|
6666
|
+
currentQuery = runQuery.replace(/cursor:\s*"[^"]*"/, `cursor: "${cursor}"`);
|
|
6667
|
+
if (!runQuery.includes('cursor:')) {
|
|
6668
|
+
currentQuery = runQuery.replace(/(items_page\s*\([^)]*)(limit:\s*\d+)/, `$1$2, cursor: "${cursor}"`);
|
|
6669
|
+
}
|
|
6670
|
+
}
|
|
6671
|
+
const rawResponse = await this.helpers.request({
|
|
6672
|
+
method: 'POST',
|
|
6673
|
+
url: apiUrl,
|
|
6674
|
+
headers: queryHeaders,
|
|
6675
|
+
body: { query: currentQuery },
|
|
6676
|
+
});
|
|
6677
|
+
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
6678
|
+
const itemsPage = (_50 = (_49 = (_48 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _48 === void 0 ? void 0 : _48.boards) === null || _49 === void 0 ? void 0 : _49[0]) === null || _50 === void 0 ? void 0 : _50.items_page;
|
|
6679
|
+
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
6680
|
+
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
6681
|
+
allData = allData.concat(items);
|
|
6682
|
+
} while (cursor);
|
|
6683
|
+
response = JSON.stringify({ data: { items: allData }, totalCount: allData.length });
|
|
6684
|
+
}
|
|
6685
|
+
else {
|
|
6686
|
+
let page = 1;
|
|
6687
|
+
let hasMore = true;
|
|
6688
|
+
while (hasMore) {
|
|
6689
|
+
const currentQuery = runQuery.replace(/page:\s*\d+/, `page: ${page}`);
|
|
6690
|
+
const rawResponse = await this.helpers.request({
|
|
6691
|
+
method: 'POST',
|
|
6692
|
+
url: apiUrl,
|
|
6693
|
+
headers: queryHeaders,
|
|
6694
|
+
body: { query: currentQuery },
|
|
6695
|
+
});
|
|
6696
|
+
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
6697
|
+
const data = ((_51 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _51 === void 0 ? void 0 : _51.boards) || ((_52 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _52 === void 0 ? void 0 : _52.users) || ((_53 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _53 === void 0 ? void 0 : _53.workspaces) || [];
|
|
6698
|
+
if (data.length === 0) {
|
|
6699
|
+
hasMore = false;
|
|
6700
|
+
}
|
|
6701
|
+
else {
|
|
6702
|
+
allData = allData.concat(data);
|
|
6703
|
+
page++;
|
|
6704
|
+
}
|
|
6705
|
+
}
|
|
6706
|
+
response = JSON.stringify({ data: allData, totalCount: allData.length });
|
|
6707
|
+
}
|
|
6708
|
+
}
|
|
6709
|
+
else {
|
|
6710
|
+
response = await this.helpers.request({
|
|
6711
|
+
method: 'POST',
|
|
6712
|
+
url: apiUrl,
|
|
6713
|
+
headers: queryHeaders,
|
|
6714
|
+
body: { query: runQuery },
|
|
6715
|
+
});
|
|
6716
|
+
}
|
|
6644
6717
|
break;
|
|
6645
6718
|
}
|
|
6646
6719
|
default:
|