nextjs-chatbot-ui 1.1.1 → 1.1.2

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/README.md CHANGED
@@ -405,16 +405,20 @@ Your backend should provide:
405
405
 
406
406
  1. **Test Connection Endpoint** (`POST /api/database/test`)
407
407
  - Accepts `DatabaseConnection` object
408
- - Returns success/failure status
408
+ - Returns `{ success: boolean, message?: string }`
409
+ - Example response: `{ success: true }` or `{ success: false, message: "Connection failed" }`
409
410
 
410
411
  2. **Fetch Columns Endpoint** (`POST /api/database/columns`)
411
412
  - Accepts `DatabaseConnection` object
412
- - Returns array of column names
413
+ - Returns `{ columns: string[] }` or `{ columnNames: string[] }`
414
+ - Example response: `{ columns: ["id", "title", "content", "description"] }`
413
415
 
414
416
  3. **Save Configuration Endpoint** (your implementation)
415
417
  - Accepts `DatabaseConfig` object
416
418
  - Saves configuration to your storage
417
419
 
420
+ **Note**: If you don't provide `onTestConnection` and `onFetchColumns` handlers, the component will automatically try to call `/api/database/test` and `/api/database/columns` endpoints. See `example-api-routes.md` for complete implementation examples.
421
+
418
422
  ## Troubleshooting
419
423
 
420
424
  ### Component not rendering or styles not working
@@ -459,6 +463,43 @@ If you see TypeScript errors:
459
463
  - Check CORS settings if making cross-origin requests
460
464
  - Verify the API response format matches the expected structure (see Backend API Requirements)
461
465
 
466
+ ### Database Connection Not Working
467
+
468
+ If the database connection is not establishing:
469
+
470
+ 1. **Check if API endpoints exist**: The component tries to call `/api/database/test` and `/api/database/columns` by default. Make sure these endpoints are implemented in your Next.js app.
471
+
472
+ 2. **Implement the endpoints**: See `example-api-routes.md` for complete implementation examples for both App Router and Pages Router.
473
+
474
+ 3. **Provide custom handlers**: You can also provide `onTestConnection` and `onFetchColumns` props to handle the connection logic yourself:
475
+
476
+ ```javascript
477
+ <AdminSetup
478
+ onTestConnection={async (connection) => {
479
+ const response = await fetch('/your-api/test', {
480
+ method: 'POST',
481
+ headers: { 'Content-Type': 'application/json' },
482
+ body: JSON.stringify(connection),
483
+ });
484
+ const data = await response.json();
485
+ return data.success === true;
486
+ }}
487
+ onFetchColumns={async (connection) => {
488
+ const response = await fetch('/your-api/columns', {
489
+ method: 'POST',
490
+ headers: { 'Content-Type': 'application/json' },
491
+ body: JSON.stringify(connection),
492
+ });
493
+ const data = await response.json();
494
+ return data.columns || [];
495
+ }}
496
+ />
497
+ ```
498
+
499
+ 4. **Check browser console**: Open browser DevTools console to see detailed error messages about connection failures.
500
+
501
+ 5. **Verify database credentials**: Ensure your database host, port, username, password, and database name are correct.
502
+
462
503
  ## License
463
504
 
464
505
  MIT