@zyacreatives/shared 2.2.31 → 2.2.32
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/schemas/chat.d.ts +22 -20
- package/dist/schemas/chat.js +12 -7
- package/package.json +1 -1
- package/src/schemas/chat.ts +14 -7
package/dist/schemas/chat.d.ts
CHANGED
|
@@ -9,11 +9,11 @@ export declare const BaseChatEntitySchema: z.ZodObject<{
|
|
|
9
9
|
readonly ACCEPTED: "ACCEPTED";
|
|
10
10
|
readonly DECLINED: "DECLINED";
|
|
11
11
|
}>>;
|
|
12
|
-
acceptedAt: z.ZodCoercedDate<unknown
|
|
13
|
-
declinedAt: z.ZodCoercedDate<unknown
|
|
12
|
+
acceptedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
13
|
+
declinedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
14
14
|
createdAt: z.ZodCoercedDate<unknown>;
|
|
15
15
|
updatedAt: z.ZodCoercedDate<unknown>;
|
|
16
|
-
deletedAt: z.ZodCoercedDate<unknown
|
|
16
|
+
deletedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
17
17
|
}, z.core.$strip>;
|
|
18
18
|
export declare const ChatEntitySchema: z.ZodObject<{
|
|
19
19
|
id: z.ZodCUID2;
|
|
@@ -25,20 +25,21 @@ export declare const ChatEntitySchema: z.ZodObject<{
|
|
|
25
25
|
readonly ACCEPTED: "ACCEPTED";
|
|
26
26
|
readonly DECLINED: "DECLINED";
|
|
27
27
|
}>>;
|
|
28
|
-
acceptedAt: z.ZodCoercedDate<unknown
|
|
29
|
-
declinedAt: z.ZodCoercedDate<unknown
|
|
28
|
+
acceptedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
29
|
+
declinedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
30
30
|
createdAt: z.ZodCoercedDate<unknown>;
|
|
31
31
|
updatedAt: z.ZodCoercedDate<unknown>;
|
|
32
|
-
deletedAt: z.ZodCoercedDate<unknown
|
|
33
|
-
senderImgUrl: z.ZodOptional<z.ZodString>;
|
|
32
|
+
deletedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
34
33
|
senderName: z.ZodString;
|
|
35
34
|
senderUsername: z.ZodString;
|
|
35
|
+
senderImgUrl: z.ZodOptional<z.ZodString>;
|
|
36
|
+
receiverName: z.ZodString;
|
|
36
37
|
receiverUsername: z.ZodString;
|
|
37
38
|
receiverImgUrl: z.ZodOptional<z.ZodString>;
|
|
38
|
-
receiverName: z.ZodString;
|
|
39
39
|
lastMessageSent: z.ZodOptional<z.ZodString>;
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
lastMessageAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
41
|
+
unreadCount: z.ZodDefault<z.ZodNumber>;
|
|
42
|
+
isOnline: z.ZodDefault<z.ZodBoolean>;
|
|
42
43
|
}, z.core.$strip>;
|
|
43
44
|
export declare const CreateChatInputSchema: z.ZodObject<{
|
|
44
45
|
senderId: z.ZodCUID2;
|
|
@@ -54,11 +55,11 @@ export declare const CreateChatOutputSchema: z.ZodObject<{
|
|
|
54
55
|
readonly ACCEPTED: "ACCEPTED";
|
|
55
56
|
readonly DECLINED: "DECLINED";
|
|
56
57
|
}>>;
|
|
57
|
-
acceptedAt: z.ZodCoercedDate<unknown
|
|
58
|
-
declinedAt: z.ZodCoercedDate<unknown
|
|
58
|
+
acceptedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
59
|
+
declinedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
59
60
|
createdAt: z.ZodCoercedDate<unknown>;
|
|
60
61
|
updatedAt: z.ZodCoercedDate<unknown>;
|
|
61
|
-
deletedAt: z.ZodCoercedDate<unknown
|
|
62
|
+
deletedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
62
63
|
}, z.core.$strip>;
|
|
63
64
|
export declare const ChatIdSchema: z.ZodObject<{
|
|
64
65
|
chatId: z.ZodCUID2;
|
|
@@ -73,18 +74,19 @@ export declare const GetChatsOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
73
74
|
readonly ACCEPTED: "ACCEPTED";
|
|
74
75
|
readonly DECLINED: "DECLINED";
|
|
75
76
|
}>>;
|
|
76
|
-
acceptedAt: z.ZodCoercedDate<unknown
|
|
77
|
-
declinedAt: z.ZodCoercedDate<unknown
|
|
77
|
+
acceptedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
78
|
+
declinedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
78
79
|
createdAt: z.ZodCoercedDate<unknown>;
|
|
79
80
|
updatedAt: z.ZodCoercedDate<unknown>;
|
|
80
|
-
deletedAt: z.ZodCoercedDate<unknown
|
|
81
|
-
senderImgUrl: z.ZodOptional<z.ZodString>;
|
|
81
|
+
deletedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
82
82
|
senderName: z.ZodString;
|
|
83
83
|
senderUsername: z.ZodString;
|
|
84
|
+
senderImgUrl: z.ZodOptional<z.ZodString>;
|
|
85
|
+
receiverName: z.ZodString;
|
|
84
86
|
receiverUsername: z.ZodString;
|
|
85
87
|
receiverImgUrl: z.ZodOptional<z.ZodString>;
|
|
86
|
-
receiverName: z.ZodString;
|
|
87
88
|
lastMessageSent: z.ZodOptional<z.ZodString>;
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
lastMessageAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
90
|
+
unreadCount: z.ZodDefault<z.ZodNumber>;
|
|
91
|
+
isOnline: z.ZodDefault<z.ZodBoolean>;
|
|
90
92
|
}, z.core.$strip>>;
|
package/dist/schemas/chat.js
CHANGED
|
@@ -3,28 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
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)
|
|
6
7
|
exports.BaseChatEntitySchema = zod_openapi_1.z.object({
|
|
7
8
|
id: zod_openapi_1.z.cuid2(),
|
|
8
9
|
senderId: zod_openapi_1.z.cuid2(),
|
|
9
10
|
receiverId: zod_openapi_1.z.cuid2(),
|
|
10
11
|
isMessageRequest: zod_openapi_1.z.boolean().default(true),
|
|
11
12
|
messageRequestStatus: zod_openapi_1.z.enum(constants_1.MESSAGE_REQUEST_STATUS).default("PENDING"),
|
|
12
|
-
acceptedAt: zod_openapi_1.z.coerce.date(),
|
|
13
|
-
declinedAt: zod_openapi_1.z.coerce.date(),
|
|
13
|
+
acceptedAt: zod_openapi_1.z.coerce.date().nullable(),
|
|
14
|
+
declinedAt: zod_openapi_1.z.coerce.date().nullable(),
|
|
14
15
|
createdAt: zod_openapi_1.z.coerce.date(),
|
|
15
16
|
updatedAt: zod_openapi_1.z.coerce.date(),
|
|
16
|
-
deletedAt: zod_openapi_1.z.coerce.date(),
|
|
17
|
+
deletedAt: zod_openapi_1.z.coerce.date().nullable(),
|
|
17
18
|
});
|
|
19
|
+
// 2. API Representation (Enriched with Redis/User data)
|
|
18
20
|
exports.ChatEntitySchema = exports.BaseChatEntitySchema.extend({
|
|
19
|
-
|
|
21
|
+
// User Details (Joined)
|
|
20
22
|
senderName: zod_openapi_1.z.string(),
|
|
21
23
|
senderUsername: zod_openapi_1.z.string(),
|
|
24
|
+
senderImgUrl: zod_openapi_1.z.string().optional(),
|
|
25
|
+
receiverName: zod_openapi_1.z.string(),
|
|
22
26
|
receiverUsername: zod_openapi_1.z.string(),
|
|
23
27
|
receiverImgUrl: zod_openapi_1.z.string().optional(),
|
|
24
|
-
|
|
28
|
+
// Ephemeral/Cached Data
|
|
25
29
|
lastMessageSent: zod_openapi_1.z.string().optional(),
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
lastMessageAt: zod_openapi_1.z.coerce.date().optional(), // Important for UI sorting
|
|
31
|
+
unreadCount: zod_openapi_1.z.number().int().default(0),
|
|
32
|
+
isOnline: zod_openapi_1.z.boolean().default(false),
|
|
28
33
|
});
|
|
29
34
|
exports.CreateChatInputSchema = zod_openapi_1.z.object({
|
|
30
35
|
senderId: zod_openapi_1.z.cuid2(),
|
package/package.json
CHANGED
package/src/schemas/chat.ts
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
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)
|
|
4
5
|
export const BaseChatEntitySchema = z.object({
|
|
5
6
|
id: z.cuid2(),
|
|
6
7
|
senderId: z.cuid2(),
|
|
7
8
|
receiverId: z.cuid2(),
|
|
8
9
|
isMessageRequest: z.boolean().default(true),
|
|
9
10
|
messageRequestStatus: z.enum(MESSAGE_REQUEST_STATUS).default("PENDING"),
|
|
10
|
-
acceptedAt: z.coerce.date(),
|
|
11
|
-
declinedAt: z.coerce.date(),
|
|
11
|
+
acceptedAt: z.coerce.date().nullable(),
|
|
12
|
+
declinedAt: z.coerce.date().nullable(),
|
|
12
13
|
createdAt: z.coerce.date(),
|
|
13
14
|
updatedAt: z.coerce.date(),
|
|
14
|
-
deletedAt: z.coerce.date(),
|
|
15
|
+
deletedAt: z.coerce.date().nullable(),
|
|
15
16
|
});
|
|
16
17
|
|
|
18
|
+
// 2. API Representation (Enriched with Redis/User data)
|
|
17
19
|
export const ChatEntitySchema = BaseChatEntitySchema.extend({
|
|
18
|
-
|
|
20
|
+
// User Details (Joined)
|
|
19
21
|
senderName: z.string(),
|
|
20
22
|
senderUsername: z.string(),
|
|
23
|
+
senderImgUrl: z.string().optional(),
|
|
24
|
+
|
|
25
|
+
receiverName: z.string(),
|
|
21
26
|
receiverUsername: z.string(),
|
|
22
27
|
receiverImgUrl: z.string().optional(),
|
|
23
|
-
|
|
28
|
+
|
|
29
|
+
// Ephemeral/Cached Data
|
|
24
30
|
lastMessageSent: z.string().optional(),
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
lastMessageAt: z.coerce.date().optional(), // Important for UI sorting
|
|
32
|
+
unreadCount: z.number().int().default(0),
|
|
33
|
+
isOnline: z.boolean().default(false),
|
|
27
34
|
});
|
|
28
35
|
|
|
29
36
|
export const CreateChatInputSchema = z.object({
|