@worktables/n8n-nodes-worktables 12.16.0 → 12.17.0
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.
- package/dist/nodes/Worktables/Worktables.node.js +68 -395
- package/dist/nodes/Worktables/Worktables.node.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/worktablesHelpers.d.ts +30 -0
- package/dist/utils/worktablesHelpers.js +138 -1
- package/dist/utils/worktablesHelpers.js.map +1 -1
- package/package.json +1 -1
|
@@ -3178,7 +3178,7 @@ class Worktables {
|
|
|
3178
3178
|
};
|
|
3179
3179
|
}
|
|
3180
3180
|
async execute() {
|
|
3181
|
-
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, _39, _40, _41, _42, _43, _44, _45, _46, _47
|
|
3181
|
+
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, _39, _40, _41, _42, _43, _44, _45, _46, _47;
|
|
3182
3182
|
const resource = this.getNodeParameter('resource', 0);
|
|
3183
3183
|
const operation = this.getNodeParameter('operation', 0);
|
|
3184
3184
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
@@ -4558,162 +4558,19 @@ class Worktables {
|
|
|
4558
4558
|
const groupName = this.getNodeParameter('groupName', 0, '');
|
|
4559
4559
|
const raw = this.getNodeParameter('columnValues', 0);
|
|
4560
4560
|
const columnValues = raw.column;
|
|
4561
|
-
let column_values_object = {};
|
|
4562
4561
|
console.log('Column Values:', JSON.stringify(raw, null, 2));
|
|
4563
|
-
|
|
4564
|
-
const columnTypeResponse = await this.helpers.request({
|
|
4565
|
-
method: 'POST',
|
|
4566
|
-
url: 'https://api.monday.com/v2',
|
|
4567
|
-
headers: {
|
|
4568
|
-
Authorization: `Bearer ${apiKey}`,
|
|
4569
|
-
'Content-Type': 'application/json',
|
|
4570
|
-
},
|
|
4571
|
-
body: {
|
|
4572
|
-
query: `query {
|
|
4573
|
-
boards(ids: ${boardId}) {
|
|
4574
|
-
columns {
|
|
4575
|
-
id
|
|
4576
|
-
type
|
|
4577
|
-
}
|
|
4578
|
-
}
|
|
4579
|
-
}`,
|
|
4580
|
-
},
|
|
4581
|
-
});
|
|
4582
|
-
const columnsType = JSON.parse(columnTypeResponse).data.boards[0].columns;
|
|
4583
|
-
for (const col of columnValues) {
|
|
4584
|
-
const columnId = col.columnId;
|
|
4585
|
-
const columnDef = columnsType.find((c) => c.id === columnId);
|
|
4586
|
-
const type = columnDef === null || columnDef === void 0 ? void 0 : columnDef.type;
|
|
4587
|
-
if (!type || type === 'text' || type === 'simple' || col.columnType === 'simple') {
|
|
4588
|
-
console.log('Processing text/simple column:', col);
|
|
4589
|
-
if (col.columnValue !== undefined) {
|
|
4590
|
-
const value = col.columnValue;
|
|
4591
|
-
if (typeof value === 'string' && type === 'file') {
|
|
4592
|
-
const links = value.split(',').map((item) => {
|
|
4593
|
-
const [link, ...nameParts] = item.trim().split(/\s+/);
|
|
4594
|
-
return {
|
|
4595
|
-
fileType: 'LINK',
|
|
4596
|
-
linkToFile: link,
|
|
4597
|
-
name: nameParts.join(' '),
|
|
4598
|
-
};
|
|
4599
|
-
});
|
|
4600
|
-
column_values_object[columnId] = { files: links };
|
|
4601
|
-
}
|
|
4602
|
-
else if (typeof value === 'string') {
|
|
4603
|
-
column_values_object[columnId] = value;
|
|
4604
|
-
}
|
|
4605
|
-
else {
|
|
4606
|
-
column_values_object[columnId] = value;
|
|
4607
|
-
}
|
|
4608
|
-
}
|
|
4609
|
-
continue;
|
|
4610
|
-
}
|
|
4611
|
-
else if (col.columnType === 'objectValue') {
|
|
4612
|
-
console.log('Processing objectValue for column:', columnId);
|
|
4613
|
-
try {
|
|
4614
|
-
const parsedValue = JSON.parse(col.objectValue || '{}');
|
|
4615
|
-
column_values_object[columnId] = parsedValue;
|
|
4616
|
-
}
|
|
4617
|
-
catch (error) {
|
|
4618
|
-
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
4619
|
-
message: `Invalid JSON format for column ${columnId}: ${error.message}`,
|
|
4620
|
-
});
|
|
4621
|
-
}
|
|
4622
|
-
continue;
|
|
4623
|
-
}
|
|
4624
|
-
switch (type) {
|
|
4625
|
-
case 'checkbox':
|
|
4626
|
-
column_values_object[columnId] = col.checkboxValue ? { checked: 'true' } : { checked: 'false' };
|
|
4627
|
-
break;
|
|
4628
|
-
case 'status':
|
|
4629
|
-
column_values_object[columnId] = { label: col.statusLabel || 'Working on it' };
|
|
4630
|
-
break;
|
|
4631
|
-
case 'location':
|
|
4632
|
-
column_values_object[columnId] = {
|
|
4633
|
-
lat: col.latitude || '0',
|
|
4634
|
-
lng: col.longitude || '0',
|
|
4635
|
-
address: col.address || '',
|
|
4636
|
-
};
|
|
4637
|
-
break;
|
|
4638
|
-
case 'dropdown':
|
|
4639
|
-
column_values_object[columnId] = { label: col.dropdownValue || '' };
|
|
4640
|
-
break;
|
|
4641
|
-
case 'people':
|
|
4642
|
-
if (col.peopleValue) {
|
|
4643
|
-
const peopleIds = Array.isArray(col.peopleValue) ? col.peopleValue : [col.peopleValue];
|
|
4644
|
-
column_values_object[columnId] = { personsAndTeams: peopleIds.map(id => ({ id, kind: 'person' })) };
|
|
4645
|
-
}
|
|
4646
|
-
break;
|
|
4647
|
-
case 'team':
|
|
4648
|
-
if (col.teamsValue) {
|
|
4649
|
-
const teamIds = Array.isArray(col.teamsValue) ? col.teamsValue : [col.teamsValue];
|
|
4650
|
-
column_values_object[columnId] = { personsAndTeams: teamIds.map(id => ({ id, kind: 'team' })) };
|
|
4651
|
-
}
|
|
4652
|
-
break;
|
|
4653
|
-
case 'timeline':
|
|
4654
|
-
column_values_object[columnId] = {
|
|
4655
|
-
from: col.startDate || '',
|
|
4656
|
-
to: col.endDate || '',
|
|
4657
|
-
};
|
|
4658
|
-
break;
|
|
4659
|
-
case 'date':
|
|
4660
|
-
column_values_object[columnId] = { date: col.dateValue || '' };
|
|
4661
|
-
break;
|
|
4662
|
-
case 'email':
|
|
4663
|
-
column_values_object[columnId] = {
|
|
4664
|
-
email: col.emailValue || '',
|
|
4665
|
-
text: col.emailText || '',
|
|
4666
|
-
};
|
|
4667
|
-
break;
|
|
4668
|
-
case 'link':
|
|
4669
|
-
column_values_object[columnId] = {
|
|
4670
|
-
url: col.url || '',
|
|
4671
|
-
text: col.linkText || '',
|
|
4672
|
-
};
|
|
4673
|
-
break;
|
|
4674
|
-
case 'phone':
|
|
4675
|
-
column_values_object[columnId] = {
|
|
4676
|
-
phone: col.phoneValue || '',
|
|
4677
|
-
countryShortName: col.countryCode || 'US',
|
|
4678
|
-
};
|
|
4679
|
-
break;
|
|
4680
|
-
case 'file':
|
|
4681
|
-
if ((_w = col.fileLinks) === null || _w === void 0 ? void 0 : _w.file) {
|
|
4682
|
-
column_values_object[columnId] = { files: col.fileLinks.file };
|
|
4683
|
-
}
|
|
4684
|
-
break;
|
|
4685
|
-
default:
|
|
4686
|
-
if (col.columnValue !== undefined) {
|
|
4687
|
-
column_values_object[columnId] = col.columnValue;
|
|
4688
|
-
}
|
|
4689
|
-
}
|
|
4690
|
-
}
|
|
4691
|
-
}
|
|
4562
|
+
const column_values_object = await (0, worktablesHelpers_1.processColumnValues)(this, columnValues, boardId, apiKey);
|
|
4692
4563
|
let mutation;
|
|
4693
4564
|
let formatted;
|
|
4694
4565
|
let itemUpdated = false;
|
|
4695
4566
|
let foundItemId = null;
|
|
4696
4567
|
let foundItemBoardId = null;
|
|
4697
4568
|
if (identifierValue && identifierValue.trim() !== '' && identifierColumn && identifierColumn.trim() !== '') {
|
|
4698
|
-
console.log('
|
|
4699
|
-
console.log('🔍 STARTING SEARCH FOR ITEM/SUBITEM');
|
|
4700
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
4701
|
-
console.log('📋 Search Parameters:');
|
|
4702
|
-
console.log(' - identifierColumn (raw):', JSON.stringify(identifierColumn));
|
|
4703
|
-
console.log(' - identifierColumn (trimmed):', JSON.stringify(identifierColumn.trim()));
|
|
4704
|
-
console.log(' - identifierValue (raw):', JSON.stringify(identifierValue));
|
|
4705
|
-
console.log(' - identifierValue (trimmed):', JSON.stringify(identifierValue.trim()));
|
|
4706
|
-
console.log(' - isSubitem:', isSubitem);
|
|
4707
|
-
console.log(' - boardId:', boardId);
|
|
4708
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
4569
|
+
console.log('Searching for item/subitem with identifier column:', identifierColumn, 'value:', identifierValue, 'isSubitem:', isSubitem);
|
|
4709
4570
|
const parentId = this.getNodeParameter('parentId', 0, false);
|
|
4710
|
-
console.log(' - parentId:', parentId || '(not provided)');
|
|
4711
4571
|
const isNameColumn = identifierColumn === 'name' || identifierColumn.toLowerCase() === 'name';
|
|
4712
|
-
console.log(' - isNameColumn:', isNameColumn);
|
|
4713
4572
|
let searchBoardId = boardId;
|
|
4714
|
-
console.log(' - Initial searchBoardId:', searchBoardId);
|
|
4715
4573
|
if (isSubitem && !parentId) {
|
|
4716
|
-
console.log(' - Discovering subitem board...');
|
|
4717
4574
|
try {
|
|
4718
4575
|
const discoverQuery = `query {
|
|
4719
4576
|
boards(ids: [${boardId}]) {
|
|
@@ -4735,23 +4592,18 @@ class Worktables {
|
|
|
4735
4592
|
body: { query: discoverQuery },
|
|
4736
4593
|
});
|
|
4737
4594
|
const discoverData = JSON.parse(discoverResponse);
|
|
4738
|
-
const items = ((
|
|
4595
|
+
const items = ((_z = (_y = (_x = (_w = discoverData === null || discoverData === void 0 ? void 0 : discoverData.data) === null || _w === void 0 ? void 0 : _w.boards) === null || _x === void 0 ? void 0 : _x[0]) === null || _y === void 0 ? void 0 : _y.items_page) === null || _z === void 0 ? void 0 : _z.items) || [];
|
|
4739
4596
|
if (items.length > 0 && items[0].subitems && items[0].subitems.length > 0) {
|
|
4740
|
-
searchBoardId = ((
|
|
4741
|
-
console.log(`
|
|
4742
|
-
}
|
|
4743
|
-
else {
|
|
4744
|
-
console.log(` ⚠ No subitems found to discover board, using main board: ${boardId}`);
|
|
4597
|
+
searchBoardId = ((_0 = items[0].subitems[0].board) === null || _0 === void 0 ? void 0 : _0.id) || boardId;
|
|
4598
|
+
console.log(`Discovered subitem board ID: ${searchBoardId}`);
|
|
4745
4599
|
}
|
|
4746
4600
|
}
|
|
4747
4601
|
catch (error) {
|
|
4748
|
-
console.log('
|
|
4602
|
+
console.log('Could not discover subitem board, using main board:', error);
|
|
4749
4603
|
}
|
|
4750
4604
|
}
|
|
4751
|
-
console.log(' - Final searchBoardId:', searchBoardId);
|
|
4752
4605
|
let columnType = null;
|
|
4753
4606
|
if (!isNameColumn) {
|
|
4754
|
-
console.log(' - Fetching column type for:', identifierColumn);
|
|
4755
4607
|
try {
|
|
4756
4608
|
const columnTypeQuery = `query {
|
|
4757
4609
|
boards(ids: [${searchBoardId}]) {
|
|
@@ -4767,31 +4619,20 @@ class Worktables {
|
|
|
4767
4619
|
body: { query: columnTypeQuery },
|
|
4768
4620
|
});
|
|
4769
4621
|
const columnTypeData = JSON.parse(columnTypeResponse);
|
|
4770
|
-
const columns = ((
|
|
4622
|
+
const columns = ((_3 = (_2 = (_1 = columnTypeData === null || columnTypeData === void 0 ? void 0 : columnTypeData.data) === null || _1 === void 0 ? void 0 : _1.boards) === null || _2 === void 0 ? void 0 : _2[0]) === null || _3 === void 0 ? void 0 : _3.columns) || [];
|
|
4771
4623
|
if (columns.length > 0) {
|
|
4772
4624
|
columnType = columns[0].type;
|
|
4773
|
-
console.log(`
|
|
4774
|
-
}
|
|
4775
|
-
else {
|
|
4776
|
-
console.log(` ⚠ Column not found in board ${searchBoardId}`);
|
|
4625
|
+
console.log(`Column type detected: ${columnType}`);
|
|
4777
4626
|
}
|
|
4778
4627
|
}
|
|
4779
4628
|
catch (error) {
|
|
4780
|
-
console.log('
|
|
4629
|
+
console.log('Could not fetch column type, using default operator:', error);
|
|
4781
4630
|
}
|
|
4782
4631
|
}
|
|
4783
|
-
else {
|
|
4784
|
-
console.log(' - Skipping column type fetch (isNameColumn=true)');
|
|
4785
|
-
}
|
|
4786
4632
|
const searchColumnId = isNameColumn ? 'name' : identifierColumn;
|
|
4787
4633
|
const operator = columnType === 'status' ? 'contains_terms' : 'contains_text';
|
|
4788
4634
|
const limit = 100;
|
|
4789
|
-
console.log(' - searchColumnId:', searchColumnId);
|
|
4790
|
-
console.log(' - operator:', operator);
|
|
4791
|
-
console.log(' - limit:', limit);
|
|
4792
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
4793
4635
|
if (isSubitem && parentId) {
|
|
4794
|
-
console.log('🔍 Searching subitems with parentId:', parentId);
|
|
4795
4636
|
const parentQuery = `query {
|
|
4796
4637
|
items(ids: [${parentId}]) {
|
|
4797
4638
|
id
|
|
@@ -4831,23 +4672,19 @@ class Worktables {
|
|
|
4831
4672
|
body: { query: parentQuery },
|
|
4832
4673
|
});
|
|
4833
4674
|
const searchData = JSON.parse(searchResponse);
|
|
4834
|
-
const items = ((
|
|
4835
|
-
console.log(` - Parent query response: ${items.length} parent item(s) found`);
|
|
4675
|
+
const items = ((_4 = searchData === null || searchData === void 0 ? void 0 : searchData.data) === null || _4 === void 0 ? void 0 : _4.items) || [];
|
|
4836
4676
|
if (items.length > 0 && items[0].subitems) {
|
|
4837
4677
|
const subitems = items[0].subitems;
|
|
4838
|
-
console.log(
|
|
4839
|
-
for (
|
|
4840
|
-
const subitem = subitems[i];
|
|
4841
|
-
console.log(` - Checking subitem ${i + 1}/${subitems.length}: ID=${subitem.id}, name="${subitem.name}"`);
|
|
4678
|
+
console.log(`🔍 Searching subitems of parent ${parentId}, found ${subitems.length} subitem(s)`);
|
|
4679
|
+
for (const subitem of subitems) {
|
|
4842
4680
|
let matches = false;
|
|
4843
4681
|
if (isNameColumn) {
|
|
4844
4682
|
const searchValue = identifierValue.trim().toLowerCase();
|
|
4845
4683
|
const subitemName = (subitem.name || '').trim().toLowerCase();
|
|
4846
4684
|
matches = subitemName === searchValue;
|
|
4847
|
-
console.log(` - Name comparison: "${subitemName}" === "${searchValue}" = ${matches}`);
|
|
4848
4685
|
}
|
|
4849
4686
|
else {
|
|
4850
|
-
const colValue = (
|
|
4687
|
+
const colValue = (_5 = subitem.column_values) === null || _5 === void 0 ? void 0 : _5.find((cv) => cv.id === identifierColumn);
|
|
4851
4688
|
if (colValue) {
|
|
4852
4689
|
const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
|
|
4853
4690
|
const isStatusColumn = colValue.type === 'status';
|
|
@@ -4855,57 +4692,25 @@ class Worktables {
|
|
|
4855
4692
|
? (colValue.display_value || '').trim()
|
|
4856
4693
|
: (colValue.text || '').trim();
|
|
4857
4694
|
const searchValue = identifierValue.trim().toLowerCase();
|
|
4858
|
-
|
|
4859
|
-
console.log(` - Column value found: "${compareValue}" (length: ${compareValue.length}, raw: ${JSON.stringify(compareValue)})`);
|
|
4860
|
-
console.log(` - Search value: "${identifierValue}" (length: ${identifierValue.trim().length}, trimmed: "${identifierValue.trim()}", raw: ${JSON.stringify(identifierValue)})`);
|
|
4861
|
-
const trimmedCompare = compareValue.trim().toLowerCase();
|
|
4862
|
-
const trimmedSearch = searchValue.trim();
|
|
4863
|
-
matches = trimmedCompare === trimmedSearch;
|
|
4864
|
-
console.log(` - Trimmed compare: "${trimmedCompare}" === "${trimmedSearch}" = ${matches}`);
|
|
4695
|
+
matches = compareValue.toLowerCase() === searchValue;
|
|
4865
4696
|
if (isStatusColumn && !matches) {
|
|
4866
|
-
const normalizedCompare =
|
|
4867
|
-
const normalizedSearch =
|
|
4697
|
+
const normalizedCompare = compareValue.toLowerCase().replace(/\s+/g, ' ').trim();
|
|
4698
|
+
const normalizedSearch = searchValue.replace(/\s+/g, ' ').trim();
|
|
4868
4699
|
matches = normalizedCompare === normalizedSearch;
|
|
4869
|
-
console.log(` - Normalized compare: "${normalizedCompare}" === "${normalizedSearch}" = ${matches}`);
|
|
4870
|
-
if (!matches) {
|
|
4871
|
-
matches = normalizedCompare.includes(normalizedSearch) || normalizedSearch.includes(normalizedCompare);
|
|
4872
|
-
console.log(` - Contains check: "${normalizedCompare}".includes("${normalizedSearch}") OR "${normalizedSearch}".includes("${normalizedCompare}") = ${matches}`);
|
|
4873
|
-
}
|
|
4874
|
-
if (!matches) {
|
|
4875
|
-
console.log(` ❌ Status column comparison failed for subitem ${subitem.id}`);
|
|
4876
|
-
}
|
|
4877
4700
|
}
|
|
4878
|
-
if (!matches) {
|
|
4879
|
-
console.log(` ❌ No match for subitem ${subitem.id}, column type: ${colValue.type}`);
|
|
4880
|
-
}
|
|
4881
|
-
}
|
|
4882
|
-
else {
|
|
4883
|
-
console.log(` ⚠ Column value not found for subitem ${subitem.id}, identifierColumn: ${identifierColumn}`);
|
|
4884
|
-
console.log(` - Available column_values:`, ((_7 = subitem.column_values) === null || _7 === void 0 ? void 0 : _7.map((cv) => cv.id).join(', ')) || 'none');
|
|
4885
4701
|
}
|
|
4886
4702
|
}
|
|
4887
4703
|
if (matches) {
|
|
4888
4704
|
foundItemId = subitem.id;
|
|
4889
|
-
foundItemBoardId = ((
|
|
4890
|
-
console.log(
|
|
4705
|
+
foundItemBoardId = ((_6 = subitem.board) === null || _6 === void 0 ? void 0 : _6.id) || null;
|
|
4706
|
+
console.log(`✓ Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
|
|
4891
4707
|
break;
|
|
4892
4708
|
}
|
|
4893
|
-
else {
|
|
4894
|
-
console.log(` ✗ No match for subitem ${subitem.id}`);
|
|
4895
|
-
}
|
|
4896
4709
|
}
|
|
4897
4710
|
}
|
|
4898
4711
|
}
|
|
4899
4712
|
else {
|
|
4900
|
-
|
|
4901
|
-
console.log('🔍 Searching items (not subitems)');
|
|
4902
|
-
console.log(' - useExactSearch:', useExactSearch);
|
|
4903
|
-
console.log(' - columnType:', columnType);
|
|
4904
|
-
console.log(' - isNameColumn:', isNameColumn);
|
|
4905
|
-
let items = [];
|
|
4906
|
-
if (useExactSearch) {
|
|
4907
|
-
console.log(' - Attempting exact search with is_equal operator...');
|
|
4908
|
-
const query = `{
|
|
4713
|
+
const query = `{
|
|
4909
4714
|
boards(ids: [${searchBoardId}]) {
|
|
4910
4715
|
items_page (
|
|
4911
4716
|
limit: ${limit},
|
|
@@ -4913,7 +4718,7 @@ class Worktables {
|
|
|
4913
4718
|
rules: [{
|
|
4914
4719
|
column_id: "${searchColumnId}",
|
|
4915
4720
|
compare_value: "${identifierValue}",
|
|
4916
|
-
operator:
|
|
4721
|
+
operator: ${operator}
|
|
4917
4722
|
}]
|
|
4918
4723
|
}
|
|
4919
4724
|
) {
|
|
@@ -4943,80 +4748,26 @@ class Worktables {
|
|
|
4943
4748
|
}
|
|
4944
4749
|
}
|
|
4945
4750
|
}`;
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
catch (error) {
|
|
4959
|
-
console.log(' ❌ Exact search failed, falling back to fetch all:', error);
|
|
4960
|
-
useExactSearch = false;
|
|
4961
|
-
}
|
|
4962
|
-
}
|
|
4963
|
-
if (!useExactSearch || items.length === 0) {
|
|
4964
|
-
console.log(' - Fetching all items from board for exact matching...');
|
|
4965
|
-
const query = `{
|
|
4966
|
-
boards(ids: [${searchBoardId}]) {
|
|
4967
|
-
items_page(limit: ${limit}) {
|
|
4968
|
-
items {
|
|
4969
|
-
name
|
|
4970
|
-
id
|
|
4971
|
-
url
|
|
4972
|
-
column_values(ids: "${identifierColumn}") {
|
|
4973
|
-
id
|
|
4974
|
-
text
|
|
4975
|
-
type
|
|
4976
|
-
column {
|
|
4977
|
-
id
|
|
4978
|
-
}
|
|
4979
|
-
... on BoardRelationValue {
|
|
4980
|
-
display_value
|
|
4981
|
-
}
|
|
4982
|
-
... on MirrorValue {
|
|
4983
|
-
display_value
|
|
4984
|
-
}
|
|
4985
|
-
... on StatusValue {
|
|
4986
|
-
text
|
|
4987
|
-
index
|
|
4988
|
-
}
|
|
4989
|
-
}
|
|
4990
|
-
}
|
|
4991
|
-
}
|
|
4992
|
-
}
|
|
4993
|
-
}`;
|
|
4994
|
-
const searchResponse = await this.helpers.request({
|
|
4995
|
-
method: 'POST',
|
|
4996
|
-
url: 'https://api.monday.com/v2',
|
|
4997
|
-
headers,
|
|
4998
|
-
body: { query },
|
|
4999
|
-
});
|
|
5000
|
-
const searchData = JSON.parse(searchResponse);
|
|
5001
|
-
const itemsPage = (_14 = (_13 = (_12 = searchData === null || searchData === void 0 ? void 0 : searchData.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;
|
|
5002
|
-
items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5003
|
-
console.log(` ✓ Fetched ${items.length} item(s) from board for exact matching`);
|
|
5004
|
-
}
|
|
5005
|
-
console.log(` - Starting exact comparison on ${items.length} item(s)...`);
|
|
5006
|
-
for (let i = 0; i < items.length; i++) {
|
|
5007
|
-
const item = items[i];
|
|
5008
|
-
console.log(` - Checking item ${i + 1}/${items.length}: ID=${item.id}, name="${item.name}"`);
|
|
4751
|
+
console.log('✅✅✅ Query: ', query);
|
|
4752
|
+
const searchResponse = await this.helpers.request({
|
|
4753
|
+
method: 'POST',
|
|
4754
|
+
url: 'https://api.monday.com/v2',
|
|
4755
|
+
headers,
|
|
4756
|
+
body: { query },
|
|
4757
|
+
});
|
|
4758
|
+
const searchData = JSON.parse(searchResponse);
|
|
4759
|
+
const itemsPage = (_9 = (_8 = (_7 = searchData === null || searchData === void 0 ? void 0 : searchData.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;
|
|
4760
|
+
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
4761
|
+
console.log(`🔍 Optimized search found ${items.length} item(s) matching identifier`);
|
|
4762
|
+
for (const item of items) {
|
|
5009
4763
|
let matches = false;
|
|
5010
4764
|
if (isNameColumn) {
|
|
5011
4765
|
const searchValue = identifierValue.trim().toLowerCase();
|
|
5012
4766
|
const itemName = (item.name || '').trim().toLowerCase();
|
|
5013
4767
|
matches = itemName === searchValue;
|
|
5014
|
-
console.log(` - Name comparison: "${itemName}" === "${searchValue}" = ${matches}`);
|
|
5015
4768
|
}
|
|
5016
4769
|
else {
|
|
5017
|
-
|
|
5018
|
-
console.log(` - Available column_values IDs:`, ((_15 = item.column_values) === null || _15 === void 0 ? void 0 : _15.map((cv) => `${cv.id} (type: ${cv.type})`).join(', ')) || 'none');
|
|
5019
|
-
const colValue = (_16 = item.column_values) === null || _16 === void 0 ? void 0 : _16.find((cv) => cv.id === identifierColumn);
|
|
4770
|
+
const colValue = (_10 = item.column_values) === null || _10 === void 0 ? void 0 : _10.find((cv) => cv.id === identifierColumn);
|
|
5020
4771
|
if (colValue) {
|
|
5021
4772
|
const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
|
|
5022
4773
|
const isStatusColumn = colValue.type === 'status';
|
|
@@ -5024,95 +4775,33 @@ class Worktables {
|
|
|
5024
4775
|
? (colValue.display_value || '').trim()
|
|
5025
4776
|
: (colValue.text || '').trim();
|
|
5026
4777
|
const searchValue = identifierValue.trim().toLowerCase();
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
const trimmedSearch = searchValue.trim();
|
|
5032
|
-
matches = trimmedCompare === trimmedSearch;
|
|
5033
|
-
console.log(` - Trimmed compare: "${trimmedCompare}" === "${trimmedSearch}" = ${matches}`);
|
|
5034
|
-
if (!matches && isStatusColumn) {
|
|
5035
|
-
const normalizedCompare = trimmedCompare.replace(/\s+/g, ' ').trim();
|
|
5036
|
-
const normalizedSearch = trimmedSearch.replace(/\s+/g, ' ').trim();
|
|
4778
|
+
matches = compareValue.toLowerCase() === searchValue;
|
|
4779
|
+
if (isStatusColumn && !matches) {
|
|
4780
|
+
const normalizedCompare = compareValue.toLowerCase().replace(/\s+/g, ' ').trim();
|
|
4781
|
+
const normalizedSearch = searchValue.replace(/\s+/g, ' ').trim();
|
|
5037
4782
|
matches = normalizedCompare === normalizedSearch;
|
|
5038
|
-
console.log(` - Normalized compare: "${normalizedCompare}" === "${normalizedSearch}" = ${matches}`);
|
|
5039
|
-
if (!matches) {
|
|
5040
|
-
matches = normalizedCompare.includes(normalizedSearch) || normalizedSearch.includes(normalizedCompare);
|
|
5041
|
-
console.log(` - Contains check: "${normalizedCompare}".includes("${normalizedSearch}") OR "${normalizedSearch}".includes("${normalizedCompare}") = ${matches}`);
|
|
5042
|
-
}
|
|
5043
|
-
}
|
|
5044
|
-
if (matches) {
|
|
5045
|
-
console.log(` ✓✓✓ MATCH FOUND! Item ${item.id}, column type: ${colValue.type}, value: "${compareValue}"`);
|
|
5046
4783
|
}
|
|
5047
|
-
else {
|
|
5048
|
-
console.log(` ❌ No match: item ${item.id}, column type: ${colValue.type}, compareValue: "${compareValue}", searchValue: "${identifierValue}"`);
|
|
5049
|
-
}
|
|
5050
|
-
}
|
|
5051
|
-
else {
|
|
5052
|
-
console.log(` ⚠⚠⚠ Column value not found for item ${item.id}`);
|
|
5053
|
-
console.log(` - Looking for column ID: "${identifierColumn}"`);
|
|
5054
|
-
console.log(` - Available column_values:`, ((_17 = item.column_values) === null || _17 === void 0 ? void 0 : _17.map((cv) => `ID:${cv.id} (type:${cv.type}, text:"${cv.text || 'N/A'}")`).join(' | ')) || 'none');
|
|
5055
|
-
console.log(` - This means the identifierColumn "${identifierColumn}" does not match any column ID in this item!`);
|
|
5056
4784
|
}
|
|
5057
4785
|
}
|
|
5058
4786
|
if (matches) {
|
|
5059
4787
|
foundItemId = item.id;
|
|
5060
4788
|
if (isSubitem) {
|
|
5061
4789
|
foundItemBoardId = searchBoardId;
|
|
5062
|
-
console.log(
|
|
4790
|
+
console.log(`✓ Found subitem with ID: ${foundItemId}, board_id: ${foundItemBoardId}`);
|
|
5063
4791
|
}
|
|
5064
4792
|
else {
|
|
5065
|
-
console.log(
|
|
4793
|
+
console.log(`✓ Found item with ID: ${foundItemId}`);
|
|
5066
4794
|
}
|
|
5067
4795
|
break;
|
|
5068
4796
|
}
|
|
5069
|
-
else {
|
|
5070
|
-
console.log(` ✗ No match for item ${item.id}`);
|
|
5071
|
-
}
|
|
5072
|
-
}
|
|
5073
|
-
if (!foundItemId) {
|
|
5074
|
-
console.log(` ❌❌❌ No exact match found for identifier column "${identifierColumn}" with value "${identifierValue}"`);
|
|
5075
|
-
const uniqueValues = new Set();
|
|
5076
|
-
items.forEach((item) => {
|
|
5077
|
-
var _a;
|
|
5078
|
-
if (!isNameColumn) {
|
|
5079
|
-
const colValue = (_a = item.column_values) === null || _a === void 0 ? void 0 : _a.find((cv) => cv.id === identifierColumn);
|
|
5080
|
-
if (colValue) {
|
|
5081
|
-
const isBoardRelation = colValue.type === 'board_relation' || colValue.type === 'mirror';
|
|
5082
|
-
const value = isBoardRelation
|
|
5083
|
-
? (colValue.display_value || '').trim()
|
|
5084
|
-
: (colValue.text || '').trim();
|
|
5085
|
-
if (value) {
|
|
5086
|
-
uniqueValues.add(value);
|
|
5087
|
-
}
|
|
5088
|
-
}
|
|
5089
|
-
}
|
|
5090
|
-
});
|
|
5091
|
-
if (uniqueValues.size > 0) {
|
|
5092
|
-
console.log(` 📊 Debug: Found ${uniqueValues.size} unique value(s) in column "${identifierColumn}":`);
|
|
5093
|
-
Array.from(uniqueValues).sort().forEach((val, idx) => {
|
|
5094
|
-
console.log(` ${idx + 1}. "${val}" (length: ${val.length}, raw: ${JSON.stringify(val)})`);
|
|
5095
|
-
});
|
|
5096
|
-
console.log(` 🔍 Searching for: "${identifierValue.trim()}" (length: ${identifierValue.trim().length}, raw: ${JSON.stringify(identifierValue)})`);
|
|
5097
|
-
}
|
|
5098
4797
|
}
|
|
5099
4798
|
}
|
|
5100
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
5101
|
-
console.log('📊 SEARCH RESULT:');
|
|
5102
|
-
console.log(' - foundItemId:', foundItemId || 'null (not found)');
|
|
5103
|
-
console.log(' - foundItemBoardId:', foundItemBoardId || 'null');
|
|
5104
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
5105
4799
|
if (foundItemId) {
|
|
5106
|
-
console.log(
|
|
4800
|
+
console.log(`Found existing ${isSubitem ? 'subitem' : 'item'}, updating:`, foundItemId);
|
|
5107
4801
|
const escapedColumnValues = (0, worktablesHelpers_1.escapeGraphQLJSONString)(column_values_object);
|
|
5108
4802
|
const updateBoardId = (isSubitem && foundItemBoardId) ? foundItemBoardId : boardId;
|
|
5109
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
5110
|
-
console.log('🔄 UPDATE OPERATION:');
|
|
5111
|
-
console.log(' - updateBoardId:', updateBoardId);
|
|
5112
|
-
console.log(' - foundItemId:', foundItemId);
|
|
5113
|
-
console.log(' - column_values_object:', JSON.stringify(column_values_object, null, 2));
|
|
5114
4803
|
if (isSubitem && !foundItemBoardId) {
|
|
5115
|
-
console.log(
|
|
4804
|
+
console.log(`⚠ Warning: Subitem board_id not found, using main board_id ${boardId}. This may cause errors.`);
|
|
5116
4805
|
}
|
|
5117
4806
|
mutation = `mutation {
|
|
5118
4807
|
change_multiple_column_values(
|
|
@@ -5128,8 +4817,7 @@ class Worktables {
|
|
|
5128
4817
|
}
|
|
5129
4818
|
}
|
|
5130
4819
|
}`;
|
|
5131
|
-
console.log('
|
|
5132
|
-
console.log(' - Sending update request...');
|
|
4820
|
+
console.log('Generated Update Mutation:', mutation);
|
|
5133
4821
|
response = await this.helpers.request({
|
|
5134
4822
|
method: 'POST',
|
|
5135
4823
|
url: 'https://api.monday.com/v2',
|
|
@@ -5137,7 +4825,6 @@ class Worktables {
|
|
|
5137
4825
|
body: { query: mutation },
|
|
5138
4826
|
});
|
|
5139
4827
|
const responseData = JSON.parse(response);
|
|
5140
|
-
console.log(' - Update response received:', JSON.stringify(responseData, null, 2));
|
|
5141
4828
|
if (!responseData.errors && responseData.data && responseData.data.change_multiple_column_values) {
|
|
5142
4829
|
const itemData = responseData.data.change_multiple_column_values;
|
|
5143
4830
|
if (itemData && itemData.id) {
|
|
@@ -5145,26 +4832,23 @@ class Worktables {
|
|
|
5145
4832
|
id: itemData.id,
|
|
5146
4833
|
url: itemData.url || '',
|
|
5147
4834
|
operation: 'update',
|
|
5148
|
-
board_id: ((
|
|
4835
|
+
board_id: ((_11 = itemData.board) === null || _11 === void 0 ? void 0 : _11.id) || boardId,
|
|
5149
4836
|
column_values: column_values_object,
|
|
5150
4837
|
};
|
|
5151
4838
|
itemUpdated = true;
|
|
5152
|
-
console.log(`
|
|
5153
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
4839
|
+
console.log(`Successfully updated ${isSubitem ? 'subitem' : 'item'}:`, itemData.id);
|
|
5154
4840
|
}
|
|
5155
4841
|
else {
|
|
5156
|
-
console.log(`
|
|
5157
|
-
console.log(' - itemData:', JSON.stringify(itemData, null, 2));
|
|
4842
|
+
console.log(`Update response missing item data, will create new ${isSubitem ? 'subitem' : 'item'} instead`);
|
|
5158
4843
|
itemUpdated = false;
|
|
5159
4844
|
}
|
|
5160
4845
|
}
|
|
5161
4846
|
else {
|
|
5162
4847
|
if (responseData.errors) {
|
|
5163
|
-
console.log('
|
|
4848
|
+
console.log('Error updating item:', JSON.stringify(responseData.errors));
|
|
5164
4849
|
}
|
|
5165
4850
|
else {
|
|
5166
|
-
console.log('
|
|
5167
|
-
console.log(' - responseData.data:', JSON.stringify(responseData.data, null, 2));
|
|
4851
|
+
console.log('Update response missing data, will create new item instead');
|
|
5168
4852
|
}
|
|
5169
4853
|
itemUpdated = false;
|
|
5170
4854
|
}
|
|
@@ -5178,15 +4862,11 @@ class Worktables {
|
|
|
5178
4862
|
}
|
|
5179
4863
|
}
|
|
5180
4864
|
else {
|
|
5181
|
-
console.log('
|
|
5182
|
-
console.log('ℹ️ No identifier provided, will create new item');
|
|
5183
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
4865
|
+
console.log('No identifier provided, will create new item');
|
|
5184
4866
|
itemUpdated = false;
|
|
5185
4867
|
}
|
|
5186
4868
|
if (!itemUpdated) {
|
|
5187
|
-
console.log('
|
|
5188
|
-
console.log(`➕ CREATING NEW ${isSubitem ? 'SUBITEM' : 'ITEM'}:`, itemName);
|
|
5189
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
4869
|
+
console.log(`Creating new ${isSubitem ? 'subitem' : 'item'}:`, itemName);
|
|
5190
4870
|
const parentId = this.getNodeParameter('parentId', 0, false);
|
|
5191
4871
|
if (isSubitem && !parentId) {
|
|
5192
4872
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
@@ -5230,8 +4910,6 @@ class Worktables {
|
|
|
5230
4910
|
}
|
|
5231
4911
|
}`;
|
|
5232
4912
|
}
|
|
5233
|
-
console.log(' - Generated Create Mutation:', mutation);
|
|
5234
|
-
console.log(' - Sending create request...');
|
|
5235
4913
|
response = await this.helpers.request({
|
|
5236
4914
|
method: 'POST',
|
|
5237
4915
|
url: 'https://api.monday.com/v2',
|
|
@@ -5239,30 +4917,25 @@ class Worktables {
|
|
|
5239
4917
|
body: { query: mutation },
|
|
5240
4918
|
});
|
|
5241
4919
|
const responseData = JSON.parse(response);
|
|
5242
|
-
console.log(' - Create response received:', JSON.stringify(responseData, null, 2));
|
|
5243
4920
|
if (responseData.errors) {
|
|
5244
|
-
console.log(' ❌ Error creating item:', JSON.stringify(responseData.errors, null, 2));
|
|
5245
4921
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5246
4922
|
message: `Error creating ${isSubitem ? 'subitem' : 'item'}: ${JSON.stringify(responseData.errors)}`,
|
|
5247
4923
|
});
|
|
5248
4924
|
}
|
|
5249
4925
|
const itemData = isSubitem && parentId
|
|
5250
|
-
? (
|
|
5251
|
-
: (
|
|
4926
|
+
? (_12 = responseData.data) === null || _12 === void 0 ? void 0 : _12.create_subitem
|
|
4927
|
+
: (_13 = responseData.data) === null || _13 === void 0 ? void 0 : _13.create_item;
|
|
5252
4928
|
if (!itemData || !itemData.id) {
|
|
5253
|
-
console.log(' ❌ No item data returned in response');
|
|
5254
4929
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5255
4930
|
message: `Error creating ${isSubitem ? 'subitem' : 'item'}: No item data returned`,
|
|
5256
4931
|
});
|
|
5257
4932
|
}
|
|
5258
|
-
console.log(` ✓✓✓ Successfully created ${isSubitem ? 'subitem' : 'item'}:`, itemData.id);
|
|
5259
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
5260
4933
|
formatted = {
|
|
5261
4934
|
id: itemData.id,
|
|
5262
4935
|
name: itemData.name || itemName,
|
|
5263
4936
|
url: itemData.url || '',
|
|
5264
4937
|
operation: 'create',
|
|
5265
|
-
board_id: ((
|
|
4938
|
+
board_id: ((_14 = itemData.board) === null || _14 === void 0 ? void 0 : _14.id) || boardId,
|
|
5266
4939
|
column_values: column_values_object,
|
|
5267
4940
|
};
|
|
5268
4941
|
if (isSubitem && parentId) {
|
|
@@ -5303,12 +4976,12 @@ class Worktables {
|
|
|
5303
4976
|
if (itemParsed.errors) {
|
|
5304
4977
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(itemParsed.errors) });
|
|
5305
4978
|
}
|
|
5306
|
-
const items = ((
|
|
4979
|
+
const items = ((_15 = itemParsed === null || itemParsed === void 0 ? void 0 : itemParsed.data) === null || _15 === void 0 ? void 0 : _15.items) || [];
|
|
5307
4980
|
if (items.length === 0) {
|
|
5308
4981
|
return [[{ json: { item_id: itemId, activity_logs: [] } }]];
|
|
5309
4982
|
}
|
|
5310
4983
|
const item = items[0];
|
|
5311
|
-
const boardId = (
|
|
4984
|
+
const boardId = (_16 = item.board) === null || _16 === void 0 ? void 0 : _16.id;
|
|
5312
4985
|
if (!boardId) {
|
|
5313
4986
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Could not retrieve board ID for the item.' });
|
|
5314
4987
|
}
|
|
@@ -5346,7 +5019,7 @@ class Worktables {
|
|
|
5346
5019
|
if (parsed.errors) {
|
|
5347
5020
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: JSON.stringify(parsed.errors) });
|
|
5348
5021
|
}
|
|
5349
|
-
const boards = ((
|
|
5022
|
+
const boards = ((_17 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _17 === void 0 ? void 0 : _17.boards) || [];
|
|
5350
5023
|
const activityLogs = boards.length > 0 ? (boards[0].activity_logs || []) : [];
|
|
5351
5024
|
const formatted = {
|
|
5352
5025
|
item_id: item.id,
|
|
@@ -5505,7 +5178,7 @@ class Worktables {
|
|
|
5505
5178
|
body: { query },
|
|
5506
5179
|
});
|
|
5507
5180
|
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
5508
|
-
const itemsPage = (
|
|
5181
|
+
const itemsPage = (_20 = (_19 = (_18 = parsed === null || parsed === void 0 ? void 0 : parsed.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;
|
|
5509
5182
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5510
5183
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
5511
5184
|
allItems = allItems.concat(items);
|
|
@@ -5584,7 +5257,7 @@ class Worktables {
|
|
|
5584
5257
|
const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
|
|
5585
5258
|
const logicalOperator = this.getNodeParameter('logicalOperator', 0);
|
|
5586
5259
|
let rulesArray = [];
|
|
5587
|
-
if (((
|
|
5260
|
+
if (((_21 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _21 === void 0 ? void 0 : _21.length) > 0) {
|
|
5588
5261
|
rulesArray = filterRules.rule.map((rule) => {
|
|
5589
5262
|
let formattedValue;
|
|
5590
5263
|
if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
|
|
@@ -5628,7 +5301,7 @@ class Worktables {
|
|
|
5628
5301
|
});
|
|
5629
5302
|
}
|
|
5630
5303
|
const orderByArray = [];
|
|
5631
|
-
if (((
|
|
5304
|
+
if (((_22 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _22 === void 0 ? void 0 : _22.length) > 0) {
|
|
5632
5305
|
sortOptions.sortBy.forEach((sort) => {
|
|
5633
5306
|
orderByArray.push(`{
|
|
5634
5307
|
column_id: "${sort.columnId}",
|
|
@@ -5684,7 +5357,7 @@ class Worktables {
|
|
|
5684
5357
|
body: { query },
|
|
5685
5358
|
});
|
|
5686
5359
|
const parsed = JSON.parse(rawResponse);
|
|
5687
|
-
const items = ((
|
|
5360
|
+
const items = ((_26 = (_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) === null || _26 === void 0 ? void 0 : _26.items) || [];
|
|
5688
5361
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
5689
5362
|
const formatted = {
|
|
5690
5363
|
id: item.id,
|
|
@@ -5718,7 +5391,7 @@ class Worktables {
|
|
|
5718
5391
|
const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
|
|
5719
5392
|
const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
|
|
5720
5393
|
let rulesArray = [];
|
|
5721
|
-
if (((
|
|
5394
|
+
if (((_27 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _27 === void 0 ? void 0 : _27.length) > 0) {
|
|
5722
5395
|
console.log('Processing filter rules:', advancedFilterRules.rule);
|
|
5723
5396
|
rulesArray = advancedFilterRules.rule.map((rule) => {
|
|
5724
5397
|
let formattedValue;
|
|
@@ -5934,7 +5607,7 @@ class Worktables {
|
|
|
5934
5607
|
});
|
|
5935
5608
|
}
|
|
5936
5609
|
const orderByArray = [];
|
|
5937
|
-
if (((
|
|
5610
|
+
if (((_28 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _28 === void 0 ? void 0 : _28.length) > 0) {
|
|
5938
5611
|
advancedSortOptions.sortBy.forEach((sort) => {
|
|
5939
5612
|
orderByArray.push(`{
|
|
5940
5613
|
column_id: "${sort.columnId}",
|
|
@@ -6016,7 +5689,7 @@ class Worktables {
|
|
|
6016
5689
|
body: { query: testQuery },
|
|
6017
5690
|
});
|
|
6018
5691
|
const testParsed = JSON.parse(testResponse);
|
|
6019
|
-
const testItems = ((
|
|
5692
|
+
const testItems = ((_32 = (_31 = (_30 = (_29 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.data) === null || _29 === void 0 ? void 0 : _29.boards) === null || _30 === void 0 ? void 0 : _30[0]) === null || _31 === void 0 ? void 0 : _31.items_page) === null || _32 === void 0 ? void 0 : _32.items) || [];
|
|
6020
5693
|
console.log('Test - Items in board (no filters):', testItems.length);
|
|
6021
5694
|
if (testItems.length > 0) {
|
|
6022
5695
|
console.log('Sample item column values:', testItems[0].column_values);
|
|
@@ -6028,7 +5701,7 @@ class Worktables {
|
|
|
6028
5701
|
body: { query },
|
|
6029
5702
|
});
|
|
6030
5703
|
const parsed = JSON.parse(rawResponse);
|
|
6031
|
-
const itemsPage = (
|
|
5704
|
+
const itemsPage = (_35 = (_34 = (_33 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _33 === void 0 ? void 0 : _33.boards) === null || _34 === void 0 ? void 0 : _34[0]) === null || _35 === void 0 ? void 0 : _35.items_page;
|
|
6032
5705
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
6033
5706
|
const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
|
|
6034
5707
|
const hasMore = nextCursor ? true : false;
|
|
@@ -6210,7 +5883,7 @@ class Worktables {
|
|
|
6210
5883
|
body: { query },
|
|
6211
5884
|
});
|
|
6212
5885
|
const parsed = JSON.parse(rawResponse);
|
|
6213
|
-
const itemsPage = (
|
|
5886
|
+
const itemsPage = (_40 = (_39 = (_38 = (_37 = (_36 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _36 === void 0 ? void 0 : _36.boards) === null || _37 === void 0 ? void 0 : _37[0]) === null || _38 === void 0 ? void 0 : _38.groups) === null || _39 === void 0 ? void 0 : _39[0]) === null || _40 === void 0 ? void 0 : _40.items_page;
|
|
6214
5887
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
6215
5888
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
6216
5889
|
allItems = allItems.concat(items);
|
|
@@ -6307,7 +5980,7 @@ class Worktables {
|
|
|
6307
5980
|
response = await (0, isErrorResponse_1.parseApiResponse)(response);
|
|
6308
5981
|
if (response.success) {
|
|
6309
5982
|
const parsed = JSON.parse(response.data);
|
|
6310
|
-
const updates = ((
|
|
5983
|
+
const updates = ((_43 = (_42 = (_41 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _41 === void 0 ? void 0 : _41.items) === null || _42 === void 0 ? void 0 : _42[0]) === null || _43 === void 0 ? void 0 : _43.updates) || [];
|
|
6311
5984
|
const formattedUpdates = updates.map((update) => {
|
|
6312
5985
|
const pinnedToTop = update.pinned_to_top || [];
|
|
6313
5986
|
const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
|
|
@@ -6372,7 +6045,7 @@ class Worktables {
|
|
|
6372
6045
|
console.log('variables:', variables);
|
|
6373
6046
|
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
6374
6047
|
console.log('Create Update Result:', JSON.stringify(response, null, 2));
|
|
6375
|
-
const updateId = (
|
|
6048
|
+
const updateId = (_45 = (_44 = JSON.parse(response).data) === null || _44 === void 0 ? void 0 : _44.create_update) === null || _45 === void 0 ? void 0 : _45.id;
|
|
6376
6049
|
if (!updateId) {
|
|
6377
6050
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6378
6051
|
message: 'Error creating update: Update not created, no ID returned',
|
|
@@ -6681,7 +6354,7 @@ class Worktables {
|
|
|
6681
6354
|
body: { query },
|
|
6682
6355
|
json: true,
|
|
6683
6356
|
});
|
|
6684
|
-
const asset = (
|
|
6357
|
+
const asset = (_47 = (_46 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _46 === void 0 ? void 0 : _46.assets) === null || _47 === void 0 ? void 0 : _47[0];
|
|
6685
6358
|
if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
|
|
6686
6359
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
6687
6360
|
message: 'Public URL not found for the given file ID.',
|