@worktables/n8n-nodes-worktables 11.34.0 → 11.36.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.
|
@@ -9,6 +9,7 @@ const isErrorResponse_1 = require("../../utils/isErrorResponse");
|
|
|
9
9
|
const form_data_1 = __importDefault(require("form-data"));
|
|
10
10
|
const axios_1 = __importDefault(require("axios"));
|
|
11
11
|
const parseValue_1 = require("../../utils/parseValue");
|
|
12
|
+
const country_codes_json_1 = __importDefault(require("../../utils/country_codes.json"));
|
|
12
13
|
class Worktables {
|
|
13
14
|
constructor() {
|
|
14
15
|
this.description = {
|
|
@@ -1151,6 +1152,7 @@ class Worktables {
|
|
|
1151
1152
|
options: [
|
|
1152
1153
|
{ name: 'Simple Column Value', value: 'simple' },
|
|
1153
1154
|
{ name: 'Column Value', value: 'objectValue' },
|
|
1155
|
+
{ name: 'Button', value: 'button' },
|
|
1154
1156
|
{ name: 'Checkbox', value: 'checkbox' },
|
|
1155
1157
|
{ name: 'Connect Boards', value: 'board_relation' },
|
|
1156
1158
|
{ name: 'People', value: 'people' },
|
|
@@ -1158,6 +1160,7 @@ class Worktables {
|
|
|
1158
1160
|
{ name: 'Location', value: 'location' },
|
|
1159
1161
|
{ name: 'Link', value: 'link' },
|
|
1160
1162
|
{ name: 'Email', value: 'email' },
|
|
1163
|
+
{ name: 'Phone', value: 'phone' },
|
|
1161
1164
|
{ name: 'Timeline', value: 'timeline' },
|
|
1162
1165
|
],
|
|
1163
1166
|
default: 'simple',
|
|
@@ -1185,6 +1188,17 @@ class Worktables {
|
|
|
1185
1188
|
},
|
|
1186
1189
|
},
|
|
1187
1190
|
},
|
|
1191
|
+
{
|
|
1192
|
+
displayName: 'Click',
|
|
1193
|
+
name: 'buttonValue',
|
|
1194
|
+
type: 'boolean',
|
|
1195
|
+
default: false,
|
|
1196
|
+
displayOptions: {
|
|
1197
|
+
show: {
|
|
1198
|
+
columnType: ['button'],
|
|
1199
|
+
},
|
|
1200
|
+
},
|
|
1201
|
+
},
|
|
1188
1202
|
{
|
|
1189
1203
|
displayName: 'Checked',
|
|
1190
1204
|
name: 'checkboxValue',
|
|
@@ -1285,11 +1299,25 @@ class Worktables {
|
|
|
1285
1299
|
},
|
|
1286
1300
|
},
|
|
1287
1301
|
},
|
|
1302
|
+
{
|
|
1303
|
+
displayName: 'Country Code',
|
|
1304
|
+
name: 'countryCode',
|
|
1305
|
+
type: 'options',
|
|
1306
|
+
options: country_codes_json_1.default,
|
|
1307
|
+
default: '+1',
|
|
1308
|
+
description: 'Select the country code for the phone number',
|
|
1309
|
+
displayOptions: {
|
|
1310
|
+
show: {
|
|
1311
|
+
columnType: ['phone'],
|
|
1312
|
+
},
|
|
1313
|
+
},
|
|
1314
|
+
},
|
|
1288
1315
|
{
|
|
1289
1316
|
displayName: 'Phone',
|
|
1290
1317
|
name: 'phoneValue',
|
|
1291
1318
|
type: 'string',
|
|
1292
1319
|
default: '',
|
|
1320
|
+
description: 'Enter the phone number. Do **not** include the country code — only the area code and the number. Use an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a> to specify a dynamic value.',
|
|
1293
1321
|
displayOptions: {
|
|
1294
1322
|
show: {
|
|
1295
1323
|
columnType: ['phone'],
|
|
@@ -2452,7 +2480,7 @@ class Worktables {
|
|
|
2452
2480
|
};
|
|
2453
2481
|
}
|
|
2454
2482
|
async execute() {
|
|
2455
|
-
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;
|
|
2483
|
+
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;
|
|
2456
2484
|
const resource = this.getNodeParameter('resource', 0);
|
|
2457
2485
|
const operation = this.getNodeParameter('operation', 0);
|
|
2458
2486
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
@@ -3370,20 +3398,40 @@ class Worktables {
|
|
|
3370
3398
|
url: col.url || '',
|
|
3371
3399
|
};
|
|
3372
3400
|
break;
|
|
3373
|
-
case '
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3401
|
+
case 'phone':
|
|
3402
|
+
column_values_object[columnId] = {
|
|
3403
|
+
phone: `${(_k = col.countryCode) === null || _k === void 0 ? void 0 : _k.split(' ')[0]}${col.phoneValue || ''}`,
|
|
3404
|
+
countryShortName: ((_l = col.countryCode) === null || _l === void 0 ? void 0 : _l.split(' ')[1]) || '',
|
|
3405
|
+
};
|
|
3406
|
+
break;
|
|
3407
|
+
case 'button':
|
|
3408
|
+
const query = `query {
|
|
3409
|
+
items (ids: ${itemId}) {
|
|
3410
|
+
column_values (ids: "${columnId}") {
|
|
3411
|
+
... on ButtonValue {
|
|
3412
|
+
color
|
|
3413
|
+
label
|
|
3414
|
+
value
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
}`;
|
|
3419
|
+
const buttonResponse = await this.helpers.request({
|
|
3420
|
+
method: 'POST',
|
|
3421
|
+
url: 'https://api.monday.com/v2',
|
|
3422
|
+
headers,
|
|
3423
|
+
body: { query },
|
|
3424
|
+
});
|
|
3425
|
+
try {
|
|
3426
|
+
const buttonValue = JSON.parse(buttonResponse).data.items[0].column_values[0].value;
|
|
3427
|
+
const clicks = ((_m = JSON.parse(buttonValue)) === null || _m === void 0 ? void 0 : _m.clicks) || 0;
|
|
3428
|
+
column_values_object[columnId] = {
|
|
3429
|
+
clicks: clicks + 1,
|
|
3430
|
+
changed_at: new Date().toISOString(),
|
|
3431
|
+
};
|
|
3384
3432
|
}
|
|
3385
|
-
|
|
3386
|
-
|
|
3433
|
+
catch (error) {
|
|
3434
|
+
continue;
|
|
3387
3435
|
}
|
|
3388
3436
|
break;
|
|
3389
3437
|
default:
|
|
@@ -3536,8 +3584,8 @@ class Worktables {
|
|
|
3536
3584
|
break;
|
|
3537
3585
|
case 'timeline':
|
|
3538
3586
|
{
|
|
3539
|
-
const from = ((
|
|
3540
|
-
const to = ((
|
|
3587
|
+
const from = ((_o = col.startDate) === null || _o === void 0 ? void 0 : _o.split('T')[0]) || '';
|
|
3588
|
+
const to = ((_p = col.endDate) === null || _p === void 0 ? void 0 : _p.split('T')[0]) || '';
|
|
3541
3589
|
column_values_object[columnId] = { from, to };
|
|
3542
3590
|
}
|
|
3543
3591
|
break;
|
|
@@ -3573,9 +3621,15 @@ class Worktables {
|
|
|
3573
3621
|
};
|
|
3574
3622
|
}
|
|
3575
3623
|
break;
|
|
3624
|
+
case 'phone':
|
|
3625
|
+
column_values_object[columnId] = {
|
|
3626
|
+
phone: `${(_q = col.countryCode) === null || _q === void 0 ? void 0 : _q.split(' ')[0]}${col.phoneValue || ''}`,
|
|
3627
|
+
countryShortName: ((_r = col.countryCode) === null || _r === void 0 ? void 0 : _r.split(' ')[1]) || '',
|
|
3628
|
+
};
|
|
3629
|
+
break;
|
|
3576
3630
|
case 'dropdown':
|
|
3577
3631
|
{
|
|
3578
|
-
const labels = (
|
|
3632
|
+
const labels = (_s = col.dropdownValue) === null || _s === void 0 ? void 0 : _s.split(',').map((t) => t.trim()).filter((t) => t);
|
|
3579
3633
|
if (labels && labels.length) {
|
|
3580
3634
|
column_values_object[columnId] = { labels };
|
|
3581
3635
|
}
|
|
@@ -3701,7 +3755,7 @@ class Worktables {
|
|
|
3701
3755
|
}
|
|
3702
3756
|
const parsedResponse = JSON.parse(responseRaw);
|
|
3703
3757
|
console.log('Parsed Response:', parsedResponse);
|
|
3704
|
-
const itemData = ((
|
|
3758
|
+
const itemData = ((_t = parsedResponse.data) === null || _t === void 0 ? void 0 : _t.create_item) || ((_u = parsedResponse.data) === null || _u === void 0 ? void 0 : _u.create_subitem);
|
|
3705
3759
|
const formattedResponse = {
|
|
3706
3760
|
id: itemData.id,
|
|
3707
3761
|
name: itemName,
|
|
@@ -3847,7 +3901,7 @@ class Worktables {
|
|
|
3847
3901
|
const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
|
|
3848
3902
|
const logicalOperator = this.getNodeParameter('logicalOperator', 0);
|
|
3849
3903
|
let rulesArray = [];
|
|
3850
|
-
if (((
|
|
3904
|
+
if (((_v = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _v === void 0 ? void 0 : _v.length) > 0) {
|
|
3851
3905
|
rulesArray = filterRules.rule.map((rule) => {
|
|
3852
3906
|
let formattedValue;
|
|
3853
3907
|
if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
|
|
@@ -3891,7 +3945,7 @@ class Worktables {
|
|
|
3891
3945
|
});
|
|
3892
3946
|
}
|
|
3893
3947
|
const orderByArray = [];
|
|
3894
|
-
if (((
|
|
3948
|
+
if (((_w = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _w === void 0 ? void 0 : _w.length) > 0) {
|
|
3895
3949
|
sortOptions.sortBy.forEach((sort) => {
|
|
3896
3950
|
orderByArray.push(`{
|
|
3897
3951
|
column_id: "${sort.columnId}",
|
|
@@ -3935,7 +3989,7 @@ class Worktables {
|
|
|
3935
3989
|
body: { query },
|
|
3936
3990
|
});
|
|
3937
3991
|
const parsed = JSON.parse(rawResponse);
|
|
3938
|
-
const items = ((
|
|
3992
|
+
const items = ((_0 = (_z = (_y = (_x = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _x === void 0 ? void 0 : _x.boards) === null || _y === void 0 ? void 0 : _y[0]) === null || _z === void 0 ? void 0 : _z.items_page) === null || _0 === void 0 ? void 0 : _0.items) || [];
|
|
3939
3993
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
3940
3994
|
const formatted = {
|
|
3941
3995
|
id: item.id,
|
|
@@ -4073,7 +4127,7 @@ class Worktables {
|
|
|
4073
4127
|
body: { query },
|
|
4074
4128
|
});
|
|
4075
4129
|
const parsed = JSON.parse(rawResponse);
|
|
4076
|
-
const items = ((
|
|
4130
|
+
const items = ((_6 = (_5 = (_4 = (_3 = (_2 = (_1 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _1 === void 0 ? void 0 : _1.boards) === null || _2 === void 0 ? void 0 : _2[0]) === null || _3 === void 0 ? void 0 : _3.groups) === null || _4 === void 0 ? void 0 : _4[0]) === null || _5 === void 0 ? void 0 : _5.items_page) === null || _6 === void 0 ? void 0 : _6.items) || [];
|
|
4077
4131
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
4078
4132
|
const formatted = {
|
|
4079
4133
|
id: item.id,
|
|
@@ -4197,7 +4251,7 @@ class Worktables {
|
|
|
4197
4251
|
body: { query: mutation },
|
|
4198
4252
|
});
|
|
4199
4253
|
console.log('Create Update Result:', JSON.stringify(response, null, 2));
|
|
4200
|
-
const updateId = (
|
|
4254
|
+
const updateId = (_8 = (_7 = JSON.parse(response).data) === null || _7 === void 0 ? void 0 : _7.create_update) === null || _8 === void 0 ? void 0 : _8.id;
|
|
4201
4255
|
if (!updateId) {
|
|
4202
4256
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
4203
4257
|
message: 'Error creating update: Update not created, no ID returned',
|
|
@@ -4517,7 +4571,7 @@ class Worktables {
|
|
|
4517
4571
|
body: { query },
|
|
4518
4572
|
json: true,
|
|
4519
4573
|
});
|
|
4520
|
-
const asset = (
|
|
4574
|
+
const asset = (_10 = (_9 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _9 === void 0 ? void 0 : _9.assets) === null || _10 === void 0 ? void 0 : _10[0];
|
|
4521
4575
|
if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
|
|
4522
4576
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
4523
4577
|
message: 'Public URL not found for the given file ID.',
|