@zyacreatives/shared 2.1.66 → 2.1.67
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/post.d.ts +3 -0
- package/dist/schemas/post.js +18 -5
- package/dist/types/post.d.ts +2 -1
- package/package.json +1 -1
- package/src/schemas/post.ts +186 -174
- package/src/types/post.ts +25 -23
package/dist/schemas/post.d.ts
CHANGED
|
@@ -612,3 +612,6 @@ export declare const SearchPostOutputSchema: z.ZodObject<{
|
|
|
612
612
|
}, z.core.$strip>>;
|
|
613
613
|
nextCursor: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
614
614
|
}, z.core.$strip>;
|
|
615
|
+
export declare const ReportPostInputSchema: z.ZodObject<{
|
|
616
|
+
complaint: z.ZodString;
|
|
617
|
+
}, z.core.$strip>;
|
package/dist/schemas/post.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SearchPostOutputSchema = exports.SearchPostInputSchema = exports.GetFeedOutputSchema = exports.GetFeedInputSchema = exports.FeedPostEntitySchema = exports.LinkPreviewOutputSchema = exports.LinkPreviewInputSchema = exports.GetPostWithBookmarksOutputSchema = exports.PostWithBookmarksEntitySchema = exports.PostWithCommentsEntitySchema = exports.GetPostWithLikesOutputSchema = exports.PostWithLikesEntitySchema = exports.MinimalPostSchema = exports.PostIdSchema = exports.GetPostOutputSchema = exports.CreatePostOutputSchema = exports.CreatePostInputSchema = exports.PostWithFilesEntitySchema = exports.PostFileEntitySchema = exports.PostEntitySchema = void 0;
|
|
3
|
+
exports.ReportPostInputSchema = exports.SearchPostOutputSchema = exports.SearchPostInputSchema = exports.GetFeedOutputSchema = exports.GetFeedInputSchema = exports.FeedPostEntitySchema = exports.LinkPreviewOutputSchema = exports.LinkPreviewInputSchema = exports.GetPostWithBookmarksOutputSchema = exports.PostWithBookmarksEntitySchema = exports.PostWithCommentsEntitySchema = exports.GetPostWithLikesOutputSchema = exports.PostWithLikesEntitySchema = exports.MinimalPostSchema = exports.PostIdSchema = exports.GetPostOutputSchema = exports.CreatePostOutputSchema = exports.CreatePostInputSchema = exports.PostWithFilesEntitySchema = exports.PostFileEntitySchema = exports.PostEntitySchema = 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");
|
|
@@ -15,7 +15,9 @@ exports.PostEntitySchema = zod_openapi_1.z.object({
|
|
|
15
15
|
.cuid2()
|
|
16
16
|
.optional()
|
|
17
17
|
.openapi({ description: "Parent id", example: "ckj1a2b3c0000abc" }),
|
|
18
|
-
parentType: zod_openapi_1.z
|
|
18
|
+
parentType: zod_openapi_1.z
|
|
19
|
+
.enum(constants_1.ACTIVITY_PARENT_TYPES)
|
|
20
|
+
.default(constants_1.ACTIVITY_PARENT_TYPES.POST),
|
|
19
21
|
tags: zod_openapi_1.z
|
|
20
22
|
.array(zod_openapi_1.z.object({
|
|
21
23
|
name: zod_openapi_1.z.string(),
|
|
@@ -64,7 +66,9 @@ exports.PostFileEntitySchema = zod_openapi_1.z
|
|
|
64
66
|
postId: zod_openapi_1.z.string().openapi({
|
|
65
67
|
description: "CUID2 of the post this file belongs to.",
|
|
66
68
|
}),
|
|
67
|
-
fileId: zod_openapi_1.z
|
|
69
|
+
fileId: zod_openapi_1.z
|
|
70
|
+
.string()
|
|
71
|
+
.openapi({ description: "CUID2 of the linked file." }),
|
|
68
72
|
order: zod_openapi_1.z.number().int().openapi({
|
|
69
73
|
description: "Order index of the file in the project.",
|
|
70
74
|
example: 1,
|
|
@@ -88,7 +92,9 @@ exports.CreatePostInputSchema = zod_openapi_1.z.object({
|
|
|
88
92
|
.cuid2({ message: "Invalid parentId" })
|
|
89
93
|
.optional()
|
|
90
94
|
.openapi({ description: "Parent id", example: "ckl1a2b3c0000abc" }),
|
|
91
|
-
parentType: zod_openapi_1.z
|
|
95
|
+
parentType: zod_openapi_1.z
|
|
96
|
+
.enum(constants_1.ACTIVITY_PARENT_TYPES)
|
|
97
|
+
.default(constants_1.ACTIVITY_PARENT_TYPES.POST),
|
|
92
98
|
content: zod_openapi_1.z
|
|
93
99
|
.string()
|
|
94
100
|
.max(500, { message: "Post content cannot exceed 500 characters" })
|
|
@@ -125,7 +131,9 @@ exports.CreatePostInputSchema = zod_openapi_1.z.object({
|
|
|
125
131
|
.optional(),
|
|
126
132
|
description: zod_openapi_1.z
|
|
127
133
|
.string()
|
|
128
|
-
.max(500, {
|
|
134
|
+
.max(500, {
|
|
135
|
+
message: "Description cannot exceed 500 characters",
|
|
136
|
+
})
|
|
129
137
|
.optional(),
|
|
130
138
|
image: zod_openapi_1.z.url({ message: "Invalid image URL" }).optional(),
|
|
131
139
|
})
|
|
@@ -205,3 +213,8 @@ exports.SearchPostOutputSchema = zod_openapi_1.z.object({
|
|
|
205
213
|
posts: zod_openapi_1.z.array(exports.FeedPostEntitySchema),
|
|
206
214
|
nextCursor: zod_openapi_1.z.string().optional().nullable(),
|
|
207
215
|
});
|
|
216
|
+
exports.ReportPostInputSchema = zod_openapi_1.z.object({
|
|
217
|
+
complaint: zod_openapi_1.z
|
|
218
|
+
.string()
|
|
219
|
+
.max(200, { error: "Complaint cannot be longer than 200 characters" }),
|
|
220
|
+
});
|
package/dist/types/post.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "@hono/zod-openapi";
|
|
2
|
-
import { CreatePostInputSchema, CreatePostOutputSchema, FeedPostEntitySchema, GetFeedInputSchema, GetFeedOutputSchema, GetPostOutputSchema, GetPostWithBookmarksOutputSchema, GetPostWithLikesOutputSchema, LinkPreviewInputSchema, LinkPreviewOutputSchema, PostEntitySchema, PostFileEntitySchema, PostIdSchema, PostWithBookmarksEntitySchema, PostWithCommentsEntitySchema, PostWithFilesEntitySchema, PostWithLikesEntitySchema, SearchPostInputSchema, SearchPostOutputSchema } from "../schemas/post";
|
|
2
|
+
import { CreatePostInputSchema, CreatePostOutputSchema, FeedPostEntitySchema, GetFeedInputSchema, GetFeedOutputSchema, GetPostOutputSchema, GetPostWithBookmarksOutputSchema, GetPostWithLikesOutputSchema, LinkPreviewInputSchema, LinkPreviewOutputSchema, PostEntitySchema, PostFileEntitySchema, PostIdSchema, PostWithBookmarksEntitySchema, PostWithCommentsEntitySchema, PostWithFilesEntitySchema, PostWithLikesEntitySchema, ReportPostInputSchema, SearchPostInputSchema, SearchPostOutputSchema } from "../schemas/post";
|
|
3
3
|
export type PostEntity = z.infer<typeof PostEntitySchema>;
|
|
4
4
|
export type PostFileEntity = z.infer<typeof PostFileEntitySchema>;
|
|
5
5
|
export type PostWithFilesEntity = z.infer<typeof PostWithFilesEntitySchema>;
|
|
@@ -19,3 +19,4 @@ export type SearchPostInput = z.infer<typeof SearchPostInputSchema>;
|
|
|
19
19
|
export type SearchPostOutput = z.infer<typeof SearchPostOutputSchema>;
|
|
20
20
|
export type GetPostWithLikesOutput = z.infer<typeof GetPostWithLikesOutputSchema>;
|
|
21
21
|
export type GetPostWithBookmarksOutput = z.infer<typeof GetPostWithBookmarksOutputSchema>;
|
|
22
|
+
export type ReportPostInput = z.infer<typeof ReportPostInputSchema>;
|
package/package.json
CHANGED
package/src/schemas/post.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from "@hono/zod-openapi";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
ACTIVITY_PARENT_TYPES,
|
|
4
|
+
POST_BADGE_TYPES,
|
|
5
|
+
POST_TYPES,
|
|
6
6
|
} from "../constants";
|
|
7
7
|
import { CreateFileInputSchema, FileEntitySchema } from "./file";
|
|
8
8
|
import { BookmarkEntitySchema } from "./bookmark";
|
|
@@ -12,231 +12,243 @@ import { EntityStatsSchema } from "./entity-stats";
|
|
|
12
12
|
import { ActivitySchema } from "./activity";
|
|
13
13
|
|
|
14
14
|
export const PostEntitySchema = z.object({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
createdAt: z.coerce.date().optional(),
|
|
48
|
-
|
|
49
|
-
linkMeta: z
|
|
50
|
-
.object({
|
|
51
|
-
url: z.url(),
|
|
52
|
-
title: z.string().optional(),
|
|
53
|
-
description: z.string().optional(),
|
|
54
|
-
image: z.url().optional(),
|
|
55
|
-
})
|
|
56
|
-
.optional()
|
|
57
|
-
.openapi({
|
|
58
|
-
description: "Optional metadata for a single link in the post",
|
|
59
|
-
example: {
|
|
60
|
-
url: "https://example.com",
|
|
61
|
-
title: "Example Website",
|
|
62
|
-
description: "This is an example link",
|
|
63
|
-
image: "https://example.com/preview.jpg",
|
|
64
|
-
},
|
|
15
|
+
id: z
|
|
16
|
+
.cuid2()
|
|
17
|
+
.openapi({ description: "Post id", example: "ckj1a2b3c0000xyz" }),
|
|
18
|
+
parentId: z
|
|
19
|
+
.cuid2()
|
|
20
|
+
.optional()
|
|
21
|
+
.openapi({ description: "Parent id", example: "ckj1a2b3c0000abc" }),
|
|
22
|
+
parentType: z
|
|
23
|
+
.enum(ACTIVITY_PARENT_TYPES)
|
|
24
|
+
.default(ACTIVITY_PARENT_TYPES.POST),
|
|
25
|
+
tags: z
|
|
26
|
+
.array(
|
|
27
|
+
z.object({
|
|
28
|
+
name: z.string(),
|
|
29
|
+
id: z.int(),
|
|
30
|
+
}),
|
|
31
|
+
)
|
|
32
|
+
.optional(),
|
|
33
|
+
badge: z.enum(POST_BADGE_TYPES).optional(),
|
|
34
|
+
userId: z
|
|
35
|
+
.cuid2()
|
|
36
|
+
.openapi({ description: "User id", example: "ckj1a2b3c0000def" }),
|
|
37
|
+
creatorUsername: z.string().optional().openapi({ description: "Username" }),
|
|
38
|
+
creatorFullName: z.string().optional(),
|
|
39
|
+
creatorImageUrl: z.cuid2().optional().openapi({ description: "Username" }),
|
|
40
|
+
content: z
|
|
41
|
+
.string()
|
|
42
|
+
.optional()
|
|
43
|
+
.openapi({ description: "Post content", example: "Hello world" }),
|
|
44
|
+
postType: z.enum(POST_TYPES).openapi({
|
|
45
|
+
description: "Type of the post entity this statistic belongs to.",
|
|
46
|
+
title: "Post Type",
|
|
65
47
|
}),
|
|
48
|
+
|
|
49
|
+
createdAt: z.coerce.date().optional(),
|
|
50
|
+
|
|
51
|
+
linkMeta: z
|
|
52
|
+
.object({
|
|
53
|
+
url: z.url(),
|
|
54
|
+
title: z.string().optional(),
|
|
55
|
+
description: z.string().optional(),
|
|
56
|
+
image: z.url().optional(),
|
|
57
|
+
})
|
|
58
|
+
.optional()
|
|
59
|
+
.openapi({
|
|
60
|
+
description: "Optional metadata for a single link in the post",
|
|
61
|
+
example: {
|
|
62
|
+
url: "https://example.com",
|
|
63
|
+
title: "Example Website",
|
|
64
|
+
description: "This is an example link",
|
|
65
|
+
image: "https://example.com/preview.jpg",
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
66
68
|
});
|
|
67
69
|
|
|
68
70
|
export const PostFileEntitySchema = z
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
.object({
|
|
72
|
+
id: z
|
|
73
|
+
.string()
|
|
74
|
+
.openapi({ description: "CUID2 of the project file record." }),
|
|
75
|
+
postId: z.string().openapi({
|
|
76
|
+
description: "CUID2 of the post this file belongs to.",
|
|
77
|
+
}),
|
|
78
|
+
fileId: z
|
|
79
|
+
.string()
|
|
80
|
+
.openapi({ description: "CUID2 of the linked file." }),
|
|
81
|
+
order: z.number().int().openapi({
|
|
82
|
+
description: "Order index of the file in the project.",
|
|
83
|
+
example: 1,
|
|
84
|
+
}),
|
|
85
|
+
})
|
|
86
|
+
.openapi({
|
|
87
|
+
title: "Post File Entity",
|
|
88
|
+
description: "Schema representing a file associated with a project.",
|
|
89
|
+
});
|
|
86
90
|
|
|
87
91
|
export const PostWithFilesEntitySchema = PostEntitySchema.extend({
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
postFiles: z
|
|
93
|
+
.array(
|
|
94
|
+
PostFileEntitySchema.extend({
|
|
95
|
+
url: z.url(),
|
|
96
|
+
}),
|
|
97
|
+
)
|
|
98
|
+
.optional()
|
|
99
|
+
.openapi({ description: "Files associated with the project." }),
|
|
96
100
|
});
|
|
97
101
|
|
|
98
102
|
export const CreatePostInputSchema = z.object({
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
.optional()
|
|
109
|
-
.openapi({
|
|
110
|
-
description: "Post content",
|
|
111
|
-
example: "New project announcement",
|
|
112
|
-
}),
|
|
113
|
-
|
|
114
|
-
postType: z
|
|
115
|
-
.enum(POST_TYPES)
|
|
116
|
-
.default("DEFAULT_POST")
|
|
117
|
-
.openapi({ description: "Post type", example: "PROJECT" }),
|
|
118
|
-
|
|
119
|
-
files: z
|
|
120
|
-
.array(
|
|
121
|
-
CreateFileInputSchema.extend({
|
|
122
|
-
order: z
|
|
123
|
-
.number()
|
|
124
|
-
.int({ message: "File order must be an integer" })
|
|
125
|
-
|
|
126
|
-
.max(5, { message: "File order cannot exceed 5" })
|
|
127
|
-
.default(1),
|
|
128
|
-
})
|
|
129
|
-
)
|
|
130
|
-
.max(5, { message: "Cannot attach more than 5 files" })
|
|
131
|
-
.optional(),
|
|
132
|
-
|
|
133
|
-
tags: z
|
|
134
|
-
.array(z.string().min(1, { message: "Tag cannot be empty" }))
|
|
135
|
-
.max(3, { message: "Cannot add more than 3 tags" })
|
|
136
|
-
.optional(),
|
|
137
|
-
badge: z.enum(POST_BADGE_TYPES).optional(),
|
|
138
|
-
linkMeta: z
|
|
139
|
-
.object({
|
|
140
|
-
url: z.url({ message: "Invalid URL format" }),
|
|
141
|
-
title: z
|
|
103
|
+
id: z.cuid2(),
|
|
104
|
+
parentId: z
|
|
105
|
+
.cuid2({ message: "Invalid parentId" })
|
|
106
|
+
.optional()
|
|
107
|
+
.openapi({ description: "Parent id", example: "ckl1a2b3c0000abc" }),
|
|
108
|
+
parentType: z
|
|
109
|
+
.enum(ACTIVITY_PARENT_TYPES)
|
|
110
|
+
.default(ACTIVITY_PARENT_TYPES.POST),
|
|
111
|
+
content: z
|
|
142
112
|
.string()
|
|
143
|
-
.max(
|
|
113
|
+
.max(500, { message: "Post content cannot exceed 500 characters" })
|
|
114
|
+
.optional()
|
|
115
|
+
.openapi({
|
|
116
|
+
description: "Post content",
|
|
117
|
+
example: "New project announcement",
|
|
118
|
+
}),
|
|
119
|
+
|
|
120
|
+
postType: z
|
|
121
|
+
.enum(POST_TYPES)
|
|
122
|
+
.default("DEFAULT_POST")
|
|
123
|
+
.openapi({ description: "Post type", example: "PROJECT" }),
|
|
124
|
+
|
|
125
|
+
files: z
|
|
126
|
+
.array(
|
|
127
|
+
CreateFileInputSchema.extend({
|
|
128
|
+
order: z
|
|
129
|
+
.number()
|
|
130
|
+
.int({ message: "File order must be an integer" })
|
|
131
|
+
|
|
132
|
+
.max(5, { message: "File order cannot exceed 5" })
|
|
133
|
+
.default(1),
|
|
134
|
+
}),
|
|
135
|
+
)
|
|
136
|
+
.max(5, { message: "Cannot attach more than 5 files" })
|
|
144
137
|
.optional(),
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
.
|
|
138
|
+
|
|
139
|
+
tags: z
|
|
140
|
+
.array(z.string().min(1, { message: "Tag cannot be empty" }))
|
|
141
|
+
.max(3, { message: "Cannot add more than 3 tags" })
|
|
148
142
|
.optional(),
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
143
|
+
badge: z.enum(POST_BADGE_TYPES).optional(),
|
|
144
|
+
linkMeta: z
|
|
145
|
+
.object({
|
|
146
|
+
url: z.url({ message: "Invalid URL format" }),
|
|
147
|
+
title: z
|
|
148
|
+
.string()
|
|
149
|
+
.max(200, { message: "Title cannot exceed 200 characters" })
|
|
150
|
+
.optional(),
|
|
151
|
+
description: z
|
|
152
|
+
.string()
|
|
153
|
+
.max(500, {
|
|
154
|
+
message: "Description cannot exceed 500 characters",
|
|
155
|
+
})
|
|
156
|
+
.optional(),
|
|
157
|
+
image: z.url({ message: "Invalid image URL" }).optional(),
|
|
158
|
+
})
|
|
159
|
+
.optional()
|
|
160
|
+
.openapi({
|
|
161
|
+
description: "Optional metadata for a single link in the post",
|
|
162
|
+
example: {
|
|
163
|
+
url: "https://example.com",
|
|
164
|
+
title: "Example Website",
|
|
165
|
+
description: "This is an example link",
|
|
166
|
+
image: "https://example.com/preview.jpg",
|
|
167
|
+
},
|
|
168
|
+
}),
|
|
161
169
|
});
|
|
162
170
|
|
|
163
171
|
export const CreatePostOutputSchema = PostEntitySchema;
|
|
164
172
|
export const GetPostOutputSchema = PostWithFilesEntitySchema;
|
|
165
173
|
export const PostIdSchema = z.object({ postId: z.cuid2() });
|
|
166
174
|
export const MinimalPostSchema = PostEntitySchema.pick({
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
175
|
+
title: true,
|
|
176
|
+
id: true,
|
|
177
|
+
parentId: true,
|
|
178
|
+
content: true,
|
|
171
179
|
});
|
|
172
180
|
|
|
173
181
|
export const PostWithLikesEntitySchema = MinimalPostSchema.extend({
|
|
174
|
-
|
|
182
|
+
likes: z.array(ActivitySchema),
|
|
175
183
|
}).openapi({
|
|
176
|
-
|
|
184
|
+
title: "PostWithPostLikesEntity",
|
|
177
185
|
});
|
|
178
186
|
|
|
179
187
|
export const GetPostWithLikesOutputSchema = PostWithLikesEntitySchema.extend({
|
|
180
|
-
|
|
188
|
+
totalNo: z.number().int(),
|
|
181
189
|
});
|
|
182
190
|
|
|
183
191
|
export const PostWithCommentsEntitySchema = MinimalPostSchema.extend({
|
|
184
|
-
|
|
185
|
-
CommentEntitySchema
|
|
186
|
-
),
|
|
192
|
+
comments: z.array(CommentEntitySchema),
|
|
187
193
|
}).openapi({
|
|
188
|
-
|
|
194
|
+
title: "PostWithPostCommentsEntity",
|
|
189
195
|
});
|
|
190
196
|
|
|
191
197
|
export const PostWithBookmarksEntitySchema = MinimalPostSchema.extend({
|
|
192
|
-
|
|
198
|
+
bookmarks: z.array(ActivitySchema),
|
|
193
199
|
}).openapi({
|
|
194
|
-
|
|
200
|
+
title: "PostWithPostBookmarksEntity",
|
|
195
201
|
});
|
|
196
202
|
|
|
197
203
|
export const GetPostWithBookmarksOutputSchema =
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
204
|
+
PostWithBookmarksEntitySchema.extend({
|
|
205
|
+
totalNo: z.number().int(),
|
|
206
|
+
});
|
|
201
207
|
|
|
202
208
|
export const LinkPreviewInputSchema = z.object({
|
|
203
|
-
|
|
209
|
+
url: z.string(),
|
|
204
210
|
});
|
|
205
211
|
|
|
206
212
|
export const LinkPreviewOutputSchema = z.object({
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
213
|
+
title: z.string(),
|
|
214
|
+
description: z.string().optional(),
|
|
215
|
+
image: z.string().optional(),
|
|
216
|
+
url: z.string().optional(),
|
|
211
217
|
});
|
|
212
218
|
|
|
213
219
|
export const FeedPostEntitySchema = PostWithFilesEntitySchema.extend({
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
220
|
+
stats: EntityStatsSchema,
|
|
221
|
+
score: z.number(),
|
|
222
|
+
isLiked: z.boolean().optional(),
|
|
223
|
+
isFollowing: z.boolean().optional(),
|
|
224
|
+
isBookmarked: z.boolean().optional(),
|
|
219
225
|
});
|
|
220
226
|
|
|
221
227
|
export const GetFeedInputSchema = z.object({
|
|
222
|
-
|
|
223
|
-
|
|
228
|
+
limit: z.number().optional(),
|
|
229
|
+
cursor: z.string().optional(),
|
|
224
230
|
});
|
|
225
231
|
|
|
226
232
|
export const GetFeedOutputSchema = z.object({
|
|
227
|
-
|
|
228
|
-
|
|
233
|
+
feed: z.array(FeedPostEntitySchema),
|
|
234
|
+
nextCursor: z.string().optional().nullable(),
|
|
229
235
|
});
|
|
230
236
|
|
|
231
237
|
export const SearchPostInputSchema = z.object({
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
238
|
+
queryString: z
|
|
239
|
+
.string()
|
|
240
|
+
.min(1, { message: "Search string cannot be empty" })
|
|
241
|
+
.max(200, { message: "Search string cannot exceed 200 characters" }),
|
|
242
|
+
cursor: z.string().optional(),
|
|
237
243
|
});
|
|
238
244
|
|
|
239
245
|
export const SearchPostOutputSchema = z.object({
|
|
240
|
-
|
|
241
|
-
|
|
246
|
+
posts: z.array(FeedPostEntitySchema),
|
|
247
|
+
nextCursor: z.string().optional().nullable(),
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
export const ReportPostInputSchema = z.object({
|
|
251
|
+
complaint: z
|
|
252
|
+
.string()
|
|
253
|
+
.max(200, { error: "Complaint cannot be longer than 200 characters" }),
|
|
242
254
|
});
|
package/src/types/post.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { z } from "@hono/zod-openapi";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
CreatePostInputSchema,
|
|
4
|
+
CreatePostOutputSchema,
|
|
5
|
+
FeedPostEntitySchema,
|
|
6
|
+
GetFeedInputSchema,
|
|
7
|
+
GetFeedOutputSchema,
|
|
8
|
+
GetPostOutputSchema,
|
|
9
|
+
GetPostWithBookmarksOutputSchema,
|
|
10
|
+
GetPostWithLikesOutputSchema,
|
|
11
|
+
LinkPreviewInputSchema,
|
|
12
|
+
LinkPreviewOutputSchema,
|
|
13
|
+
PostEntitySchema,
|
|
14
|
+
PostFileEntitySchema,
|
|
15
|
+
PostIdSchema,
|
|
16
|
+
PostWithBookmarksEntitySchema,
|
|
17
|
+
PostWithCommentsEntitySchema,
|
|
18
|
+
PostWithFilesEntitySchema,
|
|
19
|
+
PostWithLikesEntitySchema,
|
|
20
|
+
ReportPostInputSchema,
|
|
21
|
+
SearchPostInputSchema,
|
|
22
|
+
SearchPostOutputSchema,
|
|
22
23
|
} from "../schemas/post";
|
|
23
24
|
|
|
24
25
|
export type PostEntity = z.infer<typeof PostEntitySchema>;
|
|
@@ -28,11 +29,11 @@ export type CreatePostInput = z.infer<typeof CreatePostInputSchema>;
|
|
|
28
29
|
export type CreatePostOutput = z.infer<typeof CreatePostOutputSchema>;
|
|
29
30
|
export type PostWithPostLikesEntity = z.infer<typeof PostWithLikesEntitySchema>;
|
|
30
31
|
export type PostWithPostBookmarksEntity = z.infer<
|
|
31
|
-
|
|
32
|
+
typeof PostWithBookmarksEntitySchema
|
|
32
33
|
>;
|
|
33
34
|
export type PostIdInput = z.infer<typeof PostIdSchema>;
|
|
34
35
|
export type PostWithPostCommentsEntity = z.infer<
|
|
35
|
-
|
|
36
|
+
typeof PostWithCommentsEntitySchema
|
|
36
37
|
>;
|
|
37
38
|
export type GetPostOutput = z.infer<typeof GetPostOutputSchema>;
|
|
38
39
|
export type LinkPreviewInput = z.infer<typeof LinkPreviewInputSchema>;
|
|
@@ -45,8 +46,9 @@ export type SearchPostInput = z.infer<typeof SearchPostInputSchema>;
|
|
|
45
46
|
export type SearchPostOutput = z.infer<typeof SearchPostOutputSchema>;
|
|
46
47
|
|
|
47
48
|
export type GetPostWithLikesOutput = z.infer<
|
|
48
|
-
|
|
49
|
+
typeof GetPostWithLikesOutputSchema
|
|
49
50
|
>;
|
|
50
51
|
export type GetPostWithBookmarksOutput = z.infer<
|
|
51
|
-
|
|
52
|
+
typeof GetPostWithBookmarksOutputSchema
|
|
52
53
|
>;
|
|
54
|
+
export type ReportPostInput = z.infer<typeof ReportPostInputSchema>;
|