@worktables/n8n-nodes-worktables 12.5.0 → 12.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nodes/Worktables/MondayWebhook.node.js +20 -1
- package/dist/nodes/Worktables/MondayWebhook.node.js.map +1 -1
- package/dist/nodes/Worktables/Worktables.node.js +259 -177
- package/dist/nodes/Worktables/Worktables.node.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -252,6 +252,12 @@ class Worktables {
|
|
|
252
252
|
description: 'List all subscribers of an item',
|
|
253
253
|
action: 'List item subscribers',
|
|
254
254
|
},
|
|
255
|
+
{
|
|
256
|
+
name: 'Get Item Activity Logs',
|
|
257
|
+
value: 'getItemActivityLogs',
|
|
258
|
+
description: 'Retrieve activity logs of a specific item',
|
|
259
|
+
action: 'Get item activity logs',
|
|
260
|
+
},
|
|
255
261
|
{
|
|
256
262
|
name: 'Upload files to column',
|
|
257
263
|
value: 'uploadItemFile',
|
|
@@ -915,7 +921,7 @@ class Worktables {
|
|
|
915
921
|
default: '',
|
|
916
922
|
description: 'Enter the date from which to retrieve activity logs',
|
|
917
923
|
displayOptions: {
|
|
918
|
-
show: { operation: ['listBoardActivityLogs'] },
|
|
924
|
+
show: { operation: ['listBoardActivityLogs', 'getItemActivityLogs'] },
|
|
919
925
|
},
|
|
920
926
|
},
|
|
921
927
|
{
|
|
@@ -925,7 +931,7 @@ class Worktables {
|
|
|
925
931
|
default: '',
|
|
926
932
|
description: 'Enter the date to which to retrieve activity logs',
|
|
927
933
|
displayOptions: {
|
|
928
|
-
show: { operation: ['listBoardActivityLogs'] },
|
|
934
|
+
show: { operation: ['listBoardActivityLogs', 'getItemActivityLogs'] },
|
|
929
935
|
},
|
|
930
936
|
},
|
|
931
937
|
{
|
|
@@ -1122,7 +1128,7 @@ class Worktables {
|
|
|
1122
1128
|
description: 'Specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
|
1123
1129
|
displayOptions: {
|
|
1124
1130
|
show: {
|
|
1125
|
-
operation: ['getItem', 'deleteItem'],
|
|
1131
|
+
operation: ['getItem', 'deleteItem', 'getItemActivityLogs'],
|
|
1126
1132
|
},
|
|
1127
1133
|
},
|
|
1128
1134
|
},
|
|
@@ -3172,7 +3178,7 @@ class Worktables {
|
|
|
3172
3178
|
};
|
|
3173
3179
|
}
|
|
3174
3180
|
async execute() {
|
|
3175
|
-
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;
|
|
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;
|
|
3176
3182
|
const resource = this.getNodeParameter('resource', 0);
|
|
3177
3183
|
const operation = this.getNodeParameter('operation', 0);
|
|
3178
3184
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
@@ -4691,200 +4697,212 @@ class Worktables {
|
|
|
4691
4697
|
if (identifierValue && identifierValue.trim() !== '' && identifierColumn && identifierColumn.trim() !== '') {
|
|
4692
4698
|
console.log('Searching for item/subitem with identifier column:', identifierColumn, 'value:', identifierValue, 'isSubitem:', isSubitem);
|
|
4693
4699
|
const parentId = this.getNodeParameter('parentId', 0, false);
|
|
4694
|
-
|
|
4695
|
-
let
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
? `query {
|
|
4700
|
-
items(ids: [${parentId}]) {
|
|
4701
|
-
id
|
|
4702
|
-
name
|
|
4703
|
-
subitems {
|
|
4704
|
-
id
|
|
4705
|
-
name
|
|
4706
|
-
board {
|
|
4707
|
-
id
|
|
4708
|
-
}
|
|
4709
|
-
column_values(ids: ["${identifierColumn}"]) {
|
|
4710
|
-
id
|
|
4711
|
-
text
|
|
4712
|
-
value
|
|
4713
|
-
type
|
|
4714
|
-
... on BoardRelationValue {
|
|
4715
|
-
display_value
|
|
4716
|
-
}
|
|
4717
|
-
... on MirrorValue {
|
|
4718
|
-
display_value
|
|
4719
|
-
}
|
|
4720
|
-
}
|
|
4721
|
-
}
|
|
4722
|
-
}
|
|
4723
|
-
}`
|
|
4724
|
-
: isSubitem
|
|
4725
|
-
? `query {
|
|
4700
|
+
const isNameColumn = identifierColumn === 'name' || identifierColumn.toLowerCase() === 'name';
|
|
4701
|
+
let searchBoardId = boardId;
|
|
4702
|
+
if (isSubitem && !parentId) {
|
|
4703
|
+
try {
|
|
4704
|
+
const discoverQuery = `query {
|
|
4726
4705
|
boards(ids: [${boardId}]) {
|
|
4727
|
-
items_page(limit:
|
|
4706
|
+
items_page(limit: 1) {
|
|
4728
4707
|
items {
|
|
4729
|
-
id
|
|
4730
|
-
name
|
|
4731
4708
|
subitems {
|
|
4732
|
-
id
|
|
4733
|
-
name
|
|
4734
4709
|
board {
|
|
4735
4710
|
id
|
|
4736
4711
|
}
|
|
4737
|
-
column_values(ids: ["${identifierColumn}"]) {
|
|
4738
|
-
id
|
|
4739
|
-
text
|
|
4740
|
-
value
|
|
4741
|
-
type
|
|
4742
|
-
... on BoardRelationValue {
|
|
4743
|
-
display_value
|
|
4744
|
-
}
|
|
4745
|
-
... on MirrorValue {
|
|
4746
|
-
display_value
|
|
4747
|
-
}
|
|
4748
|
-
}
|
|
4749
4712
|
}
|
|
4750
4713
|
}
|
|
4751
|
-
cursor
|
|
4752
4714
|
}
|
|
4753
4715
|
}
|
|
4754
|
-
}
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4716
|
+
}`;
|
|
4717
|
+
const discoverResponse = await this.helpers.request({
|
|
4718
|
+
method: 'POST',
|
|
4719
|
+
url: 'https://api.monday.com/v2',
|
|
4720
|
+
headers,
|
|
4721
|
+
body: { query: discoverQuery },
|
|
4722
|
+
});
|
|
4723
|
+
const discoverData = JSON.parse(discoverResponse);
|
|
4724
|
+
const items = ((_0 = (_z = (_y = (_x = discoverData === null || discoverData === void 0 ? void 0 : discoverData.data) === null || _x === void 0 ? void 0 : _x.boards) === null || _y === void 0 ? void 0 : _y[0]) === null || _z === void 0 ? void 0 : _z.items_page) === null || _0 === void 0 ? void 0 : _0.items) || [];
|
|
4725
|
+
if (items.length > 0 && items[0].subitems && items[0].subitems.length > 0) {
|
|
4726
|
+
searchBoardId = ((_1 = items[0].subitems[0].board) === null || _1 === void 0 ? void 0 : _1.id) || boardId;
|
|
4727
|
+
console.log(`Discovered subitem board ID: ${searchBoardId}`);
|
|
4728
|
+
}
|
|
4729
|
+
}
|
|
4730
|
+
catch (error) {
|
|
4731
|
+
console.log('Could not discover subitem board, using main board:', error);
|
|
4732
|
+
}
|
|
4733
|
+
}
|
|
4734
|
+
let columnType = null;
|
|
4735
|
+
if (!isNameColumn) {
|
|
4736
|
+
try {
|
|
4737
|
+
const columnTypeQuery = `query {
|
|
4738
|
+
boards(ids: [${searchBoardId}]) {
|
|
4739
|
+
columns(ids: ["${identifierColumn}"]) {
|
|
4740
|
+
type
|
|
4741
|
+
}
|
|
4742
|
+
}
|
|
4743
|
+
}`;
|
|
4744
|
+
const columnTypeResponse = await this.helpers.request({
|
|
4745
|
+
method: 'POST',
|
|
4746
|
+
url: 'https://api.monday.com/v2',
|
|
4747
|
+
headers,
|
|
4748
|
+
body: { query: columnTypeQuery },
|
|
4749
|
+
});
|
|
4750
|
+
const columnTypeData = JSON.parse(columnTypeResponse);
|
|
4751
|
+
const columns = ((_4 = (_3 = (_2 = columnTypeData === null || columnTypeData === void 0 ? void 0 : columnTypeData.data) === null || _2 === void 0 ? void 0 : _2.boards) === null || _3 === void 0 ? void 0 : _3[0]) === null || _4 === void 0 ? void 0 : _4.columns) || [];
|
|
4752
|
+
if (columns.length > 0) {
|
|
4753
|
+
columnType = columns[0].type;
|
|
4754
|
+
console.log(`Column type detected: ${columnType}`);
|
|
4755
|
+
}
|
|
4756
|
+
}
|
|
4757
|
+
catch (error) {
|
|
4758
|
+
console.log('Could not fetch column type, using default operator:', error);
|
|
4759
|
+
}
|
|
4760
|
+
}
|
|
4761
|
+
const searchColumnId = isNameColumn ? 'name' : identifierColumn;
|
|
4762
|
+
const operator = columnType === 'status' ? 'contains_terms' : 'contains_text';
|
|
4763
|
+
const limit = 100;
|
|
4764
|
+
if (isSubitem && parentId) {
|
|
4765
|
+
const parentQuery = `query {
|
|
4766
|
+
items(ids: [${parentId}]) {
|
|
4767
|
+
id
|
|
4768
|
+
name
|
|
4769
|
+
subitems {
|
|
4770
|
+
id
|
|
4771
|
+
name
|
|
4772
|
+
url
|
|
4773
|
+
board {
|
|
4774
|
+
id
|
|
4775
|
+
}
|
|
4776
|
+
column_values(ids: ["${identifierColumn}"]) {
|
|
4777
|
+
id
|
|
4778
|
+
text
|
|
4779
|
+
type
|
|
4780
|
+
column {
|
|
4759
4781
|
id
|
|
4760
|
-
name
|
|
4761
|
-
column_values(ids: ["${identifierColumn}"]) {
|
|
4762
|
-
id
|
|
4763
|
-
text
|
|
4764
|
-
value
|
|
4765
|
-
type
|
|
4766
|
-
... on BoardRelationValue {
|
|
4767
|
-
display_value
|
|
4768
|
-
}
|
|
4769
|
-
... on MirrorValue {
|
|
4770
|
-
display_value
|
|
4771
|
-
}
|
|
4772
|
-
}
|
|
4773
4782
|
}
|
|
4774
|
-
|
|
4783
|
+
... on BoardRelationValue {
|
|
4784
|
+
display_value
|
|
4785
|
+
}
|
|
4786
|
+
... on MirrorValue {
|
|
4787
|
+
display_value
|
|
4788
|
+
}
|
|
4775
4789
|
}
|
|
4776
4790
|
}
|
|
4777
|
-
}
|
|
4791
|
+
}
|
|
4792
|
+
}`;
|
|
4778
4793
|
const searchResponse = await this.helpers.request({
|
|
4779
4794
|
method: 'POST',
|
|
4780
4795
|
url: 'https://api.monday.com/v2',
|
|
4781
4796
|
headers,
|
|
4782
|
-
body: { query:
|
|
4797
|
+
body: { query: parentQuery },
|
|
4783
4798
|
});
|
|
4784
4799
|
const searchData = JSON.parse(searchResponse);
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
console.log(`🔍 Searching subitems of parent ${parentId}, found ${items.length} parent item(s)`);
|
|
4791
|
-
if (items.length > 0 && items[0].subitems) {
|
|
4792
|
-
console.log(`🔍 Parent item has ${items[0].subitems.length} subitem(s)`);
|
|
4793
|
-
}
|
|
4794
|
-
}
|
|
4795
|
-
else {
|
|
4796
|
-
const itemsPage = (_0 = (_z = (_y = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _y === void 0 ? void 0 : _y.boards) === null || _z === void 0 ? void 0 : _z[0]) === null || _0 === void 0 ? void 0 : _0.items_page;
|
|
4797
|
-
items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
4798
|
-
nextCursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
4799
|
-
hasMore = nextCursor !== null && items.length > 0 && !foundItemId;
|
|
4800
|
-
console.log(`🔍 Searching in board, found ${items.length} item(s)`);
|
|
4801
|
-
}
|
|
4802
|
-
cursor = nextCursor;
|
|
4803
|
-
const isNameColumn = identifierColumn === 'name' || identifierColumn.toLowerCase() === 'name';
|
|
4804
|
-
if (isSubitem) {
|
|
4805
|
-
for (const item of items) {
|
|
4806
|
-
if (item.subitems && Array.isArray(item.subitems)) {
|
|
4807
|
-
for (const subitem of item.subitems) {
|
|
4808
|
-
let matches = false;
|
|
4809
|
-
if (isNameColumn) {
|
|
4810
|
-
const searchValue = identifierValue.trim().toLowerCase();
|
|
4811
|
-
const subitemName = (subitem.name || '').trim().toLowerCase();
|
|
4812
|
-
matches = subitemName === searchValue;
|
|
4813
|
-
}
|
|
4814
|
-
else {
|
|
4815
|
-
const colValue = (_1 = subitem.column_values) === null || _1 === void 0 ? void 0 : _1.find((cv) => cv.id === identifierColumn);
|
|
4816
|
-
if (colValue) {
|
|
4817
|
-
const isBoardRelation = colValue.type === 'board_relation';
|
|
4818
|
-
const compareValue = isBoardRelation
|
|
4819
|
-
? (colValue.display_value || '').trim()
|
|
4820
|
-
: (colValue.text || '').trim();
|
|
4821
|
-
const searchValue = identifierValue.trim().toLowerCase();
|
|
4822
|
-
const compareValueLower = compareValue.toLowerCase();
|
|
4823
|
-
matches = compareValueLower === searchValue;
|
|
4824
|
-
if (matches) {
|
|
4825
|
-
console.log(`✓ Match found! Subitem ${subitem.id} - Column ${identifierColumn} (${colValue.type}): ${isBoardRelation ? 'display_value' : 'text'}="${compareValue}", search="${identifierValue}"`);
|
|
4826
|
-
}
|
|
4827
|
-
else if (compareValue) {
|
|
4828
|
-
console.log(`✗ No match - Subitem ${subitem.id} - Column ${identifierColumn} (${colValue.type}): ${isBoardRelation ? 'display_value' : 'text'}="${compareValue}", search="${identifierValue}"`);
|
|
4829
|
-
}
|
|
4830
|
-
}
|
|
4831
|
-
else {
|
|
4832
|
-
console.log(`⚠ Subitem ${subitem.id} - Column ${identifierColumn} not found in column_values`);
|
|
4833
|
-
}
|
|
4834
|
-
}
|
|
4835
|
-
if (matches) {
|
|
4836
|
-
foundItemId = subitem.id;
|
|
4837
|
-
foundItemBoardId = ((_2 = subitem.board) === null || _2 === void 0 ? void 0 : _2.id) || null;
|
|
4838
|
-
console.log(`Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
|
|
4839
|
-
break;
|
|
4840
|
-
}
|
|
4841
|
-
}
|
|
4842
|
-
if (foundItemId)
|
|
4843
|
-
break;
|
|
4844
|
-
}
|
|
4845
|
-
}
|
|
4846
|
-
}
|
|
4847
|
-
else {
|
|
4848
|
-
for (const item of items) {
|
|
4800
|
+
const items = ((_5 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _5 === void 0 ? void 0 : _5.items) || [];
|
|
4801
|
+
if (items.length > 0 && items[0].subitems) {
|
|
4802
|
+
const subitems = items[0].subitems;
|
|
4803
|
+
console.log(`🔍 Searching subitems of parent ${parentId}, found ${subitems.length} subitem(s)`);
|
|
4804
|
+
for (const subitem of subitems) {
|
|
4849
4805
|
let matches = false;
|
|
4850
4806
|
if (isNameColumn) {
|
|
4851
4807
|
const searchValue = identifierValue.trim().toLowerCase();
|
|
4852
|
-
const
|
|
4853
|
-
matches =
|
|
4808
|
+
const subitemName = (subitem.name || '').trim().toLowerCase();
|
|
4809
|
+
matches = subitemName === searchValue;
|
|
4854
4810
|
}
|
|
4855
4811
|
else {
|
|
4856
|
-
const colValue = (
|
|
4812
|
+
const colValue = (_6 = subitem.column_values) === null || _6 === void 0 ? void 0 : _6.find((cv) => cv.id === identifierColumn);
|
|
4857
4813
|
if (colValue) {
|
|
4858
|
-
const isBoardRelation = colValue.type === 'board_relation';
|
|
4814
|
+
const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
|
|
4859
4815
|
const compareValue = isBoardRelation
|
|
4860
4816
|
? (colValue.display_value || '').trim()
|
|
4861
4817
|
: (colValue.text || '').trim();
|
|
4862
|
-
console.log(`🔍 Item ${item.id} - Column ${identifierColumn} (${colValue.type}): raw colValue=`, JSON.stringify(colValue));
|
|
4863
4818
|
const searchValue = identifierValue.trim().toLowerCase();
|
|
4864
|
-
|
|
4865
|
-
matches = compareValueLower === searchValue;
|
|
4866
|
-
if (matches) {
|
|
4867
|
-
console.log(`✓ Match found! Item ${item.id} - Column ${identifierColumn} (${colValue.type}): ${isBoardRelation ? 'display_value' : 'text'}="${compareValue}", search="${identifierValue}"`);
|
|
4868
|
-
}
|
|
4869
|
-
else if (compareValue) {
|
|
4870
|
-
console.log(`✗ No match - Item ${item.id} - Column ${identifierColumn} (${colValue.type}): ${isBoardRelation ? 'display_value' : 'text'}="${compareValue}", search="${identifierValue}"`);
|
|
4871
|
-
}
|
|
4872
|
-
else {
|
|
4873
|
-
console.log(`⚠ Item ${item.id} - Column ${identifierColumn} (${colValue.type}): compareValue is empty, display_value="${colValue.display_value}", text="${colValue.text}"`);
|
|
4874
|
-
}
|
|
4875
|
-
}
|
|
4876
|
-
else {
|
|
4877
|
-
console.log(`⚠ Item ${item.id} - Column ${identifierColumn} not found in column_values`);
|
|
4819
|
+
matches = compareValue.toLowerCase() === searchValue;
|
|
4878
4820
|
}
|
|
4879
4821
|
}
|
|
4880
4822
|
if (matches) {
|
|
4881
|
-
foundItemId =
|
|
4882
|
-
|
|
4823
|
+
foundItemId = subitem.id;
|
|
4824
|
+
foundItemBoardId = ((_7 = subitem.board) === null || _7 === void 0 ? void 0 : _7.id) || null;
|
|
4825
|
+
console.log(`✓ Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
|
|
4883
4826
|
break;
|
|
4884
4827
|
}
|
|
4885
4828
|
}
|
|
4886
4829
|
}
|
|
4887
|
-
|
|
4830
|
+
}
|
|
4831
|
+
else {
|
|
4832
|
+
const query = `{
|
|
4833
|
+
boards(ids: [${searchBoardId}]) {
|
|
4834
|
+
items_page (
|
|
4835
|
+
limit: ${limit},
|
|
4836
|
+
query_params: {
|
|
4837
|
+
rules: [{
|
|
4838
|
+
column_id: "${searchColumnId}",
|
|
4839
|
+
compare_value: "${identifierValue}",
|
|
4840
|
+
operator: ${operator}
|
|
4841
|
+
}]
|
|
4842
|
+
}
|
|
4843
|
+
) {
|
|
4844
|
+
items {
|
|
4845
|
+
name
|
|
4846
|
+
id
|
|
4847
|
+
url
|
|
4848
|
+
column_values(ids: "${identifierColumn}") {
|
|
4849
|
+
id
|
|
4850
|
+
text
|
|
4851
|
+
type
|
|
4852
|
+
column {
|
|
4853
|
+
id
|
|
4854
|
+
}
|
|
4855
|
+
... on BoardRelationValue {
|
|
4856
|
+
display_value
|
|
4857
|
+
}
|
|
4858
|
+
... on MirrorValue {
|
|
4859
|
+
display_value
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
4862
|
+
}
|
|
4863
|
+
}
|
|
4864
|
+
}
|
|
4865
|
+
}`;
|
|
4866
|
+
const searchResponse = await this.helpers.request({
|
|
4867
|
+
method: 'POST',
|
|
4868
|
+
url: 'https://api.monday.com/v2',
|
|
4869
|
+
headers,
|
|
4870
|
+
body: { query },
|
|
4871
|
+
});
|
|
4872
|
+
const searchData = JSON.parse(searchResponse);
|
|
4873
|
+
const itemsPage = (_10 = (_9 = (_8 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _8 === void 0 ? void 0 : _8.boards) === null || _9 === void 0 ? void 0 : _9[0]) === null || _10 === void 0 ? void 0 : _10.items_page;
|
|
4874
|
+
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
4875
|
+
console.log(`🔍 Optimized search found ${items.length} item(s) matching identifier`);
|
|
4876
|
+
for (const item of items) {
|
|
4877
|
+
let matches = false;
|
|
4878
|
+
if (isNameColumn) {
|
|
4879
|
+
const searchValue = identifierValue.trim().toLowerCase();
|
|
4880
|
+
const itemName = (item.name || '').trim().toLowerCase();
|
|
4881
|
+
matches = itemName === searchValue;
|
|
4882
|
+
}
|
|
4883
|
+
else {
|
|
4884
|
+
const colValue = (_11 = item.column_values) === null || _11 === void 0 ? void 0 : _11.find((cv) => cv.id === identifierColumn);
|
|
4885
|
+
if (colValue) {
|
|
4886
|
+
const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
|
|
4887
|
+
const compareValue = isBoardRelation
|
|
4888
|
+
? (colValue.display_value || '').trim()
|
|
4889
|
+
: (colValue.text || '').trim();
|
|
4890
|
+
const searchValue = identifierValue.trim().toLowerCase();
|
|
4891
|
+
matches = compareValue.toLowerCase() === searchValue;
|
|
4892
|
+
}
|
|
4893
|
+
}
|
|
4894
|
+
if (matches) {
|
|
4895
|
+
foundItemId = item.id;
|
|
4896
|
+
if (isSubitem) {
|
|
4897
|
+
foundItemBoardId = searchBoardId;
|
|
4898
|
+
console.log(`✓ Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
|
|
4899
|
+
}
|
|
4900
|
+
else {
|
|
4901
|
+
console.log(`✓ Found item with ID: ${foundItemId}`);
|
|
4902
|
+
}
|
|
4903
|
+
break;
|
|
4904
|
+
}
|
|
4905
|
+
}
|
|
4888
4906
|
}
|
|
4889
4907
|
if (foundItemId) {
|
|
4890
4908
|
console.log(`Found existing ${isSubitem ? 'subitem' : 'item'}, updating:`, foundItemId);
|
|
@@ -4922,7 +4940,7 @@ class Worktables {
|
|
|
4922
4940
|
id: itemData.id,
|
|
4923
4941
|
url: itemData.url || '',
|
|
4924
4942
|
operation: 'update',
|
|
4925
|
-
board_id: ((
|
|
4943
|
+
board_id: ((_12 = itemData.board) === null || _12 === void 0 ? void 0 : _12.id) || boardId,
|
|
4926
4944
|
column_values: column_values_object,
|
|
4927
4945
|
};
|
|
4928
4946
|
itemUpdated = true;
|
|
@@ -5013,8 +5031,8 @@ class Worktables {
|
|
|
5013
5031
|
});
|
|
5014
5032
|
}
|
|
5015
5033
|
const itemData = isSubitem && parentId
|
|
5016
|
-
? (
|
|
5017
|
-
: (
|
|
5034
|
+
? (_13 = responseData.data) === null || _13 === void 0 ? void 0 : _13.create_subitem
|
|
5035
|
+
: (_14 = responseData.data) === null || _14 === void 0 ? void 0 : _14.create_item;
|
|
5018
5036
|
if (!itemData || !itemData.id) {
|
|
5019
5037
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5020
5038
|
message: `Error creating ${isSubitem ? 'subitem' : 'item'}: No item data returned`,
|
|
@@ -5025,7 +5043,7 @@ class Worktables {
|
|
|
5025
5043
|
name: itemData.name || itemName,
|
|
5026
5044
|
url: itemData.url || '',
|
|
5027
5045
|
operation: 'create',
|
|
5028
|
-
board_id: ((
|
|
5046
|
+
board_id: ((_15 = itemData.board) === null || _15 === void 0 ? void 0 : _15.id) || boardId,
|
|
5029
5047
|
column_values: column_values_object,
|
|
5030
5048
|
};
|
|
5031
5049
|
if (isSubitem && parentId) {
|
|
@@ -5034,6 +5052,70 @@ class Worktables {
|
|
|
5034
5052
|
}
|
|
5035
5053
|
return [[{ json: formatted }]];
|
|
5036
5054
|
}
|
|
5055
|
+
case 'getItemActivityLogs': {
|
|
5056
|
+
const itemId = this.getNodeParameter('itemId', 0);
|
|
5057
|
+
const from = this.getNodeParameter('from', 0, '');
|
|
5058
|
+
const to = this.getNodeParameter('to', 0, '');
|
|
5059
|
+
if (!itemId) {
|
|
5060
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Item ID is required.' });
|
|
5061
|
+
}
|
|
5062
|
+
console.log('Getting activity logs for item:', itemId);
|
|
5063
|
+
console.log('From: ', from);
|
|
5064
|
+
console.log('To: ', to);
|
|
5065
|
+
let activityLogsQuery = 'activity_logs';
|
|
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 = `
|
|
5073
|
+
query {
|
|
5074
|
+
items(ids: ["${itemId}"]) {
|
|
5075
|
+
id
|
|
5076
|
+
name
|
|
5077
|
+
${activityLogsQuery} {
|
|
5078
|
+
id
|
|
5079
|
+
user_id
|
|
5080
|
+
entity
|
|
5081
|
+
event
|
|
5082
|
+
data
|
|
5083
|
+
created_at
|
|
5084
|
+
}
|
|
5085
|
+
}
|
|
5086
|
+
}
|
|
5087
|
+
`;
|
|
5088
|
+
console.log('Query: ', query);
|
|
5089
|
+
response = await this.helpers.request({
|
|
5090
|
+
method: 'POST',
|
|
5091
|
+
url: 'https://api.monday.com/v2',
|
|
5092
|
+
headers,
|
|
5093
|
+
body: { query },
|
|
5094
|
+
});
|
|
5095
|
+
const parsed = typeof response === 'string' ? JSON.parse(response) : response;
|
|
5096
|
+
if (parsed.errors) {
|
|
5097
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(parsed.errors) });
|
|
5098
|
+
}
|
|
5099
|
+
const items = ((_16 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _16 === void 0 ? void 0 : _16.items) || [];
|
|
5100
|
+
if (items.length === 0) {
|
|
5101
|
+
return [[{ json: { item_id: itemId, activity_logs: [] } }]];
|
|
5102
|
+
}
|
|
5103
|
+
const item = items[0];
|
|
5104
|
+
const activityLogs = item.activity_logs || [];
|
|
5105
|
+
const formatted = {
|
|
5106
|
+
item_id: item.id,
|
|
5107
|
+
item_name: item.name,
|
|
5108
|
+
activity_logs: activityLogs.map((log) => ({
|
|
5109
|
+
id: log.id,
|
|
5110
|
+
user_id: log.user_id,
|
|
5111
|
+
entity: log.entity,
|
|
5112
|
+
event: log.event,
|
|
5113
|
+
data: log.data,
|
|
5114
|
+
created_at: log.created_at,
|
|
5115
|
+
})),
|
|
5116
|
+
};
|
|
5117
|
+
return [[{ json: formatted }]];
|
|
5118
|
+
}
|
|
5037
5119
|
case 'deleteItem': {
|
|
5038
5120
|
console.log('Delete an item');
|
|
5039
5121
|
const itemId = this.getNodeParameter('itemId', 0);
|
|
@@ -5164,7 +5246,7 @@ class Worktables {
|
|
|
5164
5246
|
body: { query },
|
|
5165
5247
|
});
|
|
5166
5248
|
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
5167
|
-
const itemsPage = (
|
|
5249
|
+
const itemsPage = (_19 = (_18 = (_17 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _17 === void 0 ? void 0 : _17.boards) === null || _18 === void 0 ? void 0 : _18[0]) === null || _19 === void 0 ? void 0 : _19.items_page;
|
|
5168
5250
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5169
5251
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
5170
5252
|
allItems = allItems.concat(items);
|
|
@@ -5243,7 +5325,7 @@ class Worktables {
|
|
|
5243
5325
|
const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
|
|
5244
5326
|
const logicalOperator = this.getNodeParameter('logicalOperator', 0);
|
|
5245
5327
|
let rulesArray = [];
|
|
5246
|
-
if (((
|
|
5328
|
+
if (((_20 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _20 === void 0 ? void 0 : _20.length) > 0) {
|
|
5247
5329
|
rulesArray = filterRules.rule.map((rule) => {
|
|
5248
5330
|
let formattedValue;
|
|
5249
5331
|
if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
|
|
@@ -5287,7 +5369,7 @@ class Worktables {
|
|
|
5287
5369
|
});
|
|
5288
5370
|
}
|
|
5289
5371
|
const orderByArray = [];
|
|
5290
|
-
if (((
|
|
5372
|
+
if (((_21 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _21 === void 0 ? void 0 : _21.length) > 0) {
|
|
5291
5373
|
sortOptions.sortBy.forEach((sort) => {
|
|
5292
5374
|
orderByArray.push(`{
|
|
5293
5375
|
column_id: "${sort.columnId}",
|
|
@@ -5343,7 +5425,7 @@ class Worktables {
|
|
|
5343
5425
|
body: { query },
|
|
5344
5426
|
});
|
|
5345
5427
|
const parsed = JSON.parse(rawResponse);
|
|
5346
|
-
const items = ((
|
|
5428
|
+
const items = ((_25 = (_24 = (_23 = (_22 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _22 === void 0 ? void 0 : _22.boards) === null || _23 === void 0 ? void 0 : _23[0]) === null || _24 === void 0 ? void 0 : _24.items_page) === null || _25 === void 0 ? void 0 : _25.items) || [];
|
|
5347
5429
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
5348
5430
|
const formatted = {
|
|
5349
5431
|
id: item.id,
|
|
@@ -5377,7 +5459,7 @@ class Worktables {
|
|
|
5377
5459
|
const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
|
|
5378
5460
|
const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
|
|
5379
5461
|
let rulesArray = [];
|
|
5380
|
-
if (((
|
|
5462
|
+
if (((_26 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _26 === void 0 ? void 0 : _26.length) > 0) {
|
|
5381
5463
|
console.log('Processing filter rules:', advancedFilterRules.rule);
|
|
5382
5464
|
rulesArray = advancedFilterRules.rule.map((rule) => {
|
|
5383
5465
|
let formattedValue;
|
|
@@ -5593,7 +5675,7 @@ class Worktables {
|
|
|
5593
5675
|
});
|
|
5594
5676
|
}
|
|
5595
5677
|
const orderByArray = [];
|
|
5596
|
-
if (((
|
|
5678
|
+
if (((_27 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _27 === void 0 ? void 0 : _27.length) > 0) {
|
|
5597
5679
|
advancedSortOptions.sortBy.forEach((sort) => {
|
|
5598
5680
|
orderByArray.push(`{
|
|
5599
5681
|
column_id: "${sort.columnId}",
|
|
@@ -5675,7 +5757,7 @@ class Worktables {
|
|
|
5675
5757
|
body: { query: testQuery },
|
|
5676
5758
|
});
|
|
5677
5759
|
const testParsed = JSON.parse(testResponse);
|
|
5678
|
-
const testItems = ((
|
|
5760
|
+
const testItems = ((_31 = (_30 = (_29 = (_28 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.data) === null || _28 === void 0 ? void 0 : _28.boards) === null || _29 === void 0 ? void 0 : _29[0]) === null || _30 === void 0 ? void 0 : _30.items_page) === null || _31 === void 0 ? void 0 : _31.items) || [];
|
|
5679
5761
|
console.log('Test - Items in board (no filters):', testItems.length);
|
|
5680
5762
|
if (testItems.length > 0) {
|
|
5681
5763
|
console.log('Sample item column values:', testItems[0].column_values);
|
|
@@ -5687,7 +5769,7 @@ class Worktables {
|
|
|
5687
5769
|
body: { query },
|
|
5688
5770
|
});
|
|
5689
5771
|
const parsed = JSON.parse(rawResponse);
|
|
5690
|
-
const itemsPage = (
|
|
5772
|
+
const itemsPage = (_34 = (_33 = (_32 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _32 === void 0 ? void 0 : _32.boards) === null || _33 === void 0 ? void 0 : _33[0]) === null || _34 === void 0 ? void 0 : _34.items_page;
|
|
5691
5773
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5692
5774
|
const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
|
|
5693
5775
|
const hasMore = nextCursor ? true : false;
|
|
@@ -5869,7 +5951,7 @@ class Worktables {
|
|
|
5869
5951
|
body: { query },
|
|
5870
5952
|
});
|
|
5871
5953
|
const parsed = JSON.parse(rawResponse);
|
|
5872
|
-
const itemsPage = (
|
|
5954
|
+
const itemsPage = (_39 = (_38 = (_37 = (_36 = (_35 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _35 === void 0 ? void 0 : _35.boards) === null || _36 === void 0 ? void 0 : _36[0]) === null || _37 === void 0 ? void 0 : _37.groups) === null || _38 === void 0 ? void 0 : _38[0]) === null || _39 === void 0 ? void 0 : _39.items_page;
|
|
5873
5955
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5874
5956
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
5875
5957
|
allItems = allItems.concat(items);
|
|
@@ -5966,7 +6048,7 @@ class Worktables {
|
|
|
5966
6048
|
response = await (0, isErrorResponse_1.parseApiResponse)(response);
|
|
5967
6049
|
if (response.success) {
|
|
5968
6050
|
const parsed = JSON.parse(response.data);
|
|
5969
|
-
const updates = ((
|
|
6051
|
+
const updates = ((_42 = (_41 = (_40 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _40 === void 0 ? void 0 : _40.items) === null || _41 === void 0 ? void 0 : _41[0]) === null || _42 === void 0 ? void 0 : _42.updates) || [];
|
|
5970
6052
|
const formattedUpdates = updates.map((update) => {
|
|
5971
6053
|
const pinnedToTop = update.pinned_to_top || [];
|
|
5972
6054
|
const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
|
|
@@ -6031,7 +6113,7 @@ class Worktables {
|
|
|
6031
6113
|
console.log('variables:', variables);
|
|
6032
6114
|
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
6033
6115
|
console.log('Create Update Result:', JSON.stringify(response, null, 2));
|
|
6034
|
-
const updateId = (
|
|
6116
|
+
const updateId = (_44 = (_43 = JSON.parse(response).data) === null || _43 === void 0 ? void 0 : _43.create_update) === null || _44 === void 0 ? void 0 : _44.id;
|
|
6035
6117
|
if (!updateId) {
|
|
6036
6118
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6037
6119
|
message: 'Error creating update: Update not created, no ID returned',
|
|
@@ -6340,7 +6422,7 @@ class Worktables {
|
|
|
6340
6422
|
body: { query },
|
|
6341
6423
|
json: true,
|
|
6342
6424
|
});
|
|
6343
|
-
const asset = (
|
|
6425
|
+
const asset = (_46 = (_45 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _45 === void 0 ? void 0 : _45.assets) === null || _46 === void 0 ? void 0 : _46[0];
|
|
6344
6426
|
if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
|
|
6345
6427
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6346
6428
|
message: 'Public URL not found for the given file ID.',
|