@worktables/n8n-nodes-worktables 12.11.0 → 12.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3178,7 +3178,7 @@ class Worktables {
|
|
|
3178
3178
|
};
|
|
3179
3179
|
}
|
|
3180
3180
|
async execute() {
|
|
3181
|
-
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;
|
|
3181
|
+
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;
|
|
3182
3182
|
const resource = this.getNodeParameter('resource', 0);
|
|
3183
3183
|
const operation = this.getNodeParameter('operation', 0);
|
|
3184
3184
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
@@ -5062,30 +5062,61 @@ class Worktables {
|
|
|
5062
5062
|
console.log('Getting activity logs for item:', itemId);
|
|
5063
5063
|
console.log('From: ', from);
|
|
5064
5064
|
console.log('To: ', to);
|
|
5065
|
-
|
|
5066
|
-
if (from || to) {
|
|
5067
|
-
const fromParam = from ? `from: "${from}Z"` : '';
|
|
5068
|
-
const toParam = to ? `to: "${to}Z"` : '';
|
|
5069
|
-
const params = [fromParam, toParam].filter(p => p).join(', ');
|
|
5070
|
-
activityLogsQuery = `activity_logs (${params})`;
|
|
5071
|
-
}
|
|
5072
|
-
const query = `
|
|
5065
|
+
const itemQuery = `
|
|
5073
5066
|
query {
|
|
5074
5067
|
items(ids: ["${itemId}"]) {
|
|
5075
5068
|
id
|
|
5076
5069
|
name
|
|
5077
|
-
|
|
5070
|
+
board {
|
|
5071
|
+
id
|
|
5072
|
+
}
|
|
5073
|
+
}
|
|
5074
|
+
}
|
|
5075
|
+
`;
|
|
5076
|
+
console.log('Item Query: ', itemQuery);
|
|
5077
|
+
let itemResponse = await this.helpers.request({
|
|
5078
|
+
method: 'POST',
|
|
5079
|
+
url: 'https://api.monday.com/v2',
|
|
5080
|
+
headers,
|
|
5081
|
+
body: { query: itemQuery },
|
|
5082
|
+
});
|
|
5083
|
+
const itemParsed = typeof itemResponse === 'string' ? JSON.parse(itemResponse) : itemResponse;
|
|
5084
|
+
if (itemParsed.errors) {
|
|
5085
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(itemParsed.errors) });
|
|
5086
|
+
}
|
|
5087
|
+
const items = ((_16 = itemParsed === null || itemParsed === void 0 ? void 0 : itemParsed.data) === null || _16 === void 0 ? void 0 : _16.items) || [];
|
|
5088
|
+
if (items.length === 0) {
|
|
5089
|
+
return [[{ json: { item_id: itemId, activity_logs: [] } }]];
|
|
5090
|
+
}
|
|
5091
|
+
const item = items[0];
|
|
5092
|
+
const boardId = (_17 = item.board) === null || _17 === void 0 ? void 0 : _17.id;
|
|
5093
|
+
if (!boardId) {
|
|
5094
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Could not retrieve board ID for the item.' });
|
|
5095
|
+
}
|
|
5096
|
+
const params = [`item_ids: ["${itemId}"]`];
|
|
5097
|
+
if (from) {
|
|
5098
|
+
params.push(`from: "${from}Z"`);
|
|
5099
|
+
}
|
|
5100
|
+
if (to) {
|
|
5101
|
+
params.push(`to: "${to}Z"`);
|
|
5102
|
+
}
|
|
5103
|
+
const paramsString = params.join(', ');
|
|
5104
|
+
const query = `
|
|
5105
|
+
query {
|
|
5106
|
+
boards(ids: [${boardId}]) {
|
|
5107
|
+
activity_logs(${paramsString}) {
|
|
5078
5108
|
id
|
|
5079
5109
|
user_id
|
|
5080
5110
|
entity
|
|
5081
5111
|
event
|
|
5082
5112
|
data
|
|
5113
|
+
account_id
|
|
5083
5114
|
created_at
|
|
5084
5115
|
}
|
|
5085
5116
|
}
|
|
5086
5117
|
}
|
|
5087
5118
|
`;
|
|
5088
|
-
console.log('Query: ', query);
|
|
5119
|
+
console.log('Activity Logs Query: ', query);
|
|
5089
5120
|
response = await this.helpers.request({
|
|
5090
5121
|
method: 'POST',
|
|
5091
5122
|
url: 'https://api.monday.com/v2',
|
|
@@ -5096,23 +5127,32 @@ class Worktables {
|
|
|
5096
5127
|
if (parsed.errors) {
|
|
5097
5128
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(parsed.errors) });
|
|
5098
5129
|
}
|
|
5099
|
-
const
|
|
5100
|
-
|
|
5101
|
-
return [[{ json: { item_id: itemId, activity_logs: [] } }]];
|
|
5102
|
-
}
|
|
5103
|
-
const item = items[0];
|
|
5104
|
-
const activityLogs = item.activity_logs || [];
|
|
5130
|
+
const boards = ((_18 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _18 === void 0 ? void 0 : _18.boards) || [];
|
|
5131
|
+
const activityLogs = boards.length > 0 ? (boards[0].activity_logs || []) : [];
|
|
5105
5132
|
const formatted = {
|
|
5106
5133
|
item_id: item.id,
|
|
5107
5134
|
item_name: item.name,
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5135
|
+
board_id: boardId,
|
|
5136
|
+
activity_logs: activityLogs.map((log) => {
|
|
5137
|
+
let parsedData = log.data;
|
|
5138
|
+
if (typeof log.data === 'string') {
|
|
5139
|
+
try {
|
|
5140
|
+
parsedData = JSON.parse(log.data);
|
|
5141
|
+
}
|
|
5142
|
+
catch (e) {
|
|
5143
|
+
parsedData = log.data;
|
|
5144
|
+
}
|
|
5145
|
+
}
|
|
5146
|
+
return {
|
|
5147
|
+
id: log.id,
|
|
5148
|
+
user_id: log.user_id,
|
|
5149
|
+
entity: log.entity,
|
|
5150
|
+
event: log.event,
|
|
5151
|
+
data: parsedData,
|
|
5152
|
+
account_id: log.account_id,
|
|
5153
|
+
created_at: log.created_at,
|
|
5154
|
+
};
|
|
5155
|
+
}),
|
|
5116
5156
|
};
|
|
5117
5157
|
return [[{ json: formatted }]];
|
|
5118
5158
|
}
|
|
@@ -5246,7 +5286,7 @@ class Worktables {
|
|
|
5246
5286
|
body: { query },
|
|
5247
5287
|
});
|
|
5248
5288
|
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
5249
|
-
const itemsPage = (
|
|
5289
|
+
const itemsPage = (_21 = (_20 = (_19 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _19 === void 0 ? void 0 : _19.boards) === null || _20 === void 0 ? void 0 : _20[0]) === null || _21 === void 0 ? void 0 : _21.items_page;
|
|
5250
5290
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5251
5291
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
5252
5292
|
allItems = allItems.concat(items);
|
|
@@ -5325,7 +5365,7 @@ class Worktables {
|
|
|
5325
5365
|
const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
|
|
5326
5366
|
const logicalOperator = this.getNodeParameter('logicalOperator', 0);
|
|
5327
5367
|
let rulesArray = [];
|
|
5328
|
-
if (((
|
|
5368
|
+
if (((_22 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _22 === void 0 ? void 0 : _22.length) > 0) {
|
|
5329
5369
|
rulesArray = filterRules.rule.map((rule) => {
|
|
5330
5370
|
let formattedValue;
|
|
5331
5371
|
if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
|
|
@@ -5369,7 +5409,7 @@ class Worktables {
|
|
|
5369
5409
|
});
|
|
5370
5410
|
}
|
|
5371
5411
|
const orderByArray = [];
|
|
5372
|
-
if (((
|
|
5412
|
+
if (((_23 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _23 === void 0 ? void 0 : _23.length) > 0) {
|
|
5373
5413
|
sortOptions.sortBy.forEach((sort) => {
|
|
5374
5414
|
orderByArray.push(`{
|
|
5375
5415
|
column_id: "${sort.columnId}",
|
|
@@ -5425,7 +5465,7 @@ class Worktables {
|
|
|
5425
5465
|
body: { query },
|
|
5426
5466
|
});
|
|
5427
5467
|
const parsed = JSON.parse(rawResponse);
|
|
5428
|
-
const items = ((
|
|
5468
|
+
const items = ((_27 = (_26 = (_25 = (_24 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _24 === void 0 ? void 0 : _24.boards) === null || _25 === void 0 ? void 0 : _25[0]) === null || _26 === void 0 ? void 0 : _26.items_page) === null || _27 === void 0 ? void 0 : _27.items) || [];
|
|
5429
5469
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
5430
5470
|
const formatted = {
|
|
5431
5471
|
id: item.id,
|
|
@@ -5459,7 +5499,7 @@ class Worktables {
|
|
|
5459
5499
|
const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
|
|
5460
5500
|
const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
|
|
5461
5501
|
let rulesArray = [];
|
|
5462
|
-
if (((
|
|
5502
|
+
if (((_28 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _28 === void 0 ? void 0 : _28.length) > 0) {
|
|
5463
5503
|
console.log('Processing filter rules:', advancedFilterRules.rule);
|
|
5464
5504
|
rulesArray = advancedFilterRules.rule.map((rule) => {
|
|
5465
5505
|
let formattedValue;
|
|
@@ -5675,7 +5715,7 @@ class Worktables {
|
|
|
5675
5715
|
});
|
|
5676
5716
|
}
|
|
5677
5717
|
const orderByArray = [];
|
|
5678
|
-
if (((
|
|
5718
|
+
if (((_29 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _29 === void 0 ? void 0 : _29.length) > 0) {
|
|
5679
5719
|
advancedSortOptions.sortBy.forEach((sort) => {
|
|
5680
5720
|
orderByArray.push(`{
|
|
5681
5721
|
column_id: "${sort.columnId}",
|
|
@@ -5757,7 +5797,7 @@ class Worktables {
|
|
|
5757
5797
|
body: { query: testQuery },
|
|
5758
5798
|
});
|
|
5759
5799
|
const testParsed = JSON.parse(testResponse);
|
|
5760
|
-
const testItems = ((
|
|
5800
|
+
const testItems = ((_33 = (_32 = (_31 = (_30 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.data) === null || _30 === void 0 ? void 0 : _30.boards) === null || _31 === void 0 ? void 0 : _31[0]) === null || _32 === void 0 ? void 0 : _32.items_page) === null || _33 === void 0 ? void 0 : _33.items) || [];
|
|
5761
5801
|
console.log('Test - Items in board (no filters):', testItems.length);
|
|
5762
5802
|
if (testItems.length > 0) {
|
|
5763
5803
|
console.log('Sample item column values:', testItems[0].column_values);
|
|
@@ -5769,7 +5809,7 @@ class Worktables {
|
|
|
5769
5809
|
body: { query },
|
|
5770
5810
|
});
|
|
5771
5811
|
const parsed = JSON.parse(rawResponse);
|
|
5772
|
-
const itemsPage = (
|
|
5812
|
+
const itemsPage = (_36 = (_35 = (_34 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _34 === void 0 ? void 0 : _34.boards) === null || _35 === void 0 ? void 0 : _35[0]) === null || _36 === void 0 ? void 0 : _36.items_page;
|
|
5773
5813
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5774
5814
|
const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
|
|
5775
5815
|
const hasMore = nextCursor ? true : false;
|
|
@@ -5951,7 +5991,7 @@ class Worktables {
|
|
|
5951
5991
|
body: { query },
|
|
5952
5992
|
});
|
|
5953
5993
|
const parsed = JSON.parse(rawResponse);
|
|
5954
|
-
const itemsPage = (
|
|
5994
|
+
const itemsPage = (_41 = (_40 = (_39 = (_38 = (_37 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _37 === void 0 ? void 0 : _37.boards) === null || _38 === void 0 ? void 0 : _38[0]) === null || _39 === void 0 ? void 0 : _39.groups) === null || _40 === void 0 ? void 0 : _40[0]) === null || _41 === void 0 ? void 0 : _41.items_page;
|
|
5955
5995
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5956
5996
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
5957
5997
|
allItems = allItems.concat(items);
|
|
@@ -6048,7 +6088,7 @@ class Worktables {
|
|
|
6048
6088
|
response = await (0, isErrorResponse_1.parseApiResponse)(response);
|
|
6049
6089
|
if (response.success) {
|
|
6050
6090
|
const parsed = JSON.parse(response.data);
|
|
6051
|
-
const updates = ((
|
|
6091
|
+
const updates = ((_44 = (_43 = (_42 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _42 === void 0 ? void 0 : _42.items) === null || _43 === void 0 ? void 0 : _43[0]) === null || _44 === void 0 ? void 0 : _44.updates) || [];
|
|
6052
6092
|
const formattedUpdates = updates.map((update) => {
|
|
6053
6093
|
const pinnedToTop = update.pinned_to_top || [];
|
|
6054
6094
|
const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
|
|
@@ -6113,7 +6153,7 @@ class Worktables {
|
|
|
6113
6153
|
console.log('variables:', variables);
|
|
6114
6154
|
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
6115
6155
|
console.log('Create Update Result:', JSON.stringify(response, null, 2));
|
|
6116
|
-
const updateId = (
|
|
6156
|
+
const updateId = (_46 = (_45 = JSON.parse(response).data) === null || _45 === void 0 ? void 0 : _45.create_update) === null || _46 === void 0 ? void 0 : _46.id;
|
|
6117
6157
|
if (!updateId) {
|
|
6118
6158
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6119
6159
|
message: 'Error creating update: Update not created, no ID returned',
|
|
@@ -6422,7 +6462,7 @@ class Worktables {
|
|
|
6422
6462
|
body: { query },
|
|
6423
6463
|
json: true,
|
|
6424
6464
|
});
|
|
6425
|
-
const asset = (
|
|
6465
|
+
const asset = (_48 = (_47 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _47 === void 0 ? void 0 : _47.assets) === null || _48 === void 0 ? void 0 : _48[0];
|
|
6426
6466
|
if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
|
|
6427
6467
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6428
6468
|
message: 'Public URL not found for the given file ID.',
|