@zyacreatives/shared 2.2.36 → 2.2.38

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.
@@ -38,7 +38,7 @@ export declare const ChatEntitySchema: z.ZodObject<{
38
38
  receiverImgUrl: z.ZodNullable<z.ZodString>;
39
39
  lastMessageSent: z.ZodNullable<z.ZodString>;
40
40
  lastMessageAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
41
- unreadCount: z.ZodDefault<z.ZodNumber>;
41
+ isUnread: z.ZodDefault<z.ZodNumber>;
42
42
  isOnline: z.ZodDefault<z.ZodBoolean>;
43
43
  }, z.core.$strip>;
44
44
  export declare const CreateChatInputSchema: z.ZodObject<{
@@ -87,7 +87,7 @@ export declare const GetChatsOutputSchema: z.ZodArray<z.ZodObject<{
87
87
  receiverImgUrl: z.ZodNullable<z.ZodString>;
88
88
  lastMessageSent: z.ZodNullable<z.ZodString>;
89
89
  lastMessageAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
90
- unreadCount: z.ZodDefault<z.ZodNumber>;
90
+ isUnread: z.ZodDefault<z.ZodNumber>;
91
91
  isOnline: z.ZodDefault<z.ZodBoolean>;
92
92
  }, z.core.$strip>>;
93
93
  export declare const GetChatsForUserOutputSchema: z.ZodObject<{
@@ -114,7 +114,7 @@ export declare const GetChatsForUserOutputSchema: z.ZodObject<{
114
114
  receiverImgUrl: z.ZodNullable<z.ZodString>;
115
115
  lastMessageSent: z.ZodNullable<z.ZodString>;
116
116
  lastMessageAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
117
- unreadCount: z.ZodDefault<z.ZodNumber>;
117
+ isUnread: z.ZodDefault<z.ZodNumber>;
118
118
  isOnline: z.ZodDefault<z.ZodBoolean>;
119
119
  }, z.core.$strip>>;
120
120
  nextCursor: z.ZodNullable<z.ZodString>;
@@ -143,16 +143,16 @@ export declare const GetMessageRequestsForUserOutputSchema: z.ZodObject<{
143
143
  receiverImgUrl: z.ZodNullable<z.ZodString>;
144
144
  lastMessageSent: z.ZodNullable<z.ZodString>;
145
145
  lastMessageAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
146
- unreadCount: z.ZodDefault<z.ZodNumber>;
146
+ isUnread: z.ZodDefault<z.ZodNumber>;
147
147
  isOnline: z.ZodDefault<z.ZodBoolean>;
148
148
  }, z.core.$strip>>;
149
149
  nextCursor: z.ZodNullable<z.ZodString>;
150
150
  }, z.core.$strip>;
151
- export declare const AcceptMessageRequestInput: z.ZodObject<{
151
+ export declare const AcceptMessageRequestInputSchema: z.ZodObject<{
152
152
  chatId: z.ZodCUID2;
153
153
  userId: z.ZodCUID2;
154
154
  }, z.core.$strip>;
155
- export declare const DeclineMessageRequestInput: z.ZodObject<{
155
+ export declare const DeclineMessageRequestInputSchema: z.ZodObject<{
156
156
  chatId: z.ZodCUID2;
157
157
  userId: z.ZodCUID2;
158
158
  }, z.core.$strip>;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DeclineMessageRequestInput = exports.AcceptMessageRequestInput = exports.GetMessageRequestsForUserOutputSchema = exports.GetChatsForUserOutputSchema = exports.GetChatsOutputSchema = exports.ChatIdSchema = exports.CreateChatOutputSchema = exports.CreateChatInputSchema = exports.ChatEntitySchema = exports.BaseChatEntitySchema = void 0;
3
+ exports.DeclineMessageRequestInputSchema = exports.AcceptMessageRequestInputSchema = exports.GetMessageRequestsForUserOutputSchema = exports.GetChatsForUserOutputSchema = exports.GetChatsOutputSchema = exports.ChatIdSchema = exports.CreateChatOutputSchema = exports.CreateChatInputSchema = exports.ChatEntitySchema = exports.BaseChatEntitySchema = void 0;
4
4
  const zod_openapi_1 = require("@hono/zod-openapi");
5
5
  const constants_1 = require("../constants");
6
- // 1. DB Representation (What is actually in Postgres)
7
6
  exports.BaseChatEntitySchema = zod_openapi_1.z.object({
8
7
  id: zod_openapi_1.z.cuid2(),
9
8
  senderId: zod_openapi_1.z.cuid2(),
@@ -16,19 +15,16 @@ exports.BaseChatEntitySchema = zod_openapi_1.z.object({
16
15
  updatedAt: zod_openapi_1.z.coerce.date().nullable(),
17
16
  deletedAt: zod_openapi_1.z.coerce.date().nullable(),
18
17
  });
19
- // 2. API Representation (Enriched with Redis/User data)
20
18
  exports.ChatEntitySchema = exports.BaseChatEntitySchema.extend({
21
- // User Details (Joined)
22
19
  senderName: zod_openapi_1.z.string(),
23
20
  senderUsername: zod_openapi_1.z.string(),
24
21
  senderImgUrl: zod_openapi_1.z.string().nullable(),
25
22
  receiverName: zod_openapi_1.z.string(),
26
23
  receiverUsername: zod_openapi_1.z.string(),
27
24
  receiverImgUrl: zod_openapi_1.z.string().nullable(),
28
- // Ephemeral/Cached Data
29
25
  lastMessageSent: zod_openapi_1.z.string().nullable(),
30
- lastMessageAt: zod_openapi_1.z.coerce.date().nullable(), // Important for UI sorting
31
- unreadCount: zod_openapi_1.z.number().int().default(0),
26
+ lastMessageAt: zod_openapi_1.z.coerce.date().nullable(),
27
+ isUnread: zod_openapi_1.z.number().int().default(0),
32
28
  isOnline: zod_openapi_1.z.boolean().default(false),
33
29
  });
34
30
  exports.CreateChatInputSchema = zod_openapi_1.z.object({
@@ -45,8 +41,8 @@ exports.GetChatsForUserOutputSchema = zod_openapi_1.z.object({
45
41
  nextCursor: zod_openapi_1.z.string().nullable(),
46
42
  });
47
43
  exports.GetMessageRequestsForUserOutputSchema = exports.GetChatsForUserOutputSchema;
48
- exports.AcceptMessageRequestInput = zod_openapi_1.z.object({
44
+ exports.AcceptMessageRequestInputSchema = zod_openapi_1.z.object({
49
45
  chatId: zod_openapi_1.z.cuid2(),
50
46
  userId: zod_openapi_1.z.cuid2(),
51
47
  });
52
- exports.DeclineMessageRequestInput = exports.AcceptMessageRequestInput;
48
+ exports.DeclineMessageRequestInputSchema = exports.AcceptMessageRequestInputSchema;
@@ -1,4 +1,10 @@
1
1
  import { z } from "@hono/zod-openapi";
2
+ export declare const LinkMetaSchema: z.ZodObject<{
3
+ url: z.ZodURL;
4
+ title: z.ZodOptional<z.ZodString>;
5
+ description: z.ZodOptional<z.ZodString>;
6
+ image: z.ZodOptional<z.ZodURL>;
7
+ }, z.core.$strip>;
2
8
  export declare const MessageEntitySchema: z.ZodObject<{
3
9
  id: z.ZodCUID2;
4
10
  chatId: z.ZodCUID2;
@@ -181,46 +187,9 @@ export declare const GetMessagesOutputSchema: z.ZodObject<{
181
187
  }, z.core.$strip>>;
182
188
  nextCursor: z.ZodNullable<z.ZodString>;
183
189
  }, z.core.$strip>;
184
- export declare const CreateMessageOutputSchema: z.ZodObject<{
185
- id: z.ZodCUID2;
190
+ export declare const MessageIdSchema: z.ZodObject<{
191
+ messageId: z.ZodCUID2;
192
+ }, z.core.$strip>;
193
+ export declare const ChatIdParamSchema: z.ZodObject<{
186
194
  chatId: z.ZodCUID2;
187
- senderId: z.ZodCUID2;
188
- receiverId: z.ZodCUID2;
189
- content: z.ZodDefault<z.ZodOptional<z.ZodString>>;
190
- messageType: z.ZodDefault<z.ZodEnum<{
191
- readonly MARKETPLACE: "MARKETPLACE";
192
- readonly PROJECT: "PROJECT";
193
- readonly JOB_OPENING: "JOB_OPENING";
194
- readonly DEFAULT_MESSAGE: "DEFAULT_MESSAGE";
195
- readonly MESSAGE_WITH_LINKS: "MESSAGE_WITH_LINKS";
196
- readonly MESSAGE_WITH_MEDIA: "MESSAGE_WITH_MEDIA";
197
- readonly MESSAGE_WITH_MEDIA_AND_LINKS: "MESSAGE_WITH_MEDIA_AND_LINKS";
198
- }>>;
199
- parentId: z.ZodOptional<z.ZodCUID2>;
200
- parentType: z.ZodOptional<z.ZodEnum<{
201
- readonly PROJECT: "PROJECT";
202
- readonly USER: "USER";
203
- readonly JOB: "JOB";
204
- readonly POST: "POST";
205
- readonly COMMENT: "COMMENT";
206
- readonly JOB_APPLICATION: "JOB_APPLICATION";
207
- }>>;
208
- replyToMessageId: z.ZodOptional<z.ZodCUID2>;
209
- replyToContent: z.ZodOptional<z.ZodString>;
210
- replyToImages: z.ZodOptional<z.ZodArray<z.ZodURL>>;
211
- replyToLinkMeta: z.ZodOptional<z.ZodObject<{
212
- url: z.ZodURL;
213
- title: z.ZodOptional<z.ZodString>;
214
- description: z.ZodOptional<z.ZodString>;
215
- image: z.ZodOptional<z.ZodURL>;
216
- }, z.core.$strip>>;
217
- linkMeta: z.ZodOptional<z.ZodObject<{
218
- url: z.ZodURL;
219
- title: z.ZodOptional<z.ZodString>;
220
- description: z.ZodOptional<z.ZodString>;
221
- image: z.ZodOptional<z.ZodURL>;
222
- }, z.core.$strip>>;
223
- createdAt: z.ZodCoercedDate<unknown>;
224
- updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
225
- deletedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
226
195
  }, z.core.$strip>;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CreateMessageOutputSchema = exports.GetMessagesOutputSchema = exports.CreateMessageInputSchema = exports.MessageWithFilesEntitySchema = exports.MessageFileEntitySchema = exports.MessageEntitySchema = void 0;
3
+ exports.ChatIdParamSchema = exports.MessageIdSchema = exports.GetMessagesOutputSchema = exports.CreateMessageInputSchema = exports.MessageWithFilesEntitySchema = exports.MessageFileEntitySchema = exports.MessageEntitySchema = exports.LinkMetaSchema = void 0;
4
4
  const zod_openapi_1 = require("@hono/zod-openapi");
5
5
  const constants_1 = require("../constants");
6
6
  const file_1 = require("./file");
7
7
  // 1. Base primitives
8
- const LinkMetaSchema = zod_openapi_1.z.object({
8
+ exports.LinkMetaSchema = zod_openapi_1.z.object({
9
9
  url: zod_openapi_1.z.url(),
10
10
  title: zod_openapi_1.z.string().optional(),
11
11
  description: zod_openapi_1.z.string().optional(),
@@ -21,15 +21,15 @@ exports.MessageEntitySchema = zod_openapi_1.z.object({
21
21
  content: zod_openapi_1.z.string().optional().default(""),
22
22
  messageType: zod_openapi_1.z.enum(constants_1.MESSAGE_TYPES).default("DEFAULT_MESSAGE"),
23
23
  // Parent/Threading
24
- parentId: zod_openapi_1.z.cuid2().optional(), // For threads/comments
24
+ parentId: zod_openapi_1.z.cuid2().optional(),
25
25
  parentType: zod_openapi_1.z.enum(constants_1.ACTIVITY_PARENT_TYPES).optional(),
26
- // Reply Context (Flattened for UI convenience)
26
+ // Reply Context
27
27
  replyToMessageId: zod_openapi_1.z.cuid2().optional(),
28
28
  replyToContent: zod_openapi_1.z.string().optional(),
29
29
  replyToImages: zod_openapi_1.z.array(zod_openapi_1.z.url()).optional(),
30
- replyToLinkMeta: LinkMetaSchema.optional(),
30
+ replyToLinkMeta: exports.LinkMetaSchema.optional(),
31
31
  // Metadata
32
- linkMeta: LinkMetaSchema.optional(),
32
+ linkMeta: exports.LinkMetaSchema.optional(),
33
33
  createdAt: zod_openapi_1.z.coerce.date(),
34
34
  updatedAt: zod_openapi_1.z.coerce.date().optional(),
35
35
  deletedAt: zod_openapi_1.z.coerce.date().optional(),
@@ -46,7 +46,7 @@ exports.MessageWithFilesEntitySchema = exports.MessageEntitySchema.extend({
46
46
  });
47
47
  // 3. Inputs
48
48
  exports.CreateMessageInputSchema = zod_openapi_1.z.object({
49
- id: zod_openapi_1.z.cuid2(), // Frontend generates ID for optimistic updates
49
+ id: zod_openapi_1.z.cuid2(),
50
50
  chatId: zod_openapi_1.z.cuid2(),
51
51
  senderId: zod_openapi_1.z.cuid2(),
52
52
  receiverId: zod_openapi_1.z.cuid2(),
@@ -54,7 +54,7 @@ exports.CreateMessageInputSchema = zod_openapi_1.z.object({
54
54
  messageType: zod_openapi_1.z.enum(constants_1.MESSAGE_TYPES).default("DEFAULT_MESSAGE"),
55
55
  parentId: zod_openapi_1.z.cuid2().optional(),
56
56
  replyToMessageId: zod_openapi_1.z.cuid2().optional(),
57
- linkMeta: LinkMetaSchema.optional(),
57
+ linkMeta: exports.LinkMetaSchema.optional(),
58
58
  files: zod_openapi_1.z
59
59
  .array(file_1.CreateFileInputSchema.extend({ order: zod_openapi_1.z.number().int() }))
60
60
  .optional(),
@@ -63,4 +63,9 @@ exports.GetMessagesOutputSchema = zod_openapi_1.z.object({
63
63
  messages: zod_openapi_1.z.array(exports.MessageWithFilesEntitySchema),
64
64
  nextCursor: zod_openapi_1.z.string().nullable(),
65
65
  });
66
- exports.CreateMessageOutputSchema = exports.MessageEntitySchema;
66
+ exports.MessageIdSchema = zod_openapi_1.z.object({
67
+ messageId: zod_openapi_1.z.cuid2(),
68
+ });
69
+ exports.ChatIdParamSchema = zod_openapi_1.z.object({
70
+ chatId: zod_openapi_1.z.cuid2(),
71
+ });
@@ -1,8 +1,11 @@
1
1
  import z from "zod";
2
- import { BaseChatEntitySchema, ChatEntitySchema, ChatIdSchema, CreateChatInputSchema, CreateChatOutputSchema, GetChatsOutputSchema } from "../schemas/chat";
2
+ import { AcceptMessageRequestInputSchema, BaseChatEntitySchema, ChatEntitySchema, ChatIdSchema, CreateChatInputSchema, CreateChatOutputSchema, GetChatsForUserOutputSchema, GetChatsOutputSchema } from "../schemas/chat";
3
3
  export type BaseChatEntity = z.infer<typeof BaseChatEntitySchema>;
4
4
  export type ChatEntity = z.infer<typeof ChatEntitySchema>;
5
5
  export type CreateChatInput = z.infer<typeof CreateChatInputSchema>;
6
6
  export type CreateChatOutput = z.infer<typeof CreateChatOutputSchema>;
7
7
  export type ChatIdInput = z.infer<typeof ChatIdSchema>;
8
8
  export type GetChatsOutput = z.infer<typeof GetChatsOutputSchema>;
9
+ export type GetChatsForUserOutput = z.infer<typeof GetChatsForUserOutputSchema>;
10
+ export type AcceptMessageRequestInput = z.infer<typeof AcceptMessageRequestInputSchema>;
11
+ export type DeclineMessageRequestInput = AcceptMessageRequestInput;
@@ -1,8 +1,7 @@
1
1
  import z from "zod";
2
- import { CreateMessageInputSchema, CreateMessageOutputSchema, GetMessagesOutputSchema, MessageEntitySchema, MessageFileEntitySchema, MessageWithFilesEntitySchema } from "../schemas/message";
2
+ import { CreateMessageInputSchema, GetMessagesOutputSchema, MessageEntitySchema, MessageFileEntitySchema, MessageWithFilesEntitySchema } from "../schemas/message";
3
3
  export type MessageEntity = z.infer<typeof MessageEntitySchema>;
4
4
  export type MessageFileEntity = z.infer<typeof MessageFileEntitySchema>;
5
5
  export type MessageWithFilesEntity = z.infer<typeof MessageWithFilesEntitySchema>;
6
6
  export type CreateMessageInput = z.infer<typeof CreateMessageInputSchema>;
7
- export type CreateMessageOutput = z.infer<typeof CreateMessageOutputSchema>;
8
7
  export type GetMessagesOutput = z.infer<typeof GetMessagesOutputSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyacreatives/shared",
3
- "version": "2.2.36",
3
+ "version": "2.2.38",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,7 +1,6 @@
1
1
  import { z } from "@hono/zod-openapi";
2
2
  import { MESSAGE_REQUEST_STATUS } from "../constants";
3
3
 
4
- // 1. DB Representation (What is actually in Postgres)
5
4
  export const BaseChatEntitySchema = z.object({
6
5
  id: z.cuid2(),
7
6
  senderId: z.cuid2(),
@@ -15,9 +14,7 @@ export const BaseChatEntitySchema = z.object({
15
14
  deletedAt: z.coerce.date().nullable(),
16
15
  });
17
16
 
18
- // 2. API Representation (Enriched with Redis/User data)
19
17
  export const ChatEntitySchema = BaseChatEntitySchema.extend({
20
- // User Details (Joined)
21
18
  senderName: z.string(),
22
19
  senderUsername: z.string(),
23
20
  senderImgUrl: z.string().nullable(),
@@ -26,10 +23,9 @@ export const ChatEntitySchema = BaseChatEntitySchema.extend({
26
23
  receiverUsername: z.string(),
27
24
  receiverImgUrl: z.string().nullable(),
28
25
 
29
- // Ephemeral/Cached Data
30
26
  lastMessageSent: z.string().nullable(),
31
- lastMessageAt: z.coerce.date().nullable(), // Important for UI sorting
32
- unreadCount: z.number().int().default(0),
27
+ lastMessageAt: z.coerce.date().nullable(),
28
+ isUnread: z.number().int().default(0),
33
29
  isOnline: z.boolean().default(false),
34
30
  });
35
31
 
@@ -54,9 +50,9 @@ export const GetChatsForUserOutputSchema = z.object({
54
50
  export const GetMessageRequestsForUserOutputSchema =
55
51
  GetChatsForUserOutputSchema;
56
52
 
57
- export const AcceptMessageRequestInput = z.object({
53
+ export const AcceptMessageRequestInputSchema = z.object({
58
54
  chatId: z.cuid2(),
59
55
  userId: z.cuid2(),
60
56
  });
61
57
 
62
- export const DeclineMessageRequestInput = AcceptMessageRequestInput;
58
+ export const DeclineMessageRequestInputSchema = AcceptMessageRequestInputSchema;
@@ -3,7 +3,7 @@ import { ACTIVITY_PARENT_TYPES, MESSAGE_TYPES } from "../constants";
3
3
  import { CreateFileInputSchema } from "./file";
4
4
 
5
5
  // 1. Base primitives
6
- const LinkMetaSchema = z.object({
6
+ export const LinkMetaSchema = z.object({
7
7
  url: z.url(),
8
8
  title: z.string().optional(),
9
9
  description: z.string().optional(),
@@ -16,16 +16,16 @@ export const MessageEntitySchema = z.object({
16
16
  chatId: z.cuid2(),
17
17
  senderId: z.cuid2(),
18
18
  receiverId: z.cuid2(),
19
-
19
+
20
20
  // Content & Type
21
21
  content: z.string().optional().default(""),
22
22
  messageType: z.enum(MESSAGE_TYPES).default("DEFAULT_MESSAGE"),
23
23
 
24
24
  // Parent/Threading
25
- parentId: z.cuid2().optional(), // For threads/comments
25
+ parentId: z.cuid2().optional(),
26
26
  parentType: z.enum(ACTIVITY_PARENT_TYPES).optional(),
27
27
 
28
- // Reply Context (Flattened for UI convenience)
28
+ // Reply Context
29
29
  replyToMessageId: z.cuid2().optional(),
30
30
  replyToContent: z.string().optional(),
31
31
  replyToImages: z.array(z.url()).optional(),
@@ -52,7 +52,7 @@ export const MessageWithFilesEntitySchema = MessageEntitySchema.extend({
52
52
 
53
53
  // 3. Inputs
54
54
  export const CreateMessageInputSchema = z.object({
55
- id: z.cuid2(), // Frontend generates ID for optimistic updates
55
+ id: z.cuid2(),
56
56
  chatId: z.cuid2(),
57
57
  senderId: z.cuid2(),
58
58
  receiverId: z.cuid2(),
@@ -74,4 +74,10 @@ export const GetMessagesOutputSchema = z.object({
74
74
  nextCursor: z.string().nullable(),
75
75
  });
76
76
 
77
- export const CreateMessageOutputSchema = MessageEntitySchema;
77
+ export const MessageIdSchema = z.object({
78
+ messageId: z.cuid2(),
79
+ });
80
+
81
+ export const ChatIdParamSchema = z.object({
82
+ chatId: z.cuid2(),
83
+ });
package/src/types/chat.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import z from "zod";
2
2
  import {
3
+ AcceptMessageRequestInputSchema,
3
4
  BaseChatEntitySchema,
4
5
  ChatEntitySchema,
5
6
  ChatIdSchema,
6
7
  CreateChatInputSchema,
7
8
  CreateChatOutputSchema,
9
+ GetChatsForUserOutputSchema,
8
10
  GetChatsOutputSchema,
9
11
  } from "../schemas/chat";
10
12
 
@@ -19,3 +21,11 @@ export type CreateChatOutput = z.infer<typeof CreateChatOutputSchema>;
19
21
  export type ChatIdInput = z.infer<typeof ChatIdSchema>;
20
22
 
21
23
  export type GetChatsOutput = z.infer<typeof GetChatsOutputSchema>;
24
+
25
+ export type GetChatsForUserOutput = z.infer<typeof GetChatsForUserOutputSchema>;
26
+
27
+ export type AcceptMessageRequestInput = z.infer<
28
+ typeof AcceptMessageRequestInputSchema
29
+ >;
30
+
31
+ export type DeclineMessageRequestInput = AcceptMessageRequestInput;
@@ -1,7 +1,6 @@
1
1
  import z from "zod";
2
2
  import {
3
3
  CreateMessageInputSchema,
4
- CreateMessageOutputSchema,
5
4
  GetMessagesOutputSchema,
6
5
  MessageEntitySchema,
7
6
  MessageFileEntitySchema,
@@ -18,6 +17,4 @@ export type MessageWithFilesEntity = z.infer<
18
17
 
19
18
  export type CreateMessageInput = z.infer<typeof CreateMessageInputSchema>;
20
19
 
21
- export type CreateMessageOutput = z.infer<typeof CreateMessageOutputSchema>;
22
-
23
20
  export type GetMessagesOutput = z.infer<typeof GetMessagesOutputSchema>;