@zyacreatives/shared 2.2.30 → 2.2.31
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/message.d.ts +122 -78
- package/dist/schemas/message.js +42 -89
- package/package.json +1 -1
- package/src/schemas/message.ts +51 -93
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { z } from "@hono/zod-openapi";
|
|
2
2
|
export declare const MessageEntitySchema: z.ZodObject<{
|
|
3
3
|
id: z.ZodCUID2;
|
|
4
|
+
chatId: z.ZodCUID2;
|
|
5
|
+
senderId: z.ZodCUID2;
|
|
6
|
+
content: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
7
|
+
messageType: z.ZodDefault<z.ZodEnum<{
|
|
8
|
+
readonly MARKETPLACE: "MARKETPLACE";
|
|
9
|
+
readonly PROJECT: "PROJECT";
|
|
10
|
+
readonly JOB_OPENING: "JOB_OPENING";
|
|
11
|
+
readonly DEFAULT_MESSAGE: "DEFAULT_MESSAGE";
|
|
12
|
+
readonly MESSAGE_WITH_LINKS: "MESSAGE_WITH_LINKS";
|
|
13
|
+
readonly MESSAGE_WITH_MEDIA: "MESSAGE_WITH_MEDIA";
|
|
14
|
+
readonly MESSAGE_WITH_MEDIA_AND_LINKS: "MESSAGE_WITH_MEDIA_AND_LINKS";
|
|
15
|
+
}>>;
|
|
4
16
|
parentId: z.ZodOptional<z.ZodCUID2>;
|
|
5
17
|
parentType: z.ZodOptional<z.ZodEnum<{
|
|
6
18
|
readonly PROJECT: "PROJECT";
|
|
@@ -11,45 +23,45 @@ export declare const MessageEntitySchema: z.ZodObject<{
|
|
|
11
23
|
readonly JOB_APPLICATION: "JOB_APPLICATION";
|
|
12
24
|
}>>;
|
|
13
25
|
replyToMessageId: z.ZodOptional<z.ZodCUID2>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
linkMeta: z.ZodOptional<z.ZodObject<{
|
|
26
|
+
replyToContent: z.ZodOptional<z.ZodString>;
|
|
27
|
+
replyToImages: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
28
|
+
replyToLinkMeta: z.ZodOptional<z.ZodObject<{
|
|
18
29
|
url: z.ZodURL;
|
|
19
30
|
title: z.ZodOptional<z.ZodString>;
|
|
20
31
|
description: z.ZodOptional<z.ZodString>;
|
|
21
32
|
image: z.ZodOptional<z.ZodURL>;
|
|
22
33
|
}, z.core.$strip>>;
|
|
23
|
-
|
|
24
|
-
messageType: z.ZodDefault<z.ZodEnum<{
|
|
25
|
-
readonly MARKETPLACE: "MARKETPLACE";
|
|
26
|
-
readonly PROJECT: "PROJECT";
|
|
27
|
-
readonly JOB_OPENING: "JOB_OPENING";
|
|
28
|
-
readonly DEFAULT_MESSAGE: "DEFAULT_MESSAGE";
|
|
29
|
-
readonly MESSAGE_WITH_LINKS: "MESSAGE_WITH_LINKS";
|
|
30
|
-
readonly MESSAGE_WITH_MEDIA: "MESSAGE_WITH_MEDIA";
|
|
31
|
-
readonly MESSAGE_WITH_MEDIA_AND_LINKS: "MESSAGE_WITH_MEDIA_AND_LINKS";
|
|
32
|
-
}>>;
|
|
33
|
-
replyToContent: z.ZodOptional<z.ZodString>;
|
|
34
|
-
replyToImages: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
35
|
-
replyToLinkMeta: z.ZodOptional<z.ZodObject<{
|
|
34
|
+
linkMeta: z.ZodOptional<z.ZodObject<{
|
|
36
35
|
url: z.ZodURL;
|
|
37
36
|
title: z.ZodOptional<z.ZodString>;
|
|
38
37
|
description: z.ZodOptional<z.ZodString>;
|
|
39
38
|
image: z.ZodOptional<z.ZodURL>;
|
|
40
39
|
}, z.core.$strip>>;
|
|
41
|
-
createdAt: z.
|
|
40
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
42
41
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
43
42
|
deletedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
44
43
|
}, z.core.$strip>;
|
|
45
44
|
export declare const MessageFileEntitySchema: z.ZodObject<{
|
|
46
|
-
id: z.
|
|
47
|
-
messageId: z.
|
|
48
|
-
fileId: z.
|
|
49
|
-
|
|
45
|
+
id: z.ZodCUID2;
|
|
46
|
+
messageId: z.ZodCUID2;
|
|
47
|
+
fileId: z.ZodCUID2;
|
|
48
|
+
url: z.ZodURL;
|
|
49
|
+
order: z.ZodDefault<z.ZodNumber>;
|
|
50
50
|
}, z.core.$strip>;
|
|
51
51
|
export declare const MessageWithFilesEntitySchema: z.ZodObject<{
|
|
52
52
|
id: z.ZodCUID2;
|
|
53
|
+
chatId: z.ZodCUID2;
|
|
54
|
+
senderId: z.ZodCUID2;
|
|
55
|
+
content: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
56
|
+
messageType: z.ZodDefault<z.ZodEnum<{
|
|
57
|
+
readonly MARKETPLACE: "MARKETPLACE";
|
|
58
|
+
readonly PROJECT: "PROJECT";
|
|
59
|
+
readonly JOB_OPENING: "JOB_OPENING";
|
|
60
|
+
readonly DEFAULT_MESSAGE: "DEFAULT_MESSAGE";
|
|
61
|
+
readonly MESSAGE_WITH_LINKS: "MESSAGE_WITH_LINKS";
|
|
62
|
+
readonly MESSAGE_WITH_MEDIA: "MESSAGE_WITH_MEDIA";
|
|
63
|
+
readonly MESSAGE_WITH_MEDIA_AND_LINKS: "MESSAGE_WITH_MEDIA_AND_LINKS";
|
|
64
|
+
}>>;
|
|
53
65
|
parentId: z.ZodOptional<z.ZodCUID2>;
|
|
54
66
|
parentType: z.ZodOptional<z.ZodEnum<{
|
|
55
67
|
readonly PROJECT: "PROJECT";
|
|
@@ -60,47 +72,36 @@ export declare const MessageWithFilesEntitySchema: z.ZodObject<{
|
|
|
60
72
|
readonly JOB_APPLICATION: "JOB_APPLICATION";
|
|
61
73
|
}>>;
|
|
62
74
|
replyToMessageId: z.ZodOptional<z.ZodCUID2>;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
linkMeta: z.ZodOptional<z.ZodObject<{
|
|
75
|
+
replyToContent: z.ZodOptional<z.ZodString>;
|
|
76
|
+
replyToImages: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
77
|
+
replyToLinkMeta: z.ZodOptional<z.ZodObject<{
|
|
67
78
|
url: z.ZodURL;
|
|
68
79
|
title: z.ZodOptional<z.ZodString>;
|
|
69
80
|
description: z.ZodOptional<z.ZodString>;
|
|
70
81
|
image: z.ZodOptional<z.ZodURL>;
|
|
71
82
|
}, z.core.$strip>>;
|
|
72
|
-
|
|
73
|
-
messageType: z.ZodDefault<z.ZodEnum<{
|
|
74
|
-
readonly MARKETPLACE: "MARKETPLACE";
|
|
75
|
-
readonly PROJECT: "PROJECT";
|
|
76
|
-
readonly JOB_OPENING: "JOB_OPENING";
|
|
77
|
-
readonly DEFAULT_MESSAGE: "DEFAULT_MESSAGE";
|
|
78
|
-
readonly MESSAGE_WITH_LINKS: "MESSAGE_WITH_LINKS";
|
|
79
|
-
readonly MESSAGE_WITH_MEDIA: "MESSAGE_WITH_MEDIA";
|
|
80
|
-
readonly MESSAGE_WITH_MEDIA_AND_LINKS: "MESSAGE_WITH_MEDIA_AND_LINKS";
|
|
81
|
-
}>>;
|
|
82
|
-
replyToContent: z.ZodOptional<z.ZodString>;
|
|
83
|
-
replyToImages: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
84
|
-
replyToLinkMeta: z.ZodOptional<z.ZodObject<{
|
|
83
|
+
linkMeta: z.ZodOptional<z.ZodObject<{
|
|
85
84
|
url: z.ZodURL;
|
|
86
85
|
title: z.ZodOptional<z.ZodString>;
|
|
87
86
|
description: z.ZodOptional<z.ZodString>;
|
|
88
87
|
image: z.ZodOptional<z.ZodURL>;
|
|
89
88
|
}, z.core.$strip>>;
|
|
90
|
-
createdAt: z.
|
|
89
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
91
90
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
92
91
|
deletedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
93
|
-
messageFiles: z.
|
|
94
|
-
id: z.
|
|
95
|
-
messageId: z.
|
|
96
|
-
fileId: z.
|
|
97
|
-
order: z.ZodNumber;
|
|
92
|
+
messageFiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
93
|
+
id: z.ZodCUID2;
|
|
94
|
+
messageId: z.ZodCUID2;
|
|
95
|
+
fileId: z.ZodCUID2;
|
|
98
96
|
url: z.ZodURL;
|
|
97
|
+
order: z.ZodDefault<z.ZodNumber>;
|
|
99
98
|
}, z.core.$strip>>>;
|
|
100
99
|
}, z.core.$strip>;
|
|
101
100
|
export declare const CreateMessageInputSchema: z.ZodObject<{
|
|
102
101
|
id: z.ZodCUID2;
|
|
103
|
-
|
|
102
|
+
chatId: z.ZodCUID2;
|
|
103
|
+
senderId: z.ZodCUID2;
|
|
104
|
+
receiverId: z.ZodCUID2;
|
|
104
105
|
content: z.ZodOptional<z.ZodString>;
|
|
105
106
|
messageType: z.ZodDefault<z.ZodEnum<{
|
|
106
107
|
readonly MARKETPLACE: "MARKETPLACE";
|
|
@@ -111,14 +112,7 @@ export declare const CreateMessageInputSchema: z.ZodObject<{
|
|
|
111
112
|
readonly MESSAGE_WITH_MEDIA: "MESSAGE_WITH_MEDIA";
|
|
112
113
|
readonly MESSAGE_WITH_MEDIA_AND_LINKS: "MESSAGE_WITH_MEDIA_AND_LINKS";
|
|
113
114
|
}>>;
|
|
114
|
-
|
|
115
|
-
key: z.ZodString;
|
|
116
|
-
mimeType: z.ZodString;
|
|
117
|
-
order: z.ZodDefault<z.ZodInt>;
|
|
118
|
-
}, z.core.$strip>>>;
|
|
119
|
-
chatId: z.ZodString;
|
|
120
|
-
senderId: z.ZodString;
|
|
121
|
-
receiverId: z.ZodString;
|
|
115
|
+
parentId: z.ZodOptional<z.ZodCUID2>;
|
|
122
116
|
replyToMessageId: z.ZodOptional<z.ZodCUID2>;
|
|
123
117
|
linkMeta: z.ZodOptional<z.ZodObject<{
|
|
124
118
|
url: z.ZodURL;
|
|
@@ -126,9 +120,78 @@ export declare const CreateMessageInputSchema: z.ZodObject<{
|
|
|
126
120
|
description: z.ZodOptional<z.ZodString>;
|
|
127
121
|
image: z.ZodOptional<z.ZodURL>;
|
|
128
122
|
}, z.core.$strip>>;
|
|
123
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
124
|
+
key: z.ZodString;
|
|
125
|
+
mimeType: z.ZodString;
|
|
126
|
+
order: z.ZodNumber;
|
|
127
|
+
}, z.core.$strip>>>;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
export declare const GetMessagesOutputSchema: z.ZodObject<{
|
|
130
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
131
|
+
id: z.ZodCUID2;
|
|
132
|
+
chatId: z.ZodCUID2;
|
|
133
|
+
senderId: z.ZodCUID2;
|
|
134
|
+
content: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
135
|
+
messageType: z.ZodDefault<z.ZodEnum<{
|
|
136
|
+
readonly MARKETPLACE: "MARKETPLACE";
|
|
137
|
+
readonly PROJECT: "PROJECT";
|
|
138
|
+
readonly JOB_OPENING: "JOB_OPENING";
|
|
139
|
+
readonly DEFAULT_MESSAGE: "DEFAULT_MESSAGE";
|
|
140
|
+
readonly MESSAGE_WITH_LINKS: "MESSAGE_WITH_LINKS";
|
|
141
|
+
readonly MESSAGE_WITH_MEDIA: "MESSAGE_WITH_MEDIA";
|
|
142
|
+
readonly MESSAGE_WITH_MEDIA_AND_LINKS: "MESSAGE_WITH_MEDIA_AND_LINKS";
|
|
143
|
+
}>>;
|
|
144
|
+
parentId: z.ZodOptional<z.ZodCUID2>;
|
|
145
|
+
parentType: z.ZodOptional<z.ZodEnum<{
|
|
146
|
+
readonly PROJECT: "PROJECT";
|
|
147
|
+
readonly USER: "USER";
|
|
148
|
+
readonly JOB: "JOB";
|
|
149
|
+
readonly POST: "POST";
|
|
150
|
+
readonly COMMENT: "COMMENT";
|
|
151
|
+
readonly JOB_APPLICATION: "JOB_APPLICATION";
|
|
152
|
+
}>>;
|
|
153
|
+
replyToMessageId: z.ZodOptional<z.ZodCUID2>;
|
|
154
|
+
replyToContent: z.ZodOptional<z.ZodString>;
|
|
155
|
+
replyToImages: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
156
|
+
replyToLinkMeta: z.ZodOptional<z.ZodObject<{
|
|
157
|
+
url: z.ZodURL;
|
|
158
|
+
title: z.ZodOptional<z.ZodString>;
|
|
159
|
+
description: z.ZodOptional<z.ZodString>;
|
|
160
|
+
image: z.ZodOptional<z.ZodURL>;
|
|
161
|
+
}, z.core.$strip>>;
|
|
162
|
+
linkMeta: z.ZodOptional<z.ZodObject<{
|
|
163
|
+
url: z.ZodURL;
|
|
164
|
+
title: z.ZodOptional<z.ZodString>;
|
|
165
|
+
description: z.ZodOptional<z.ZodString>;
|
|
166
|
+
image: z.ZodOptional<z.ZodURL>;
|
|
167
|
+
}, z.core.$strip>>;
|
|
168
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
169
|
+
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
170
|
+
deletedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
171
|
+
messageFiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
172
|
+
id: z.ZodCUID2;
|
|
173
|
+
messageId: z.ZodCUID2;
|
|
174
|
+
fileId: z.ZodCUID2;
|
|
175
|
+
url: z.ZodURL;
|
|
176
|
+
order: z.ZodDefault<z.ZodNumber>;
|
|
177
|
+
}, z.core.$strip>>>;
|
|
178
|
+
}, z.core.$strip>>;
|
|
179
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
129
180
|
}, z.core.$strip>;
|
|
130
181
|
export declare const CreateMessageOutputSchema: z.ZodObject<{
|
|
131
182
|
id: z.ZodCUID2;
|
|
183
|
+
chatId: z.ZodCUID2;
|
|
184
|
+
senderId: z.ZodCUID2;
|
|
185
|
+
content: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
186
|
+
messageType: z.ZodDefault<z.ZodEnum<{
|
|
187
|
+
readonly MARKETPLACE: "MARKETPLACE";
|
|
188
|
+
readonly PROJECT: "PROJECT";
|
|
189
|
+
readonly JOB_OPENING: "JOB_OPENING";
|
|
190
|
+
readonly DEFAULT_MESSAGE: "DEFAULT_MESSAGE";
|
|
191
|
+
readonly MESSAGE_WITH_LINKS: "MESSAGE_WITH_LINKS";
|
|
192
|
+
readonly MESSAGE_WITH_MEDIA: "MESSAGE_WITH_MEDIA";
|
|
193
|
+
readonly MESSAGE_WITH_MEDIA_AND_LINKS: "MESSAGE_WITH_MEDIA_AND_LINKS";
|
|
194
|
+
}>>;
|
|
132
195
|
parentId: z.ZodOptional<z.ZodCUID2>;
|
|
133
196
|
parentType: z.ZodOptional<z.ZodEnum<{
|
|
134
197
|
readonly PROJECT: "PROJECT";
|
|
@@ -139,40 +202,21 @@ export declare const CreateMessageOutputSchema: z.ZodObject<{
|
|
|
139
202
|
readonly JOB_APPLICATION: "JOB_APPLICATION";
|
|
140
203
|
}>>;
|
|
141
204
|
replyToMessageId: z.ZodOptional<z.ZodCUID2>;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
linkMeta: z.ZodOptional<z.ZodObject<{
|
|
205
|
+
replyToContent: z.ZodOptional<z.ZodString>;
|
|
206
|
+
replyToImages: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
207
|
+
replyToLinkMeta: z.ZodOptional<z.ZodObject<{
|
|
146
208
|
url: z.ZodURL;
|
|
147
209
|
title: z.ZodOptional<z.ZodString>;
|
|
148
210
|
description: z.ZodOptional<z.ZodString>;
|
|
149
211
|
image: z.ZodOptional<z.ZodURL>;
|
|
150
212
|
}, z.core.$strip>>;
|
|
151
|
-
|
|
152
|
-
messageType: z.ZodDefault<z.ZodEnum<{
|
|
153
|
-
readonly MARKETPLACE: "MARKETPLACE";
|
|
154
|
-
readonly PROJECT: "PROJECT";
|
|
155
|
-
readonly JOB_OPENING: "JOB_OPENING";
|
|
156
|
-
readonly DEFAULT_MESSAGE: "DEFAULT_MESSAGE";
|
|
157
|
-
readonly MESSAGE_WITH_LINKS: "MESSAGE_WITH_LINKS";
|
|
158
|
-
readonly MESSAGE_WITH_MEDIA: "MESSAGE_WITH_MEDIA";
|
|
159
|
-
readonly MESSAGE_WITH_MEDIA_AND_LINKS: "MESSAGE_WITH_MEDIA_AND_LINKS";
|
|
160
|
-
}>>;
|
|
161
|
-
replyToContent: z.ZodOptional<z.ZodString>;
|
|
162
|
-
replyToImages: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
163
|
-
replyToLinkMeta: z.ZodOptional<z.ZodObject<{
|
|
213
|
+
linkMeta: z.ZodOptional<z.ZodObject<{
|
|
164
214
|
url: z.ZodURL;
|
|
165
215
|
title: z.ZodOptional<z.ZodString>;
|
|
166
216
|
description: z.ZodOptional<z.ZodString>;
|
|
167
217
|
image: z.ZodOptional<z.ZodURL>;
|
|
168
218
|
}, z.core.$strip>>;
|
|
169
|
-
createdAt: z.
|
|
219
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
170
220
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
171
221
|
deletedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
172
222
|
}, z.core.$strip>;
|
|
173
|
-
export declare const GetMessagesOutputSchema: z.ZodArray<z.ZodObject<{
|
|
174
|
-
id: z.ZodString;
|
|
175
|
-
messageId: z.ZodString;
|
|
176
|
-
fileId: z.ZodString;
|
|
177
|
-
order: z.ZodNumber;
|
|
178
|
-
}, z.core.$strip>>;
|
package/dist/schemas/message.js
CHANGED
|
@@ -1,110 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CreateMessageOutputSchema = exports.GetMessagesOutputSchema = exports.CreateMessageInputSchema = exports.MessageWithFilesEntitySchema = exports.MessageFileEntitySchema = exports.MessageEntitySchema = 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
|
+
// 1. Base primitives
|
|
8
|
+
const LinkMetaSchema = zod_openapi_1.z.object({
|
|
9
|
+
url: zod_openapi_1.z.url(),
|
|
10
|
+
title: zod_openapi_1.z.string().optional(),
|
|
11
|
+
description: zod_openapi_1.z.string().optional(),
|
|
12
|
+
image: zod_openapi_1.z.url().optional(),
|
|
13
|
+
});
|
|
14
|
+
// 2. The API Output Schema (Enriched)
|
|
7
15
|
exports.MessageEntitySchema = zod_openapi_1.z.object({
|
|
8
16
|
id: zod_openapi_1.z.cuid2(),
|
|
9
|
-
parentId: zod_openapi_1.z.cuid2().optional(),
|
|
10
|
-
parentType: zod_openapi_1.z.enum(constants_1.ACTIVITY_PARENT_TYPES).optional(),
|
|
11
|
-
replyToMessageId: zod_openapi_1.z.cuid2().optional(),
|
|
12
17
|
chatId: zod_openapi_1.z.cuid2(),
|
|
13
18
|
senderId: zod_openapi_1.z.cuid2(),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.optional(),
|
|
23
|
-
content: zod_openapi_1.z.string().optional(),
|
|
24
|
-
messageType: zod_openapi_1.z.enum(constants_1.MESSAGE_TYPES).default(constants_1.MESSAGE_TYPES.DEFAULT_MESSAGE),
|
|
19
|
+
// Content & Type
|
|
20
|
+
content: zod_openapi_1.z.string().optional().default(""),
|
|
21
|
+
messageType: zod_openapi_1.z.enum(constants_1.MESSAGE_TYPES).default("DEFAULT_MESSAGE"),
|
|
22
|
+
// Parent/Threading
|
|
23
|
+
parentId: zod_openapi_1.z.cuid2().optional(), // For threads/comments
|
|
24
|
+
parentType: zod_openapi_1.z.enum(constants_1.ACTIVITY_PARENT_TYPES).optional(),
|
|
25
|
+
// Reply Context (Flattened for UI convenience)
|
|
26
|
+
replyToMessageId: zod_openapi_1.z.cuid2().optional(),
|
|
25
27
|
replyToContent: zod_openapi_1.z.string().optional(),
|
|
26
28
|
replyToImages: zod_openapi_1.z.array(zod_openapi_1.z.url()).optional(),
|
|
27
|
-
replyToLinkMeta:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
description: zod_openapi_1.z.string().optional(),
|
|
32
|
-
image: zod_openapi_1.z.url().optional(),
|
|
33
|
-
})
|
|
34
|
-
.optional(),
|
|
35
|
-
createdAt: zod_openapi_1.z.coerce.date().optional(),
|
|
29
|
+
replyToLinkMeta: LinkMetaSchema.optional(),
|
|
30
|
+
// Metadata
|
|
31
|
+
linkMeta: LinkMetaSchema.optional(),
|
|
32
|
+
createdAt: zod_openapi_1.z.coerce.date(),
|
|
36
33
|
updatedAt: zod_openapi_1.z.coerce.date().optional(),
|
|
37
34
|
deletedAt: zod_openapi_1.z.coerce.date().optional(),
|
|
38
35
|
});
|
|
39
|
-
exports.MessageFileEntitySchema = zod_openapi_1.z
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
description: "CUID2 of the message this file belongs to.",
|
|
46
|
-
}),
|
|
47
|
-
fileId: zod_openapi_1.z.string().openapi({ description: "CUID2 of the linked file." }),
|
|
48
|
-
order: zod_openapi_1.z.number().int().openapi({
|
|
49
|
-
description: "Order index of the file in the project.",
|
|
50
|
-
example: 1,
|
|
51
|
-
}),
|
|
52
|
-
})
|
|
53
|
-
.openapi({
|
|
54
|
-
title: "Message File Entity",
|
|
55
|
-
description: "Schema representing a file associated with a project.",
|
|
36
|
+
exports.MessageFileEntitySchema = zod_openapi_1.z.object({
|
|
37
|
+
id: zod_openapi_1.z.cuid2(),
|
|
38
|
+
messageId: zod_openapi_1.z.cuid2(),
|
|
39
|
+
fileId: zod_openapi_1.z.cuid2(),
|
|
40
|
+
url: zod_openapi_1.z.url(),
|
|
41
|
+
order: zod_openapi_1.z.number().int().default(0),
|
|
56
42
|
});
|
|
57
43
|
exports.MessageWithFilesEntitySchema = exports.MessageEntitySchema.extend({
|
|
58
|
-
messageFiles: zod_openapi_1.z
|
|
59
|
-
.array(exports.MessageFileEntitySchema.extend({
|
|
60
|
-
url: zod_openapi_1.z.url(),
|
|
61
|
-
}))
|
|
62
|
-
.optional()
|
|
63
|
-
.openapi({ description: "Files associated with the project." }),
|
|
44
|
+
messageFiles: zod_openapi_1.z.array(exports.MessageFileEntitySchema).default([]),
|
|
64
45
|
});
|
|
46
|
+
// 3. Inputs
|
|
65
47
|
exports.CreateMessageInputSchema = zod_openapi_1.z.object({
|
|
66
|
-
id: zod_openapi_1.z.cuid2(),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.openapi({
|
|
74
|
-
description: "Message content",
|
|
75
|
-
example: "New project announcement",
|
|
76
|
-
})
|
|
77
|
-
.optional(),
|
|
78
|
-
messageType: zod_openapi_1.z
|
|
79
|
-
.enum(constants_1.MESSAGE_TYPES)
|
|
80
|
-
.default("DEFAULT_MESSAGE")
|
|
81
|
-
.openapi({ description: "Message type", example: "PROJECT" }),
|
|
82
|
-
files: zod_openapi_1.z
|
|
83
|
-
.array(file_1.CreateFileInputSchema.extend({
|
|
84
|
-
order: zod_openapi_1.z.int().default(1),
|
|
85
|
-
}))
|
|
86
|
-
.optional(),
|
|
87
|
-
chatId: zod_openapi_1.z.string(),
|
|
88
|
-
senderId: zod_openapi_1.z.string(),
|
|
89
|
-
receiverId: zod_openapi_1.z.string(),
|
|
48
|
+
id: zod_openapi_1.z.cuid2(), // Frontend generates ID for optimistic updates
|
|
49
|
+
chatId: zod_openapi_1.z.cuid2(),
|
|
50
|
+
senderId: zod_openapi_1.z.cuid2(),
|
|
51
|
+
receiverId: zod_openapi_1.z.cuid2(),
|
|
52
|
+
content: zod_openapi_1.z.string().optional(),
|
|
53
|
+
messageType: zod_openapi_1.z.enum(constants_1.MESSAGE_TYPES).default("DEFAULT_MESSAGE"),
|
|
54
|
+
parentId: zod_openapi_1.z.cuid2().optional(),
|
|
90
55
|
replyToMessageId: zod_openapi_1.z.cuid2().optional(),
|
|
91
|
-
linkMeta:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
})
|
|
98
|
-
.optional()
|
|
99
|
-
.openapi({
|
|
100
|
-
description: "Optional metadata for a single link in the message",
|
|
101
|
-
example: {
|
|
102
|
-
url: "https://example.com",
|
|
103
|
-
title: "Example Website",
|
|
104
|
-
description: "This is an example link",
|
|
105
|
-
image: "https://example.com/preview.jpg",
|
|
106
|
-
},
|
|
107
|
-
}),
|
|
56
|
+
linkMeta: LinkMetaSchema.optional(),
|
|
57
|
+
files: zod_openapi_1.z.array(file_1.CreateFileInputSchema.extend({ order: zod_openapi_1.z.number().int() })).optional(),
|
|
58
|
+
});
|
|
59
|
+
exports.GetMessagesOutputSchema = zod_openapi_1.z.object({
|
|
60
|
+
messages: zod_openapi_1.z.array(exports.MessageWithFilesEntitySchema),
|
|
61
|
+
nextCursor: zod_openapi_1.z.string().nullable(),
|
|
108
62
|
});
|
|
109
63
|
exports.CreateMessageOutputSchema = exports.MessageEntitySchema;
|
|
110
|
-
exports.GetMessagesOutputSchema = zod_openapi_1.z.array(exports.MessageFileEntitySchema);
|
package/package.json
CHANGED
package/src/schemas/message.ts
CHANGED
|
@@ -2,116 +2,74 @@ import { z } from "@hono/zod-openapi";
|
|
|
2
2
|
import { ACTIVITY_PARENT_TYPES, MESSAGE_TYPES } from "../constants";
|
|
3
3
|
import { CreateFileInputSchema } from "./file";
|
|
4
4
|
|
|
5
|
+
// 1. Base primitives
|
|
6
|
+
const LinkMetaSchema = z.object({
|
|
7
|
+
url: z.url(),
|
|
8
|
+
title: z.string().optional(),
|
|
9
|
+
description: z.string().optional(),
|
|
10
|
+
image: z.url().optional(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// 2. The API Output Schema (Enriched)
|
|
5
14
|
export const MessageEntitySchema = z.object({
|
|
6
15
|
id: z.cuid2(),
|
|
7
|
-
parentId: z.cuid2().optional(),
|
|
8
|
-
parentType: z.enum(ACTIVITY_PARENT_TYPES).optional(),
|
|
9
|
-
replyToMessageId: z.cuid2().optional(),
|
|
10
16
|
chatId: z.cuid2(),
|
|
11
17
|
senderId: z.cuid2(),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
|
|
19
|
+
// Content & Type
|
|
20
|
+
content: z.string().optional().default(""),
|
|
21
|
+
messageType: z.enum(MESSAGE_TYPES).default("DEFAULT_MESSAGE"),
|
|
22
|
+
|
|
23
|
+
// Parent/Threading
|
|
24
|
+
parentId: z.cuid2().optional(), // For threads/comments
|
|
25
|
+
parentType: z.enum(ACTIVITY_PARENT_TYPES).optional(),
|
|
26
|
+
|
|
27
|
+
// Reply Context (Flattened for UI convenience)
|
|
28
|
+
replyToMessageId: z.cuid2().optional(),
|
|
23
29
|
replyToContent: z.string().optional(),
|
|
24
30
|
replyToImages: z.array(z.url()).optional(),
|
|
25
|
-
replyToLinkMeta:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
image: z.url().optional(),
|
|
31
|
-
})
|
|
32
|
-
.optional(),
|
|
33
|
-
createdAt: z.coerce.date().optional(),
|
|
31
|
+
replyToLinkMeta: LinkMetaSchema.optional(),
|
|
32
|
+
|
|
33
|
+
// Metadata
|
|
34
|
+
linkMeta: LinkMetaSchema.optional(),
|
|
35
|
+
createdAt: z.coerce.date(),
|
|
34
36
|
updatedAt: z.coerce.date().optional(),
|
|
35
37
|
deletedAt: z.coerce.date().optional(),
|
|
36
38
|
});
|
|
37
39
|
|
|
38
|
-
export const MessageFileEntitySchema = z
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}),
|
|
46
|
-
fileId: z.string().openapi({ description: "CUID2 of the linked file." }),
|
|
47
|
-
order: z.number().int().openapi({
|
|
48
|
-
description: "Order index of the file in the project.",
|
|
49
|
-
example: 1,
|
|
50
|
-
}),
|
|
51
|
-
})
|
|
52
|
-
.openapi({
|
|
53
|
-
title: "Message File Entity",
|
|
54
|
-
description: "Schema representing a file associated with a project.",
|
|
55
|
-
});
|
|
40
|
+
export const MessageFileEntitySchema = z.object({
|
|
41
|
+
id: z.cuid2(),
|
|
42
|
+
messageId: z.cuid2(),
|
|
43
|
+
fileId: z.cuid2(),
|
|
44
|
+
url: z.url(),
|
|
45
|
+
order: z.number().int().default(0),
|
|
46
|
+
});
|
|
56
47
|
|
|
57
48
|
export const MessageWithFilesEntitySchema = MessageEntitySchema.extend({
|
|
58
|
-
messageFiles: z
|
|
59
|
-
.array(
|
|
60
|
-
MessageFileEntitySchema.extend({
|
|
61
|
-
url: z.url(),
|
|
62
|
-
}),
|
|
63
|
-
)
|
|
64
|
-
.optional()
|
|
65
|
-
.openapi({ description: "Files associated with the project." }),
|
|
49
|
+
messageFiles: z.array(MessageFileEntitySchema).default([]),
|
|
66
50
|
});
|
|
67
51
|
|
|
52
|
+
// 3. Inputs
|
|
68
53
|
export const CreateMessageInputSchema = z.object({
|
|
69
|
-
id: z.cuid2(),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
content: z
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
example: "New project announcement",
|
|
79
|
-
})
|
|
80
|
-
.optional(),
|
|
81
|
-
messageType: z
|
|
82
|
-
.enum(MESSAGE_TYPES)
|
|
83
|
-
.default("DEFAULT_MESSAGE")
|
|
84
|
-
.openapi({ description: "Message type", example: "PROJECT" }),
|
|
85
|
-
files: z
|
|
86
|
-
.array(
|
|
87
|
-
CreateFileInputSchema.extend({
|
|
88
|
-
order: z.int().default(1),
|
|
89
|
-
}),
|
|
90
|
-
)
|
|
91
|
-
.optional(),
|
|
92
|
-
chatId: z.string(),
|
|
93
|
-
senderId: z.string(),
|
|
94
|
-
receiverId: z.string(),
|
|
54
|
+
id: z.cuid2(), // Frontend generates ID for optimistic updates
|
|
55
|
+
chatId: z.cuid2(),
|
|
56
|
+
senderId: z.cuid2(),
|
|
57
|
+
receiverId: z.cuid2(),
|
|
58
|
+
|
|
59
|
+
content: z.string().optional(),
|
|
60
|
+
messageType: z.enum(MESSAGE_TYPES).default("DEFAULT_MESSAGE"),
|
|
61
|
+
|
|
62
|
+
parentId: z.cuid2().optional(),
|
|
95
63
|
replyToMessageId: z.cuid2().optional(),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
.openapi({
|
|
105
|
-
description: "Optional metadata for a single link in the message",
|
|
106
|
-
example: {
|
|
107
|
-
url: "https://example.com",
|
|
108
|
-
title: "Example Website",
|
|
109
|
-
description: "This is an example link",
|
|
110
|
-
image: "https://example.com/preview.jpg",
|
|
111
|
-
},
|
|
112
|
-
}),
|
|
64
|
+
|
|
65
|
+
linkMeta: LinkMetaSchema.optional(),
|
|
66
|
+
files: z.array(CreateFileInputSchema.extend({ order: z.number().int() })).optional(),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export const GetMessagesOutputSchema = z.object({
|
|
70
|
+
messages: z.array(MessageWithFilesEntitySchema),
|
|
71
|
+
nextCursor: z.string().nullable(),
|
|
113
72
|
});
|
|
114
73
|
|
|
115
74
|
export const CreateMessageOutputSchema = MessageEntitySchema;
|
|
116
75
|
|
|
117
|
-
export const GetMessagesOutputSchema = z.array(MessageFileEntitySchema);
|