@zyacreatives/shared 2.1.85 → 2.1.86

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.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/constants.ts +483 -483
  4. package/src/index.ts +4 -4
  5. package/src/schemas/activity.ts +14 -14
  6. package/src/schemas/auth.ts +43 -43
  7. package/src/schemas/bookmark.ts +38 -38
  8. package/src/schemas/brand.ts +146 -146
  9. package/src/schemas/chat.ts +31 -31
  10. package/src/schemas/comment.ts +60 -60
  11. package/src/schemas/common.ts +22 -22
  12. package/src/schemas/creative.ts +222 -222
  13. package/src/schemas/discipline.ts +88 -88
  14. package/src/schemas/entity-stats.ts +43 -43
  15. package/src/schemas/feed.ts +11 -11
  16. package/src/schemas/file.ts +61 -61
  17. package/src/schemas/index.ts +21 -21
  18. package/src/schemas/investor.ts +211 -211
  19. package/src/schemas/job-application.ts +257 -257
  20. package/src/schemas/job.ts +364 -364
  21. package/src/schemas/like.ts +38 -38
  22. package/src/schemas/message.ts +112 -112
  23. package/src/schemas/notification.ts +71 -71
  24. package/src/schemas/post.ts +279 -279
  25. package/src/schemas/project.ts +298 -298
  26. package/src/schemas/user-strike.ts +21 -21
  27. package/src/schemas/user.ts +283 -283
  28. package/src/schemas/username.ts +11 -11
  29. package/src/schemas/view.ts +50 -50
  30. package/src/types/auth.ts +5 -5
  31. package/src/types/bookmark.ts +4 -4
  32. package/src/types/brand.ts +37 -37
  33. package/src/types/chat.ts +21 -21
  34. package/src/types/comment.ts +12 -12
  35. package/src/types/common.ts +9 -9
  36. package/src/types/creative.ts +33 -33
  37. package/src/types/discipline.ts +32 -32
  38. package/src/types/entity-stats.ts +4 -4
  39. package/src/types/feed.ts +5 -5
  40. package/src/types/file.ts +39 -39
  41. package/src/types/index.ts +22 -22
  42. package/src/types/investor.ts +34 -34
  43. package/src/types/job-application.ts +41 -41
  44. package/src/types/job.ts +71 -71
  45. package/src/types/like.ts +3 -3
  46. package/src/types/message.ts +23 -23
  47. package/src/types/notification.ts +34 -34
  48. package/src/types/post.ts +63 -63
  49. package/src/types/project.ts +65 -65
  50. package/src/types/user-strike.ts +10 -10
  51. package/src/types/user.ts +96 -96
  52. package/src/types/username.ts +4 -4
  53. package/src/utils/slugify.ts +10 -10
  54. package/tsconfig.json +13 -13
