nextjs-chatbot-ui 1.1.1 → 1.2.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nextjs-chatbot-ui",
3
3
 
4
- "version": "1.1.1",
4
+ "version": "1.2.0",
5
5
  "description": "A configurable chatbot UI component for Next.js with Tailwind CSS",
6
6
  "main": "./index.tsx",
7
7
  "module": "./index.tsx",
@@ -29,6 +29,7 @@
29
29
  "files": [
30
30
  "components",
31
31
  "types",
32
+ "utils",
32
33
  "index.tsx",
33
34
  "README.md"
34
35
  ],
package/types/admin.ts CHANGED
@@ -27,3 +27,9 @@ export interface AdminSetupProps {
27
27
  onTestConnection?: (connection: DatabaseConnection) => Promise<boolean>;
28
28
  onFetchColumns?: (connection: DatabaseConnection) => Promise<string[]>;
29
29
  }
30
+
31
+ // Backend request format
32
+ export interface BackendConnectionRequest {
33
+ databaseType: 'mongodb' | 'postgresql';
34
+ connection: Omit<DatabaseConnection, 'type'>;
35
+ }
@@ -0,0 +1,40 @@
1
+ import { DatabaseConnection, DatabaseType } from '../types/admin';
2
+
3
+ export interface BackendConnectionRequest {
4
+ databaseType: 'mongodb' | 'postgresql';
5
+ connection: Omit<DatabaseConnection, 'type'>;
6
+ }
7
+
8
+ /**
9
+ * Normalizes connection data with defaults
10
+ */
11
+ export function normalizeConnection(
12
+ connection: DatabaseConnection,
13
+ dbType: DatabaseType
14
+ ): DatabaseConnection {
15
+ return {
16
+ ...connection,
17
+ port: connection.port || (dbType === 'mongodb' ? 27017 : 5432),
18
+ host: connection.host || 'localhost',
19
+ database: connection.database || '',
20
+ };
21
+ }
22
+
23
+ /**
24
+ * Transforms DatabaseConnection to backend format
25
+ */
26
+ export function transformConnectionForBackend(
27
+ connection: DatabaseConnection,
28
+ dbType: DatabaseType
29
+ ): BackendConnectionRequest {
30
+ const normalized = normalizeConnection(connection, dbType);
31
+
32
+ const backendConnection = { ...normalized };
33
+ // Remove type from connection object
34
+ delete (backendConnection as any).type;
35
+
36
+ return {
37
+ databaseType: dbType === 'postgres' ? 'postgresql' : 'mongodb',
38
+ connection: backendConnection,
39
+ };
40
+ }