5htp-core 0.6.0-81 → 0.6.0-83
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/common/errors/index.tsx +2 -2
- package/package.json +1 -1
- package/server/app/container/console/index.ts +24 -16
- package/server/utils/rte.ts +44 -16
- package/types/icons.d.ts +1 -1
package/common/errors/index.tsx
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp-core",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.6.0-
|
|
4
|
+
"version": "0.6.0-83",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -310,16 +310,26 @@ export default class Console {
|
|
|
310
310
|
|
|
311
311
|
// On envoi l'email avant l'insertion dans bla bdd
|
|
312
312
|
// Car cette denrière a plus de chances de provoquer une erreur
|
|
313
|
-
const logs = this.logs.filter(e => e.channel.channelId === channelId).slice(-100);
|
|
313
|
+
//const logs = this.logs.filter(e => e.channel.channelId === channelId).slice(-100);
|
|
314
|
+
const stacktraces: string[] = [];
|
|
315
|
+
const context: object[] = [];
|
|
314
316
|
|
|
315
|
-
const errors: TCatchedError[] = []
|
|
316
317
|
let currentError: TCatchedError | undefined = error;
|
|
317
318
|
let title: string | undefined;
|
|
318
319
|
while (currentError !== undefined) {
|
|
319
320
|
|
|
321
|
+
if (title === undefined)
|
|
322
|
+
title = currentError.message;
|
|
323
|
+
|
|
324
|
+
// Stacktrace
|
|
320
325
|
this.logger.error(LogPrefix, `Sending bug report for the following error:`, currentError);
|
|
321
|
-
|
|
326
|
+
stacktraces.push(currentError.stack || currentError.message);
|
|
327
|
+
|
|
328
|
+
// Context
|
|
329
|
+
if (('dataForDebugging' in currentError) && currentError.dataForDebugging !== undefined) {
|
|
322
330
|
console.error(LogPrefix, `More data about the error:`, currentError.dataForDebugging);
|
|
331
|
+
context.push(currentError.dataForDebugging || {});
|
|
332
|
+
}
|
|
323
333
|
|
|
324
334
|
// Print the error so it's accessible via logs
|
|
325
335
|
if (currentError instanceof SqlError) {
|
|
@@ -332,10 +342,7 @@ export default class Console {
|
|
|
332
342
|
console.error(`Error caused by this query:`, printedQuery);
|
|
333
343
|
}
|
|
334
344
|
|
|
335
|
-
|
|
336
|
-
title = currentError.message;
|
|
337
|
-
|
|
338
|
-
errors.push(currentError);
|
|
345
|
+
// Go deeper
|
|
339
346
|
currentError = 'originalError' in currentError
|
|
340
347
|
? currentError.originalError
|
|
341
348
|
: undefined
|
|
@@ -369,8 +376,8 @@ export default class Console {
|
|
|
369
376
|
|
|
370
377
|
// Error
|
|
371
378
|
title,
|
|
372
|
-
|
|
373
|
-
|
|
379
|
+
stacktraces,
|
|
380
|
+
context
|
|
374
381
|
}
|
|
375
382
|
|
|
376
383
|
await application.runHook('bug', bugReport);
|
|
@@ -394,14 +401,15 @@ export default class Console {
|
|
|
394
401
|
<b>User</b>: ${report.user ? (report.user.name + ' (' + report.user.email + ')') : 'Unknown'}<br />
|
|
395
402
|
<b>IP</b>: ${report.ip}<br />
|
|
396
403
|
|
|
397
|
-
${report.
|
|
404
|
+
${report.stacktraces.map((stacktrace, index) => `
|
|
405
|
+
<hr />
|
|
406
|
+
<b>Error ${index + 1}</b>:
|
|
407
|
+
${this.printHtml(stacktrace)}<br />
|
|
408
|
+
`).join('')}
|
|
409
|
+
|
|
410
|
+
${report.context.map((context, index) => `
|
|
398
411
|
<hr />
|
|
399
|
-
<b>
|
|
400
|
-
${this.printHtml(e.stack || e.message)}<br />
|
|
401
|
-
${'dataForDebugging' in e ? `
|
|
402
|
-
<b>Data for debugging</b><br />
|
|
403
|
-
${this.jsonToHTML(e.dataForDebugging)}<br />
|
|
404
|
-
` : ''}
|
|
412
|
+
<b>Context ${index + 1}</b>: ${this.jsonToHTML(context)}<br />
|
|
405
413
|
`).join('')}
|
|
406
414
|
|
|
407
415
|
${report.request ? `
|
package/server/utils/rte.ts
CHANGED
|
@@ -346,24 +346,52 @@ export class RteUtils {
|
|
|
346
346
|
return html;
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
private jsonToText(
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
349
|
+
private jsonToText(root: LexicalNode): string {
|
|
350
|
+
let result = '';
|
|
351
|
+
|
|
352
|
+
function traverse(node: LexicalNode) {
|
|
353
|
+
switch (node.type) {
|
|
354
|
+
case 'text':
|
|
355
|
+
// Leaf text node
|
|
356
|
+
result += node.text ?? '';
|
|
357
|
+
break;
|
|
358
|
+
case 'linebreak':
|
|
359
|
+
// Explicit line break node
|
|
360
|
+
result += '\n';
|
|
361
|
+
break;
|
|
362
|
+
default:
|
|
363
|
+
// Container or block node: dive into children if any
|
|
364
|
+
if (node.children) {
|
|
365
|
+
node.children.forEach(traverse);
|
|
366
|
+
}
|
|
367
|
+
// After finishing a block-level node, append newline
|
|
368
|
+
if (isBlockNode(node.type)) {
|
|
369
|
+
result += '\n';
|
|
370
|
+
}
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
356
373
|
}
|
|
357
|
-
|
|
358
|
-
//
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
374
|
+
|
|
375
|
+
// Heuristic: treat these as blocks
|
|
376
|
+
function isBlockNode(type: string): boolean {
|
|
377
|
+
return [
|
|
378
|
+
'root',
|
|
379
|
+
'paragraph',
|
|
380
|
+
'heading',
|
|
381
|
+
'listitem',
|
|
382
|
+
'unorderedlist',
|
|
383
|
+
'orderedlist',
|
|
384
|
+
'quote',
|
|
385
|
+
'codeblock',
|
|
386
|
+
'table',
|
|
387
|
+
].includes(type);
|
|
363
388
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
389
|
+
|
|
390
|
+
traverse(root);
|
|
391
|
+
|
|
392
|
+
// Trim trailing whitespace/newlines
|
|
393
|
+
return result.replace(/\s+$/, '');
|
|
394
|
+
}
|
|
367
395
|
|
|
368
396
|
public async htmlToJson(htmlString: string): Promise<LexicalState> {
|
|
369
397
|
|
package/types/icons.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type TIcones = "
|
|
1
|
+
export type TIcones = "times"|"solid/spinner-third"|"long-arrow-right"|"sack-dollar"|"bell"|"bullseye"|"project-diagram"|"user-friends"|"eye"|"lock"|"comments"|"phone"|"chalkboard-teacher"|"rocket"|"chart-bar"|"user-circle"|"crosshairs"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"arrow-right"|"plus-circle"|"comments-alt"|"key"|"user"|"at"|"user-plus"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"magnet"|"paper-plane"|"plus"|"binoculars"|"brands/linkedin"|"clock"|"cog"|"trash"|"ellipsis-h"|"times-circle"|"search"|"lightbulb"|"calendar-alt"|"angle-up"|"angle-down"|"solid/crown"|"brands/discord"|"pen"|"file"|"envelope"|"coins"|"download"|"check"|"meh-rolling-eyes"|"arrow-left"|"info-circle"|"check-circle"|"exclamation-circle"|"bars"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"power-off"|"plane-departure"|"brands/whatsapp"|"wind"|"play"|"minus-circle"|"broom"|"exclamation-triangle"|"external-link"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"question-circle"|"minus"|"comment-alt"|"map-marker-alt"|"arrow-to-bottom"|"solid/magic"|"users"|"industry"|"map-marker"|"calendar"|"briefcase"|"fire"|"globe"|"magic"|"bug"|"building"|"graduation-cap"|"coin"|"unlink"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"code"|"font"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"
|