n8n-nodes-blossom 2.3.29 → 2.4.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/Blossom/Blossom.node.js +182 -218
- package/dist/nodes/Blossom/Blossom.node.js.map +1 -1
- package/dist/nodes/Blossom/shared/transport.d.ts +9 -1
- package/dist/nodes/Blossom/shared/transport.js +154 -246
- package/dist/nodes/Blossom/shared/transport.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ const managers_1 = require("./resources/managers");
|
|
|
10
10
|
const utilities_1 = require("./resources/utilities");
|
|
11
11
|
const suppliers_1 = require("./resources/suppliers");
|
|
12
12
|
const performances_1 = require("./resources/performances");
|
|
13
|
+
const UTF8_BOM = [0xEF, 0xBB, 0xBF];
|
|
13
14
|
class Blossom {
|
|
14
15
|
constructor() {
|
|
15
16
|
this.description = {
|
|
@@ -88,6 +89,7 @@ class Blossom {
|
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
91
|
async execute() {
|
|
92
|
+
var _a;
|
|
91
93
|
const items = this.getInputData();
|
|
92
94
|
const returnData = [];
|
|
93
95
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -129,25 +131,6 @@ class Blossom {
|
|
|
129
131
|
console.log('========================================');
|
|
130
132
|
console.log('csvFile parameter value:', csvFile);
|
|
131
133
|
console.log('importOptions:', JSON.stringify(importOptions, null, 2));
|
|
132
|
-
console.log('Item index:', i);
|
|
133
|
-
console.log('Item keys:', Object.keys(items[i]));
|
|
134
|
-
console.log('Item has binary?:', !!items[i].binary);
|
|
135
|
-
const itemBinary = items[i].binary;
|
|
136
|
-
if (itemBinary) {
|
|
137
|
-
console.log('Binary property names:', Object.keys(itemBinary));
|
|
138
|
-
const binaryKeys = Object.keys(itemBinary);
|
|
139
|
-
binaryKeys.forEach(key => {
|
|
140
|
-
var _a, _b;
|
|
141
|
-
const bin = itemBinary[key];
|
|
142
|
-
console.log(`Binary[${key}]:`, {
|
|
143
|
-
fileName: bin.fileName,
|
|
144
|
-
mimeType: bin.mimeType,
|
|
145
|
-
fileExtension: bin.fileExtension,
|
|
146
|
-
dataLength: ((_a = bin.data) === null || _a === void 0 ? void 0 : _a.length) || 0,
|
|
147
|
-
dataPreview: ((_b = bin.data) === null || _b === void 0 ? void 0 : _b.substring(0, 100)) || 'N/A'
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
134
|
const optionParts = [];
|
|
152
135
|
Object.entries(importOptions).forEach(([key, value]) => {
|
|
153
136
|
if (value !== undefined && value !== null && value !== '') {
|
|
@@ -156,126 +139,126 @@ class Blossom {
|
|
|
156
139
|
}
|
|
157
140
|
});
|
|
158
141
|
const optionsPath = optionParts.length > 0 ? `/${optionParts.join('&')}` : '';
|
|
159
|
-
let
|
|
142
|
+
let fileBuffer;
|
|
160
143
|
let fileName = 'users.csv';
|
|
161
144
|
let mimeType = 'text/csv';
|
|
162
145
|
const binaryData = items[i].binary;
|
|
146
|
+
console.log('Has binary data:', !!binaryData);
|
|
147
|
+
console.log('Binary keys:', binaryData ? Object.keys(binaryData) : 'none');
|
|
163
148
|
if (binaryData && binaryData[csvFile]) {
|
|
164
149
|
const binary = binaryData[csvFile];
|
|
165
|
-
console.log('Found binary data for property:', csvFile);
|
|
166
|
-
console.log('Binary object keys:', Object.keys(binary));
|
|
167
150
|
console.log('Binary data type:', typeof binary.data);
|
|
168
|
-
console.log('Binary data
|
|
169
|
-
|
|
151
|
+
console.log('Binary data length:', (_a = binary.data) === null || _a === void 0 ? void 0 : _a.length);
|
|
152
|
+
if (typeof binary.data === 'string') {
|
|
153
|
+
fileBuffer = Buffer.from(binary.data, 'base64');
|
|
154
|
+
console.log('Decoded from base64, buffer length:', fileBuffer.length);
|
|
155
|
+
}
|
|
156
|
+
else if (Buffer.isBuffer(binary.data)) {
|
|
157
|
+
fileBuffer = binary.data;
|
|
158
|
+
console.log('Already a buffer, length:', fileBuffer.length);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
throw new Error(`Unexpected binary data type: ${typeof binary.data}`);
|
|
162
|
+
}
|
|
163
|
+
if (fileBuffer.length >= 3 &&
|
|
164
|
+
fileBuffer[0] === UTF8_BOM[0] &&
|
|
165
|
+
fileBuffer[1] === UTF8_BOM[1] &&
|
|
166
|
+
fileBuffer[2] === UTF8_BOM[2]) {
|
|
167
|
+
console.log('REMOVING UTF-8 BOM - Original length:', fileBuffer.length);
|
|
168
|
+
fileBuffer = Buffer.from(fileBuffer.toString('utf-8').substring(1), 'utf-8');
|
|
169
|
+
console.log('After BOM removal:', fileBuffer.length);
|
|
170
|
+
}
|
|
170
171
|
fileName = binary.fileName || 'users.csv';
|
|
171
172
|
mimeType = binary.mimeType || 'text/csv';
|
|
172
|
-
console.log('
|
|
173
|
-
console.log('
|
|
173
|
+
console.log('File name:', fileName);
|
|
174
|
+
console.log('MIME type:', mimeType);
|
|
175
|
+
console.log('First line:', fileBuffer.toString('utf-8').split('\n')[0]);
|
|
174
176
|
}
|
|
175
177
|
else {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
throw new Error(`Binary data not found for property "${csvFile}". Available: ${binaryData ? Object.keys(binaryData).join(', ') : 'none'}`);
|
|
179
|
+
}
|
|
180
|
+
if (fileBuffer.length === 0) {
|
|
181
|
+
throw new Error('CSV file is empty');
|
|
180
182
|
}
|
|
181
|
-
const formData = {
|
|
182
|
-
sheet_file: {
|
|
183
|
-
value: fileContent,
|
|
184
|
-
options: {
|
|
185
|
-
filename: fileName,
|
|
186
|
-
contentType: mimeType
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
183
|
const endpoint = `ImportUsersCSV/${parseInt(domain)}${optionsPath}`;
|
|
191
184
|
console.log('========================================');
|
|
192
|
-
console.log('ImportUsersCSV - REQUEST
|
|
185
|
+
console.log('ImportUsersCSV - SENDING REQUEST');
|
|
193
186
|
console.log('========================================');
|
|
194
187
|
console.log('Endpoint:', endpoint);
|
|
195
|
-
console.log('
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
valueIsBuffer: Buffer.isBuffer(formData.sheet_file.value),
|
|
203
|
-
optionsFilename: formData.sheet_file.options.filename,
|
|
204
|
-
optionsContentType: formData.sheet_file.options.contentType
|
|
188
|
+
console.log('Buffer length:', fileBuffer.length);
|
|
189
|
+
responseData = await transport_1.blossomApiRequest.call(this, 'POST', endpoint, {}, {
|
|
190
|
+
__isFileUpload: true,
|
|
191
|
+
__fieldName: 'sheet_file',
|
|
192
|
+
__fileBuffer: fileBuffer,
|
|
193
|
+
__fileName: fileName,
|
|
194
|
+
__contentType: mimeType
|
|
205
195
|
});
|
|
206
|
-
console.log('========================================');
|
|
207
|
-
responseData = await transport_1.blossomApiRequest.call(this, 'POST', endpoint, {}, formData);
|
|
208
196
|
}
|
|
209
197
|
else if (operation === 'deleteUsersCSV') {
|
|
210
198
|
const csvFile = this.getNodeParameter('csvFile', i);
|
|
211
|
-
let
|
|
199
|
+
let fileBuffer;
|
|
212
200
|
let fileName = 'delete_users.csv';
|
|
213
201
|
let mimeType = 'text/csv';
|
|
214
202
|
const binaryData = items[i].binary;
|
|
215
203
|
if (binaryData && binaryData[csvFile]) {
|
|
216
204
|
const binary = binaryData[csvFile];
|
|
217
|
-
|
|
205
|
+
fileBuffer = Buffer.from(binary.data, 'base64');
|
|
206
|
+
if (fileBuffer.length >= 3 &&
|
|
207
|
+
fileBuffer[0] === UTF8_BOM[0] &&
|
|
208
|
+
fileBuffer[1] === UTF8_BOM[1] &&
|
|
209
|
+
fileBuffer[2] === UTF8_BOM[2]) {
|
|
210
|
+
console.log('REMOVING UTF-8 BOM - Original length:', fileBuffer.length);
|
|
211
|
+
fileBuffer = Buffer.from(fileBuffer.toString('utf-8').substring(1), 'utf-8');
|
|
212
|
+
console.log('After BOM removal:', fileBuffer.length);
|
|
213
|
+
}
|
|
218
214
|
fileName = binary.fileName || 'delete_users.csv';
|
|
219
215
|
mimeType = binary.mimeType || 'text/csv';
|
|
220
216
|
}
|
|
221
217
|
else {
|
|
222
|
-
|
|
218
|
+
throw new Error(`Binary data not found for property "${csvFile}"`);
|
|
223
219
|
}
|
|
224
|
-
const formData = {
|
|
225
|
-
sheet_file: {
|
|
226
|
-
value: fileContent,
|
|
227
|
-
options: {
|
|
228
|
-
filename: fileName,
|
|
229
|
-
contentType: mimeType
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
220
|
console.log('DeleteUsersCSV Request:', {
|
|
234
221
|
endpoint: `DeleteUsersCSV/${parseInt(domain)}`,
|
|
235
|
-
fileName
|
|
236
|
-
|
|
237
|
-
|
|
222
|
+
fileName,
|
|
223
|
+
bufferLength: fileBuffer.length,
|
|
224
|
+
firstLine: fileBuffer.toString('utf-8').split('\n')[0]
|
|
225
|
+
});
|
|
226
|
+
responseData = await transport_1.blossomApiRequest.call(this, 'POST', `DeleteUsersCSV/${parseInt(domain)}`, {}, {
|
|
227
|
+
__isFileUpload: true,
|
|
228
|
+
__fieldName: 'sheet_file',
|
|
229
|
+
__fileBuffer: fileBuffer,
|
|
230
|
+
__fileName: fileName,
|
|
231
|
+
__contentType: mimeType
|
|
238
232
|
});
|
|
239
|
-
responseData = await transport_1.blossomApiRequest.call(this, 'POST', `DeleteUsersCSV/${parseInt(domain)}`, {}, formData);
|
|
240
233
|
}
|
|
241
234
|
else if (operation === 'setAvatar') {
|
|
242
235
|
const userIdentifier = this.getNodeParameter('userIdentifier.identifier', i, {});
|
|
243
236
|
const avatarFile = this.getNodeParameter('avatarFile', i);
|
|
244
237
|
const removeAvatar = this.getNodeParameter('removeAvatar', i);
|
|
245
|
-
|
|
238
|
+
const endpoint = `AvatarSet/${parseInt(domain)}/${Object.entries(userIdentifier).map(([k, v]) => `${k}=${v}`).join(',')}/${removeAvatar ? '1' : '0'}`;
|
|
239
|
+
console.log('SetAvatar Request:', { userIdentifier, removeAvatar, endpoint });
|
|
246
240
|
if (!removeAvatar && avatarFile) {
|
|
247
|
-
let fileContent;
|
|
248
|
-
let fileName = 'avatar.jpg';
|
|
249
|
-
let mimeType = 'image/jpeg';
|
|
250
241
|
const binaryData = items[i].binary;
|
|
251
242
|
if (binaryData && binaryData[avatarFile]) {
|
|
252
243
|
const binary = binaryData[avatarFile];
|
|
253
|
-
|
|
254
|
-
fileName = binary.fileName || 'avatar.jpg';
|
|
255
|
-
mimeType = binary.mimeType || 'image/jpeg';
|
|
244
|
+
const fileBuffer = Buffer.from(binary.data, 'base64');
|
|
245
|
+
const fileName = binary.fileName || 'avatar.jpg';
|
|
246
|
+
const mimeType = binary.mimeType || 'image/jpeg';
|
|
247
|
+
responseData = await transport_1.blossomApiRequest.call(this, 'POST', endpoint, {}, {
|
|
248
|
+
__isFileUpload: true,
|
|
249
|
+
__fieldName: 'avatarfile',
|
|
250
|
+
__fileBuffer: fileBuffer,
|
|
251
|
+
__fileName: fileName,
|
|
252
|
+
__contentType: mimeType
|
|
253
|
+
});
|
|
256
254
|
}
|
|
257
255
|
else {
|
|
258
|
-
|
|
256
|
+
throw new Error(`Binary data not found for property "${avatarFile}"`);
|
|
259
257
|
}
|
|
260
|
-
formData = {
|
|
261
|
-
avatarfile: {
|
|
262
|
-
value: fileContent,
|
|
263
|
-
options: {
|
|
264
|
-
filename: fileName,
|
|
265
|
-
contentType: mimeType
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
258
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
removeAvatar: removeAvatar,
|
|
274
|
-
hasAvatarFile: !!avatarFile,
|
|
275
|
-
domain: domain,
|
|
276
|
-
endpoint: endpoint
|
|
277
|
-
});
|
|
278
|
-
responseData = await transport_1.blossomApiRequest.call(this, 'POST', endpoint, {}, formData);
|
|
259
|
+
else {
|
|
260
|
+
responseData = await transport_1.blossomApiRequest.call(this, 'POST', endpoint, {}, {});
|
|
261
|
+
}
|
|
279
262
|
}
|
|
280
263
|
}
|
|
281
264
|
else if (resource === 'groups') {
|
|
@@ -309,36 +292,31 @@ class Blossom {
|
|
|
309
292
|
}
|
|
310
293
|
});
|
|
311
294
|
const optionsPath = optionParts.length > 0 ? `/${optionParts.join('&')}` : '';
|
|
312
|
-
let fileContent;
|
|
313
|
-
let fileName = 'groups.csv';
|
|
314
|
-
let mimeType = 'text/csv';
|
|
315
295
|
const binaryData = items[i].binary;
|
|
316
|
-
if (binaryData
|
|
317
|
-
|
|
318
|
-
fileContent = Buffer.from(binary.data, 'base64');
|
|
319
|
-
fileName = binary.fileName || 'groups.csv';
|
|
320
|
-
mimeType = binary.mimeType || 'text/csv';
|
|
296
|
+
if (!binaryData || !binaryData[csvFile]) {
|
|
297
|
+
throw new Error(`Binary data not found for property "${csvFile}"`);
|
|
321
298
|
}
|
|
322
|
-
|
|
323
|
-
|
|
299
|
+
const binary = binaryData[csvFile];
|
|
300
|
+
let fileBuffer = Buffer.from(binary.data, 'base64');
|
|
301
|
+
if (fileBuffer.length >= 3 &&
|
|
302
|
+
fileBuffer[0] === UTF8_BOM[0] &&
|
|
303
|
+
fileBuffer[1] === UTF8_BOM[1] &&
|
|
304
|
+
fileBuffer[2] === UTF8_BOM[2]) {
|
|
305
|
+
console.log('REMOVING UTF-8 BOM - Original length:', fileBuffer.length);
|
|
306
|
+
fileBuffer = Buffer.from(fileBuffer.toString('utf-8').substring(1), 'utf-8');
|
|
307
|
+
console.log('After BOM removal:', fileBuffer.length);
|
|
324
308
|
}
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
value: fileContent,
|
|
328
|
-
options: {
|
|
329
|
-
filename: fileName,
|
|
330
|
-
contentType: mimeType
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
};
|
|
309
|
+
const fileName = binary.fileName || 'groups.csv';
|
|
310
|
+
const mimeType = binary.mimeType || 'text/csv';
|
|
334
311
|
const endpoint = `ImportGroupsCSV/${parseInt(domain)}${optionsPath}`;
|
|
335
|
-
console.log('ImportGroupsCSV Request:', {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
312
|
+
console.log('ImportGroupsCSV Request:', { endpoint, fileName, bufferLength: fileBuffer.length, firstLine: fileBuffer.toString('utf-8').split('\n')[0] });
|
|
313
|
+
responseData = await transport_1.blossomApiRequest.call(this, 'POST', endpoint, {}, {
|
|
314
|
+
__isFileUpload: true,
|
|
315
|
+
__fieldName: 'sheet_file',
|
|
316
|
+
__fileBuffer: fileBuffer,
|
|
317
|
+
__fileName: fileName,
|
|
318
|
+
__contentType: mimeType
|
|
340
319
|
});
|
|
341
|
-
responseData = await transport_1.blossomApiRequest.call(this, 'POST', endpoint, {}, formData);
|
|
342
320
|
}
|
|
343
321
|
else if (operation === 'attachSubGroup') {
|
|
344
322
|
const subGroupIdentifier = this.getNodeParameter('subGroupIdentifier.identifier', i, {});
|
|
@@ -465,36 +443,31 @@ class Blossom {
|
|
|
465
443
|
}
|
|
466
444
|
});
|
|
467
445
|
const optionsPath = optionParts.length > 0 ? `/${optionParts.join('&')}` : '';
|
|
468
|
-
let fileContent;
|
|
469
|
-
let fileName = 'group_members.csv';
|
|
470
|
-
let mimeType = 'text/csv';
|
|
471
446
|
const binaryData = items[i].binary;
|
|
472
|
-
if (binaryData
|
|
473
|
-
|
|
474
|
-
fileContent = Buffer.from(binary.data, 'base64');
|
|
475
|
-
fileName = binary.fileName || 'group_members.csv';
|
|
476
|
-
mimeType = binary.mimeType || 'text/csv';
|
|
447
|
+
if (!binaryData || !binaryData[csvFile]) {
|
|
448
|
+
throw new Error(`Binary data not found for property "${csvFile}"`);
|
|
477
449
|
}
|
|
478
|
-
|
|
479
|
-
|
|
450
|
+
const binary = binaryData[csvFile];
|
|
451
|
+
let fileBuffer = Buffer.from(binary.data, 'base64');
|
|
452
|
+
if (fileBuffer.length >= 3 &&
|
|
453
|
+
fileBuffer[0] === UTF8_BOM[0] &&
|
|
454
|
+
fileBuffer[1] === UTF8_BOM[1] &&
|
|
455
|
+
fileBuffer[2] === UTF8_BOM[2]) {
|
|
456
|
+
console.log('REMOVING UTF-8 BOM - Original length:', fileBuffer.length);
|
|
457
|
+
fileBuffer = Buffer.from(fileBuffer.toString('utf-8').substring(1), 'utf-8');
|
|
458
|
+
console.log('After BOM removal:', fileBuffer.length);
|
|
480
459
|
}
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
value: fileContent,
|
|
484
|
-
options: {
|
|
485
|
-
filename: fileName,
|
|
486
|
-
contentType: mimeType
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
};
|
|
460
|
+
const fileName = binary.fileName || 'group_members.csv';
|
|
461
|
+
const mimeType = binary.mimeType || 'text/csv';
|
|
490
462
|
const endpoint = `ImportGroupsMembersCSV/${parseInt(domain)}${optionsPath}`;
|
|
491
|
-
console.log('ImportGroupsMembersCSV Request:', {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
463
|
+
console.log('ImportGroupsMembersCSV Request:', { endpoint, fileName, bufferLength: fileBuffer.length });
|
|
464
|
+
responseData = await transport_1.blossomApiRequest.call(this, 'POST', endpoint, {}, {
|
|
465
|
+
__isFileUpload: true,
|
|
466
|
+
__fieldName: 'sheet_file',
|
|
467
|
+
__fileBuffer: fileBuffer,
|
|
468
|
+
__fileName: fileName,
|
|
469
|
+
__contentType: mimeType
|
|
496
470
|
});
|
|
497
|
-
responseData = await transport_1.blossomApiRequest.call(this, 'POST', endpoint, {}, formData);
|
|
498
471
|
}
|
|
499
472
|
else if (operation === 'detachManager') {
|
|
500
473
|
const userIdentifier = this.getNodeParameter('userIdentifier.identifier', i, {});
|
|
@@ -565,108 +538,99 @@ class Blossom {
|
|
|
565
538
|
const domain = this.getNodeParameter('domain', i);
|
|
566
539
|
const csvFile = this.getNodeParameter('csvFile', i);
|
|
567
540
|
if (operation === 'importAssignmentPerformancesCSV') {
|
|
568
|
-
let fileContent;
|
|
569
|
-
let fileName = 'assignment_performances.csv';
|
|
570
|
-
let mimeType = 'text/csv';
|
|
571
541
|
const binaryData = items[i].binary;
|
|
572
|
-
if (binaryData
|
|
573
|
-
|
|
574
|
-
fileContent = Buffer.from(binary.data, 'base64');
|
|
575
|
-
fileName = binary.fileName || 'assignment_performances.csv';
|
|
576
|
-
mimeType = binary.mimeType || 'text/csv';
|
|
542
|
+
if (!binaryData || !binaryData[csvFile]) {
|
|
543
|
+
throw new Error(`Binary data not found for property "${csvFile}"`);
|
|
577
544
|
}
|
|
578
|
-
|
|
579
|
-
|
|
545
|
+
const binary = binaryData[csvFile];
|
|
546
|
+
let fileBuffer = Buffer.from(binary.data, 'base64');
|
|
547
|
+
if (fileBuffer.length >= 3 &&
|
|
548
|
+
fileBuffer[0] === UTF8_BOM[0] &&
|
|
549
|
+
fileBuffer[1] === UTF8_BOM[1] &&
|
|
550
|
+
fileBuffer[2] === UTF8_BOM[2]) {
|
|
551
|
+
console.log('REMOVING UTF-8 BOM - Original length:', fileBuffer.length);
|
|
552
|
+
fileBuffer = Buffer.from(fileBuffer.toString('utf-8').substring(1), 'utf-8');
|
|
553
|
+
console.log('After BOM removal:', fileBuffer.length);
|
|
580
554
|
}
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
value: fileContent,
|
|
584
|
-
options: {
|
|
585
|
-
filename: fileName,
|
|
586
|
-
contentType: mimeType
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
};
|
|
555
|
+
const fileName = binary.fileName || 'assignment_performances.csv';
|
|
556
|
+
const mimeType = binary.mimeType || 'text/csv';
|
|
590
557
|
console.log('ImportAssignmentPerformancesCSV Request:', {
|
|
591
558
|
endpoint: `ImportAssignmentPerformancesCSV/${parseInt(domain)}`,
|
|
592
|
-
fileName
|
|
593
|
-
|
|
559
|
+
fileName,
|
|
560
|
+
bufferLength: fileBuffer.length,
|
|
561
|
+
firstLine: fileBuffer.toString('utf-8').split('\n')[0]
|
|
562
|
+
});
|
|
563
|
+
responseData = await transport_1.blossomApiRequest.call(this, 'POST', `ImportAssignmentPerformancesCSV/${parseInt(domain)}`, {}, {
|
|
564
|
+
__isFileUpload: true,
|
|
565
|
+
__fieldName: 'sheet_file',
|
|
566
|
+
__fileBuffer: fileBuffer,
|
|
567
|
+
__fileName: fileName,
|
|
568
|
+
__contentType: mimeType
|
|
594
569
|
});
|
|
595
|
-
responseData = await transport_1.blossomApiRequest.call(this, 'POST', `ImportAssignmentPerformancesCSV/${parseInt(domain)}`, {}, formData);
|
|
596
570
|
}
|
|
597
571
|
else if (operation === 'importGroupPerformancesCSV') {
|
|
598
|
-
let fileContent;
|
|
599
|
-
let fileName = 'group_performances.csv';
|
|
600
|
-
let mimeType = 'text/csv';
|
|
601
572
|
const binaryData = items[i].binary;
|
|
602
|
-
if (binaryData
|
|
603
|
-
|
|
604
|
-
fileContent = Buffer.from(binary.data, 'base64');
|
|
605
|
-
fileName = binary.fileName || 'group_performances.csv';
|
|
606
|
-
mimeType = binary.mimeType || 'text/csv';
|
|
573
|
+
if (!binaryData || !binaryData[csvFile]) {
|
|
574
|
+
throw new Error(`Binary data not found for property "${csvFile}"`);
|
|
607
575
|
}
|
|
608
|
-
|
|
609
|
-
|
|
576
|
+
const binary = binaryData[csvFile];
|
|
577
|
+
let fileBuffer = Buffer.from(binary.data, 'base64');
|
|
578
|
+
if (fileBuffer.length >= 3 &&
|
|
579
|
+
fileBuffer[0] === UTF8_BOM[0] &&
|
|
580
|
+
fileBuffer[1] === UTF8_BOM[1] &&
|
|
581
|
+
fileBuffer[2] === UTF8_BOM[2]) {
|
|
582
|
+
console.log('REMOVING UTF-8 BOM - Original length:', fileBuffer.length);
|
|
583
|
+
fileBuffer = Buffer.from(fileBuffer.toString('utf-8').substring(1), 'utf-8');
|
|
584
|
+
console.log('After BOM removal:', fileBuffer.length);
|
|
610
585
|
}
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
value: fileContent,
|
|
614
|
-
options: {
|
|
615
|
-
filename: fileName,
|
|
616
|
-
contentType: mimeType
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
};
|
|
586
|
+
const fileName = binary.fileName || 'group_performances.csv';
|
|
587
|
+
const mimeType = binary.mimeType || 'text/csv';
|
|
620
588
|
console.log('ImportGroupPerformancesCSV Request:', {
|
|
621
589
|
endpoint: `ImportGroupPerformancesCSV/${parseInt(domain)}`,
|
|
622
|
-
fileName
|
|
623
|
-
|
|
590
|
+
fileName,
|
|
591
|
+
bufferLength: fileBuffer.length,
|
|
592
|
+
firstLine: fileBuffer.toString('utf-8').split('\n')[0]
|
|
593
|
+
});
|
|
594
|
+
responseData = await transport_1.blossomApiRequest.call(this, 'POST', `ImportGroupPerformancesCSV/${parseInt(domain)}`, {}, {
|
|
595
|
+
__isFileUpload: true,
|
|
596
|
+
__fieldName: 'sheet_file',
|
|
597
|
+
__fileBuffer: fileBuffer,
|
|
598
|
+
__fileName: fileName,
|
|
599
|
+
__contentType: mimeType
|
|
624
600
|
});
|
|
625
|
-
responseData = await transport_1.blossomApiRequest.call(this, 'POST', `ImportGroupPerformancesCSV/${parseInt(domain)}`, {}, formData);
|
|
626
601
|
}
|
|
627
602
|
else if (operation === 'uploadDiploma') {
|
|
628
603
|
const userIdentifier = this.getNodeParameter('userIdentifier.identifier', i, {});
|
|
629
604
|
const groupIdentifier = this.getNodeParameter('groupIdentifier.identifier', i, {});
|
|
630
605
|
const diplomaFile = this.getNodeParameter('diplomaFile', i);
|
|
631
606
|
const removeDiploma = this.getNodeParameter('removeDiploma', i);
|
|
632
|
-
|
|
607
|
+
const removeFlag = removeDiploma ? '1' : '0';
|
|
608
|
+
const userParam = userIdentifier.external_id || userIdentifier.user_id || userIdentifier.user_name || userIdentifier.identity_num;
|
|
609
|
+
const groupParam = groupIdentifier.group_external_id || groupIdentifier.group_id;
|
|
610
|
+
const endpoint = `UploadDiploma/${parseInt(domain)}/${userParam}/${groupParam}/${removeFlag}`;
|
|
611
|
+
console.log('UploadDiploma Request:', { userIdentifier, groupIdentifier, removeDiploma, endpoint });
|
|
633
612
|
if (!removeDiploma && diplomaFile) {
|
|
634
|
-
let fileContent;
|
|
635
|
-
let fileName = 'diploma.pdf';
|
|
636
|
-
let mimeType = 'application/pdf';
|
|
637
613
|
const binaryData = items[i].binary;
|
|
638
614
|
if (binaryData && binaryData[diplomaFile]) {
|
|
639
615
|
const binary = binaryData[diplomaFile];
|
|
640
|
-
|
|
641
|
-
fileName = binary.fileName || 'diploma.pdf';
|
|
642
|
-
mimeType = binary.mimeType || 'application/pdf';
|
|
616
|
+
const fileBuffer = Buffer.from(binary.data, 'base64');
|
|
617
|
+
const fileName = binary.fileName || 'diploma.pdf';
|
|
618
|
+
const mimeType = binary.mimeType || 'application/pdf';
|
|
619
|
+
responseData = await transport_1.blossomApiRequest.call(this, 'POST', endpoint, {}, {
|
|
620
|
+
__isFileUpload: true,
|
|
621
|
+
__fieldName: 'diploma_file',
|
|
622
|
+
__fileBuffer: fileBuffer,
|
|
623
|
+
__fileName: fileName,
|
|
624
|
+
__contentType: mimeType
|
|
625
|
+
});
|
|
643
626
|
}
|
|
644
627
|
else {
|
|
645
|
-
|
|
628
|
+
throw new Error(`Binary data not found for property "${diplomaFile}"`);
|
|
646
629
|
}
|
|
647
|
-
formData = {
|
|
648
|
-
diploma_file: {
|
|
649
|
-
value: fileContent,
|
|
650
|
-
options: {
|
|
651
|
-
filename: fileName,
|
|
652
|
-
contentType: mimeType
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
};
|
|
656
630
|
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
const endpoint = `UploadDiploma/${parseInt(domain)}/${userParam}/${groupParam}/${removeFlag}`;
|
|
661
|
-
console.log('UploadDiploma Request:', {
|
|
662
|
-
userIdentifier: userIdentifier,
|
|
663
|
-
groupIdentifier: groupIdentifier,
|
|
664
|
-
removeDiploma: removeDiploma,
|
|
665
|
-
hasDiplomaFile: !!diplomaFile,
|
|
666
|
-
domain: domain,
|
|
667
|
-
endpoint: endpoint
|
|
668
|
-
});
|
|
669
|
-
responseData = await transport_1.blossomApiRequest.call(this, 'POST', endpoint, {}, formData);
|
|
631
|
+
else {
|
|
632
|
+
responseData = await transport_1.blossomApiRequest.call(this, 'POST', endpoint, {}, {});
|
|
633
|
+
}
|
|
670
634
|
}
|
|
671
635
|
}
|
|
672
636
|
returnData.push({
|