@zyacreatives/shared 2.1.66 → 2.1.68
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 +7 -0
- package/dist/schemas/post.js +22 -6
- package/dist/types/post.d.ts +2 -1
- package/package.json +1 -1
- package/src/schemas/post.ts +191 -174
- package/src/types/post.ts +25 -23
package/dist/schemas/post.d.ts
CHANGED
|
@@ -276,6 +276,8 @@ export declare const PostWithLikesEntitySchema: z.ZodObject<{
|
|
|
276
276
|
actorId: z.ZodString;
|
|
277
277
|
actorUsername: z.ZodString;
|
|
278
278
|
actorImageUrl: z.ZodOptional<z.ZodURL>;
|
|
279
|
+
followsYou: z.ZodOptional<z.ZodBoolean>;
|
|
280
|
+
isFollowing: z.ZodOptional<z.ZodBoolean>;
|
|
279
281
|
}, z.core.$strip>>;
|
|
280
282
|
}, z.core.$strip>;
|
|
281
283
|
export declare const GetPostWithLikesOutputSchema: z.ZodObject<{
|
|
@@ -295,6 +297,8 @@ export declare const GetPostWithLikesOutputSchema: z.ZodObject<{
|
|
|
295
297
|
actorId: z.ZodString;
|
|
296
298
|
actorUsername: z.ZodString;
|
|
297
299
|
actorImageUrl: z.ZodOptional<z.ZodURL>;
|
|
300
|
+
followsYou: z.ZodOptional<z.ZodBoolean>;
|
|
301
|
+
isFollowing: z.ZodOptional<z.ZodBoolean>;
|
|
298
302
|
}, z.core.$strip>>;
|
|
299
303
|
totalNo: z.ZodNumber;
|
|
300
304
|
}, z.core.$strip>;
|
|
@@ -612,3 +616,6 @@ export declare const SearchPostOutputSchema: z.ZodObject<{
|
|
|
612
616
|
}, z.core.$strip>>;
|
|
613
617
|
nextCursor: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
614
618
|
}, z.core.$strip>;
|
|
619
|
+
export declare const ReportPostInputSchema: z.ZodObject<{
|
|
620
|
+
complaint: z.ZodString;
|
|
621
|
+
}, 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
|
})
|
|
@@ -150,7 +158,10 @@ exports.MinimalPostSchema = exports.PostEntitySchema.pick({
|
|
|
150
158
|
content: true,
|
|
151
159
|
});
|
|
152
160
|
exports.PostWithLikesEntitySchema = exports.MinimalPostSchema.extend({
|
|
153
|
-
likes: zod_openapi_1.z.array(activity_1.ActivitySchema
|
|
161
|
+
likes: zod_openapi_1.z.array(activity_1.ActivitySchema.extend({
|
|
162
|
+
followsYou: zod_openapi_1.z.boolean().optional(),
|
|
163
|
+
isFollowing: zod_openapi_1.z.boolean().optional(),
|
|
164
|
+
})),
|
|
154
165
|
}).openapi({
|
|
155
166
|
title: "PostWithPostLikesEntity",
|
|
156
167
|
});
|
|
@@ -205,3 +216,8 @@ exports.SearchPostOutputSchema = zod_openapi_1.z.object({
|
|
|
205
216
|
posts: zod_openapi_1.z.array(exports.FeedPostEntitySchema),
|
|
206
217
|
nextCursor: zod_openapi_1.z.string().optional().nullable(),
|
|
207
218
|
});
|
|
219
|
+
exports.ReportPostInputSchema = zod_openapi_1.z.object({
|
|
220
|
+
complaint: zod_openapi_1.z
|
|
221
|
+
.string()
|
|
222
|
+
.max(200, { error: "Complaint cannot be longer than 200 characters" }),
|
|
223
|
+
});
|
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,248 @@ 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(
|
|
183
|
+
ActivitySchema.extend({
|
|
184
|
+
followsYou: z.boolean().optional(),
|
|
185
|
+
isFollowing: z.boolean().optional(),
|
|
186
|
+
}),
|
|
187
|
+
),
|
|
175
188
|
}).openapi({
|
|
176
|
-
|
|
189
|
+
title: "PostWithPostLikesEntity",
|
|
177
190
|
});
|
|
178
191
|
|
|
179
192
|
export const GetPostWithLikesOutputSchema = PostWithLikesEntitySchema.extend({
|
|
180
|
-
|
|
193
|
+
totalNo: z.number().int(),
|
|
181
194
|
});
|
|
182
195
|
|
|
183
196
|
export const PostWithCommentsEntitySchema = MinimalPostSchema.extend({
|
|
184
|
-
|
|
185
|
-
CommentEntitySchema
|
|
186
|
-
),
|
|
197
|
+
comments: z.array(CommentEntitySchema),
|
|
187
198
|
}).openapi({
|
|
188
|
-
|
|
199
|
+
title: "PostWithPostCommentsEntity",
|
|
189
200
|
});
|
|
190
201
|
|
|
191
202
|
export const PostWithBookmarksEntitySchema = MinimalPostSchema.extend({
|
|
192
|
-
|
|
203
|
+
bookmarks: z.array(ActivitySchema),
|
|
193
204
|
}).openapi({
|
|
194
|
-
|
|
205
|
+
title: "PostWithPostBookmarksEntity",
|
|
195
206
|
});
|
|
196
207
|
|
|
197
208
|
export const GetPostWithBookmarksOutputSchema =
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
209
|
+
PostWithBookmarksEntitySchema.extend({
|
|
210
|
+
totalNo: z.number().int(),
|
|
211
|
+
});
|
|
201
212
|
|
|
202
213
|
export const LinkPreviewInputSchema = z.object({
|
|
203
|
-
|
|
214
|
+
url: z.string(),
|
|
204
215
|
});
|
|
205
216
|
|
|
206
217
|
export const LinkPreviewOutputSchema = z.object({
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
218
|
+
title: z.string(),
|
|
219
|
+
description: z.string().optional(),
|
|
220
|
+
image: z.string().optional(),
|
|
221
|
+
url: z.string().optional(),
|
|
211
222
|
});
|
|
212
223
|
|
|
213
224
|
export const FeedPostEntitySchema = PostWithFilesEntitySchema.extend({
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
225
|
+
stats: EntityStatsSchema,
|
|
226
|
+
score: z.number(),
|
|
227
|
+
isLiked: z.boolean().optional(),
|
|
228
|
+
isFollowing: z.boolean().optional(),
|
|
229
|
+
isBookmarked: z.boolean().optional(),
|
|
219
230
|
});
|
|
220
231
|
|
|
221
232
|
export const GetFeedInputSchema = z.object({
|
|
222
|
-
|
|
223
|
-
|
|
233
|
+
limit: z.number().optional(),
|
|
234
|
+
cursor: z.string().optional(),
|
|
224
235
|
});
|
|
225
236
|
|
|
226
237
|
export const GetFeedOutputSchema = z.object({
|
|
227
|
-
|
|
228
|
-
|
|
238
|
+
feed: z.array(FeedPostEntitySchema),
|
|
239
|
+
nextCursor: z.string().optional().nullable(),
|
|
229
240
|
});
|
|
230
241
|
|
|
231
242
|
export const SearchPostInputSchema = z.object({
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
243
|
+
queryString: z
|
|
244
|
+
.string()
|
|
245
|
+
.min(1, { message: "Search string cannot be empty" })
|
|
246
|
+
.max(200, { message: "Search string cannot exceed 200 characters" }),
|
|
247
|
+
cursor: z.string().optional(),
|
|
237
248
|
});
|
|
238
249
|
|
|
239
250
|
export const SearchPostOutputSchema = z.object({
|
|
240
|
-
|
|
241
|
-
|
|
251
|
+
posts: z.array(FeedPostEntitySchema),
|
|
252
|
+
nextCursor: z.string().optional().nullable(),
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
export const ReportPostInputSchema = z.object({
|
|
256
|
+
complaint: z
|
|
257
|
+
.string()
|
|
258
|
+
.max(200, { error: "Complaint cannot be longer than 200 characters" }),
|
|
242
259
|
});
|
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>;
|