@worktables/n8n-nodes-worktables 12.4.0 → 12.5.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.
@@ -979,6 +979,22 @@ class Worktables {
979
979
  show: { operation: ['getGroup', 'listGroupItems'] },
980
980
  },
981
981
  },
982
+ {
983
+ displayName: 'Limit',
984
+ name: 'limit',
985
+ type: 'number',
986
+ typeOptions: {
987
+ minValue: 0,
988
+ },
989
+ default: 50,
990
+ description: 'Max number of results to return',
991
+ hint: 'If 0 is provided, all items will be returned. This may take longer for large groups.',
992
+ displayOptions: {
993
+ show: {
994
+ operation: ['listGroupItems'],
995
+ },
996
+ },
997
+ },
982
998
  {
983
999
  displayName: 'Position Relative',
984
1000
  name: 'positionRelative',
@@ -3156,7 +3172,7 @@ class Worktables {
3156
3172
  };
3157
3173
  }
3158
3174
  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;
3175
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37;
3160
3176
  const resource = this.getNodeParameter('resource', 0);
3161
3177
  const operation = this.getNodeParameter('operation', 0);
3162
3178
  const credentials = await this.getCredentials('WorktablesApi');
@@ -5781,62 +5797,88 @@ class Worktables {
5781
5797
  case 'listGroupItems': {
5782
5798
  const boardId = this.getNodeParameter('boardId', 0);
5783
5799
  const groupId = this.getNodeParameter('groupId', 0);
5800
+ const limit = this.getNodeParameter('limit', 0);
5784
5801
  if (!boardId || !groupId) {
5785
5802
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5786
5803
  message: 'Board ID and Group ID are required.',
5787
5804
  });
5788
5805
  }
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
5806
+ const queryColumnValues = `
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
5820
+ }
5821
+ }
5822
+ }
5823
+ `;
5824
+ let allItems = [];
5825
+ let cursor = null;
5826
+ const pageLimit = 100;
5827
+ do {
5828
+ const cursorParam = cursor ? `, cursor: "${cursor}"` : '';
5829
+ let currentLimit;
5830
+ if (limit === 0) {
5831
+ currentLimit = pageLimit;
5832
+ }
5833
+ else {
5834
+ const remaining = limit - allItems.length;
5835
+ currentLimit = remaining > pageLimit ? pageLimit : remaining;
5836
+ }
5837
+ const query = `
5838
+ query {
5839
+ boards (ids: [${boardId}]) {
5840
+ groups (ids: "${groupId}") {
5841
+ items_page(limit: ${currentLimit}${cursorParam}) {
5842
+ cursor
5843
+ items {
5844
+ id
5845
+ name
5846
+ url
5847
+ board {
5848
+ id
5820
5849
  }
5850
+ group {
5851
+ id
5852
+ title
5853
+ color
5854
+ position
5855
+ }
5856
+ created_at
5857
+ updated_at
5858
+ ${queryColumnValues}
5821
5859
  }
5822
5860
  }
5823
- created_at
5824
- updated_at
5825
5861
  }
5826
5862
  }
5827
5863
  }
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) => {
5864
+ `;
5865
+ const rawResponse = await this.helpers.request({
5866
+ method: 'POST',
5867
+ url: 'https://api.monday.com/v2',
5868
+ headers,
5869
+ body: { query },
5870
+ });
5871
+ const parsed = JSON.parse(rawResponse);
5872
+ const itemsPage = (_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;
5873
+ const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5874
+ cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
5875
+ allItems = allItems.concat(items);
5876
+ if (limit > 0 && allItems.length >= limit) {
5877
+ allItems = allItems.slice(0, limit);
5878
+ break;
5879
+ }
5880
+ } while (cursor && (limit === 0 || allItems.length < limit));
5881
+ const formattedItems = await Promise.all(allItems.map(async (item) => {
5840
5882
  const columnValues = item.column_values || [];
5841
5883
  const formatted = {
5842
5884
  id: item.id,
@@ -5924,7 +5966,7 @@ class Worktables {
5924
5966
  response = await (0, isErrorResponse_1.parseApiResponse)(response);
5925
5967
  if (response.success) {
5926
5968
  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) || [];
5969
+ const updates = ((_33 = (_32 = (_31 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _31 === void 0 ? void 0 : _31.items) === null || _32 === void 0 ? void 0 : _32[0]) === null || _33 === void 0 ? void 0 : _33.updates) || [];
5928
5970
  const formattedUpdates = updates.map((update) => {
5929
5971
  const pinnedToTop = update.pinned_to_top || [];
5930
5972
  const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
@@ -5989,7 +6031,7 @@ class Worktables {
5989
6031
  console.log('variables:', variables);
5990
6032
  response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
5991
6033
  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;
6034
+ const updateId = (_35 = (_34 = JSON.parse(response).data) === null || _34 === void 0 ? void 0 : _34.create_update) === null || _35 === void 0 ? void 0 : _35.id;
5993
6035
  if (!updateId) {
5994
6036
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5995
6037
  message: 'Error creating update: Update not created, no ID returned',
@@ -6298,7 +6340,7 @@ class Worktables {
6298
6340
  body: { query },
6299
6341
  json: true,
6300
6342
  });
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];
6343
+ const asset = (_37 = (_36 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _36 === void 0 ? void 0 : _36.assets) === null || _37 === void 0 ? void 0 : _37[0];
6302
6344
  if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
6303
6345
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
6304
6346
  message: 'Public URL not found for the given file ID.',