@worktables/n8n-nodes-worktables 12.2.13 → 12.2.15

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.
@@ -962,6 +962,20 @@ class Worktables {
962
962
  show: { operation: ['getGroup', 'listGroupItems'] },
963
963
  },
964
964
  },
965
+ {
966
+ displayName: 'Limit',
967
+ name: 'limit',
968
+ type: 'number',
969
+ typeOptions: {
970
+ minValue: 0,
971
+ },
972
+ default: 50,
973
+ description: 'Max number of results to return',
974
+ hint: 'If 0 is provided, all items will be returned',
975
+ displayOptions: {
976
+ show: { operation: ['listGroupItems'] },
977
+ },
978
+ },
965
979
  {
966
980
  displayName: 'Position Relative',
967
981
  name: 'positionRelative',
@@ -1092,57 +1106,42 @@ class Worktables {
1092
1106
  },
1093
1107
  },
1094
1108
  {
1095
- displayName: 'Additional Options',
1096
- name: 'additionalOptions',
1097
- type: 'fixedCollection',
1098
- typeOptions: {
1099
- multipleValues: true,
1109
+ displayName: 'Is Subitem',
1110
+ name: 'isSubitem',
1111
+ type: 'boolean',
1112
+ default: false,
1113
+ description: 'Whether a subitem',
1114
+ displayOptions: {
1115
+ show: {
1116
+ operation: ['getItem'],
1117
+ },
1100
1118
  },
1101
- default: [],
1119
+ },
1120
+ {
1121
+ displayName: 'Fetch Subitems',
1122
+ name: 'fetchSubitems',
1123
+ type: 'boolean',
1124
+ default: false,
1125
+ description: 'Whether to fetch subitems',
1102
1126
  displayOptions: {
1103
1127
  show: {
1104
1128
  operation: ['getItem'],
1129
+ isSubitem: [false],
1105
1130
  },
1106
1131
  },
1107
- options: [
1108
- {
1109
- displayName: 'Options',
1110
- name: 'options',
1111
- values: [
1112
- {
1113
- displayName: 'Is Subitem',
1114
- name: 'isSubitem',
1115
- type: 'boolean',
1116
- default: false,
1117
- description: 'Whether a subitem',
1118
- },
1119
- {
1120
- displayName: 'Fetch Subitems',
1121
- name: 'fetchSubitems',
1122
- type: 'boolean',
1123
- default: false,
1124
- description: 'Whether to fetch subitems',
1125
- displayOptions: {
1126
- show: {
1127
- isSubitem: [false],
1128
- },
1129
- },
1130
- },
1131
- {
1132
- displayName: 'Fetch Parent Item',
1133
- name: 'fetchParentItems',
1134
- type: 'boolean',
1135
- default: false,
1136
- description: 'Whether to fetch parent item',
1137
- displayOptions: {
1138
- show: {
1139
- isSubitem: [true],
1140
- },
1141
- },
1142
- },
1143
- ],
1132
+ },
1133
+ {
1134
+ displayName: 'Fetch Parent Item',
1135
+ name: 'fetchParentItems',
1136
+ type: 'boolean',
1137
+ default: false,
1138
+ description: 'Whether to fetch parent item',
1139
+ displayOptions: {
1140
+ show: {
1141
+ operation: ['getItem'],
1142
+ isSubitem: [true],
1144
1143
  },
1145
- ],
1144
+ },
1146
1145
  },
1147
1146
  {
1148
1147
  displayName: 'With Updates',
@@ -2778,7 +2777,7 @@ class Worktables {
2778
2777
  };
2779
2778
  }
2780
2779
  async execute() {
2781
- 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;
2780
+ 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;
2782
2781
  const resource = this.getNodeParameter('resource', 0);
2783
2782
  const operation = this.getNodeParameter('operation', 0);
2784
2783
  const credentials = await this.getCredentials('WorktablesApi');
@@ -3389,15 +3388,13 @@ class Worktables {
3389
3388
  }
3390
3389
  case 'getItem': {
3391
3390
  const itemId = this.getNodeParameter('itemId', 0);
3391
+ const isSubitem = this.getNodeParameter('isSubitem', 0);
3392
3392
  const fetchAllColumns = this.getNodeParameter('fetchAllColumns', 0);
3393
3393
  const columnIds = fetchAllColumns
3394
3394
  ? ''
3395
3395
  : this.getNodeParameter('columnIds', 0, false) || '';
3396
- const additionalOptionsArray = this.getNodeParameter('additionalOptions', 0, []);
3397
- const options = additionalOptionsArray.length > 0 ? additionalOptionsArray[0].options || {} : {};
3398
- const isSubitem = options.isSubitem || false;
3399
- const fetchSubitems = !isSubitem && (options.fetchSubitems || false);
3400
- const fetchParentItem = isSubitem && (options.fetchParentItems || false);
3396
+ const fetchSubitems = !isSubitem && this.getNodeParameter('fetchSubitems', 0);
3397
+ const fetchParentItem = isSubitem && this.getNodeParameter('fetchParentItems', 0);
3401
3398
  let queryColumnValues = '';
3402
3399
  if (fetchAllColumns) {
3403
3400
  queryColumnValues = `
@@ -5123,62 +5120,84 @@ class Worktables {
5123
5120
  case 'listGroupItems': {
5124
5121
  const boardId = this.getNodeParameter('boardId', 0);
5125
5122
  const groupId = this.getNodeParameter('groupId', 0);
5123
+ const limit = this.getNodeParameter('limit', 0);
5126
5124
  if (!boardId || !groupId) {
5127
5125
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5128
5126
  message: 'Board ID and Group ID are required.',
5129
5127
  });
5130
5128
  }
5131
- const query = `
5132
- query {
5133
- boards (ids: [${boardId}]) {
5134
- groups (ids: "${groupId}") {
5135
- items_page {
5136
- items {
5137
- id
5138
- name
5139
- url
5140
- board {
5141
- id
5142
- }
5143
- group {
5144
- id
5145
- title
5146
- color
5147
- position
5148
- }
5149
- column_values {
5129
+ const allItems = [];
5130
+ let cursor = null;
5131
+ const queryLimit = limit === 0 ? 100 : limit;
5132
+ let hasMore = true;
5133
+ let totalFetched = 0;
5134
+ while (hasMore) {
5135
+ const cursorParam = cursor ? `, cursor: "${cursor}"` : '';
5136
+ const currentLimit = limit === 0 ? 100 : Math.min(queryLimit - totalFetched, 100);
5137
+ const query = `
5138
+ query {
5139
+ boards (ids: [${boardId}]) {
5140
+ groups (ids: "${groupId}") {
5141
+ items_page(limit: ${currentLimit}${cursorParam}) {
5142
+ items {
5150
5143
  id
5151
- text
5152
- value
5153
- type
5154
- ... on BoardRelationValue {
5155
- display_value
5156
- linked_item_ids
5144
+ name
5145
+ url
5146
+ board {
5147
+ id
5148
+ }
5149
+ group {
5150
+ id
5151
+ title
5152
+ color
5153
+ position
5157
5154
  }
5158
- ... on MirrorValue {
5159
- display_value
5160
- mirrored_items {
5161
- linked_board_id
5155
+ column_values {
5156
+ id
5157
+ text
5158
+ value
5159
+ type
5160
+ ... on BoardRelationValue {
5161
+ display_value
5162
+ linked_item_ids
5163
+ }
5164
+ ... on MirrorValue {
5165
+ display_value
5166
+ mirrored_items {
5167
+ linked_board_id
5168
+ }
5162
5169
  }
5163
5170
  }
5171
+ created_at
5172
+ updated_at
5164
5173
  }
5165
- created_at
5166
- updated_at
5174
+ cursor
5167
5175
  }
5168
5176
  }
5169
5177
  }
5170
5178
  }
5171
- }
5172
- `;
5173
- const rawResponse = await this.helpers.request({
5174
- method: 'POST',
5175
- url: 'https://api.monday.com/v2',
5176
- headers,
5177
- body: { query },
5178
- });
5179
- const parsed = JSON.parse(rawResponse);
5180
- const items = ((_20 = (_19 = (_18 = (_17 = (_16 = (_15 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _15 === void 0 ? void 0 : _15.boards) === null || _16 === void 0 ? void 0 : _16[0]) === null || _17 === void 0 ? void 0 : _17.groups) === null || _18 === void 0 ? void 0 : _18[0]) === null || _19 === void 0 ? void 0 : _19.items_page) === null || _20 === void 0 ? void 0 : _20.items) || [];
5181
- const formattedItems = await Promise.all(items.map(async (item) => {
5179
+ `;
5180
+ const rawResponse = await this.helpers.request({
5181
+ method: 'POST',
5182
+ url: 'https://api.monday.com/v2',
5183
+ headers,
5184
+ body: { query },
5185
+ });
5186
+ const parsed = JSON.parse(rawResponse);
5187
+ const itemsPage = (_19 = (_18 = (_17 = (_16 = (_15 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _15 === void 0 ? void 0 : _15.boards) === null || _16 === void 0 ? void 0 : _16[0]) === null || _17 === void 0 ? void 0 : _17.groups) === null || _18 === void 0 ? void 0 : _18[0]) === null || _19 === void 0 ? void 0 : _19.items_page;
5188
+ const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5189
+ cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
5190
+ allItems.push(...items);
5191
+ totalFetched += items.length;
5192
+ if (limit === 0) {
5193
+ hasMore = cursor !== null && items.length > 0;
5194
+ }
5195
+ else {
5196
+ hasMore = totalFetched < limit && cursor !== null && items.length > 0;
5197
+ }
5198
+ }
5199
+ const itemsToFormat = limit === 0 ? allItems : allItems.slice(0, limit);
5200
+ const formattedItems = await Promise.all(itemsToFormat.map(async (item) => {
5182
5201
  const columnValues = item.column_values || [];
5183
5202
  const formatted = {
5184
5203
  id: item.id,
@@ -5261,7 +5280,7 @@ class Worktables {
5261
5280
  response = await (0, isErrorResponse_1.parseApiResponse)(response);
5262
5281
  if (response.success) {
5263
5282
  const parsed = JSON.parse(response.data);
5264
- const updates = ((_23 = (_22 = (_21 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _21 === void 0 ? void 0 : _21.items) === null || _22 === void 0 ? void 0 : _22[0]) === null || _23 === void 0 ? void 0 : _23.updates) || [];
5283
+ const updates = ((_22 = (_21 = (_20 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _20 === void 0 ? void 0 : _20.items) === null || _21 === void 0 ? void 0 : _21[0]) === null || _22 === void 0 ? void 0 : _22.updates) || [];
5265
5284
  return [updates.map((update) => ({ json: update }))];
5266
5285
  }
5267
5286
  else {
@@ -5318,7 +5337,7 @@ class Worktables {
5318
5337
  console.log('variables:', variables);
5319
5338
  response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
5320
5339
  console.log('Create Update Result:', JSON.stringify(response, null, 2));
5321
- const updateId = (_25 = (_24 = JSON.parse(response).data) === null || _24 === void 0 ? void 0 : _24.create_update) === null || _25 === void 0 ? void 0 : _25.id;
5340
+ const updateId = (_24 = (_23 = JSON.parse(response).data) === null || _23 === void 0 ? void 0 : _23.create_update) === null || _24 === void 0 ? void 0 : _24.id;
5322
5341
  if (!updateId) {
5323
5342
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5324
5343
  message: 'Error creating update: Update not created, no ID returned',
@@ -5624,7 +5643,7 @@ class Worktables {
5624
5643
  body: { query },
5625
5644
  json: true,
5626
5645
  });
5627
- const asset = (_27 = (_26 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _26 === void 0 ? void 0 : _26.assets) === null || _27 === void 0 ? void 0 : _27[0];
5646
+ const asset = (_26 = (_25 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _25 === void 0 ? void 0 : _25.assets) === null || _26 === void 0 ? void 0 : _26[0];
5628
5647
  if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
5629
5648
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5630
5649
  message: 'Public URL not found for the given file ID.',