@worktables/n8n-nodes-worktables 12.14.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('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:', 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
@@ -4802,15 +4830,19 @@ class Worktables {
4802
4830
  });
4803
4831
  const searchData = JSON.parse(searchResponse);
4804
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`);
4805
4834
  if (items.length > 0 && items[0].subitems) {
4806
4835
  const subitems = items[0].subitems;
4807
- console.log(`🔍 Searching subitems of parent ${parentId}, found ${subitems.length} subitem(s)`);
4808
- for (const subitem of subitems) {
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}"`);
4809
4840
  let matches = false;
4810
4841
  if (isNameColumn) {
4811
4842
  const searchValue = identifierValue.trim().toLowerCase();
4812
4843
  const subitemName = (subitem.name || '').trim().toLowerCase();
4813
4844
  matches = subitemName === searchValue;
4845
+ console.log(` - Name comparison: "${subitemName}" === "${searchValue}" = ${matches}`);
4814
4846
  }
4815
4847
  else {
4816
4848
  const colValue = (_6 = subitem.column_values) === null || _6 === void 0 ? void 0 : _6.find((cv) => cv.id === identifierColumn);
@@ -4821,90 +4853,160 @@ class Worktables {
4821
4853
  ? (colValue.display_value || '').trim()
4822
4854
  : (colValue.text || '').trim();
4823
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}"`);
4824
4859
  matches = compareValue.toLowerCase() === searchValue;
4860
+ console.log(` - Initial match: ${matches}`);
4825
4861
  if (isStatusColumn && !matches) {
4826
4862
  const normalizedCompare = compareValue.toLowerCase().replace(/\s+/g, ' ').trim();
4827
4863
  const normalizedSearch = searchValue.replace(/\s+/g, ' ').trim();
4828
4864
  matches = normalizedCompare === normalizedSearch;
4865
+ console.log(` - Normalized compare: "${normalizedCompare}" === "${normalizedSearch}" = ${matches}`);
4829
4866
  if (!matches) {
4830
- console.log(`Status column comparison failed for subitem ${subitem.id}: compareValue="${compareValue}" (normalized: "${normalizedCompare}") vs searchValue="${identifierValue}" (normalized: "${normalizedSearch}")`);
4867
+ console.log(`Status column comparison failed for subitem ${subitem.id}`);
4831
4868
  }
4832
4869
  }
4833
- if (!matches && colValue.type) {
4834
- console.log(`Column value comparison for subitem ${subitem.id}, column type: ${colValue.type}, compareValue: "${compareValue}", searchValue: "${identifierValue}"`);
4870
+ if (!matches) {
4871
+ console.log(` No match for subitem ${subitem.id}, column type: ${colValue.type}`);
4835
4872
  }
4836
4873
  }
4837
4874
  else {
4838
- console.log(`Column value not found for subitem ${subitem.id}, identifierColumn: ${identifierColumn}`);
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');
4839
4877
  }
4840
4878
  }
4841
4879
  if (matches) {
4842
4880
  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}`);
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}`);
4845
4883
  break;
4846
4884
  }
4885
+ else {
4886
+ console.log(` ✗ No match for subitem ${subitem.id}`);
4887
+ }
4847
4888
  }
4848
4889
  }
4849
4890
  }
4850
4891
  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}") {
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
4868
4914
  id
4869
- text
4870
- type
4871
- column {
4915
+ url
4916
+ column_values(ids: "${identifierColumn}") {
4872
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
+ }
4873
4933
  }
4874
- ... on BoardRelationValue {
4875
- display_value
4876
- }
4877
- ... on MirrorValue {
4878
- display_value
4879
- }
4880
- ... on StatusValue {
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
4881
4966
  text
4882
- index
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
+ }
4883
4981
  }
4884
4982
  }
4885
4983
  }
4886
4984
  }
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) {
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}"`);
4900
5001
  let matches = false;
