@worktables/n8n-nodes-worktables 12.4.0 → 12.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -252,6 +252,12 @@ class Worktables {
252
252
  description: 'List all subscribers of an item',
253
253
  action: 'List item subscribers',
254
254
  },
255
+ {
256
+ name: 'Get Item Activity Logs',
257
+ value: 'getItemActivityLogs',
258
+ description: 'Retrieve activity logs of a specific item',
259
+ action: 'Get item activity logs',
260
+ },
255
261
  {
256
262
  name: 'Upload files to column',
257
263
  value: 'uploadItemFile',
@@ -915,7 +921,7 @@ class Worktables {
915
921
  default: '',
916
922
  description: 'Enter the date from which to retrieve activity logs',
917
923
  displayOptions: {
918
- show: { operation: ['listBoardActivityLogs'] },
924
+ show: { operation: ['listBoardActivityLogs', 'getItemActivityLogs'] },
919
925
  },
920
926
  },
921
927
  {
@@ -925,7 +931,7 @@ class Worktables {
925
931
  default: '',
926
932
  description: 'Enter the date to which to retrieve activity logs',
927
933
  displayOptions: {
928
- show: { operation: ['listBoardActivityLogs'] },
934
+ show: { operation: ['listBoardActivityLogs', 'getItemActivityLogs'] },
929
935
  },
930
936
  },
931
937
  {
@@ -979,6 +985,22 @@ class Worktables {
979
985
  show: { operation: ['getGroup', 'listGroupItems'] },
980
986
  },
981
987
  },
988
+ {
989
+ displayName: 'Limit',
990
+ name: 'limit',
991
+ type: 'number',
992
+ typeOptions: {
993
+ minValue: 0,
994
+ },
995
+ default: 50,
996
+ description: 'Max number of results to return',
997
+ hint: 'If 0 is provided, all items will be returned. This may take longer for large groups.',
998
+ displayOptions: {
999
+ show: {
1000
+ operation: ['listGroupItems'],
1001
+ },
1002
+ },
1003
+ },
982
1004
  {
983
1005
  displayName: 'Position Relative',
984
1006
  name: 'positionRelative',
@@ -1106,7 +1128,7 @@ class Worktables {
1106
1128
  description: 'Specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
1107
1129
  displayOptions: {
1108
1130
  show: {
1109
- operation: ['getItem', 'deleteItem'],
1131
+ operation: ['getItem', 'deleteItem', 'getItemActivityLogs'],
1110
1132
  },
1111
1133
  },
1112
1134
  },
@@ -3156,7 +3178,7 @@ class Worktables {
3156
3178
  };
3157
3179
  }
3158
3180
  async execute() {
3159
- 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;
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;
3160
3182
  const resource = this.getNodeParameter('resource', 0);
3161
3183
  const operation = this.getNodeParameter('operation', 0);
3162
3184
  const credentials = await this.getCredentials('WorktablesApi');
@@ -4675,200 +4697,212 @@ class Worktables {
4675
4697
  if (identifierValue && identifierValue.trim() !== '' && identifierColumn && identifierColumn.trim() !== '') {
4676
4698
  console.log('Searching for item/subitem with identifier column:', identifierColumn, 'value:', identifierValue, 'isSubitem:', isSubitem);
4677
4699
  const parentId = this.getNodeParameter('parentId', 0, false);
4678
- let cursor = null;
4679
- let hasMore = true;
4680
- while (hasMore && !foundItemId) {
4681
- const cursorParam = cursor ? `, cursor: "${cursor}"` : '';
4682
- const searchQuery = isSubitem && parentId
4683
- ? `query {
4684
- items(ids: [${parentId}]) {
4685
- id
4686
- name
4687
- subitems {
4688
- id
4689
- name
4690
- board {
4691
- id
4692
- }
4693
- column_values(ids: ["${identifierColumn}"]) {
4694
- id
4695
- text
4696
- value
4697
- type
4698
- ... on BoardRelationValue {
4699
- display_value
4700
- }
4701
- ... on MirrorValue {
4702
- display_value
4703
- }
4704
- }
4705
- }
4706
- }
4707
- }`
4708
- : isSubitem
4709
- ? `query {
4700
+ const isNameColumn = identifierColumn === 'name' || identifierColumn.toLowerCase() === 'name';
4701
+ let searchBoardId = boardId;
4702
+ if (isSubitem && !parentId) {
4703
+ try {
4704
+ const discoverQuery = `query {
4710
4705
  boards(ids: [${boardId}]) {
4711
- items_page(limit: 100${cursorParam}) {
4706
+ items_page(limit: 1) {
4712
4707
  items {
4713
- id
4714
- name
4715
4708
  subitems {
4716
- id
4717
- name
4718
4709
  board {
4719
4710
  id
4720
4711
  }
4721
- column_values(ids: ["${identifierColumn}"]) {
4722
- id
4723
- text
4724
- value
4725
- type
4726
- ... on BoardRelationValue {
4727
- display_value
4728
- }
4729
- ... on MirrorValue {
4730
- display_value
4731
- }
4732
- }
4733
4712
  }
4734
4713
  }
4735
- cursor
4736
4714
  }
4737
4715
  }
4738
- }`
4739
- : `query {
4740
- boards(ids: [${boardId}]) {
4741
- items_page(limit: 100${cursorParam}) {
4742
- items {
4716
+ }`;
4717
+ const discoverResponse = await this.helpers.request({
4718
+ method: 'POST',
4719
+ url: 'https://api.monday.com/v2',
4720
+ headers,
4721
+ body: { query: discoverQuery },
4722
+ });
4723
+ const discoverData = JSON.parse(discoverResponse);
4724
+ const items = ((_0 = (_z = (_y = (_x = discoverData === null || discoverData === void 0 ? void 0 : discoverData.data) === null || _x === void 0 ? void 0 : _x.boards) === null || _y === void 0 ? void 0 : _y[0]) === null || _z === void 0 ? void 0 : _z.items_page) === null || _0 === void 0 ? void 0 : _0.items) || [];
4725
+ if (items.length > 0 && items[0].subitems && items[0].subitems.length > 0) {
4726
+ searchBoardId = ((_1 = items[0].subitems[0].board) === null || _1 === void 0 ? void 0 : _1.id) || boardId;
4727
+ console.log(`Discovered subitem board ID: ${searchBoardId}`);
4728
+ }
4729
+ }
4730
+ catch (error) {
4731
+ console.log('Could not discover subitem board, using main board:', error);
4732
+ }
4733
+ }
4734
+ let columnType = null;
4735
+ if (!isNameColumn) {
4736
+ try {
4737
+ const columnTypeQuery = `query {
4738
+ boards(ids: [${searchBoardId}]) {
4739
+ columns(ids: ["${identifierColumn}"]) {
4740
+ type
4741
+ }
4742
+ }
4743
+ }`;
4744
+ const columnTypeResponse = await this.helpers.request({
4745
+ method: 'POST',
4746
+ url: 'https://api.monday.com/v2',
4747
+ headers,
4748
+ body: { query: columnTypeQuery },
4749
+ });
4750
+ const columnTypeData = JSON.parse(columnTypeResponse);
4751
+ const columns = ((_4 = (_3 = (_2 = columnTypeData === null || columnTypeData === void 0 ? void 0 : columnTypeData.data) === null || _2 === void 0 ? void 0 : _2.boards) === null || _3 === void 0 ? void 0 : _3[0]) === null || _4 === void 0 ? void 0 : _4.columns) || [];
4752
+ if (columns.length > 0) {
4753
+ columnType = columns[0].type;
4754
+ console.log(`Column type detected: ${columnType}`);
4755
+ }
4756
+ }
4757
+ catch (error) {
4758
+ console.log('Could not fetch column type, using default operator:', error);
4759
+ }
4760
+ }
4761
+ const searchColumnId = isNameColumn ? 'name' : identifierColumn;
4762
+ const operator = columnType === 'status' ? 'contains_terms' : 'contains_text';
4763
+ const limit = 100;
4764
+ if (isSubitem && parentId) {
4765
+ const parentQuery = `query {
4766
+ items(ids: [${parentId}]) {
4767
+ id
4768
+ name
4769
+ subitems {
4770
+ id
4771
+ name
4772
+ url
4773
+ board {
4774
+ id
4775
+ }
4776
+ column_values(ids: ["${identifierColumn}"]) {
4777
+ id
4778
+ text
4779
+ type
4780
+ column {
4743
4781
  id
4744
- name
4745
- column_values(ids: ["${identifierColumn}"]) {
4746
- id
4747
- text
4748
- value
4749
- type
4750
- ... on BoardRelationValue {
4751
- display_value
4752
- }
4753
- ... on MirrorValue {
4754
- display_value
4755
- }
4756
- }
4757
4782
  }
4758
- cursor
4783
+ ... on BoardRelationValue {
4784
+ display_value
4785
+ }
4786
+ ... on MirrorValue {
4787
+ display_value
4788
+ }
4759
4789
  }
4760
4790
  }
4761
- }`;
4791
+ }
4792
+ }`;
4762
4793
  const searchResponse = await this.helpers.request({
4763
4794
  method: 'POST',
4764
4795
  url: 'https://api.monday.com/v2',
4765
4796
  headers,
4766
- body: { query: searchQuery },
4797
+ body: { query: parentQuery },
4767
4798
  });
4768
4799
  const searchData = JSON.parse(searchResponse);
4769
- let items = [];
4770
- let nextCursor = null;
4771
- if (isSubitem && parentId) {
4772
- items = ((_x = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _x === void 0 ? void 0 : _x.items) || [];
4773
- hasMore = false;
4774
- console.log(`🔍 Searching subitems of parent ${parentId}, found ${items.length} parent item(s)`);
4775
- if (items.length > 0 && items[0].subitems) {
4776
- console.log(`🔍 Parent item has ${items[0].subitems.length} subitem(s)`);
4777
- }
4778
- }
4779
- else {
4780
- const itemsPage = (_0 = (_z = (_y = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _y === void 0 ? void 0 : _y.boards) === null || _z === void 0 ? void 0 : _z[0]) === null || _0 === void 0 ? void 0 : _0.items_page;
4781
- items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
4782
- nextCursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
4783
- hasMore = nextCursor !== null && items.length > 0 && !foundItemId;
4784
- console.log(`🔍 Searching in board, found ${items.length} item(s)`);
4785
- }
4786
- cursor = nextCursor;
4787
- const isNameColumn = identifierColumn === 'name' || identifierColumn.toLowerCase() === 'name';
4788
- if (isSubitem) {
4789
- for (const item of items) {
4790
- if (item.subitems && Array.isArray(item.subitems)) {
4791
- for (const subitem of item.subitems) {
4792
- let matches = false;
4793
- if (isNameColumn) {
4794
- const searchValue = identifierValue.trim().toLowerCase();
4795
- const subitemName = (subitem.name || '').trim().toLowerCase();
4796
- matches = subitemName === searchValue;
4797
- }
4798
- else {
4799
- const colValue = (_1 = subitem.column_values) === null || _1 === void 0 ? void 0 : _1.find((cv) => cv.id === identifierColumn);
4800
- if (colValue) {
4801
- const isBoardRelation = colValue.type === 'board_relation';
4802
- const compareValue = isBoardRelation
4803
- ? (colValue.display_value || '').trim()
4804
- : (colValue.text || '').trim();
4805
- const searchValue = identifierValue.trim().toLowerCase();
4806
- const compareValueLower = compareValue.toLowerCase();
4807
- matches = compareValueLower === searchValue;
4808
- if (matches) {
4809
- console.log(`✓ Match found! Subitem ${subitem.id} - Column ${identifierColumn} (${colValue.type}): ${isBoardRelation ? 'display_value' : 'text'}="${compareValue}", search="${identifierValue}"`);
4810
- }
4811
- else if (compareValue) {
4812
- console.log(`✗ No match - Subitem ${subitem.id} - Column ${identifierColumn} (${colValue.type}): ${isBoardRelation ? 'display_value' : 'text'}="${compareValue}", search="${identifierValue}"`);
4813
- }
4814
- }
4815
- else {
4816
- console.log(`⚠ Subitem ${subitem.id} - Column ${identifierColumn} not found in column_values`);
4817
- }
4818
- }
4819
- if (matches) {
4820
- foundItemId = subitem.id;
4821
- foundItemBoardId = ((_2 = subitem.board) === null || _2 === void 0 ? void 0 : _2.id) || null;
4822
- console.log(`Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
4823
- break;
4824
- }
4825
- }
4826
- if (foundItemId)
4827
- break;
4828
- }
4829
- }
4830
- }
4831
- else {
4832
- for (const item of items) {
4800
+ const items = ((_5 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _5 === void 0 ? void 0 : _5.items) || [];
4801
+ if (items.length > 0 && items[0].subitems) {
4802
+ const subitems = items[0].subitems;
4803
+ console.log(`🔍 Searching subitems of parent ${parentId}, found ${subitems.length} subitem(s)`);
4804
+ for (const subitem of subitems) {
4833
4805
  let matches = false;
4834
4806
  if (isNameColumn) {
4835
4807
  const searchValue = identifierValue.trim().toLowerCase();
4836
- const itemName = (item.name || '').trim().toLowerCase();
4837
- matches = itemName === searchValue;
4808
+ const subitemName = (subitem.name || '').trim().toLowerCase();
4809
+ matches = subitemName === searchValue;
4838
4810
  }
4839
4811
  else {
4840
- const colValue = (_3 = item.column_values) === null || _3 === void 0 ? void 0 : _3.find((cv) => cv.id === identifierColumn);
4812
+ const colValue = (_6 = subitem.column_values) === null || _6 === void 0 ? void 0 : _6.find((cv) => cv.id === identifierColumn);
4841
4813
  if (colValue) {
4842
- const isBoardRelation = colValue.type === 'board_relation';
4814
+ const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
4843
4815
  const compareValue = isBoardRelation
4844
4816
  ? (colValue.display_value || '').trim()
4845
4817
  : (colValue.text || '').trim();
4846
- console.log(`🔍 Item ${item.id} - Column ${identifierColumn} (${colValue.type}): raw colValue=`, JSON.stringify(colValue));
4847
4818
  const searchValue = identifierValue.trim().toLowerCase();
4848
- const compareValueLower = compareValue.toLowerCase();
4849
- matches = compareValueLower === searchValue;
4850
- if (matches) {
4851
- console.log(`✓ Match found! Item ${item.id} - Column ${identifierColumn} (${colValue.type}): ${isBoardRelation ? 'display_value' : 'text'}="${compareValue}", search="${identifierValue}"`);
4852
- }
4853
- else if (compareValue) {
4854
- console.log(`✗ No match - Item ${item.id} - Column ${identifierColumn} (${colValue.type}): ${isBoardRelation ? 'display_value' : 'text'}="${compareValue}", search="${identifierValue}"`);
4855
- }
4856
- else {
4857
- console.log(`⚠ Item ${item.id} - Column ${identifierColumn} (${colValue.type}): compareValue is empty, display_value="${colValue.display_value}", text="${colValue.text}"`);
4858
- }
4859
- }
4860
- else {
4861
- console.log(`⚠ Item ${item.id} - Column ${identifierColumn} not found in column_values`);
4819
+ matches = compareValue.toLowerCase() === searchValue;
4862
4820
  }
4863
4821
  }
4864
4822
  if (matches) {
4865
- foundItemId = item.id;
4866
- console.log(`Found item with ID: ${foundItemId}`);
4823
+ foundItemId = subitem.id;
4824
+ foundItemBoardId = ((_7 = subitem.board) === null || _7 === void 0 ? void 0 : _7.id) || null;
4825
+ console.log(`✓ Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
4867
4826
  break;
4868
4827
  }
4869
4828
  }
4870
4829
  }
4871
- hasMore = cursor !== null && items.length > 0 && !foundItemId;
4830
+ }
4831
+ else {
4832
+ const query = `{
4833
+ boards(ids: [${searchBoardId}]) {
4834
+ items_page (
4835
+ limit: ${limit},
4836
+ query_params: {
4837
+ rules: [{
4838
+ column_id: "${searchColumnId}",
4839
+ compare_value: "${identifierValue}",
4840
+ operator: ${operator}
4841
+ }]
4842
+ }
4843
+ ) {
4844
+ items {
4845
+ name
4846
+ id
4847
+ url
4848
+ column_values(ids: "${identifierColumn}") {
4849
+ id
4850
+ text
4851
+ type
4852
+ column {
4853
+ id
4854
+ }
4855
+ ... on BoardRelationValue {
4856
+ display_value
4857
+ }
4858
+ ... on MirrorValue {
4859
+ display_value
4860
+ }
4861
+ }
4862
+ }
4863
+ }
4864
+ }
4865
+ }`;
4866
+ const searchResponse = await this.helpers.request({
4867
+ method: 'POST',
4868
+ url: 'https://api.monday.com/v2',
4869
+ headers,
4870
+ body: { query },
4871
+ });
4872
+ const searchData = JSON.parse(searchResponse);
4873
+ const itemsPage = (_10 = (_9 = (_8 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _8 === void 0 ? void 0 : _8.boards) === null || _9 === void 0 ? void 0 : _9[0]) === null || _10 === void 0 ? void 0 : _10.items_page;
4874
+ const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
4875
+ console.log(`🔍 Optimized search found ${items.length} item(s) matching identifier`);
4876
+ for (const item of items) {
4877
+ let matches = false;
4878
+ if (isNameColumn) {
4879
+ const searchValue = identifierValue.trim().toLowerCase();
4880
+ const itemName = (item.name || '').trim().toLowerCase();
4881
+ matches = itemName === searchValue;
4882
+ }
4883
+ else {
4884
+ const colValue = (_11 = item.column_values) === null || _11 === void 0 ? void 0 : _11.find((cv) => cv.id === identifierColumn);
4885
+ if (colValue) {
4886
+ const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
4887
+ const compareValue = isBoardRelation
4888
+ ? (colValue.display_value || '').trim()
4889
+ : (colValue.text || '').trim();
4890
+ const searchValue = identifierValue.trim().toLowerCase();
4891
+ matches = compareValue.toLowerCase() === searchValue;
4892
+ }
4893
+ }
4894
+ if (matches) {
4895
+ foundItemId = item.id;
4896
+ if (isSubitem) {
4897
+ foundItemBoardId = searchBoardId;
4898
+ console.log(`✓ Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
4899
+ }
4900
+ else {
4901
+ console.log(`✓ Found item with ID: ${foundItemId}`);
4902
+ }
4903
+ break;
4904
+ }
4905
+ }
4872
4906
  }
4873
4907
  if (foundItemId) {
4874
4908
  console.log(`Found existing ${isSubitem ? 'subitem' : 'item'}, updating:`, foundItemId);
@@ -4906,7 +4940,7 @@ class Worktables {
4906
4940
  id: itemData.id,
4907
4941
  url: itemData.url || '',
4908
4942
  operation: 'update',
4909
- board_id: ((_4 = itemData.board) === null || _4 === void 0 ? void 0 : _4.id) || boardId,
4943
+ board_id: ((_12 = itemData.board) === null || _12 === void 0 ? void 0 : _12.id) || boardId,
4910
4944
  column_values: column_values_object,
4911
4945
  };
4912
4946
  itemUpdated = true;
@@ -4997,8 +5031,8 @@ class Worktables {
4997
5031
  });
4998
5032
  }
4999
5033
  const itemData = isSubitem && parentId
5000
- ? (_5 = responseData.data) === null || _5 === void 0 ? void 0 : _5.create_subitem
5001
- : (_6 = responseData.data) === null || _6 === void 0 ? void 0 : _6.create_item;
5034
+ ? (_13 = responseData.data) === null || _13 === void 0 ? void 0 : _13.create_subitem
5035
+ : (_14 = responseData.data) === null || _14 === void 0 ? void 0 : _14.create_item;
5002
5036
  if (!itemData || !itemData.id) {
5003
5037
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5004
5038
  message: `Error creating ${isSubitem ? 'subitem' : 'item'}: No item data returned`,
@@ -5009,7 +5043,7 @@ class Worktables {
5009
5043
  name: itemData.name || itemName,
5010
5044
  url: itemData.url || '',
5011
5045
  operation: 'create',
5012
- board_id: ((_7 = itemData.board) === null || _7 === void 0 ? void 0 : _7.id) || boardId,
5046
+ board_id: ((_15 = itemData.board) === null || _15 === void 0 ? void 0 : _15.id) || boardId,
5013
5047
  column_values: column_values_object,
5014
5048
  };
5015
5049
  if (isSubitem && parentId) {
@@ -5018,6 +5052,70 @@ class Worktables {
5018
5052
  }
5019
5053
  return [[{ json: formatted }]];
5020
5054
  }
5055
+ case 'getItemActivityLogs': {
5056
+ const itemId = this.getNodeParameter('itemId', 0);
5057
+ const from = this.getNodeParameter('from', 0, '');
5058
+ const to = this.getNodeParameter('to', 0, '');
5059
+ if (!itemId) {
5060
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Item ID is required.' });
5061
+ }
5062
+ console.log('Getting activity logs for item:', itemId);
5063
+ console.log('From: ', from);
5064
+ console.log('To: ', to);
5065
+ let activityLogsQuery = 'activity_logs';
5066
+ if (from || to) {
5067
+ const fromParam = from ? `from: "${from}Z"` : '';
5068
+ const toParam = to ? `to: "${to}Z"` : '';
5069
+ const params = [fromParam, toParam].filter(p => p).join(', ');
5070
+ activityLogsQuery = `activity_logs (${params})`;
5071
+ }
5072
+ const query = `
5073
+ query {
5074
+ items(ids: ["${itemId}"]) {
5075
+ id
5076
+ name
5077
+ ${activityLogsQuery} {
5078
+ id
5079
+ user_id
5080
+ entity
5081
+ event
5082
+ data
5083
+ created_at
5084
+ }
5085
+ }
5086
+ }
5087
+ `;
5088
+ console.log('Query: ', query);
5089
+ response = await this.helpers.request({
5090
+ method: 'POST',
5091
+ url: 'https://api.monday.com/v2',
5092
+ headers,
5093
+ body: { query },
5094
+ });
5095
+ const parsed = typeof response === 'string' ? JSON.parse(response) : response;
5096
+ if (parsed.errors) {
5097
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(parsed.errors) });
5098
+ }
5099
+ const items = ((_16 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _16 === void 0 ? void 0 : _16.items) || [];
5100
+ if (items.length === 0) {
5101
+ return [[{ json: { item_id: itemId, activity_logs: [] } }]];
5102
+ }
5103
+ const item = items[0];
5104
+ const activityLogs = item.activity_logs || [];
5105
+ const formatted = {
5106
+ item_id: item.id,
5107
+ item_name: item.name,
5108
+ activity_logs: activityLogs.map((log) => ({
5109
+ id: log.id,
5110
+ user_id: log.user_id,
5111
+ entity: log.entity,
5112
+ event: log.event,
5113
+ data: log.data,
5114
+ created_at: log.created_at,
5115
+ })),
5116
+ };
5117
+ return [[{ json: formatted }]];
5118
+ }
5021
5119
  case 'deleteItem': {
5022
5120
  console.log('Delete an item');
5023
5121
  const itemId = this.getNodeParameter('itemId', 0);
@@ -5148,7 +5246,7 @@ class Worktables {
5148
5246
  body: { query },
5149
5247
  });
5150
5248
  const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
5151
- const itemsPage = (_10 = (_9 = (_8 = parsed === null || parsed === void 0 ? void 0 : parsed.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;
5249
+ const itemsPage = (_19 = (_18 = (_17 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _17 === void 0 ? void 0 : _17.boards) === null || _18 === void 0 ? void 0 : _18[0]) === null || _19 === void 0 ? void 0 : _19.items_page;
5152
5250
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5153
5251
  cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
5154
5252
  allItems = allItems.concat(items);
@@ -5227,7 +5325,7 @@ class Worktables {
5227
5325
  const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
5228
5326
  const logicalOperator = this.getNodeParameter('logicalOperator', 0);
5229
5327
  let rulesArray = [];
5230
- if (((_11 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _11 === void 0 ? void 0 : _11.length) > 0) {
5328
+ if (((_20 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _20 === void 0 ? void 0 : _20.length) > 0) {
5231
5329
  rulesArray = filterRules.rule.map((rule) => {
5232
5330
  let formattedValue;
5233
5331
  if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
@@ -5271,7 +5369,7 @@ class Worktables {
5271
5369
  });
5272
5370
  }
5273
5371
  const orderByArray = [];
5274
- if (((_12 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _12 === void 0 ? void 0 : _12.length) > 0) {
5372
+ if (((_21 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _21 === void 0 ? void 0 : _21.length) > 0) {
5275
5373
  sortOptions.sortBy.forEach((sort) => {
5276
5374
  orderByArray.push(`{
5277
5375
  column_id: "${sort.columnId}",
@@ -5327,7 +5425,7 @@ class Worktables {
5327
5425
  body: { query },
5328
5426
  });
5329
5427
  const parsed = JSON.parse(rawResponse);
5330
- const items = ((_16 = (_15 = (_14 = (_13 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _13 === void 0 ? void 0 : _13.boards) === null || _14 === void 0 ? void 0 : _14[0]) === null || _15 === void 0 ? void 0 : _15.items_page) === null || _16 === void 0 ? void 0 : _16.items) || [];
5428
+ const items = ((_25 = (_24 = (_23 = (_22 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _22 === void 0 ? void 0 : _22.boards) === null || _23 === void 0 ? void 0 : _23[0]) === null || _24 === void 0 ? void 0 : _24.items_page) === null || _25 === void 0 ? void 0 : _25.items) || [];
5331
5429
  const formattedItems = await Promise.all(items.map(async (item) => {
5332
5430
  const formatted = {
5333
5431
  id: item.id,
@@ -5361,7 +5459,7 @@ class Worktables {
5361
5459
  const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
5362
5460
  const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
5363
5461
  let rulesArray = [];
5364
- if (((_17 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _17 === void 0 ? void 0 : _17.length) > 0) {
5462
+ if (((_26 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _26 === void 0 ? void 0 : _26.length) > 0) {
5365
5463
  console.log('Processing filter rules:', advancedFilterRules.rule);
5366
5464
  rulesArray = advancedFilterRules.rule.map((rule) => {
5367
5465
  let formattedValue;
@@ -5577,7 +5675,7 @@ class Worktables {
5577
5675
  });
5578
5676
  }
5579
5677
  const orderByArray = [];
5580
- if (((_18 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _18 === void 0 ? void 0 : _18.length) > 0) {
5678
+ if (((_27 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _27 === void 0 ? void 0 : _27.length) > 0) {
5581
5679
  advancedSortOptions.sortBy.forEach((sort) => {
5582
5680
  orderByArray.push(`{
5583
5681
  column_id: "${sort.columnId}",
@@ -5659,7 +5757,7 @@ class Worktables {
5659
5757
  body: { query: testQuery },
5660
5758
  });
5661
5759
  const testParsed = JSON.parse(testResponse);
5662
- const testItems = ((_22 = (_21 = (_20 = (_19 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.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) === null || _22 === void 0 ? void 0 : _22.items) || [];
5760
+ const testItems = ((_31 = (_30 = (_29 = (_28 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.data) === null || _28 === void 0 ? void 0 : _28.boards) === null || _29 === void 0 ? void 0 : _29[0]) === null || _30 === void 0 ? void 0 : _30.items_page) === null || _31 === void 0 ? void 0 : _31.items) || [];
5663
5761
  console.log('Test - Items in board (no filters):', testItems.length);
5664
5762
  if (testItems.length > 0) {
5665
5763
  console.log('Sample item column values:', testItems[0].column_values);
@@ -5671,7 +5769,7 @@ class Worktables {
5671
5769
  body: { query },
5672
5770
  });
5673
5771
  const parsed = JSON.parse(rawResponse);
5674
- const itemsPage = (_25 = (_24 = (_23 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _23 === void 0 ? void 0 : _23.boards) === null || _24 === void 0 ? void 0 : _24[0]) === null || _25 === void 0 ? void 0 : _25.items_page;
5772
+ const itemsPage = (_34 = (_33 = (_32 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _32 === void 0 ? void 0 : _32.boards) === null || _33 === void 0 ? void 0 : _33[0]) === null || _34 === void 0 ? void 0 : _34.items_page;
5675
5773
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5676
5774
  const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
5677
5775
  const hasMore = nextCursor ? true : false;
@@ -5781,62 +5879,88 @@ class Worktables {
5781
5879
  case 'listGroupItems': {
5782
5880
  const boardId = this.getNodeParameter('boardId', 0);
5783
5881
  const groupId = this.getNodeParameter('groupId', 0);
5882
+ const limit = this.getNodeParameter('limit', 0);
5784
5883
  if (!boardId || !groupId) {
5785
5884
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5786
5885
  message: 'Board ID and Group ID are required.',
5787
5886
  });
5788
5887
  }
5789
- const query = `
5790
- query {
5791
- boards (ids: [${boardId}]) {
5792
- groups (ids: "${groupId}") {
5793
- items_page {
5794
- items {
5795
- id
5796
- name
5797
- url
5798
- board {
5799
- id
5800
- }
5801
- group {
5802
- id
5803
- title
5804
- color
5805
- position
5806
- }
5807
- column_values {
5808
- id
5809
- text
5810
- value
5811
- type
5812
- ... on BoardRelationValue {
5813
- display_value
5814
- linked_item_ids
5815
- }
5816
- ... on MirrorValue {
5817
- display_value
5818
- mirrored_items {
5819
- linked_board_id
5888
+ const queryColumnValues = `
5889
+ column_values {
5890
+ id
5891
+ text
5892
+ value
5893
+ type
5894
+ ... on BoardRelationValue {
5895
+ display_value
5896
+ linked_item_ids
5897
+ }
5898
+ ... on MirrorValue {
5899
+ display_value
5900
+ mirrored_items {
5901
+ linked_board_id
5902
+ }
5903
+ }
5904
+ }
5905
+ `;
5906
+ let allItems = [];
5907
+ let cursor = null;
5908
+ const pageLimit = 100;
5909
+ do {
5910
+ const cursorParam = cursor ? `, cursor: "${cursor}"` : '';
5911
+ let currentLimit;
5912
+ if (limit === 0) {
5913
+ currentLimit = pageLimit;
5914
+ }
5915
+ else {
5916
+ const remaining = limit - allItems.length;
5917
+ currentLimit = remaining > pageLimit ? pageLimit : remaining;
5918
+ }
5919
+ const query = `
5920
+ query {
5921
+ boards (ids: [${boardId}]) {
5922
+ groups (ids: "${groupId}") {
5923
+ items_page(limit: ${currentLimit}${cursorParam}) {
5924
+ cursor
5925
+ items {
5926
+ id
5927
+ name
5928
+ url
5929
+ board {
5930
+ id
5820
5931
  }
5932
+ group {
5933
+ id
5934
+ title
5935
+ color
5936
+ position
5937
+ }
5938
+ created_at
5939
+ updated_at
5940
+ ${queryColumnValues}
5821
5941
  }
5822
5942
  }
5823
- created_at
5824
- updated_at
5825
5943
  }
5826
5944
  }
5827
5945
  }
5828
- }
5829
- }
5830
- `;
5831
- const rawResponse = await this.helpers.request({
5832
- method: 'POST',
5833
- url: 'https://api.monday.com/v2',
5834
- headers,
5835
- body: { query },
5836
- });
5837
- const parsed = JSON.parse(rawResponse);
5838
- const items = ((_31 = (_30 = (_29 = (_28 = (_27 = (_26 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _26 === void 0 ? void 0 : _26.boards) === null || _27 === void 0 ? void 0 : _27[0]) === null || _28 === void 0 ? void 0 : _28.groups) === null || _29 === void 0 ? void 0 : _29[0]) === null || _30 === void 0 ? void 0 : _30.items_page) === null || _31 === void 0 ? void 0 : _31.items) || [];
5839
- const formattedItems = await Promise.all(items.map(async (item) => {
5946
+ `;
5947
+ const rawResponse = await this.helpers.request({
5948
+ method: 'POST',
5949
+ url: 'https://api.monday.com/v2',
5950
+ headers,
5951
+ body: { query },
5952
+ });
5953
+ const parsed = JSON.parse(rawResponse);
5954
+ const itemsPage = (_39 = (_38 = (_37 = (_36 = (_35 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _35 === void 0 ? void 0 : _35.boards) === null || _36 === void 0 ? void 0 : _36[0]) === null || _37 === void 0 ? void 0 : _37.groups) === null || _38 === void 0 ? void 0 : _38[0]) === null || _39 === void 0 ? void 0 : _39.items_page;
5955
+ const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5956
+ cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
5957
+ allItems = allItems.concat(items);
5958
+ if (limit > 0 && allItems.length >= limit) {
5959
+ allItems = allItems.slice(0, limit);
5960
+ break;
5961
+ }
5962
+ } while (cursor && (limit === 0 || allItems.length < limit));
5963
+ const formattedItems = await Promise.all(allItems.map(async (item) => {
5840
5964
  const columnValues = item.column_values || [];
5841
5965
  const formatted = {
5842
5966
  id: item.id,
@@ -5924,7 +6048,7 @@ class Worktables {
5924
6048
  response = await (0, isErrorResponse_1.parseApiResponse)(response);
5925
6049
  if (response.success) {
5926
6050
  const parsed = JSON.parse(response.data);
5927
- const updates = ((_34 = (_33 = (_32 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _32 === void 0 ? void 0 : _32.items) === null || _33 === void 0 ? void 0 : _33[0]) === null || _34 === void 0 ? void 0 : _34.updates) || [];
6051
+ const updates = ((_42 = (_41 = (_40 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _40 === void 0 ? void 0 : _40.items) === null || _41 === void 0 ? void 0 : _41[0]) === null || _42 === void 0 ? void 0 : _42.updates) || [];
5928
6052
  const formattedUpdates = updates.map((update) => {
5929
6053
  const pinnedToTop = update.pinned_to_top || [];
5930
6054
  const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
@@ -5989,7 +6113,7 @@ class Worktables {
5989
6113
  console.log('variables:', variables);
5990
6114
  response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
5991
6115
  console.log('Create Update Result:', JSON.stringify(response, null, 2));
5992
- const updateId = (_36 = (_35 = JSON.parse(response).data) === null || _35 === void 0 ? void 0 : _35.create_update) === null || _36 === void 0 ? void 0 : _36.id;
6116
+ const updateId = (_44 = (_43 = JSON.parse(response).data) === null || _43 === void 0 ? void 0 : _43.create_update) === null || _44 === void 0 ? void 0 : _44.id;
5993
6117
  if (!updateId) {
5994
6118
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5995
6119
  message: 'Error creating update: Update not created, no ID returned',
@@ -6298,7 +6422,7 @@ class Worktables {
6298
6422
  body: { query },
6299
6423
  json: true,
6300
6424
  });
6301
- const asset = (_38 = (_37 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _37 === void 0 ? void 0 : _37.assets) === null || _38 === void 0 ? void 0 : _38[0];
6425
+ const asset = (_46 = (_45 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _45 === void 0 ? void 0 : _45.assets) === null || _46 === void 0 ? void 0 : _46[0];
6302
6426
  if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
6303
6427
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
6304
6428
  message: 'Public URL not found for the given file ID.',