hazo_chat 2.0.13 → 2.0.15

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.
Files changed (155) hide show
  1. package/README.md +104 -7
  2. package/SETUP_CHECKLIST.md +73 -0
  3. package/package.json +1 -1
  4. package/dist/api/index.d.ts +0 -26
  5. package/dist/api/index.d.ts.map +0 -1
  6. package/dist/api/index.js +0 -25
  7. package/dist/api/index.js.map +0 -1
  8. package/dist/api/messages.d.ts +0 -34
  9. package/dist/api/messages.d.ts.map +0 -1
  10. package/dist/api/messages.js +0 -214
  11. package/dist/api/messages.js.map +0 -1
  12. package/dist/api/types.d.ts +0 -69
  13. package/dist/api/types.d.ts.map +0 -1
  14. package/dist/api/types.js +0 -8
  15. package/dist/api/types.js.map +0 -1
  16. package/dist/api/unread_count.d.ts +0 -57
  17. package/dist/api/unread_count.d.ts.map +0 -1
  18. package/dist/api/unread_count.js +0 -86
  19. package/dist/api/unread_count.js.map +0 -1
  20. package/dist/components/hazo_chat/hazo_chat.d.ts +0 -28
  21. package/dist/components/hazo_chat/hazo_chat.d.ts.map +0 -1
  22. package/dist/components/hazo_chat/hazo_chat.js +0 -201
  23. package/dist/components/hazo_chat/hazo_chat.js.map +0 -1
  24. package/dist/components/hazo_chat/hazo_chat_attachment_preview.d.ts +0 -17
  25. package/dist/components/hazo_chat/hazo_chat_attachment_preview.d.ts.map +0 -1
  26. package/dist/components/hazo_chat/hazo_chat_attachment_preview.js +0 -60
  27. package/dist/components/hazo_chat/hazo_chat_attachment_preview.js.map +0 -1
  28. package/dist/components/hazo_chat/hazo_chat_context.d.ts +0 -42
  29. package/dist/components/hazo_chat/hazo_chat_context.d.ts.map +0 -1
  30. package/dist/components/hazo_chat/hazo_chat_context.js +0 -273
  31. package/dist/components/hazo_chat/hazo_chat_context.js.map +0 -1
  32. package/dist/components/hazo_chat/hazo_chat_document_viewer.d.ts +0 -15
  33. package/dist/components/hazo_chat/hazo_chat_document_viewer.d.ts.map +0 -1
  34. package/dist/components/hazo_chat/hazo_chat_document_viewer.js +0 -111
  35. package/dist/components/hazo_chat/hazo_chat_document_viewer.js.map +0 -1
  36. package/dist/components/hazo_chat/hazo_chat_header.d.ts +0 -16
  37. package/dist/components/hazo_chat/hazo_chat_header.d.ts.map +0 -1
  38. package/dist/components/hazo_chat/hazo_chat_header.js +0 -24
  39. package/dist/components/hazo_chat/hazo_chat_header.js.map +0 -1
  40. package/dist/components/hazo_chat/hazo_chat_input.d.ts +0 -16
  41. package/dist/components/hazo_chat/hazo_chat_input.d.ts.map +0 -1
  42. package/dist/components/hazo_chat/hazo_chat_input.js +0 -75
  43. package/dist/components/hazo_chat/hazo_chat_input.js.map +0 -1
  44. package/dist/components/hazo_chat/hazo_chat_messages.d.ts +0 -17
  45. package/dist/components/hazo_chat/hazo_chat_messages.d.ts.map +0 -1
  46. package/dist/components/hazo_chat/hazo_chat_messages.js +0 -109
  47. package/dist/components/hazo_chat/hazo_chat_messages.js.map +0 -1
  48. package/dist/components/hazo_chat/hazo_chat_reference_list.d.ts +0 -16
  49. package/dist/components/hazo_chat/hazo_chat_reference_list.d.ts.map +0 -1
  50. package/dist/components/hazo_chat/hazo_chat_reference_list.js +0 -59
  51. package/dist/components/hazo_chat/hazo_chat_reference_list.js.map +0 -1
  52. package/dist/components/hazo_chat/hazo_chat_sidebar.d.ts +0 -18
  53. package/dist/components/hazo_chat/hazo_chat_sidebar.d.ts.map +0 -1
  54. package/dist/components/hazo_chat/hazo_chat_sidebar.js +0 -72
  55. package/dist/components/hazo_chat/hazo_chat_sidebar.js.map +0 -1
  56. package/dist/components/hazo_chat/index.d.ts +0 -16
  57. package/dist/components/hazo_chat/index.d.ts.map +0 -1
  58. package/dist/components/hazo_chat/index.js +0 -19
  59. package/dist/components/hazo_chat/index.js.map +0 -1
  60. package/dist/components/index.d.ts +0 -9
  61. package/dist/components/index.d.ts.map +0 -1
  62. package/dist/components/index.js +0 -11
  63. package/dist/components/index.js.map +0 -1
  64. package/dist/components/ui/avatar.d.ts +0 -13
  65. package/dist/components/ui/avatar.d.ts.map +0 -1
  66. package/dist/components/ui/avatar.js +0 -28
  67. package/dist/components/ui/avatar.js.map +0 -1
  68. package/dist/components/ui/badge.d.ts +0 -16
  69. package/dist/components/ui/badge.d.ts.map +0 -1
  70. package/dist/components/ui/badge.js +0 -36
  71. package/dist/components/ui/badge.js.map +0 -1
  72. package/dist/components/ui/button.d.ts +0 -18
  73. package/dist/components/ui/button.d.ts.map +0 -1
  74. package/dist/components/ui/button.js +0 -47
  75. package/dist/components/ui/button.js.map +0 -1
  76. package/dist/components/ui/chat_bubble.d.ts +0 -18
  77. package/dist/components/ui/chat_bubble.d.ts.map +0 -1
  78. package/dist/components/ui/chat_bubble.js +0 -107
  79. package/dist/components/ui/chat_bubble.js.map +0 -1
  80. package/dist/components/ui/hover-card.d.ts +0 -13
  81. package/dist/components/ui/hover-card.d.ts.map +0 -1
  82. package/dist/components/ui/hover-card.js +0 -17
  83. package/dist/components/ui/hover-card.js.map +0 -1
  84. package/dist/components/ui/index.d.ts +0 -19
  85. package/dist/components/ui/index.d.ts.map +0 -1
  86. package/dist/components/ui/index.js +0 -21
  87. package/dist/components/ui/index.js.map +0 -1
  88. package/dist/components/ui/input.d.ts +0 -11
  89. package/dist/components/ui/input.d.ts.map +0 -1
  90. package/dist/components/ui/input.js +0 -18
  91. package/dist/components/ui/input.js.map +0 -1
  92. package/dist/components/ui/loading_skeleton.d.ts +0 -19
  93. package/dist/components/ui/loading_skeleton.d.ts.map +0 -1
  94. package/dist/components/ui/loading_skeleton.js +0 -30
  95. package/dist/components/ui/loading_skeleton.js.map +0 -1
  96. package/dist/components/ui/scroll-area.d.ts +0 -12
  97. package/dist/components/ui/scroll-area.d.ts.map +0 -1
  98. package/dist/components/ui/scroll-area.js +0 -25
  99. package/dist/components/ui/scroll-area.js.map +0 -1
  100. package/dist/components/ui/separator.d.ts +0 -11
  101. package/dist/components/ui/separator.d.ts.map +0 -1
  102. package/dist/components/ui/separator.js +0 -18
  103. package/dist/components/ui/separator.js.map +0 -1
  104. package/dist/components/ui/skeleton.d.ts +0 -9
  105. package/dist/components/ui/skeleton.d.ts.map +0 -1
  106. package/dist/components/ui/skeleton.js +0 -16
  107. package/dist/components/ui/skeleton.js.map +0 -1
  108. package/dist/components/ui/textarea.d.ts +0 -11
  109. package/dist/components/ui/textarea.d.ts.map +0 -1
  110. package/dist/components/ui/textarea.js +0 -18
  111. package/dist/components/ui/textarea.js.map +0 -1
  112. package/dist/components/ui/tooltip.d.ts +0 -14
  113. package/dist/components/ui/tooltip.d.ts.map +0 -1
  114. package/dist/components/ui/tooltip.js +0 -30
  115. package/dist/components/ui/tooltip.js.map +0 -1
  116. package/dist/hooks/index.d.ts +0 -10
  117. package/dist/hooks/index.d.ts.map +0 -1
  118. package/dist/hooks/index.js +0 -10
  119. package/dist/hooks/index.js.map +0 -1
  120. package/dist/hooks/use_chat_messages.d.ts +0 -33
  121. package/dist/hooks/use_chat_messages.d.ts.map +0 -1
  122. package/dist/hooks/use_chat_messages.js +0 -466
  123. package/dist/hooks/use_chat_messages.js.map +0 -1
  124. package/dist/hooks/use_chat_references.d.ts +0 -17
  125. package/dist/hooks/use_chat_references.d.ts.map +0 -1
  126. package/dist/hooks/use_chat_references.js +0 -133
  127. package/dist/hooks/use_chat_references.js.map +0 -1
  128. package/dist/hooks/use_file_upload.d.ts +0 -23
  129. package/dist/hooks/use_file_upload.d.ts.map +0 -1
  130. package/dist/hooks/use_file_upload.js +0 -212
  131. package/dist/hooks/use_file_upload.js.map +0 -1
  132. package/dist/index.d.ts +0 -13
  133. package/dist/index.d.ts.map +0 -1
  134. package/dist/index.js +0 -17
  135. package/dist/index.js.map +0 -1
  136. package/dist/lib/config.d.ts +0 -41
  137. package/dist/lib/config.d.ts.map +0 -1
  138. package/dist/lib/config.js +0 -93
  139. package/dist/lib/config.js.map +0 -1
  140. package/dist/lib/constants.d.ts +0 -41
  141. package/dist/lib/constants.d.ts.map +0 -1
  142. package/dist/lib/constants.js +0 -72
  143. package/dist/lib/constants.js.map +0 -1
  144. package/dist/lib/index.d.ts +0 -9
  145. package/dist/lib/index.d.ts.map +0 -1
  146. package/dist/lib/index.js +0 -9
  147. package/dist/lib/index.js.map +0 -1
  148. package/dist/lib/utils.d.ts +0 -17
  149. package/dist/lib/utils.d.ts.map +0 -1
  150. package/dist/lib/utils.js +0 -20
  151. package/dist/lib/utils.js.map +0 -1
  152. package/dist/types/index.d.ts +0 -404
  153. package/dist/types/index.d.ts.map +0 -1
  154. package/dist/types/index.js +0 -11
  155. package/dist/types/index.js.map +0 -1