4901
5002
  if (isNameColumn) {
4902
5003
  const searchValue = identifierValue.trim().toLowerCase();
4903
5004
  const itemName = (item.name || '').trim().toLowerCase();
4904
5005
  matches = itemName === searchValue;
5006
+ console.log(` - Name comparison: "${itemName}" === "${searchValue}" = ${matches}`);
4905
5007
  }
4906
5008
  else {
4907
- const colValue = (_11 = item.column_values) === null || _11 === void 0 ? void 0 : _11.find((cv) => cv.id === identifierColumn);
5009
+ const colValue = (_15 = item.column_values) === null || _15 === void 0 ? void 0 : _15.find((cv) => cv.id === identifierColumn);
4908
5010
  if (colValue) {
4909
5011
  const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
4910
5012
  const isStatusColumn = colValue.type === 'status';
@@ -4912,42 +5014,64 @@ class Worktables {
4912
5014
  ? (colValue.display_value || '').trim()
4913
5015
  : (colValue.text || '').trim();
4914
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}"`);
4915
5020
  matches = compareValue.toLowerCase() === searchValue;
4916
- if (isStatusColumn && !matches) {
5021
+ console.log(` - Initial match: ${matches}`);
5022
+ if (!matches && isStatusColumn) {
4917
5023
  const normalizedCompare = compareValue.toLowerCase().replace(/\s+/g, ' ').trim();
4918
5024
  const normalizedSearch = searchValue.replace(/\s+/g, ' ').trim();
4919
5025
  matches = normalizedCompare === normalizedSearch;
4920
- if (!matches) {
4921
- console.log(`Status column comparison failed for item ${item.id}: compareValue="${compareValue}" (normalized: "${normalizedCompare}") vs searchValue="${identifierValue}" (normalized: "${normalizedSearch}")`);
4922
- }
5026
+ console.log(` - Normalized compare: "${normalizedCompare}" === "${normalizedSearch}" = ${matches}`);
4923
5027
  }
4924
- if (!matches && colValue.type) {
4925
- console.log(`Column value comparison for item ${item.id}, column type: ${colValue.type}, compareValue: "${compareValue}", searchValue: "${identifierValue}"`);
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}"`);
4926
5033
  }
4927
5034
  }
4928
5035
  else {
4929
- console.log(`Column value not found for item ${item.id}, identifierColumn: ${identifierColumn}`);
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');
4930
5038
  }
4931
5039
  }
4932
5040
  if (matches) {
4933
5041
  foundItemId = item.id;
4934
5042
  if (isSubitem) {
4935
5043
  foundItemBoardId = searchBoardId;
4936
- console.log(`✓ Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
5044
+ console.log(` ✓✓✓ Found matching ${isSubitem ? 'subitem' : 'item'} with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
4937
5045
  }
4938
5046
  else {
4939
- console.log(`✓ Found item with ID: ${foundItemId}`);
5047
+ console.log(` ✓✓✓ Found matching item with ID: ${foundItemId}`);
4940
5048
  }
4941
5049
  break;
4942
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}"`);
4943
5057
  }
4944
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('═══════════════════════════════════════════════════════════');
4945
5064
  if (foundItemId) {
4946
- console.log(`Found existing ${isSubitem ? 'subitem' : 'item'}, updating:`, foundItemId);
5065
+ console.log(`🔄 Found existing ${isSubitem ? 'subitem' : 'item'}, updating:`, foundItemId);
4947
5066
  const escapedColumnValues = (0, worktablesHelpers_1.escapeGraphQLJSONString)(column_values_object);
4948
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));
4949
5073
  if (isSubitem && !foundItemBoardId) {
4950
- console.log(`⚠ Warning: Subitem board_id not found, using main board_id ${boardId}. This may cause errors.`);
5074
+ console.log(` ⚠ Warning: Subitem board_id not found, using main board_id ${boardId}. This may cause errors.`);
4951
5075
  }
