hazo_chat 2.0.2 → 2.0.3
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/api/index.d.ts +24 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +24 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/messages.d.ts +34 -0
- package/dist/api/messages.d.ts.map +1 -0
- package/dist/api/messages.js +210 -0
- package/dist/api/messages.js.map +1 -0
- package/dist/api/types.d.ts +69 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +8 -0
- package/dist/api/types.js.map +1 -0
- package/dist/components/hazo_chat/hazo_chat.d.ts +28 -0
- package/dist/components/hazo_chat/hazo_chat.d.ts.map +1 -0
- package/dist/components/hazo_chat/hazo_chat.js +167 -0
- package/dist/components/hazo_chat/hazo_chat.js.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_attachment_preview.d.ts +17 -0
- package/dist/components/hazo_chat/hazo_chat_attachment_preview.d.ts.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_attachment_preview.js +60 -0
- package/dist/components/hazo_chat/hazo_chat_attachment_preview.js.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_context.d.ts +42 -0
- package/dist/components/hazo_chat/hazo_chat_context.d.ts.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_context.js +261 -0
- package/dist/components/hazo_chat/hazo_chat_context.js.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_document_viewer.d.ts +15 -0
- package/dist/components/hazo_chat/hazo_chat_document_viewer.d.ts.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_document_viewer.js +111 -0
- package/dist/components/hazo_chat/hazo_chat_document_viewer.js.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_header.d.ts +16 -0
- package/dist/components/hazo_chat/hazo_chat_header.d.ts.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_header.js +24 -0
- package/dist/components/hazo_chat/hazo_chat_header.js.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_input.d.ts +18 -0
- package/dist/components/hazo_chat/hazo_chat_input.d.ts.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_input.js +134 -0
- package/dist/components/hazo_chat/hazo_chat_input.js.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_messages.d.ts +17 -0
- package/dist/components/hazo_chat/hazo_chat_messages.d.ts.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_messages.js +109 -0
- package/dist/components/hazo_chat/hazo_chat_messages.js.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_reference_list.d.ts +16 -0
- package/dist/components/hazo_chat/hazo_chat_reference_list.d.ts.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_reference_list.js +59 -0
- package/dist/components/hazo_chat/hazo_chat_reference_list.js.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_sidebar.d.ts +18 -0
- package/dist/components/hazo_chat/hazo_chat_sidebar.d.ts.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_sidebar.js +72 -0
- package/dist/components/hazo_chat/hazo_chat_sidebar.js.map +1 -0
- package/dist/components/hazo_chat/index.d.ts +16 -0
- package/dist/components/hazo_chat/index.d.ts.map +1 -0
- package/dist/components/hazo_chat/index.js +19 -0
- package/dist/components/hazo_chat/index.js.map +1 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +11 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +13 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +28 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/badge.d.ts +16 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +36 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/button.d.ts +18 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +47 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/chat_bubble.d.ts +19 -0
- package/dist/components/ui/chat_bubble.d.ts.map +1 -0
- package/dist/components/ui/chat_bubble.js +101 -0
- package/dist/components/ui/chat_bubble.js.map +1 -0
- package/dist/components/ui/index.d.ts +18 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +20 -0
- package/dist/components/ui/index.js.map +1 -0
- package/dist/components/ui/input.d.ts +11 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +18 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/loading_skeleton.d.ts +19 -0
- package/dist/components/ui/loading_skeleton.d.ts.map +1 -0
- package/dist/components/ui/loading_skeleton.js +30 -0
- package/dist/components/ui/loading_skeleton.js.map +1 -0
- package/dist/components/ui/scroll-area.d.ts +12 -0
- package/dist/components/ui/scroll-area.d.ts.map +1 -0
- package/dist/components/ui/scroll-area.js +25 -0
- package/dist/components/ui/scroll-area.js.map +1 -0
- package/dist/components/ui/separator.d.ts +11 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +18 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/skeleton.d.ts +9 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +16 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +11 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/textarea.js +18 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +14 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +30 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use_chat_messages.d.ts +30 -0
- package/dist/hooks/use_chat_messages.d.ts.map +1 -0
- package/dist/hooks/use_chat_messages.js +432 -0
- package/dist/hooks/use_chat_messages.js.map +1 -0
- package/dist/hooks/use_chat_references.d.ts +17 -0
- package/dist/hooks/use_chat_references.d.ts.map +1 -0
- package/dist/hooks/use_chat_references.js +133 -0
- package/dist/hooks/use_chat_references.js.map +1 -0
- package/dist/hooks/use_file_upload.d.ts +23 -0
- package/dist/hooks/use_file_upload.d.ts.map +1 -0
- package/dist/hooks/use_file_upload.js +212 -0
- package/dist/hooks/use_file_upload.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/config.d.ts +41 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +93 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/constants.d.ts +39 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +70 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/index.d.ts +9 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +9 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/utils.d.ts +17 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +20 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/types/index.d.ts +378 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hazo_chat API Module
|
|
3
|
+
*
|
|
4
|
+
* Provides exportable API route handlers for Next.js applications.
|
|
5
|
+
* These handlers can be imported and re-exported in your API routes.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // app/api/hazo_chat/messages/route.ts
|
|
10
|
+
* import { createMessagesHandler } from 'hazo_chat/api';
|
|
11
|
+
* import { getHazoConnectSingleton } from 'hazo_connect/nextjs/setup';
|
|
12
|
+
*
|
|
13
|
+
* export const dynamic = 'force-dynamic';
|
|
14
|
+
*
|
|
15
|
+
* const { GET, POST } = createMessagesHandler({
|
|
16
|
+
* getHazoConnect: () => getHazoConnectSingleton()
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* export { GET, POST };
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export { createMessagesHandler } from './messages.js';
|
|
23
|
+
export type { MessagesHandlerOptions, ChatMessageInput, ChatMessageRecord } from './types.js';
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGtD,YAAY,EACV,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hazo_chat API Module
|
|
3
|
+
*
|
|
4
|
+
* Provides exportable API route handlers for Next.js applications.
|
|
5
|
+
* These handlers can be imported and re-exported in your API routes.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // app/api/hazo_chat/messages/route.ts
|
|
10
|
+
* import { createMessagesHandler } from 'hazo_chat/api';
|
|
11
|
+
* import { getHazoConnectSingleton } from 'hazo_connect/nextjs/setup';
|
|
12
|
+
*
|
|
13
|
+
* export const dynamic = 'force-dynamic';
|
|
14
|
+
*
|
|
15
|
+
* const { GET, POST } = createMessagesHandler({
|
|
16
|
+
* getHazoConnect: () => getHazoConnectSingleton()
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* export { GET, POST };
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
// Export handler factories
|
|
23
|
+
export { createMessagesHandler } from './messages.js';
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,2BAA2B;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messages API Handler Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates GET and POST handlers for the /api/hazo_chat/messages endpoint.
|
|
5
|
+
* These handlers should be used in a Next.js API route.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // app/api/hazo_chat/messages/route.ts
|
|
10
|
+
* import { createMessagesHandler } from 'hazo_chat/api';
|
|
11
|
+
* import { getHazoConnectSingleton } from 'hazo_connect/nextjs/setup';
|
|
12
|
+
*
|
|
13
|
+
* export const dynamic = 'force-dynamic';
|
|
14
|
+
*
|
|
15
|
+
* const { GET, POST } = createMessagesHandler({
|
|
16
|
+
* getHazoConnect: () => getHazoConnectSingleton()
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* export { GET, POST };
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
23
|
+
import type { MessagesHandlerOptions } from './types.js';
|
|
24
|
+
/**
|
|
25
|
+
* Creates GET and POST handlers for chat messages
|
|
26
|
+
*
|
|
27
|
+
* @param options - Configuration options
|
|
28
|
+
* @returns Object with GET and POST handlers
|
|
29
|
+
*/
|
|
30
|
+
export declare function createMessagesHandler(options: MessagesHandlerOptions): {
|
|
31
|
+
GET: (request: NextRequest) => Promise<NextResponse>;
|
|
32
|
+
POST: (request: NextRequest) => Promise<NextResponse>;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/api/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIxD,OAAO,KAAK,EAAE,sBAAsB,EAAuC,MAAM,YAAY,CAAC;AAmB9F;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB;mBAWvC,WAAW,KAAG,OAAO,CAAC,YAAY,CAAC;oBA+FlC,WAAW,KAAG,OAAO,CAAC,YAAY,CAAC;EAsGjE"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messages API Handler Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates GET and POST handlers for the /api/hazo_chat/messages endpoint.
|
|
5
|
+
* These handlers should be used in a Next.js API route.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // app/api/hazo_chat/messages/route.ts
|
|
10
|
+
* import { createMessagesHandler } from 'hazo_chat/api';
|
|
11
|
+
* import { getHazoConnectSingleton } from 'hazo_connect/nextjs/setup';
|
|
12
|
+
*
|
|
13
|
+
* export const dynamic = 'force-dynamic';
|
|
14
|
+
*
|
|
15
|
+
* const { GET, POST } = createMessagesHandler({
|
|
16
|
+
* getHazoConnect: () => getHazoConnectSingleton()
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* export { GET, POST };
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { NextResponse } from 'next/server';
|
|
23
|
+
import { cookies } from 'next/headers';
|
|
24
|
+
import { createCrudService } from 'hazo_connect/server';
|
|
25
|
+
// UUID generation for message IDs
|
|
26
|
+
function generateUUID() {
|
|
27
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
28
|
+
const r = Math.random() * 16 | 0;
|
|
29
|
+
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
30
|
+
return v.toString(16);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Default function to get user ID from request cookies
|
|
35
|
+
*/
|
|
36
|
+
async function defaultGetUserIdFromRequest() {
|
|
37
|
+
const cookieStore = await cookies();
|
|
38
|
+
return cookieStore.get('hazo_auth_user_id')?.value || null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates GET and POST handlers for chat messages
|
|
42
|
+
*
|
|
43
|
+
* @param options - Configuration options
|
|
44
|
+
* @returns Object with GET and POST handlers
|
|
45
|
+
*/
|
|
46
|
+
export function createMessagesHandler(options) {
|
|
47
|
+
const { getHazoConnect, getUserIdFromRequest } = options;
|
|
48
|
+
/**
|
|
49
|
+
* GET handler - Fetch chat messages
|
|
50
|
+
*
|
|
51
|
+
* Query params:
|
|
52
|
+
* - receiver_user_id (required): The other user in the conversation
|
|
53
|
+
* - reference_id (optional): Filter by reference ID
|
|
54
|
+
* - reference_type (optional): Filter by reference type
|
|
55
|
+
*/
|
|
56
|
+
async function GET(request) {
|
|
57
|
+
try {
|
|
58
|
+
// Get current user ID
|
|
59
|
+
const current_user_id = getUserIdFromRequest
|
|
60
|
+
? await getUserIdFromRequest(request)
|
|
61
|
+
: await defaultGetUserIdFromRequest();
|
|
62
|
+
if (!current_user_id) {
|
|
63
|
+
console.error('[hazo_chat/messages GET] No user ID - not authenticated');
|
|
64
|
+
return NextResponse.json({ success: false, error: 'User not authenticated', messages: [] }, { status: 401 });
|
|
65
|
+
}
|
|
66
|
+
// Get query params
|
|
67
|
+
const { searchParams } = new URL(request.url);
|
|
68
|
+
const receiver_user_id = searchParams.get('receiver_user_id');
|
|
69
|
+
const reference_id = searchParams.get('reference_id') || '';
|
|
70
|
+
const reference_type = searchParams.get('reference_type') || '';
|
|
71
|
+
if (!receiver_user_id) {
|
|
72
|
+
console.error('[hazo_chat/messages GET] Missing receiver_user_id');
|
|
73
|
+
return NextResponse.json({ success: false, error: 'receiver_user_id is required', messages: [] }, { status: 400 });
|
|
74
|
+
}
|
|
75
|
+
console.log('[hazo_chat/messages GET] Fetching messages:', {
|
|
76
|
+
current_user_id,
|
|
77
|
+
receiver_user_id,
|
|
78
|
+
reference_id,
|
|
79
|
+
reference_type,
|
|
80
|
+
});
|
|
81
|
+
// Get hazo_connect instance and create CRUD service
|
|
82
|
+
const hazoConnect = getHazoConnect();
|
|
83
|
+
const chatService = createCrudService(hazoConnect, 'hazo_chat');
|
|
84
|
+
let messages = [];
|
|
85
|
+
try {
|
|
86
|
+
// Fetch all messages with reference filters
|
|
87
|
+
const all_messages = await chatService.list((qb) => {
|
|
88
|
+
let builder = qb.select('*');
|
|
89
|
+
if (reference_id) {
|
|
90
|
+
builder = builder.where('reference_id', 'eq', reference_id);
|
|
91
|
+
}
|
|
92
|
+
if (reference_type) {
|
|
93
|
+
builder = builder.where('reference_type', 'eq', reference_type);
|
|
94
|
+
}
|
|
95
|
+
return builder.order('created_at', 'asc');
|
|
96
|
+
});
|
|
97
|
+
// Filter to only messages between current user and receiver
|
|
98
|
+
messages = all_messages.filter((msg) => {
|
|
99
|
+
const is_sent_by_me = msg.sender_user_id === current_user_id && msg.receiver_user_id === receiver_user_id;
|
|
100
|
+
const is_sent_to_me = msg.sender_user_id === receiver_user_id && msg.receiver_user_id === current_user_id;
|
|
101
|
+
return is_sent_by_me || is_sent_to_me;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (dbError) {
|
|
105
|
+
console.error('[hazo_chat/messages GET] Database error:', dbError);
|
|
106
|
+
throw dbError;
|
|
107
|
+
}
|
|
108
|
+
console.log('[hazo_chat/messages GET] Found messages:', messages.length);
|
|
109
|
+
return NextResponse.json({
|
|
110
|
+
success: true,
|
|
111
|
+
messages,
|
|
112
|
+
current_user_id,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
const error_message = error instanceof Error ? error.message : 'Unknown error';
|
|
117
|
+
console.error('[hazo_chat/messages GET] Error:', error_message, error);
|
|
118
|
+
return NextResponse.json({ success: false, error: 'Failed to fetch messages', messages: [] }, { status: 500 });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* POST handler - Create a new chat message
|
|
123
|
+
*
|
|
124
|
+
* Request body:
|
|
125
|
+
* - receiver_user_id (required): The recipient user ID
|
|
126
|
+
* - message_text (required): The message content
|
|
127
|
+
* - reference_id (optional): Reference ID for context grouping
|
|
128
|
+
* - reference_type (optional): Reference type (default: 'chat')
|
|
129
|
+
*/
|
|
130
|
+
async function POST(request) {
|
|
131
|
+
try {
|
|
132
|
+
// Get current user ID (sender)
|
|
133
|
+
const sender_user_id = getUserIdFromRequest
|
|
134
|
+
? await getUserIdFromRequest(request)
|
|
135
|
+
: await defaultGetUserIdFromRequest();
|
|
136
|
+
if (!sender_user_id) {
|
|
137
|
+
console.error('[hazo_chat/messages POST] No user ID - not authenticated');
|
|
138
|
+
return NextResponse.json({ success: false, error: 'User not authenticated' }, { status: 401 });
|
|
139
|
+
}
|
|
140
|
+
// Parse request body
|
|
141
|
+
const body = await request.json();
|
|
142
|
+
const { receiver_user_id, message_text, reference_id, reference_type } = body;
|
|
143
|
+
// Validate required fields
|
|
144
|
+
if (!receiver_user_id) {
|
|
145
|
+
console.error('[hazo_chat/messages POST] Missing receiver_user_id');
|
|
146
|
+
return NextResponse.json({ success: false, error: 'receiver_user_id is required' }, { status: 400 });
|
|
147
|
+
}
|
|
148
|
+
if (!message_text || message_text.trim() === '') {
|
|
149
|
+
console.error('[hazo_chat/messages POST] Missing or empty message_text');
|
|
150
|
+
return NextResponse.json({ success: false, error: 'message_text is required' }, { status: 400 });
|
|
151
|
+
}
|
|
152
|
+
// Get hazo_connect instance and create CRUD service
|
|
153
|
+
const hazoConnect = getHazoConnect();
|
|
154
|
+
const chatService = createCrudService(hazoConnect, 'hazo_chat');
|
|
155
|
+
// Generate message ID and timestamps
|
|
156
|
+
const message_id = generateUUID();
|
|
157
|
+
const now = new Date().toISOString();
|
|
158
|
+
// Create message record
|
|
159
|
+
const message_record = {
|
|
160
|
+
id: message_id,
|
|
161
|
+
reference_id: reference_id || '',
|
|
162
|
+
reference_type: reference_type || 'chat',
|
|
163
|
+
sender_user_id,
|
|
164
|
+
receiver_user_id,
|
|
165
|
+
message_text: message_text.trim(),
|
|
166
|
+
reference_list: null,
|
|
167
|
+
read_at: null,
|
|
168
|
+
deleted_at: null,
|
|
169
|
+
created_at: now,
|
|
170
|
+
changed_at: now,
|
|
171
|
+
};
|
|
172
|
+
console.log('[hazo_chat/messages POST] Saving message:', {
|
|
173
|
+
id: message_id,
|
|
174
|
+
sender_user_id,
|
|
175
|
+
receiver_user_id,
|
|
176
|
+
reference_id: reference_id || '',
|
|
177
|
+
reference_type: reference_type || 'chat',
|
|
178
|
+
message_length: message_text.length,
|
|
179
|
+
});
|
|
180
|
+
// Save to database
|
|
181
|
+
try {
|
|
182
|
+
await chatService.insert(message_record);
|
|
183
|
+
}
|
|
184
|
+
catch (dbError) {
|
|
185
|
+
console.error('[hazo_chat/messages POST] Database error:', dbError);
|
|
186
|
+
throw dbError;
|
|
187
|
+
}
|
|
188
|
+
console.log('[hazo_chat/messages POST] Message saved successfully:', message_id);
|
|
189
|
+
return NextResponse.json({
|
|
190
|
+
success: true,
|
|
191
|
+
message: {
|
|
192
|
+
id: message_id,
|
|
193
|
+
sender_user_id,
|
|
194
|
+
receiver_user_id,
|
|
195
|
+
reference_id: reference_id || '',
|
|
196
|
+
reference_type: reference_type || 'chat',
|
|
197
|
+
message_text: message_text.trim(),
|
|
198
|
+
created_at: now,
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
const error_message = error instanceof Error ? error.message : 'Unknown error';
|
|
204
|
+
console.error('[hazo_chat/messages POST] Error:', error_message, error);
|
|
205
|
+
return NextResponse.json({ success: false, error: 'Failed to save message' }, { status: 500 });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return { GET, POST };
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/api/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAe,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD,kCAAkC;AAClC,SAAS,YAAY;IACnB,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,UAAS,CAAC;QACvE,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;QAC1C,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,2BAA2B;IACxC,MAAM,WAAW,GAAG,MAAM,OAAO,EAAE,CAAC;IACpC,OAAO,WAAW,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,KAAK,IAAI,IAAI,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,MAAM,EAAE,cAAc,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC;IAEzD;;;;;;;OAOG;IACH,KAAK,UAAU,GAAG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aACpC,CAAC,CAAC;YAEH,mBAAmB;YACnB,IAAI,CAAC;gBACH,MAAM,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YAC3C,CAAC;YAAC,OAAO,OAAO,EAAE,CAAC;gBACjB,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,OAAO,CAAC,CAAC;gBACpE,MAAM,OAAO,CAAC;YAChB,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,uDAAuD,EAAE,UAAU,CAAC,CAAC;YAEjF,OAAO,YAAY,CAAC,IAAI,CAAC;gBACvB,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE;oBACP,EAAE,EAAE,UAAU;oBACd,cAAc;oBACd,gBAAgB;oBAChB,YAAY,EAAE,YAAY,IAAI,EAAE;oBAChC,cAAc,EAAE,cAAc,IAAI,MAAM;oBACxC,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE;oBACjC,UAAU,EAAE,GAAG;iBAChB;aACF,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,aAAa,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAC/E,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;YAExE,OAAO,YAAY,CAAC,IAAI,CACtB,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,wBAAwB,EAAE,EACnD,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Handler Types
|
|
3
|
+
*
|
|
4
|
+
* Shared types for the exportable API route handlers.
|
|
5
|
+
* These are used by consumers when setting up their API routes.
|
|
6
|
+
*/
|
|
7
|
+
import type { NextRequest } from 'next/server';
|
|
8
|
+
/**
|
|
9
|
+
* Options for creating message API handlers
|
|
10
|
+
*/
|
|
11
|
+
export interface MessagesHandlerOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Function to get the hazo_connect adapter instance.
|
|
14
|
+
* Called on each request to get a fresh connection.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { getHazoConnectSingleton } from 'hazo_connect/nextjs/setup';
|
|
19
|
+
*
|
|
20
|
+
* const options = {
|
|
21
|
+
* getHazoConnect: () => getHazoConnectSingleton()
|
|
22
|
+
* };
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
getHazoConnect: () => unknown;
|
|
26
|
+
/**
|
|
27
|
+
* Optional function to extract user ID from the request.
|
|
28
|
+
* Defaults to reading from 'hazo_auth_user_id' cookie.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // Custom auth extraction
|
|
33
|
+
* const options = {
|
|
34
|
+
* getUserIdFromRequest: (request) => {
|
|
35
|
+
* const token = request.headers.get('Authorization');
|
|
36
|
+
* return decodeToken(token)?.userId || null;
|
|
37
|
+
* }
|
|
38
|
+
* };
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
getUserIdFromRequest?: (request: NextRequest) => string | null | Promise<string | null>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Chat message input for creating new messages
|
|
45
|
+
*/
|
|
46
|
+
export interface ChatMessageInput {
|
|
47
|
+
receiver_user_id: string;
|
|
48
|
+
message_text: string;
|
|
49
|
+
reference_id?: string;
|
|
50
|
+
reference_type?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Chat message database record
|
|
54
|
+
*/
|
|
55
|
+
export interface ChatMessageRecord {
|
|
56
|
+
id: string;
|
|
57
|
+
reference_id: string;
|
|
58
|
+
reference_type: string;
|
|
59
|
+
sender_user_id: string;
|
|
60
|
+
receiver_user_id: string;
|
|
61
|
+
message_text: string;
|
|
62
|
+
reference_list: string | null;
|
|
63
|
+
read_at: string | null;
|
|
64
|
+
deleted_at: string | null;
|
|
65
|
+
created_at: string;
|
|
66
|
+
changed_at: string;
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;;;;;OAYG;IACH,cAAc,EAAE,MAAM,OAAO,CAAC;IAE9B;;;;;;;;;;;;;;OAcG;IACH,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACzF;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HazoChat Component
|
|
3
|
+
*
|
|
4
|
+
* Main chat UI component with:
|
|
5
|
+
* - Responsive grid layout (sidebar + chat area)
|
|
6
|
+
* - Context provider for shared state
|
|
7
|
+
* - Document viewer and reference list
|
|
8
|
+
* - Message polling and pagination
|
|
9
|
+
*
|
|
10
|
+
* Uses API calls internally - no server-side dependencies required.
|
|
11
|
+
*/
|
|
12
|
+
import type { HazoChatProps } from '../../types/index.js';
|
|
13
|
+
/**
|
|
14
|
+
* HazoChat - Main chat component
|
|
15
|
+
*
|
|
16
|
+
* Uses API calls internally for all data operations.
|
|
17
|
+
* Requires the following API routes to be set up:
|
|
18
|
+
* - GET/POST /api/hazo_chat/messages
|
|
19
|
+
* - GET /api/hazo_auth/me
|
|
20
|
+
* - POST /api/hazo_auth/profiles
|
|
21
|
+
*
|
|
22
|
+
* See SETUP_CHECKLIST.md for detailed setup instructions.
|
|
23
|
+
*/
|
|
24
|
+
export declare function HazoChat(props: HazoChatProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare namespace HazoChat {
|
|
26
|
+
var displayName: string;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=hazo_chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hazo_chat.d.ts","sourceRoot":"","sources":["../../../src/components/hazo_chat/hazo_chat.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EACV,aAAa,EAId,MAAM,sBAAsB,CAAC;AA6T9B;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,2CA6C5C;yBA7Ce,QAAQ"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HazoChat Component
|
|
3
|
+
*
|
|
4
|
+
* Main chat UI component with:
|
|
5
|
+
* - Responsive grid layout (sidebar + chat area)
|
|
6
|
+
* - Context provider for shared state
|
|
7
|
+
* - Document viewer and reference list
|
|
8
|
+
* - Message polling and pagination
|
|
9
|
+
*
|
|
10
|
+
* Uses API calls internally - no server-side dependencies required.
|
|
11
|
+
*/
|
|
12
|
+
'use client';
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { useCallback, useMemo } from 'react';
|
|
15
|
+
import { cn } from '../../lib/utils.js';
|
|
16
|
+
import { DEFAULT_TIMEZONE, DEFAULT_POLLING_INTERVAL, DEFAULT_MESSAGES_PER_PAGE } from '../../lib/constants.js';
|
|
17
|
+
// Sub-components
|
|
18
|
+
import { HazoChatProvider, useHazoChatContext } from './hazo_chat_context.js';
|
|
19
|
+
import { HazoChatHeader } from './hazo_chat_header.js';
|
|
20
|
+
import { HazoChatReferenceList } from './hazo_chat_reference_list.js';
|
|
21
|
+
import { HazoChatDocumentViewer } from './hazo_chat_document_viewer.js';
|
|
22
|
+
import { HazoChatMessages } from './hazo_chat_messages.js';
|
|
23
|
+
import { HazoChatInput } from './hazo_chat_input.js';
|
|
24
|
+
import { TooltipProvider } from '../ui/tooltip.js';
|
|
25
|
+
// Hooks
|
|
26
|
+
import { useChatMessages } from '../../hooks/use_chat_messages.js';
|
|
27
|
+
import { useChatReferences } from '../../hooks/use_chat_references.js';
|
|
28
|
+
import { useFileUpload } from '../../hooks/use_file_upload.js';
|
|
29
|
+
function HazoChatInner({ receiver_user_id, reference_id = '', reference_type = 'chat', api_base_url = '/api/hazo_chat', additional_references = [], timezone = DEFAULT_TIMEZONE, title, subtitle, on_close, className, polling_interval = DEFAULT_POLLING_INTERVAL, messages_per_page = DEFAULT_MESSAGES_PER_PAGE }) {
|
|
30
|
+
// Get context
|
|
31
|
+
const { current_user, selected_reference, highlighted_message_id, pending_attachments, is_sidebar_open, set_selected_reference, set_highlighted_message_id, add_pending_attachment, remove_pending_attachment, clear_pending_attachments, toggle_sidebar, set_sidebar_open, add_reference } = useHazoChatContext();
|
|
32
|
+
// -------------------------------------------------------------------------
|
|
33
|
+
// Messages hook (uses API calls)
|
|
34
|
+
// -------------------------------------------------------------------------
|
|
35
|
+
const { messages, is_loading: is_loading_messages, has_more, load_more, send_message, delete_message, polling_status, refresh: refresh_messages } = useChatMessages({
|
|
36
|
+
receiver_user_id,
|
|
37
|
+
reference_id,
|
|
38
|
+
reference_type,
|
|
39
|
+
api_base_url,
|
|
40
|
+
polling_interval,
|
|
41
|
+
messages_per_page
|
|
42
|
+
});
|
|
43
|
+
// -------------------------------------------------------------------------
|
|
44
|
+
// References hook
|
|
45
|
+
// -------------------------------------------------------------------------
|
|
46
|
+
const { references, select_reference } = useChatReferences({
|
|
47
|
+
messages,
|
|
48
|
+
initial_references: additional_references.map((ref) => ({
|
|
49
|
+
...ref,
|
|
50
|
+
scope: ref.scope || 'field'
|
|
51
|
+
})),
|
|
52
|
+
on_selection_change: (ref) => {
|
|
53
|
+
set_selected_reference(ref);
|
|
54
|
+
// If ref has message_id, highlight it
|
|
55
|
+
if (ref?.message_id) {
|
|
56
|
+
set_highlighted_message_id(ref.message_id);
|
|
57
|
+
// Close sidebar on mobile after selection
|
|
58
|
+
set_sidebar_open(false);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
// -------------------------------------------------------------------------
|
|
63
|
+
// File upload hook
|
|
64
|
+
// -------------------------------------------------------------------------
|
|
65
|
+
const { add_files, remove_file, upload_all, is_uploading } = useFileUpload({
|
|
66
|
+
upload_location: `${api_base_url}/uploads`
|
|
67
|
+
});
|
|
68
|
+
// -------------------------------------------------------------------------
|
|
69
|
+
// Handle send message
|
|
70
|
+
// -------------------------------------------------------------------------
|
|
71
|
+
const handle_send = useCallback(async (text, attachments) => {
|
|
72
|
+
if (!current_user)
|
|
73
|
+
return;
|
|
74
|
+
// Upload pending files first
|
|
75
|
+
const uploaded = await upload_all();
|
|
76
|
+
// Build reference list from attachments
|
|
77
|
+
const attachment_refs = [
|
|
78
|
+
...attachments,
|
|
79
|
+
...uploaded
|
|
80
|
+
].map((file) => ({
|
|
81
|
+
id: file.id,
|
|
82
|
+
type: 'document',
|
|
83
|
+
scope: 'chat',
|
|
84
|
+
name: file.name,
|
|
85
|
+
url: file.url,
|
|
86
|
+
mime_type: file.mime_type,
|
|
87
|
+
file_size: file.file_size
|
|
88
|
+
}));
|
|
89
|
+
const payload = {
|
|
90
|
+
reference_id: reference_id || '',
|
|
91
|
+
reference_type,
|
|
92
|
+
receiver_user_id,
|
|
93
|
+
message_text: text,
|
|
94
|
+
reference_list: attachment_refs.length > 0 ? attachment_refs : undefined
|
|
95
|
+
};
|
|
96
|
+
const success = await send_message(payload);
|
|
97
|
+
if (success) {
|
|
98
|
+
clear_pending_attachments();
|
|
99
|
+
// Add new references to the list
|
|
100
|
+
attachment_refs.forEach((ref) => add_reference(ref));
|
|
101
|
+
}
|
|
102
|
+
}, [
|
|
103
|
+
current_user,
|
|
104
|
+
reference_id,
|
|
105
|
+
reference_type,
|
|
106
|
+
receiver_user_id,
|
|
107
|
+
upload_all,
|
|
108
|
+
send_message,
|
|
109
|
+
clear_pending_attachments,
|
|
110
|
+
add_reference
|
|
111
|
+
]);
|
|
112
|
+
// -------------------------------------------------------------------------
|
|
113
|
+
// Handle add attachment
|
|
114
|
+
// -------------------------------------------------------------------------
|
|
115
|
+
const handle_add_attachment = useCallback((files) => {
|
|
116
|
+
files.forEach((file) => {
|
|
117
|
+
add_pending_attachment(file);
|
|
118
|
+
});
|
|
119
|
+
add_files(files);
|
|
120
|
+
}, [add_pending_attachment, add_files]);
|
|
121
|
+
// -------------------------------------------------------------------------
|
|
122
|
+
// Handle remove attachment
|
|
123
|
+
// -------------------------------------------------------------------------
|
|
124
|
+
const handle_remove_attachment = useCallback((attachment_id) => {
|
|
125
|
+
remove_pending_attachment(attachment_id);
|
|
126
|
+
remove_file(attachment_id);
|
|
127
|
+
}, [remove_pending_attachment, remove_file]);
|
|
128
|
+
// -------------------------------------------------------------------------
|
|
129
|
+
// Handle reference selection
|
|
130
|
+
// -------------------------------------------------------------------------
|
|
131
|
+
const handle_reference_select = useCallback((reference) => {
|
|
132
|
+
select_reference(reference);
|
|
133
|
+
}, [select_reference]);
|
|
134
|
+
// -------------------------------------------------------------------------
|
|
135
|
+
// Render
|
|
136
|
+
// -------------------------------------------------------------------------
|
|
137
|
+
return (_jsxs("div", { className: cn('cls_hazo_chat', 'flex flex-col h-full w-full', 'bg-background rounded-lg border overflow-hidden', className), children: [_jsx(HazoChatHeader, { title: title, subtitle: subtitle, on_close: on_close, on_refresh: refresh_messages, is_refreshing: is_loading_messages, on_toggle_sidebar: toggle_sidebar, is_sidebar_open: is_sidebar_open }), _jsx("div", { className: "cls_references_row border-b bg-muted/30", children: _jsxs("div", { className: "cls_references_container px-3 py-2", children: [_jsx("h3", { className: "text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1.5", children: "References" }), _jsx(HazoChatReferenceList, { references: references, selected_reference_id: selected_reference?.id, on_select: handle_reference_select, className: "flex-wrap" })] }) }), _jsxs("div", { className: "cls_main_content flex flex-1 overflow-hidden relative", children: [_jsx("div", { className: cn('cls_doc_preview_column', 'border-r bg-muted/20', 'w-[280px] md:w-[320px] lg:w-[380px]', 'flex-shrink-0', 'flex flex-col',
|
|
138
|
+
// Mobile: hidden by default, shown when sidebar is open
|
|
139
|
+
is_sidebar_open ? 'flex' : 'hidden md:flex'), children: _jsx(HazoChatDocumentViewer, { reference: selected_reference || undefined }) }), _jsx("div", { className: "cls_chat_column flex flex-col flex-1 min-w-0", children: _jsx(HazoChatMessages, { messages: messages, current_user_id: current_user?.id || '', timezone: timezone, is_loading: is_loading_messages, has_more: has_more, on_load_more: load_more, on_delete_message: delete_message, highlighted_message_id: highlighted_message_id || undefined }) })] }), _jsx("div", { className: "cls_input_row border-t bg-background", children: _jsx(HazoChatInput, { on_send: handle_send, pending_attachments: pending_attachments, on_add_attachment: handle_add_attachment, on_remove_attachment: handle_remove_attachment, is_disabled: !current_user || is_uploading }) }), polling_status !== 'connected' && (_jsx("div", { className: cn('cls_connection_status', 'absolute bottom-20 left-1/2 -translate-x-1/2', 'px-3 py-1.5 rounded-full text-xs font-medium z-10', polling_status === 'reconnecting'
|
|
140
|
+
? 'bg-yellow-100 text-yellow-800'
|
|
141
|
+
: 'bg-red-100 text-red-800'), children: polling_status === 'reconnecting' ? 'Reconnecting...' : 'Connection error' }))] }));
|
|
142
|
+
}
|
|
143
|
+
// ============================================================================
|
|
144
|
+
// Main Component (with Provider)
|
|
145
|
+
// ============================================================================
|
|
146
|
+
/**
|
|
147
|
+
* HazoChat - Main chat component
|
|
148
|
+
*
|
|
149
|
+
* Uses API calls internally for all data operations.
|
|
150
|
+
* Requires the following API routes to be set up:
|
|
151
|
+
* - GET/POST /api/hazo_chat/messages
|
|
152
|
+
* - GET /api/hazo_auth/me
|
|
153
|
+
* - POST /api/hazo_auth/profiles
|
|
154
|
+
*
|
|
155
|
+
* See SETUP_CHECKLIST.md for detailed setup instructions.
|
|
156
|
+
*/
|
|
157
|
+
export function HazoChat(props) {
|
|
158
|
+
const { receiver_user_id, reference_id, reference_type = 'chat', api_base_url = '/api/hazo_chat', additional_references = [], timezone = DEFAULT_TIMEZONE, title, subtitle, on_close, className } = props;
|
|
159
|
+
// Convert ReferenceItem[] to ChatReferenceItem[]
|
|
160
|
+
const initial_refs = useMemo(() => additional_references.map((ref) => ({
|
|
161
|
+
...ref,
|
|
162
|
+
scope: ref.scope || 'field'
|
|
163
|
+
})), [additional_references]);
|
|
164
|
+
return (_jsx(TooltipProvider, { children: _jsx(HazoChatProvider, { api_base_url: api_base_url, initial_references: initial_refs, children: _jsx(HazoChatInner, { receiver_user_id: receiver_user_id, reference_id: reference_id, reference_type: reference_type, api_base_url: api_base_url, additional_references: initial_refs, timezone: timezone, title: title, subtitle: subtitle, on_close: on_close, className: className }) }) }));
|
|
165
|
+
}
|
|
166
|
+
HazoChat.displayName = 'HazoChat';
|
|
167
|
+
//# sourceMappingURL=hazo_chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hazo_chat.js","sourceRoot":"","sources":["../../../src/components/hazo_chat/hazo_chat.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,YAAY,CAAC;;AAEb,OAAc,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAOxC,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,iBAAiB;AACjB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,QAAQ;AACR,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAqB/D,SAAS,aAAa,CAAC,EACrB,gBAAgB,EAChB,YAAY,GAAG,EAAE,EACjB,cAAc,GAAG,MAAM,EACvB,YAAY,GAAG,gBAAgB,EAC/B,q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,CAAC,WAAW,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HazoChatAttachmentPreview Component
|
|
3
|
+
*
|
|
4
|
+
* Shows thumbnails of pending file attachments before sending with:
|
|
5
|
+
* - Image previews for image files
|
|
6
|
+
* - File icon for non-image files
|
|
7
|
+
* - Upload status indicator
|
|
8
|
+
* - Remove button
|
|
9
|
+
*
|
|
10
|
+
* Uses shadcn/ui Button and Badge components.
|
|
11
|
+
*/
|
|
12
|
+
import type { HazoChatAttachmentPreviewProps } from '../../types/index.js';
|
|
13
|
+
export declare function HazoChatAttachmentPreview({ attachments, on_remove, className }: HazoChatAttachmentPreviewProps): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
export declare namespace HazoChatAttachmentPreview {
|
|
15
|
+
var displayName: string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=hazo_chat_attachment_preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hazo_chat_attachment_preview.d.ts","sourceRoot":"","sources":["../../../src/components/hazo_chat/hazo_chat_attachment_preview.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,KAAK,EAAE,8BAA8B,EAAqB,MAAM,sBAAsB,CAAC;AA+H9F,wBAAgB,yBAAyB,CAAC,EACxC,WAAW,EACX,SAAS,EACT,SAAS,EACV,EAAE,8BAA8B,kDA+BhC;yBAnCe,yBAAyB"}
|