@worktables/n8n-nodes-worktables 12.2.28 → 12.2.29

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.
@@ -3026,7 +3026,7 @@ class Worktables {
3026
3026
  };
3027
3027
  }
3028
3028
  async execute() {
3029
- 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;
3029
+ 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;
3030
3030
  const resource = this.getNodeParameter('resource', 0);
3031
3031
  const operation = this.getNodeParameter('operation', 0);
3032
3032
  const credentials = await this.getCredentials('WorktablesApi');
@@ -4543,12 +4543,36 @@ class Worktables {
4543
4543
  let foundItemId = null;
4544
4544
  if (identifierValue && identifierValue.trim() !== '' && identifierColumn && identifierColumn.trim() !== '') {
4545
4545
  console.log('Searching for item/subitem with identifier column:', identifierColumn, 'value:', identifierValue, 'isSubitem:', isSubitem);
4546
+ const parentId = this.getNodeParameter('parentId', 0, false);
4546
4547
  let cursor = null;
4547
4548
  let hasMore = true;
4548
4549
  while (hasMore && !foundItemId) {
4549
4550
  const cursorParam = cursor ? `, cursor: "${cursor}"` : '';
4550
- const searchQuery = isSubitem
4551
+ const searchQuery = isSubitem && parentId
4551
4552
  ? `query {
4553
+ items(ids: [${parentId}]) {
4554
+ id
4555
+ name
4556
+ subitems {
4557
+ id
4558
+ name
4559
+ column_values(ids: ["${identifierColumn}"]) {
4560
+ id
4561
+ text
4562
+ value
4563
+ type
4564
+ ... on BoardRelationValue {
4565
+ display_value
4566
+ }
4567
+ ... on MirrorValue {
4568
+ display_value
4569
+ }
4570
+ }
4571
+ }
4572
+ }
4573
+ }`
4574
+ : isSubitem
4575
+ ? `query {
4552
4576
  boards(ids: [${boardId}]) {
4553
4577
  items_page(limit: 100${cursorParam}) {
4554
4578
  items {
@@ -4575,7 +4599,7 @@ class Worktables {
4575
4599
  }
4576
4600
  }
4577
4601
  }`
4578
- : `query {
4602
+ : `query {
4579
4603
  boards(ids: [${boardId}]) {
4580
4604
  items_page(limit: 100${cursorParam}) {
4581
4605
  items {
@@ -4605,9 +4629,24 @@ class Worktables {
4605
4629
  body: { query: searchQuery },
4606
4630
  });
4607
4631
  const searchData = JSON.parse(searchResponse);
4608
- const itemsPage = (_z = (_y = (_x = searchData === null || searchData === void 0 ? void 0 : searchData.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;
4609
- const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
4610
- cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
4632
+ let items = [];
4633
+ let nextCursor = null;
4634
+ if (isSubitem && parentId) {
4635
+ items = ((_x = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _x === void 0 ? void 0 : _x.items) || [];
4636
+ hasMore = false;
4637
+ console.log(`🔍 Searching subitems of parent ${parentId}, found ${items.length} parent item(s)`);
4638
+ if (items.length > 0 && items[0].subitems) {
4639
+ console.log(`🔍 Parent item has ${items[0].subitems.length} subitem(s)`);
4640
+ }
4641
+ }
4642
+ else {
4643
+ 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;
4644
+ items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
4645
+ nextCursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
4646
+ hasMore = nextCursor !== null && items.length > 0 && !foundItemId;
4647
+ console.log(`🔍 Searching in board, found ${items.length} item(s)`);
4648
+ }
4649
+ cursor = nextCursor;
4611
4650
  const isNameColumn = identifierColumn === 'name' || identifierColumn.toLowerCase() === 'name';
4612
4651
  if (isSubitem) {
4613
4652
  for (const item of items) {
@@ -4620,7 +4659,7 @@ class Worktables {
4620
4659
  matches = subitemName === searchValue;
4621
4660
  }
4622
4661
  else {
4623
- const colValue = (_0 = subitem.column_values) === null || _0 === void 0 ? void 0 : _0.find((cv) => cv.id === identifierColumn);
4662
+ const colValue = (_1 = subitem.column_values) === null || _1 === void 0 ? void 0 : _1.find((cv) => cv.id === identifierColumn);
4624
4663
  if (colValue) {
4625
4664
  const isBoardRelation = colValue.type === 'board_relation';
4626
4665
  const compareValue = isBoardRelation
@@ -4660,7 +4699,7 @@ class Worktables {
4660
4699
  matches = itemName === searchValue;
4661
4700
  }
4662
4701
  else {
4663
- const colValue = (_1 = item.column_values) === null || _1 === void 0 ? void 0 : _1.find((cv) => cv.id === identifierColumn);
4702
+ const colValue = (_2 = item.column_values) === null || _2 === void 0 ? void 0 : _2.find((cv) => cv.id === identifierColumn);
4664
4703
  if (colValue) {
4665
4704
  const isBoardRelation = colValue.type === 'board_relation';
4666
4705
  const compareValue = isBoardRelation
@@ -4725,7 +4764,7 @@ class Worktables {
4725
4764
  id: itemData.id,
4726
4765
  url: itemData.url || '',
4727
4766
  operation: 'update',
4728
- board_id: ((_2 = itemData.board) === null || _2 === void 0 ? void 0 : _2.id) || boardId,
4767
+ board_id: ((_3 = itemData.board) === null || _3 === void 0 ? void 0 : _3.id) || boardId,
4729
4768
  column_values: column_values_object,
4730
4769
  };
4731
4770
  itemUpdated = true;
@@ -4747,7 +4786,10 @@ class Worktables {
4747
4786
  }
4748
4787
  }
4749
4788
  else {
4750
- console.log(`${isSubitem ? 'Subitem' : 'Item'} not found with identifier value "${identifierValue}", will create new ${isSubitem ? 'subitem' : 'item'}`);
4789
+ console.log(`❌ ${isSubitem ? 'Subitem' : 'Item'} not found with identifier column "${identifierColumn}" and value "${identifierValue}", will create new ${isSubitem ? 'subitem' : 'item'}`);
4790
+ if (isSubitem && parentId) {
4791
+ console.log(` Parent ID: ${parentId}`);
4792
+ }
4751
4793
  itemUpdated = false;
4752
4794
  }
4753
4795
  }
@@ -4813,8 +4855,8 @@ class Worktables {
4813
4855
  });
4814
4856
  }
4815
4857
  const itemData = isSubitem && parentId
4816
- ? (_3 = responseData.data) === null || _3 === void 0 ? void 0 : _3.create_subitem
4817
- : (_4 = responseData.data) === null || _4 === void 0 ? void 0 : _4.create_item;
4858
+ ? (_4 = responseData.data) === null || _4 === void 0 ? void 0 : _4.create_subitem
4859
+ : (_5 = responseData.data) === null || _5 === void 0 ? void 0 : _5.create_item;
4818
4860
  if (!itemData || !itemData.id) {
4819
4861
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
4820
4862
  message: `Error creating ${isSubitem ? 'subitem' : 'item'}: No item data returned`,
@@ -4825,7 +4867,7 @@ class Worktables {
4825
4867
  name: itemData.name || itemName,
4826
4868
  url: itemData.url || '',
4827
4869
  operation: 'create',
4828
- board_id: ((_5 = itemData.board) === null || _5 === void 0 ? void 0 : _5.id) || boardId,
4870
+ board_id: ((_6 = itemData.board) === null || _6 === void 0 ? void 0 : _6.id) || boardId,
4829
4871
  column_values: column_values_object,
4830
4872
  };
4831
4873
  if (isSubitem && parentId) {
@@ -4964,7 +5006,7 @@ class Worktables {
4964
5006
  body: { query },
4965
5007
  });
4966
5008
  const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
4967
- const itemsPage = (_8 = (_7 = (_6 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _6 === void 0 ? void 0 : _6.boards) === null || _7 === void 0 ? void 0 : _7[0]) === null || _8 === void 0 ? void 0 : _8.items_page;
5009
+ 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;
4968
5010
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
4969
5011
  cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
4970
5012
  allItems = allItems.concat(items);
@@ -5043,7 +5085,7 @@ class Worktables {
5043
5085
  const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
5044
5086
  const logicalOperator = this.getNodeParameter('logicalOperator', 0);
5045
5087
  let rulesArray = [];
5046
- if (((_9 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _9 === void 0 ? void 0 : _9.length) > 0) {
5088
+ if (((_10 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _10 === void 0 ? void 0 : _10.length) > 0) {
5047
5089
  rulesArray = filterRules.rule.map((rule) => {
5048
5090
  let formattedValue;
5049
5091
  if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
@@ -5087,7 +5129,7 @@ class Worktables {
5087
5129
  });
5088
5130
  }
5089
5131
  const orderByArray = [];
5090
- if (((_10 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _10 === void 0 ? void 0 : _10.length) > 0) {
5132
+ if (((_11 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _11 === void 0 ? void 0 : _11.length) > 0) {
5091
5133
  sortOptions.sortBy.forEach((sort) => {
5092
5134
  orderByArray.push(`{
5093
5135
  column_id: "${sort.columnId}",
@@ -5143,7 +5185,7 @@ class Worktables {
5143
5185
  body: { query },
5144
5186
  });
5145
5187
  const parsed = JSON.parse(rawResponse);
5146
- const items = ((_14 = (_13 = (_12 = (_11 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _11 === void 0 ? void 0 : _11.boards) === null || _12 === void 0 ? void 0 : _12[0]) === null || _13 === void 0 ? void 0 : _13.items_page) === null || _14 === void 0 ? void 0 : _14.items) || [];
5188
+ 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) || [];
5147
5189
  const formattedItems = await Promise.all(items.map(async (item) => {
5148
5190
  const formatted = {
5149
5191
  id: item.id,
@@ -5177,7 +5219,7 @@ class Worktables {
5177
5219
  const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
5178
5220
  const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
5179
5221
  let rulesArray = [];
5180
- if (((_15 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _15 === void 0 ? void 0 : _15.length) > 0) {
5222
+ if (((_16 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _16 === void 0 ? void 0 : _16.length) > 0) {
5181
5223
  console.log('Processing filter rules:', advancedFilterRules.rule);
5182
5224
  rulesArray = advancedFilterRules.rule.map((rule) => {
5183
5225
  let formattedValue;
@@ -5393,7 +5435,7 @@ class Worktables {
5393
5435
  });
5394
5436
  }
5395
5437
  const orderByArray = [];
5396
- if (((_16 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _16 === void 0 ? void 0 : _16.length) > 0) {
5438
+ if (((_17 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _17 === void 0 ? void 0 : _17.length) > 0) {
5397
5439
  advancedSortOptions.sortBy.forEach((sort) => {
5398
5440
  orderByArray.push(`{
5399
5441
  column_id: "${sort.columnId}",
@@ -5475,7 +5517,7 @@ class Worktables {
5475
5517
  body: { query: testQuery },
5476
5518
  });
5477
5519
  const testParsed = JSON.parse(testResponse);
5478
- const testItems = ((_20 = (_19 = (_18 = (_17 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.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) === null || _20 === void 0 ? void 0 : _20.items) || [];
5520
+ 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) || [];
5479
5521
  console.log('Test - Items in board (no filters):', testItems.length);
5480
5522
  if (testItems.length > 0) {
5481
5523
  console.log('Sample item column values:', testItems[0].column_values);
@@ -5487,7 +5529,7 @@ class Worktables {
5487
5529
  body: { query },
5488
5530
  });
5489
5531
  const parsed = JSON.parse(rawResponse);
5490
- const itemsPage = (_23 = (_22 = (_21 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _21 === void 0 ? void 0 : _21.boards) === null || _22 === void 0 ? void 0 : _22[0]) === null || _23 === void 0 ? void 0 : _23.items_page;
5532
+ 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;
5491
5533
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5492
5534
  const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
5493
5535
  const hasMore = nextCursor ? true : false;
@@ -5651,7 +5693,7 @@ class Worktables {
5651
5693
  body: { query },
5652
5694
  });
5653
5695
  const parsed = JSON.parse(rawResponse);
5654
- const items = ((_29 = (_28 = (_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.groups) === null || _27 === void 0 ? void 0 : _27[0]) === null || _28 === void 0 ? void 0 : _28.items_page) === null || _29 === void 0 ? void 0 : _29.items) || [];
5696
+ 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) || [];
5655
5697
  const formattedItems = await Promise.all(items.map(async (item) => {
5656
5698
  const columnValues = item.column_values || [];
5657
5699
  const formatted = {
@@ -5740,7 +5782,7 @@ class Worktables {
5740
5782
  response = await (0, isErrorResponse_1.parseApiResponse)(response);
5741
5783
  if (response.success) {
5742
5784
  const parsed = JSON.parse(response.data);
5743
- const updates = ((_32 = (_31 = (_30 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _30 === void 0 ? void 0 : _30.items) === null || _31 === void 0 ? void 0 : _31[0]) === null || _32 === void 0 ? void 0 : _32.updates) || [];
5785
+ 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) || [];
5744
5786
  const formattedUpdates = updates.map((update) => {
5745
5787
  const pinnedToTop = update.pinned_to_top || [];
5746
5788
  const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
@@ -5805,7 +5847,7 @@ class Worktables {
5805
5847
  console.log('variables:', variables);
5806
5848
  response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
5807
5849
  console.log('Create Update Result:', JSON.stringify(response, null, 2));
5808
- const updateId = (_34 = (_33 = JSON.parse(response).data) === null || _33 === void 0 ? void 0 : _33.create_update) === null || _34 === void 0 ? void 0 : _34.id;
5850
+ 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;
5809
5851
  if (!updateId) {
5810
5852
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5811
5853
  message: 'Error creating update: Update not created, no ID returned',
@@ -6114,7 +6156,7 @@ class Worktables {
6114
6156
  body: { query },
6115
6157
  json: true,
6116
6158
  });
6117
- const asset = (_36 = (_35 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _35 === void 0 ? void 0 : _35.assets) === null || _36 === void 0 ? void 0 : _36[0];
6159
+ 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];
6118
6160
  if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
6119
6161
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
6120
6162
  message: 'Public URL not found for the given file ID.',