4952
5076
  mutation = `mutation {
4953
5077
  change_multiple_column_values(
@@ -4963,7 +5087,8 @@ class Worktables {
4963
5087
  }
4964
5088
  }
4965
5089
  }`;
4966
- console.log('Generated Update Mutation:', mutation);
5090
+ console.log(' - Generated Update Mutation:', mutation);
5091
+ console.log(' - Sending update request...');
4967
5092
  response = await this.helpers.request({
4968
5093
  method: 'POST',
4969
5094
  url: 'https://api.monday.com/v2',
@@ -4971,6 +5096,7 @@ class Worktables {
4971
5096
  body: { query: mutation },
4972
5097
  });
4973
5098
  const responseData = JSON.parse(response);
5099
+ console.log(' - Update response received:', JSON.stringify(responseData, null, 2));
4974
5100
  if (!responseData.errors && responseData.data && responseData.data.change_multiple_column_values) {
4975
5101
  const itemData = responseData.data.change_multiple_column_values;
4976
5102
  if (itemData && itemData.id) {
@@ -4978,23 +5104,26 @@ class Worktables {
4978
5104
  id: itemData.id,
4979
5105
  url: itemData.url || '',
4980
5106
  operation: 'update',
4981
- board_id: ((_12 = itemData.board) === null || _12 === void 0 ? void 0 : _12.id) || boardId,
5107
+ board_id: ((_17 = itemData.board) === null || _17 === void 0 ? void 0 : _17.id) || boardId,
4982
5108
  column_values: column_values_object,
4983
5109
  };
4984
5110
  itemUpdated = true;
4985
- console.log(`Successfully updated ${isSubitem ? 'subitem' : 'item'}:`, itemData.id);
5111
+ console.log(` ✓✓✓ Successfully updated ${isSubitem ? 'subitem' : 'item'}:`, itemData.id);
5112
+ console.log('═══════════════════════════════════════════════════════════');
4986
5113
  }
4987
5114
  else {
4988
- 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));
4989
5117
  itemUpdated = false;
4990
5118
  }
4991
5119
  }
4992
5120
  else {
4993
5121
  if (responseData.errors) {
4994
- console.log('Error updating item:', JSON.stringify(responseData.errors));
5122
+ console.log('Error updating item:', JSON.stringify(responseData.errors, null, 2));
4995
5123
  }
4996
5124
  else {
4997
- 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));
4998
5127
  }
4999
5128
  itemUpdated = false;
5000
5129
  }
@@ -5008,11 +5137,15 @@ class Worktables {
5008
5137
  }
5009
5138
  }
5010
5139
  else {
5011
- console.log('No identifier provided, will create new item');
5140
+ console.log('═══════════════════════════════════════════════════════════');
5141
+ console.log('ℹ️ No identifier provided, will create new item');
5142
+ console.log('═══════════════════════════════════════════════════════════');
5012
5143
  itemUpdated = false;
5013
5144
  }
