@worktables/n8n-nodes-worktables 12.13.0 → 12.15.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, _47, _48;
|
|
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, _49, _50, _51, _52, _53;
|
|
3182
3182
|
const resource = this.getNodeParameter('resource', 0);
|
|
3183
3183
|
const operation = this.getNodeParameter('operation', 0);
|
|
3184
3184
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
@@ -4695,11 +4695,23 @@ class Worktables {
|
|
|
4695
4695
|
let foundItemId = null;
|
|
4696
4696
|
let foundItemBoardId = null;
|
|
4697
4697
|
if (identifierValue && identifierValue.trim() !== '' && identifierColumn && identifierColumn.trim() !== '') {
|
|
4698
|
-
console.log('
|
|
4698
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
4699
|
+
console.log('🔍 STARTING SEARCH FOR ITEM/SUBITEM');
|
|
4700
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
4701
|
+
console.log('📋 Search Parameters:');
|
|
4702
|
+
console.log(' - identifierColumn:', identifierColumn);
|
|
4703
|
+
console.log(' - identifierValue:', identifierValue);
|
|
4704
|
+
console.log(' - isSubitem:', isSubitem);
|
|
4705
|
+
console.log(' - boardId:', boardId);
|
|
4706
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
4699
4707
|
const parentId = this.getNodeParameter('parentId', 0, false);
|
|
4708
|
+
console.log(' - parentId:', parentId || '(not provided)');
|
|
4700
4709
|
const isNameColumn = identifierColumn === 'name' || identifierColumn.toLowerCase() === 'name';
|
|
4710
|
+
console.log(' - isNameColumn:', isNameColumn);
|
|
4701
4711
|
let searchBoardId = boardId;
|
|
4712
|
+
console.log(' - Initial searchBoardId:', searchBoardId);
|
|
4702
4713
|
if (isSubitem && !parentId) {
|
|
4714
|
+
console.log(' - Discovering subitem board...');
|
|
4703
4715
|
try {
|
|
4704
4716
|
const discoverQuery = `query {
|
|
4705
4717
|
boards(ids: [${boardId}]) {
|
|
@@ -4724,15 +4736,20 @@ class Worktables {
|
|
|
4724
4736
|
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
4737
|
if (items.length > 0 && items[0].subitems && items[0].subitems.length > 0) {
|
|
4726
4738
|
searchBoardId = ((_1 = items[0].subitems[0].board) === null || _1 === void 0 ? void 0 : _1.id) || boardId;
|
|
4727
|
-
console.log(`Discovered subitem board ID: ${searchBoardId}`);
|
|
4739
|
+
console.log(` ✓ Discovered subitem board ID: ${searchBoardId}`);
|
|
4740
|
+
}
|
|
4741
|
+
else {
|
|
4742
|
+
console.log(` ⚠ No subitems found to discover board, using main board: ${boardId}`);
|
|
4728
4743
|
}
|
|
4729
4744
|
}
|
|
4730
4745
|
catch (error) {
|
|
4731
|
-
console.log('Could not discover subitem board, using main board:', error);
|
|
4746
|
+
console.log(' ❌ Could not discover subitem board, using main board:', error);
|
|
4732
4747
|
}
|
|
4733
4748
|
}
|
|
4749
|
+
console.log(' - Final searchBoardId:', searchBoardId);
|
|
4734
4750
|
let columnType = null;
|
|
4735
4751
|
if (!isNameColumn) {
|
|
4752
|
+
console.log(' - Fetching column type for:', identifierColumn);
|
|
4736
4753
|
try {
|
|
4737
4754
|
const columnTypeQuery = `query {
|
|
4738
4755
|
boards(ids: [${searchBoardId}]) {
|
|
@@ -4751,17 +4768,28 @@ class Worktables {
|
|
|
4751
4768
|
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
4769
|
if (columns.length > 0) {
|
|
4753
4770
|
columnType = columns[0].type;
|
|
4754
|
-
console.log(`Column type detected: ${columnType}`);
|
|
4771
|
+
console.log(` ✓ Column type detected: ${columnType}`);
|
|
4772
|
+
}
|
|
4773
|
+
else {
|
|
4774
|
+
console.log(` ⚠ Column not found in board ${searchBoardId}`);
|
|
4755
4775
|
}
|
|
4756
4776
|
}
|
|
4757
4777
|
catch (error) {
|
|
4758
|
-
console.log('Could not fetch column type, using default operator:', error);
|
|
4778
|
+
console.log(' ❌ Could not fetch column type, using default operator:', error);
|
|
4759
4779
|
}
|
|
4760
4780
|
}
|
|
4781
|
+
else {
|
|
4782
|
+
console.log(' - Skipping column type fetch (isNameColumn=true)');
|
|
4783
|
+
}
|
|
4761
4784
|
const searchColumnId = isNameColumn ? 'name' : identifierColumn;
|
|
4762
4785
|
const operator = columnType === 'status' ? 'contains_terms' : 'contains_text';
|
|
4763
4786
|
const limit = 100;
|
|
4787
|
+
console.log(' - searchColumnId:', searchColumnId);
|
|
4788
|
+
console.log(' - operator:', operator);
|
|
4789
|
+
console.log(' - limit:', limit);
|
|
4790
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
4764
4791
|
if (isSubitem && parentId) {
|
|
4792
|
+
console.log('🔍 Searching subitems with parentId:', parentId);
|
|
4765
4793
|
const parentQuery = `query {
|
|
4766
4794
|
items(ids: [${parentId}]) {
|
|
4767
4795
|
id
|
|
@@ -4786,6 +4814,10 @@ class Worktables {
|
|
|
4786
4814
|
... on MirrorValue {
|
|
4787
4815
|
display_value
|
|
4788
4816
|
}
|
|
4817
|
+
... on StatusValue {
|
|
4818
|
+
text
|
|
4819
|
+
index
|
|
4820
|
+
}
|
|
4789
4821
|
}
|
|
4790
4822
|
}
|
|
4791
4823
|
}
|
|
@@ -4798,118 +4830,248 @@ class Worktables {
|
|
|
4798
4830
|
});
|
|
4799
4831
|
const searchData = JSON.parse(searchResponse);
|
|
4800
4832
|
const items = ((_5 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _5 === void 0 ? void 0 : _5.items) || [];
|
|
4833
|
+
console.log(` - Parent query response: ${items.length} parent item(s) found`);
|
|
4801
4834
|
if (items.length > 0 && items[0].subitems) {
|
|
4802
4835
|
const subitems = items[0].subitems;
|
|
4803
|
-
console.log(
|
|
4804
|
-
for (
|
|
4836
|
+
console.log(` - Found ${subitems.length} subitem(s) to check`);
|
|
4837
|
+
for (let i = 0; i < subitems.length; i++) {
|
|
4838
|
+
const subitem = subitems[i];
|
|
4839
|
+
console.log(` - Checking subitem ${i + 1}/${subitems.length}: ID=${subitem.id}, name="${subitem.name}"`);
|
|
4805
4840
|
let matches = false;
|
|
4806
4841
|
if (isNameColumn) {
|
|
4807
4842
|
const searchValue = identifierValue.trim().toLowerCase();
|
|
4808
4843
|
const subitemName = (subitem.name || '').trim().toLowerCase();
|
|
4809
4844
|
matches = subitemName === searchValue;
|
|
4845
|
+
console.log(` - Name comparison: "${subitemName}" === "${searchValue}" = ${matches}`);
|
|
4810
4846
|
}
|
|
4811
4847
|
else {
|
|
4812
4848
|
const colValue = (_6 = subitem.column_values) === null || _6 === void 0 ? void 0 : _6.find((cv) => cv.id === identifierColumn);
|
|
4813
4849
|
if (colValue) {
|
|
4814
4850
|
const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
|
|
4851
|
+
const isStatusColumn = colValue.type === 'status';
|
|
4815
4852
|
const compareValue = isBoardRelation
|
|
4816
4853
|
? (colValue.display_value || '').trim()
|
|
4817
4854
|
: (colValue.text || '').trim();
|
|
4818
4855
|
const searchValue = identifierValue.trim().toLowerCase();
|
|
4856
|
+
console.log(` - Column type: ${colValue.type}`);
|
|
4857
|
+
console.log(` - Column value found: "${compareValue}"`);
|
|
4858
|
+
console.log(` - Search value: "${identifierValue}"`);
|
|
4819
4859
|
matches = compareValue.toLowerCase() === searchValue;
|
|
4860
|
+
console.log(` - Initial match: ${matches}`);
|
|
4861
|
+
if (isStatusColumn && !matches) {
|
|
4862
|
+
const normalizedCompare = compareValue.toLowerCase().replace(/\s+/g, ' ').trim();
|
|
4863
|
+
const normalizedSearch = searchValue.replace(/\s+/g, ' ').trim();
|
|
4864
|
+
matches = normalizedCompare === normalizedSearch;
|
|
4865
|
+
console.log(` - Normalized compare: "${normalizedCompare}" === "${normalizedSearch}" = ${matches}`);
|
|
4866
|
+
if (!matches) {
|
|
4867
|
+
console.log(` ❌ Status column comparison failed for subitem ${subitem.id}`);
|
|
4868
|
+
}
|
|
4869
|
+
}
|
|
4870
|
+
if (!matches) {
|
|
4871
|
+
console.log(` ❌ No match for subitem ${subitem.id}, column type: ${colValue.type}`);
|
|
4872
|
+
}
|
|
4873
|
+
}
|
|
4874
|
+
else {
|
|
4875
|
+
console.log(` ⚠ Column value not found for subitem ${subitem.id}, identifierColumn: ${identifierColumn}`);
|
|
4876
|
+
console.log(` - Available column_values:`, ((_7 = subitem.column_values) === null || _7 === void 0 ? void 0 : _7.map((cv) => cv.id).join(', ')) || 'none');
|
|
4820
4877
|
}
|
|
4821
4878
|
}
|
|
4822
4879
|
if (matches) {
|
|
4823
4880
|
foundItemId = subitem.id;
|
|
4824
|
-
foundItemBoardId = ((
|
|
4825
|
-
console.log(
|
|
4881
|
+
foundItemBoardId = ((_8 = subitem.board) === null || _8 === void 0 ? void 0 : _8.id) || null;
|
|
4882
|
+
console.log(` ✓✓✓ MATCH FOUND! Subitem ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
|
|
4826
4883
|
break;
|
|
4827
4884
|
}
|
|
4885
|
+
else {
|
|
4886
|
+
console.log(` ✗ No match for subitem ${subitem.id}`);
|
|
4887
|
+
}
|
|
4828
4888
|
}
|
|
4829
4889
|
}
|
|
4830
4890
|
}
|
|
4831
4891
|
else {
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4892
|
+
let useExactSearch = (columnType === 'text' || isNameColumn) && columnType !== 'status';
|
|
4893
|
+
console.log('🔍 Searching items (not subitems)');
|
|
4894
|
+
console.log(' - useExactSearch:', useExactSearch);
|
|
4895
|
+
console.log(' - columnType:', columnType);
|
|
4896
|
+
console.log(' - isNameColumn:', isNameColumn);
|
|
4897
|
+
let items = [];
|
|
4898
|
+
if (useExactSearch) {
|
|
4899
|
+
console.log(' - Attempting exact search with is_equal operator...');
|
|
4900
|
+
const query = `{
|
|
4901
|
+
boards(ids: [${searchBoardId}]) {
|
|
4902
|
+
items_page (
|
|
4903
|
+
limit: ${limit},
|
|
4904
|
+
query_params: {
|
|
4905
|
+
rules: [{
|
|
4906
|
+
column_id: "${searchColumnId}",
|
|
4907
|
+
compare_value: "${identifierValue}",
|
|
4908
|
+
operator: is_equal
|
|
4909
|
+
}]
|
|
4910
|
+
}
|
|
4911
|
+
) {
|
|
4912
|
+
items {
|
|
4913
|
+
name
|
|
4849
4914
|
id
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
column {
|
|
4915
|
+
url
|
|
4916
|
+
column_values(ids: "${identifierColumn}") {
|
|
4853
4917
|
id
|
|
4918
|
+
text
|
|
4919
|
+
type
|
|
4920
|
+
column {
|
|
4921
|
+
id
|
|
4922
|
+
}
|
|
4923
|
+
... on BoardRelationValue {
|
|
4924
|
+
display_value
|
|
4925
|
+
}
|
|
4926
|
+
... on MirrorValue {
|
|
4927
|
+
display_value
|
|
4928
|
+
}
|
|
4929
|
+
... on StatusValue {
|
|
4930
|
+
text
|
|
4931
|
+
index
|
|
4932
|
+
}
|
|
4854
4933
|
}
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4937
|
+
}`;
|
|
4938
|
+
try {
|
|
4939
|
+
const searchResponse = await this.helpers.request({
|
|
4940
|
+
method: 'POST',
|
|
4941
|
+
url: 'https://api.monday.com/v2',
|
|
4942
|
+
headers,
|
|
4943
|
+
body: { query },
|
|
4944
|
+
});
|
|
4945
|
+
const searchData = JSON.parse(searchResponse);
|
|
4946
|
+
const itemsPage = (_11 = (_10 = (_9 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _9 === void 0 ? void 0 : _9.boards) === null || _10 === void 0 ? void 0 : _10[0]) === null || _11 === void 0 ? void 0 : _11.items_page;
|
|
4947
|
+
items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
4948
|
+
console.log(` ✓ Exact search (is_equal) found ${items.length} item(s)`);
|
|
4949
|
+
}
|
|
4950
|
+
catch (error) {
|
|
4951
|
+
console.log(' ❌ Exact search failed, falling back to fetch all:', error);
|
|
4952
|
+
useExactSearch = false;
|
|
4953
|
+
}
|
|
4954
|
+
}
|
|
4955
|
+
if (!useExactSearch || items.length === 0) {
|
|
4956
|
+
console.log(' - Fetching all items from board for exact matching...');
|
|
4957
|
+
const query = `{
|
|
4958
|
+
boards(ids: [${searchBoardId}]) {
|
|
4959
|
+
items_page(limit: ${limit}) {
|
|
4960
|
+
items {
|
|
4961
|
+
name
|
|
4962
|
+
id
|
|
4963
|
+
url
|
|
4964
|
+
column_values(ids: "${identifierColumn}") {
|
|
4965
|
+
id
|
|
4966
|
+
text
|
|
4967
|
+
type
|
|
4968
|
+
column {
|
|
4969
|
+
id
|
|
4970
|
+
}
|
|
4971
|
+
... on BoardRelationValue {
|
|
4972
|
+
display_value
|
|
4973
|
+
}
|
|
4974
|
+
... on MirrorValue {
|
|
4975
|
+
display_value
|
|
4976
|
+
}
|
|
4977
|
+
... on StatusValue {
|
|
4978
|
+
text
|
|
4979
|
+
index
|
|
4980
|
+
}
|
|
4860
4981
|
}
|
|
4861
4982
|
}
|
|
4862
4983
|
}
|
|
4863
4984
|
}
|
|
4864
|
-
}
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4985
|
+
}`;
|
|
4986
|
+
const searchResponse = await this.helpers.request({
|
|
4987
|
+
method: 'POST',
|
|
4988
|
+
url: 'https://api.monday.com/v2',
|
|
4989
|
+
headers,
|
|
4990
|
+
body: { query },
|
|
4991
|
+
});
|
|
4992
|
+
const searchData = JSON.parse(searchResponse);
|
|
4993
|
+
const itemsPage = (_14 = (_13 = (_12 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _12 === void 0 ? void 0 : _12.boards) === null || _13 === void 0 ? void 0 : _13[0]) === null || _14 === void 0 ? void 0 : _14.items_page;
|
|
4994
|
+
items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
4995
|
+
console.log(` ✓ Fetched ${items.length} item(s) from board for exact matching`);
|
|
4996
|
+
}
|
|
4997
|
+
console.log(` - Starting exact comparison on ${items.length} item(s)...`);
|
|
4998
|
+
for (let i = 0; i < items.length; i++) {
|
|
4999
|
+
const item = items[i];
|
|
5000
|
+
console.log(` - Checking item ${i + 1}/${items.length}: ID=${item.id}, name="${item.name}"`);
|
|
4877
5001
|
let matches = false;
|
|
4878
5002
|
if (isNameColumn) {
|
|
4879
5003
|
const searchValue = identifierValue.trim().toLowerCase();
|
|
4880
5004
|
const itemName = (item.name || '').trim().toLowerCase();
|
|
4881
5005
|
matches = itemName === searchValue;
|
|
5006
|
+
console.log(` - Name comparison: "${itemName}" === "${searchValue}" = ${matches}`);
|
|
4882
5007
|
}
|
|
4883
5008
|
else {
|
|
4884
|
-
const colValue = (
|
|
5009
|
+
const colValue = (_15 = item.column_values) === null || _15 === void 0 ? void 0 : _15.find((cv) => cv.id === identifierColumn);
|
|
4885
5010
|
if (colValue) {
|
|
4886
5011
|
const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
|
|
5012
|
+
const isStatusColumn = colValue.type === 'status';
|
|
4887
5013
|
const compareValue = isBoardRelation
|
|
4888
5014
|
? (colValue.display_value || '').trim()
|
|
4889
5015
|
: (colValue.text || '').trim();
|
|
4890
5016
|
const searchValue = identifierValue.trim().toLowerCase();
|
|
5017
|
+
console.log(` - Column type: ${colValue.type}`);
|
|
5018
|
+
console.log(` - Column value found: "${compareValue}"`);
|
|
5019
|
+
console.log(` - Search value: "${identifierValue}"`);
|
|
4891
5020
|
matches = compareValue.toLowerCase() === searchValue;
|
|
5021
|
+
console.log(` - Initial match: ${matches}`);
|
|
5022
|
+
if (!matches && isStatusColumn) {
|
|
5023
|
+
const normalizedCompare = compareValue.toLowerCase().replace(/\s+/g, ' ').trim();
|
|
5024
|
+
const normalizedSearch = searchValue.replace(/\s+/g, ' ').trim();
|
|
5025
|
+
matches = normalizedCompare === normalizedSearch;
|
|
5026
|
+
console.log(` - Normalized compare: "${normalizedCompare}" === "${normalizedSearch}" = ${matches}`);
|
|
5027
|
+
}
|
|
5028
|
+
if (matches) {
|
|
5029
|
+
console.log(` ✓✓✓ MATCH FOUND! Item ${item.id}, column type: ${colValue.type}, value: "${compareValue}"`);
|
|
5030
|
+
}
|
|
5031
|
+
else {
|
|
5032
|
+
console.log(` ❌ No match: item ${item.id}, column type: ${colValue.type}, compareValue: "${compareValue}", searchValue: "${identifierValue}"`);
|
|
5033
|
+
}
|
|
5034
|
+
}
|
|
5035
|
+
else {
|
|
5036
|
+
console.log(` ⚠ Column value not found for item ${item.id}, identifierColumn: ${identifierColumn}`);
|
|
5037
|
+
console.log(` - Available column_values:`, ((_16 = item.column_values) === null || _16 === void 0 ? void 0 : _16.map((cv) => cv.id).join(', ')) || 'none');
|
|
4892
5038
|
}
|
|
4893
5039
|
}
|
|
4894
5040
|
if (matches) {
|
|
4895
5041
|
foundItemId = item.id;
|
|
4896
5042
|
if (isSubitem) {
|
|
4897
5043
|
foundItemBoardId = searchBoardId;
|
|
4898
|
-
console.log(
|
|
5044
|
+
console.log(` ✓✓✓ Found matching ${isSubitem ? 'subitem' : 'item'} with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
|
|
4899
5045
|
}
|
|
4900
5046
|
else {
|
|
4901
|
-
console.log(
|
|
5047
|
+
console.log(` ✓✓✓ Found matching item with ID: ${foundItemId}`);
|
|
4902
5048
|
}
|
|
4903
5049
|
break;
|
|
4904
5050
|
}
|
|
5051
|
+
else {
|
|
5052
|
+
console.log(` ✗ No match for item ${item.id}`);
|
|
5053
|
+
}
|
|
5054
|
+
}
|
|
5055
|
+
if (!foundItemId) {
|
|
5056
|
+
console.log(` ❌❌❌ No exact match found for identifier column "${identifierColumn}" with value "${identifierValue}"`);
|
|
4905
5057
|
}
|
|
4906
5058
|
}
|
|
5059
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
5060
|
+
console.log('📊 SEARCH RESULT:');
|
|
5061
|
+
console.log(' - foundItemId:', foundItemId || 'null (not found)');
|
|
5062
|
+
console.log(' - foundItemBoardId:', foundItemBoardId || 'null');
|
|
5063
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
4907
5064
|
if (foundItemId) {
|
|
4908
|
-
console.log(
|
|
5065
|
+
console.log(`🔄 Found existing ${isSubitem ? 'subitem' : 'item'}, updating:`, foundItemId);
|
|
4909
5066
|
const escapedColumnValues = (0, worktablesHelpers_1.escapeGraphQLJSONString)(column_values_object);
|
|
4910
5067
|
const updateBoardId = (isSubitem && foundItemBoardId) ? foundItemBoardId : boardId;
|
|
5068
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
5069
|
+
console.log('🔄 UPDATE OPERATION:');
|
|
5070
|
+
console.log(' - updateBoardId:', updateBoardId);
|
|
5071
|
+
console.log(' - foundItemId:', foundItemId);
|
|
5072
|
+
console.log(' - column_values_object:', JSON.stringify(column_values_object, null, 2));
|
|
4911
5073
|
if (isSubitem && !foundItemBoardId) {
|
|
4912
|
-
console.log(
|
|
5074
|
+
console.log(` ⚠ Warning: Subitem board_id not found, using main board_id ${boardId}. This may cause errors.`);
|
|
4913
5075
|
}
|
|
4914
5076
|
mutation = `mutation {
|
|
4915
5077
|
change_multiple_column_values(
|
|
@@ -4925,7 +5087,8 @@ class Worktables {
|
|
|
4925
5087
|
}
|
|
4926
5088
|
}
|
|
4927
5089
|
}`;
|
|
4928
|
-
console.log('Generated Update Mutation:', mutation);
|
|
5090
|
+
console.log(' - Generated Update Mutation:', mutation);
|
|
5091
|
+
console.log(' - Sending update request...');
|
|
4929
5092
|
response = await this.helpers.request({
|
|
4930
5093
|
method: 'POST',
|
|
4931
5094
|
url: 'https://api.monday.com/v2',
|
|
@@ -4933,6 +5096,7 @@ class Worktables {
|
|
|
4933
5096
|
body: { query: mutation },
|
|
4934
5097
|
});
|
|
4935
5098
|
const responseData = JSON.parse(response);
|
|
5099
|
+
console.log(' - Update response received:', JSON.stringify(responseData, null, 2));
|
|
4936
5100
|
if (!responseData.errors && responseData.data && responseData.data.change_multiple_column_values) {
|
|
4937
5101
|
const itemData = responseData.data.change_multiple_column_values;
|
|
4938
5102
|
if (itemData && itemData.id) {
|
|
@@ -4940,23 +5104,26 @@ class Worktables {
|
|
|
4940
5104
|
id: itemData.id,
|
|
4941
5105
|
url: itemData.url || '',
|
|
4942
5106
|
operation: 'update',
|
|
4943
|
-
board_id: ((
|
|
5107
|
+
board_id: ((_17 = itemData.board) === null || _17 === void 0 ? void 0 : _17.id) || boardId,
|
|
4944
5108
|
column_values: column_values_object,
|
|
4945
5109
|
};
|
|
4946
5110
|
itemUpdated = true;
|
|
4947
|
-
console.log(`Successfully updated ${isSubitem ? 'subitem' : 'item'}:`, itemData.id);
|
|
5111
|
+
console.log(` ✓✓✓ Successfully updated ${isSubitem ? 'subitem' : 'item'}:`, itemData.id);
|
|
5112
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
4948
5113
|
}
|
|
4949
5114
|
else {
|
|
4950
|
-
console.log(`Update response missing item data, will create new ${isSubitem ? 'subitem' : 'item'} instead`);
|
|
5115
|
+
console.log(` ❌ Update response missing item data, will create new ${isSubitem ? 'subitem' : 'item'} instead`);
|
|
5116
|
+
console.log(' - itemData:', JSON.stringify(itemData, null, 2));
|
|
4951
5117
|
itemUpdated = false;
|
|
4952
5118
|
}
|
|
4953
5119
|
}
|
|
4954
5120
|
else {
|
|
4955
5121
|
if (responseData.errors) {
|
|
4956
|
-
console.log('Error updating item:', JSON.stringify(responseData.errors));
|
|
5122
|
+
console.log(' ❌ Error updating item:', JSON.stringify(responseData.errors, null, 2));
|
|
4957
5123
|
}
|
|
4958
5124
|
else {
|
|
4959
|
-
console.log('Update response missing data, will create new item instead');
|
|
5125
|
+
console.log(' ❌ Update response missing data, will create new item instead');
|
|
5126
|
+
console.log(' - responseData.data:', JSON.stringify(responseData.data, null, 2));
|
|
4960
5127
|
}
|
|
4961
5128
|
itemUpdated = false;
|
|
4962
5129
|
}
|
|
@@ -4970,11 +5137,15 @@ class Worktables {
|
|
|
4970
5137
|
}
|
|
4971
5138
|
}
|
|
4972
5139
|
else {
|
|
4973
|
-
console.log('
|
|
5140
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
5141
|
+
console.log('ℹ️ No identifier provided, will create new item');
|
|
5142
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
4974
5143
|
itemUpdated = false;
|
|
4975
5144
|
}
|
|
4976
5145
|
if (!itemUpdated) {
|
|
4977
|
-
console.log(
|
|
5146
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
5147
|
+
console.log(`➕ CREATING NEW ${isSubitem ? 'SUBITEM' : 'ITEM'}:`, itemName);
|
|
5148
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
4978
5149
|
const parentId = this.getNodeParameter('parentId', 0, false);
|
|
4979
5150
|
if (isSubitem && !parentId) {
|
|
4980
5151
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
@@ -5018,6 +5189,8 @@ class Worktables {
|
|
|
5018
5189
|
}
|
|
5019
5190
|
}`;
|
|
5020
5191
|
}
|
|
5192
|
+
console.log(' - Generated Create Mutation:', mutation);
|
|
5193
|
+
console.log(' - Sending create request...');
|
|
5021
5194
|
response = await this.helpers.request({
|
|
5022
5195
|
method: 'POST',
|
|
5023
5196
|
url: 'https://api.monday.com/v2',
|
|
@@ -5025,25 +5198,30 @@ class Worktables {
|
|
|
5025
5198
|
body: { query: mutation },
|
|
5026
5199
|
});
|
|
5027
5200
|
const responseData = JSON.parse(response);
|
|
5201
|
+
console.log(' - Create response received:', JSON.stringify(responseData, null, 2));
|
|
5028
5202
|
if (responseData.errors) {
|
|
5203
|
+
console.log(' ❌ Error creating item:', JSON.stringify(responseData.errors, null, 2));
|
|
5029
5204
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5030
5205
|
message: `Error creating ${isSubitem ? 'subitem' : 'item'}: ${JSON.stringify(responseData.errors)}`,
|
|
5031
5206
|
});
|
|
5032
5207
|
}
|
|
5033
5208
|
const itemData = isSubitem && parentId
|
|
5034
|
-
? (
|
|
5035
|
-
: (
|
|
5209
|
+
? (_18 = responseData.data) === null || _18 === void 0 ? void 0 : _18.create_subitem
|
|
5210
|
+
: (_19 = responseData.data) === null || _19 === void 0 ? void 0 : _19.create_item;
|
|
5036
5211
|
if (!itemData || !itemData.id) {
|
|
5212
|
+
console.log(' ❌ No item data returned in response');
|
|
5037
5213
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5038
5214
|
message: `Error creating ${isSubitem ? 'subitem' : 'item'}: No item data returned`,
|
|
5039
5215
|
});
|
|
5040
5216
|
}
|
|
5217
|
+
console.log(` ✓✓✓ Successfully created ${isSubitem ? 'subitem' : 'item'}:`, itemData.id);
|
|
5218
|
+
console.log('═══════════════════════════════════════════════════════════');
|
|
5041
5219
|
formatted = {
|
|
5042
5220
|
id: itemData.id,
|
|
5043
5221
|
name: itemData.name || itemName,
|
|
5044
5222
|
url: itemData.url || '',
|
|
5045
5223
|
operation: 'create',
|
|
5046
|
-
board_id: ((
|
|
5224
|
+
board_id: ((_20 = itemData.board) === null || _20 === void 0 ? void 0 : _20.id) || boardId,
|
|
5047
5225
|
column_values: column_values_object,
|
|
5048
5226
|
};
|
|
5049
5227
|
if (isSubitem && parentId) {
|
|
@@ -5084,12 +5262,12 @@ class Worktables {
|
|
|
5084
5262
|
if (itemParsed.errors) {
|
|
5085
5263
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(itemParsed.errors) });
|
|
5086
5264
|
}
|
|
5087
|
-
const items = ((
|
|
5265
|
+
const items = ((_21 = itemParsed === null || itemParsed === void 0 ? void 0 : itemParsed.data) === null || _21 === void 0 ? void 0 : _21.items) || [];
|
|
5088
5266
|
if (items.length === 0) {
|
|
5089
5267
|
return [[{ json: { item_id: itemId, activity_logs: [] } }]];
|
|
5090
5268
|
}
|
|
5091
5269
|
const item = items[0];
|
|
5092
|
-
const boardId = (
|
|
5270
|
+
const boardId = (_22 = item.board) === null || _22 === void 0 ? void 0 : _22.id;
|
|
5093
5271
|
if (!boardId) {
|
|
5094
5272
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Could not retrieve board ID for the item.' });
|
|
5095
5273
|
}
|
|
@@ -5127,7 +5305,7 @@ class Worktables {
|
|
|
5127
5305
|
if (parsed.errors) {
|
|
5128
5306
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(parsed.errors) });
|
|
5129
5307
|
}
|
|
5130
|
-
const boards = ((
|
|
5308
|
+
const boards = ((_23 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _23 === void 0 ? void 0 : _23.boards) || [];
|
|
5131
5309
|
const activityLogs = boards.length > 0 ? (boards[0].activity_logs || []) : [];
|
|
5132
5310
|
const formatted = {
|
|
5133
5311
|
item_id: item.id,
|
|
@@ -5286,7 +5464,7 @@ class Worktables {
|
|
|
5286
5464
|
body: { query },
|
|
5287
5465
|
});
|
|
5288
5466
|
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
5289
|
-
const itemsPage = (
|
|
5467
|
+
const itemsPage = (_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;
|
|
5290
5468
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5291
5469
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
5292
5470
|
allItems = allItems.concat(items);
|
|
@@ -5365,7 +5543,7 @@ class Worktables {
|
|
|
5365
5543
|
const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
|
|
5366
5544
|
const logicalOperator = this.getNodeParameter('logicalOperator', 0);
|
|
5367
5545
|
let rulesArray = [];
|
|
5368
|
-
if (((
|
|
5546
|
+
if (((_27 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _27 === void 0 ? void 0 : _27.length) > 0) {
|
|
5369
5547
|
rulesArray = filterRules.rule.map((rule) => {
|
|
5370
5548
|
let formattedValue;
|
|
5371
5549
|
if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
|
|
@@ -5409,7 +5587,7 @@ class Worktables {
|
|
|
5409
5587
|
});
|
|
5410
5588
|
}
|
|
5411
5589
|
const orderByArray = [];
|
|
5412
|
-
if (((
|
|
5590
|
+
if (((_28 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _28 === void 0 ? void 0 : _28.length) > 0) {
|
|
5413
5591
|
sortOptions.sortBy.forEach((sort) => {
|
|
5414
5592
|
orderByArray.push(`{
|
|
5415
5593
|
column_id: "${sort.columnId}",
|
|
@@ -5465,7 +5643,7 @@ class Worktables {
|
|
|
5465
5643
|
body: { query },
|
|
5466
5644
|
});
|
|
5467
5645
|
const parsed = JSON.parse(rawResponse);
|
|
5468
|
-
const items = ((
|
|
5646
|
+
const items = ((_32 = (_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) === null || _32 === void 0 ? void 0 : _32.items) || [];
|
|
5469
5647
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
5470
5648
|
const formatted = {
|
|
5471
5649
|
id: item.id,
|
|
@@ -5499,7 +5677,7 @@ class Worktables {
|
|
|
5499
5677
|
const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
|
|
5500
5678
|
const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
|
|
5501
5679
|
let rulesArray = [];
|
|
5502
|
-
if (((
|
|
5680
|
+
if (((_33 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _33 === void 0 ? void 0 : _33.length) > 0) {
|
|
5503
5681
|
console.log('Processing filter rules:', advancedFilterRules.rule);
|
|
5504
5682
|
rulesArray = advancedFilterRules.rule.map((rule) => {
|
|
5505
5683
|
let formattedValue;
|
|
@@ -5715,7 +5893,7 @@ class Worktables {
|
|
|
5715
5893
|
});
|
|
5716
5894
|
}
|
|
5717
5895
|
const orderByArray = [];
|
|
5718
|
-
if (((
|
|
5896
|
+
if (((_34 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _34 === void 0 ? void 0 : _34.length) > 0) {
|
|
5719
5897
|
advancedSortOptions.sortBy.forEach((sort) => {
|
|
5720
5898
|
orderByArray.push(`{
|
|
5721
5899
|
column_id: "${sort.columnId}",
|
|
@@ -5797,7 +5975,7 @@ class Worktables {
|
|
|
5797
5975
|
body: { query: testQuery },
|
|
5798
5976
|
});
|
|
5799
5977
|
const testParsed = JSON.parse(testResponse);
|
|
5800
|
-
const testItems = ((
|
|
5978
|
+
const testItems = ((_38 = (_37 = (_36 = (_35 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.data) === null || _35 === void 0 ? void 0 : _35.boards) === null || _36 === void 0 ? void 0 : _36[0]) === null || _37 === void 0 ? void 0 : _37.items_page) === null || _38 === void 0 ? void 0 : _38.items) || [];
|
|
5801
5979
|
console.log('Test - Items in board (no filters):', testItems.length);
|
|
5802
5980
|
if (testItems.length > 0) {
|
|
5803
5981
|
console.log('Sample item column values:', testItems[0].column_values);
|
|
@@ -5809,7 +5987,7 @@ class Worktables {
|
|
|
5809
5987
|
body: { query },
|
|
5810
5988
|
});
|
|
5811
5989
|
const parsed = JSON.parse(rawResponse);
|
|
5812
|
-
const itemsPage = (
|
|
5990
|
+
const itemsPage = (_41 = (_40 = (_39 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _39 === void 0 ? void 0 : _39.boards) === null || _40 === void 0 ? void 0 : _40[0]) === null || _41 === void 0 ? void 0 : _41.items_page;
|
|
5813
5991
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5814
5992
|
const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
|
|
5815
5993
|
const hasMore = nextCursor ? true : false;
|
|
@@ -5991,7 +6169,7 @@ class Worktables {
|
|
|
5991
6169
|
body: { query },
|
|
5992
6170
|
});
|
|
5993
6171
|
const parsed = JSON.parse(rawResponse);
|
|
5994
|
-
const itemsPage = (
|
|
6172
|
+
const itemsPage = (_46 = (_45 = (_44 = (_43 = (_42 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _42 === void 0 ? void 0 : _42.boards) === null || _43 === void 0 ? void 0 : _43[0]) === null || _44 === void 0 ? void 0 : _44.groups) === null || _45 === void 0 ? void 0 : _45[0]) === null || _46 === void 0 ? void 0 : _46.items_page;
|
|
5995
6173
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5996
6174
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
5997
6175
|
allItems = allItems.concat(items);
|
|
@@ -6088,7 +6266,7 @@ class Worktables {
|
|
|
6088
6266
|
response = await (0, isErrorResponse_1.parseApiResponse)(response);
|
|
6089
6267
|
if (response.success) {
|
|
6090
6268
|
const parsed = JSON.parse(response.data);
|
|
6091
|
-
const updates = ((
|
|
6269
|
+
const updates = ((_49 = (_48 = (_47 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _47 === void 0 ? void 0 : _47.items) === null || _48 === void 0 ? void 0 : _48[0]) === null || _49 === void 0 ? void 0 : _49.updates) || [];
|
|
6092
6270
|
const formattedUpdates = updates.map((update) => {
|
|
6093
6271
|
const pinnedToTop = update.pinned_to_top || [];
|
|
6094
6272
|
const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
|
|
@@ -6153,7 +6331,7 @@ class Worktables {
|
|
|
6153
6331
|
console.log('variables:', variables);
|
|
6154
6332
|
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
6155
6333
|
console.log('Create Update Result:', JSON.stringify(response, null, 2));
|
|
6156
|
-
const updateId = (
|
|
6334
|
+
const updateId = (_51 = (_50 = JSON.parse(response).data) === null || _50 === void 0 ? void 0 : _50.create_update) === null || _51 === void 0 ? void 0 : _51.id;
|
|
6157
6335
|
if (!updateId) {
|
|
6158
6336
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6159
6337
|
message: 'Error creating update: Update not created, no ID returned',
|
|
@@ -6462,7 +6640,7 @@ class Worktables {
|
|
|
6462
6640
|
body: { query },
|
|
6463
6641
|
json: true,
|
|
6464
6642
|
});
|
|
6465
|
-
const asset = (
|
|
6643
|
+
const asset = (_53 = (_52 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _52 === void 0 ? void 0 : _52.assets) === null || _53 === void 0 ? void 0 : _53[0];
|
|
6466
6644
|
if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
|
|
6467
6645
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6468
6646
|
message: 'Public URL not found for the given file ID.',
|