@worktables/n8n-nodes-worktables 12.2.29 → 12.2.30

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.
@@ -1013,7 +1013,7 @@ class Worktables {
1013
1013
  name: 'identifierColumn',
1014
1014
  type: 'options',
1015
1015
  typeOptions: {
1016
- loadOptionsDependsOn: ['boardId'],
1016
+ loadOptionsDependsOn: ['boardId', 'isSubitem'],
1017
1017
  loadOptionsMethod: 'getColumnsItemsForIdentifier',
1018
1018
  },
1019
1019
  default: '',
@@ -2608,28 +2608,71 @@ class Worktables {
2608
2608
  });
2609
2609
  },
2610
2610
  async getColumnsItemsForIdentifier() {
2611
+ var _a, _b, _c, _d, _e;
2611
2612
  const boardId = this.getCurrentNodeParameter('boardId');
2613
+ const isSubitem = this.getCurrentNodeParameter('isSubitem') || false;
2612
2614
  const credentials = await this.getCredentials('WorktablesApi');
2613
2615
  const apiKey = credentials === null || credentials === void 0 ? void 0 : credentials.apiKey;
2614
- const response = await this.helpers.request({
2615
- method: 'POST',
2616
- url: 'https://api.monday.com/v2',
2617
- headers: {
2618
- Authorization: `Bearer ${apiKey}`,
2619
- 'Content-Type': 'application/json',
2620
- },
2621
- body: JSON.stringify({
2622
- query: `query {
2623
- boards(ids: ${boardId}) {
2624
- columns {
2625
- id
2626
- title
2627
- type
2616
+ if (isSubitem) {
2617
+ let parentId = null;
2618
+ try {
2619
+ parentId = this.getCurrentNodeParameter('parentId');
2620
+ }
2621
+ catch (e) {
2622
+ }
2623
+ let subitemBoardColumns = [];
2624
+ if (parentId) {
2625
+ const response = await this.helpers.request({
2626
+ method: 'POST',
2627
+ url: 'https://api.monday.com/v2',
2628
+ headers: {
2629
+ Authorization: `Bearer ${apiKey}`,
2630
+ 'Content-Type': 'application/json',
2631
+ 'API-Version': '2025-01',
2632
+ },
2633
+ body: JSON.stringify({
2634
+ query: `query {
2635
+ items(ids: [${parentId}]) {
2636
+ subitems {
2637
+ board {
2638
+ id
2639
+ columns {
2640
+ id
2641
+ title
2642
+ type
2643
+ }
2644
+ }
2628
2645
  }
2629
- items_page {
2646
+ }
2647
+ }`,
2648
+ }),
2649
+ });
2650
+ const parsedResponse = JSON.parse(response);
2651
+ const items = ((_a = parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.data) === null || _a === void 0 ? void 0 : _a.items) || [];
2652
+ if (items.length > 0 && items[0].subitems && items[0].subitems.length > 0) {
2653
+ const subitem = items[0].subitems[0];
2654
+ if (subitem.board && subitem.board.columns) {
2655
+ subitemBoardColumns = subitem.board.columns;
2656
+ }
2657
+ }
2658
+ }
2659
+ if (subitemBoardColumns.length === 0) {
2660
+ const response = await this.helpers.request({
2661
+ method: 'POST',
2662
+ url: 'https://api.monday.com/v2',
2663
+ headers: {
2664
+ Authorization: `Bearer ${apiKey}`,
2665
+ 'Content-Type': 'application/json',
2666
+ 'API-Version': '2025-01',
2667
+ },
2668
+ body: JSON.stringify({
2669
+ query: `query {
2670
+ boards(ids: ${boardId}) {
2671
+ items_page(limit: 25) {
2630
2672
  items {
2631
2673
  subitems {
2632
2674
  board {
2675
+ id
2633
2676
  columns {
2634
2677
  id
2635
2678
  title
@@ -2641,27 +2684,84 @@ class Worktables {
2641
2684
  }
2642
2685
  }
2643
2686
  }`,
2644
- }),
2645
- });
2646
- const parsedResponse = JSON.parse(response);
2647
- return parsedResponse.data.boards[0].columns
2648
- .filter((column) => column.type !== 'subitem' &&
2649
- column.type !== 'auto_number' &&
2650
- column.type !== 'creation_log' &&
2651
- column.type !== 'formula' &&
2652
- column.type !== 'item_id' &&
2653
- column.type !== 'last_updated' &&
2654
- column.type !== 'progress' &&
2655
- column.type !== 'mirror' &&
2656
- column.type !== 'subtasks' &&
2657
- column.type !== 'file' &&
2658
- column.type !== 'button')
2659
- .map((column) => {
2660
- return {
2661
- name: column.title,
2662
- value: column.id,
2663
- };
2664
- });
2687
+ }),
2688
+ });
2689
+ const parsedResponse = JSON.parse(response);
2690
+ const items = ((_e = (_d = (_c = (_b = parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.data) === null || _b === void 0 ? void 0 : _b.boards) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.items_page) === null || _e === void 0 ? void 0 : _e.items) || [];
2691
+ for (const item of items) {
2692
+ if (item.subitems && item.subitems.length > 0) {
2693
+ const subitem = item.subitems[0];
2694
+ if (subitem.board && subitem.board.columns) {
2695
+ subitemBoardColumns = subitem.board.columns;
2696
+ break;
2697
+ }
2698
+ }
2699
+ }
2700
+ }
2701
+ if (subitemBoardColumns.length === 0) {
2702
+ console.log('No subitems found in board, cannot load subitem columns for identifier');
2703
+ return [];
2704
+ }
2705
+ return subitemBoardColumns
2706
+ .filter((column) => column.type !== 'subitem' &&
2707
+ column.type !== 'auto_number' &&
2708
+ column.type !== 'creation_log' &&
2709
+ column.type !== 'formula' &&
2710
+ column.type !== 'item_id' &&
2711
+ column.type !== 'last_updated' &&
2712
+ column.type !== 'progress' &&
2713
+ column.type !== 'mirror' &&
2714
+ column.type !== 'subtasks' &&
2715
+ column.type !== 'file' &&
2716
+ column.type !== 'button')
2717
+ .map((column) => {
2718
+ return {
2719
+ name: column.title,
2720
+ value: column.id,
2721
+ };
2722
+ });
2723
+ }
2724
+ else {
2725
+ const response = await this.helpers.request({
2726
+ method: 'POST',
2727
+ url: 'https://api.monday.com/v2',
2728
+ headers: {
2729
+ Authorization: `Bearer ${apiKey}`,
2730
+ 'Content-Type': 'application/json',
2731
+ 'API-Version': '2025-01',
2732
+ },
2733
+ body: JSON.stringify({
2734
+ query: `query {
2735
+ boards(ids: ${boardId}) {
2736
+ columns {
2737
+ id
2738
+ title
2739
+ type
2740
+ }
2741
+ }
2742
+ }`,
2743
+ }),
2744
+ });
2745
+ const parsedResponse = JSON.parse(response);
2746
+ return parsedResponse.data.boards[0].columns
2747
+ .filter((column) => column.type !== 'subitem' &&
2748
+ column.type !== 'auto_number' &&
2749
+ column.type !== 'creation_log' &&
2750
+ column.type !== 'formula' &&
2751
+ column.type !== 'item_id' &&
2752
+ column.type !== 'last_updated' &&
2753
+ column.type !== 'progress' &&
2754
+ column.type !== 'mirror' &&
2755
+ column.type !== 'subtasks' &&
2756
+ column.type !== 'file' &&
2757
+ column.type !== 'button')
2758
+ .map((column) => {
2759
+ return {
2760
+ name: column.title,
2761
+ value: column.id,
2762
+ };
2763
+ });
2764
+ }
2665
2765
  },
2666
2766
  async getColumnsItemsForCreateOrUpdate() {
2667
2767
  var _a, _b, _c, _d, _e;