@worktables/n8n-nodes-worktables 12.2.20 → 12.2.21

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.
@@ -1023,6 +1023,27 @@ class Worktables {
1023
1023
  },
1024
1024
  },
1025
1025
  },
1026
+ {
1027
+ displayName: 'Operator',
1028
+ name: 'identifierOperator',
1029
+ type: 'options',
1030
+ options: [
1031
+ { name: 'Equals', value: 'equals' },
1032
+ { name: 'Any Of', value: 'any_of' },
1033
+ { name: 'Not Any Of', value: 'not_any_of' },
1034
+ { name: 'Contains Text', value: 'contains_text' },
1035
+ { name: 'Does Not Contain Text', value: 'not_contains_text' },
1036
+ { name: 'Starts With', value: 'starts_with' },
1037
+ { name: 'Ends With', value: 'ends_with' },
1038
+ ],
1039
+ default: 'equals',
1040
+ description: 'The condition for value comparison',
1041
+ displayOptions: {
1042
+ show: {
1043
+ operation: ['createOrUpdateItem'],
1044
+ },
1045
+ },
1046
+ },
1026
1047
  {
1027
1048
  displayName: 'Identifier Value',
1028
1049
  name: 'itemIdOptional',
@@ -2809,7 +2830,7 @@ class Worktables {
2809
2830
  };
2810
2831
  }
