@worktables/n8n-nodes-worktables 12.2.26 → 12.2.28

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.
@@ -20,6 +20,8 @@ export declare class Worktables implements INodeType {
20
20
  getSubscribersFromBoard(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
21
21
  getSubitems(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
22
22
  getColumnsItems(this: ILoadOptionsFunctions): Promise<any>;
23
+ getColumnsItemsForIdentifier(this: ILoadOptionsFunctions): Promise<any>;
24
+ getColumnsItemsForCreateOrUpdate(this: ILoadOptionsFunctions): Promise<any>;
23
25
  getFolders(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
24
26
  getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
25
27
  getTeams(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
@@ -1014,7 +1014,7 @@ class Worktables {
1014
1014
  type: 'options',
1015
1015
  typeOptions: {
1016
1016
  loadOptionsDependsOn: ['boardId'],
1017
- loadOptionsMethod: 'getColumnsItems',
1017
+ loadOptionsMethod: 'getColumnsItemsForIdentifier',
1018
1018
  },
1019
1019
  default: '',
1020
1020
  description: 'Select the column to use as identifier for finding/updating items. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
@@ -1257,8 +1257,8 @@ class Worktables {
1257
1257
  name: 'columnId',
1258
1258
  type: 'options',
1259
1259
  typeOptions: {
1260
- loadOptionsDependsOn: ['boardId'],
1261
- loadOptionsMethod: 'getColumnsItems',
1260
+ loadOptionsDependsOn: ['boardId', 'isSubitem'],
1261
+ loadOptionsMethod: 'getColumnsItemsForCreateOrUpdate',
1262
1262
  },
1263
1263
  default: '',
1264
1264
  },
@@ -2607,6 +2607,218 @@ class Worktables {
2607
2607
  };
2608
2608
  });
2609
2609
  },
2610
+ async getColumnsItemsForIdentifier() {
2611
+ const boardId = this.getCurrentNodeParameter('boardId');
2612
+ const credentials = await this.getCredentials('WorktablesApi');
2613
+ 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
2628
+ }
2629
+ items_page {
2630
+ items {
2631
+ subitems {
2632
+ board {
2633
+ columns {
2634
+ id
2635
+ title
2636
+ type
2637
+ }
2638
+ }
2639
+ }
2640
+ }
2641
+ }
2642
+ }
2643
+ }`,
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
+ });
2665
+ },
2666
+ async getColumnsItemsForCreateOrUpdate() {
2667
+ var _a, _b, _c, _d, _e;
2668
+ const boardId = this.getCurrentNodeParameter('boardId');
2669
+ const isSubitem = this.getCurrentNodeParameter('isSubitem') || false;
2670
+ const credentials = await this.getCredentials('WorktablesApi');
2671
+ const apiKey = credentials === null || credentials === void 0 ? void 0 : credentials.apiKey;
2672
+ if (isSubitem) {
2673
+ let parentId = null;
2674
+ try {
2675
+ parentId = this.getCurrentNodeParameter('parentId');
2676
+ }
2677
+ catch (e) {
2678
+ }
2679
+ let subitemBoardColumns = [];
2680
+ if (parentId) {
2681
+ const response = await this.helpers.request({
2682
+ method: 'POST',
2683
+ url: 'https://api.monday.com/v2',
2684
+ headers: {
2685
+ Authorization: `Bearer ${apiKey}`,
2686
+ 'Content-Type': 'application/json',
2687
+ 'API-Version': '2025-01',
2688
+ },
2689
+ body: JSON.stringify({
2690
+ query: `query {
2691
+ items(ids: [${parentId}]) {
2692
+ subitems {
2693
+ board {
2694
+ id
2695
+ columns {
2696
+ id
2697
+ title
2698
+ type
2699
+ }
2700
+ }
2701
+ }
2702
+ }
2703
+ }`,
2704
+ }),
2705
+ });
2706
+ const parsedResponse = JSON.parse(response);
2707
+ const items = ((_a = parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.data) === null || _a === void 0 ? void 0 : _a.items) || [];
2708
+ if (items.length > 0 && items[0].subitems && items[0].subitems.length > 0) {
2709
+ const subitem = items[0].subitems[0];
2710
+ if (subitem.board && subitem.board.columns) {
2711
+ subitemBoardColumns = subitem.board.columns;
2712
+ }
2713
+ }
2714
+ }
2715
+ if (subitemBoardColumns.length === 0) {
2716
+ const response = await this.helpers.request({
2717
+ method: 'POST',
2718
+ url: 'https://api.monday.com/v2',
2719
+ headers: {
2720
+ Authorization: `Bearer ${apiKey}`,
2721
+ 'Content-Type': 'application/json',
2722
+ 'API-Version': '2025-01',
2723
+ },
2724
+ body: JSON.stringify({
2725
+ query: `query {
2726
+ boards(ids: ${boardId}) {
2727
+ items_page(limit: 25) {
2728
+ items {
2729
+ subitems {
2730
+ board {
2731
+ id
2732
+ columns {
2733
+ id
2734
+ title
2735
+ type
2736
+ }
2737
+ }
2738
+ }
2739
+ }
2740
+ }
2741
+ }
2742
+ }`,
2743
+ }),
2744
+ });
2745
+ const parsedResponse = JSON.parse(response);
2746
+ 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) || [];
2747
+ for (const item of items) {
2748
+ if (item.subitems && item.subitems.length > 0) {
2749
+ const subitem = item.subitems[0];
2750
+ if (subitem.board && subitem.board.columns) {
2751
+ subitemBoardColumns = subitem.board.columns;
2752
+ break;
2753
+ }
2754
+ }
2755
+ }
2756
+ }
2757
+ if (subitemBoardColumns.length === 0) {
2758
+ console.log('No subitems found in board, cannot load subitem columns');
2759
+ return [];
2760
+ }
2761
+ return subitemBoardColumns
2762
+ .filter((column) => column.type !== 'subitem' &&
2763
+ column.type !== 'auto_number' &&
2764
+ column.type !== 'creation_log' &&
2765
+ column.type !== 'formula' &&
2766
+ column.type !== 'item_id' &&
2767
+ column.type !== 'last_updated' &&
2768
+ column.type !== 'progress' &&
2769
+ column.type !== 'mirror' &&
2770
+ column.type !== 'subtasks' &&
2771
+ column.type !== 'file' &&
2772
+ column.type !== 'button')
2773
+ .map((column) => {
2774
+ return {
2775
+ name: column.title,
2776
+ value: column.id,
2777
+ };
2778
+ });
2779
+ }
2780
+ else {
2781
+ const response = await this.helpers.request({
2782
+ method: 'POST',
2783
+ url: 'https://api.monday.com/v2',
2784
+ headers: {
2785
+ Authorization: `Bearer ${apiKey}`,
2786
+ 'Content-Type': 'application/json',
2787
+ 'API-Version': '2025-01',
2788
+ },
2789
+ body: JSON.stringify({
2790
+ query: `query {
2791
+ boards(ids: ${boardId}) {
2792
+ columns {
2793
+ id
2794
+ title
2795
+ type
2796
+ }
2797
+ }
2798
+ }`,
2799
+ }),
2800
+ });
2801
+ const parsedResponse = JSON.parse(response);
2802
+ return parsedResponse.data.boards[0].columns
2803
+ .filter((column) => column.type !== 'subitem' &&
2804
+ column.type !== 'auto_number' &&
2805
+ column.type !== 'creation_log' &&
2806
+ column.type !== 'formula' &&
2807
+ column.type !== 'item_id' &&
2808
+ column.type !== 'last_updated' &&
2809
+ column.type !== 'progress' &&
2810
+ column.type !== 'mirror' &&
2811
+ column.type !== 'subtasks' &&
2812
+ column.type !== 'file' &&
2813
+ column.type !== 'button')
2814
+ .map((column) => {
2815
+ return {
2816
+ name: column.title,
2817
+ value: column.id,
2818
+ };
2819
+ });
2820
+ }
2821
+ },
2610
2822
  async getFolders() {
2611
2823
  const workspaceId = this.getNodeParameter('workspace');
2612
2824
  const credentials = await this.getCredentials('WorktablesApi');
@@ -4353,6 +4565,9 @@ class Worktables {
4353
4565
  ... on BoardRelationValue {
4354
4566
  display_value
4355
4567
  }
4568
+ ... on MirrorValue {
4569
+ display_value
4570
+ }
4356
4571
  }
4357
4572
  }
4358
4573
  }
@@ -4370,6 +4585,13 @@ class Worktables {
4370
4585
  id
4371
4586
  text
4372
4587
  value
4588
+ type
4589
+ ... on BoardRelationValue {
4590
+ display_value
4591
+ }
4592
+ ... on MirrorValue {
4593
+ display_value
4594
+ }
4373
4595
  }
4374
4596
  }
4375
4597
  cursor
@@ -4444,6 +4666,7 @@ class Worktables {
4444
4666
  const compareValue = isBoardRelation
4445
4667
  ? (colValue.display_value || '').trim()
4446
4668
  : (colValue.text || '').trim();
4669
+ console.log(`🔍 Item ${item.id} - Column ${identifierColumn} (${colValue.type}): raw colValue=`, JSON.stringify(colValue));
4447
4670
  const searchValue = identifierValue.trim().toLowerCase();
4448
4671
  const compareValueLower = compareValue.toLowerCase();
4449
4672
  matches = compareValueLower === searchValue;
@@ -4453,6 +4676,9 @@ class Worktables {
4453
4676
  else if (compareValue) {
4454
4677
  console.log(`✗ No match - Item ${item.id} - Column ${identifierColumn} (${colValue.type}): ${isBoardRelation ? 'display_value' : 'text'}="${compareValue}", search="${identifierValue}"`);
4455
4678
  }
4679
+ else {
4680
+ console.log(`⚠ Item ${item.id} - Column ${identifierColumn} (${colValue.type}): compareValue is empty, display_value="${colValue.display_value}", text="${colValue.text}"`);
4681
+ }
4456
4682
  }
4457
4683
  else {
4458
4684
  console.log(`⚠ Item ${item.id} - Column ${identifierColumn} not found in column_values`);
@@ -4532,6 +4758,11 @@ class Worktables {
4532
4758
  if (!itemUpdated) {
4533
4759
  console.log(`Creating new ${isSubitem ? 'subitem' : 'item'}:`, itemName);
4534
4760
  const parentId = this.getNodeParameter('parentId', 0, false);
4761
+ if (isSubitem && !parentId) {
4762
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), {
4763
+ message: 'Parent Item is required when creating a subitem. Please select a parent item.',
4764
+ });
4765
+ }
4535
4766
  const escapedItemName = (0, worktablesHelpers_1.escapeGraphQLString)(itemName);
4536
4767
  const escapedColumnValues = (0, worktablesHelpers_1.escapeGraphQLJSONString)(column_values_object);
4537
4768
  if (isSubitem && parentId) {