hazo_chat 4.0.2 → 4.0.5
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 +46 -6
- package/SETUP_CHECKLIST.md +12 -2
- package/dist/api/index.d.ts +41 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +40 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/messages.d.ts +85 -0
- package/dist/api/messages.d.ts.map +1 -0
- package/dist/api/messages.js +626 -0
- package/dist/api/messages.js.map +1 -0
- package/dist/api/types.d.ts +134 -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/api/unread_count.d.ts +82 -0
- package/dist/api/unread_count.d.ts.map +1 -0
- package/dist/api/unread_count.js +111 -0
- package/dist/api/unread_count.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 +230 -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 +46 -0
- package/dist/components/hazo_chat/hazo_chat_context.d.ts.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_context.js +277 -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 +140 -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 +45 -0
- package/dist/components/hazo_chat/hazo_chat_header.js.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_input.d.ts +16 -0
- package/dist/components/hazo_chat/hazo_chat_input.d.ts.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_input.js +75 -0
- package/dist/components/hazo_chat/hazo_chat_input.js.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_messages.d.ts +18 -0
- package/dist/components/hazo_chat/hazo_chat_messages.d.ts.map +1 -0
- package/dist/components/hazo_chat/hazo_chat_messages.js +255 -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 +18 -0
- package/dist/components/ui/chat_bubble.d.ts.map +1 -0
- package/dist/components/ui/chat_bubble.js +130 -0
- package/dist/components/ui/chat_bubble.js.map +1 -0
- package/dist/components/ui/hover-card.d.ts +13 -0
- package/dist/components/ui/hover-card.d.ts.map +1 -0
- package/dist/components/ui/hover-card.js +17 -0
- package/dist/components/ui/hover-card.js.map +1 -0
- package/dist/components/ui/index.d.ts +19 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +21 -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 +38 -0
- package/dist/hooks/use_chat_messages.d.ts.map +1 -0
- package/dist/hooks/use_chat_messages.js +584 -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 +26 -0
- package/dist/hooks/use_file_upload.d.ts.map +1 -0
- package/dist/hooks/use_file_upload.js +216 -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 +41 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +72 -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 +572 -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 +2 -6
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
A full-featured React chat component library for group-based communication with document sharing, file attachments, and real-time messaging capabilities.
|
|
4
4
|
|
|
5
|
+
**Version 4.0.4** - Added `read_only` prop for view-only mode (hides chat input).
|
|
6
|
+
|
|
7
|
+
**Version 4.0** - Mandatory logging integration with `hazo_logs`. See [Logging Integration](#logging-integration) section.
|
|
8
|
+
|
|
5
9
|
**Version 3.1** - Generic schema supporting multiple chat patterns: support (client-to-staff), peer (1:1), and group conversations.
|
|
6
10
|
|
|
7
11
|
**Version 3.0** - Introduced group-based chat architecture. Multiple users can participate in a single chat group, perfect for support staff rotating on client sessions.
|
|
@@ -42,7 +46,7 @@ A full-featured React chat component library for group-based communication with
|
|
|
42
46
|
## Installation
|
|
43
47
|
|
|
44
48
|
```bash
|
|
45
|
-
npm install hazo_chat hazo_connect next
|
|
49
|
+
npm install hazo_chat hazo_connect hazo_logs next
|
|
46
50
|
```
|
|
47
51
|
|
|
48
52
|
## UI Requirements
|
|
@@ -480,12 +484,17 @@ export { GET, POST };
|
|
|
480
484
|
'use client';
|
|
481
485
|
|
|
482
486
|
import { HazoChat } from 'hazo_chat';
|
|
487
|
+
import { createClientLogger } from 'hazo_logs/ui';
|
|
488
|
+
|
|
489
|
+
// Create client logger (required in v4.0+)
|
|
490
|
+
const logger = createClientLogger({ packageName: 'hazo_chat' });
|
|
483
491
|
|
|
484
492
|
export default function ChatPage() {
|
|
485
493
|
return (
|
|
486
494
|
<div className="h-screen">
|
|
487
495
|
<HazoChat
|
|
488
496
|
chat_group_id="group-uuid"
|
|
497
|
+
logger={logger}
|
|
489
498
|
reference_id="conversation-123"
|
|
490
499
|
reference_type="support"
|
|
491
500
|
title="Chat with Support"
|
|
@@ -738,6 +747,8 @@ export async function getUnreadCounts(receiver_user_id: string) {
|
|
|
738
747
|
| Prop | Type | Required | Default | Description |
|
|
739
748
|
|------|------|----------|---------|-------------|
|
|
740
749
|
| `chat_group_id` | `string` | ✅ | - | UUID of the chat group (CHANGED from `receiver_user_id` in v3.0) |
|
|
750
|
+
| `logger` | `ClientLogger` | ✅ | - | Logger instance from hazo_logs/ui (NEW in v4.0) |
|
|
751
|
+
| `read_only` | `boolean` | ❌ | `false` | When true, hides chat input for view-only mode (NEW in v4.0.4) |
|
|
741
752
|
| `reference_id` | `string` | ❌ | - | Reference ID for chat context grouping |
|
|
742
753
|
| `reference_type` | `string` | ❌ | `'chat'` | Type of reference |
|
|
743
754
|
| `api_base_url` | `string` | ❌ | `'/api/hazo_chat'` | Base URL for API endpoints |
|
|
@@ -757,8 +768,13 @@ export async function getUnreadCounts(receiver_user_id: string) {
|
|
|
757
768
|
### Example with All Props
|
|
758
769
|
|
|
759
770
|
```tsx
|
|
771
|
+
import { createClientLogger } from 'hazo_logs/ui';
|
|
772
|
+
|
|
773
|
+
const logger = createClientLogger({ packageName: 'hazo_chat' });
|
|
774
|
+
|
|
760
775
|
<HazoChat
|
|
761
776
|
chat_group_id="group-123"
|
|
777
|
+
logger={logger}
|
|
762
778
|
reference_id="project-456"
|
|
763
779
|
reference_type="project_chat"
|
|
764
780
|
api_base_url="/api/hazo_chat"
|
|
@@ -771,6 +787,7 @@ export async function getUnreadCounts(receiver_user_id: string) {
|
|
|
771
787
|
{ id: 'doc-1', type: 'document', name: 'Design.pdf', url: '/files/design.pdf', scope: 'field' }
|
|
772
788
|
]}
|
|
773
789
|
on_close={() => console.log('Chat closed')}
|
|
790
|
+
read_only={false} // set to true for view-only mode
|
|
774
791
|
className="h-[600px]"
|
|
775
792
|
/>
|
|
776
793
|
```
|
|
@@ -781,13 +798,31 @@ hazo_chat provides props to customize component appearance and behavior without
|
|
|
781
798
|
|
|
782
799
|
### Common Customizations
|
|
783
800
|
|
|
801
|
+
#### Read-Only Mode (View Only)
|
|
802
|
+
|
|
803
|
+
To display chat messages without allowing users to send new messages:
|
|
804
|
+
|
|
805
|
+
```tsx
|
|
806
|
+
<HazoChat
|
|
807
|
+
chat_group_id="group-123"
|
|
808
|
+
logger={logger}
|
|
809
|
+
read_only={true} // Hides chat input - view only
|
|
810
|
+
/>
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
Use cases:
|
|
814
|
+
- Displaying archived conversations
|
|
815
|
+
- Showing chat history to non-participants
|
|
816
|
+
- Read-only audit views
|
|
817
|
+
|
|
784
818
|
#### Hide Sidebar Toggle Button (Hamburger Menu)
|
|
785
819
|
|
|
786
820
|
By default, the sidebar toggle button is hidden (`show_sidebar_toggle={false}`). To show it:
|
|
787
821
|
|
|
788
822
|
```tsx
|
|
789
823
|
<HazoChat
|
|
790
|
-
|
|
824
|
+
chat_group_id="group-123"
|
|
825
|
+
logger={logger}
|
|
791
826
|
show_sidebar_toggle={true} // Show hamburger menu button
|
|
792
827
|
/>
|
|
793
828
|
```
|
|
@@ -798,7 +833,8 @@ To hide the delete button on chat bubbles:
|
|
|
798
833
|
|
|
799
834
|
```tsx
|
|
800
835
|
<HazoChat
|
|
801
|
-
|
|
836
|
+
chat_group_id="group-123"
|
|
837
|
+
logger={logger}
|
|
802
838
|
show_delete_button={false} // Hide delete button
|
|
803
839
|
/>
|
|
804
840
|
```
|
|
@@ -809,7 +845,8 @@ To make all chat bubbles fully round (instead of the default style with a tail):
|
|
|
809
845
|
|
|
810
846
|
```tsx
|
|
811
847
|
<HazoChat
|
|
812
|
-
|
|
848
|
+
chat_group_id="group-123"
|
|
849
|
+
logger={logger}
|
|
813
850
|
bubble_radius="full" // Fully round all corners
|
|
814
851
|
/>
|
|
815
852
|
```
|
|
@@ -818,6 +855,7 @@ To make all chat bubbles fully round (instead of the default style with a tail):
|
|
|
818
855
|
|
|
819
856
|
| Prop | Default | Options | Description |
|
|
820
857
|
|------|--------|---------|------------|
|
|
858
|
+
| `read_only` | `false` | `boolean` | Hide chat input for view-only mode |
|
|
821
859
|
| `show_sidebar_toggle` | `false` | `boolean` | Show/hide the hamburger menu button |
|
|
822
860
|
| `show_delete_button` | `true` | `boolean` | Show/hide delete button on chat bubbles |
|
|
823
861
|
| `bubble_radius` | `'default'` | `'default' \| 'full'` | Bubble border radius style |
|
|
@@ -827,9 +865,11 @@ To make all chat bubbles fully round (instead of the default style with a tail):
|
|
|
827
865
|
```tsx
|
|
828
866
|
<HazoChat
|
|
829
867
|
chat_group_id="group-123"
|
|
868
|
+
logger={logger}
|
|
830
869
|
reference_id="project-456"
|
|
831
|
-
|
|
832
|
-
|
|
870
|
+
read_only={false} // Set true for view-only mode
|
|
871
|
+
show_sidebar_toggle={false} // Hide hamburger menu
|
|
872
|
+
show_delete_button={false} // Hide delete buttons
|
|
833
873
|
bubble_radius="full" // Fully round bubbles
|
|
834
874
|
title="Project Chat"
|
|
835
875
|
className="h-[600px]"
|
package/SETUP_CHECKLIST.md
CHANGED
|
@@ -42,7 +42,7 @@ A comprehensive, step-by-step guide for setting up hazo_chat in a Next.js projec
|
|
|
42
42
|
### Step 2.1: Install Core Packages
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
|
-
npm install hazo_chat hazo_connect
|
|
45
|
+
npm install hazo_chat hazo_connect hazo_logs
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
### Step 2.2: Install Peer Dependencies (if not already installed)
|
|
@@ -52,7 +52,7 @@ npm install react react-dom next
|
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
### Verification
|
|
55
|
-
- [ ] `package.json` contains `hazo_chat` and `
|
|
55
|
+
- [ ] `package.json` contains `hazo_chat`, `hazo_connect`, and `hazo_logs`
|
|
56
56
|
- [ ] No npm installation errors
|
|
57
57
|
- [ ] `node_modules/hazo_chat` exists
|
|
58
58
|
|
|
@@ -777,12 +777,17 @@ export async function GET(request: NextRequest) {
|
|
|
777
777
|
'use client';
|
|
778
778
|
|
|
779
779
|
import { HazoChat } from 'hazo_chat';
|
|
780
|
+
import { createClientLogger } from 'hazo_logs/ui';
|
|
781
|
+
|
|
782
|
+
// Create client logger (required in v4.0+)
|
|
783
|
+
const logger = createClientLogger({ packageName: 'hazo_chat' });
|
|
780
784
|
|
|
781
785
|
export default function ChatPage() {
|
|
782
786
|
return (
|
|
783
787
|
<div className="h-screen">
|
|
784
788
|
<HazoChat
|
|
785
789
|
chat_group_id="group-uuid-here"
|
|
790
|
+
logger={logger}
|
|
786
791
|
title="Chat"
|
|
787
792
|
subtitle="Direct Message"
|
|
788
793
|
/>
|
|
@@ -797,11 +802,15 @@ export default function ChatPage() {
|
|
|
797
802
|
'use client';
|
|
798
803
|
|
|
799
804
|
import { HazoChat } from 'hazo_chat';
|
|
805
|
+
import { createClientLogger } from 'hazo_logs/ui';
|
|
806
|
+
|
|
807
|
+
const logger = createClientLogger({ packageName: 'hazo_chat' });
|
|
800
808
|
|
|
801
809
|
export default function ChatPage() {
|
|
802
810
|
return (
|
|
803
811
|
<HazoChat
|
|
804
812
|
chat_group_id="group-123"
|
|
813
|
+
logger={logger}
|
|
805
814
|
reference_id="project-456"
|
|
806
815
|
reference_type="project_chat"
|
|
807
816
|
api_base_url="/api/hazo_chat"
|
|
@@ -818,6 +827,7 @@ export default function ChatPage() {
|
|
|
818
827
|
}
|
|
819
828
|
]}
|
|
820
829
|
on_close={() => window.history.back()}
|
|
830
|
+
read_only={false} // Set true for view-only mode
|
|
821
831
|
className="h-[600px]"
|
|
822
832
|
/>
|
|
823
833
|
);
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // app/api/hazo_chat/messages/[id]/route.ts
|
|
25
|
+
* import { createDeleteHandler } from 'hazo_chat/api';
|
|
26
|
+
* import { getHazoConnectSingleton } from 'hazo_connect/nextjs/setup';
|
|
27
|
+
*
|
|
28
|
+
* export const dynamic = 'force-dynamic';
|
|
29
|
+
*
|
|
30
|
+
* const { DELETE } = createDeleteHandler({
|
|
31
|
+
* getHazoConnect: () => getHazoConnectSingleton()
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* export { DELETE };
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export { createMessagesHandler, createMarkAsReadHandler, createDeleteHandler, } from './messages.js';
|
|
38
|
+
export { createUnreadCountFunction } from './unread_count.js';
|
|
39
|
+
export type { MessagesHandlerOptions, ChatMessageInput, ChatMessageRecord, ApiErrorResponse, ApiSuccessResponse, PaginationMeta, } from './types.js';
|
|
40
|
+
export type { UnreadCountFunctionOptions, UnreadCountResult } from './unread_count.js';
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAG9D,YAAY,EACV,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // app/api/hazo_chat/messages/[id]/route.ts
|
|
25
|
+
* import { createDeleteHandler } from 'hazo_chat/api';
|
|
26
|
+
* import { getHazoConnectSingleton } from 'hazo_connect/nextjs/setup';
|
|
27
|
+
*
|
|
28
|
+
* export const dynamic = 'force-dynamic';
|
|
29
|
+
*
|
|
30
|
+
* const { DELETE } = createDeleteHandler({
|
|
31
|
+
* getHazoConnect: () => getHazoConnectSingleton()
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* export { DELETE };
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
// Export handler factories
|
|
38
|
+
export { createMessagesHandler, createMarkAsReadHandler, createDeleteHandler, } from './messages.js';
|
|
39
|
+
export { createUnreadCountFunction } from './unread_count.js';
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,2BAA2B;AAC3B,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messages API Handler Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates GET, POST, and DELETE 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
|
+
/**
|
|
35
|
+
* Creates a PATCH handler for marking a message as read
|
|
36
|
+
*
|
|
37
|
+
* This handler should be used in a Next.js API route like:
|
|
38
|
+
* /api/hazo_chat/messages/[id]/read/route.ts
|
|
39
|
+
*
|
|
40
|
+
* @param options - Configuration options
|
|
41
|
+
* @returns PATCH handler function
|
|
42
|
+
*/
|
|
43
|
+
export declare function createMarkAsReadHandler(options: MessagesHandlerOptions): {
|
|
44
|
+
PATCH: (request: NextRequest, context: {
|
|
45
|
+
params: {
|
|
46
|
+
id: string;
|
|
47
|
+
} | Promise<{
|
|
48
|
+
id: string;
|
|
49
|
+
}>;
|
|
50
|
+
}) => Promise<NextResponse>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Creates a DELETE handler for soft-deleting a message
|
|
54
|
+
*
|
|
55
|
+
* This handler should be used in a Next.js API route like:
|
|
56
|
+
* /api/hazo_chat/messages/[id]/route.ts
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // app/api/hazo_chat/messages/[id]/route.ts
|
|
61
|
+
* import { createDeleteHandler } from 'hazo_chat/api';
|
|
62
|
+
* import { getHazoConnectSingleton } from 'hazo_connect/nextjs/setup';
|
|
63
|
+
*
|
|
64
|
+
* export const dynamic = 'force-dynamic';
|
|
65
|
+
*
|
|
66
|
+
* const { DELETE } = createDeleteHandler({
|
|
67
|
+
* getHazoConnect: () => getHazoConnectSingleton()
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* export { DELETE };
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @param options - Configuration options
|
|
74
|
+
* @returns DELETE handler function
|
|
75
|
+
*/
|
|
76
|
+
export declare function createDeleteHandler(options: MessagesHandlerOptions): {
|
|
77
|
+
DELETE: (request: NextRequest, context: {
|
|
78
|
+
params: {
|
|
79
|
+
id: string;
|
|
80
|
+
} | Promise<{
|
|
81
|
+
id: string;
|
|
82
|
+
}>;
|
|
83
|
+
}) => Promise<NextResponse>;
|
|
84
|
+
};
|
|
85
|
+
//# 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;AAKxD,OAAO,KAAK,EAAE,sBAAsB,EAAkG,MAAM,YAAY,CAAC;AA2FzJ;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB;mBAevC,WAAW,KAAG,OAAO,CAAC,YAAY,CAAC;oBA2KlC,WAAW,KAAG,OAAO,CAAC,YAAY,CAAC;EAiJjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,sBAAsB;qBAa1D,WAAW,WACX;QAAE,MAAM,EAAE;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,KAC5D,OAAO,CAAC,YAAY,CAAC;EA2IzB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,sBAAsB;sBActD,WAAW,WACX;QAAE,MAAM,EAAE;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,KAC5D,OAAO,CAAC,YAAY,CAAC;EAgIzB"}
|