2811
2832
  async execute() {
2812
- 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;
2833
+ 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;
2813
2834
  const resource = this.getNodeParameter('resource', 0);
2814
2835
  const operation = this.getNodeParameter('operation', 0);
2815
2836
  const credentials = await this.getCredentials('WorktablesApi');
@@ -4325,7 +4346,8 @@ class Worktables {
4325
4346
  let itemUpdated = false;
4326
4347
  let foundItemId = null;
4327
4348
  if (identifierValue && identifierValue.trim() !== '' && identifierColumn && identifierColumn.trim() !== '') {
4328
- console.log('Searching for item/subitem with identifier column:', identifierColumn, 'value:', identifierValue, 'isSubitem:', isSubitem);
4349
+ const identifierOperator = this.getNodeParameter('identifierOperator', 0, 'equals');
4350
+ console.log('Searching for item/subitem with identifier column:', identifierColumn, 'value:', identifierValue, 'operator:', identifierOperator, 'isSubitem:', isSubitem);
4329
4351
  let cursor = null;
4330
4352
  let hasMore = true;
4331
4353
  while (hasMore && !foundItemId) {
@@ -4377,6 +4399,47 @@ class Worktables {
4377
4399
  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;
4378
4400
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
4379
4401
  cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
4402
+ const compareValues = (colValue, identifierValue, operator) => {
4403
+ let colText = colValue.text || '';
4404
+ let colValueStr = '';
4405
+ try {
4406
+ if (colValue.value) {
4407
+ const parsedValue = JSON.parse(colValue.value);
4408
+ if (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.label) {
4409
+ colValueStr = parsedValue.label;
4410
+ }
4411
+ else {
4412
+ colValueStr = (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.text) || (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.value) || String(parsedValue);
4413
+ }
4414
+ }
4415
+ }
4416
+ catch {
4417
+ colValueStr = colValue.value || '';
4418
+ }
4419
+ const searchValue = identifierValue.trim().toLowerCase();
4420
+ const colTextLower = colText.trim().toLowerCase();
4421
+ const colValueStrLower = colValueStr.trim().toLowerCase();
4422
+ switch (operator) {
4423
+ case 'equals':
4424
+ return colTextLower === searchValue || colValueStrLower === searchValue;
4425
+ case 'any_of':
4426
+ const values = identifierValue.split(',').map(v => v.trim().toLowerCase());
4427
+ return values.includes(colTextLower) || values.includes(colValueStrLower);
4428
+ case 'not_any_of':
4429
+ const notValues = identifierValue.split(',').map(v => v.trim().toLowerCase());
4430
+ return !notValues.includes(colTextLower) && !notValues.includes(colValueStrLower);
4431
+ case 'contains_text':
4432
+ return colTextLower.includes(searchValue) || colValueStrLower.includes(searchValue);
4433
+ case 'not_contains_text':
4434
+ return !colTextLower.includes(searchValue) && !colValueStrLower.includes(searchValue);
4435
+ case 'starts_with':
4436
+ return colTextLower.startsWith(searchValue) || colValueStrLower.startsWith(searchValue);
4437
+ case 'ends_with':
4438
+ return colTextLower.endsWith(searchValue) || colValueStrLower.endsWith(searchValue);
4439
+ default:
4440
+ return colTextLower === searchValue || colValueStrLower === searchValue;
4441
+ }
4442
+ };
4380
4443
  const isNameColumn = identifierColumn === 'name' || identifierColumn.toLowerCase() === 'name';
4381
4444
  if (isSubitem) {
4382
4445
  for (const item of items) {
@@ -4384,25 +4447,29 @@ class Worktables {
4384
4447
  for (const subitem of item.subitems) {
4385
4448
  let matches = false;
4386
4449
  if (isNameColumn) {
4387
- matches = subitem.name === identifierValue ||
4388
- ((_0 = subitem.name) === null || _0 === void 0 ? void 0 : _0.trim()) === identifierValue.trim();
4450
+ const subitemName = (subitem.name || '').trim().toLowerCase();
4451
+ const searchValue = identifierValue.trim().toLowerCase();
4452
+ switch (identifierOperator) {
4453
+ case 'equals':
4454
+ matches = subitemName === searchValue;
4455
+ break;
4456
+ case 'contains_text':
4457
+ matches = subitemName.includes(searchValue);
4458
+ break;
4459
+ case 'starts_with':
4460
+ matches = subitemName.startsWith(searchValue);
4461
+ break;
4462
+ case 'ends_with':
4463
+ matches = subitemName.endsWith(searchValue);
4464
+ break;
4465
+ default:
4466
+ matches = subitemName === searchValue;
4467
+ }
4389
4468
  }
4390
4469
  else {
4391
- const colValue = (_1 = subitem.column_values) === null || _1 === void 0 ? void 0 : _1.find((cv) => cv.id === identifierColumn);
4470
+ const colValue = (_0 = subitem.column_values) === null || _0 === void 0 ? void 0 : _0.find((cv) => cv.id === identifierColumn);
4392
4471
  if (colValue) {
4393
- let colText = colValue.text || '';
4394
- let colValueStr = '';
4395
- try {
4396
- if (colValue.value) {
4397
- const parsedValue = JSON.parse(colValue.value);
4398
- colValueStr = (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.text) || (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.value) || String(parsedValue);
4399
- }
4400
- }
4401
- catch {
4402
- colValueStr = colValue.value || '';
4403
- }
4404
- matches = colText === identifierValue || colValueStr === identifierValue ||
4405
- colText.trim() === identifierValue.trim() || colValueStr.trim() === identifierValue.trim();
4472
+ matches = compareValues(colValue, identifierValue, identifierOperator);
4406
4473
  }
4407
4474
  }
4408
4475
  if (matches) {
@@ -4419,25 +4486,29 @@ class Worktables {
4419
4486
  for (const item of items) {
4420
4487
  let matches = false;
4421
4488
  if (isNameColumn) {
4422
- matches = item.name === identifierValue ||
4423
- ((_2 = item.name) === null || _2 === void 0 ? void 0 : _2.trim()) === identifierValue.trim();
4489
+ const itemName = (item.name || '').trim().toLowerCase();
4490
+ const searchValue = identifierValue.trim().toLowerCase();
4491
+ switch (identifierOperator) {
4492
+ case 'equals':
4493
+ matches = itemName === searchValue;
4494
+ break;
4495
+ case 'contains_text':
4496
+ matches = itemName.includes(searchValue);
4497
+ break;
4498
+ case 'starts_with':
4499
+ matches = itemName.startsWith(searchValue);
4500
+ break;
4501
+ case 'ends_with':
4502
+ matches = itemName.endsWith(searchValue);
4503
+ break;
4504
+ default:
4505
+ matches = itemName === searchValue;
4506
+ }
4424
4507
  }
4425
4508
  else {
4426
- const colValue = (_3 = item.column_values) === null || _3 === void 0 ? void 0 : _3.find((cv) => cv.id === identifierColumn);
4509
+ const colValue = (_1 = item.column_values) === null || _1 === void 0 ? void 0 : _1.find((cv) => cv.id === identifierColumn);
4427
4510
  if (colValue) {
4428
- let colText = colValue.text || '';
4429
- let colValueStr = '';
4430
- try {
4431
- if (colValue.value) {
4432
- const parsedValue = JSON.parse(colValue.value);
4433
- colValueStr = (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.text) || (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.value) || String(parsedValue);
4434
- }
4435
- }
4436
- catch {
4437
- colValueStr = colValue.value || '';
4438
- }
4439
- matches = colText === identifierValue || colValueStr === identifierValue ||
4440
- colText.trim() === identifierValue.trim() || colValueStr.trim() === identifierValue.trim();
4511
+ matches = compareValues(colValue, identifierValue, identifierOperator);
4441
4512
  }
4442
4513
  }
4443
4514
  if (matches) {
@@ -4480,7 +4551,7 @@ class Worktables {
4480
4551
  id: itemData.id,
4481
4552
  url: itemData.url || '',
4482
4553
  operation: 'update',
4483
- board_id: ((_4 = itemData.board) === null || _4 === void 0 ? void 0 : _4.id) || boardId,
4554
+ board_id: ((_2 = itemData.board) === null || _2 === void 0 ? void 0 : _2.id) || boardId,
4484
4555
  column_values: column_values_object,
4485
4556
  };
4486
4557
  itemUpdated = true;
@@ -4563,8 +4634,8 @@ class Worktables {
4563
4634
  });
4564
4635
  }
4565
4636
  const itemData = isSubitem && parentId
4566
- ? (_5 = responseData.data) === null || _5 === void 0 ? void 0 : _5.create_subitem
4567
- : (_6 = responseData.data) === null || _6 === void 0 ? void 0 : _6.create_item;
4637
+ ? (_3 = responseData.data) === null || _3 === void 0 ? void 0 : _3.create_subitem
4638
+ : (_4 = responseData.data) === null || _4 === void 0 ? void 0 : _4.create_item;
4568
4639
  if (!itemData || !itemData.id) {
4569
4640
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
4570
4641
  message: `Error creating ${isSubitem ? 'subitem' : 'item'}: No item data returned`,
@@ -4575,7 +4646,7 @@ class Worktables {
4575
4646
  name: itemData.name || itemName,
4576
4647
  url: itemData.url || '',
4577
4648
  operation: 'create',
4578
- board_id: ((_7 = itemData.board) === null || _7 === void 0 ? void 0 : _7.id) || boardId,
4649
+ board_id: ((_5 = itemData.board) === null || _5 === void 0 ? void 0 : _5.id) || boardId,
4579
4650
  column_values: column_values_object,
4580
4651
  };
4581
4652
  if (isSubitem && parentId) {
@@ -4714,7 +4785,7 @@ class Worktables {
4714
4785
  body: { query },
4715
4786
  });
4716
4787
  const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
4717
- 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;
4788
+ 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;
4718
4789
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
4719
4790
  cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
4720
4791
  allItems = allItems.concat(items);
@@ -4794,7 +4865,7 @@ class Worktables {
4794
4865
  const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
4795
4866
  const logicalOperator = this.getNodeParameter('logicalOperator', 0);
4796
4867
  let rulesArray = [];
4797
- if (((_11 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _11 === void 0 ? void 0 : _11.length) > 0) {
4868
+ if (((_9 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _9 === void 0 ? void 0 : _9.length) > 0) {
4798
4869
  rulesArray = filterRules.rule.map((rule) => {
4799
4870
  let formattedValue;
4800
4871
  if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
@@ -4838,7 +4909,7 @@ class Worktables {
4838
4909
  });
4839
4910
  }
4840
4911
  const orderByArray = [];
4841
- if (((_12 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _12 === void 0 ? void 0 : _12.length) > 0) {
4912
+ if (((_10 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _10 === void 0 ? void 0 : _10.length) > 0) {
4842
4913
  sortOptions.sortBy.forEach((sort) => {
4843
4914
  orderByArray.push(`{
4844
4915
  column_id: "${sort.columnId}",
@@ -4884,7 +4955,7 @@ class Worktables {
4884
4955
  body: { query },
4885
4956
  });
4886
4957
  const parsed = JSON.parse(rawResponse);
4887
- 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) || [];
4958
+ 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) || [];
4888
4959
  const formattedItems = await Promise.all(items.map(async (item) => {
4889
4960
  const formatted = {
4890
4961
  id: item.id,
@@ -4918,7 +4989,7 @@ class Worktables {
4918
4989
  const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
4919
4990
  const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
4920
4991
  let rulesArray = [];
4921
- if (((_17 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _17 === void 0 ? void 0 : _17.length) > 0) {
4992
+ if (((_15 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _15 === void 0 ? void 0 : _15.length) > 0) {
4922
4993
  console.log('Processing filter rules:', advancedFilterRules.rule);
4923
4994
  rulesArray = advancedFilterRules.rule.map((rule) => {
4924
4995
  let formattedValue;
@@ -5134,7 +5205,7 @@ class Worktables {
5134
5205
  });
5135
5206
  }
5136
5207
  const orderByArray = [];
5137
- if (((_18 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _18 === void 0 ? void 0 : _18.length) > 0) {
5208
+ if (((_16 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _16 === void 0 ? void 0 : _16.length) > 0) {
5138
5209
  advancedSortOptions.sortBy.forEach((sort) => {
5139
5210
  orderByArray.push(`{
5140
5211
  column_id: "${sort.columnId}",
@@ -5206,7 +5277,7 @@ class Worktables {
5206
5277
  body: { query: testQuery },
5207
5278
  });
5208
5279
  const testParsed = JSON.parse(testResponse);
5209
- 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) || [];
5280
+ 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) || [];
5210
5281
  console.log('Test - Items in board (no filters):', testItems.length);
5211
5282
  if (testItems.length > 0) {
5212
5283
  console.log('Sample item column values:', testItems[0].column_values);
@@ -5218,7 +5289,7 @@ class Worktables {
5218
5289
  body: { query },
5219
5290
  });
5220
5291
  const parsed = JSON.parse(rawResponse);
5221
- 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;
5292
+ 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;
5222
5293
  const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
5223
5294
  const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
5224
5295
  const hasMore = nextCursor ? true : false;
@@ -5376,7 +5447,7 @@ class Worktables {
5376
5447
  body: { query },
5377
5448
  });
5378
5449
  const parsed = JSON.parse(rawResponse);
5379
- 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) || [];
5450
+ 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) || [];
5380
5451
  const formattedItems = await Promise.all(items.map(async (item) => {
5381
5452
  const columnValues = item.column_values || [];
5382
5453
  const formatted = {
@@ -5466,7 +5537,7 @@ class Worktables {
5466
5537
  response = await (0, isErrorResponse_1.parseApiResponse)(response);
5467
5538
  if (response.success) {
5468
5539
  const parsed = JSON.parse(response.data);
5469
- 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) || [];
5540
+ 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) || [];
5470
5541
  const formattedUpdates = updates.map((update) => {
5471
5542
  const pinnedToTop = update.pinned_to_top || [];
5472
5543
  const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
@@ -5531,7 +5602,7 @@ class Worktables {
5531
5602
  console.log('variables:', variables);
5532
5603
  response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
5533
5604
  console.log('Create Update Result:', JSON.stringify(response, null, 2));
5534
- 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;
5605
+ 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;
5535
5606
  if (!updateId) {
5536
5607
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5537
5608
  message: 'Error creating update: Update not created, no ID returned',
@@ -5837,7 +5908,7 @@ class Worktables {
5837
5908
  body: { query },
5838
5909
  json: true,
5839
5910
  });
5840
- 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];
5911
+ 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];
5841
5912
  if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
5842
5913
  throw new n8n_workflow_1.NodeApiError(this.getNode(), {
5843
5914
  message: 'Public URL not found for the given file ID.',