@mostfeatured/dbi 0.2.29-dev.1 → 0.2.30

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.
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Discord Components V2 Error Parser
3
+ * Parses Discord API errors and provides helpful, developer-friendly error messages
4
+ * that map component indices to actual HTML elements with their outerHTML
5
+ */
6
+ export interface ComponentErrorInfo {
7
+ /** Original error path like "components[0].components[4].accessory" */
8
+ path: string;
9
+ /** Error code like "BASE_TYPE_REQUIRED" */
10
+ code: string;
11
+ /** Error message from Discord */
12
+ message: string;
13
+ /** Parsed path segments for navigation */
14
+ pathSegments: PathSegment[];
15
+ /** Human-readable explanation of what went wrong */
16
+ explanation: string;
17
+ /** Suggested fix */
18
+ suggestion: string;
19
+ /** The actual HTML element's outerHTML that caused the error */
20
+ htmlElement?: string;
21
+ /** Annotation about what's wrong with this element */
22
+ htmlAnnotation?: string;
23
+ }
24
+ export interface PathSegment {
25
+ type: 'array' | 'property';
26
+ key: string | number;
27
+ }
28
+ export interface ParsedDiscordError {
29
+ /** Original error object */
30
+ original: any;
31
+ /** Parsed component errors */
32
+ componentErrors: ComponentErrorInfo[];
33
+ /** Formatted error message for display */
34
+ formattedMessage: string;
35
+ }
36
+ /**
37
+ * Parse Discord API errors into user-friendly format
38
+ */
39
+ export declare function parseDiscordComponentError(error: any, components?: any[], sourceHTML?: string): ParsedDiscordError;
40
+ /**
41
+ * Create a user-friendly error with enhanced message
42
+ */
43
+ export declare function createEnhancedError(originalError: any, components?: any[], sourceHTML?: string, componentName?: string): Error;
44
+ /**
45
+ * Check if an error is a Discord component validation error
46
+ */
47
+ export declare function isComponentValidationError(error: any): boolean;
48
+ /**
49
+ * Wrap an async function to enhance Discord component errors
50
+ */
51
+ export declare function withEnhancedErrors<T extends (...args: any[]) => Promise<any>>(fn: T, options?: {
52
+ components?: any[];
53
+ sourceHTML?: string;
54
+ componentName?: string;
55
+ }): T;
56
+ //# sourceMappingURL=errorParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorParser.d.ts","sourceRoot":"","sources":["../../../../../src/types/Components/HTMLComponentsV2/errorParser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,QAAQ,EAAE,GAAG,CAAC;IACd,8BAA8B;IAC9B,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,0CAA0C;IAC1C,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AA8PD;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,GAAG,EACV,UAAU,CAAC,EAAE,GAAG,EAAE,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,kBAAkB,CA6DpB;AAuGD;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,GAAG,EAClB,UAAU,CAAC,EAAE,GAAG,EAAE,EAClB,UAAU,CAAC,EAAE,MAAM,EACnB,aAAa,CAAC,EAAE,MAAM,GACrB,KAAK,CAkBP;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAa9D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EAC3E,EAAE,EAAE,CAAC,EACL,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,GAChF,CAAC,CAWH"}
@@ -0,0 +1,447 @@
1
+ "use strict";
2
+ /**
3
+ * Discord Components V2 Error Parser
4
+ * Parses Discord API errors and provides helpful, developer-friendly error messages
5
+ * that map component indices to actual HTML elements with their outerHTML
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.parseDiscordComponentError = parseDiscordComponentError;
9
+ exports.createEnhancedError = createEnhancedError;
10
+ exports.isComponentValidationError = isComponentValidationError;
11
+ exports.withEnhancedErrors = withEnhancedErrors;
12
+ const jsdom_1 = require("jsdom");
13
+ // Known Discord error codes and their explanations
14
+ const ERROR_CODE_EXPLANATIONS = {
15
+ 'BASE_TYPE_REQUIRED': {
16
+ explanation: 'This field is required but is empty or missing!',
17
+ suggestion: 'Add the required content or attributes to the element'
18
+ },
19
+ 'BASE_TYPE_BAD_LENGTH': {
20
+ explanation: 'Wrong number of child elements (section requires 1-3)',
21
+ suggestion: 'A <section> must contain 1-3 <components> elements inside it'
22
+ },
23
+ 'BASE_TYPE_MAX_LENGTH': {
24
+ explanation: 'Value exceeds maximum length',
25
+ suggestion: 'Reduce the text content or number of items'
26
+ },
27
+ 'BASE_TYPE_MIN_LENGTH': {
28
+ explanation: 'Value is below minimum length',
29
+ suggestion: 'Add more content or items'
30
+ },
31
+ 'BASE_TYPE_CHOICES': {
32
+ explanation: 'Value is not one of the allowed choices',
33
+ suggestion: 'Use a valid option for this field'
34
+ },
35
+ 'STRING_TYPE_REGEX': {
36
+ explanation: 'String value does not match required format',
37
+ suggestion: 'Check the format requirements for this field'
38
+ },
39
+ 'NUMBER_TYPE_MIN': {
40
+ explanation: 'Number is below minimum value',
41
+ suggestion: 'Increase the number to meet minimum requirement'
42
+ },
43
+ 'NUMBER_TYPE_MAX': {
44
+ explanation: 'Number exceeds maximum value',
45
+ suggestion: 'Keep the number within limits'
46
+ },
47
+ 'COMPONENT_LAYOUT_WIDTH_EXCEEDED': {
48
+ explanation: 'Row exceeds maximum width (5 units for buttons)',
49
+ suggestion: 'Move some components to a new action-row'
50
+ },
51
+ 'COMPONENT_CUSTOM_ID_DUPLICATED': {
52
+ explanation: 'Multiple components have the same custom_id',
53
+ suggestion: 'Each interactive element must have a unique name/id'
54
+ },
55
+ };
56
+ // Component type names for better error messages
57
+ const COMPONENT_TYPE_NAMES = {
58
+ 1: 'ActionRow',
59
+ 2: 'Button',
60
+ 3: 'StringSelect',
61
+ 4: 'TextInput',
62
+ 5: 'UserSelect',
63
+ 6: 'RoleSelect',
64
+ 7: 'MentionableSelect',
65
+ 8: 'ChannelSelect',
66
+ 9: 'Section',
67
+ 10: 'TextDisplay',
68
+ 12: 'MediaGallery',
69
+ 13: 'File',
70
+ 14: 'Separator',
71
+ 17: 'Container',
72
+ };
73
+ // Discord component HTML tag names (used to filter elements)
74
+ const DISCORD_COMPONENT_TAGS = new Set([
75
+ 'container', 'action-row', 'button', 'string-select', 'string-select-menu',
76
+ 'user-select', 'user-select-menu', 'role-select', 'role-select-menu',
77
+ 'mentionable-select', 'mentionable-select-menu', 'channel-select', 'channel-select-menu',
78
+ 'text-input', 'text-display', 'section', 'separator', 'media-gallery', 'file',
79
+ 'thumbnail', 'accessory', 'field'
80
+ ]);
81
+ /**
82
+ * Parse a Discord API error path like "components[0].components[4].accessory"
83
+ * Returns array of segments for navigation
84
+ */
85
+ function parseErrorPath(path) {
86
+ const segments = [];
87
+ // Match both property.name and [index] patterns
88
+ const regex = /\.?(\w+)|\[(\d+)\]/g;
89
+ let match;
90
+ while ((match = regex.exec(path)) !== null) {
91
+ if (match[1]) {
92
+ segments.push({ type: 'property', key: match[1] });
93
+ }
94
+ else if (match[2]) {
95
+ segments.push({ type: 'array', key: parseInt(match[2], 10) });
96
+ }
97
+ }
98
+ return segments;
99
+ }
100
+ /**
101
+ * Check if an element tag is a Discord component
102
+ */
103
+ function isDiscordComponentTag(tag) {
104
+ return DISCORD_COMPONENT_TAGS.has(tag.toLowerCase());
105
+ }
106
+ /**
107
+ * Get Discord component children of an element (filters out non-component elements)
108
+ */
109
+ function getComponentChildren(element) {
110
+ return Array.from(element.children).filter(child => isDiscordComponentTag(child.tagName.toLowerCase()));
111
+ }
112
+ /**
113
+ * Navigate HTML DOM following Discord's component path
114
+ * Returns the exact element that has the error
115
+ */
116
+ function findHTMLElementByPath(sourceHTML, segments, components) {
117
+ try {
118
+ const dom = new jsdom_1.JSDOM(`<root>${sourceHTML}</root>`);
119
+ const document = dom.window.document;
120
+ const root = document.querySelector('root');
121
+ if (!root)
122
+ return null;
123
+ // Find the main components container (skip modal type)
124
+ let currentElement = root.querySelector('components:not([type="modal"])') || root;
125
+ let currentComponentsArray = components;
126
+ for (let i = 0; i < segments.length; i++) {
127
+ const segment = segments[i];
128
+ if (!currentElement)
129
+ return null;
130
+ if (segment.type === 'property') {
131
+ const key = segment.key;
132
+ if (key === 'components') {
133
+ // "components" property means we look at children - continue to array index
134
+ continue;
135
+ }
136
+ else if (key === 'accessory') {
137
+ // Find <accessory> child
138
+ const accessory = currentElement.querySelector(':scope > accessory');
139
+ if (accessory) {
140
+ currentElement = accessory;
141
+ }
142
+ else {
143
+ // Accessory is MISSING - this is the error!
144
+ return {
145
+ element: currentElement,
146
+ annotation: `<accessory> element is missing! This element should contain an <accessory>.`
147
+ };
148
+ }
149
+ }
150
+ else if (key === 'content' || key === 'label' || key === 'title' || key === 'placeholder' || key === 'url' || key === 'custom_id') {
151
+ // These are text/attribute properties - return current element
152
+ return {
153
+ element: currentElement,
154
+ annotation: `Error in the "${key}" field.`
155
+ };
156
+ }
157
+ }
158
+ else if (segment.type === 'array') {
159
+ const index = segment.key;
160
+ // Get component children (filter out non-component elements)
161
+ const componentChildren = getComponentChildren(currentElement);
162
+ if (index < componentChildren.length) {
163
+ currentElement = componentChildren[index];
164
+ // Update the JSON components array reference for the next iteration
165
+ if (currentComponentsArray && Array.isArray(currentComponentsArray) && currentComponentsArray[index]) {
166
+ currentComponentsArray = currentComponentsArray[index].components;
167
+ }
168
+ }
169
+ else {
170
+ // Index out of bounds - not enough children
171
+ return {
172
+ element: currentElement,
173
+ annotation: `Expected child element #${index + 1} but only found ${componentChildren.length}!`
174
+ };
175
+ }
176
+ }
177
+ }
178
+ return currentElement ? { element: currentElement } : null;
179
+ }
180
+ catch (e) {
181
+ return null;
182
+ }
183
+ }
184
+ /**
185
+ * Format outerHTML for display - indent and optionally truncate
186
+ */
187
+ function formatOuterHTML(outerHTML, maxLength = 600) {
188
+ // Pretty format by adding newlines
189
+ let formatted = outerHTML
190
+ .replace(/></g, '>\n<')
191
+ .replace(/>\s+</g, '>\n<');
192
+ // Truncate if too long
193
+ if (formatted.length > maxLength) {
194
+ const half = Math.floor(maxLength / 2) - 30;
195
+ formatted = formatted.substring(0, half) + '\n ... (truncated) ...\n' + formatted.substring(formatted.length - half);
196
+ }
197
+ // Basic indentation
198
+ const lines = formatted.split('\n');
199
+ let indent = 0;
200
+ const indented = lines.map(line => {
201
+ const trimmed = line.trim();
202
+ if (trimmed.startsWith('</'))
203
+ indent = Math.max(0, indent - 1);
204
+ const result = ' '.repeat(indent) + trimmed;
205
+ if (trimmed.startsWith('<') && !trimmed.startsWith('</') && !trimmed.endsWith('/>') && !trimmed.includes('</')) {
206
+ indent++;
207
+ }
208
+ return result;
209
+ });
210
+ return indented.join('\n');
211
+ }
212
+ /**
213
+ * Navigate through JSON components tree for breadcrumb generation
214
+ */
215
+ function navigateComponentTree(components, segments) {
216
+ let current = { components };
217
+ const breadcrumb = [];
218
+ for (const segment of segments) {
219
+ if (segment.type === 'property') {
220
+ const key = segment.key;
221
+ if (current && typeof current === 'object' && key in current) {
222
+ current = current[key];
223
+ if (key !== 'components' && key !== 'data') {
224
+ breadcrumb.push(key);
225
+ }
226
+ }
227
+ else {
228
+ return null;
229
+ }
230
+ }
231
+ else if (segment.type === 'array') {
232
+ const index = segment.key;
233
+ if (Array.isArray(current) && index < current.length) {
234
+ current = current[index];
235
+ const typeName = current?.type ? (COMPONENT_TYPE_NAMES[current.type] || `Type${current.type}`) : 'Element';
236
+ const name = current?.custom_id?.split('$')[1]?.split('/')[0] ||
237
+ current?.label ||
238
+ current?.placeholder?.substring(0, 20) ||
239
+ '';
240
+ breadcrumb.push(`${typeName}[${index}]${name ? ` "${name}"` : ''}`);
241
+ }
242
+ else {
243
+ return null;
244
+ }
245
+ }
246
+ }
247
+ return { breadcrumb };
248
+ }
249
+ /**
250
+ * Parse Discord API errors into user-friendly format
251
+ */
252
+ function parseDiscordComponentError(error, components, sourceHTML) {
253
+ const componentErrors = [];
254
+ // Try to extract error details from various Discord.js error formats
255
+ let rawErrors = {};
256
+ if (error.rawError?.errors) {
257
+ rawErrors = flattenDiscordErrors(error.rawError.errors);
258
+ }
259
+ else if (error.errors) {
260
+ rawErrors = flattenDiscordErrors(error.errors);
261
+ }
262
+ else if (typeof error.message === 'string') {
263
+ const lines = error.message.split('\n');
264
+ for (const line of lines) {
265
+ const match = line.match(/^([\w\[\]\.]+)\[(\w+)\]:\s*(.+)$/);
266
+ if (match) {
267
+ const [, path, code, message] = match;
268
+ if (!rawErrors[path])
269
+ rawErrors[path] = [];
270
+ rawErrors[path].push({ code, message });
271
+ }
272
+ }
273
+ }
274
+ // Process each error
275
+ for (const [path, errors] of Object.entries(rawErrors)) {
276
+ for (const { code, message } of errors) {
277
+ const pathSegments = parseErrorPath(path);
278
+ const errorInfo = ERROR_CODE_EXPLANATIONS[code] || {
279
+ explanation: message,
280
+ suggestion: 'Check the Discord API documentation for this error'
281
+ };
282
+ const errorEntry = {
283
+ path,
284
+ code,
285
+ message,
286
+ pathSegments,
287
+ explanation: errorInfo.explanation,
288
+ suggestion: errorInfo.suggestion
289
+ };
290
+ // Find the actual HTML element using JSDOM
291
+ if (sourceHTML) {
292
+ const htmlResult = findHTMLElementByPath(sourceHTML, pathSegments, components);
293
+ if (htmlResult) {
294
+ errorEntry.htmlElement = formatOuterHTML(htmlResult.element.outerHTML);
295
+ errorEntry.htmlAnnotation = htmlResult.annotation;
296
+ }
297
+ }
298
+ componentErrors.push(errorEntry);
299
+ }
300
+ }
301
+ // Generate formatted message
302
+ const formattedMessage = generateFormattedMessage(componentErrors, components, error);
303
+ return {
304
+ original: error,
305
+ componentErrors,
306
+ formattedMessage
307
+ };
308
+ }
309
+ /**
310
+ * Generate a beautifully formatted error message with actual HTML snippets
311
+ */
312
+ function generateFormattedMessage(errors, components, originalError) {
313
+ let msg = '\n';
314
+ msg += '╔══════════════════════════════════════════════════════════════════════════════╗\n';
315
+ msg += '║ 🚨 Discord Components V2 - Validation Error ║\n';
316
+ msg += '╠══════════════════════════════════════════════════════════════════════════════╣\n';
317
+ if (errors.length === 0) {
318
+ msg += `║ ${originalError?.message || 'Unknown error'}\n`;
319
+ }
320
+ else {
321
+ for (let i = 0; i < errors.length; i++) {
322
+ const err = errors[i];
323
+ // Generate breadcrumb from components tree
324
+ let breadcrumb = 'Unknown';
325
+ if (components) {
326
+ const nav = navigateComponentTree(components, err.pathSegments);
327
+ if (nav && nav.breadcrumb.length > 0) {
328
+ breadcrumb = nav.breadcrumb.join(' → ');
329
+ }
330
+ }
331
+ msg += '║\n';
332
+ msg += `║ ❌ Error ${i + 1}/${errors.length}\n`;
333
+ msg += '║ ┌────────────────────────────────────────────────────────────────────────────\n';
334
+ msg += `║ │ 📍 Path: ${err.path}\n`;
335
+ msg += `║ │ 🏷️ Code: ${err.code}\n`;
336
+ msg += `║ │ 📂 Location: ${breadcrumb}\n`;
337
+ msg += '║ │\n';
338
+ msg += `║ │ ⚠️ Problem: ${err.explanation}\n`;
339
+ msg += `║ │ 💡 Solution: ${err.suggestion}\n`;
340
+ // Show the actual HTML element that caused the error - THIS IS THE KEY FEATURE!
341
+ if (err.htmlElement) {
342
+ msg += '║ │\n';
343
+ if (err.htmlAnnotation) {
344
+ msg += `║ │ 🔍 ${err.htmlAnnotation}\n`;
345
+ }
346
+ msg += '║ │ 📄 Problematic HTML Element:\n';
347
+ msg += '║ │ ┌──────────────────────────────────────────────────────────────────────\n';
348
+ // Show the actual outerHTML with indentation
349
+ const htmlLines = err.htmlElement.split('\n');
350
+ for (const line of htmlLines) {
351
+ msg += `║ │ │ ${line}\n`;
352
+ }
353
+ msg += '║ │ └──────────────────────────────────────────────────────────────────────\n';
354
+ }
355
+ msg += '║ └────────────────────────────────────────────────────────────────────────────\n';
356
+ }
357
+ }
358
+ msg += '║\n';
359
+ msg += '╚══════════════════════════════════════════════════════════════════════════════╝\n';
360
+ return msg;
361
+ }
362
+ /**
363
+ * Flatten nested Discord error objects into a path-based map
364
+ */
365
+ function flattenDiscordErrors(obj, prefix = '') {
366
+ const result = {};
367
+ if (!obj || typeof obj !== 'object')
368
+ return result;
369
+ // Check if this is an error entry
370
+ if (obj._errors && Array.isArray(obj._errors)) {
371
+ const cleanPrefix = prefix.replace(/^data\./, '');
372
+ result[cleanPrefix] = obj._errors.map((e) => ({
373
+ code: e.code || 'UNKNOWN',
374
+ message: e.message || 'Unknown error'
375
+ }));
376
+ }
377
+ // Recurse into nested objects
378
+ for (const [key, value] of Object.entries(obj)) {
379
+ if (key === '_errors')
380
+ continue;
381
+ let newPrefix;
382
+ if (/^\d+$/.test(key)) {
383
+ // It's an array index - use bracket notation
384
+ newPrefix = prefix ? `${prefix}[${key}]` : `[${key}]`;
385
+ }
386
+ else {
387
+ newPrefix = prefix ? `${prefix}.${key}` : key;
388
+ }
389
+ const nested = flattenDiscordErrors(value, newPrefix);
390
+ Object.assign(result, nested);
391
+ }
392
+ return result;
393
+ }
394
+ /**
395
+ * Create a user-friendly error with enhanced message
396
+ */
397
+ function createEnhancedError(originalError, components, sourceHTML, componentName) {
398
+ const parsed = parseDiscordComponentError(originalError, components, sourceHTML);
399
+ let enhancedMessage = `[DBI-ComponentsV2] ${componentName ? `Component "${componentName}" ` : ''}Discord API rejected the components:\n\n`;
400
+ enhancedMessage += parsed.formattedMessage;
401
+ const enhancedError = new Error(enhancedMessage);
402
+ enhancedError.originalError = originalError;
403
+ enhancedError.componentErrors = parsed.componentErrors;
404
+ enhancedError.parsedError = parsed;
405
+ enhancedError.type = 'discord-component-validation';
406
+ // Preserve stack trace
407
+ if (originalError.stack) {
408
+ enhancedError.stack = enhancedError.message + '\n\nOriginal stack:\n' + originalError.stack;
409
+ }
410
+ return enhancedError;
411
+ }
412
+ /**
413
+ * Check if an error is a Discord component validation error
414
+ */
415
+ function isComponentValidationError(error) {
416
+ if (!error)
417
+ return false;
418
+ // Check for common Discord.js error patterns
419
+ if (error.code === 50035)
420
+ return true; // Invalid Form Body
421
+ if (error.rawError?.code === 50035)
422
+ return true;
423
+ // Check error message patterns
424
+ const message = error.message || '';
425
+ if (message.includes('components[') && message.includes('[BASE_TYPE'))
426
+ return true;
427
+ if (message.includes('Invalid Form Body'))
428
+ return true;
429
+ return false;
430
+ }
431
+ /**
432
+ * Wrap an async function to enhance Discord component errors
433
+ */
434
+ function withEnhancedErrors(fn, options = {}) {
435
+ return (async (...args) => {
436
+ try {
437
+ return await fn(...args);
438
+ }
439
+ catch (error) {
440
+ if (isComponentValidationError(error)) {
441
+ throw createEnhancedError(error, options.components, options.sourceHTML, options.componentName);
442
+ }
443
+ throw error;
444
+ }
445
+ });
446
+ }
447
+ //# sourceMappingURL=errorParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorParser.js","sourceRoot":"","sources":["../../../../../src/types/Components/HTMLComponentsV2/errorParser.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAoSH,gEAiEC;AA0GD,kDAuBC;AAKD,gEAaC;AAKD,gDAcC;AAzgBD,iCAA8B;AAmC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AC,KAAK,EAAE,GAAG,IAAW,EAAE,EAAE;QAC/B,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,0BAA0B,CAAC,KAAK,CAAC,EAAE,CAAC;gBACtC,MAAM,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;YAClG,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAM,CAAC;AACV,CAAC","sourcesContent":["/**\r\n * Discord Components V2 Error Parser\r\n * Parses Discord API errors and provides helpful, developer-friendly error messages\r\n * that map component indices to actual HTML elements with their outerHTML\r\n */\r\n\r\nimport { JSDOM } from \"jsdom\";\r\n\r\nexport interface ComponentErrorInfo {\r\n /** Original error path like \"components[0].components[4].accessory\" */\r\n path: string;\r\n /** Error code like \"BASE_TYPE_REQUIRED\" */\r\n code: string;\r\n /** Error message from Discord */\r\n message: string;\r\n /** Parsed path segments for navigation */\r\n pathSegments: PathSegment[];\r\n /** Human-readable explanation of what went wrong */\r\n explanation: string;\r\n /** Suggested fix */\r\n suggestion: string;\r\n /** The actual HTML element's outerHTML that caused the error */\r\n htmlElement?: string;\r\n /** Annotation about what's wrong with this element */\r\n htmlAnnotation?: string;\r\n}\r\n\r\nexport interface PathSegment {\r\n type: 'array' | 'property';\r\n key: string | number;\r\n}\r\n\r\nexport interface ParsedDiscordError {\r\n /** Original error object */\r\n original: any;\r\n /** Parsed component errors */\r\n componentErrors: ComponentErrorInfo[];\r\n /** Formatted error message for display */\r\n formattedMessage: string;\r\n}\r\n\r\n// Known Discord error codes and their explanations\r\nconst ERROR_CODE_EXPLANATIONS: Record<string, { explanation: string; suggestion: string }> = {\r\n 'BASE_TYPE_REQUIRED': {\r\n explanation: 'This field is required but is empty or missing!',\r\n suggestion: 'Add the required content or attributes to the element'\r\n },\r\n 'BASE_TYPE_BAD_LENGTH': {\r\n explanation: 'Wrong number of child elements (section requires 1-3)',\r\n suggestion: 'A <section> must contain 1-3 <components> elements inside it'\r\n },\r\n 'BASE_TYPE_MAX_LENGTH': {\r\n explanation: 'Value exceeds maximum length',\r\n suggestion: 'Reduce the text content or number of items'\r\n },\r\n 'BASE_TYPE_MIN_LENGTH': {\r\n explanation: 'Value is below minimum length',\r\n suggestion: 'Add more content or items'\r\n },\r\n 'BASE_TYPE_CHOICES': {\r\n explanation: 'Value is not one of the allowed choices',\r\n suggestion: 'Use a valid option for this field'\r\n },\r\n 'STRING_TYPE_REGEX': {\r\n explanation: 'String value does not match required format',\r\n suggestion: 'Check the format requirements for this field'\r\n },\r\n 'NUMBER_TYPE_MIN': {\r\n explanation: 'Number is below minimum value',\r\n suggestion: 'Increase the number to meet minimum requirement'\r\n },\r\n 'NUMBER_TYPE_MAX': {\r\n explanation: 'Number exceeds maximum value',\r\n suggestion: 'Keep the number within limits'\r\n },\r\n 'COMPONENT_LAYOUT_WIDTH_EXCEEDED': {\r\n explanation: 'Row exceeds maximum width (5 units for buttons)',\r\n suggestion: 'Move some components to a new action-row'\r\n },\r\n 'COMPONENT_CUSTOM_ID_DUPLICATED': {\r\n explanation: 'Multiple components have the same custom_id',\r\n suggestion: 'Each interactive element must have a unique name/id'\r\n },\r\n};\r\n\r\n// Component type names for better error messages\r\nconst COMPONENT_TYPE_NAMES: Record<number, string> = {\r\n 1: 'ActionRow',\r\n 2: 'Button',\r\n 3: 'StringSelect',\r\n 4: 'TextInput',\r\n 5: 'UserSelect',\r\n 6: 'RoleSelect',\r\n 7: 'MentionableSelect',\r\n 8: 'ChannelSelect',\r\n 9: 'Section',\r\n 10: 'TextDisplay',\r\n 12: 'MediaGallery',\r\n 13: 'File',\r\n 14: 'Separator',\r\n 17: 'Container',\r\n};\r\n\r\n// Discord component HTML tag names (used to filter elements)\r\nconst DISCORD_COMPONENT_TAGS = new Set([\r\n 'container', 'action-row', 'button', 'string-select', 'string-select-menu',\r\n 'user-select', 'user-select-menu', 'role-select', 'role-select-menu',\r\n 'mentionable-select', 'mentionable-select-menu', 'channel-select', 'channel-select-menu',\r\n 'text-input', 'text-display', 'section', 'separator', 'media-gallery', 'file',\r\n 'thumbnail', 'accessory', 'field'\r\n]);\r\n\r\n/**\r\n * Parse a Discord API error path like \"components[0].components[4].accessory\"\r\n * Returns array of segments for navigation\r\n */\r\nfunction parseErrorPath(path: string): PathSegment[] {\r\n const segments: PathSegment[] = [];\r\n // Match both property.name and [index] patterns\r\n const regex = /\\.?(\\w+)|\\[(\\d+)\\]/g;\r\n let match;\r\n\r\n while ((match = regex.exec(path)) !== null) {\r\n if (match[1]) {\r\n segments.push({ type: 'property', key: match[1] });\r\n } else if (match[2]) {\r\n segments.push({ type: 'array', key: parseInt(match[2], 10) });\r\n }\r\n }\r\n\r\n return segments;\r\n}\r\n\r\n/**\r\n * Check if an element tag is a Discord component\r\n */\r\nfunction isDiscordComponentTag(tag: string): boolean {\r\n return DISCORD_COMPONENT_TAGS.has(tag.toLowerCase());\r\n}\r\n\r\n/**\r\n * Get Discord component children of an element (filters out non-component elements)\r\n */\r\nfunction getComponentChildren(element: Element): Element[] {\r\n return Array.from(element.children).filter(child =>\r\n isDiscordComponentTag(child.tagName.toLowerCase())\r\n );\r\n}\r\n\r\n/**\r\n * Navigate HTML DOM following Discord's component path\r\n * Returns the exact element that has the error\r\n */\r\nfunction findHTMLElementByPath(\r\n sourceHTML: string,\r\n segments: PathSegment[],\r\n components?: any[]\r\n): { element: Element; annotation?: string } | null {\r\n try {\r\n const dom = new JSDOM(`<root>${sourceHTML}</root>`);\r\n const document = dom.window.document;\r\n const root = document.querySelector('root');\r\n if (!root) return null;\r\n\r\n // Find the main components container (skip modal type)\r\n let currentElement: Element | null = root.querySelector('components:not([type=\"modal\"])') || root;\r\n let currentComponentsArray = components;\r\n\r\n for (let i = 0; i < segments.length; i++) {\r\n const segment = segments[i];\r\n if (!currentElement) return null;\r\n\r\n if (segment.type === 'property') {\r\n const key = segment.key as string;\r\n\r\n if (key === 'components') {\r\n // \"components\" property means we look at children - continue to array index\r\n continue;\r\n } else if (key === 'accessory') {\r\n // Find <accessory> child\r\n const accessory = currentElement.querySelector(':scope > accessory');\r\n if (accessory) {\r\n currentElement = accessory;\r\n } else {\r\n // Accessory is MISSING - this is the error!\r\n return {\r\n element: currentElement,\r\n annotation: `<accessory> element is missing! This element should contain an <accessory>.`\r\n };\r\n }\r\n } else if (key === 'content' || key === 'label' || key === 'title' || key === 'placeholder' || key === 'url' || key === 'custom_id') {\r\n // These are text/attribute properties - return current element\r\n return {\r\n element: currentElement,\r\n annotation: `Error in the \"${key}\" field.`\r\n };\r\n }\r\n } else if (segment.type === 'array') {\r\n const index = segment.key as number;\r\n\r\n // Get component children (filter out non-component elements)\r\n const componentChildren = getComponentChildren(currentElement);\r\n\r\n if (index < componentChildren.length) {\r\n currentElement = componentChildren[index];\r\n // Update the JSON components array reference for the next iteration\r\n if (currentComponentsArray && Array.isArray(currentComponentsArray) && currentComponentsArray[index]) {\r\n currentComponentsArray = currentComponentsArray[index].components;\r\n }\r\n } else {\r\n // Index out of bounds - not enough children\r\n return {\r\n element: currentElement,\r\n annotation: `Expected child element #${index + 1} but only found ${componentChildren.length}!`\r\n };\r\n }\r\n }\r\n }\r\n\r\n return currentElement ? { element: currentElement } : null;\r\n } catch (e) {\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * Format outerHTML for display - indent and optionally truncate\r\n */\r\nfunction formatOuterHTML(outerHTML: string, maxLength: number = 600): string {\r\n // Pretty format by adding newlines\r\n let formatted = outerHTML\r\n .replace(/></g, '>\\n<')\r\n .replace(/>\\s+</g, '>\\n<');\r\n\r\n // Truncate if too long\r\n if (formatted.length > maxLength) {\r\n const half = Math.floor(maxLength / 2) - 30;\r\n formatted = formatted.substring(0, half) + '\\n ... (truncated) ...\\n' + formatted.substring(formatted.length - half);\r\n }\r\n\r\n // Basic indentation\r\n const lines = formatted.split('\\n');\r\n let indent = 0;\r\n const indented = lines.map(line => {\r\n const trimmed = line.trim();\r\n if (trimmed.startsWith('</')) indent = Math.max(0, indent - 1);\r\n const result = ' '.repeat(indent) + trimmed;\r\n if (trimmed.startsWith('<') && !trimmed.startsWith('</') && !trimmed.endsWith('/>') && !trimmed.includes('</')) {\r\n indent++;\r\n }\r\n return result;\r\n });\r\n\r\n return indented.join('\\n');\r\n}\r\n\r\n/**\r\n * Navigate through JSON components tree for breadcrumb generation\r\n */\r\nfunction navigateComponentTree(components: any[], segments: PathSegment[]): { breadcrumb: string[] } | null {\r\n let current: any = { components };\r\n const breadcrumb: string[] = [];\r\n\r\n for (const segment of segments) {\r\n if (segment.type === 'property') {\r\n const key = segment.key as string;\r\n if (current && typeof current === 'object' && key in current) {\r\n current = current[key];\r\n if (key !== 'components' && key !== 'data') {\r\n breadcrumb.push(key);\r\n }\r\n } else {\r\n return null;\r\n }\r\n } else if (segment.type === 'array') {\r\n const index = segment.key as number;\r\n if (Array.isArray(current) && index < current.length) {\r\n current = current[index];\r\n const typeName = current?.type ? (COMPONENT_TYPE_NAMES[current.type] || `Type${current.type}`) : 'Element';\r\n const name = current?.custom_id?.split('$')[1]?.split('/')[0] ||\r\n current?.label ||\r\n current?.placeholder?.substring(0, 20) ||\r\n '';\r\n breadcrumb.push(`${typeName}[${index}]${name ? ` \"${name}\"` : ''}`);\r\n } else {\r\n return null;\r\n }\r\n }\r\n }\r\n\r\n return { breadcrumb };\r\n}\r\n\r\n/**\r\n * Parse Discord API errors into user-friendly format\r\n */\r\nexport function parseDiscordComponentError(\r\n error: any,\r\n components?: any[],\r\n sourceHTML?: string\r\n): ParsedDiscordError {\r\n const componentErrors: ComponentErrorInfo[] = [];\r\n\r\n // Try to extract error details from various Discord.js error formats\r\n let rawErrors: Record<string, { code: string; message: string }[]> = {};\r\n\r\n if (error.rawError?.errors) {\r\n rawErrors = flattenDiscordErrors(error.rawError.errors);\r\n } else if (error.errors) {\r\n rawErrors = flattenDiscordErrors(error.errors);\r\n } else if (typeof error.message === 'string') {\r\n const lines = error.message.split('\\n');\r\n for (const line of lines) {\r\n const match = line.match(/^([\\w\\[\\]\\.]+)\\[(\\w+)\\]:\\s*(.+)$/);\r\n if (match) {\r\n const [, path, code, message] = match;\r\n if (!rawErrors[path]) rawErrors[path] = [];\r\n rawErrors[path].push({ code, message });\r\n }\r\n }\r\n }\r\n\r\n // Process each error\r\n for (const [path, errors] of Object.entries(rawErrors)) {\r\n for (const { code, message } of errors) {\r\n const pathSegments = parseErrorPath(path);\r\n const errorInfo = ERROR_CODE_EXPLANATIONS[code] || {\r\n explanation: message,\r\n suggestion: 'Check the Discord API documentation for this error'\r\n };\r\n\r\n const errorEntry: ComponentErrorInfo = {\r\n path,\r\n code,\r\n message,\r\n pathSegments,\r\n explanation: errorInfo.explanation,\r\n suggestion: errorInfo.suggestion\r\n };\r\n\r\n // Find the actual HTML element using JSDOM\r\n if (sourceHTML) {\r\n const htmlResult = findHTMLElementByPath(sourceHTML, pathSegments, components);\r\n if (htmlResult) {\r\n errorEntry.htmlElement = formatOuterHTML(htmlResult.element.outerHTML);\r\n errorEntry.htmlAnnotation = htmlResult.annotation;\r\n }\r\n }\r\n\r\n componentErrors.push(errorEntry);\r\n }\r\n }\r\n\r\n // Generate formatted message\r\n const formattedMessage = generateFormattedMessage(componentErrors, components, error);\r\n\r\n return {\r\n original: error,\r\n componentErrors,\r\n formattedMessage\r\n };\r\n}\r\n\r\n/**\r\n * Generate a beautifully formatted error message with actual HTML snippets\r\n */\r\nfunction generateFormattedMessage(errors: ComponentErrorInfo[], components?: any[], originalError?: any): string {\r\n let msg = '\\n';\r\n msg += '╔══════════════════════════════════════════════════════════════════════════════╗\\n';\r\n msg += '║ 🚨 Discord Components V2 - Validation Error ║\\n';\r\n msg += '╠══════════════════════════════════════════════════════════════════════════════╣\\n';\r\n\r\n if (errors.length === 0) {\r\n msg += `║ ${originalError?.message || 'Unknown error'}\\n`;\r\n } else {\r\n for (let i = 0; i < errors.length; i++) {\r\n const err = errors[i];\r\n\r\n // Generate breadcrumb from components tree\r\n let breadcrumb = 'Unknown';\r\n if (components) {\r\n const nav = navigateComponentTree(components, err.pathSegments);\r\n if (nav && nav.breadcrumb.length > 0) {\r\n breadcrumb = nav.breadcrumb.join(' → ');\r\n }\r\n }\r\n\r\n msg += '║\\n';\r\n msg += `║ ❌ Error ${i + 1}/${errors.length}\\n`;\r\n msg += '║ ┌────────────────────────────────────────────────────────────────────────────\\n';\r\n msg += `║ │ 📍 Path: ${err.path}\\n`;\r\n msg += `║ │ 🏷️ Code: ${err.code}\\n`;\r\n msg += `║ │ 📂 Location: ${breadcrumb}\\n`;\r\n msg += '║ │\\n';\r\n msg += `║ │ ⚠️ Problem: ${err.explanation}\\n`;\r\n msg += `║ │ 💡 Solution: ${err.suggestion}\\n`;\r\n\r\n // Show the actual HTML element that caused the error - THIS IS THE KEY FEATURE!\r\n if (err.htmlElement) {\r\n msg += '║ │\\n';\r\n if (err.htmlAnnotation) {\r\n msg += `║ │ 🔍 ${err.htmlAnnotation}\\n`;\r\n }\r\n msg += '║ │ 📄 Problematic HTML Element:\\n';\r\n msg += '║ │ ┌──────────────────────────────────────────────────────────────────────\\n';\r\n\r\n // Show the actual outerHTML with indentation\r\n const htmlLines = err.htmlElement.split('\\n');\r\n for (const line of htmlLines) {\r\n msg += `║ │ │ ${line}\\n`;\r\n }\r\n\r\n msg += '║ │ └──────────────────────────────────────────────────────────────────────\\n';\r\n }\r\n\r\n msg += '║ └────────────────────────────────────────────────────────────────────────────\\n';\r\n }\r\n }\r\n\r\n msg += '║\\n';\r\n msg += '╚══════════════════════════════════════════════════════════════════════════════╝\\n';\r\n\r\n return msg;\r\n}\r\n\r\n/**\r\n * Flatten nested Discord error objects into a path-based map\r\n */\r\nfunction flattenDiscordErrors(\r\n obj: any,\r\n prefix = ''\r\n): Record<string, { code: string; message: string }[]> {\r\n const result: Record<string, { code: string; message: string }[]> = {};\r\n\r\n if (!obj || typeof obj !== 'object') return result;\r\n\r\n // Check if this is an error entry\r\n if (obj._errors && Array.isArray(obj._errors)) {\r\n const cleanPrefix = prefix.replace(/^data\\./, '');\r\n result[cleanPrefix] = obj._errors.map((e: any) => ({\r\n code: e.code || 'UNKNOWN',\r\n message: e.message || 'Unknown error'\r\n }));\r\n }\r\n\r\n // Recurse into nested objects\r\n for (const [key, value] of Object.entries(obj)) {\r\n if (key === '_errors') continue;\r\n\r\n let newPrefix: string;\r\n if (/^\\d+$/.test(key)) {\r\n // It's an array index - use bracket notation\r\n newPrefix = prefix ? `${prefix}[${key}]` : `[${key}]`;\r\n } else {\r\n newPrefix = prefix ? `${prefix}.${key}` : key;\r\n }\r\n\r\n const nested = flattenDiscordErrors(value, newPrefix);\r\n Object.assign(result, nested);\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Create a user-friendly error with enhanced message\r\n */\r\nexport function createEnhancedError(\r\n originalError: any,\r\n components?: any[],\r\n sourceHTML?: string,\r\n componentName?: string\r\n): Error {\r\n const parsed = parseDiscordComponentError(originalError, components, sourceHTML);\r\n\r\n let enhancedMessage = `[DBI-ComponentsV2] ${componentName ? `Component \"${componentName}\" ` : ''}Discord API rejected the components:\\n\\n`;\r\n enhancedMessage += parsed.formattedMessage;\r\n\r\n const enhancedError = new Error(enhancedMessage);\r\n (enhancedError as any).originalError = originalError;\r\n (enhancedError as any).componentErrors = parsed.componentErrors;\r\n (enhancedError as any).parsedError = parsed;\r\n (enhancedError as any).type = 'discord-component-validation';\r\n\r\n // Preserve stack trace\r\n if (originalError.stack) {\r\n enhancedError.stack = enhancedError.message + '\\n\\nOriginal stack:\\n' + originalError.stack;\r\n }\r\n\r\n return enhancedError;\r\n}\r\n\r\n/**\r\n * Check if an error is a Discord component validation error\r\n */\r\nexport function isComponentValidationError(error: any): boolean {\r\n if (!error) return false;\r\n\r\n // Check for common Discord.js error patterns\r\n if (error.code === 50035) return true; // Invalid Form Body\r\n if (error.rawError?.code === 50035) return true;\r\n\r\n // Check error message patterns\r\n const message = error.message || '';\r\n if (message.includes('components[') && message.includes('[BASE_TYPE')) return true;\r\n if (message.includes('Invalid Form Body')) return true;\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Wrap an async function to enhance Discord component errors\r\n */\r\nexport function withEnhancedErrors<T extends (...args: any[]) => Promise<any>>(\r\n fn: T,\r\n options: { components?: any[]; sourceHTML?: string; componentName?: string } = {}\r\n): T {\r\n return (async (...args: any[]) => {\r\n try {\r\n return await fn(...args);\r\n } catch (error: any) {\r\n if (isComponentValidationError(error)) {\r\n throw createEnhancedError(error, options.components, options.sourceHTML, options.componentName);\r\n }\r\n throw error;\r\n }\r\n }) as T;\r\n}\r\n"]}
@@ -1,6 +1,7 @@
1
1
  import { NamespaceEnums } from "../../../../generated/namespaceData";
2
2
  import { DBI } from "../../../DBI";
3
3
  import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "../../Interaction";
4
+ export { createEnhancedError, isComponentValidationError, parseDiscordComponentError, ComponentErrorInfo, ParsedDiscordError } from "./errorParser";
4
5
  export type TDBIHTMLComponentsV2Omitted<TNamespace extends NamespaceEnums> = Omit<DBIHTMLComponentsV2<TNamespace>, "type" | "dbi" | "toJSON" | "description" | "send" | "destroy" | "destroyAll" | "__lastRenderModals__" | "_pendingModals" | "_initPromise"> & {
5
6
  /**
6
7
  * Use 'svelte' for Svelte 5 components, 'eta' for Eta templates (default)
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/Components/HTMLComponentsV2/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAgB,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAsJ7G,MAAM,MAAM,2BAA2B,CAAC,UAAU,SAA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