@worktables/n8n-nodes-worktables 12.2.30 → 12.2.31

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.
@@ -3126,7 +3126,7 @@ class Worktables {
3126
3126
  };
3127
3127
  }
3128
3128
  async execute() {
3129
- 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;
3129
+ 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;
3130
3130
  const resource = this.getNodeParameter('resource', 0);
3131
3131
  const operation = this.getNodeParameter('operation', 0);
3132
3132
  const credentials = await this.getCredentials('WorktablesApi');
@@ -4641,6 +4641,7 @@ class Worktables {
4641
4641
  let formatted;
4642
4642
  let itemUpdated = false;
4643
4643
  let foundItemId = null;
4644
+ let foundItemBoardId = null;
4644
4645
  if (identifierValue && identifierValue.trim() !== '' && identifierColumn && identifierColumn.trim() !== '') {
4645
4646
  console.log('Searching for item/subitem with identifier column:', identifierColumn, 'value:', identifierValue, 'isSubitem:', isSubitem);
4646
4647
  const parentId = this.getNodeParameter('parentId', 0, false);
@@ -4656,6 +4657,9 @@ class Worktables {
4656
4657
  subitems {
4657
4658
  id
4658
4659
  name
4660
+ board {
4661
+ id
4662
+ }
4659
4663
  column_values(ids: ["${identifierColumn}"]) {
4660
4664
  id
4661
4665
  text
@@ -4681,6 +4685,9 @@ class Worktables {
4681
4685
  subitems {
4682
4686
  id
4683
4687
  name
4688
+ board {
4689
+ id
4690
+ }
4684
4691
  column_values(ids: ["${identifierColumn}"]) {
4685
4692
  id
4686
4693
  text
@@ -4781,7 +4788,8 @@ class Worktables {
4781
4788
  }
4782
4789
  if (matches) {
4783
4790
  foundItemId = subitem.id;
4784
- console.log(`Found subitem with ID: ${foundItemId}`);
4791
+ foundItemBoardId = ((_2 = subitem.board) === null || _2 === void 0 ? void 0 : _2.id) || null;
4792
+ console.log(`Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
4785
4793
  break;
4786
4794
  }
4787
4795
  }
@@ -4799,7 +4807,7 @@ class Worktables {
4799
4807
  matches = itemName === searchValue;
4800
4808
  }
4801
4809
  else {
4802
- const colValue = (_2 = item.column_values) === null || _2 === void 0 ? void 0 : _2.find((cv) => cv.id === identifierColumn);
4810
+ const colValue = (_3 = item.column_values) === null || _3 === void 0 ? void 0 : _3.find((cv) => cv.id === identifierColumn);
4803
4811
  if (colValue) {
4804
4812
  const isBoardRelation = colValue.type === 'board_relation';
4805
4813
  const compareValue = isBoardRelation
@@ -4835,10 +4843,14 @@ class Worktables {
4835
4843
  if (foundItemId) {
4836
4844
  console.log(`Found existing ${isSubitem ? 'subitem' : 'item'}, updating:`, foundItemId);
4837
4845
  const escapedColumnValues = (0, worktablesHelpers_1.escapeGraphQLJSONString)(column_values_object);
4846
+ const updateBoardId = (isSubitem && foundItemBoardId) ? foundItemBoardId : boardId;
4847
+ if (isSubitem && !foundItemBoardId) {
4848
+ console.log(`⚠ Warning: Subitem board_id not found, using main board_id ${boardId}. This may cause errors.`);
4849
+ }
4838
4850
  mutation = `mutation {
4839
4851
  change_multiple_column_values(
4840
4852
  create_labels_if_missing: true,
4841
- board_id: ${boardId},
4853
+ board_id: ${updateBoardId},
4842
4854
  item_id: "${foundItemId}",
4843
4855
  column_values: "${escapedColumnValues}"
4844
4856
  ) {
@@ -4864,7 +4876,7 @@ class Worktables {
4864
4876
  id: itemData.id,
4865
4877
  url: itemData.url || '',
4866
4878
  operation: 'update',
4867
- board_id: ((_3 = itemData.board) === null || _3 === void 0 ? void 0 : _3.id) || boardId,
4879
+ board_id: ((_4 = itemData.board) === null || _4 === void 0 ? void 0 : _4.id) || boardId,
4868
4880
  column_values: column_values_object,
4869
4881
  };
4870
4882
  itemUpdated = true;
@@ -4955,8 +4967,8 @@ class Worktables {
4955
4967
  });
4956
4968
  }
4957
4969
  const itemData = isSubitem && parentId
4958
- ? (_4 = responseData.data) === null || _4 === void 0 ? void 0 : _4.create_subitem
4959
- : (_5 = responseData.data) === null || _5 === void 0 ? void 0 : _5.create_item;
4970
+ ? (_5 = responseData.data) === null || _5 === void 0 ? void 0 : _5.create_subitem
4971
+ : (_6 = responseData.data) === null || _6 === void 0 ? void 0 : _6.create_item;
4960
4972
  if (!itemData || !itemData.id) {
4961
4973
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
4962
4974
  message: `Error creating ${isSubitem ? 'subitem' : 'item'}: No item data returned`,
@@ -4967,7 +4979,7 @@ class Worktables {
4967
4979
  name: itemData.name || itemName,
4968
4980
  url: itemData.url || '',
4969
4981
  operation: 'create',
4970
- board_id: ((_6 = itemData.board) === null || _6 === void 0 ? void 0 : _6.id) || boardId,
4982
+ board_id: ((_7 = itemData.board) === null || _7 === void 0 ? void 0 : _7.id) || boardId,
4971
4983
  column_values: column_values_object,
4972
4984
  };
4973
4985
  if (isSubitem && parentId) {
@@ -5106,7 +5118,7 @@ class Worktables {
5106
5118
  body: { query },
5107
5119
  });
5108
5120
  const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
5109
- const itemsPage = (_9 = (_8 = (_7 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _7 === void 0 ? void 0 : _7.boards) === null || _8 === void 0 ? void 0 : _8[0]) === null || _9 === void 0 ? void 0 : _9.items_page;
5121
+ 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;
5110
5122
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5111
5123
  cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
5112
5124
  allItems = allItems.concat(items);
@@ -5185,7 +5197,7 @@ class Worktables {
5185
5197
  const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
5186
5198
  const logicalOperator = this.getNodeParameter('logicalOperator', 0);
5187
5199
  let rulesArray = [];
5188
- if (((_10 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _10 === void 0 ? void 0 : _10.length) > 0) {
5200
+ if (((_11 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _11 === void 0 ? void 0 : _11.length) > 0) {
5189
5201
  rulesArray = filterRules.rule.map((rule) => {
5190
5202
  let formattedValue;
5191
5203
  if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
@@ -5229,7 +5241,7 @@ class Worktables {
5229
5241
  });
5230
5242
  }
5231
5243
  const orderByArray = [];
5232
- if (((_11 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _11 === void 0 ? void 0 : _11.length) > 0) {
5244
+ if (((_12 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _12 === void 0 ? void 0 : _12.length) > 0) {
5233
5245
  sortOptions.sortBy.forEach((sort) => {
5234
5246
  orderByArray.push(`{
5235
5247
  column_id: "${sort.columnId}",
@@ -5285,7 +5297,7 @@ class Worktables {
5285
5297
  body: { query },
5286
5298
  });
5287
5299
  const parsed = JSON.parse(rawResponse);
5288
- const items = ((_15 = (_14 = (_13 = (_12 = parsed === null || parsed === void 0 ? void 0 : parsed.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) === null || _15 === void 0 ? void 0 : _15.items) || [];
5300
+ 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) || [];
5289
5301
  const formattedItems = await Promise.all(items.map(async (item) => {
5290
5302
  const formatted = {
5291
5303
  id: item.id,
@@ -5319,7 +5331,7 @@ class Worktables {
5319
5331
  const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
5320
5332
  const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
5321
5333
  let rulesArray = [];
5322
- if (((_16 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _16 === void 0 ? void 0 : _16.length) > 0) {
5334
+ if (((_17 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _17 === void 0 ? void 0 : _17.length) > 0) {
5323
5335
  console.log('Processing filter rules:', advancedFilterRules.rule);
5324
5336
  rulesArray = advancedFilterRules.rule.map((rule) => {
5325
5337
  let formattedValue;
@@ -5535,7 +5547,7 @@ class Worktables {
5535
5547
  });
5536
5548
  }
5537
5549
  const orderByArray = [];
5538
- if (((_17 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _17 === void 0 ? void 0 : _17.length) > 0) {
5550
+ if (((_18 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _18 === void 0 ? void 0 : _18.length) > 0) {
5539
5551
  advancedSortOptions.sortBy.forEach((sort) => {
5540
5552
  orderByArray.push(`{
5541
5553
  column_id: "${sort.columnId}",
@@ -5617,7 +5629,7 @@ class Worktables {
5617
5629
  body: { query: testQuery },
5618
5630
  });
5619
5631
  const testParsed = JSON.parse(testResponse);
5620
- const testItems = ((_21 = (_20 = (_19 = (_18 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.data) === null || _18 === void 0 ? void 0 : _18.boards) === null || _19 === void 0 ? void 0 : _19[0]) === null || _20 === void 0 ? void 0 : _20.items_page) === null || _21 === void 0 ? void 0 : _21.items) || [];
5632
+ 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) || [];
5621
5633
  console.log('Test - Items in board (no filters):', testItems.length);
5622
5634
  if (testItems.length > 0) {
5623
5635
  console.log('Sample item column values:', testItems[0].column_values);
@@ -5629,7 +5641,7 @@ class Worktables {
5629
5641
  body: { query },
5630
5642
  });
5631
5643
  const parsed = JSON.parse(rawResponse);
5632
- const itemsPage = (_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;
5644
+ 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;
5633
5645
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5634
5646
  const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
5635
5647
  const hasMore = nextCursor ? true : false;
@@ -5793,7 +5805,7 @@ class Worktables {
5793
5805
  body: { query },
5794
5806
  });
5795
5807
  const parsed = JSON.parse(rawResponse);
5796
- const items = ((_30 = (_29 = (_28 = (_27 = (_26 = (_25 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _25 === void 0 ? void 0 : _25.boards) === null || _26 === void 0 ? void 0 : _26[0]) === null || _27 === void 0 ? void 0 : _27.groups) === null || _28 === void 0 ? void 0 : _28[0]) === null || _29 === void 0 ? void 0 : _29.items_page) === null || _30 === void 0 ? void 0 : _30.items) || [];
5808
+ 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) || [];
5797
5809
  const formattedItems = await Promise.all(items.map(async (item) => {
5798
5810
  const columnValues = item.column_values || [];
5799
5811
  const formatted = {
@@ -5882,7 +5894,7 @@ class Worktables {
5882
5894
  response = await (0, isErrorResponse_1.parseApiResponse)(response);
5883
5895
  if (response.success) {
5884
5896
  const parsed = JSON.parse(response.data);
5885
- 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) || [];
5897
+ 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) || [];
5886
5898
  const formattedUpdates = updates.map((update) => {
5887
5899
  const pinnedToTop = update.pinned_to_top || [];
5888
5900
  const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
@@ -5947,7 +5959,7 @@ class Worktables {
5947
5959
  console.log('variables:', variables);
5948
5960
  response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
5949
5961
  console.log('Create Update Result:', JSON.stringify(response, null, 2));
5950
- 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;
5962
+ 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;
5951
5963
  if (!updateId) {
5952
5964
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5953
5965
  message: 'Error creating update: Update not created, no ID returned',
@@ -6256,7 +6268,7 @@ class Worktables {
6256
6268
  body: { query },
6257
6269
  json: true,
6258
6270
  });
6259
- 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];
6271
+ 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];
6260
6272
  if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
6261
6273
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
6262
6274
  message: 'Public URL not found for the given file ID.',