@worktables/n8n-nodes-worktables 12.1.11 → 12.2.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/MondayWebhook.node.js +123 -3
- package/dist/nodes/Worktables/MondayWebhook.node.js.map +1 -1
- package/dist/nodes/Worktables/Worktables.node.js +82 -139
- 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
|
@@ -15,7 +15,12 @@ class MondayWebhook {
|
|
|
15
15
|
},
|
|
16
16
|
inputs: ["main"],
|
|
17
17
|
outputs: ["main"],
|
|
18
|
-
credentials: [
|
|
18
|
+
credentials: [
|
|
19
|
+
{
|
|
20
|
+
name: 'WorktablesApi',
|
|
21
|
+
required: false,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
19
24
|
webhooks: [
|
|
20
25
|
{
|
|
21
26
|
name: 'default',
|
|
@@ -24,10 +29,69 @@ class MondayWebhook {
|
|
|
24
29
|
path: '/webhook',
|
|
25
30
|
},
|
|
26
31
|
],
|
|
27
|
-
properties: [
|
|
32
|
+
properties: [
|
|
33
|
+
{
|
|
34
|
+
displayName: 'Get Item After Event',
|
|
35
|
+
name: 'getItemAfterEvent',
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
default: false,
|
|
38
|
+
description: 'Fetch the related item from Monday after receiving the event',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
displayName: 'Is Subitem',
|
|
42
|
+
name: 'isSubitem',
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
default: false,
|
|
45
|
+
description: 'Treat the received item as a subitem when fetching data',
|
|
46
|
+
displayOptions: {
|
|
47
|
+
show: {
|
|
48
|
+
getItemAfterEvent: [true],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
displayName: 'Fetch Subitems',
|
|
54
|
+
name: 'fetchSubitems',
|
|
55
|
+
type: 'boolean',
|
|
56
|
+
default: false,
|
|
57
|
+
description: 'Include subitems of the item in the response',
|
|
58
|
+
displayOptions: {
|
|
59
|
+
show: {
|
|
60
|
+
getItemAfterEvent: [true],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
displayName: 'Fetch All Columns',
|
|
66
|
+
name: 'fetchAllColumns',
|
|
67
|
+
type: 'boolean',
|
|
68
|
+
default: true,
|
|
69
|
+
description: 'When true, returns all columns; otherwise, only specified Column IDs',
|
|
70
|
+
displayOptions: {
|
|
71
|
+
show: {
|
|
72
|
+
getItemAfterEvent: [true],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
displayName: 'Column IDs',
|
|
78
|
+
name: 'columnIds',
|
|
79
|
+
type: 'string',
|
|
80
|
+
default: '',
|
|
81
|
+
placeholder: 'status,owner,date',
|
|
82
|
+
description: 'Comma-separated column IDs to fetch. Leave empty to fetch all columns.',
|
|
83
|
+
displayOptions: {
|
|
84
|
+
show: {
|
|
85
|
+
getItemAfterEvent: [true],
|
|
86
|
+
fetchAllColumns: [false],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
],
|
|
28
91
|
};
|
|
29
92
|
}
|
|
30
93
|
async webhook() {
|
|
94
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
31
95
|
const req = this.getRequestObject();
|
|
32
96
|
const res = this.getResponseObject();
|
|
33
97
|
const body = req.body;
|
|
@@ -36,8 +100,64 @@ class MondayWebhook {
|
|
|
36
100
|
res.status(200).json({ challenge: body.challenge });
|
|
37
101
|
return {};
|
|
38
102
|
}
|
|
103
|
+
const getItemAfterEvent = this.getNodeParameter('getItemAfterEvent', 0);
|
|
104
|
+
if (!getItemAfterEvent) {
|
|
105
|
+
return {
|
|
106
|
+
workflowData: [this.helpers.returnJsonArray([body])],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const isSubitem = this.getNodeParameter('isSubitem', 0);
|
|
110
|
+
const fetchSubitems = this.getNodeParameter('fetchSubitems', 0);
|
|
111
|
+
const fetchAllColumns = this.getNodeParameter('fetchAllColumns', 0);
|
|
112
|
+
const columnIdsRaw = this.getNodeParameter('columnIds', 0);
|
|
113
|
+
const columnIds = (columnIdsRaw || '')
|
|
114
|
+
.split(',')
|
|
115
|
+
.map((s) => s.trim())
|
|
116
|
+
.filter((s) => s.length > 0);
|
|
117
|
+
const itemId = (_g = (_f = (_d = (_b = (_a = body === null || body === void 0 ? void 0 : body.event) === null || _a === void 0 ? void 0 : _a.pulseId) !== null && _b !== void 0 ? _b : (_c = body === null || body === void 0 ? void 0 : body.event) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : (_e = body === null || body === void 0 ? void 0 : body.event) === null || _e === void 0 ? void 0 : _e.entityId) !== null && _f !== void 0 ? _f : body === null || body === void 0 ? void 0 : body.pulseId) !== null && _g !== void 0 ? _g : body === null || body === void 0 ? void 0 : body.itemId;
|
|
118
|
+
if (!itemId) {
|
|
119
|
+
return {
|
|
120
|
+
workflowData: [this.helpers.returnJsonArray([body])],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const columnsSelection = fetchAllColumns
|
|
124
|
+
? 'column_values { id text value type }'
|
|
125
|
+
: columnIds.length > 0
|
|
126
|
+
? `column_values (ids: [${columnIds.map((id) => `"${id}"`).join(', ')}]) { id text value type }`
|
|
127
|
+
: 'column_values { id text value type }';
|
|
128
|
+
const subitemsSelection = fetchSubitems ? `subitems { id name ${columnsSelection} }` : '';
|
|
129
|
+
const itemFragment = `id name ${columnsSelection} ${subitemsSelection}`.trim();
|
|
130
|
+
const query = isSubitem
|
|
131
|
+
? `query { item (id: ${itemId}) { ${itemFragment} } }`
|
|
132
|
+
: `query { item (id: ${itemId}) { ${itemFragment} } }`;
|
|
133
|
+
let fetchedItem = undefined;
|
|
134
|
+
try {
|
|
135
|
+
const credentials = await this.getCredentials('WorktablesApi');
|
|
136
|
+
const apiKey = credentials === null || credentials === void 0 ? void 0 : credentials.apiKey;
|
|
137
|
+
const response = await this.helpers.httpRequest({
|
|
138
|
+
method: 'POST',
|
|
139
|
+
url: 'https://api.monday.com/v2',
|
|
140
|
+
headers: {
|
|
141
|
+
'Content-Type': 'application/json',
|
|
142
|
+
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
|
|
143
|
+
},
|
|
144
|
+
body: { query },
|
|
145
|
+
json: true,
|
|
146
|
+
});
|
|
147
|
+
fetchedItem = (_j = (_h = response === null || response === void 0 ? void 0 : response.data) === null || _h === void 0 ? void 0 : _h.item) !== null && _j !== void 0 ? _j : null;
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
fetchedItem = null;
|
|
151
|
+
}
|
|
39
152
|
return {
|
|
40
|
-
workflowData: [
|
|
153
|
+
workflowData: [
|
|
154
|
+
this.helpers.returnJsonArray([
|
|
155
|
+
{
|
|
156
|
+
...body,
|
|
157
|
+
fetchedItem,
|
|
158
|
+
},
|
|
159
|
+
]),
|
|
160
|
+
],
|
|
41
161
|
};
|
|
42
162
|
}
|
|
43
163
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MondayWebhook.node.js","sourceRoot":"","sources":["../../../nodes/Worktables/MondayWebhook.node.ts"],"names":[],"mappings":";;;AAWA,MAAa,aAAa;IAA1B;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,oBAAoB;YACjC,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,0BAA0B;YAChC,KAAK,EAAE,CAAC,SAAS,CAAC;YAClB,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,uDAAuD;YACpE,QAAQ,EAAE;gBACT,IAAI,EAAE,gBAAgB;aACtB;YACD,MAAM,EAAE,QAAyB;YACjC,OAAO,EAAE,QAAyB;YAClC,WAAW,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"MondayWebhook.node.js","sourceRoot":"","sources":["../../../nodes/Worktables/MondayWebhook.node.ts"],"names":[],"mappings":";;;AAWA,MAAa,aAAa;IAA1B;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,oBAAoB;YACjC,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,0BAA0B;YAChC,KAAK,EAAE,CAAC,SAAS,CAAC;YAClB,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,uDAAuD;YACpE,QAAQ,EAAE;gBACT,IAAI,EAAE,gBAAgB;aACtB;YACD,MAAM,EAAE,QAAyB;YACjC,OAAO,EAAE,QAAyB;YAClC,WAAW,EAAE;gBACZ;oBACC,IAAI,EAAE,eAAe;oBACrB,QAAQ,EAAE,KAAK;iBACf;aACD;YACD,QAAQ,EAAE;gBACT;oBACC,IAAI,EAAE,SAAS;oBACf,UAAU,EAAE,MAAM;oBAClB,YAAY,EAAE,YAAY;oBAC1B,IAAI,EAAE,UAAU;iBAChB;aACD;YACD,UAAU,EAAE;gBACX;oBACC,WAAW,EAAE,sBAAsB;oBACnC,IAAI,EAAE,mBAAmB;oBACzB,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,KAAK;oBACd,WAAW,EAAE,8DAA8D;iBAC3E;gBACD;oBACC,WAAW,EAAE,YAAY;oBACzB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,KAAK;oBACd,WAAW,EAAE,yDAAyD;oBACtE,cAAc,EAAE;wBACf,IAAI,EAAE;4BACL,iBAAiB,EAAE,CAAC,IAAI,CAAC;yBACzB;qBACD;iBACD;gBACD;oBACC,WAAW,EAAE,gBAAgB;oBAC7B,IAAI,EAAE,eAAe;oBACrB,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,KAAK;oBACd,WAAW,EA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I,IAAI,CAAC;SAC3C;QAAC,OAAO,KAAK,EAAE;YAEf,WAAW,GAAG,IAAI,CAAC;SACnB;QAED,OAAO;YACN,YAAY,EAAE;gBACb,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;oBAC5B;wBACC,GAAG,IAAI;wBACP,WAAW;qBACX;iBACD,CAAC;aACF;SACD,CAAC;IACH,CAAC;CACD;AAtLD,sCAsLC"}
|
|
@@ -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() {
|
|
@@ -1098,6 +1099,7 @@ class Worktables {
|
|
|
1098
1099
|
name: 'columnIds',
|
|
1099
1100
|
type: 'string',
|
|
1100
1101
|
default: '',
|
|
1102
|
+
required: false,
|
|
1101
1103
|
description: 'Comma-separated list of column IDs to fetch (e.g., text, number, date). Only used when "Fetch All Columns" is disabled.',
|
|
1102
1104
|
displayOptions: {
|
|
1103
1105
|
show: {
|
|
@@ -2753,7 +2755,7 @@ class Worktables {
|
|
|
2753
2755
|
};
|
|
2754
2756
|
}
|
|
2755
2757
|
async execute() {
|
|
2756
|
-
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;
|
|
2757
2759
|
const resource = this.getNodeParameter('resource', 0);
|
|
2758
2760
|
const operation = this.getNodeParameter('operation', 0);
|
|
2759
2761
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
@@ -3513,21 +3515,10 @@ class Worktables {
|
|
|
3513
3515
|
column_values: {},
|
|
3514
3516
|
};
|
|
3515
3517
|
for (const col of subitem.column_values || []) {
|
|
3516
|
-
const subCol =
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
text: col.text,
|
|
3520
|
-
};
|
|
3521
|
-
if ('display_value' in col) {
|
|
3522
|
-
subCol.display_value = col.display_value;
|
|
3518
|
+
const subCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
|
|
3519
|
+
if (subCol) {
|
|
3520
|
+
subFormatted.column_values[col.id] = subCol;
|
|
3523
3521
|
}
|
|
3524
|
-
if ('linked_item_ids' in col) {
|
|
3525
|
-
subCol.linked_item_ids = col.linked_item_ids;
|
|
3526
|
-
}
|
|
3527
|
-
if ('mirrored_items' in col) {
|
|
3528
|
-
subCol.mirrored_items = col.mirrored_items;
|
|
3529
|
-
}
|
|
3530
|
-
subFormatted.column_values[col.id] = subCol;
|
|
3531
3522
|
}
|
|
3532
3523
|
return subFormatted;
|
|
3533
3524
|
}));
|
|
@@ -3542,21 +3533,10 @@ class Worktables {
|
|
|
3542
3533
|
column_values: {},
|
|
3543
3534
|
};
|
|
3544
3535
|
for (const col of parentItem.column_values || []) {
|
|
3545
|
-
const subCol =
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
text: col.text,
|
|
3549
|
-
};
|
|
3550
|
-
if ('display_value' in col) {
|
|
3551
|
-
subCol.display_value = col.display_value;
|
|
3552
|
-
}
|
|
3553
|
-
if ('linked_item_ids' in col) {
|
|
3554
|
-
subCol.linked_item_ids = col.linked_item_ids;
|
|
3555
|
-
}
|
|
3556
|
-
if ('mirrored_items' in col) {
|
|
3557
|
-
subCol.mirrored_items = col.mirrored_items;
|
|
3536
|
+
const subCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
|
|
3537
|
+
if (subCol) {
|
|
3538
|
+
parentFormatted.column_values[col.id] = subCol;
|
|
3558
3539
|
}
|
|
3559
|
-
parentFormatted.column_values[col.id] = subCol;
|
|
3560
3540
|
}
|
|
3561
3541
|
formatted.parent_item = parentFormatted;
|
|
3562
3542
|
}
|
|
@@ -4125,23 +4105,10 @@ class Worktables {
|
|
|
4125
4105
|
column_values: {},
|
|
4126
4106
|
};
|
|
4127
4107
|
for (const col of itemData.column_values || []) {
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
type: col.type,
|
|
4132
|
-
value: col.value,
|
|
4133
|
-
text: col.text,
|
|
4134
|
-
};
|
|
4135
|
-
if ('display_value' in col) {
|
|
4136
|
-
formattedCol.display_value = col.display_value;
|
|
4137
|
-
}
|
|
4138
|
-
if ('linked_item_ids' in col) {
|
|
4139
|
-
formattedCol.linked_item_ids = col.linked_item_ids;
|
|
4140
|
-
}
|
|
4141
|
-
if ('mirrored_items' in col) {
|
|
4142
|
-
formattedCol.mirrored_items = col.mirrored_items;
|
|
4108
|
+
const formattedCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
|
|
4109
|
+
if (formattedCol) {
|
|
4110
|
+
formattedResponse.column_values[col.id] = formattedCol;
|
|
4143
4111
|
}
|
|
4144
|
-
formattedResponse.column_values[col.id] = formattedCol;
|
|
4145
4112
|
}
|
|
4146
4113
|
response = JSON.stringify(formattedResponse);
|
|
4147
4114
|
break;
|
|
@@ -4600,23 +4567,10 @@ class Worktables {
|
|
|
4600
4567
|
if (!fetchColumnValues)
|
|
4601
4568
|
return formatted;
|
|
4602
4569
|
for (const col of item.column_values || []) {
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
type: col.type,
|
|
4607
|
-
value: await (0, parseValue_1.parseValue)(col.value),
|
|
4608
|
-
text: col.text,
|
|
4609
|
-
};
|
|
4610
|
-
if ('display_value' in col) {
|
|
4611
|
-
formattedCol.display_value = col.display_value;
|
|
4570
|
+
const formattedCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
|
|
4571
|
+
if (formattedCol) {
|
|
4572
|
+
formatted.column_values[col.id] = formattedCol;
|
|
4612
4573
|
}
|
|
4613
|
-
if ('linked_item_ids' in col) {
|
|
4614
|
-
formattedCol.linked_item_ids = col.linked_item_ids;
|
|
4615
|
-
}
|
|
4616
|
-
if ('mirrored_items' in col) {
|
|
4617
|
-
formattedCol.mirrored_items = col.mirrored_items;
|
|
4618
|
-
}
|
|
4619
|
-
formatted.column_values[col.id] = formattedCol;
|
|
4620
4574
|
}
|
|
4621
4575
|
return formatted;
|
|
4622
4576
|
}));
|
|
@@ -4991,10 +4945,7 @@ class Worktables {
|
|
|
4991
4945
|
message: 'Item ID, Column ID, and Binary Property Name(s) are required.',
|
|
4992
4946
|
});
|
|
4993
4947
|
}
|
|
4994
|
-
const binaryNames = binaryNamesRaw
|
|
4995
|
-
.split(',')
|
|
4996
|
-
.map((name) => name.trim())
|
|
4997
|
-
.filter(Boolean);
|
|
4948
|
+
const binaryNames = (0, worktablesHelpers_1.parseBinaryNames)(binaryNamesRaw);
|
|
4998
4949
|
for (const binaryName of binaryNames) {
|
|
4999
4950
|
let binaryData;
|
|
5000
4951
|
try {
|
|
@@ -5005,7 +4956,7 @@ class Worktables {
|
|
|
5005
4956
|
continue;
|
|
5006
4957
|
}
|
|
5007
4958
|
const fileBuffer = Buffer.from(binaryData.data, 'base64');
|
|
5008
|
-
const fileName =
|
|
4959
|
+
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension);
|
|
5009
4960
|
console.log('Binary Data:', binaryData);
|
|
5010
4961
|
console.log('fileName:', fileName);
|
|
5011
4962
|
const form = new form_data_1.default();
|
|
@@ -5095,28 +5046,14 @@ class Worktables {
|
|
|
5095
5046
|
column_values: {},
|
|
5096
5047
|
};
|
|
5097
5048
|
for (const col of item.column_values || []) {
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
type: col.type,
|
|
5102
|
-
value: await (0, parseValue_1.parseValue)(col.value),
|
|
5103
|
-
text: col.text,
|
|
5104
|
-
};
|
|
5105
|
-
if ('display_value' in col) {
|
|
5106
|
-
formattedCol.display_value = col.display_value;
|
|
5107
|
-
}
|
|
5108
|
-
if ('linked_item_ids' in col) {
|
|
5109
|
-
formattedCol.linked_item_ids = col.linked_item_ids;
|
|
5110
|
-
}
|
|
5111
|
-
if ('mirrored_items' in col) {
|
|
5112
|
-
formattedCol.mirrored_items = col.mirrored_items;
|
|
5049
|
+
const formattedCol = await (0, worktablesHelpers_1.formatColumnValue)(col);
|
|
5050
|
+
if (formattedCol) {
|
|
5051
|
+
formatted.column_values[col.id] = formattedCol;
|
|
5113
5052
|
}
|
|
5114
|
-
formatted.column_values[col.id] = formattedCol;
|
|
5115
5053
|
}
|
|
5116
5054
|
return formatted;
|
|
5117
5055
|
}));
|
|
5118
|
-
|
|
5119
|
-
break;
|
|
5056
|
+
return [formattedItems.map((item) => ({ json: item }))];
|
|
5120
5057
|
}
|
|
5121
5058
|
default:
|
|
5122
5059
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
@@ -5167,7 +5104,20 @@ class Worktables {
|
|
|
5167
5104
|
headers,
|
|
5168
5105
|
body: { query },
|
|
5169
5106
|
});
|
|
5170
|
-
|
|
5107
|
+
response = await (0, isErrorResponse_1.parseApiResponse)(response);
|
|
5108
|
+
if (response.success) {
|
|
5109
|
+
const parsed = JSON.parse(response.data);
|
|
5110
|
+
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) || [];
|
|
5111
|
+
return [updates.map((update) => ({ json: update }))];
|
|
5112
|
+
}
|
|
5113
|
+
else {
|
|
5114
|
+
const parsed = JSON.parse(response.data);
|
|
5115
|
+
const firstError = parsed.errors || { message: 'Unknown error' };
|
|
5116
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), firstError, {
|
|
5117
|
+
message: firstError.message,
|
|
5118
|
+
description: JSON.stringify(firstError, null, 2),
|
|
5119
|
+
});
|
|
5120
|
+
}
|
|
5171
5121
|
}
|
|
5172
5122
|
case 'createUpdate': {
|
|
5173
5123
|
const items = this.getInputData();
|
|
@@ -5182,32 +5132,39 @@ class Worktables {
|
|
|
5182
5132
|
}
|
|
5183
5133
|
console.log('Mentions Collection:', JSON.stringify(mentionsCollection, null, 2));
|
|
5184
5134
|
console.log('Should Mention:', shouldMention);
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5135
|
+
const mentionsGraphQL = (0, worktablesHelpers_1.buildMentionsGraphQL)(shouldMention, mentionsCollection);
|
|
5136
|
+
const mutation = isReply
|
|
5137
|
+
? `
|
|
5138
|
+
mutation ($body: String!, $itemId: ID!, $parentId: ID!) {
|
|
5139
|
+
create_update (
|
|
5140
|
+
item_id: $itemId,
|
|
5141
|
+
body: $body,
|
|
5142
|
+
parent_id: $parentId${mentionsGraphQL}
|
|
5143
|
+
) {
|
|
5144
|
+
id
|
|
5145
|
+
}
|
|
5146
|
+
}`
|
|
5147
|
+
: `
|
|
5148
|
+
mutation ($body: String!, $itemId: ID!) {
|
|
5149
|
+
create_update (
|
|
5150
|
+
item_id: $itemId,
|
|
5151
|
+
body: $body${mentionsGraphQL}
|
|
5152
|
+
) {
|
|
5153
|
+
id
|
|
5154
|
+
}
|
|
5155
|
+
}`;
|
|
5156
|
+
const variables = {
|
|
5157
|
+
body,
|
|
5158
|
+
itemId: itemId.toString(),
|
|
5159
|
+
};
|
|
5160
|
+
if (isReply) {
|
|
5161
|
+
variables.parentId = parentUpdateId;
|
|
5191
5162
|
}
|
|
5192
|
-
const mutation = `
|
|
5193
|
-
mutation {
|
|
5194
|
-
create_update (
|
|
5195
|
-
item_id: ${itemId},
|
|
5196
|
-
body: "${body}" ${isReply ? `, parent_id: ${parentUpdateId}` : ''}${mentionsGraphQL}
|
|
5197
|
-
) {
|
|
5198
|
-
id
|
|
5199
|
-
}
|
|
5200
|
-
}
|
|
5201
|
-
`;
|
|
5202
5163
|
console.log('mutation:', mutation);
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
url: 'https://api.monday.com/v2',
|
|
5206
|
-
headers,
|
|
5207
|
-
body: { query: mutation },
|
|
5208
|
-
});
|
|
5164
|
+
console.log('variables:', variables);
|
|
5165
|
+
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
5209
5166
|
console.log('Create Update Result:', JSON.stringify(response, null, 2));
|
|
5210
|
-
const updateId = (
|
|
5167
|
+
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;
|
|
5211
5168
|
if (!updateId) {
|
|
5212
5169
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5213
5170
|
message: 'Error creating update: Update not created, no ID returned',
|
|
@@ -5215,10 +5172,7 @@ class Worktables {
|
|
|
5215
5172
|
}
|
|
5216
5173
|
for (let i = 0; i < items.length; i++) {
|
|
5217
5174
|
const attachmentsString = this.getNodeParameter('attachmentsUpdate', i);
|
|
5218
|
-
const binaryNames = attachmentsString
|
|
5219
|
-
.split(',')
|
|
5220
|
-
.map((name) => name.trim())
|
|
5221
|
-
.filter(Boolean);
|
|
5175
|
+
const binaryNames = (0, worktablesHelpers_1.parseBinaryNames)(attachmentsString);
|
|
5222
5176
|
console.log(`Item ${i} - Binary names to process:`, binaryNames);
|
|
5223
5177
|
for (const binaryName of binaryNames) {
|
|
5224
5178
|
let binaryData;
|
|
@@ -5230,7 +5184,7 @@ class Worktables {
|
|
|
5230
5184
|
continue;
|
|
5231
5185
|
}
|
|
5232
5186
|
const fileBuffer = Buffer.from(binaryData.data, 'base64');
|
|
5233
|
-
const fileName = binaryData.fileName
|
|
5187
|
+
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension, 'upload', 'dat');
|
|
5234
5188
|
const form = new form_data_1.default();
|
|
5235
5189
|
form.append('query', `mutation ($file: File!) {
|
|
5236
5190
|
add_file_to_update (update_id: ${updateId}, file: $file) {
|
|
@@ -5262,32 +5216,24 @@ class Worktables {
|
|
|
5262
5216
|
const mentionsCollection = this.getNodeParameter('mentionsList', 0, []);
|
|
5263
5217
|
console.log('Mentions Collection:', JSON.stringify(mentionsCollection, null, 2));
|
|
5264
5218
|
console.log('Should Mention:', shouldMention);
|
|
5265
|
-
|
|
5266
|
-
if (shouldMention && mentionsCollection.mention.length > 0) {
|
|
5267
|
-
const mentions = mentionsCollection.mention
|
|
5268
|
-
.map((m) => `{id: ${m.id}, type: ${m.type}}`)
|
|
5269
|
-
.join(', ');
|
|
5270
|
-
mentionsGraphQL = `, mentions_list: [${mentions}]`;
|
|
5271
|
-
}
|
|
5219
|
+
const mentionsGraphQL = (0, worktablesHelpers_1.buildMentionsGraphQL)(shouldMention, mentionsCollection);
|
|
5272
5220
|
const mutation = `
|
|
5273
|
-
mutation {
|
|
5274
|
-
edit_update (id: $
|
|
5221
|
+
mutation ($body: String!, $updateId: ID!) {
|
|
5222
|
+
edit_update (id: $updateId, body: $body${mentionsGraphQL}) {
|
|
5275
5223
|
id
|
|
5276
5224
|
}
|
|
5277
5225
|
}
|
|
5278
5226
|
`;
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5227
|
+
const variables = {
|
|
5228
|
+
body,
|
|
5229
|
+
updateId: updateId.toString(),
|
|
5230
|
+
};
|
|
5231
|
+
console.log('mutation:', mutation);
|
|
5232
|
+
console.log('variables:', variables);
|
|
5233
|
+
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
5285
5234
|
for (let i = 0; i < items.length; i++) {
|
|
5286
5235
|
const attachmentsString = this.getNodeParameter('attachmentsUpdate', i);
|
|
5287
|
-
const binaryNames = attachmentsString
|
|
5288
|
-
.split(',')
|
|
5289
|
-
.map((name) => name.trim())
|
|
5290
|
-
.filter(Boolean);
|
|
5236
|
+
const binaryNames = (0, worktablesHelpers_1.parseBinaryNames)(attachmentsString);
|
|
5291
5237
|
console.log(`Item ${i} - Binary names to process:`, binaryNames);
|
|
5292
5238
|
for (const binaryName of binaryNames) {
|
|
5293
5239
|
let binaryData;
|
|
@@ -5299,7 +5245,7 @@ class Worktables {
|
|
|
5299
5245
|
continue;
|
|
5300
5246
|
}
|
|
5301
5247
|
const fileBuffer = Buffer.from(binaryData.data, 'base64');
|
|
5302
|
-
const fileName = binaryData.fileName
|
|
5248
|
+
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension, 'upload', 'dat');
|
|
5303
5249
|
const form = new form_data_1.default();
|
|
5304
5250
|
form.append('query', `mutation ($file: File!) {
|
|
5305
5251
|
add_file_to_update (update_id: ${updateId}, file: $file) {
|
|
@@ -5349,10 +5295,7 @@ class Worktables {
|
|
|
5349
5295
|
message: 'Update ID and attachmentsUpdate (binary names) are required.',
|
|
5350
5296
|
});
|
|
5351
5297
|
}
|
|
5352
|
-
const binaryNames = attachmentsRaw
|
|
5353
|
-
.split(',')
|
|
5354
|
-
.map((name) => name.trim())
|
|
5355
|
-
.filter(Boolean);
|
|
5298
|
+
const binaryNames = (0, worktablesHelpers_1.parseBinaryNames)(attachmentsRaw);
|
|
5356
5299
|
for (let i = 0; i < items.length; i++) {
|
|
5357
5300
|
for (const binaryName of binaryNames) {
|
|
5358
5301
|
let binaryData;
|
|
@@ -5364,7 +5307,7 @@ class Worktables {
|
|
|
5364
5307
|
continue;
|
|
5365
5308
|
}
|
|
5366
5309
|
const fileBuffer = Buffer.from(binaryData.data, 'base64');
|
|
5367
|
-
const fileName =
|
|
5310
|
+
const fileName = (0, worktablesHelpers_1.formatFileName)(binaryData.fileName, binaryData.fileExtension);
|
|
5368
5311
|
console.log(`Item ${i} - Uploading file '${fileName}' from '${binaryName}'`);
|
|
5369
5312
|
const form = new form_data_1.default();
|
|
5370
5313
|
form.append('query', `mutation ($file: File!) {
|
|
@@ -5527,7 +5470,7 @@ class Worktables {
|
|
|
5527
5470
|
body: { query },
|
|
5528
5471
|
json: true,
|
|
5529
5472
|
});
|
|
5530
|
-
const asset = (
|
|
5473
|
+
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];
|
|
5531
5474
|
if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
|
|
5532
5475
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5533
5476
|
message: 'Public URL not found for the given file ID.',
|