package/README.md CHANGED
@@ -9,7 +9,7 @@ A full-featured React chat component library for 1-1 communication with document
9
9
  - 📱 **Responsive Design** - Works on desktop and mobile with adaptive layout
10
10
  - 💬 **Real-time Messaging** - Polling or manual refresh modes for message updates with optimistic UI
11
11
  - 📎 **File Attachments** - Support for documents and images with preview
12
- - 📄 **Document Viewer** - Built-in PDF and image viewer with expand/collapse toggle
12
+ - 📄 **Document Viewer** - Built-in PDF and image viewer with expand/collapse toggle, download, and open in new tab actions
13
13
  - 👤 **User Profiles** - Avatar display and user information
14
14
  - 🔄 **Infinite Scroll** - Cursor-based pagination for message history
15
15
  - ✅ **Read Receipts** - Track message read status
@@ -102,7 +102,54 @@ const config: Config = {
102
102
  ],
103
103
  theme: {
104
104
  extend: {
105
- // Your theme extensions
105
+ // Required: Font family configuration for consistent typography
106
+ fontFamily: {
107
+ sans: ['var(--font-sans)', 'system-ui', 'sans-serif'],
108
+ mono: ['var(--font-mono)', 'monospace'],
109
+ },
110
+ // Required: Color variables for shadcn/ui compatibility
111
+ colors: {
112
+ background: 'var(--background)',
113
+ foreground: 'var(--foreground)',
114
+ card: {
115
+ DEFAULT: 'var(--card)',
116
+ foreground: 'var(--card-foreground)',
117
+ },
118
+ popover: {
119
+ DEFAULT: 'var(--popover)',
120
+ foreground: 'var(--popover-foreground)',
121
+ },
122
+ primary: {
123
+ DEFAULT: 'var(--primary)',
124
+ foreground: 'var(--primary-foreground)',
125
+ },
126
+ secondary: {
127
+ DEFAULT: 'var(--secondary)',
128
+ foreground: 'var(--secondary-foreground)',
129
+ },
130
+ muted: {
131
+ DEFAULT: 'var(--muted)',
132
+ foreground: 'var(--muted-foreground)',
133
+ },
134
+ accent: {
135
+ DEFAULT: 'var(--accent)',
136
+ foreground: 'var(--accent-foreground)',
137
+ },
138
+ destructive: {
139
+ DEFAULT: 'var(--destructive)',
140
+ foreground: 'var(--destructive-foreground)',
141
+ },
142
+ border: 'var(--border)',
143
+ input: 'var(--input)',
144
+ ring: 'var(--ring)',
145
+ },
146
+ // Required: Border radius configuration
147
+ borderRadius: {
148
+ lg: 'var(--radius)',
149
+ md: 'calc(var(--radius) - 2px)',
150
+ sm: 'calc(var(--radius) - 4px)',
151
+ },
152
+ // Your additional theme extensions can go here
106
153
  },
107
154
  },
