@worktables/n8n-nodes-worktables 12.2.19 → 12.2.20
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.
|
@@ -2809,7 +2809,7 @@ class Worktables {
|
|
|
2809
2809
|
};
|
|
2810
2810
|
}
|
|
2811
2811
|
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;
|
|
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;
|
|
2813
2813
|
const resource = this.getNodeParameter('resource', 0);
|
|
2814
2814
|
const operation = this.getNodeParameter('operation', 0);
|
|
2815
2815
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
@@ -4336,8 +4336,10 @@ class Worktables {
|
|
|
4336
4336
|
items_page(limit: 100${cursorParam}) {
|
|
4337
4337
|
items {
|
|
4338
4338
|
id
|
|
4339
|
+
name
|
|
4339
4340
|
subitems {
|
|
4340
4341
|
id
|
|
4342
|
+
name
|
|
4341
4343
|
column_values(ids: ["${identifierColumn}"]) {
|
|
4342
4344
|
id
|
|
4343
4345
|
text
|
|
@@ -4354,6 +4356,7 @@ class Worktables {
|
|
|
4354
4356
|
items_page(limit: 100${cursorParam}) {
|
|
4355
4357
|
items {
|
|
4356
4358
|
id
|
|
4359
|
+
name
|
|
4357
4360
|
column_values(ids: ["${identifierColumn}"]) {
|
|
4358
4361
|
id
|
|
4359
4362
|
text
|
|
@@ -4374,29 +4377,38 @@ class Worktables {
|
|
|
4374
4377
|
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;
|
|
4375
4378
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
4376
4379
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
4380
|
+
const isNameColumn = identifierColumn === 'name' || identifierColumn.toLowerCase() === 'name';
|
|
4377
4381
|
if (isSubitem) {
|
|
4378
4382
|
for (const item of items) {
|
|
4379
4383
|
if (item.subitems && Array.isArray(item.subitems)) {
|
|
4380
4384
|
for (const subitem of item.subitems) {
|
|
4381
|
-
|
|
4382
|
-
if (
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4385
|
+
let matches = false;
|
|
4386
|
+
if (isNameColumn) {
|
|
4387
|
+
matches = subitem.name === identifierValue ||
|
|
4388
|
+
((_0 = subitem.name) === null || _0 === void 0 ? void 0 : _0.trim()) === identifierValue.trim();
|
|
4389
|
+
}
|
|
4390
|
+
else {
|
|
4391
|
+
const colValue = (_1 = subitem.column_values) === null || _1 === void 0 ? void 0 : _1.find((cv) => cv.id === identifierColumn);
|
|
4392
|
+
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
|
+
}
|
|
4389
4400
|
}
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
colText.trim() === identifierValue.trim() || colValueStr.trim() === identifierValue.trim()) {
|
|
4396
|
-
foundItemId = subitem.id;
|
|
4397
|
-
break;
|
|
4401
|
+
catch {
|
|
4402
|
+
colValueStr = colValue.value || '';
|
|
4403
|
+
}
|
|
4404
|
+
matches = colText === identifierValue || colValueStr === identifierValue ||
|
|
4405
|
+
colText.trim() === identifierValue.trim() || colValueStr.trim() === identifierValue.trim();
|
|
4398
4406
|
}
|
|
4399
4407
|
}
|
|
4408
|
+
if (matches) {
|
|
4409
|
+
foundItemId = subitem.id;
|
|
4410
|
+
break;
|
|
4411
|
+
}
|
|
4400
4412
|
}
|
|
4401
4413
|
if (foundItemId)
|
|
4402
4414
|
break;
|
|
@@ -4405,24 +4417,32 @@ class Worktables {
|
|
|
4405
4417
|
}
|
|
4406
4418
|
else {
|
|
4407
4419
|
for (const item of items) {
|
|
4408
|
-
|
|
4409
|
-
if (
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4420
|
+
let matches = false;
|
|
4421
|
+
if (isNameColumn) {
|
|
4422
|
+
matches = item.name === identifierValue ||
|
|
4423
|
+
((_2 = item.name) === null || _2 === void 0 ? void 0 : _2.trim()) === identifierValue.trim();
|
|
4424
|
+
}
|
|
4425
|
+
else {
|
|
4426
|
+
const colValue = (_3 = item.column_values) === null || _3 === void 0 ? void 0 : _3.find((cv) => cv.id === identifierColumn);
|
|
4427
|
+
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
|
+
}
|
|
4416
4435
|
}
|
|
4436
|
+
catch {
|
|
4437
|
+
colValueStr = colValue.value || '';
|
|
4438
|
+
}
|
|
4439
|
+
matches = colText === identifierValue || colValueStr === identifierValue ||
|
|
4440
|
+
colText.trim() === identifierValue.trim() || colValueStr.trim() === identifierValue.trim();
|
|
4417
4441
|
}
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
colText.trim() === identifierValue.trim() || colValueStr.trim() === identifierValue.trim()) {
|
|
4423
|
-
foundItemId = item.id;
|
|
4424
|
-
break;
|
|
4425
|
-
}
|
|
4442
|
+
}
|
|
4443
|
+
if (matches) {
|
|
4444
|
+
foundItemId = item.id;
|
|
4445
|
+
break;
|
|
4426
4446
|
}
|
|
4427
4447
|
}
|
|
4428
4448
|
}
|
|
@@ -4458,22 +4478,38 @@ class Worktables {
|
|
|
4458
4478
|
if (itemData && itemData.id) {
|
|
4459
4479
|
formatted = {
|
|
4460
4480
|
id: itemData.id,
|
|
4461
|
-
url: itemData.url,
|
|
4481
|
+
url: itemData.url || '',
|
|
4462
4482
|
operation: 'update',
|
|
4463
|
-
board_id: itemData.board.id,
|
|
4483
|
+
board_id: ((_4 = itemData.board) === null || _4 === void 0 ? void 0 : _4.id) || boardId,
|
|
4464
4484
|
column_values: column_values_object,
|
|
4465
4485
|
};
|
|
4466
4486
|
itemUpdated = true;
|
|
4487
|
+
console.log(`Successfully updated ${isSubitem ? 'subitem' : 'item'}:`, itemData.id);
|
|
4488
|
+
}
|
|
4489
|
+
else {
|
|
4490
|
+
console.log(`Update response missing item data, will create new ${isSubitem ? 'subitem' : 'item'} instead`);
|
|
4491
|
+
itemUpdated = false;
|
|
4467
4492
|
}
|
|
4468
4493
|
}
|
|
4469
|
-
|
|
4470
|
-
|
|
4494
|
+
else {
|
|
4495
|
+
if (responseData.errors) {
|
|
4496
|
+
console.log('Error updating item:', JSON.stringify(responseData.errors));
|
|
4497
|
+
}
|
|
4498
|
+
else {
|
|
4499
|
+
console.log('Update response missing data, will create new item instead');
|
|
4500
|
+
}
|
|
4501
|
+
itemUpdated = false;
|
|
4471
4502
|
}
|
|
4472
4503
|
}
|
|
4473
4504
|
else {
|
|
4474
|
-
console.log(`${isSubitem ? 'Subitem' : 'Item'} not found with identifier value, will create new ${isSubitem ? 'subitem' : 'item'}`);
|
|
4505
|
+
console.log(`${isSubitem ? 'Subitem' : 'Item'} not found with identifier value "${identifierValue}", will create new ${isSubitem ? 'subitem' : 'item'}`);
|
|
4506
|
+
itemUpdated = false;
|
|
4475
4507
|
}
|
|
4476
4508
|
}
|
|
4509
|
+
else {
|
|
4510
|
+
console.log('No identifier provided, will create new item');
|
|
4511
|
+
itemUpdated = false;
|
|
4512
|
+
}
|
|
4477
4513
|
if (!itemUpdated) {
|
|
4478
4514
|
console.log(`Creating new ${isSubitem ? 'subitem' : 'item'}:`, itemName);
|
|
4479
4515
|
const parentId = this.getNodeParameter('parentId', 0, false);
|
|
@@ -4521,15 +4557,25 @@ class Worktables {
|
|
|
4521
4557
|
body: { query: mutation },
|
|
4522
4558
|
});
|
|
4523
4559
|
const responseData = JSON.parse(response);
|
|
4560
|
+
if (responseData.errors) {
|
|
4561
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
4562
|
+
message: `Error creating ${isSubitem ? 'subitem' : 'item'}: ${JSON.stringify(responseData.errors)}`,
|
|
4563
|
+
});
|
|
4564
|
+
}
|
|
4524
4565
|
const itemData = isSubitem && parentId
|
|
4525
|
-
? responseData.data.create_subitem
|
|
4526
|
-
: responseData.data.create_item;
|
|
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;
|
|
4568
|
+
if (!itemData || !itemData.id) {
|
|
4569
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
4570
|
+
message: `Error creating ${isSubitem ? 'subitem' : 'item'}: No item data returned`,
|
|
4571
|
+
});
|
|
4572
|
+
}
|
|
4527
4573
|
formatted = {
|
|
4528
4574
|
id: itemData.id,
|
|
4529
|
-
name: itemData.name,
|
|
4530
|
-
url: itemData.url,
|
|
4575
|
+
name: itemData.name || itemName,
|
|
4576
|
+
url: itemData.url || '',
|
|
4531
4577
|
operation: 'create',
|
|
4532
|
-
board_id: itemData.board.id,
|
|
4578
|
+
board_id: ((_7 = itemData.board) === null || _7 === void 0 ? void 0 : _7.id) || boardId,
|
|
4533
4579
|
column_values: column_values_object,
|
|
4534
4580
|
};
|
|
4535
4581
|
if (isSubitem && parentId) {
|
|
@@ -4668,7 +4714,7 @@ class Worktables {
|
|
|
4668
4714
|
body: { query },
|
|
4669
4715
|
});
|
|
4670
4716
|
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
4671
|
-
const itemsPage = (
|
|
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;
|
|
4672
4718
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
4673
4719
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
4674
4720
|
allItems = allItems.concat(items);
|
|
@@ -4748,7 +4794,7 @@ class Worktables {
|
|
|
4748
4794
|
const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
|
|
4749
4795
|
const logicalOperator = this.getNodeParameter('logicalOperator', 0);
|
|
4750
4796
|
let rulesArray = [];
|
|
4751
|
-
if (((
|
|
4797
|
+
if (((_11 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _11 === void 0 ? void 0 : _11.length) > 0) {
|
|
4752
4798
|
rulesArray = filterRules.rule.map((rule) => {
|
|
4753
4799
|
let formattedValue;
|
|
4754
4800
|
if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
|
|
@@ -4792,7 +4838,7 @@ class Worktables {
|
|
|
4792
4838
|
});
|
|
4793
4839
|
}
|
|
4794
4840
|
const orderByArray = [];
|
|
4795
|
-
if (((
|
|
4841
|
+
if (((_12 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _12 === void 0 ? void 0 : _12.length) > 0) {
|
|
4796
4842
|
sortOptions.sortBy.forEach((sort) => {
|
|
4797
4843
|
orderByArray.push(`{
|
|
4798
4844
|
column_id: "${sort.columnId}",
|
|
@@ -4838,7 +4884,7 @@ class Worktables {
|
|
|
4838
4884
|
body: { query },
|
|
4839
4885
|
});
|
|
4840
4886
|
const parsed = JSON.parse(rawResponse);
|
|
4841
|
-
const items = ((
|
|
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) || [];
|
|
4842
4888
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
4843
4889
|
const formatted = {
|
|
4844
4890
|
id: item.id,
|
|
@@ -4872,7 +4918,7 @@ class Worktables {
|
|
|
4872
4918
|
const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
|
|
4873
4919
|
const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
|
|
4874
4920
|
let rulesArray = [];
|
|
4875
|
-
if (((
|
|
4921
|
+
if (((_17 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _17 === void 0 ? void 0 : _17.length) > 0) {
|
|
4876
4922
|
console.log('Processing filter rules:', advancedFilterRules.rule);
|
|
4877
4923
|
rulesArray = advancedFilterRules.rule.map((rule) => {
|
|
4878
4924
|
let formattedValue;
|
|
@@ -5088,7 +5134,7 @@ class Worktables {
|
|
|
5088
5134
|
});
|
|
5089
5135
|
}
|
|
5090
5136
|
const orderByArray = [];
|
|
5091
|
-
if (((
|
|
5137
|
+
if (((_18 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _18 === void 0 ? void 0 : _18.length) > 0) {
|
|
5092
5138
|
advancedSortOptions.sortBy.forEach((sort) => {
|
|
5093
5139
|
orderByArray.push(`{
|
|
5094
5140
|
column_id: "${sort.columnId}",
|
|
@@ -5160,7 +5206,7 @@ class Worktables {
|
|
|
5160
5206
|
body: { query: testQuery },
|
|
5161
5207
|
});
|
|
5162
5208
|
const testParsed = JSON.parse(testResponse);
|
|
5163
|
-
const testItems = ((
|
|
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) || [];
|
|
5164
5210
|
console.log('Test - Items in board (no filters):', testItems.length);
|
|
5165
5211
|
if (testItems.length > 0) {
|
|
5166
5212
|
console.log('Sample item column values:', testItems[0].column_values);
|
|
@@ -5172,7 +5218,7 @@ class Worktables {
|
|
|
5172
5218
|
body: { query },
|
|
5173
5219
|
});
|
|
5174
5220
|
const parsed = JSON.parse(rawResponse);
|
|
5175
|
-
const itemsPage = (
|
|
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;
|
|
5176
5222
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5177
5223
|
const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
|
|
5178
5224
|
const hasMore = nextCursor ? true : false;
|
|
@@ -5330,7 +5376,7 @@ class Worktables {
|
|
|
5330
5376
|
body: { query },
|
|
5331
5377
|
});
|
|
5332
5378
|
const parsed = JSON.parse(rawResponse);
|
|
5333
|
-
const items = ((
|
|
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) || [];
|
|
5334
5380
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
5335
5381
|
const columnValues = item.column_values || [];
|
|
5336
5382
|
const formatted = {
|
|
@@ -5420,7 +5466,7 @@ class Worktables {
|
|
|
5420
5466
|
response = await (0, isErrorResponse_1.parseApiResponse)(response);
|
|
5421
5467
|
if (response.success) {
|
|
5422
5468
|
const parsed = JSON.parse(response.data);
|
|
5423
|
-
const updates = ((
|
|
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) || [];
|
|
5424
5470
|
const formattedUpdates = updates.map((update) => {
|
|
5425
5471
|
const pinnedToTop = update.pinned_to_top || [];
|
|
5426
5472
|
const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
|
|
@@ -5485,7 +5531,7 @@ class Worktables {
|
|
|
5485
5531
|
console.log('variables:', variables);
|
|
5486
5532
|
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
5487
5533
|
console.log('Create Update Result:', JSON.stringify(response, null, 2));
|
|
5488
|
-
const updateId = (
|
|
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;
|
|
5489
5535
|
if (!updateId) {
|
|
5490
5536
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5491
5537
|
message: 'Error creating update: Update not created, no ID returned',
|
|
@@ -5791,7 +5837,7 @@ class Worktables {
|
|
|
5791
5837
|
body: { query },
|
|
5792
5838
|
json: true,
|
|
5793
5839
|
});
|
|
5794
|
-
const asset = (
|
|
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];
|
|
5795
5841
|
if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
|
|
5796
5842
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5797
5843
|
message: 'Public URL not found for the given file ID.',
|