@worktables/n8n-nodes-worktables 12.1.12 → 12.2.1
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 +84 -140
- 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 +11 -0
- package/dist/utils/worktablesHelpers.js +65 -0
- package/dist/utils/worktablesHelpers.js.map +1 -0
- package/package.json +1 -1
|
@@ -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 worktablesHelpers_1 = require("../../utils/worktablesHelpers");
|
|
12
13
|
const country_codes_json_1 = __importDefault(require("../../utils/country_codes.json"));
|
|
13
14
|
class Worktables {
|
|
14
15
|
constructor() {
|
|
@@ -2754,7 +2755,7 @@ class Worktables {
|
|
|
2754
2755
|
};
|
|
2755
2756
|
}
|
|
2756
2757
|
async execute() {
|
|
2757
|
-
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;
|
|
2758
|
+
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;
|
|
2758
2759
|
const resource = this.getNodeParameter('resource', 0);
|
|
2759
2760
|
const operation = this.getNodeParameter('operation', 0);
|
|
2760
2761
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
@@ -3367,7 +3368,9 @@ class Worktables {
|
|
|
3367
3368
|
const itemId = this.getNodeParameter('itemId', 0);
|
|
3368
3369
|
const isSubitem = this.getNodeParameter('isSubitem', 0);
|
|
3369
3370
|
const fetchAllColumns = this.getNodeParameter('fetchAllColumns', 0);
|
|
3370
|
-
const columnIds =
|
|
3371
|
+
const columnIds = fetchAllColumns
|
|
3372
|
+
? ''
|
|
3373
|
+
: this.getNodeParameter('columnIds', 0, false) || '';
|
|
3371
3374
|
const fetchSubitems = !isSubitem && this.getNodeParameter('fetchSubitems', 0);
|
|
3372
3375
|
const fetchParentItem = isSubitem && this.getNodeParameter('fetchParentItems', 0);
|
|
3373
3376
|
let queryColumnValues = '';
|
|
@@ -3514,21 +3517,10 @@ class Worktables {
|
|
|
3514
3517
|
column_values: {},
|
|
3515
3518
|
};
|
|
3516
3519
|
for (const col of subitem.column_values || []) {
|
|
3517
|
-
const subCol =
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
text: col.text,
|
|
3521
|
-
};
|
|
3522
|
-
if ('display_value' in col) {
|
|
3523
|
-
subCol.display_value = col.display_value;
|
|
3520
|
+
const subCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
|
|
3521
|
+
if (subCol) {
|
|
3522
|
+
subFormatted.column_values[col.id] = subCol;
|
|
3524
3523
|
}
|
|
3525
|
-
if ('linked_item_ids' in col) {
|
|
3526
|
-
subCol.linked_item_ids = col.linked_item_ids;
|
|
3527
|
-
}
|
|
3528
|
-
if ('mirrored_items' in col) {
|
|
3529
|
-
subCol.mirrored_items = col.mirrored_items;
|
|
3530
|
-
}
|
|
3531
|
-
subFormatted.column_values[col.id] = subCol;
|
|
3532
3524
|
}
|
|
3533
3525
|
return subFormatted;
|
|
3534
3526
|
}));
|
|
@@ -3543,21 +3535,10 @@ class Worktables {
|
|
|
3543
3535
|
column_values: {},
|
|
3544
3536
|
};
|
|
3545
3537
|
for (const col of parentItem.column_values || []) {
|
|
3546
|
-
const subCol =
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
text: col.text,
|
|
3550
|
-
};
|
|
3551
|
-
if ('display_value' in col) {
|
|
3552
|
-
subCol.display_value = col.display_value;
|
|
3553
|
-
}
|
|
3554
|
-
if ('linked_item_ids' in col) {
|
|
3555
|
-
subCol.linked_item_ids = col.linked_item_ids;
|
|
3556
|
-
}
|
|
3557
|
-
if ('mirrored_items' in col) {
|
|
3558
|
-
subCol.mirrored_items = col.mirrored_items;
|
|
3538
|
+
const subCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
|
|
3539
|
+
if (subCol) {
|
|
3540
|
+
parentFormatted.column_values[col.id] = subCol;
|
|
3559
3541
|
}
|
|
3560
|
-
parentFormatted.column_values[col.id] = subCol;
|
|
3561
3542
|
}
|
|
3562
3543
|
formatted.parent_item = parentFormatted;
|
|
3563
3544
|
}
|
|
@@ -4126,23 +4107,10 @@ class Worktables {
|
|
|
4126
4107
|
column_values: {},
|
|
4127
4108
|
};
|
|
4128
4109
|
for (const col of itemData.column_values || []) {
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
type: col.type,
|
|
4133
|
-
value: col.value,
|
|
4134
|
-
text: col.text,
|
|
4135
|
-
};
|
|
4136
|
-
if ('display_value' in col) {
|
|
4137
|
-
formattedCol.display_value = col.display_value;
|
|
4138
|
-
}
|
|
4139
|
-
if ('linked_item_ids' in col) {
|
|
4140
|
-
formattedCol.linked_item_ids = col.linked_item_ids;
|
|
4141
|
-
}
|
|
4142
|
-
if ('mirrored_items' in col) {
|
|
4143
|
-
formattedCol.mirrored_items = col.mirrored_items;
|
|
4110
|
+
const formattedCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
|
|
4111
|
+
if (formattedCol) {
|
|
4112
|
+
formattedResponse.column_values[col.id] = formattedCol;
|
|
4144
4113
|
}
|
|
4145
|
-
formattedResponse.column_values[col.id] = formattedCol;
|
|
4146
4114
|
}
|
|
4147
4115
|
response = JSON.stringify(formattedResponse);
|
|
4148
4116
|
break;
|
|
@@ -4601,23 +4569,10 @@ class Worktables {
|
|
|
4601
4569
|
if (!fetchColumnValues)
|
|
4602
4570
|
return formatted;
|
|
4603
4571
|
for (const col of item.column_values || []) {
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
type: col.type,
|
|
4608
|
-
value: await (0, parseValue_1.parseValue)(col.value),
|
|
4609
|
-
text: col.text,
|
|
4610
|
-
};
|
|
4611
|
-
if ('display_value' in col) {
|
|
4612
|
-
formattedCol.display_value = col.display_value;
|
|
4572
|
+
const formattedCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
|
|
4573
|
+
if (formattedCol) {
|
|
4574
|
+
formatted.column_values[col.id] = formattedCol;
|
|
4613
4575
|
}
|
|
4614
|
-
if ('linked_item_ids' in col) {
|
|
4615
|
-
formattedCol.linked_item_ids = col.linked_item_ids;
|
|
4616
|
-
}
|
|
4617
|
-
if ('mirrored_items' in col) {
|
|
4618
|
-
formattedCol.mirrored_items = col.mirrored_items;
|
|
4619
|
-
}
|
|
4620
|
-
formatted.column_values[col.id] = formattedCol;
|
|
4621
4576
|
}
|
|
4622
4577
|
return formatted;
|
|
4623
4578
|
}));
|
|
@@ -4992,10 +4947,7 @@ class Worktables {
|
|
|
4992
4947
|
message: 'Item ID, Column ID, and Binary Property Name(s) are required.',
|
|
4993
4948
|
});
|
|
4994
4949
|
}
|
|
4995
|
-
const binaryNames = binaryNamesRaw
|
|
4996
|
-
.split(',')
|
|
4997
|
-
.map((name) => name.trim())
|
|
4998
|
-
.filter(Boolean);
|
|
4950
|
+
const binaryNames = (0, worktablesHelpers_1.parseBinaryNames)(binaryNamesRaw);
|
|
4999
4951
|
for (const binaryName of binaryNames) {
|
|
5000
4952
|
let binaryData;
|
|
5001
4953
|
try {
|
|
@@ -5006,7 +4958,7 @@ class Worktables {
|
|
|
5006
4958
|
continue;
|
|
5007
4959
|
}
|
|
5008
4960
|
const fileBuffer = Buffer.from(binaryData.data, 'base64');
|
|
5009
|
-
const fileName =
|
|
4961
|
+
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension);
|
|
5010
4962
|
console.log('Binary Data:', binaryData);
|
|
5011
4963
|
console.log('fileName:', fileName);
|
|
5012
4964
|
const form = new form_data_1.default();
|
|
@@ -5096,28 +5048,14 @@ class Worktables {
|
|
|
5096
5048
|
column_values: {},
|
|
5097
5049
|
};
|
|
5098
5050
|
for (const col of item.column_values || []) {
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
type: col.type,
|
|
5103
|
-
value: await (0, parseValue_1.parseValue)(col.value),
|
|
5104
|
-
text: col.text,
|
|
5105
|
-
};
|
|
5106
|
-
if ('display_value' in col) {
|
|
5107
|
-
formattedCol.display_value = col.display_value;
|
|
5108
|
-
}
|
|
5109
|
-
if ('linked_item_ids' in col) {
|
|
5110
|
-
formattedCol.linked_item_ids = col.linked_item_ids;
|
|
5111
|
-
}
|
|
5112
|
-
if ('mirrored_items' in col) {
|
|
5113
|
-
formattedCol.mirrored_items = col.mirrored_items;
|
|
5051
|
+
const formattedCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
|
|
5052
|
+
if (formattedCol) {
|
|
5053
|
+
formatted.column_values[col.id] = formattedCol;
|
|
5114
5054
|
}
|
|
5115
|
-
formatted.column_values[col.id] = formattedCol;
|
|
5116
5055
|
}
|
|
5117
5056
|
return formatted;
|
|
5118
5057
|
}));
|
|
5119
|
-
|
|
5120
|
-
break;
|
|
5058
|
+
return [formattedItems.map((item) => ({ json: item }))];
|
|
5121
5059
|
}
|
|
5122
5060
|
default:
|
|
5123
5061
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
@@ -5168,7 +5106,20 @@ class Worktables {
|
|
|
5168
5106
|
headers,
|
|
5169
5107
|
body: { query },
|
|
5170
5108
|
});
|
|
5171
|
-
|
|
5109
|
+
response = await (0, isErrorResponse_1.parseApiResponse)(response);
|
|
5110
|
+
if (response.success) {
|
|
5111
|
+
const parsed = JSON.parse(response.data);
|
|
5112
|
+
const updates = ((_19 = (_18 = (_17 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _17 === void 0 ? void 0 : _17.items) === null || _18 === void 0 ? void 0 : _18[0]) === null || _19 === void 0 ? void 0 : _19.updates) || [];
|
|
5113
|
+
return [updates.map((update) => ({ json: update }))];
|
|
5114
|
+
}
|
|
5115
|
+
else {
|
|
5116
|
+
const parsed = JSON.parse(response.data);
|
|
5117
|
+
const firstError = parsed.errors || { message: 'Unknown error' };
|
|
5118
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), firstError, {
|
|
5119
|
+
message: firstError.message,
|
|
5120
|
+
description: JSON.stringify(firstError, null, 2),
|
|
5121
|
+
});
|
|
5122
|
+
}
|
|
5172
5123
|
}
|
|
5173
5124
|
case 'createUpdate': {
|
|
5174
5125
|
const items = this.getInputData();
|
|
@@ -5183,32 +5134,39 @@ class Worktables {
|
|
|
5183
5134
|
}
|
|
5184
5135
|
console.log('Mentions Collection:', JSON.stringify(mentionsCollection, null, 2));
|
|
5185
5136
|
console.log('Should Mention:', shouldMention);
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5137
|
+
const mentionsGraphQL = (0, worktablesHelpers_1.buildMentionsGraphQL)(shouldMention, mentionsCollection);
|
|
5138
|
+
const mutation = isReply
|
|
5139
|
+
? `
|
|
5140
|
+
mutation ($body: String!, $itemId: ID!, $parentId: ID!) {
|
|
5141
|
+
create_update (
|
|
5142
|
+
item_id: $itemId,
|
|
5143
|
+
body: $body,
|
|
5144
|
+
parent_id: $parentId${mentionsGraphQL}
|
|
5145
|
+
) {
|
|
5146
|
+
id
|
|
5147
|
+
}
|
|
5148
|
+
}`
|
|
5149
|
+
: `
|
|
5150
|
+
mutation ($body: String!, $itemId: ID!) {
|
|
5151
|
+
create_update (
|
|
5152
|
+
item_id: $itemId,
|
|
5153
|
+
body: $body${mentionsGraphQL}
|
|
5154
|
+
) {
|
|
5155
|
+
id
|
|
5156
|
+
}
|
|
5157
|
+
}`;
|
|
5158
|
+
const variables = {
|
|
5159
|
+
body,
|
|
5160
|
+
itemId: itemId.toString(),
|
|
5161
|
+
};
|
|
5162
|
+
if (isReply) {
|
|
5163
|
+
variables.parentId = parentUpdateId;
|
|
5192
5164
|
}
|
|
5193
|
-
const mutation = `
|
|
5194
|
-
mutation {
|
|
5195
|
-
create_update (
|
|
5196
|
-
item_id: ${itemId},
|
|
5197
|
-
body: "${body}" ${isReply ? `, parent_id: ${parentUpdateId}` : ''}${mentionsGraphQL}
|
|
5198
|
-
) {
|
|
5199
|
-
id
|
|
5200
|
-
}
|
|
5201
|
-
}
|
|
5202
|
-
`;
|
|
5203
5165
|
console.log('mutation:', mutation);
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
url: 'https://api.monday.com/v2',
|
|
5207
|
-
headers,
|
|
5208
|
-
body: { query: mutation },
|
|
5209
|
-
});
|
|
5166
|
+
console.log('variables:', variables);
|
|
5167
|
+
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
5210
5168
|
console.log('Create Update Result:', JSON.stringify(response, null, 2));
|
|
5211
|
-
const updateId = (
|
|
5169
|
+
const updateId = (_21 = (_20 = JSON.parse(response).data) === null || _20 === void 0 ? void 0 : _20.create_update) === null || _21 === void 0 ? void 0 : _21.id;
|
|
5212
5170
|
if (!updateId) {
|
|
5213
5171
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5214
5172
|
message: 'Error creating update: Update not created, no ID returned',
|
|
@@ -5216,10 +5174,7 @@ class Worktables {
|
|
|
5216
5174
|
}
|
|
5217
5175
|
for (let i = 0; i < items.length; i++) {
|
|
5218
5176
|
const attachmentsString = this.getNodeParameter('attachmentsUpdate', i);
|
|
5219
|
-
const binaryNames = attachmentsString
|
|
5220
|
-
.split(',')
|
|
5221
|
-
.map((name) => name.trim())
|
|
5222
|
-
.filter(Boolean);
|
|
5177
|
+
const binaryNames = (0, worktablesHelpers_1.parseBinaryNames)(attachmentsString);
|
|
5223
5178
|
console.log(`Item ${i} - Binary names to process:`, binaryNames);
|
|
5224
5179
|
for (const binaryName of binaryNames) {
|
|
5225
5180
|
let binaryData;
|
|
@@ -5231,7 +5186,7 @@ class Worktables {
|
|
|
5231
5186
|
continue;
|
|
5232
5187
|
}
|
|
5233
5188
|
const fileBuffer = Buffer.from(binaryData.data, 'base64');
|
|
5234
|
-
const fileName = binaryData.fileName
|
|
5189
|
+
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension, 'upload', 'dat');
|
|
5235
5190
|
const form = new form_data_1.default();
|
|
5236
5191
|
form.append('query', `mutation ($file: File!) {
|
|
5237
5192
|
add_file_to_update (update_id: ${updateId}, file: $file) {
|
|
@@ -5263,32 +5218,24 @@ class Worktables {
|
|
|
5263
5218
|
const mentionsCollection = this.getNodeParameter('mentionsList', 0, []);
|
|
5264
5219
|
console.log('Mentions Collection:', JSON.stringify(mentionsCollection, null, 2));
|
|
5265
5220
|
console.log('Should Mention:', shouldMention);
|
|
5266
|
-
|
|
5267
|
-
if (shouldMention && mentionsCollection.mention.length > 0) {
|
|
5268
|
-
const mentions = mentionsCollection.mention
|
|
5269
|
-
.map((m) => `{id: ${m.id}, type: ${m.type}}`)
|
|
5270
|
-
.join(', ');
|
|
5271
|
-
mentionsGraphQL = `, mentions_list: [${mentions}]`;
|
|
5272
|
-
}
|
|
5221
|
+
const mentionsGraphQL = (0, worktablesHelpers_1.buildMentionsGraphQL)(shouldMention, mentionsCollection);
|
|
5273
5222
|
const mutation = `
|
|
5274
|
-
mutation {
|
|
5275
|
-
edit_update (id: $
|
|
5223
|
+
mutation ($body: String!, $updateId: ID!) {
|
|
5224
|
+
edit_update (id: $updateId, body: $body${mentionsGraphQL}) {
|
|
5276
5225
|
id
|
|
5277
5226
|
}
|
|
5278
5227
|
}
|
|
5279
5228
|
`;
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5229
|
+
const variables = {
|
|
5230
|
+
body,
|
|
5231
|
+
updateId: updateId.toString(),
|
|
5232
|
+
};
|
|
5233
|
+
console.log('mutation:', mutation);
|
|
5234
|
+
console.log('variables:', variables);
|
|
5235
|
+
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
5286
5236
|
for (let i = 0; i < items.length; i++) {
|
|
5287
5237
|
const attachmentsString = this.getNodeParameter('attachmentsUpdate', i);
|
|
5288
|
-
const binaryNames = attachmentsString
|
|
5289
|
-
.split(',')
|
|
5290
|
-
.map((name) => name.trim())
|
|
5291
|
-
.filter(Boolean);
|
|
5238
|
+
const binaryNames = (0, worktablesHelpers_1.parseBinaryNames)(attachmentsString);
|
|
5292
5239
|
console.log(`Item ${i} - Binary names to process:`, binaryNames);
|
|
5293
5240
|
for (const binaryName of binaryNames) {
|
|
5294
5241
|
let binaryData;
|
|
@@ -5300,7 +5247,7 @@ class Worktables {
|
|
|
5300
5247
|
continue;
|
|
5301
5248
|
}
|
|
5302
5249
|
const fileBuffer = Buffer.from(binaryData.data, 'base64');
|
|
5303
|
-
const fileName = binaryData.fileName
|
|
5250
|
+
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension, 'upload', 'dat');
|
|
5304
5251
|
const form = new form_data_1.default();
|
|
5305
5252
|
form.append('query', `mutation ($file: File!) {
|
|
5306
5253
|
add_file_to_update (update_id: ${updateId}, file: $file) {
|
|
@@ -5350,10 +5297,7 @@ class Worktables {
|
|
|
5350
5297
|
message: 'Update ID and attachmentsUpdate (binary names) are required.',
|
|
5351
5298
|
});
|
|
5352
5299
|
}
|
|
5353
|
-
const binaryNames = attachmentsRaw
|
|
5354
|
-
.split(',')
|
|
5355
|
-
.map((name) => name.trim())
|
|
5356
|
-
.filter(Boolean);
|
|
5300
|
+
const binaryNames = (0, worktablesHelpers_1.parseBinaryNames)(attachmentsRaw);
|
|
5357
5301
|
for (let i = 0; i < items.length; i++) {
|
|
5358
5302
|
for (const binaryName of binaryNames) {
|
|
5359
5303
|
let binaryData;
|
|
@@ -5365,7 +5309,7 @@ class Worktables {
|
|
|
5365
5309
|
continue;
|
|
5366
5310
|
}
|
|
5367
5311
|
const fileBuffer = Buffer.from(binaryData.data, 'base64');
|
|
5368
|
-
const fileName =
|
|
5312
|
+
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension);
|
|
5369
5313
|
console.log(`Item ${i} - Uploading file '${fileName}' from '${binaryName}'`);
|
|
5370
5314
|
const form = new form_data_1.default();
|
|
5371
5315
|
form.append('query', `mutation ($file: File!) {
|
|
@@ -5528,7 +5472,7 @@ class Worktables {
|
|
|
5528
5472
|
body: { query },
|
|
5529
5473
|
json: true,
|
|
5530
5474
|
});
|
|
5531
|
-
const asset = (
|
|
5475
|
+
const asset = (_23 = (_22 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _22 === void 0 ? void 0 : _22.assets) === null || _23 === void 0 ? void 0 : _23[0];
|
|
5532
5476
|
if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
|
|
5533
5477
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5534
5478
|
message: 'Public URL not found for the given file ID.',
|