5014
5145
  if (!itemUpdated) {
5015
- console.log(`Creating new ${isSubitem ? 'subitem' : 'item'}:`, itemName);
5146
+ console.log('═══════════════════════════════════════════════════════════');
5147
+ console.log(`➕ CREATING NEW ${isSubitem ? 'SUBITEM' : 'ITEM'}:`, itemName);
5148
+ console.log('═══════════════════════════════════════════════════════════');
5016
5149
  const parentId = this.getNodeParameter('parentId', 0, false);
5017
5150
  if (isSubitem && !parentId) {
5018
5151
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
@@ -5056,6 +5189,8 @@ class Worktables {
5056
5189
  }
5057
5190
  }`;
5058
5191
  }
5192
+ console.log(' - Generated Create Mutation:', mutation);
5193
+ console.log(' - Sending create request...');
5059
5194
  response = await this.helpers.request({
5060
5195
  method: 'POST',
5061
5196
  url: 'https://api.monday.com/v2',
@@ -5063,25 +5198,30 @@ class Worktables {
5063
5198
  body: { query: mutation },
5064
5199
  });
5065
5200
  const responseData = JSON.parse(response);
5201
+ console.log(' - Create response received:', JSON.stringify(responseData, null, 2));
5066
5202
  if (responseData.errors) {
5203
+ console.log(' ❌ Error creating item:', JSON.stringify(responseData.errors, null, 2));
5067
5204
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5068
5205
  message: `Error creating ${isSubitem ? 'subitem' : 'item'}: ${JSON.stringify(responseData.errors)}`,
5069
5206
  });
5070
5207
  }
5071
5208
  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;
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;
5074
5211
  if (!itemData || !itemData.id) {
5212
+ console.log(' ❌ No item data returned in response');
5075
5213
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5076
5214
  message: `Error creating ${isSubitem ? 'subitem' : 'item'}: No item data returned`,
5077
5215
  });
5078
5216
  }
5217
+ console.log(` ✓✓✓ Successfully created ${isSubitem ? 'subitem' : 'item'}:`, itemData.id);
5218
+ console.log('═══════════════════════════════════════════════════════════');
5079
5219
  formatted = {
5080
5220
  id: itemData.id,
5081
5221
  name: itemData.name || itemName,
5082
5222
  url: itemData.url || '',
5083
5223
  operation: 'create',
5084
- board_id: ((_15 = itemData.board) === null || _15 === void 0 ? void 0 : _15.id) || boardId,
5224
+ board_id: ((_20 = itemData.board) === null || _20 === void 0 ? void 0 : _20.id) || boardId,
5085
5225
  column_values: column_values_object,
5086
5226
  };
5087
5227
  if (isSubitem && parentId) {
@@ -5122,12 +5262,12 @@ class Worktables {
5122
5262
  if (itemParsed.errors) {
5123
5263
  throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(itemParsed.errors) });
5124
5264
  }
5125
- const items = ((_16 = itemParsed === null || itemParsed === void 0 ? void 0 : itemParsed.data) === null || _16 === void 0 ? void 0 : _16.items) || [];
5265
+ const items = ((_21 = itemParsed === null || itemParsed === void 0 ? void 0 : itemParsed.data) === null || _21 === void 0 ? void 0 : _21.items) || [];
5126
5266
  if (items.length === 0) {
5127
5267
  return [[{ json: { item_id: itemId, activity_logs: [] } }]];
5128
5268
  }
5129
5269
  const item = items[0];
5130
- const boardId = (_17 = item.board) === null || _17 === void 0 ? void 0 : _17.id;
5270
+ const boardId = (_22 = item.board) === null || _22 === void 0 ? void 0 : _22.id;
5131
5271
  if (!boardId) {
5132
5272
  throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Could not retrieve board ID for the item.' });
5133
5273
  }
@@ -5165,7 +5305,7 @@ class Worktables {
5165
5305
  if (parsed.errors) {
5166
5306
  throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(parsed.errors) });
5167
5307
  }
5168
- const boards = ((_18 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _18 === void 0 ? void 0 : _18.boards) || [];
5308
+ const boards = ((_23 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _23 === void 0 ? void 0 : _23.boards) || [];
5169
5309
  const activityLogs = boards.length > 0 ? (boards[0].activity_logs || []) : [];
5170
5310
  const formatted = {
5171
5311
  item_id: item.id,
@@ -5324,7 +5464,7 @@ class Worktables {
5324
5464
  body: { query },
5325
5465
  });
5326
5466
  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;
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;
5328
5468
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5329
5469
  cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
5330
5470
  allItems = allItems.concat(items);
@@ -5403,7 +5543,7 @@ class Worktables {
5403
5543
  const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
5404
5544
  const logicalOperator = this.getNodeParameter('logicalOperator', 0);
5405
5545
  let rulesArray = [];
5406
- if (((_22 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _22 === void 0 ? void 0 : _22.length) > 0) {
5546
+ if (((_27 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _27 === void 0 ? void 0 : _27.length) > 0) {
5407
5547
  rulesArray = filterRules.rule.map((rule) => {
5408
5548
  let formattedValue;
5409
5549
  if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
@@ -5447,7 +5587,7 @@ class Worktables {
5447
5587
  });
5448
5588
  }
5449
5589
  const orderByArray = [];
5450
- if (((_23 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _23 === void 0 ? void 0 : _23.length) > 0) {
5590
+ if (((_28 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _28 === void 0 ? void 0 : _28.length) > 0) {
5451
5591
  sortOptions.sortBy.forEach((sort) => {
5452
5592
  orderByArray.push(`{
5453
5593
  column_id: "${sort.columnId}",
@@ -5503,7 +5643,7 @@ class Worktables {
5503
5643
  body: { query },
5504
5644
  });
5505
5645
  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) || [];
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) || [];
5507
5647
  const formattedItems = await Promise.all(items.map(async (item) => {
5508
5648
  const formatted = {
5509
5649
  id: item.id,
@@ -5537,7 +5677,7 @@ class Worktables {
5537
5677
  const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
5538
5678
  const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
5539
5679
  let rulesArray = [];
5540
- if (((_28 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _28 === void 0 ? void 0 : _28.length) > 0) {
5680
+ if (((_33 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _33 === void 0 ? void 0 : _33.length) > 0) {
5541
5681
  console.log('Processing filter rules:', advancedFilterRules.rule);
5542
5682
  rulesArray = advancedFilterRules.rule.map((rule) => {
5543
5683
  let formattedValue;
@@ -5753,7 +5893,7 @@ class Worktables {
5753
5893
  });
5754
5894
  }
5755
5895
  const orderByArray = [];
5756
- if (((_29 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _29 === void 0 ? void 0 : _29.length) > 0) {
5896
+ if (((_34 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _34 === void 0 ? void 0 : _34.length) > 0) {
5757
5897
  advancedSortOptions.sortBy.forEach((sort) => {
5758
5898
  orderByArray.push(`{
5759
5899
  column_id: "${sort.columnId}",
@@ -5835,7 +5975,7 @@ class Worktables {
5835
5975
  body: { query: testQuery },
5836
5976
  });
5837
5977
  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) || [];
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) || [];
5839
5979
  console.log('Test - Items in board (no filters):', testItems.length);
5840
5980
  if (testItems.length > 0) {
5841
5981
  console.log('Sample item column values:', testItems[0].column_values);
@@ -5847,7 +5987,7 @@ class Worktables {
5847
5987
  body: { query },
5848
5988
  });
5849
5989
  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;
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;
5851
5991
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5852
5992
  const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
5853
5993
  const hasMore = nextCursor ? true : false;
@@ -6029,7 +6169,7 @@ class Worktables {
6029
6169
  body: { query },
6030
6170
  });
6031
6171
  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;
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;
6033
6173
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
6034
6174
  cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
6035
6175
  allItems = allItems.concat(items);
@@ -6126,7 +6266,7 @@ class Worktables {
6126
6266
  response = await (0, isErrorResponse_1.parseApiResponse)(response);
6127
6267
  if (response.success) {
6128
6268
  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) || [];
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) || [];
6130
6270
  const formattedUpdates = updates.map((update) => {
6131
6271
  const pinnedToTop = update.pinned_to_top || [];
6132
6272
  const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
@@ -6191,7 +6331,7 @@ class Worktables {
6191
6331
  console.log('variables:', variables);
6192
6332
  response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
6193
6333
  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;
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;
6195
6335
  if (!updateId) {
6196
6336
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
6197
6337
  message: 'Error creating update: Update not created, no ID returned',
@@ -6500,7 +6640,7 @@ class Worktables {
6500
6640
  body: { query },
6501
6641
  json: true,
6502
6642
  });
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];
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];
6504
6644
  if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
6505
6645
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
6506
6646
  message: 'Public URL not found for the given file ID.',