@worktables/n8n-nodes-worktables 12.2.4 → 12.2.6

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.
@@ -419,6 +419,14 @@ class Worktables {
419
419
  description: 'Enter the query to run',
420
420
  displayOptions: { show: { resource: ['query'] } },
421
421
  },
422
+ {
423
+ displayName: 'API Version',
424
+ name: 'apiVersion',
425
+ type: 'string',
426
+ default: '2025-01',
427
+ description: 'Monday.com API version (e.g., 2025-01, 2024-10)',
428
+ displayOptions: { show: { resource: ['query'] } },
429
+ },
422
430
  {
423
431
  displayName: 'Operation',
424
432
  name: 'operation',
@@ -2128,11 +2136,11 @@ class Worktables {
2128
2136
  name: 'limit',
2129
2137
  type: 'number',
2130
2138
  typeOptions: {
2131
- minValue: 1,
2139
+ minValue: 0,
2132
2140
  },
2133
2141
  default: 50,
2134
2142
  description: 'Max number of results to return',
2135
- hint: 'If 0 is provided, all items will be returned',
2143
+ hint: 'If 0 is provided, all items will be returned. This may take longer for large boards.',
2136
2144
  displayOptions: {
2137
2145
  show: {
2138
2146
  operation: ['listBoardItems'],
@@ -2755,7 +2763,7 @@ class Worktables {
2755
2763
  };
2756
2764
  }
2757
2765
  async execute() {
2758
- 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;
2766
+ 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;
2759
2767
  const resource = this.getNodeParameter('resource', 0);
2760
2768
  const operation = this.getNodeParameter('operation', 0);
2761
2769
  const credentials = await this.getCredentials('WorktablesApi');
@@ -3595,7 +3603,7 @@ class Worktables {
3595
3603
  column_values_object[columnId] = { files: links };
3596
3604
  }
3597
3605
  else if (typeof value === 'string') {
3598
- column_values_object[columnId] = value.replace(/\n/g, '\\n');
3606
+ column_values_object[columnId] = value;
3599
3607
  }
3600
3608
  else {
3601
3609
  column_values_object[columnId] = value;
@@ -3851,7 +3859,7 @@ class Worktables {
3851
3859
  column_values_object[columnId] = { files: links };
3852
3860
  }
3853
3861
  else if (typeof value === 'string') {
3854
- column_values_object[columnId] = value.replace(/\n/g, '\\n');
3862
+ column_values_object[columnId] = value;
3855
3863
  }
3856
3864
  else {
3857
3865
  column_values_object[columnId] = value;
@@ -4169,7 +4177,7 @@ class Worktables {
4169
4177
  column_values_object[columnId] = { files: links };
4170
4178
  }
4171
4179
  else if (typeof value === 'string') {
4172
- column_values_object[columnId] = value.replace(/\n/g, '\\n');
4180
+ column_values_object[columnId] = value;
4173
4181
  }
4174
4182
  else {
4175
4183
  column_values_object[columnId] = value;
@@ -4415,51 +4423,150 @@ class Worktables {
4415
4423
  if (!boardId) {
4416
4424
  throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Board ID is required.' });
4417
4425
  }
4418
- const query = `
4426
+ const queryColumnValues = `
4427
+ column_values {
4428
+ id
4429
+ text
4430
+ value
4431
+ type
4432
+ ... on BoardRelationValue {
4433
+ display_value
4434
+ linked_item_ids
4435
+ }
4436
+ ... on MirrorValue {
4437
+ display_value
4438
+ mirrored_items {
4439
+ linked_board_id
4440
+ }
4441
+ }
4442
+ }
4443
+ `;
4444
+ const querySubitems = `
4445
+ subitems {
4446
+ id
4447
+ name
4448
+ url
4449
+ board {
4450
+ id
4451
+ }
4452
+ created_at
4453
+ updated_at
4454
+ ${queryColumnValues}
4455
+ }
4456
+ `;
4457
+ let allItems = [];
4458
+ let cursor = null;
4459
+ const pageLimit = 100;
4460
+ do {
4461
+ const cursorParam = cursor ? `, cursor: "${cursor}"` : '';
4462
+ let currentLimit;
4463
+ if (limit === 0) {
4464
+ currentLimit = pageLimit;
4465
+ }
4466
+ else {
4467
+ const remaining = limit - allItems.length;
4468
+ currentLimit = remaining > pageLimit ? pageLimit : remaining;
4469
+ }
4470
+ const query = `
4419
4471
  query {
4420
- boards (ids: ${boardId}) {
4421
- items_page(limit: ${limit}) {
4472
+ boards (ids: [${boardId}]) {
4473
+ items_page(limit: ${currentLimit}${cursorParam}) {
4474
+ cursor
4422
4475
  items {
4423
- id
4424
- updates {
4425
- id
4426
- body
4427
- }
4428
- assets {
4429
4476
  id
4430
4477
  name
4431
- public_url
4432
4478
  url
4433
- }
4434
- column_values {
4435
- id
4436
- text
4437
- value
4479
+ board {
4480
+ id
4438
4481
  }
4439
4482
  group {
4440
- id
4441
- title
4442
- }
4443
- subitems {
4444
- id
4445
- column_values {
4446
4483
  id
4447
- text
4448
- value
4449
- }
4484
+ title
4485
+ color
4486
+ position
4450
4487
  }
4451
- url
4488
+ created_at
4489
+ updated_at
4490
+ ${queryColumnValues}
4491
+ ${querySubitems}
4452
4492
  }
4453
4493
  }
4454
4494
  }
4455
- }`;
4456
- response = await this.helpers.request({
4457
- method: 'POST',
4458
- url: 'https://api.monday.com/v2',
4459
- headers,
4460
- body: { query },
4461
- });
4462
- break;
4495
+ }
4496
+ `;
4497
+ const rawResponse = await this.helpers.request({
4498
+ method: 'POST',
4499
+ url: 'https://api.monday.com/v2',
4500
+ headers,
4501
+ body: { query },
4502
+ });
4503
+ const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
4504
+ const itemsPage = (_z = (_y = (_x = parsed === null || parsed === void 0 ? void 0 : parsed.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;
4505
+ const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
4506
+ cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
4507
+ allItems = allItems.concat(items);
4508
+ if (limit > 0 && allItems.length >= limit) {
4509
+ if (allItems.length > limit) {
4510
+ allItems = allItems.slice(0, limit);
4511
+ }
4512
+ break;
4513
+ }
4514
+ if (!cursor) {
4515
+ break;
4516
+ }
4517
+ } while (true);
4518
+ const formattedItems = await Promise.all(allItems.map(async (item) => {
4519
+ const columnValues = item.column_values || [];
4520
+ const formatted = {
4521
+ id: item.id,
4522
+ name: item.name,
4523
+ url: item.url,
4524
+ created_at: item.created_at,
4525
+ updated_at: item.updated_at,
4526
+ board: item.board ? {
4527
+ id: item.board.id,
4528
+ } : undefined,
4529
+ group: item.group ? {
4530
+ id: item.group.id,
4531
+ title: item.group.title,
4532
+ color: item.group.color,
4533
+ position: item.group.position,
4534
+ } : undefined,
4535
+ column_values: {},
4536
+ };
4537
+ for (const col of columnValues) {
4538
+ if (col.type === 'subtasks')
4539
+ continue;
4540
+ const formattedCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
4541
+ if (formattedCol) {
4542
+ formatted.column_values[col.id] = formattedCol;
4543
+ }
4544
+ }
4545
+ if (item.subitems && Array.isArray(item.subitems)) {
4546
+ formatted.subitems = await Promise.all(item.subitems.map(async (subitem) => {
4547
+ const subFormatted = {
4548
+ id: subitem.id,
4549
+ name: subitem.name,
4550
+ url: subitem.url,
4551
+ created_at: subitem.created_at,
4552
+ updated_at: subitem.updated_at,
4553
+ board: subitem.board ? {
4554
+ id: subitem.board.id,
4555
+ } : undefined,
4556
+ column_values: {},
4557
+ };
4558
+ for (const col of subitem.column_values || []) {
4559
+ const subCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
4560
+ if (subCol) {
4561
+ subFormatted.column_values[col.id] = subCol;
4562
+ }
4563
+ }
4564
+ return subFormatted;
4565
+ }));
4566
+ }
4567
+ return formatted;
4568
+ }));
4569
+ return [formattedItems.map((item) => ({ json: item }))];
4463
4570
  }
4464
4571
  case 'searchItems': {
4465
4572
  const boardId = this.getNodeParameter('boardId', 0);
@@ -4468,7 +4575,7 @@ class Worktables {
4468
4575
  const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
4469
4576
  const logicalOperator = this.getNodeParameter('logicalOperator', 0);
4470
4577
  let rulesArray = [];
4471
- if (((_x = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _x === void 0 ? void 0 : _x.length) > 0) {
4578
+ if (((_0 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _0 === void 0 ? void 0 : _0.length) > 0) {
4472
4579
  rulesArray = filterRules.rule.map((rule) => {
4473
4580
  let formattedValue;
4474
4581
  if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
@@ -4512,7 +4619,7 @@ class Worktables {
4512
4619
  });
4513
4620
  }
4514
4621
  const orderByArray = [];
4515
- if (((_y = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _y === void 0 ? void 0 : _y.length) > 0) {
4622
+ if (((_1 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _1 === void 0 ? void 0 : _1.length) > 0) {
4516
4623
  sortOptions.sortBy.forEach((sort) => {
4517
4624
  orderByArray.push(`{
4518
4625
  column_id: "${sort.columnId}",
@@ -4558,7 +4665,7 @@ class Worktables {
4558
4665
  body: { query },
4559
4666
  });
4560
4667
  const parsed = JSON.parse(rawResponse);
4561
- const items = ((_2 = (_1 = (_0 = (_z = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _z === void 0 ? void 0 : _z.boards) === null || _0 === void 0 ? void 0 : _0[0]) === null || _1 === void 0 ? void 0 : _1.items_page) === null || _2 === void 0 ? void 0 : _2.items) || [];
4668
+ const items = ((_5 = (_4 = (_3 = (_2 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _2 === void 0 ? void 0 : _2.boards) === null || _3 === void 0 ? void 0 : _3[0]) === null || _4 === void 0 ? void 0 : _4.items_page) === null || _5 === void 0 ? void 0 : _5.items) || [];
4562
4669
  const formattedItems = await Promise.all(items.map(async (item) => {
4563
4670
  const formatted = {
4564
4671
  id: item.id,
@@ -4592,7 +4699,7 @@ class Worktables {
4592
4699
  const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
4593
4700
  const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
4594
4701
  let rulesArray = [];
4595
- if (((_3 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _3 === void 0 ? void 0 : _3.length) > 0) {
4702
+ if (((_6 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _6 === void 0 ? void 0 : _6.length) > 0) {
4596
4703
  console.log('Processing filter rules:', advancedFilterRules.rule);
4597
4704
  rulesArray = advancedFilterRules.rule.map((rule) => {
4598
4705
  let formattedValue;
@@ -4808,7 +4915,7 @@ class Worktables {
4808
4915
  });
4809
4916
  }
4810
4917
  const orderByArray = [];
4811
- if (((_4 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _4 === void 0 ? void 0 : _4.length) > 0) {
4918
+ if (((_7 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _7 === void 0 ? void 0 : _7.length) > 0) {
4812
4919
  advancedSortOptions.sortBy.forEach((sort) => {
4813
4920
  orderByArray.push(`{
4814
4921
  column_id: "${sort.columnId}",
@@ -4880,7 +4987,7 @@ class Worktables {
4880
4987
  body: { query: testQuery },
4881
4988
  });
4882
4989
  const testParsed = JSON.parse(testResponse);
4883
- const testItems = ((_8 = (_7 = (_6 = (_5 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.data) === null || _5 === void 0 ? void 0 : _5.boards) === null || _6 === void 0 ? void 0 : _6[0]) === null || _7 === void 0 ? void 0 : _7.items_page) === null || _8 === void 0 ? void 0 : _8.items) || [];
4990
+ const testItems = ((_11 = (_10 = (_9 = (_8 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.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) === null || _11 === void 0 ? void 0 : _11.items) || [];
4884
4991
  console.log('Test - Items in board (no filters):', testItems.length);
4885
4992
  if (testItems.length > 0) {
4886
4993
  console.log('Sample item column values:', testItems[0].column_values);
@@ -4892,7 +4999,7 @@ class Worktables {
4892
4999
  body: { query },
4893
5000
  });
4894
5001
  const parsed = JSON.parse(rawResponse);
4895
- const itemsPage = (_11 = (_10 = (_9 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _9 === void 0 ? void 0 : _9.boards) === null || _10 === void 0 ? void 0 : _10[0]) === null || _11 === void 0 ? void 0 : _11.items_page;
5002
+ const itemsPage = (_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;
4896
5003
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
4897
5004
  const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
4898
5005
  const hasMore = nextCursor ? true : false;
@@ -5003,6 +5110,16 @@ class Worktables {
5003
5110
  items {
5004
5111
  id
5005
5112
  name
5113
+ url
5114
+ board {
5115
+ id
5116
+ }
5117
+ group {
5118
+ id
5119
+ title
5120
+ color
5121
+ position
5122
+ }
5006
5123
  column_values {
5007
5124
  id
5008
5125
  text
@@ -5019,11 +5136,6 @@ class Worktables {
5019
5136
  }
5020
5137
  }
5021
5138
  }
5022
- group {
5023
- id
5024
- title
5025
- }
5026
- state
5027
5139
  created_at
5028
5140
  updated_at
5029
5141
  }
@@ -5039,18 +5151,29 @@ class Worktables {
5039
5151
  body: { query },
5040
5152
  });
5041
5153
  const parsed = JSON.parse(rawResponse);
5042
- const items = ((_17 = (_16 = (_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.groups) === null || _15 === void 0 ? void 0 : _15[0]) === null || _16 === void 0 ? void 0 : _16.items_page) === null || _17 === void 0 ? void 0 : _17.items) || [];
5154
+ 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) || [];
5043
5155
  const formattedItems = await Promise.all(items.map(async (item) => {
5156
+ const columnValues = item.column_values || [];
5044
5157
  const formatted = {
5045
5158
  id: item.id,
5046
5159
  name: item.name,
5047
- group: item.group,
5048
- state: item.state,
5160
+ url: item.url,
5049
5161
  created_at: item.created_at,
5050
5162
  updated_at: item.updated_at,
5163
+ board: item.board ? {
5164
+ id: item.board.id,
5165
+ } : undefined,
5166
+ group: item.group ? {
5167
+ id: item.group.id,
5168
+ title: item.group.title,
5169
+ color: item.group.color,
5170
+ position: item.group.position,
5171
+ } : undefined,
5051
5172
  column_values: {},
5052
5173
  };
5053
- for (const col of item.column_values || []) {
5174
+ for (const col of columnValues) {
5175
+ if (col.type === 'subtasks')
5176
+ continue;
5054
5177
  const formattedCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
5055
5178
  if (formattedCol) {
5056
5179
  formatted.column_values[col.id] = formattedCol;
@@ -5112,7 +5235,7 @@ class Worktables {
5112
5235
  response = await (0, isErrorResponse_1.parseApiResponse)(response);
5113
5236
  if (response.success) {
5114
5237
  const parsed = JSON.parse(response.data);
5115
- const updates = ((_20 = (_19 = (_18 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _18 === void 0 ? void 0 : _18.items) === null || _19 === void 0 ? void 0 : _19[0]) === null || _20 === void 0 ? void 0 : _20.updates) || [];
5238
+ 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) || [];
5116
5239
  return [updates.map((update) => ({ json: update }))];
5117
5240
  }
5118
5241
  else {
@@ -5169,7 +5292,7 @@ class Worktables {
5169
5292
  console.log('variables:', variables);
5170
5293
  response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
5171
5294
  console.log('Create Update Result:', JSON.stringify(response, null, 2));
5172
- const updateId = (_22 = (_21 = JSON.parse(response).data) === null || _21 === void 0 ? void 0 : _21.create_update) === null || _22 === void 0 ? void 0 : _22.id;
5295
+ 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;
5173
5296
  if (!updateId) {
5174
5297
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5175
5298
  message: 'Error creating update: Update not created, no ID returned',
@@ -5475,7 +5598,7 @@ class Worktables {
5475
5598
  body: { query },
5476
5599
  json: true,
5477
5600
  });
5478
- const asset = (_24 = (_23 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _23 === void 0 ? void 0 : _23.assets) === null || _24 === void 0 ? void 0 : _24[0];
5601
+ 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];
5479
5602
  if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
5480
5603
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5481
5604
  message: 'Public URL not found for the given file ID.',
@@ -5503,16 +5626,22 @@ class Worktables {
5503
5626
  }
5504
5627
  case 'query': {
5505
5628
  const runQuery = this.getNodeParameter('runQuery', 0);
5629
+ const apiVersion = this.getNodeParameter('apiVersion', 0);
5506
5630
  if (!runQuery) {
5507
5631
  throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Invalid item data.' });
5508
5632
  }
5509
5633
  switch (operation) {
5510
5634
  case 'query': {
5511
5635
  console.log('Run Query:', runQuery);
5636
+ const apiUrl = `https://api.monday.com/v2`;
5637
+ const queryHeaders = {
5638
+ ...headers,
5639
+ 'API-Version': apiVersion,
5640
+ };
5512
5641
  response = await this.helpers.request({
5513
5642
  method: 'POST',
5514
- url: 'https://api.monday.com/v2',
5515
- headers,
5643
+ url: apiUrl,
5644
+ headers: queryHeaders,
5516
5645
  body: { query: runQuery },
5517
5646
  });
5518
5647
  break;