@worktables/n8n-nodes-worktables 12.14.0 → 12.16.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, _54;
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,25 @@ class Worktables {
4695
4695
  let foundItemId = null;
4696
4696
  let foundItemBoardId = null;
4697
4697
  if (identifierValue && identifierValue.trim() !== '' && identifierColumn && identifierColumn.trim() !== '') {
4698
- console.log('Searching for item/subitem with identifier column:', identifierColumn, 'value:', identifierValue, 'isSubitem:', isSubitem);
4698
+ console.log('═══════════════════════════════════════════════════════════');
4699
+ console.log('🔍 STARTING SEARCH FOR ITEM/SUBITEM');
4700
+ console.log('═══════════════════════════════════════════════════════════');
4701
+ console.log('📋 Search Parameters:');
4702
+ console.log(' - identifierColumn (raw):', JSON.stringify(identifierColumn));
4703
+ console.log(' - identifierColumn (trimmed):', JSON.stringify(identifierColumn.trim()));
4704
+ console.log(' - identifierValue (raw):', JSON.stringify(identifierValue));
4705
+ console.log(' - identifierValue (trimmed):', JSON.stringify(identifierValue.trim()));
4706
+ console.log(' - isSubitem:', isSubitem);
4707
+ console.log(' - boardId:', boardId);
4708
+ console.log('═══════════════════════════════════════════════════════════');
4699
4709
  const parentId = this.getNodeParameter('parentId', 0, false);
4710
+ console.log(' - parentId:', parentId || '(not provided)');
4700
4711
  const isNameColumn = identifierColumn === 'name' || identifierColumn.toLowerCase() === 'name';
4712
+ console.log(' - isNameColumn:', isNameColumn);
4701
4713
  let searchBoardId = boardId;
4714
+ console.log(' - Initial searchBoardId:', searchBoardId);
4702
4715
  if (isSubitem && !parentId) {
4716
+ console.log(' - Discovering subitem board...');
4703
4717
  try {
4704
4718
  const discoverQuery = `query {
4705
4719
  boards(ids: [${boardId}]) {
@@ -4724,15 +4738,20 @@ class Worktables {
4724
4738
  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
4739
  if (items.length > 0 && items[0].subitems && items[0].subitems.length > 0) {
4726
4740
  searchBoardId = ((_1 = items[0].subitems[0].board) === null || _1 === void 0 ? void 0 : _1.id) || boardId;
4727
- console.log(`Discovered subitem board ID: ${searchBoardId}`);
4741
+ console.log(`Discovered subitem board ID: ${searchBoardId}`);
4742
+ }
4743
+ else {
4744
+ console.log(` ⚠ No subitems found to discover board, using main board: ${boardId}`);
4728
4745
  }
4729
4746
  }
4730
4747
  catch (error) {
4731
- console.log('Could not discover subitem board, using main board:', error);
4748
+ console.log('Could not discover subitem board, using main board:', error);
4732
4749
  }
4733
4750
  }
4751
+ console.log(' - Final searchBoardId:', searchBoardId);
4734
4752
  let columnType = null;
4735
4753
  if (!isNameColumn) {
4754
+ console.log(' - Fetching column type for:', identifierColumn);
4736
4755
  try {
4737
4756
  const columnTypeQuery = `query {
4738
4757
  boards(ids: [${searchBoardId}]) {
@@ -4751,17 +4770,28 @@ class Worktables {
4751
4770
  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
4771
  if (columns.length > 0) {
4753
4772
  columnType = columns[0].type;
4754
- console.log(`Column type detected: ${columnType}`);
4773
+ console.log(`Column type detected: ${columnType}`);
4774
+ }
4775
+ else {
4776
+ console.log(` ⚠ Column not found in board ${searchBoardId}`);
4755
4777
  }
4756
4778
  }
4757
4779
  catch (error) {
4758
- console.log('Could not fetch column type, using default operator:', error);
4780
+ console.log('Could not fetch column type, using default operator:', error);
4759
4781
  }
4760
4782
  }
4783
+ else {
4784
+ console.log(' - Skipping column type fetch (isNameColumn=true)');
4785
+ }
4761
4786
  const searchColumnId = isNameColumn ? 'name' : identifierColumn;
4762
4787
  const operator = columnType === 'status' ? 'contains_terms' : 'contains_text';
4763
4788
  const limit = 100;
4789
+ console.log(' - searchColumnId:', searchColumnId);
4790
+ console.log(' - operator:', operator);
4791
+ console.log(' - limit:', limit);
4792
+ console.log('═══════════════════════════════════════════════════════════');
4764
4793
  if (isSubitem && parentId) {
4794
+ console.log('🔍 Searching subitems with parentId:', parentId);
4765
4795
  const parentQuery = `query {
4766
4796
  items(ids: [${parentId}]) {
4767
4797
  id
@@ -4802,15 +4832,19 @@ class Worktables {
4802
4832
  });
4803
4833
  const searchData = JSON.parse(searchResponse);
4804
4834
  const items = ((_5 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _5 === void 0 ? void 0 : _5.items) || [];
4835
+ console.log(` - Parent query response: ${items.length} parent item(s) found`);
4805
4836
  if (items.length > 0 && items[0].subitems) {
4806
4837
  const subitems = items[0].subitems;
4807
- console.log(`🔍 Searching subitems of parent ${parentId}, found ${subitems.length} subitem(s)`);
4808
- for (const subitem of subitems) {
4838
+ console.log(` - Found ${subitems.length} subitem(s) to check`);
4839
+ for (let i = 0; i < subitems.length; i++) {
4840
+ const subitem = subitems[i];
4841
+ console.log(` - Checking subitem ${i + 1}/${subitems.length}: ID=${subitem.id}, name="${subitem.name}"`);
4809
4842
  let matches = false;
4810
4843
  if (isNameColumn) {
4811
4844
  const searchValue = identifierValue.trim().toLowerCase();
4812
4845
  const subitemName = (subitem.name || '').trim().toLowerCase();
4813
4846
  matches = subitemName === searchValue;
4847
+ console.log(` - Name comparison: "${subitemName}" === "${searchValue}" = ${matches}`);
4814
4848
  }
4815
4849
  else {
4816
4850
  const colValue = (_6 = subitem.column_values) === null || _6 === void 0 ? void 0 : _6.find((cv) => cv.id === identifierColumn);
@@ -4821,90 +4855,168 @@ class Worktables {
4821
4855
  ? (colValue.display_value || '').trim()
4822
4856
  : (colValue.text || '').trim();
4823
4857
  const searchValue = identifierValue.trim().toLowerCase();
4824
- matches = compareValue.toLowerCase() === searchValue;
4858
+ console.log(` - Column type: ${colValue.type}`);
4859
+ console.log(` - Column value found: "${compareValue}" (length: ${compareValue.length}, raw: ${JSON.stringify(compareValue)})`);
4860
+ console.log(` - Search value: "${identifierValue}" (length: ${identifierValue.trim().length}, trimmed: "${identifierValue.trim()}", raw: ${JSON.stringify(identifierValue)})`);
4861
+ const trimmedCompare = compareValue.trim().toLowerCase();
4862
+ const trimmedSearch = searchValue.trim();
4863
+ matches = trimmedCompare === trimmedSearch;
4864
+ console.log(` - Trimmed compare: "${trimmedCompare}" === "${trimmedSearch}" = ${matches}`);
4825
4865
  if (isStatusColumn && !matches) {
4826
- const normalizedCompare = compareValue.toLowerCase().replace(/\s+/g, ' ').trim();
4827
- const normalizedSearch = searchValue.replace(/\s+/g, ' ').trim();
4866
+ const normalizedCompare = trimmedCompare.replace(/\s+/g, ' ').trim();
4867
+ const normalizedSearch = trimmedSearch.replace(/\s+/g, ' ').trim();
4828
4868
  matches = normalizedCompare === normalizedSearch;
4869
+ console.log(` - Normalized compare: "${normalizedCompare}" === "${normalizedSearch}" = ${matches}`);
4829
4870
  if (!matches) {
4830
- console.log(`Status column comparison failed for subitem ${subitem.id}: compareValue="${compareValue}" (normalized: "${normalizedCompare}") vs searchValue="${identifierValue}" (normalized: "${normalizedSearch}")`);
4871
+ matches = normalizedCompare.includes(normalizedSearch) || normalizedSearch.includes(normalizedCompare);
4872
+ console.log(` - Contains check: "${normalizedCompare}".includes("${normalizedSearch}") OR "${normalizedSearch}".includes("${normalizedCompare}") = ${matches}`);
4873
+ }
4874
+ if (!matches) {
4875
+ console.log(` ❌ Status column comparison failed for subitem ${subitem.id}`);
4831
4876
  }
4832
4877
  }
4833
- if (!matches && colValue.type) {
4834
- console.log(`Column value comparison for subitem ${subitem.id}, column type: ${colValue.type}, compareValue: "${compareValue}", searchValue: "${identifierValue}"`);
4878
+ if (!matches) {
4879
+ console.log(` No match for subitem ${subitem.id}, column type: ${colValue.type}`);
4835
4880
  }
4836
4881
  }
4837
4882
  else {
4838
- console.log(`Column value not found for subitem ${subitem.id}, identifierColumn: ${identifierColumn}`);
4883
+ console.log(`Column value not found for subitem ${subitem.id}, identifierColumn: ${identifierColumn}`);
4884
+ console.log(` - Available column_values:`, ((_7 = subitem.column_values) === null || _7 === void 0 ? void 0 : _7.map((cv) => cv.id).join(', ')) || 'none');
4839
4885
  }
4840
4886
  }
4841
4887
  if (matches) {
4842
4888
  foundItemId = subitem.id;
4843
- foundItemBoardId = ((_7 = subitem.board) === null || _7 === void 0 ? void 0 : _7.id) || null;
4844
- console.log(`✓ Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
4889
+ foundItemBoardId = ((_8 = subitem.board) === null || _8 === void 0 ? void 0 : _8.id) || null;
4890
+ console.log(` ✓✓✓ MATCH FOUND! Subitem ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
4845
4891
  break;
4846
4892
  }
4893
+ else {
4894
+ console.log(` ✗ No match for subitem ${subitem.id}`);
4895
+ }
4847
4896
  }
4848
4897
  }
4849
4898
  }
4850
4899
  else {
4851
- const query = `{
4852
- boards(ids: [${searchBoardId}]) {
4853
- items_page (
4854
- limit: ${limit},
4855
- query_params: {
4856
- rules: [{
4857
- column_id: "${searchColumnId}",
4858
- compare_value: "${identifierValue}",
4859
- operator: ${operator}
4860
- }]
4861
- }
4862
- ) {
4863
- items {
4864
- name
4865
- id
4866
- url
4867
- column_values(ids: "${identifierColumn}") {
4900
+ let useExactSearch = (columnType === 'text' || isNameColumn) && columnType !== 'status';
4901
+ console.log('🔍 Searching items (not subitems)');
4902
+ console.log(' - useExactSearch:', useExactSearch);
4903
+ console.log(' - columnType:', columnType);
4904
+ console.log(' - isNameColumn:', isNameColumn);
4905
+ let items = [];
4906
+ if (useExactSearch) {
4907
+ console.log(' - Attempting exact search with is_equal operator...');
4908
+ const query = `{
4909
+ boards(ids: [${searchBoardId}]) {
4910
+ items_page (
4911
+ limit: ${limit},
4912
+ query_params: {
4913
+ rules: [{
4914
+ column_id: "${searchColumnId}",
4915
+ compare_value: "${identifierValue}",
4916
+ operator: is_equal
4917
+ }]
4918
+ }
4919
+ ) {
4920
+ items {
4921
+ name
4868
4922
  id
4869
- text
4870
- type
4871
- column {
4923
+ url
4924
+ column_values(ids: "${identifierColumn}") {
4872
4925
  id
4926
+ text
4927
+ type
4928
+ column {
4929
+ id
4930
+ }
4931
+ ... on BoardRelationValue {
4932
+ display_value
4933
+ }
4934
+ ... on MirrorValue {
4935
+ display_value
4936
+ }
4937
+ ... on StatusValue {
4938
+ text
4939
+ index
4940
+ }
4873
4941
  }
4874
- ... on BoardRelationValue {
4875
- display_value
4876
- }
4877
- ... on MirrorValue {
4878
- display_value
4879
- }
4880
- ... on StatusValue {
4942
+ }
4943
+ }
4944
+ }
4945
+ }`;
4946
+ try {
4947
+ const searchResponse = await this.helpers.request({
4948
+ method: 'POST',
4949
+ url: 'https://api.monday.com/v2',
4950
+ headers,
4951
+ body: { query },
4952
+ });
4953
+ const searchData = JSON.parse(searchResponse);
4954
+ 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;
4955
+ items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
4956
+ console.log(` ✓ Exact search (is_equal) found ${items.length} item(s)`);
4957
+ }
4958
+ catch (error) {
4959
+ console.log(' ❌ Exact search failed, falling back to fetch all:', error);
4960
+ useExactSearch = false;
4961
+ }
4962
+ }
4963
+ if (!useExactSearch || items.length === 0) {
4964
+ console.log(' - Fetching all items from board for exact matching...');
4965
+ const query = `{
4966
+ boards(ids: [${searchBoardId}]) {
4967
+ items_page(limit: ${limit}) {
4968
+ items {
4969
+ name
4970
+ id
4971
+ url
4972
+ column_values(ids: "${identifierColumn}") {
4973
+ id
4881
4974
  text
4882
- index
4975
+ type
4976
+ column {
4977
+ id
4978
+ }
4979
+ ... on BoardRelationValue {
4980
+ display_value
4981
+ }
4982
+ ... on MirrorValue {
4983
+ display_value
4984
+ }
4985
+ ... on StatusValue {
4986
+ text
4987
+ index
4988
+ }
4883
4989
  }
4884
4990
  }
4885
4991
  }
4886
4992
  }
4887
- }
4888
- }`;
4889
- const searchResponse = await this.helpers.request({
4890
- method: 'POST',
4891
- url: 'https://api.monday.com/v2',
4892
- headers,
4893
- body: { query },
4894
- });
4895
- const searchData = JSON.parse(searchResponse);
4896
- 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;
4897
- const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
4898
- console.log(`🔍 Optimized search found ${items.length} item(s) matching identifier`);
4899
- for (const item of items) {
4993
+ }`;
4994
+ const searchResponse = await this.helpers.request({
4995
+ method: 'POST',
4996
+ url: 'https://api.monday.com/v2',
4997
+ headers,
4998
+ body: { query },
4999
+ });
5000
+ const searchData = JSON.parse(searchResponse);
5001
+ 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;
5002
+ items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5003
+ console.log(` ✓ Fetched ${items.length} item(s) from board for exact matching`);
5004
+ }
5005
+ console.log(` - Starting exact comparison on ${items.length} item(s)...`);
5006
+ for (let i = 0; i < items.length; i++) {
5007
+ const item = items[i];
5008
+ console.log(` - Checking item ${i + 1}/${items.length}: ID=${item.id}, name="${item.name}"`);
4900
5009
  let matches = false;
4901
5010
  if (isNameColumn) {
4902
5011
  const searchValue = identifierValue.trim().toLowerCase();
4903
5012
  const itemName = (item.name || '').trim().toLowerCase();
4904
5013
  matches = itemName === searchValue;
5014
+ console.log(` - Name comparison: "${itemName}" === "${searchValue}" = ${matches}`);
4905
5015
  }
4906
5016
  else {
4907
- const colValue = (_11 = item.column_values) === null || _11 === void 0 ? void 0 : _11.find((cv) => cv.id === identifierColumn);
5017
+ console.log(` - Looking for column with ID: "${identifierColumn}"`);
5018
+ console.log(` - Available column_values IDs:`, ((_15 = item.column_values) === null || _15 === void 0 ? void 0 : _15.map((cv) => `${cv.id} (type: ${cv.type})`).join(', ')) || 'none');
5019
+ const colValue = (_16 = item.column_values) === null || _16 === void 0 ? void 0 : _16.find((cv) => cv.id === identifierColumn);
4908
5020
  if (colValue) {
4909
5021
  const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
4910
5022
  const isStatusColumn = colValue.type === 'status';
@@ -4912,42 +5024,95 @@ class Worktables {
4912
5024
  ? (colValue.display_value || '').trim()
4913
5025
  : (colValue.text || '').trim();
4914
5026
  const searchValue = identifierValue.trim().toLowerCase();
4915
- matches = compareValue.toLowerCase() === searchValue;
4916
- if (isStatusColumn && !matches) {
4917
- const normalizedCompare = compareValue.toLowerCase().replace(/\s+/g, ' ').trim();
4918
- const normalizedSearch = searchValue.replace(/\s+/g, ' ').trim();
5027
+ console.log(` - Found column: ID="${colValue.id}", type="${colValue.type}"`);
5028
+ console.log(` - Column value found: "${compareValue}" (length: ${compareValue.length}, raw: ${JSON.stringify(compareValue)})`);
5029
+ console.log(` - Search value: "${identifierValue}" (length: ${identifierValue.trim().length}, trimmed: "${identifierValue.trim()}", raw: ${JSON.stringify(identifierValue)})`);
5030
+ const trimmedCompare = compareValue.trim().toLowerCase();
5031
+ const trimmedSearch = searchValue.trim();
5032
+ matches = trimmedCompare === trimmedSearch;
5033
+ console.log(` - Trimmed compare: "${trimmedCompare}" === "${trimmedSearch}" = ${matches}`);
5034
+ if (!matches && isStatusColumn) {
5035
+ const normalizedCompare = trimmedCompare.replace(/\s+/g, ' ').trim();
5036
+ const normalizedSearch = trimmedSearch.replace(/\s+/g, ' ').trim();
4919
5037
  matches = normalizedCompare === normalizedSearch;
5038
+ console.log(` - Normalized compare: "${normalizedCompare}" === "${normalizedSearch}" = ${matches}`);
4920
5039
  if (!matches) {
4921
- console.log(`Status column comparison failed for item ${item.id}: compareValue="${compareValue}" (normalized: "${normalizedCompare}") vs searchValue="${identifierValue}" (normalized: "${normalizedSearch}")`);
5040
+ matches = normalizedCompare.includes(normalizedSearch) || normalizedSearch.includes(normalizedCompare);
5041
+ console.log(` - Contains check: "${normalizedCompare}".includes("${normalizedSearch}") OR "${normalizedSearch}".includes("${normalizedCompare}") = ${matches}`);
4922
5042
  }
4923
5043
  }
4924
- if (!matches && colValue.type) {
4925
- console.log(`Column value comparison for item ${item.id}, column type: ${colValue.type}, compareValue: "${compareValue}", searchValue: "${identifierValue}"`);
5044
+ if (matches) {
5045
+ console.log(` ✓✓✓ MATCH FOUND! Item ${item.id}, column type: ${colValue.type}, value: "${compareValue}"`);
5046
+ }
5047
+ else {
5048
+ console.log(` ❌ No match: item ${item.id}, column type: ${colValue.type}, compareValue: "${compareValue}", searchValue: "${identifierValue}"`);
4926
5049
  }
4927
5050
  }
4928
5051
  else {
4929
- console.log(`Column value not found for item ${item.id}, identifierColumn: ${identifierColumn}`);
5052
+ console.log(` ⚠⚠⚠ Column value not found for item ${item.id}`);
5053
+ console.log(` - Looking for column ID: "${identifierColumn}"`);
5054
+ console.log(` - Available column_values:`, ((_17 = item.column_values) === null || _17 === void 0 ? void 0 : _17.map((cv) => `ID:${cv.id} (type:${cv.type}, text:"${cv.text || 'N/A'}")`).join(' | ')) || 'none');
5055
+ console.log(` - This means the identifierColumn "${identifierColumn}" does not match any column ID in this item!`);
4930
5056
  }
4931
5057
  }
4932
5058
  if (matches) {
4933
5059
  foundItemId = item.id;
4934
5060
  if (isSubitem) {
4935
5061
  foundItemBoardId = searchBoardId;
4936
- console.log(`✓ Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
5062
+ console.log(` ✓✓✓ Found matching ${isSubitem ? 'subitem' : 'item'} with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
4937
5063
  }
4938
5064
  else {
4939
- console.log(`✓ Found item with ID: ${foundItemId}`);
5065
+ console.log(` ✓✓✓ Found matching item with ID: ${foundItemId}`);
4940
5066
  }
4941
5067
  break;
4942
5068
  }
5069
+ else {
5070
+ console.log(` ✗ No match for item ${item.id}`);
5071
+ }
5072
+ }
5073
+ if (!foundItemId) {
5074
+ console.log(` ❌❌❌ No exact match found for identifier column "${identifierColumn}" with value "${identifierValue}"`);
5075
+ const uniqueValues = new Set();
5076
+ items.forEach((item) => {
5077
+ var _a;
5078
+ if (!isNameColumn) {
5079
+ const colValue = (_a = item.column_values) === null || _a === void 0 ? void 0 : _a.find((cv) => cv.id === identifierColumn);
5080
+ if (colValue) {
5081
+ const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
5082
+ const value = isBoardRelation
5083
+ ? (colValue.display_value || '').trim()
5084
+ : (colValue.text || '').trim();
5085
+ if (value) {
5086
+ uniqueValues.add(value);
5087
+ }
5088
+ }
5089
+ }
5090
+ });
5091
+ if (uniqueValues.size > 0) {
5092
+ console.log(` 📊 Debug: Found ${uniqueValues.size} unique value(s) in column "${identifierColumn}":`);
5093
+ Array.from(uniqueValues).sort().forEach((val, idx) => {
5094
+ console.log(` ${idx + 1}. "${val}" (length: ${val.length}, raw: ${JSON.stringify(val)})`);
5095
+ });
5096
+ console.log(` 🔍 Searching for: "${identifierValue.trim()}" (length: ${identifierValue.trim().length}, raw: ${JSON.stringify(identifierValue)})`);
5097
+ }
4943
5098
  }
4944
5099
  }
5100
+ console.log('═══════════════════════════════════════════════════════════');
5101
+ console.log('📊 SEARCH RESULT:');
5102
+ console.log(' - foundItemId:', foundItemId || 'null (not found)');
5103
+ console.log(' - foundItemBoardId:', foundItemBoardId || 'null');
5104
+ console.log('═══════════════════════════════════════════════════════════');
4945
5105
  if (foundItemId) {
4946
- console.log(`Found existing ${isSubitem ? 'subitem' : 'item'}, updating:`, foundItemId);
5106
+ console.log(`🔄 Found existing ${isSubitem ? 'subitem' : 'item'}, updating:`, foundItemId);
4947
5107
  const escapedColumnValues = (0, worktablesHelpers_1.escapeGraphQLJSONString)(column_values_object);
4948
5108
  const updateBoardId = (isSubitem && foundItemBoardId) ? foundItemBoardId : boardId;
5109
+ console.log('═══════════════════════════════════════════════════════════');
5110
+ console.log('🔄 UPDATE OPERATION:');
5111
+ console.log(' - updateBoardId:', updateBoardId);
5112
+ console.log(' - foundItemId:', foundItemId);
5113
+ console.log(' - column_values_object:', JSON.stringify(column_values_object, null, 2));
4949
5114
  if (isSubitem && !foundItemBoardId) {
4950
- console.log(`⚠ Warning: Subitem board_id not found, using main board_id ${boardId}. This may cause errors.`);
5115
+ console.log(` ⚠ Warning: Subitem board_id not found, using main board_id ${boardId}. This may cause errors.`);
4951
5116
  }
4952
5117
  mutation = `mutation {
4953
5118
  change_multiple_column_values(
@@ -4963,7 +5128,8 @@ class Worktables {
4963
5128
  }
4964
5129
  }
4965
5130
  }`;
4966
- console.log('Generated Update Mutation:', mutation);
5131
+ console.log(' - Generated Update Mutation:', mutation);
5132
+ console.log(' - Sending update request...');
4967
5133
  response = await this.helpers.request({
4968
5134
  method: 'POST',
4969
5135
  url: 'https://api.monday.com/v2',
@@ -4971,6 +5137,7 @@ class Worktables {
4971
5137
  body: { query: mutation },
4972
5138
  });
4973
5139
  const responseData = JSON.parse(response);
5140
+ console.log(' - Update response received:', JSON.stringify(responseData, null, 2));
4974
5141
  if (!responseData.errors && responseData.data && responseData.data.change_multiple_column_values) {
4975
5142
  const itemData = responseData.data.change_multiple_column_values;
4976
5143
  if (itemData && itemData.id) {
@@ -4978,23 +5145,26 @@ class Worktables {
4978
5145
  id: itemData.id,
4979
5146
  url: itemData.url || '',
4980
5147
  operation: 'update',
4981
- board_id: ((_12 = itemData.board) === null || _12 === void 0 ? void 0 : _12.id) || boardId,
5148
+ board_id: ((_18 = itemData.board) === null || _18 === void 0 ? void 0 : _18.id) || boardId,
4982
5149
  column_values: column_values_object,
4983
5150
  };
4984
5151
  itemUpdated = true;
4985
- console.log(`Successfully updated ${isSubitem ? 'subitem' : 'item'}:`, itemData.id);
5152
+ console.log(` ✓✓✓ Successfully updated ${isSubitem ? 'subitem' : 'item'}:`, itemData.id);
5153
+ console.log('═══════════════════════════════════════════════════════════');
4986
5154
  }
4987
5155
  else {
4988
- console.log(`Update response missing item data, will create new ${isSubitem ? 'subitem' : 'item'} instead`);
5156
+ console.log(`Update response missing item data, will create new ${isSubitem ? 'subitem' : 'item'} instead`);
5157
+ console.log(' - itemData:', JSON.stringify(itemData, null, 2));
4989
5158
  itemUpdated = false;
4990
5159
  }
4991
5160
  }
4992
5161
  else {
4993
5162
  if (responseData.errors) {
4994
- console.log('Error updating item:', JSON.stringify(responseData.errors));
5163
+ console.log('Error updating item:', JSON.stringify(responseData.errors, null, 2));
4995
5164
  }
4996
5165
  else {
4997
- console.log('Update response missing data, will create new item instead');
5166
+ console.log('Update response missing data, will create new item instead');
5167
+ console.log(' - responseData.data:', JSON.stringify(responseData.data, null, 2));
4998
5168
  }
4999
5169
  itemUpdated = false;
5000
5170
  }
@@ -5008,11 +5178,15 @@ class Worktables {
5008
5178
  }
5009
5179
  }
5010
5180
  else {
5011
- console.log('No identifier provided, will create new item');
5181
+ console.log('═══════════════════════════════════════════════════════════');
5182
+ console.log('ℹ️ No identifier provided, will create new item');
5183
+ console.log('═══════════════════════════════════════════════════════════');
5012
5184
  itemUpdated = false;
5013
5185
  }
5014
5186
  if (!itemUpdated) {
5015
- console.log(`Creating new ${isSubitem ? 'subitem' : 'item'}:`, itemName);
5187
+ console.log('═══════════════════════════════════════════════════════════');
5188
+ console.log(`➕ CREATING NEW ${isSubitem ? 'SUBITEM' : 'ITEM'}:`, itemName);
5189
+ console.log('═══════════════════════════════════════════════════════════');
5016
5190
  const parentId = this.getNodeParameter('parentId', 0, false);
5017
5191
  if (isSubitem && !parentId) {
5018
5192
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
@@ -5056,6 +5230,8 @@ class Worktables {
5056
5230
  }
5057
5231
  }`;
5058
5232
  }
5233
+ console.log(' - Generated Create Mutation:', mutation);
5234
+ console.log(' - Sending create request...');
5059
5235
  response = await this.helpers.request({
5060
5236
  method: 'POST',
5061
5237
  url: 'https://api.monday.com/v2',
@@ -5063,25 +5239,30 @@ class Worktables {
5063
5239
  body: { query: mutation },
5064
5240
  });
5065
5241
  const responseData = JSON.parse(response);
5242
+ console.log(' - Create response received:', JSON.stringify(responseData, null, 2));
5066
5243
  if (responseData.errors) {
5244
+ console.log(' ❌ Error creating item:', JSON.stringify(responseData.errors, null, 2));
5067
5245
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5068
5246
  message: `Error creating ${isSubitem ? 'subitem' : 'item'}: ${JSON.stringify(responseData.errors)}`,
5069
5247
  });
5070
5248
  }
5071
5249
  const itemData = isSubitem && parentId
5072
- ? (_13 = responseData.data) === null || _13 === void 0 ? void 0 : _13.create_subitem
5073
- : (_14 = responseData.data) === null || _14 === void 0 ? void 0 : _14.create_item;
5250
+ ? (_19 = responseData.data) === null || _19 === void 0 ? void 0 : _19.create_subitem
5251
+ : (_20 = responseData.data) === null || _20 === void 0 ? void 0 : _20.create_item;
5074
5252
  if (!itemData || !itemData.id) {
5253
+ console.log(' ❌ No item data returned in response');
5075
5254
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5076
5255
  message: `Error creating ${isSubitem ? 'subitem' : 'item'}: No item data returned`,
5077
5256
  });
5078
5257
  }
5258
+ console.log(` ✓✓✓ Successfully created ${isSubitem ? 'subitem' : 'item'}:`, itemData.id);
5259
+ console.log('═══════════════════════════════════════════════════════════');
5079
5260
  formatted = {
5080
5261
  id: itemData.id,
5081
5262
  name: itemData.name || itemName,
5082
5263
  url: itemData.url || '',
5083
5264
  operation: 'create',
5084
- board_id: ((_15 = itemData.board) === null || _15 === void 0 ? void 0 : _15.id) || boardId,
5265
+ board_id: ((_21 = itemData.board) === null || _21 === void 0 ? void 0 : _21.id) || boardId,
5085
5266
  column_values: column_values_object,
5086
5267
  };
5087
5268
  if (isSubitem && parentId) {
@@ -5122,12 +5303,12 @@ class Worktables {
5122
5303
  if (itemParsed.errors) {
5123
5304
  throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(itemParsed.errors) });
5124
5305
  }
5125
- const items = ((_16 = itemParsed === null || itemParsed === void 0 ? void 0 : itemParsed.data) === null || _16 === void 0 ? void 0 : _16.items) || [];
5306
+ const items = ((_22 = itemParsed === null || itemParsed === void 0 ? void 0 : itemParsed.data) === null || _22 === void 0 ? void 0 : _22.items) || [];
5126
5307
  if (items.length === 0) {
5127
5308
  return [[{ json: { item_id: itemId, activity_logs: [] } }]];
5128
5309
  }
5129
5310
  const item = items[0];
5130
- const boardId = (_17 = item.board) === null || _17 === void 0 ? void 0 : _17.id;
5311
+ const boardId = (_23 = item.board) === null || _23 === void 0 ? void 0 : _23.id;
5131
5312
  if (!boardId) {
5132
5313
  throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Could not retrieve board ID for the item.' });
5133
5314
  }
@@ -5165,7 +5346,7 @@ class Worktables {
5165
5346
  if (parsed.errors) {
5166
5347
  throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(parsed.errors) });
5167
5348
  }
5168
- const boards = ((_18 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _18 === void 0 ? void 0 : _18.boards) || [];
5349
+ const boards = ((_24 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _24 === void 0 ? void 0 : _24.boards) || [];
5169
5350
  const activityLogs = boards.length > 0 ? (boards[0].activity_logs || []) : [];
5170
5351
  const formatted = {
5171
5352
  item_id: item.id,
@@ -5324,7 +5505,7 @@ class Worktables {
5324
5505
  body: { query },
5325
5506
  });
5326
5507
  const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
5327
- 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;
5508
+ const itemsPage = (_27 = (_26 = (_25 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _25 === void 0 ? void 0 : _25.boards) === null || _26 === void 0 ? void 0 : _26[0]) === null || _27 === void 0 ? void 0 : _27.items_page;
5328
5509
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5329
5510
  cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
5330
5511
  allItems = allItems.concat(items);
@@ -5403,7 +5584,7 @@ class Worktables {
5403
5584
  const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
5404
5585
  const logicalOperator = this.getNodeParameter('logicalOperator', 0);
5405
5586
  let rulesArray = [];
5406
- if (((_22 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _22 === void 0 ? void 0 : _22.length) > 0) {
5587
+ if (((_28 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _28 === void 0 ? void 0 : _28.length) > 0) {
5407
5588
  rulesArray = filterRules.rule.map((rule) => {
5408
5589
  let formattedValue;
5409
5590
  if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
@@ -5447,7 +5628,7 @@ class Worktables {
5447
5628
  });
5448
5629
  }
5449
5630
  const orderByArray = [];
5450
- if (((_23 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _23 === void 0 ? void 0 : _23.length) > 0) {
5631
+ if (((_29 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _29 === void 0 ? void 0 : _29.length) > 0) {
5451
5632
  sortOptions.sortBy.forEach((sort) => {
5452
5633
  orderByArray.push(`{
5453
5634
  column_id: "${sort.columnId}",
@@ -5503,7 +5684,7 @@ class Worktables {
5503
5684
  body: { query },
5504
5685
  });
5505
5686
  const parsed = JSON.parse(rawResponse);
5506
- 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) || [];
5687
+ const items = ((_33 = (_32 = (_31 = (_30 = parsed === null || parsed === void 0 ? void 0 : parsed.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) || [];
5507
5688
  const formattedItems = await Promise.all(items.map(async (item) => {
5508
5689
  const formatted = {
5509
5690
  id: item.id,
@@ -5537,7 +5718,7 @@ class Worktables {
5537
5718
  const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
5538
5719
  const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
5539
5720
  let rulesArray = [];
5540
- if (((_28 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _28 === void 0 ? void 0 : _28.length) > 0) {
5721
+ if (((_34 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _34 === void 0 ? void 0 : _34.length) > 0) {
5541
5722
  console.log('Processing filter rules:', advancedFilterRules.rule);
5542
5723
  rulesArray = advancedFilterRules.rule.map((rule) => {
5543
5724
  let formattedValue;
@@ -5753,7 +5934,7 @@ class Worktables {
5753
5934
  });
5754
5935
  }
5755
5936
  const orderByArray = [];
5756
- if (((_29 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _29 === void 0 ? void 0 : _29.length) > 0) {
5937
+ if (((_35 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _35 === void 0 ? void 0 : _35.length) > 0) {
5757
5938
  advancedSortOptions.sortBy.forEach((sort) => {
5758
5939
  orderByArray.push(`{
5759
5940
  column_id: "${sort.columnId}",
@@ -5835,7 +6016,7 @@ class Worktables {
5835
6016
  body: { query: testQuery },
5836
6017
  });
5837
6018
  const testParsed = JSON.parse(testResponse);
5838
- 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) || [];
6019
+ const testItems = ((_39 = (_38 = (_37 = (_36 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.data) === null || _36 === void 0 ? void 0 : _36.boards) === null || _37 === void 0 ? void 0 : _37[0]) === null || _38 === void 0 ? void 0 : _38.items_page) === null || _39 === void 0 ? void 0 : _39.items) || [];
5839
6020
  console.log('Test - Items in board (no filters):', testItems.length);
5840
6021
  if (testItems.length > 0) {
5841
6022
  console.log('Sample item column values:', testItems[0].column_values);
@@ -5847,7 +6028,7 @@ class Worktables {
5847
6028
  body: { query },
5848
6029
  });
5849
6030
  const parsed = JSON.parse(rawResponse);
5850
- 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;
6031
+ const itemsPage = (_42 = (_41 = (_40 = parsed === null || parsed === void 0 ? void 0 : parsed.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;
5851
6032
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5852
6033
  const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
5853
6034
  const hasMore = nextCursor ? true : false;
@@ -6029,7 +6210,7 @@ class Worktables {
6029
6210
  body: { query },
6030
6211
  });
6031
6212
  const parsed = JSON.parse(rawResponse);
6032
- 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;
6213
+ const itemsPage = (_47 = (_46 = (_45 = (_44 = (_43 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _43 === void 0 ? void 0 : _43.boards) === null || _44 === void 0 ? void 0 : _44[0]) === null || _45 === void 0 ? void 0 : _45.groups) === null || _46 === void 0 ? void 0 : _46[0]) === null || _47 === void 0 ? void 0 : _47.items_page;
6033
6214
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
6034
6215
  cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
6035
6216
  allItems = allItems.concat(items);
@@ -6126,7 +6307,7 @@ class Worktables {
6126
6307
  response = await (0, isErrorResponse_1.parseApiResponse)(response);
6127
6308
  if (response.success) {
6128
6309
  const parsed = JSON.parse(response.data);
6129
- 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) || [];
6310
+ const updates = ((_50 = (_49 = (_48 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _48 === void 0 ? void 0 : _48.items) === null || _49 === void 0 ? void 0 : _49[0]) === null || _50 === void 0 ? void 0 : _50.updates) || [];
6130
6311
  const formattedUpdates = updates.map((update) => {
6131
6312
  const pinnedToTop = update.pinned_to_top || [];
6132
6313
  const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
@@ -6191,7 +6372,7 @@ class Worktables {
6191
6372
  console.log('variables:', variables);
6192
6373
  response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
6193
6374
  console.log('Create Update Result:', JSON.stringify(response, null, 2));
6194
- 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;
6375
+ const updateId = (_52 = (_51 = JSON.parse(response).data) === null || _51 === void 0 ? void 0 : _51.create_update) === null || _52 === void 0 ? void 0 : _52.id;
6195
6376
  if (!updateId) {
6196
6377
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
6197
6378
  message: 'Error creating update: Update not created, no ID returned',
@@ -6500,7 +6681,7 @@ class Worktables {
6500
6681
  body: { query },
6501
6682
  json: true,
6502
6683
  });
6503
- 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];
6684
+ const asset = (_54 = (_53 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _53 === void 0 ? void 0 : _53.assets) === null || _54 === void 0 ? void 0 : _54[0];
6504
6685
  if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
6505
6686
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
6506
6687
  message: 'Public URL not found for the given file ID.',