@@ -1,279 +1,279 @@
1
- import { z } from "@hono/zod-openapi";
2
- import {
3
- ACTIVITY_PARENT_TYPES,
4
- POST_BADGE_TYPES,
5
- POST_TYPES,
6
- } from "../constants";
7
- import { CreateFileInputSchema } from "./file";
8
- import { CommentEntitySchema } from "./comment";
9
- import { EntityStatsSchema } from "./entity-stats";
10
- import { ActivitySchema } from "./activity";
11
-
12
- export const PostEntitySchema = z.object({
13
- id: z
14
- .cuid2()
15
- .openapi({ description: "Post id", example: "ckj1a2b3c0000xyz" }),
16
- parentId: z
17
- .cuid2()
18
- .optional()
19
- .openapi({ description: "Parent id", example: "ckj1a2b3c0000abc" }),
20
- parentType: z.enum(ACTIVITY_PARENT_TYPES).default(ACTIVITY_PARENT_TYPES.POST),
21
- tags: z
22
- .array(
23
- z.object({
24
- name: z.string(),
25
- id: z.int(),
26
- }),
27
- )
28
- .optional(),
29
- badge: z.enum(POST_BADGE_TYPES).optional(),
30
- userId: z
31
- .cuid2()
32
- .openapi({ description: "User id", example: "ckj1a2b3c0000def" }),
33
- creatorUsername: z.string().optional().openapi({ description: "Username" }),
34
- creatorFullName: z.string().optional(),
35
- creatorImageUrl: z.cuid2().optional().openapi({ description: "Username" }),
36
- content: z
37
- .string()
38
- .optional()
39
- .openapi({ description: "Post content", example: "Hello world" }),
40
- postType: z.enum(POST_TYPES).openapi({
41
- description: "Type of the post entity this statistic belongs to.",
42
- title: "Post Type",
43
- }),
44
-
45
- createdAt: z.coerce.date().optional(),
46
-
47
- linkMeta: z
48
- .object({
49
- url: z.url(),
50
- title: z.string().optional(),
51
- description: z.string().optional(),
52
- image: z.url().optional(),
53
- })
54
- .optional()
55
- .openapi({
56
- description: "Optional metadata for a single link in the post",
57
- example: {
58
- url: "https://example.com",
59
- title: "Example Website",
60
- description: "This is an example link",
61
- image: "https://example.com/preview.jpg",
62
- },
63
- }),
64
- });
65
-
66
- export const PostFileEntitySchema = z
67
- .object({
68
- id: z
69
- .string()
70
- .openapi({ description: "CUID2 of the project file record." }),
71
- postId: z.string().openapi({
72
- description: "CUID2 of the post this file belongs to.",
73
- }),
74
- fileId: z.string().openapi({ description: "CUID2 of the linked file." }),
75
- order: z.number().int().openapi({
76
- description: "Order index of the file in the project.",
77
- example: 1,
78
- }),
79
- })
80
- .openapi({
81
- title: "Post File Entity",
82
- description: "Schema representing a file associated with a project.",
83
- });
84
-
85
- export const PostWithFilesEntitySchema = PostEntitySchema.extend({
86
- postFiles: z
87
- .array(
88
- PostFileEntitySchema.extend({
89
- url: z.url(),
90
- }),
91
- )
92
- .optional()
93
- .openapi({ description: "Files associated with the project." }),
94
- });
95
-
96
- export const CreatePostInputSchema = z.object({
97
- id: z.cuid2(),
98
- parentId: z
99
- .cuid2({ message: "Invalid parentId" })
100
- .optional()
101
- .openapi({ description: "Parent id", example: "ckl1a2b3c0000abc" }),
102
- parentType: z.enum(ACTIVITY_PARENT_TYPES).default(ACTIVITY_PARENT_TYPES.POST),
103
- content: z
104
- .string()
105
- .max(500, { message: "Post content cannot exceed 500 characters" })
106
- .optional()
107
- .openapi({
108
- description: "Post content",
109
- example: "New project announcement",
110
- }),
111
-
112
- postType: z
113
- .enum(POST_TYPES)
114
- .default("DEFAULT_POST")
115
- .openapi({ description: "Post type", example: "PROJECT" }),
116
-
117
- files: z
118
- .array(
119
- CreateFileInputSchema.extend({
120
- order: z
121
- .number()
122
- .int({ message: "File order must be an integer" })
123
-
124
- .max(5, { message: "File order cannot exceed 5" })
125
- .default(1),
126
- }),
127
- )
128
- .max(5, { message: "Cannot attach more than 5 files" })
129
- .optional(),
130
-
131
- tags: z
132
- .array(z.string().min(1, { message: "Tag cannot be empty" }))
133
- .max(3, { message: "Cannot add more than 3 tags" })
134
- .optional(),
135
- badge: z.enum(POST_BADGE_TYPES).optional(),
136
- linkMeta: z
137
- .object({
138
- url: z.url({ message: "Invalid URL format" }),
139
- title: z
140
- .string()
141
- .max(200, { message: "Title cannot exceed 200 characters" })
142
- .optional(),
143
- description: z
144
- .string()
145
- .max(500, {
146
- message: "Description cannot exceed 500 characters",
147
- })
148
- .optional(),
149
- image: z.url({ message: "Invalid image URL" }).optional(),
150
- })
151
- .optional()
152
- .openapi({
153
- description: "Optional metadata for a single link in the post",
154
- example: {
155
- url: "https://example.com",
156
- title: "Example Website",
157
- description: "This is an example link",
158
- image: "https://example.com/preview.jpg",
159
- },
160
- }),
161
- });
162
-
163
- export const CreatePostOutputSchema = PostEntitySchema;
164
- export const GetPostOutputSchema = PostWithFilesEntitySchema;
165
- export const PostIdSchema = z.object({ postId: z.cuid2() });
166
- export const MinimalPostSchema = PostEntitySchema.pick({
167
- id: true,
168
- parentId: true,
169
- content: true,
170
- });
171
-
172
- export const PostWithLikesEntitySchema = MinimalPostSchema.extend({
173
- likes: z.array(
174
- ActivitySchema.extend({
175
- followsYou: z.boolean().optional(),
176
- isFollowing: z.boolean().optional(),
177
- }),
178
- ),
179
- }).openapi({
180
- title: "PostWithPostLikesEntity",
181
- });
182
-
183
- export const GetPostWithLikesOutputSchema = PostWithLikesEntitySchema.extend({
184
- nextCursor: z.string().optional().nullable(),
185
- });
186
-
187
- export const PostWithCommentsEntitySchema = MinimalPostSchema.extend({
188
- comments: z.array(CommentEntitySchema),
189
- }).openapi({
190
- title: "PostWithPostCommentsEntity",
191
- });
192
-
193
- export const GetPostWithCommentsOutputSchema =
194
- PostWithCommentsEntitySchema.extend({
195
- nextCursor: z.string().optional().nullable(),
196
- });
197
-
198
- export const PostWithBookmarksEntitySchema = MinimalPostSchema.extend({
199
- bookmarks: z.array(ActivitySchema),
200
- }).openapi({
201
- title: "PostWithPostBookmarksEntity",
202
- });
203
-
204
- export const GetPostWithBookmarksOutputSchema =
205
- PostWithBookmarksEntitySchema.extend({
206
- totalNo: z.number().int(),
207
- });
208
-
209
- export const LinkPreviewInputSchema = z.object({
210
- url: z.string(),
211
- });
212
-
213
- export const LinkPreviewOutputSchema = z.object({
214
- title: z.string(),
215
- description: z.string().optional(),
216
- image: z.string().optional(),
217
- url: z.string().optional(),
218
- });
219
-
220
- export const FeedPostEntitySchema = PostWithFilesEntitySchema.extend({
221
- stats: EntityStatsSchema,
222
- score: z.number(),
223
- isLiked: z.boolean().optional(),
224
- isFollowing: z.boolean().optional(),
225
- isBookmarked: z.boolean().optional(),
226
- });
227
-
228
- export const GetFeedInputSchema = z.object({
229
- limit: z.number().optional(),
230
- cursor: z.string().optional(),
231
- });
232
-
233
- export const GetFeedOutputSchema = z.object({
234
- feed: z.array(FeedPostEntitySchema),
235
- nextCursor: z.string().optional().nullable(),
236
- });
237
-
238
- export const SearchPostInputSchema = z.object({
239
- queryString: z
240
- .string()
241
- .min(1, { message: "Search string cannot be empty" })
242
- .max(200, { message: "Search string cannot exceed 200 characters" }),
243
- cursor: z.string().optional(),
244
- });
245
-
246
- export const SearchPostOutputSchema = z.object({
247
- posts: z.array(FeedPostEntitySchema),
248
- nextCursor: z.string().optional().nullable(),
249
- });
250
-
251
- export const ReportPostInputSchema = z.object({
252
- complaint: z
253
- .string()
254
- .max(200, { error: "Complaint cannot be longer than 200 characters" }),
255
- });
256
-
257
- export const PostAnalyticsOutputSchema = z.object({
258
- awareness: z.object({
259
- reach: z.number(),
260
- impressions: z.number(),
261
- newFollowers: z.number(),
262
- }),
263
- engagement: z.object({
264
- rate: z.number(),
265
- likes: z.number(),
266
- comments: z.number(),
267
- bookmarks: z.number(),
268
- }),
269
- behavior: z.object({
270
- viralityScore: z.number(),
271
- frictionRatio: z.number(),
272
- consumptionDepth: z.number(),
273
- sentiment: z.object({
274
- positive: z.number(),
275
- negative: z.number(),
276
- status: z.enum(["Healthy", "Polarizing"]),
277
- }),
278
- }),
279
- });
1
+ import { z } from "@hono/zod-openapi";
2
+ import {
3
+ ACTIVITY_PARENT_TYPES,
4
+ POST_BADGE_TYPES,
5
+ POST_TYPES,
6
+ } from "../constants";
7
+ import { CreateFileInputSchema } from "./file";
8
+ import { CommentEntitySchema } from "./comment";
9
+ import { EntityStatsSchema } from "./entity-stats";
10
+ import { ActivitySchema } from "./activity";
11
+
12
+ export const PostEntitySchema = z.object({
13
+ id: z
14
+ .cuid2()
15
+ .openapi({ description: "Post id", example: "ckj1a2b3c0000xyz" }),
16
+ parentId: z
17
+ .cuid2()
18
+ .optional()
19
+ .openapi({ description: "Parent id", example: "ckj1a2b3c0000abc" }),
20
+ parentType: z.enum(ACTIVITY_PARENT_TYPES).default(ACTIVITY_PARENT_TYPES.POST),
21
+ tags: z
22
+ .array(
23
+ z.object({
24
+ name: z.string(),
25
+ id: z.int(),
26
+ }),
27
+ )
28
+ .optional(),
29
+ badge: z.enum(POST_BADGE_TYPES).optional(),
30
+ userId: z
31
+ .cuid2()
32
+ .openapi({ description: "User id", example: "ckj1a2b3c0000def" }),
33
+ creatorUsername: z.string().optional().openapi({ description: "Username" }),
34
+ creatorFullName: z.string().optional(),
35
+ creatorImageUrl: z.cuid2().optional().openapi({ description: "Username" }),
36
+ content: z
37
+ .string()
38
+ .optional()
39
+ .openapi({ description: "Post content", example: "Hello world" }),
40
+ postType: z.enum(POST_TYPES).openapi({
41
+ description: "Type of the post entity this statistic belongs to.",
42
+ title: "Post Type",
43
+ }),
44
+
45
+ createdAt: z.coerce.date().optional(),
46
+
47
+ linkMeta: z
48
+ .object({
49
+ url: z.url(),
50
+ title: z.string().optional(),
51
+ description: z.string().optional(),
52
+ image: z.url().optional(),
53
+ })
54
+ .optional()
55
+ .openapi({
56
+ description: "Optional metadata for a single link in the post",
57
+ example: {
58
+ url: "https://example.com",
59
+ title: "Example Website",
60
+ description: "This is an example link",
61
+ image: "https://example.com/preview.jpg",
62
+ },
63
+ }),
64
+ });
65
+
66
+ export const PostFileEntitySchema = z
67
+ .object({
68
+ id: z
69
+ .string()
70
+ .openapi({ description: "CUID2 of the project file record." }),
71
+ postId: z.string().openapi({
72
+ description: "CUID2 of the post this file belongs to.",
73
+ }),
74
+ fileId: z.string().openapi({ description: "CUID2 of the linked file." }),
75
+ order: z.number().int().openapi({
76
+ description: "Order index of the file in the project.",
77
+ example: 1,
78
+ }),
79
+ })
80
+ .openapi({
81
+ title: "Post File Entity",
82
+ description: "Schema representing a file associated with a project.",
83
+ });
84
+
85
+ export const PostWithFilesEntitySchema = PostEntitySchema.extend({
86
+ postFiles: z
87
+ .array(
88
+ PostFileEntitySchema.extend({
89
+ url: z.url(),
90
+ }),
91
+ )
92
+ .optional()
93
+ .openapi({ description: "Files associated with the project." }),
94
+ });
95
+
96
+ export const CreatePostInputSchema = z.object({
97
+ id: z.cuid2(),
98
+ parentId: z
99
+ .cuid2({ message: "Invalid parentId" })
100
+ .optional()
101
+ .openapi({ description: "Parent id", example: "ckl1a2b3c0000abc" }),
102
+ parentType: z.enum(ACTIVITY_PARENT_TYPES).default(ACTIVITY_PARENT_TYPES.POST),
103
+ content: z
104
+ .string()
105
+ .max(500, { message: "Post content cannot exceed 500 characters" })
106
+ .optional()
107
+ .openapi({
108
+ description: "Post content",
109
+ example: "New project announcement",
110
+ }),
111
+
112
+ postType: z
113
+ .enum(POST_TYPES)
114
+ .default("DEFAULT_POST")
115
+ .openapi({ description: "Post type", example: "PROJECT" }),
116
+
117
+ files: z
118
+ .array(
119
+ CreateFileInputSchema.extend({
120
+ order: z
121
+ .number()
122
+ .int({ message: "File order must be an integer" })
123
+
124
+ .max(5, { message: "File order cannot exceed 5" })
125
+ .default(1),
126
+ }),
127
+ )
128
+ .max(5, { message: "Cannot attach more than 5 files" })
129
+ .optional(),
130
+
131
+ tags: z
132
+ .array(z.string().min(1, { message: "Tag cannot be empty" }))
133
+ .max(3, { message: "Cannot add more than 3 tags" })
134
+ .optional(),
135
+ badge: z.enum(POST_BADGE_TYPES).optional(),
136
+ linkMeta: z
137
+ .object({
138
+ url: z.url({ message: "Invalid URL format" }),
139
+ title: z
140
+ .string()
141
+ .max(200, { message: "Title cannot exceed 200 characters" })
142
+ .optional(),
143
+ description: z
144
+ .string()
145
+ .max(500, {
146
+ message: "Description cannot exceed 500 characters",
147
+ })
148
+ .optional(),
149
+ image: z.url({ message: "Invalid image URL" }).optional(),
150
+ })
151
+ .optional()
152
+ .openapi({
153
+ description: "Optional metadata for a single link in the post",
154
+ example: {
155
+ url: "https://example.com",
156
+ title: "Example Website",
157
+ description: "This is an example link",
158
+ image: "https://example.com/preview.jpg",
159
+ },
160
+ }),
161
+ });
162
+
163
+ export const CreatePostOutputSchema = PostEntitySchema;
164
+ export const GetPostOutputSchema = PostWithFilesEntitySchema;
165
+ export const PostIdSchema = z.object({ postId: z.cuid2() });
166
+ export const MinimalPostSchema = PostEntitySchema.pick({
167
+ id: true,
168
+ parentId: true,
169
+ content: true,
170
+ });
171
+
172
+ export const PostWithLikesEntitySchema = MinimalPostSchema.extend({
173
+ likes: z.array(
174
+ ActivitySchema.extend({
175
+ followsYou: z.boolean().optional(),
176
+ isFollowing: z.boolean().optional(),
177
+ }),
178
+ ),
179
+ }).openapi({
180
+ title: "PostWithPostLikesEntity",
181
+ });
182
+
183
+ export const GetPostWithLikesOutputSchema = PostWithLikesEntitySchema.extend({
184
+ nextCursor: z.string().optional().nullable(),
185
+ });
186
+
187
+ export const PostWithCommentsEntitySchema = MinimalPostSchema.extend({
188
+ comments: z.array(CommentEntitySchema),
189
+ }).openapi({
190
+ title: "PostWithPostCommentsEntity",
191
+ });
192
+
193
+ export const GetPostWithCommentsOutputSchema =
194
+ PostWithCommentsEntitySchema.extend({
195
+ nextCursor: z.string().optional().nullable(),
196
+ });
197
+
198
+ export const PostWithBookmarksEntitySchema = MinimalPostSchema.extend({
199
+ bookmarks: z.array(ActivitySchema),
200
+ }).openapi({
201
+ title: "PostWithPostBookmarksEntity",
202
+ });
203
+
204
+ export const GetPostWithBookmarksOutputSchema =
205
+ PostWithBookmarksEntitySchema.extend({
206
+ totalNo: z.number().int(),
207
+ });
208
+
209
+ export const LinkPreviewInputSchema = z.object({
210
+ url: z.string(),
211
+ });
212
+
213
+ export const LinkPreviewOutputSchema = z.object({
214
+ title: z.string(),
215
+ description: z.string().optional(),
216
+ image: z.string().optional(),
217
+ url: z.string().optional(),
218
+ });
219
+
220
+ export const FeedPostEntitySchema = PostWithFilesEntitySchema.extend({
221
+ stats: EntityStatsSchema,
222
+ score: z.number(),
223
+ isLiked: z.boolean().optional(),
224
+ isFollowing: z.boolean().optional(),
225
+ isBookmarked: z.boolean().optional(),
226
+ });
227
+
228
+ export const GetFeedInputSchema = z.object({
229
+ limit: z.number().optional(),
230
+ cursor: z.string().optional(),
231
+ });
232
+
233
+ export const GetFeedOutputSchema = z.object({
234
+ feed: z.array(FeedPostEntitySchema),
235
+ nextCursor: z.string().optional().nullable(),
236
+ });
237
+
238
+ export const SearchPostInputSchema = z.object({
239
+ queryString: z
240
+ .string()
241
+ .min(1, { message: "Search string cannot be empty" })
242
+ .max(200, { message: "Search string cannot exceed 200 characters" }),
243
+ cursor: z.string().optional(),
244
+ });
245
+
246
+ export const SearchPostOutputSchema = z.object({
247
+ posts: z.array(FeedPostEntitySchema),
248
+ nextCursor: z.string().optional().nullable(),
249
+ });
250
+
251
+ export const ReportPostInputSchema = z.object({
252
+ complaint: z
253
+ .string()
254
+ .max(200, { error: "Complaint cannot be longer than 200 characters" }),
255
+ });
256
+
257
+ export const PostAnalyticsOutputSchema = z.object({
258
+ awareness: z.object({
259
+ reach: z.number(),
260
+ impressions: z.number(),
261
+ newFollowers: z.number(),
262
+ }),
263
+ engagement: z.object({
264
+ rate: z.number(),
265
+ likes: z.number(),
266
+ comments: z.number(),
267
+ bookmarks: z.number(),
268
+ }),
269
+ behavior: z.object({
270
+ viralityScore: z.number(),
271
+ frictionRatio: z.number(),
272
+ consumptionDepth: z.number(),
273
+ sentiment: z.object({
274
+ positive: z.number(),
275
+ negative: z.number(),
276
+ status: z.enum(["Healthy", "Polarizing"]),
277
+ }),
278
+ }),
279
+ });