@worktables/n8n-nodes-worktables 12.2.18 → 12.2.19
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;
|
|
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;
|
|
2813
2813
|
const resource = this.getNodeParameter('resource', 0);
|
|
2814
2814
|
const operation = this.getNodeParameter('operation', 0);
|
|
2815
2815
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
@@ -4325,26 +4325,45 @@ class Worktables {
|
|
|
4325
4325
|
let itemUpdated = false;
|
|
4326
4326
|
let foundItemId = null;
|
|
4327
4327
|
if (identifierValue && identifierValue.trim() !== '' && identifierColumn && identifierColumn.trim() !== '') {
|
|
4328
|
-
console.log('Searching for item with identifier column:', identifierColumn, 'value:', identifierValue);
|
|
4328
|
+
console.log('Searching for item/subitem with identifier column:', identifierColumn, 'value:', identifierValue, 'isSubitem:', isSubitem);
|
|
4329
4329
|
let cursor = null;
|
|
4330
4330
|
let hasMore = true;
|
|
4331
4331
|
while (hasMore && !foundItemId) {
|
|
4332
4332
|
const cursorParam = cursor ? `, cursor: "${cursor}"` : '';
|
|
4333
|
-
const searchQuery =
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
column_values(ids: ["${identifierColumn}"]) {
|
|
4333
|
+
const searchQuery = isSubitem
|
|
4334
|
+
? `query {
|
|
4335
|
+
boards(ids: [${boardId}]) {
|
|
4336
|
+
items_page(limit: 100${cursorParam}) {
|
|
4337
|
+
items {
|
|
4339
4338
|
id
|
|
4340
|
-
|
|
4341
|
-
|
|
4339
|
+
subitems {
|
|
4340
|
+
id
|
|
4341
|
+
column_values(ids: ["${identifierColumn}"]) {
|
|
4342
|
+
id
|
|
4343
|
+
text
|
|
4344
|
+
value
|
|
4345
|
+
}
|
|
4346
|
+
}
|
|
4342
4347
|
}
|
|
4348
|
+
cursor
|
|
4343
4349
|
}
|
|
4344
|
-
cursor
|
|
4345
4350
|
}
|
|
4346
|
-
}
|
|
4347
|
-
|
|
4351
|
+
}`
|
|
4352
|
+
: `query {
|
|
4353
|
+
boards(ids: [${boardId}]) {
|
|
4354
|
+
items_page(limit: 100${cursorParam}) {
|
|
4355
|
+
items {
|
|
4356
|
+
id
|
|
4357
|
+
column_values(ids: ["${identifierColumn}"]) {
|
|
4358
|
+
id
|
|
4359
|
+
text
|
|
4360
|
+
value
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
cursor
|
|
4364
|
+
}
|
|
4365
|
+
}
|
|
4366
|
+
}`;
|
|
4348
4367
|
const searchResponse = await this.helpers.request({
|
|
4349
4368
|
method: 'POST',
|
|
4350
4369
|
url: 'https://api.monday.com/v2',
|
|
@@ -4355,31 +4374,62 @@ class Worktables {
|
|
|
4355
4374
|
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;
|
|
4356
4375
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
4357
4376
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4377
|
+
if (isSubitem) {
|
|
4378
|
+
for (const item of items) {
|
|
4379
|
+
if (item.subitems && Array.isArray(item.subitems)) {
|
|
4380
|
+
for (const subitem of item.subitems) {
|
|
4381
|
+
const colValue = (_0 = subitem.column_values) === null || _0 === void 0 ? void 0 : _0.find((cv) => cv.id === identifierColumn);
|
|
4382
|
+
if (colValue) {
|
|
4383
|
+
let colText = colValue.text || '';
|
|
4384
|
+
let colValueStr = '';
|
|
4385
|
+
try {
|
|
4386
|
+
if (colValue.value) {
|
|
4387
|
+
const parsedValue = JSON.parse(colValue.value);
|
|
4388
|
+
colValueStr = (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.text) || (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.value) || String(parsedValue);
|
|
4389
|
+
}
|
|
4390
|
+
}
|
|
4391
|
+
catch {
|
|
4392
|
+
colValueStr = colValue.value || '';
|
|
4393
|
+
}
|
|
4394
|
+
if (colText === identifierValue || colValueStr === identifierValue ||
|
|
4395
|
+
colText.trim() === identifierValue.trim() || colValueStr.trim() === identifierValue.trim()) {
|
|
4396
|
+
foundItemId = subitem.id;
|
|
4397
|
+
break;
|
|
4398
|
+
}
|
|
4399
|
+
}
|
|
4367
4400
|
}
|
|
4401
|
+
if (foundItemId)
|
|
4402
|
+
break;
|
|
4368
4403
|
}
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4404
|
+
}
|
|
4405
|
+
}
|
|
4406
|
+
else {
|
|
4407
|
+
for (const item of items) {
|
|
4408
|
+
const colValue = (_1 = item.column_values) === null || _1 === void 0 ? void 0 : _1.find((cv) => cv.id === identifierColumn);
|
|
4409
|
+
if (colValue) {
|
|
4410
|
+
let colText = colValue.text || '';
|
|
4411
|
+
let colValueStr = '';
|
|
4412
|
+
try {
|
|
4413
|
+
if (colValue.value) {
|
|
4414
|
+
const parsedValue = JSON.parse(colValue.value);
|
|
4415
|
+
colValueStr = (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.text) || (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.value) || String(parsedValue);
|
|
4416
|
+
}
|
|
4417
|
+
}
|
|
4418
|
+
catch {
|
|
4419
|
+
colValueStr = colValue.value || '';
|
|
4420
|
+
}
|
|
4421
|
+
if (colText === identifierValue || colValueStr === identifierValue ||
|
|
4422
|
+
colText.trim() === identifierValue.trim() || colValueStr.trim() === identifierValue.trim()) {
|
|
4423
|
+
foundItemId = item.id;
|
|
4424
|
+
break;
|
|
4425
|
+
}
|
|
4376
4426
|
}
|
|
4377
4427
|
}
|
|
4378
4428
|
}
|
|
4379
4429
|
hasMore = cursor !== null && items.length > 0 && !foundItemId;
|
|
4380
4430
|
}
|
|
4381
4431
|
if (foundItemId) {
|
|
4382
|
-
console.log(
|
|
4432
|
+
console.log(`Found existing ${isSubitem ? 'subitem' : 'item'}, updating:`, foundItemId);
|
|
4383
4433
|
const escapedColumnValues = (0, worktablesHelpers_1.escapeGraphQLJSONString)(column_values_object);
|
|
4384
4434
|
mutation = `mutation {
|
|
4385
4435
|
change_multiple_column_values(
|
|
@@ -4417,19 +4467,18 @@ class Worktables {
|
|
|
4417
4467
|
}
|
|
4418
4468
|
}
|
|
4419
4469
|
if (!itemUpdated) {
|
|
4420
|
-
console.log(
|
|
4470
|
+
console.log(`Error updating ${isSubitem ? 'subitem' : 'item'}, creating new ${isSubitem ? 'subitem' : 'item'} instead`);
|
|
4421
4471
|
}
|
|
4422
4472
|
}
|
|
4423
4473
|
else {
|
|
4424
|
-
console.log('Item not found with identifier value, will create new item');
|
|
4474
|
+
console.log(`${isSubitem ? 'Subitem' : 'Item'} not found with identifier value, will create new ${isSubitem ? 'subitem' : 'item'}`);
|
|
4425
4475
|
}
|
|
4426
4476
|
}
|
|
4427
4477
|
if (!itemUpdated) {
|
|
4428
|
-
console.log(
|
|
4478
|
+
console.log(`Creating new ${isSubitem ? 'subitem' : 'item'}:`, itemName);
|
|
4429
4479
|
const parentId = this.getNodeParameter('parentId', 0, false);
|
|
4430
4480
|
const escapedItemName = (0, worktablesHelpers_1.escapeGraphQLString)(itemName);
|
|
4431
4481
|
const escapedColumnValues = (0, worktablesHelpers_1.escapeGraphQLJSONString)(column_values_object);
|
|
4432
|
-
const escapedGroupName = groupName ? (0, worktablesHelpers_1.escapeGraphQLString)(groupName) : '';
|
|
4433
4482
|
if (isSubitem && parentId) {
|
|
4434
4483
|
mutation = `mutation {
|
|
4435
4484
|
create_subitem(
|
|
@@ -4447,11 +4496,12 @@ class Worktables {
|
|
|
4447
4496
|
}`;
|
|
4448
4497
|
}
|
|
4449
4498
|
else {
|
|
4450
|
-
const
|
|
4499
|
+
const finalGroupId = groupName || 'topics';
|
|
4500
|
+
const escapedFinalGroupId = (0, worktablesHelpers_1.escapeGraphQLString)(finalGroupId);
|
|
4451
4501
|
mutation = `mutation {
|
|
4452
4502
|
create_item(
|
|
4453
4503
|
board_id: ${boardId},
|
|
4454
|
-
${
|
|
4504
|
+
group_id: "${escapedFinalGroupId}",
|
|
4455
4505
|
item_name: "${escapedItemName}",
|
|
4456
4506
|
column_values: "${escapedColumnValues}"
|
|
4457
4507
|
) {
|
|
@@ -4618,7 +4668,7 @@ class Worktables {
|
|
|
4618
4668
|
body: { query },
|
|
4619
4669
|
});
|
|
4620
4670
|
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
4621
|
-
const itemsPage = (
|
|
4671
|
+
const itemsPage = (_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;
|
|
4622
4672
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
4623
4673
|
cursor = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor) || null;
|
|
4624
4674
|
allItems = allItems.concat(items);
|
|
@@ -4698,7 +4748,7 @@ class Worktables {
|
|
|
4698
4748
|
const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
|
|
4699
4749
|
const logicalOperator = this.getNodeParameter('logicalOperator', 0);
|
|
4700
4750
|
let rulesArray = [];
|
|
4701
|
-
if (((
|
|
4751
|
+
if (((_5 = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _5 === void 0 ? void 0 : _5.length) > 0) {
|
|
4702
4752
|
rulesArray = filterRules.rule.map((rule) => {
|
|
4703
4753
|
let formattedValue;
|
|
4704
4754
|
if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
|
|
@@ -4742,7 +4792,7 @@ class Worktables {
|
|
|
4742
4792
|
});
|
|
4743
4793
|
}
|
|
4744
4794
|
const orderByArray = [];
|
|
4745
|
-
if (((
|
|
4795
|
+
if (((_6 = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _6 === void 0 ? void 0 : _6.length) > 0) {
|
|
4746
4796
|
sortOptions.sortBy.forEach((sort) => {
|
|
4747
4797
|
orderByArray.push(`{
|
|
4748
4798
|
column_id: "${sort.columnId}",
|
|
@@ -4788,7 +4838,7 @@ class Worktables {
|
|
|
4788
4838
|
body: { query },
|
|
4789
4839
|
});
|
|
4790
4840
|
const parsed = JSON.parse(rawResponse);
|
|
4791
|
-
const items = ((
|
|
4841
|
+
const items = ((_10 = (_9 = (_8 = (_7 = parsed === null || parsed === void 0 ? void 0 : parsed.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) === null || _10 === void 0 ? void 0 : _10.items) || [];
|
|
4792
4842
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
4793
4843
|
const formatted = {
|
|
4794
4844
|
id: item.id,
|
|
@@ -4822,7 +4872,7 @@ class Worktables {
|
|
|
4822
4872
|
const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
|
|
4823
4873
|
const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
|
|
4824
4874
|
let rulesArray = [];
|
|
4825
|
-
if (((
|
|
4875
|
+
if (((_11 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _11 === void 0 ? void 0 : _11.length) > 0) {
|
|
4826
4876
|
console.log('Processing filter rules:', advancedFilterRules.rule);
|
|
4827
4877
|
rulesArray = advancedFilterRules.rule.map((rule) => {
|
|
4828
4878
|
let formattedValue;
|
|
@@ -5038,7 +5088,7 @@ class Worktables {
|
|
|
5038
5088
|
});
|
|
5039
5089
|
}
|
|
5040
5090
|
const orderByArray = [];
|
|
5041
|
-
if (((
|
|
5091
|
+
if (((_12 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _12 === void 0 ? void 0 : _12.length) > 0) {
|
|
5042
5092
|
advancedSortOptions.sortBy.forEach((sort) => {
|
|
5043
5093
|
orderByArray.push(`{
|
|
5044
5094
|
column_id: "${sort.columnId}",
|
|
@@ -5110,7 +5160,7 @@ class Worktables {
|
|
|
5110
5160
|
body: { query: testQuery },
|
|
5111
5161
|
});
|
|
5112
5162
|
const testParsed = JSON.parse(testResponse);
|
|
5113
|
-
const testItems = ((
|
|
5163
|
+
const testItems = ((_16 = (_15 = (_14 = (_13 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.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) || [];
|
|
5114
5164
|
console.log('Test - Items in board (no filters):', testItems.length);
|
|
5115
5165
|
if (testItems.length > 0) {
|
|
5116
5166
|
console.log('Sample item column values:', testItems[0].column_values);
|
|
@@ -5122,7 +5172,7 @@ class Worktables {
|
|
|
5122
5172
|
body: { query },
|
|
5123
5173
|
});
|
|
5124
5174
|
const parsed = JSON.parse(rawResponse);
|
|
5125
|
-
const itemsPage = (
|
|
5175
|
+
const itemsPage = (_19 = (_18 = (_17 = parsed === null || parsed === void 0 ? void 0 : parsed.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;
|
|
5126
5176
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
5127
5177
|
const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
|
|
5128
5178
|
const hasMore = nextCursor ? true : false;
|
|
@@ -5280,7 +5330,7 @@ class Worktables {
|
|
|
5280
5330
|
body: { query },
|
|
5281
5331
|
});
|
|
5282
5332
|
const parsed = JSON.parse(rawResponse);
|
|
5283
|
-
const items = ((_24 = (_23 = (_22 = (_21 = (_20 =
|
|
5333
|
+
const items = ((_25 = (_24 = (_23 = (_22 = (_21 = (_20 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _20 === void 0 ? void 0 : _20.boards) === null || _21 === void 0 ? void 0 : _21[0]) === null || _22 === void 0 ? void 0 : _22.groups) === null || _23 === void 0 ? void 0 : _23[0]) === null || _24 === void 0 ? void 0 : _24.items_page) === null || _25 === void 0 ? void 0 : _25.items) || [];
|
|
5284
5334
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
5285
5335
|
const columnValues = item.column_values || [];
|
|
5286
5336
|
const formatted = {
|
|
@@ -5370,7 +5420,7 @@ class Worktables {
|
|
|
5370
5420
|
response = await (0, isErrorResponse_1.parseApiResponse)(response);
|
|
5371
5421
|
if (response.success) {
|
|
5372
5422
|
const parsed = JSON.parse(response.data);
|
|
5373
|
-
const updates = ((
|
|
5423
|
+
const updates = ((_28 = (_27 = (_26 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _26 === void 0 ? void 0 : _26.items) === null || _27 === void 0 ? void 0 : _27[0]) === null || _28 === void 0 ? void 0 : _28.updates) || [];
|
|
5374
5424
|
const formattedUpdates = updates.map((update) => {
|
|
5375
5425
|
const pinnedToTop = update.pinned_to_top || [];
|
|
5376
5426
|
const isPinnedToTop = Array.isArray(pinnedToTop) && pinnedToTop.length > 0;
|
|
@@ -5435,7 +5485,7 @@ class Worktables {
|
|
|
5435
5485
|
console.log('variables:', variables);
|
|
5436
5486
|
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
5437
5487
|
console.log('Create Update Result:', JSON.stringify(response, null, 2));
|
|
5438
|
-
const updateId = (
|
|
5488
|
+
const updateId = (_30 = (_29 = JSON.parse(response).data) === null || _29 === void 0 ? void 0 : _29.create_update) === null || _30 === void 0 ? void 0 : _30.id;
|
|
5439
5489
|
if (!updateId) {
|
|
5440
5490
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5441
5491
|
message: 'Error creating update: Update not created, no ID returned',
|
|
@@ -5741,7 +5791,7 @@ class Worktables {
|
|
|
5741
5791
|
body: { query },
|
|
5742
5792
|
json: true,
|
|
5743
5793
|
});
|
|
5744
|
-
const asset = (
|
|
5794
|
+
const asset = (_32 = (_31 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _31 === void 0 ? void 0 : _31.assets) === null || _32 === void 0 ? void 0 : _32[0];
|
|
5745
5795
|
if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
|
|
5746
5796
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5747
5797
|
message: 'Public URL not found for the given file ID.',
|