108
155
  plugins: [],
@@ -111,6 +158,18 @@ const config: Config = {
111
158
  export default config;
112
159
  ```
113
160
 
161
+ **Important Theme Extensions:**
162
+
163
+ The `hazo_chat` component relies on specific Tailwind theme extensions to ensure consistent styling:
164
+
165
+ 1. **Font Families:** The `font-sans` and `font-mono` utilities must map to CSS variables for consistent typography across all consuming applications.
166
+
167
+ 2. **Color Variables:** All color utilities (e.g., `bg-background`, `text-foreground`, `border-border`) must map to CSS variables defined in your `globals.css`.
168
+
169
+ 3. **Border Radius:** The component uses `rounded-lg`, `rounded-md`, and `rounded-sm` which must map to your CSS `--radius` variable.
170
+
171
+ **Note:** If you're using shadcn/ui in your project, your Tailwind config likely already includes these extensions. Simply add the `hazo_chat` package path to the `content` array.
172
+
114
173
  **Why This Is Required:**
115
174
 
116
175
  The `hazo_chat` component library uses Tailwind CSS utility classes (e.g., `flex`, `h-full`, `bg-background`, `p-4`) for all styling. These classes are not compiled into CSS by default. By adding the package path to your Tailwind `content` array, Tailwind will:
@@ -257,11 +316,47 @@ This section defines the visual design standards and component behavior specific
257
316
 
258
317
  **Important:** When wrapping HazoChat in containers (e.g., Card components):
259
318
 
260
- 1. **Avoid nested `overflow-hidden`**: Nested overflow-hidden containers can clip rounded corners. Use overflow-hidden only on the HazoChat component itself.
261
-
262
- 2. **Padding**: If wrapping in a Card, ensure proper padding is maintained. Avoid `p-0` on CardContent as it may affect internal spacing.
263
-
264
- 3. **Tailwind Configuration**: Ensure `./node_modules/hazo_chat/dist/**/*.{js,ts,jsx,tsx}` is included in your Tailwind `content` array so all utility classes (including `rounded-*` classes) are compiled.
319
+ 1. **Container Height Requirement:**
320
+ - The `HazoChat` component uses `h-full` which requires its parent container to have a **defined height**.
321
+ - **Required:** Parent container must have a fixed height (e.g., `h-[600px]`, `h-screen`, `min-h-[500px]`).
322
+ - **Example:**
323
+ ```tsx
324
+ <div className="h-[600px]"> {/* Required: parent must have height */}
325
+ <HazoChat receiver_user_id={...} />
326
+ </div>
327
+ ```
328
+ - **Without a defined height**, the component may not render correctly and the chat message area may collapse.
329
+
330
+ 2. **Container Width Requirements:**
331
+ - **Recommended minimum width:** 500px for optimal two-column layout (document viewer + chat messages).
332
+ - **For narrow containers (< 500px):** Document references will automatically open in a new tab when clicked instead of showing in the preview panel.
333
+ - **Document viewer defaults to collapsed** to maximize chat space. Users can expand it using the toggle button.
334
+ - **Example:**
335
+ ```tsx
336
+ {/* Recommended: at least 500px width */}
337
+ <div className="w-[600px] h-[600px]">
338
+ <HazoChat receiver_user_id={...} />
339
+ </div>
340
+ ```
341
+
342
+ 3. **Avoid nested `overflow-hidden`**: Nested overflow-hidden containers can clip rounded corners. Use overflow-hidden only on the HazoChat component itself.
343
+
344
+ 4. **Padding**: If wrapping in a Card, ensure proper padding is maintained. Avoid `p-0` on CardContent as it may affect internal spacing.
345
+
346
+ 5. **Tailwind Configuration**: Ensure `./node_modules/hazo_chat/dist/**/*.{js,ts,jsx,tsx}` is included in your Tailwind `content` array so all utility classes (including `rounded-*` classes) are compiled.
347
+
348
+ **Complete Container Example:**
349
+ ```tsx
350
+ <div className="w-[600px] h-[600px] flex-shrink-0">
351
+ <div className="rounded-xl border shadow-lg p-0 h-full">
352
+ <HazoChat
353
+ receiver_user_id="user-123"
354
+ title="Chat"
355
+ className="h-full"
356
+ />
357
+ </div>
358
+ </div>
359
+ ```
265
360
 
266
361
  #### Typography
267
362
 
@@ -910,6 +1005,8 @@ interface ChatReferenceItem {
910
1005
  }
911
1006
  ```
912
1007
 
1008
+ **Note on MIME Type:** The `mime_type` property is optional. If not provided, the component will automatically infer the MIME type from the file extension (e.g., `.jpg` → `image/jpeg`, `.pdf` → `application/pdf`). This ensures document preview works even when `mime_type` is not explicitly set. Supported file extensions for inference include: `pdf`, `png`, `jpg`, `jpeg`, `gif`, `webp`, `txt`, `doc`, `docx`.
1009
+
913
1010
  ## Database Schema
914
1011
 
915
1012
  ### hazo_chat Table
@@ -397,6 +397,79 @@ export default function ChatPage() {
397
397
  }
398
398
  ```
399
399
 
400
+ ### Step 5.3: Container Requirements
401
+
402
+ **Critical:** The `HazoChat` component requires specific container dimensions to render correctly.
403
+
404
+ #### Container Height Requirement
405
+
406
+ The component uses `h-full`, which requires its parent container to have a **defined height**. Without this, the chat message area may collapse.
407
+
408
+ **Required:** Parent container must have a fixed height:
409
+
410
+ ```typescript
411
+ <div className="h-[600px]"> {/* ✅ Required: parent must have height */}
412
+ <HazoChat receiver_user_id={...} />
413
+ </div>
414
+
415
+ // OR
416
+
417
+ <div className="h-screen"> {/* ✅ Full screen height */}
418
+ <HazoChat receiver_user_id={...} />
419
+ </div>
420
+
421
+ // ❌ WRONG - will cause layout issues
422
+ <div> {/* No height defined */}
423
+ <HazoChat receiver_user_id={...} />
424
+ </div>
425
+ ```
426
+
427
+ #### Container Width Requirements
428
+
429
+ - **Recommended minimum width:** 500px for optimal two-column layout (document viewer + chat messages).
430
+ - **For narrow containers (< 500px):** Document references will automatically open in a new tab when clicked instead of showing in the preview panel.
431
+ - **Document viewer defaults to collapsed** to maximize chat space. Users can expand it using the toggle button.
432
+
433
+ ```typescript
434
+ // ✅ Recommended: at least 500px width
435
+ <div className="w-[600px] h-[600px]">
436
+ <HazoChat receiver_user_id={...} />
437
+ </div>
438
+
439
+ // ✅ Narrow container: documents will open in new tab
440
+ <div className="w-[400px] h-[600px]">
441
+ <HazoChat receiver_user_id={...} />
442
+ </div>
443
+ ```
444
+
445
+ #### Complete Container Example
446
+
447
+ ```typescript
448
+ 'use client';
449
+
450
+ import { HazoChat } from 'hazo_chat';
451
+
452
+ export default function ChatPage() {
453
+ return (
454
+ <div className="w-[600px] h-[600px] flex-shrink-0">
455
+ <div className="rounded-xl border shadow-lg p-0 h-full">
456
+ <HazoChat
457
+ receiver_user_id="user-123"
458
+ title="Chat"
459
+ className="h-full"
460
+ />
461
+ </div>
462
+ </div>
463
+ );
464
+ }
465
+ ```
466
+
467
+ **Verification:**
468
+ - [ ] Parent container has defined height (e.g., `h-[600px]`, `h-screen`)
469
+ - [ ] Container width is at least 500px for optimal layout (or accept narrow width behavior)
470
+ - [ ] Component renders with proper chat message area visible
471
+ - [ ] Document viewer toggle button is accessible
472
+
400
473
  ---
401
474
 
402
475
  ## 6. UI Components and Styling Setup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_chat",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
4
4
  "description": "Chat interface for 1-1 communication with API-first architecture",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,26 +0,0 @@
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 { createUnreadCountFunction } from './unread_count.js';
24
- export type { MessagesHandlerOptions, ChatMessageInput, ChatMessageRecord } from './types.js';
25
- export type { UnreadCountFunctionOptions, UnreadCountResult } from './unread_count.js';
26
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAG9D,YAAY,EACV,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,0BAA0B,EAC1B,iBAAiB,EAClB,MAAM,mBAAmB,CAAC"}
package/dist/api/index.js DELETED
@@ -1,25 +0,0 @@
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
- export { createUnreadCountFunction } from './unread_count.js';
25
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,34 +0,0 @@
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
@@ -1 +0,0 @@
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;EA0GjE"}
@@ -1,214 +0,0 @@
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
- reference_list: null,
199
- read_at: null,
200
- deleted_at: null,
201
- created_at: now,
202
- changed_at: now,
203
- },
204
- });
205
- }
206
- catch (error) {
207
- const error_message = error instanceof Error ? error.message : 'Unknown error';
208
- console.error('[hazo_chat/messages POST] Error:', error_message, error);
209
- return NextResponse.json({ success: false, error: 'Failed to save message' }, { status: 500 });
210
- }
211
- }
212
- return { GET, POST };
213
- }
214
- //# sourceMappingURL=messages.js.map
@@ -1 +0,0 @@
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;A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AChB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AACvB,CAAC"}
@@ -1,69 +0,0 @@
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
@@ -1 +0,0 @@
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"}
package/dist/api/types.js DELETED
@@ -1,8 +0,0 @@
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
- export {};
8
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}