@worktables/n8n-nodes-worktables 12.2.1 → 12.2.3
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 +106 -21
- package/dist/nodes/Worktables/MondayWebhook.node.js.map +1 -1
- package/dist/nodes/Worktables/Worktables.node.js +45 -42
- 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 +2 -0
- package/dist/utils/worktablesHelpers.js +15 -1
- package/dist/utils/worktablesHelpers.js.map +1 -1
- package/package.json +1 -1
|
@@ -110,43 +110,128 @@ class MondayWebhook {
|
|
|
110
110
|
const fetchSubitems = this.getNodeParameter('fetchSubitems', 0);
|
|
111
111
|
const fetchAllColumns = this.getNodeParameter('fetchAllColumns', 0);
|
|
112
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
113
|
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
114
|
if (!itemId) {
|
|
119
115
|
return {
|
|
120
116
|
workflowData: [this.helpers.returnJsonArray([body])],
|
|
121
117
|
};
|
|
122
118
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
119
|
+
let queryColumnValues = '';
|
|
120
|
+
if (fetchAllColumns) {
|
|
121
|
+
queryColumnValues = `
|
|
122
|
+
column_values {
|
|
123
|
+
id
|
|
124
|
+
text
|
|
125
|
+
value
|
|
126
|
+
type
|
|
127
|
+
... on BoardRelationValue {
|
|
128
|
+
display_value
|
|
129
|
+
linked_item_ids
|
|
130
|
+
}
|
|
131
|
+
... on MirrorValue {
|
|
132
|
+
display_value
|
|
133
|
+
mirrored_items {
|
|
134
|
+
linked_board_id
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
`;
|
|
139
|
+
}
|
|
140
|
+
else if (columnIdsRaw && columnIdsRaw.trim()) {
|
|
141
|
+
const specificColumnIds = columnIdsRaw.split(',').map(id => id.trim()).filter(id => id);
|
|
142
|
+
if (specificColumnIds.length > 0) {
|
|
143
|
+
const columnIdsString = specificColumnIds.map(id => `"${id}"`).join(', ');
|
|
144
|
+
queryColumnValues = `
|
|
145
|
+
column_values(ids: [${columnIdsString}]) {
|
|
146
|
+
id
|
|
147
|
+
text
|
|
148
|
+
value
|
|
149
|
+
type
|
|
150
|
+
... on BoardRelationValue {
|
|
151
|
+
display_value
|
|
152
|
+
linked_item_ids
|
|
153
|
+
}
|
|
154
|
+
... on MirrorValue {
|
|
155
|
+
display_value
|
|
156
|
+
mirrored_items {
|
|
157
|
+
linked_board_id
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
`;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const querySubitems = `
|
|
165
|
+
subitems {
|
|
166
|
+
id
|
|
167
|
+
name
|
|
168
|
+
url
|
|
169
|
+
board {
|
|
170
|
+
id
|
|
171
|
+
}
|
|
172
|
+
created_at
|
|
173
|
+
updated_at
|
|
174
|
+
${queryColumnValues}
|
|
175
|
+
}
|
|
176
|
+
`;
|
|
177
|
+
const queryParentItem = `
|
|
178
|
+
parent_item {
|
|
179
|
+
id
|
|
180
|
+
name
|
|
181
|
+
url
|
|
182
|
+
board {
|
|
183
|
+
id
|
|
184
|
+
}
|
|
185
|
+
created_at
|
|
186
|
+
updated_at
|
|
187
|
+
${queryColumnValues}
|
|
188
|
+
}
|
|
189
|
+
`;
|
|
190
|
+
const query = `
|
|
191
|
+
{
|
|
192
|
+
items(ids: ["${itemId}"]) {
|
|
193
|
+
id
|
|
194
|
+
name
|
|
195
|
+
url
|
|
196
|
+
board {
|
|
197
|
+
id
|
|
198
|
+
}
|
|
199
|
+
group {
|
|
200
|
+
id
|
|
201
|
+
title
|
|
202
|
+
color
|
|
203
|
+
position
|
|
204
|
+
}
|
|
205
|
+
created_at
|
|
206
|
+
updated_at
|
|
207
|
+
${queryColumnValues}
|
|
208
|
+
${!isSubitem && fetchSubitems ? querySubitems : ''}
|
|
209
|
+
${isSubitem ? queryParentItem : ''}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
`;
|
|
133
213
|
let fetchedItem = undefined;
|
|
134
214
|
try {
|
|
135
215
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
136
216
|
const apiKey = credentials === null || credentials === void 0 ? void 0 : credentials.apiKey;
|
|
137
|
-
const
|
|
217
|
+
const headers = {
|
|
218
|
+
'Content-Type': 'application/json',
|
|
219
|
+
};
|
|
220
|
+
if (apiKey) {
|
|
221
|
+
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
222
|
+
}
|
|
223
|
+
const rawResponse = await this.helpers.request({
|
|
138
224
|
method: 'POST',
|
|
139
225
|
url: 'https://api.monday.com/v2',
|
|
140
|
-
headers
|
|
141
|
-
'Content-Type': 'application/json',
|
|
142
|
-
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
|
|
143
|
-
},
|
|
226
|
+
headers,
|
|
144
227
|
body: { query },
|
|
145
|
-
json: true,
|
|
146
228
|
});
|
|
147
|
-
|
|
229
|
+
const parsed = typeof rawResponse === 'string' ? JSON.parse(rawResponse) : rawResponse;
|
|
230
|
+
const items = (_h = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _h === void 0 ? void 0 : _h.items;
|
|
231
|
+
fetchedItem = (_j = items === null || items === void 0 ? void 0 : items[0]) !== null && _j !== void 0 ? _j : null;
|
|
148
232
|
}
|
|
149
233
|
catch (error) {
|
|
234
|
+
console.error('Error fetching item:', error);
|
|
150
235
|
fetchedItem = null;
|
|
151
236
|
}
|
|
152
237
|
return {
|
|
@@ -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;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,EAAE,8CAA8C;oBAC3D,cAAc,EAAE;wBACf,IAAI,EAAE;4BACL,iBAAiB,EAAE,CAAC,IAAI,CAAC;yBACzB;qBACD;iBACD;gBACD;oBACC,WAAW,EAAE,mBAAmB;oBAChC,IAAI,EAAE,iBAAiB;oBACvB,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,IAAI;oBACb,WAAW,EAAE,sEAAsE;oBACnF,cAAc,EAAE;wBACf,IAAI,EAAE;4BACL,iBAAiB,EAAE,CAAC,IAAI,CAAC;yBACzB;qBACD;iBACD;gBACD;oBACC,WAAW,EAAE,YAAY;oBACzB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,EAAE;oBACX,WAAW,EAAE,mBAAmB;oBAChC,WAAW,EACV,wEAAwE;oBACzE,cAAc,EAAE;wBACf,IAAI,EAAE;4BACL,iBAAiB,EAAE,CAAC,IAAI,CAAC;4BACzB,eAAe,EAAE,CAAC,KAAK,CAAC;yBACxB;qBACD;iBACD;aACD;SACD,CAAC;
|
|
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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C,CAAC;YAC7C,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;AAhRD,sCAgRC"}
|
|
@@ -2755,7 +2755,7 @@ class Worktables {
|
|
|
2755
2755
|
};
|
|
2756
2756
|
}
|
|
2757
2757
|
async execute() {
|
|
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
|
+
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;
|
|
2759
2759
|
const resource = this.getNodeParameter('resource', 0);
|
|
2760
2760
|
const operation = this.getNodeParameter('operation', 0);
|
|
2761
2761
|
const credentials = await this.getCredentials('WorktablesApi');
|
|
@@ -3475,7 +3475,11 @@ class Worktables {
|
|
|
3475
3475
|
body: { query },
|
|
3476
3476
|
});
|
|
3477
3477
|
const parsed = JSON.parse(rawResponse);
|
|
3478
|
-
const
|
|
3478
|
+
const items = (_a = parsed.data) === null || _a === void 0 ? void 0 : _a.items;
|
|
3479
|
+
const item = items === null || items === void 0 ? void 0 : items[0];
|
|
3480
|
+
if (!item || !items || items.length === 0) {
|
|
3481
|
+
return [[]];
|
|
3482
|
+
}
|
|
3479
3483
|
const columnValues = item.column_values || [];
|
|
3480
3484
|
const formatted = {
|
|
3481
3485
|
id: item.id,
|
|
@@ -3618,7 +3622,7 @@ class Worktables {
|
|
|
3618
3622
|
headers,
|
|
3619
3623
|
body: { query: mutation },
|
|
3620
3624
|
});
|
|
3621
|
-
const existingIds = ((_f = (_e = (_d = (_c = (_b =
|
|
3625
|
+
const existingIds = ((_g = (_f = (_e = (_d = (_c = (_b = JSON.parse(itemConnectionResponse)) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.items) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.column_values) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.linked_item_ids) || [];
|
|
3622
3626
|
console.log('Existing IDs:', existingIds);
|
|
3623
3627
|
const newIds = columnValue.split(',').map((id) => id.trim());
|
|
3624
3628
|
const mergedIds = Array.from(new Set([...existingIds, ...newIds]));
|
|
@@ -3658,8 +3662,8 @@ class Worktables {
|
|
|
3658
3662
|
break;
|
|
3659
3663
|
case 'timeline':
|
|
3660
3664
|
column_values_object[columnId] = {
|
|
3661
|
-
from: (
|
|
3662
|
-
to: (
|
|
3665
|
+
from: (_h = col.startDate) === null || _h === void 0 ? void 0 : _h.split('T')[0],
|
|
3666
|
+
to: (_j = col.endDate) === null || _j === void 0 ? void 0 : _j.split('T')[0],
|
|
3663
3667
|
};
|
|
3664
3668
|
break;
|
|
3665
3669
|
case 'checkbox':
|
|
@@ -3680,7 +3684,7 @@ class Worktables {
|
|
|
3680
3684
|
};
|
|
3681
3685
|
break;
|
|
3682
3686
|
case 'dropdown':
|
|
3683
|
-
const dropdownLabels = (
|
|
3687
|
+
const dropdownLabels = (_k = col.dropdownValue) === null || _k === void 0 ? void 0 : _k.split(',').map((label) => label.trim()).filter(Boolean);
|
|
3684
3688
|
if (dropdownLabels === null || dropdownLabels === void 0 ? void 0 : dropdownLabels.length) {
|
|
3685
3689
|
column_values_object[columnId] = { labels: dropdownLabels };
|
|
3686
3690
|
}
|
|
@@ -3713,8 +3717,8 @@ class Worktables {
|
|
|
3713
3717
|
break;
|
|
3714
3718
|
case 'phone':
|
|
3715
3719
|
column_values_object[columnId] = {
|
|
3716
|
-
phone: `${(
|
|
3717
|
-
countryShortName: ((
|
|
3720
|
+
phone: `${(_l = col.countryCode) === null || _l === void 0 ? void 0 : _l.split(' ')[0]}${col.phoneValue || ''}`.replace(/[^\d+]/g, ''),
|
|
3721
|
+
countryShortName: ((_m = col.countryCode) === null || _m === void 0 ? void 0 : _m.split(' ')[1]) || '',
|
|
3718
3722
|
};
|
|
3719
3723
|
break;
|
|
3720
3724
|
case 'fileLink':
|
|
@@ -3747,7 +3751,7 @@ class Worktables {
|
|
|
3747
3751
|
});
|
|
3748
3752
|
try {
|
|
3749
3753
|
const buttonValue = JSON.parse(buttonResponse).data.items[0].column_values[0].value;
|
|
3750
|
-
const clicks = ((
|
|
3754
|
+
const clicks = ((_o = JSON.parse(buttonValue)) === null || _o === void 0 ? void 0 : _o.clicks) || 0;
|
|
3751
3755
|
column_values_object[columnId] = {
|
|
3752
3756
|
clicks: clicks + 1,
|
|
3753
3757
|
changed_at: new Date().toISOString(),
|
|
@@ -3774,14 +3778,13 @@ class Worktables {
|
|
|
3774
3778
|
}
|
|
3775
3779
|
}
|
|
3776
3780
|
console.log('column_values_object FINAL:', JSON.stringify(column_values_object, null, 2));
|
|
3781
|
+
const escapedColumnValues = (0, worktablesHelpers_1.escapeGraphQLJSONString)(column_values_object);
|
|
3777
3782
|
const mutation = `mutation {
|
|
3778
3783
|
change_multiple_column_values(
|
|
3779
3784
|
create_labels_if_missing: true,
|
|
3780
3785
|
board_id: ${boardId},
|
|
3781
3786
|
item_id: "${itemId}",
|
|
3782
|
-
column_values: "${
|
|
3783
|
-
.replace(/"/g, '\\"')
|
|
3784
|
-
.replace(/(^|[^\\])\\n/g, '$1\\\\n')}"
|
|
3787
|
+
column_values: "${escapedColumnValues}"
|
|
3785
3788
|
) {
|
|
3786
3789
|
id
|
|
3787
3790
|
url
|
|
@@ -3918,8 +3921,8 @@ class Worktables {
|
|
|
3918
3921
|
break;
|
|
3919
3922
|
case 'timeline':
|
|
3920
3923
|
{
|
|
3921
|
-
const from = ((
|
|
3922
|
-
const to = ((
|
|
3924
|
+
const from = ((_p = col.startDate) === null || _p === void 0 ? void 0 : _p.split('T')[0]) || '';
|
|
3925
|
+
const to = ((_q = col.endDate) === null || _q === void 0 ? void 0 : _q.split('T')[0]) || '';
|
|
3923
3926
|
column_values_object[columnId] = { from, to };
|
|
3924
3927
|
}
|
|
3925
3928
|
break;
|
|
@@ -3957,8 +3960,8 @@ class Worktables {
|
|
|
3957
3960
|
break;
|
|
3958
3961
|
case 'phone':
|
|
3959
3962
|
column_values_object[columnId] = {
|
|
3960
|
-
phone: `${(
|
|
3961
|
-
countryShortName: ((
|
|
3963
|
+
phone: `${(_r = col.countryCode) === null || _r === void 0 ? void 0 : _r.split(' ')[0]}${col.phoneValue || ''}`.replace(/[^\d+]/g, ''),
|
|
3964
|
+
countryShortName: ((_s = col.countryCode) === null || _s === void 0 ? void 0 : _s.split(' ')[1]) || '',
|
|
3962
3965
|
};
|
|
3963
3966
|
break;
|
|
3964
3967
|
case 'file':
|
|
@@ -3974,7 +3977,7 @@ class Worktables {
|
|
|
3974
3977
|
break;
|
|
3975
3978
|
case 'dropdown':
|
|
3976
3979
|
{
|
|
3977
|
-
const labels = (
|
|
3980
|
+
const labels = (_t = col.dropdownValue) === null || _t === void 0 ? void 0 : _t.split(',').map((t) => t.trim()).filter((t) => t);
|
|
3978
3981
|
if (labels && labels.length) {
|
|
3979
3982
|
column_values_object[columnId] = { labels };
|
|
3980
3983
|
}
|
|
@@ -4037,16 +4040,15 @@ class Worktables {
|
|
|
4037
4040
|
if (parentBoardName.startsWith('Subitems of') || (parentBoardName && isSubitem)) {
|
|
4038
4041
|
parentId = this.getNodeParameter('parentId', 0);
|
|
4039
4042
|
}
|
|
4040
|
-
const columnValuesString =
|
|
4041
|
-
.replace(/"/g, '\\"')
|
|
4042
|
-
.replace(/(^|[^\\])\\n/g, '$1\\\\n');
|
|
4043
|
+
const columnValuesString = (0, worktablesHelpers_1.escapeGraphQLJSONString)(column_values_object);
|
|
4043
4044
|
let groupLine = groupId ? `group_id: "${groupId}",` : '';
|
|
4045
|
+
const escapedItemName = (0, worktablesHelpers_1.escapeGraphQLString)(itemName);
|
|
4044
4046
|
const mutation = parentId
|
|
4045
4047
|
? `mutation {
|
|
4046
4048
|
create_subitem(
|
|
4047
4049
|
create_labels_if_missing: true,
|
|
4048
4050
|
parent_item_id: ${parentId},
|
|
4049
|
-
item_name: "${
|
|
4051
|
+
item_name: "${escapedItemName}",
|
|
4050
4052
|
column_values: "${columnValuesString}"
|
|
4051
4053
|
) { id name url
|
|
4052
4054
|
board {
|
|
@@ -4063,7 +4065,7 @@ class Worktables {
|
|
|
4063
4065
|
create_item(
|
|
4064
4066
|
create_labels_if_missing: true,
|
|
4065
4067
|
board_id: ${boardId},
|
|
4066
|
-
item_name: "${
|
|
4068
|
+
item_name: "${escapedItemName}",
|
|
4067
4069
|
${groupLine}
|
|
4068
4070
|
column_values: "${columnValuesString}"
|
|
4069
4071
|
) { id name url
|
|
@@ -4098,7 +4100,7 @@ class Worktables {
|
|
|
4098
4100
|
});
|
|
4099
4101
|
}
|
|
4100
4102
|
const parsedResponse = JSON.parse(responseRaw);
|
|
4101
|
-
const itemData = ((
|
|
4103
|
+
const itemData = ((_u = parsedResponse.data) === null || _u === void 0 ? void 0 : _u.create_item) || ((_v = parsedResponse.data) === null || _v === void 0 ? void 0 : _v.create_subitem);
|
|
4102
4104
|
const formattedResponse = {
|
|
4103
4105
|
id: itemData.id,
|
|
4104
4106
|
name: itemName,
|
|
@@ -4245,7 +4247,7 @@ class Worktables {
|
|
|
4245
4247
|
};
|
|
4246
4248
|
break;
|
|
4247
4249
|
case 'file':
|
|
4248
|
-
if ((
|
|
4250
|
+
if ((_w = col.fileLinks) === null || _w === void 0 ? void 0 : _w.file) {
|
|
4249
4251
|
column_values_object[columnId] = { files: col.fileLinks.file };
|
|
4250
4252
|
}
|
|
4251
4253
|
break;
|
|
@@ -4260,14 +4262,13 @@ class Worktables {
|
|
|
4260
4262
|
let formatted;
|
|
4261
4263
|
if (itemIdOptional && itemIdOptional.trim() !== '') {
|
|
4262
4264
|
console.log('Updating existing item:', itemIdOptional);
|
|
4265
|
+
const escapedColumnValues = (0, worktablesHelpers_1.escapeGraphQLJSONString)(column_values_object);
|
|
4263
4266
|
mutation = `mutation {
|
|
4264
4267
|
change_multiple_column_values(
|
|
4265
4268
|
create_labels_if_missing: true,
|
|
4266
4269
|
board_id: ${boardId},
|
|
4267
4270
|
item_id: "${itemIdOptional}",
|
|
4268
|
-
column_values: "${
|
|
4269
|
-
.replace(/"/g, '\\"')
|
|
4270
|
-
.replace(/(^|[^\\])\\n/g, '$1\\\\n')}"
|
|
4271
|
+
column_values: "${escapedColumnValues}"
|
|
4271
4272
|
) {
|
|
4272
4273
|
id
|
|
4273
4274
|
url
|
|
@@ -4296,12 +4297,14 @@ class Worktables {
|
|
|
4296
4297
|
else {
|
|
4297
4298
|
console.log('Creating new item:', itemName);
|
|
4298
4299
|
const parentId = this.getNodeParameter('parentId', 0, false);
|
|
4300
|
+
const escapedItemName = (0, worktablesHelpers_1.escapeGraphQLString)(itemName);
|
|
4301
|
+
const escapedColumnValues = (0, worktablesHelpers_1.escapeGraphQLJSONString)(column_values_object);
|
|
4299
4302
|
if (isSubitem && parentId) {
|
|
4300
4303
|
mutation = `mutation {
|
|
4301
4304
|
create_subitem(
|
|
4302
4305
|
parent_item_id: ${parentId},
|
|
4303
|
-
item_name: "${
|
|
4304
|
-
column_values: "${
|
|
4306
|
+
item_name: "${escapedItemName}",
|
|
4307
|
+
column_values: "${escapedColumnValues}"
|
|
4305
4308
|
) {
|
|
4306
4309
|
id
|
|
4307
4310
|
name
|
|
@@ -4316,8 +4319,8 @@ class Worktables {
|
|
|
4316
4319
|
mutation = `mutation {
|
|
4317
4320
|
create_item(
|
|
4318
4321
|
board_id: ${boardId},
|
|
4319
|
-
item_name: "${
|
|
4320
|
-
column_values: "${
|
|
4322
|
+
item_name: "${escapedItemName}",
|
|
4323
|
+
column_values: "${escapedColumnValues}"
|
|
4321
4324
|
) {
|
|
4322
4325
|
id
|
|
4323
4326
|
name
|
|
@@ -4465,7 +4468,7 @@ class Worktables {
|
|
|
4465
4468
|
const sortOptions = this.getNodeParameter('sortOptions', 0, { sortBy: [] });
|
|
4466
4469
|
const logicalOperator = this.getNodeParameter('logicalOperator', 0);
|
|
4467
4470
|
let rulesArray = [];
|
|
4468
|
-
if (((
|
|
4471
|
+
if (((_x = filterRules === null || filterRules === void 0 ? void 0 : filterRules.rule) === null || _x === void 0 ? void 0 : _x.length) > 0) {
|
|
4469
4472
|
rulesArray = filterRules.rule.map((rule) => {
|
|
4470
4473
|
let formattedValue;
|
|
4471
4474
|
if (['is_empty', 'is_not_empty'].includes(rule.operator)) {
|
|
@@ -4509,7 +4512,7 @@ class Worktables {
|
|
|
4509
4512
|
});
|
|
4510
4513
|
}
|
|
4511
4514
|
const orderByArray = [];
|
|
4512
|
-
if (((
|
|
4515
|
+
if (((_y = sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sortBy) === null || _y === void 0 ? void 0 : _y.length) > 0) {
|
|
4513
4516
|
sortOptions.sortBy.forEach((sort) => {
|
|
4514
4517
|
orderByArray.push(`{
|
|
4515
4518
|
column_id: "${sort.columnId}",
|
|
@@ -4555,7 +4558,7 @@ class Worktables {
|
|
|
4555
4558
|
body: { query },
|
|
4556
4559
|
});
|
|
4557
4560
|
const parsed = JSON.parse(rawResponse);
|
|
4558
|
-
const items = ((
|
|
4561
|
+
const items = ((_2 = (_1 = (_0 = (_z = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _z === void 0 ? void 0 : _z.boards) === null || _0 === void 0 ? void 0 : _0[0]) === null || _1 === void 0 ? void 0 : _1.items_page) === null || _2 === void 0 ? void 0 : _2.items) || [];
|
|
4559
4562
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
4560
4563
|
const formatted = {
|
|
4561
4564
|
id: item.id,
|
|
@@ -4589,7 +4592,7 @@ class Worktables {
|
|
|
4589
4592
|
const advancedSortOptions = this.getNodeParameter('advancedSortOptions', 0, { sortBy: [] });
|
|
4590
4593
|
const logicalOperator = this.getNodeParameter('logicalOperatorAdvanced', 0);
|
|
4591
4594
|
let rulesArray = [];
|
|
4592
|
-
if (((
|
|
4595
|
+
if (((_3 = advancedFilterRules === null || advancedFilterRules === void 0 ? void 0 : advancedFilterRules.rule) === null || _3 === void 0 ? void 0 : _3.length) > 0) {
|
|
4593
4596
|
console.log('Processing filter rules:', advancedFilterRules.rule);
|
|
4594
4597
|
rulesArray = advancedFilterRules.rule.map((rule) => {
|
|
4595
4598
|
let formattedValue;
|
|
@@ -4805,7 +4808,7 @@ class Worktables {
|
|
|
4805
4808
|
});
|
|
4806
4809
|
}
|
|
4807
4810
|
const orderByArray = [];
|
|
4808
|
-
if (((
|
|
4811
|
+
if (((_4 = advancedSortOptions === null || advancedSortOptions === void 0 ? void 0 : advancedSortOptions.sortBy) === null || _4 === void 0 ? void 0 : _4.length) > 0) {
|
|
4809
4812
|
advancedSortOptions.sortBy.forEach((sort) => {
|
|
4810
4813
|
orderByArray.push(`{
|
|
4811
4814
|
column_id: "${sort.columnId}",
|
|
@@ -4877,7 +4880,7 @@ class Worktables {
|
|
|
4877
4880
|
body: { query: testQuery },
|
|
4878
4881
|
});
|
|
4879
4882
|
const testParsed = JSON.parse(testResponse);
|
|
4880
|
-
const testItems = ((
|
|
4883
|
+
const testItems = ((_8 = (_7 = (_6 = (_5 = testParsed === null || testParsed === void 0 ? void 0 : testParsed.data) === null || _5 === void 0 ? void 0 : _5.boards) === null || _6 === void 0 ? void 0 : _6[0]) === null || _7 === void 0 ? void 0 : _7.items_page) === null || _8 === void 0 ? void 0 : _8.items) || [];
|
|
4881
4884
|
console.log('Test - Items in board (no filters):', testItems.length);
|
|
4882
4885
|
if (testItems.length > 0) {
|
|
4883
4886
|
console.log('Sample item column values:', testItems[0].column_values);
|
|
@@ -4889,7 +4892,7 @@ class Worktables {
|
|
|
4889
4892
|
body: { query },
|
|
4890
4893
|
});
|
|
4891
4894
|
const parsed = JSON.parse(rawResponse);
|
|
4892
|
-
const itemsPage = (
|
|
4895
|
+
const itemsPage = (_11 = (_10 = (_9 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _9 === void 0 ? void 0 : _9.boards) === null || _10 === void 0 ? void 0 : _10[0]) === null || _11 === void 0 ? void 0 : _11.items_page;
|
|
4893
4896
|
const items = (itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.items) || [];
|
|
4894
4897
|
const nextCursor = itemsPage === null || itemsPage === void 0 ? void 0 : itemsPage.cursor;
|
|
4895
4898
|
const hasMore = nextCursor ? true : false;
|
|
@@ -5036,7 +5039,7 @@ class Worktables {
|
|
|
5036
5039
|
body: { query },
|
|
5037
5040
|
});
|
|
5038
5041
|
const parsed = JSON.parse(rawResponse);
|
|
5039
|
-
const items = ((_16 = (_15 = (_14 = (_13 = (_12 =
|
|
5042
|
+
const items = ((_17 = (_16 = (_15 = (_14 = (_13 = (_12 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _12 === void 0 ? void 0 : _12.boards) === null || _13 === void 0 ? void 0 : _13[0]) === null || _14 === void 0 ? void 0 : _14.groups) === null || _15 === void 0 ? void 0 : _15[0]) === null || _16 === void 0 ? void 0 : _16.items_page) === null || _17 === void 0 ? void 0 : _17.items) || [];
|
|
5040
5043
|
const formattedItems = await Promise.all(items.map(async (item) => {
|
|
5041
5044
|
const formatted = {
|
|
5042
5045
|
id: item.id,
|
|
@@ -5109,7 +5112,7 @@ class Worktables {
|
|
|
5109
5112
|
response = await (0, isErrorResponse_1.parseApiResponse)(response);
|
|
5110
5113
|
if (response.success) {
|
|
5111
5114
|
const parsed = JSON.parse(response.data);
|
|
5112
|
-
const updates = ((
|
|
5115
|
+
const updates = ((_20 = (_19 = (_18 = parsed === null || parsed === void 0 ? void 0 : parsed.data) === null || _18 === void 0 ? void 0 : _18.items) === null || _19 === void 0 ? void 0 : _19[0]) === null || _20 === void 0 ? void 0 : _20.updates) || [];
|
|
5113
5116
|
return [updates.map((update) => ({ json: update }))];
|
|
5114
5117
|
}
|
|
5115
5118
|
else {
|
|
@@ -5166,7 +5169,7 @@ class Worktables {
|
|
|
5166
5169
|
console.log('variables:', variables);
|
|
5167
5170
|
response = await (0, worktablesHelpers_1.makeGraphQLRequest)(this, mutation, headers, variables);
|
|
5168
5171
|
console.log('Create Update Result:', JSON.stringify(response, null, 2));
|
|
5169
|
-
const updateId = (
|
|
5172
|
+
const updateId = (_22 = (_21 = JSON.parse(response).data) === null || _21 === void 0 ? void 0 : _21.create_update) === null || _22 === void 0 ? void 0 : _22.id;
|
|
5170
5173
|
if (!updateId) {
|
|
5171
5174
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5172
5175
|
message: 'Error creating update: Update not created, no ID returned',
|
|
@@ -5472,7 +5475,7 @@ class Worktables {
|
|
|
5472
5475
|
body: { query },
|
|
5473
5476
|
json: true,
|
|
5474
5477
|
});
|
|
5475
|
-
const asset = (
|
|
5478
|
+
const asset = (_24 = (_23 = responseFile === null || responseFile === void 0 ? void 0 : responseFile.data) === null || _23 === void 0 ? void 0 : _23.assets) === null || _24 === void 0 ? void 0 : _24[0];
|
|
5476
5479
|
if (!(asset === null || asset === void 0 ? void 0 : asset.public_url)) {
|
|
5477
5480
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
5478
5481
|
message: 'Public URL not found for the given file ID.',
|