@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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/constants.ts +483 -483
- package/src/index.ts +4 -4
- package/src/schemas/activity.ts +14 -14
- package/src/schemas/auth.ts +43 -43
- package/src/schemas/bookmark.ts +38 -38
- package/src/schemas/brand.ts +146 -146
- package/src/schemas/chat.ts +31 -31
- package/src/schemas/comment.ts +60 -60
- package/src/schemas/common.ts +22 -22
- package/src/schemas/creative.ts +222 -222
- package/src/schemas/discipline.ts +88 -88
- package/src/schemas/entity-stats.ts +43 -43
- package/src/schemas/feed.ts +11 -11
- package/src/schemas/file.ts +61 -61
- package/src/schemas/index.ts +21 -21
- package/src/schemas/investor.ts +211 -211
- package/src/schemas/job-application.ts +257 -257
- package/src/schemas/job.ts +364 -364
- package/src/schemas/like.ts +38 -38
- package/src/schemas/message.ts +112 -112
- package/src/schemas/notification.ts +71 -71
- package/src/schemas/post.ts +279 -279
- package/src/schemas/project.ts +298 -298
- package/src/schemas/user-strike.ts +21 -21
- package/src/schemas/user.ts +283 -283
- package/src/schemas/username.ts +11 -11
- package/src/schemas/view.ts +50 -50
- package/src/types/auth.ts +5 -5
- package/src/types/bookmark.ts +4 -4
- package/src/types/brand.ts +37 -37
- package/src/types/chat.ts +21 -21
- package/src/types/comment.ts +12 -12
- package/src/types/common.ts +9 -9
- package/src/types/creative.ts +33 -33
- package/src/types/discipline.ts +32 -32
- package/src/types/entity-stats.ts +4 -4
- package/src/types/feed.ts +5 -5
- package/src/types/file.ts +39 -39
- package/src/types/index.ts +22 -22
- package/src/types/investor.ts +34 -34
- package/src/types/job-application.ts +41 -41
- package/src/types/job.ts +71 -71
- package/src/types/like.ts +3 -3
- package/src/types/message.ts +23 -23
- package/src/types/notification.ts +34 -34
- package/src/types/post.ts +63 -63
- package/src/types/project.ts +65 -65
- package/src/types/user-strike.ts +10 -10
- package/src/types/user.ts +96 -96
- package/src/types/username.ts +4 -4
- package/src/utils/slugify.ts +10 -10
- package/tsconfig.json +13 -13
package/src/schemas/user.ts
CHANGED
|
@@ -1,283 +1,283 @@
|
|
|
1
|
-
import { z } from "@hono/zod-openapi";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ROLES,
|
|
5
|
-
USER_STATUSES,
|
|
6
|
-
ONBOARDING_PAGES,
|
|
7
|
-
ACTIVITY_TYPES,
|
|
8
|
-
ACTIVITY_PARENT_TYPES,
|
|
9
|
-
} from "../constants";
|
|
10
|
-
import type {
|
|
11
|
-
Role,
|
|
12
|
-
UserStatus,
|
|
13
|
-
OnboardingPage,
|
|
14
|
-
ActivityType,
|
|
15
|
-
ActivityParentType,
|
|
16
|
-
} from "../constants";
|
|
17
|
-
import { ProjectEntitySchema } from "./project";
|
|
18
|
-
import { BookmarkEntitySchema } from "./bookmark";
|
|
19
|
-
import { LikeEntitySchema } from "./like";
|
|
20
|
-
import { BrandEntitySchema } from "./brand";
|
|
21
|
-
import { CreativeEntitySchema } from "./creative";
|
|
22
|
-
import { InvestorEntitySchema } from "./investor";
|
|
23
|
-
import { PostEntitySchema, PostWithFilesEntitySchema } from "./post";
|
|
24
|
-
|
|
25
|
-
export const UserEntitySchema = z
|
|
26
|
-
.object({
|
|
27
|
-
id: z.cuid2().openapi({ example: "cksd0v6q0000s9a5y8z7p3x9" }),
|
|
28
|
-
email: z.email().openapi({ example: "user@example.com" }),
|
|
29
|
-
emailVerified: z.boolean().openapi({ example: true }),
|
|
30
|
-
name: z.string().optional().openapi({ example: "John Doe" }),
|
|
31
|
-
image: z
|
|
32
|
-
.string()
|
|
33
|
-
.optional()
|
|
34
|
-
.openapi({ example: "https://example.com/avatar.png" }),
|
|
35
|
-
username: z.string().optional().openapi({ example: "johndoe" }),
|
|
36
|
-
displayUsername: z.string().optional().openapi({ example: "@johndoe" }),
|
|
37
|
-
role: z.enum(Object.values(ROLES) as [Role, ...Role[]]).openapi({
|
|
38
|
-
example: "CREATIVE",
|
|
39
|
-
}),
|
|
40
|
-
status: z
|
|
41
|
-
.enum(Object.values(USER_STATUSES) as [UserStatus, ...UserStatus[]])
|
|
42
|
-
.openapi({
|
|
43
|
-
example: "ACTIVE",
|
|
44
|
-
}),
|
|
45
|
-
onboardingPage: z
|
|
46
|
-
.enum(
|
|
47
|
-
Object.values(ONBOARDING_PAGES) as [
|
|
48
|
-
OnboardingPage,
|
|
49
|
-
...OnboardingPage[],
|
|
50
|
-
],
|
|
51
|
-
)
|
|
52
|
-
.openapi({
|
|
53
|
-
example: "DONE",
|
|
54
|
-
}),
|
|
55
|
-
createdAt: z.coerce
|
|
56
|
-
.date()
|
|
57
|
-
.openapi({ example: "2025-10-13T09:00:00.000Z" }),
|
|
58
|
-
version: z.int(),
|
|
59
|
-
updatedAt: z.coerce
|
|
60
|
-
.date()
|
|
61
|
-
.openapi({ example: "2025-10-13T09:00:00.000Z" }),
|
|
62
|
-
})
|
|
63
|
-
.openapi("BaseUserEntity");
|
|
64
|
-
|
|
65
|
-
export const MinimalUserSchema = UserEntitySchema.pick({
|
|
66
|
-
id: true,
|
|
67
|
-
name: true,
|
|
68
|
-
email: true,
|
|
69
|
-
image: true,
|
|
70
|
-
username: true,
|
|
71
|
-
role: true,
|
|
72
|
-
}).openapi("MinimalUser");
|
|
73
|
-
|
|
74
|
-
export const UserStatsEntitySchema = z.object({
|
|
75
|
-
followerCount: z.int(),
|
|
76
|
-
followingCount: z.int(),
|
|
77
|
-
followingIds: z.array(z.string()),
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
export const UserProfileEntitySchema = UserEntitySchema.extend({
|
|
81
|
-
profileType: z.enum(["creative", "brand", "investor"]).optional(),
|
|
82
|
-
brand: BrandEntitySchema,
|
|
83
|
-
creative: CreativeEntitySchema,
|
|
84
|
-
investor: InvestorEntitySchema,
|
|
85
|
-
}).openapi("UserProfileEntity");
|
|
86
|
-
|
|
87
|
-
export const UserWithProjectsEntitySchema = z
|
|
88
|
-
.object({
|
|
89
|
-
userId: z.cuid2(),
|
|
90
|
-
projects: z.array(ProjectEntitySchema.omit({ overview: true })),
|
|
91
|
-
})
|
|
92
|
-
.openapi("UserWithProjectsEntity");
|
|
93
|
-
|
|
94
|
-
export const UserWithProjectLikesEntitySchema = z.object({
|
|
95
|
-
userId: z.cuid2(),
|
|
96
|
-
projectLikes: z.array(
|
|
97
|
-
LikeEntitySchema.extend({
|
|
98
|
-
project: ProjectEntitySchema.pick({
|
|
99
|
-
id: true,
|
|
100
|
-
title: true,
|
|
101
|
-
description: true,
|
|
102
|
-
tags: true,
|
|
103
|
-
startDate: true,
|
|
104
|
-
endDate: true,
|
|
105
|
-
imagePlaceholderUrl: true,
|
|
106
|
-
}),
|
|
107
|
-
}),
|
|
108
|
-
),
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
export const UserWithPostLikesEntitySchema = z.object({
|
|
112
|
-
userId: z.cuid2(),
|
|
113
|
-
postLikes: z.array(
|
|
114
|
-
LikeEntitySchema.extend({
|
|
115
|
-
post: PostEntitySchema.pick({
|
|
116
|
-
id: true,
|
|
117
|
-
parentId: true,
|
|
118
|
-
title: true,
|
|
119
|
-
content: true,
|
|
120
|
-
tags: true,
|
|
121
|
-
createdAt: true,
|
|
122
|
-
updatedAt: true,
|
|
123
|
-
}),
|
|
124
|
-
}),
|
|
125
|
-
),
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
export const UserWithPostBookmarksEntitySchema = z.object({
|
|
129
|
-
userId: z.cuid2(),
|
|
130
|
-
postBookmarks: z.array(
|
|
131
|
-
BookmarkEntitySchema.extend({
|
|
132
|
-
post: PostEntitySchema.pick({
|
|
133
|
-
id: true,
|
|
134
|
-
parentId: true,
|
|
135
|
-
title: true,
|
|
136
|
-
content: true,
|
|
137
|
-
tags: true,
|
|
138
|
-
createdAt: true,
|
|
139
|
-
updatedAt: true,
|
|
140
|
-
}),
|
|
141
|
-
}),
|
|
142
|
-
),
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
export const UserWithProjectBookmarksEntitySchema = z
|
|
146
|
-
.object({
|
|
147
|
-
userId: z.cuid2(),
|
|
148
|
-
projectBookmarks: z.array(
|
|
149
|
-
BookmarkEntitySchema.extend({
|
|
150
|
-
project: ProjectEntitySchema.pick({
|
|
151
|
-
id: true,
|
|
152
|
-
title: true,
|
|
153
|
-
description: true,
|
|
154
|
-
tags: true,
|
|
155
|
-
startDate: true,
|
|
156
|
-
endDate: true,
|
|
157
|
-
imagePlaceholderUrl: true,
|
|
158
|
-
}),
|
|
159
|
-
}),
|
|
160
|
-
),
|
|
161
|
-
})
|
|
162
|
-
.openapi("UserWithProjectBookmarksEntity");
|
|
163
|
-
|
|
164
|
-
export const GetUserFollowingInputSchema = z.object({
|
|
165
|
-
searchQuery: z.string().optional().openapi({ example: "design systems" }),
|
|
166
|
-
offset: z.number().int().nonnegative().optional().openapi({ example: 20 }),
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
export const GetUserFollowersInputSchema = z.object({
|
|
170
|
-
searchQuery: z.string().optional().openapi({ example: "design systems" }),
|
|
171
|
-
offset: z.number().int().nonnegative().optional().openapi({ example: 20 }),
|
|
172
|
-
});
|
|
173
|
-
export const UserWithFollowingEntitySchema = MinimalUserSchema.extend({
|
|
174
|
-
following: z
|
|
175
|
-
.array(
|
|
176
|
-
MinimalUserSchema.extend({
|
|
177
|
-
isFollowing: z.boolean().optional(),
|
|
178
|
-
followsYou: z.boolean().optional(),
|
|
179
|
-
}),
|
|
180
|
-
)
|
|
181
|
-
.openapi({ description: "List of users this user is following." }),
|
|
182
|
-
}).openapi("UserWithFollowingEntity");
|
|
183
|
-
|
|
184
|
-
export const UserWithFollowersEntitySchema = MinimalUserSchema.extend({
|
|
185
|
-
followers: z
|
|
186
|
-
.array(
|
|
187
|
-
MinimalUserSchema.extend({
|
|
188
|
-
isFollowing: z.boolean().optional(),
|
|
189
|
-
followsYou: z.boolean().optional(),
|
|
190
|
-
}),
|
|
191
|
-
)
|
|
192
|
-
.openapi({ description: "List of users who follow this user." }),
|
|
193
|
-
}).openapi("UserWithFollowersEntity");
|
|
194
|
-
|
|
195
|
-
export const GetUserFollowersOutputSchema = z.object({
|
|
196
|
-
nextCursor: z.string(),
|
|
197
|
-
followers: z.array(
|
|
198
|
-
MinimalUserSchema.extend({
|
|
199
|
-
isFollowing: z.boolean().optional(),
|
|
200
|
-
followsYou: z.boolean().optional(),
|
|
201
|
-
}),
|
|
202
|
-
),
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
export const GetUserFollowingOutputSchema = z.object({
|
|
206
|
-
nextCursor: z.string(),
|
|
207
|
-
following: z.array(
|
|
208
|
-
MinimalUserSchema.extend({
|
|
209
|
-
isFollowing: z.boolean().optional(),
|
|
210
|
-
followsYou: z.boolean().optional(),
|
|
211
|
-
}),
|
|
212
|
-
),
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
export const UserWithPostsEntitySchema = z
|
|
216
|
-
.object({
|
|
217
|
-
userId: z.cuid2(),
|
|
218
|
-
posts: z.array(PostWithFilesEntitySchema),
|
|
219
|
-
})
|
|
220
|
-
.openapi("UserWithPostsEntity");
|
|
221
|
-
|
|
222
|
-
export const GetAuthenticatedUserOutputSchema = UserEntitySchema;
|
|
223
|
-
|
|
224
|
-
export const GetAuthenticatedUserProfileOutputSchema = UserProfileEntitySchema;
|
|
225
|
-
|
|
226
|
-
export const GetAuthenticatedUserWithProjectsOutputSchema =
|
|
227
|
-
UserWithProjectsEntitySchema;
|
|
228
|
-
|
|
229
|
-
export const GetAuthenticatedUserWithProjectBookmarksOutputSchema =
|
|
230
|
-
UserWithProjectBookmarksEntitySchema;
|
|
231
|
-
|
|
232
|
-
export const GetAuthenticatedUserWithUserFollowingOutputSchema =
|
|
233
|
-
UserWithFollowingEntitySchema;
|
|
234
|
-
|
|
235
|
-
export const GetAuthenticatedUserWithUserFollowersOutputSchema =
|
|
236
|
-
UserWithFollowersEntitySchema;
|
|
237
|
-
|
|
238
|
-
export const GetAuthenticatedUserWithProjectLikesOutputSchema =
|
|
239
|
-
UserWithProjectLikesEntitySchema;
|
|
240
|
-
|
|
241
|
-
export const GetUserActivityInputSchema = z.object({
|
|
242
|
-
activityType: z.enum(
|
|
243
|
-
Object.values(ACTIVITY_TYPES) as [ActivityType, ...ActivityType[]],
|
|
244
|
-
),
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
export const GetUserActivityOutputSchema = z.array(
|
|
248
|
-
z.object({
|
|
249
|
-
parentId: z.string(),
|
|
250
|
-
parentType: z.enum(
|
|
251
|
-
Object.values(ACTIVITY_PARENT_TYPES) as [
|
|
252
|
-
ActivityParentType,
|
|
253
|
-
...ActivityParentType[],
|
|
254
|
-
],
|
|
255
|
-
),
|
|
256
|
-
}),
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
export const SearchUsersInputSchema = z.object({
|
|
260
|
-
query: z.string().default("").openapi({
|
|
261
|
-
example: "john",
|
|
262
|
-
description: "Search by name, email, username, or discipline",
|
|
263
|
-
}),
|
|
264
|
-
role: z.enum(Object.values(ROLES) as [Role, ...Role[]]).optional(),
|
|
265
|
-
limit: z.coerce
|
|
266
|
-
.number()
|
|
267
|
-
.min(1)
|
|
268
|
-
.max(100)
|
|
269
|
-
.default(20)
|
|
270
|
-
.openapi({ example: 20 }),
|
|
271
|
-
cursor: z.string().optional().openapi({
|
|
272
|
-
example: 0,
|
|
273
|
-
description: "The offset/cursor for pagination",
|
|
274
|
-
}),
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
export const SearchUsersOutputSchema = z.object({
|
|
278
|
-
users: z.array(MinimalUserSchema),
|
|
279
|
-
nextCursor: z.string().optional().openapi({
|
|
280
|
-
example: "abc123",
|
|
281
|
-
description: "The next cursor for pagination",
|
|
282
|
-
}),
|
|
283
|
-
});
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ROLES,
|
|
5
|
+
USER_STATUSES,
|
|
6
|
+
ONBOARDING_PAGES,
|
|
7
|
+
ACTIVITY_TYPES,
|
|
8
|
+
ACTIVITY_PARENT_TYPES,
|
|
9
|
+
} from "../constants";
|
|
10
|
+
import type {
|
|
11
|
+
Role,
|
|
12
|
+
UserStatus,
|
|
13
|
+
OnboardingPage,
|
|
14
|
+
ActivityType,
|
|
15
|
+
ActivityParentType,
|
|
16
|
+
} from "../constants";
|
|
17
|
+
import { ProjectEntitySchema } from "./project";
|
|
18
|
+
import { BookmarkEntitySchema } from "./bookmark";
|
|
19
|
+
import { LikeEntitySchema } from "./like";
|
|
20
|
+
import { BrandEntitySchema } from "./brand";
|
|
21
|
+
import { CreativeEntitySchema } from "./creative";
|
|
22
|
+
import { InvestorEntitySchema } from "./investor";
|
|
23
|
+
import { PostEntitySchema, PostWithFilesEntitySchema } from "./post";
|
|
24
|
+
|
|
25
|
+
export const UserEntitySchema = z
|
|
26
|
+
.object({
|
|
27
|
+
id: z.cuid2().openapi({ example: "cksd0v6q0000s9a5y8z7p3x9" }),
|
|
28
|
+
email: z.email().openapi({ example: "user@example.com" }),
|
|
29
|
+
emailVerified: z.boolean().openapi({ example: true }),
|
|
30
|
+
name: z.string().optional().openapi({ example: "John Doe" }),
|
|
31
|
+
image: z
|
|
32
|
+
.string()
|
|
33
|
+
.optional()
|
|
34
|
+
.openapi({ example: "https://example.com/avatar.png" }),
|
|
35
|
+
username: z.string().optional().openapi({ example: "johndoe" }),
|
|
36
|
+
displayUsername: z.string().optional().openapi({ example: "@johndoe" }),
|
|
37
|
+
role: z.enum(Object.values(ROLES) as [Role, ...Role[]]).openapi({
|
|
38
|
+
example: "CREATIVE",
|
|
39
|
+
}),
|
|
40
|
+
status: z
|
|
41
|
+
.enum(Object.values(USER_STATUSES) as [UserStatus, ...UserStatus[]])
|
|
42
|
+
.openapi({
|
|
43
|
+
example: "ACTIVE",
|
|
44
|
+
}),
|
|
45
|
+
onboardingPage: z
|
|
46
|
+
.enum(
|
|
47
|
+
Object.values(ONBOARDING_PAGES) as [
|
|
48
|
+
OnboardingPage,
|
|
49
|
+
...OnboardingPage[],
|
|
50
|
+
],
|
|
51
|
+
)
|
|
52
|
+
.openapi({
|
|
53
|
+
example: "DONE",
|
|
54
|
+
}),
|
|
55
|
+
createdAt: z.coerce
|
|
56
|
+
.date()
|
|
57
|
+
.openapi({ example: "2025-10-13T09:00:00.000Z" }),
|
|
58
|
+
version: z.int(),
|
|
59
|
+
updatedAt: z.coerce
|
|
60
|
+
.date()
|
|
61
|
+
.openapi({ example: "2025-10-13T09:00:00.000Z" }),
|
|
62
|
+
})
|
|
63
|
+
.openapi("BaseUserEntity");
|
|
64
|
+
|
|
65
|
+
export const MinimalUserSchema = UserEntitySchema.pick({
|
|
66
|
+
id: true,
|
|
67
|
+
name: true,
|
|
68
|
+
email: true,
|
|
69
|
+
image: true,
|
|
70
|
+
username: true,
|
|
71
|
+
role: true,
|
|
72
|
+
}).openapi("MinimalUser");
|
|
73
|
+
|
|
74
|
+
export const UserStatsEntitySchema = z.object({
|
|
75
|
+
followerCount: z.int(),
|
|
76
|
+
followingCount: z.int(),
|
|
77
|
+
followingIds: z.array(z.string()),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export const UserProfileEntitySchema = UserEntitySchema.extend({
|
|
81
|
+
profileType: z.enum(["creative", "brand", "investor"]).optional(),
|
|
82
|
+
brand: BrandEntitySchema,
|
|
83
|
+
creative: CreativeEntitySchema,
|
|
84
|
+
investor: InvestorEntitySchema,
|
|
85
|
+
}).openapi("UserProfileEntity");
|
|
86
|
+
|
|
87
|
+
export const UserWithProjectsEntitySchema = z
|
|
88
|
+
.object({
|
|
89
|
+
userId: z.cuid2(),
|
|
90
|
+
projects: z.array(ProjectEntitySchema.omit({ overview: true })),
|
|
91
|
+
})
|
|
92
|
+
.openapi("UserWithProjectsEntity");
|
|
93
|
+
|
|
94
|
+
export const UserWithProjectLikesEntitySchema = z.object({
|
|
95
|
+
userId: z.cuid2(),
|
|
96
|
+
projectLikes: z.array(
|
|
97
|
+
LikeEntitySchema.extend({
|
|
98
|
+
project: ProjectEntitySchema.pick({
|
|
99
|
+
id: true,
|
|
100
|
+
title: true,
|
|
101
|
+
description: true,
|
|
102
|
+
tags: true,
|
|
103
|
+
startDate: true,
|
|
104
|
+
endDate: true,
|
|
105
|
+
imagePlaceholderUrl: true,
|
|
106
|
+
}),
|
|
107
|
+
}),
|
|
108
|
+
),
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export const UserWithPostLikesEntitySchema = z.object({
|
|
112
|
+
userId: z.cuid2(),
|
|
113
|
+
postLikes: z.array(
|
|
114
|
+
LikeEntitySchema.extend({
|
|
115
|
+
post: PostEntitySchema.pick({
|
|
116
|
+
id: true,
|
|
117
|
+
parentId: true,
|
|
118
|
+
title: true,
|
|
119
|
+
content: true,
|
|
120
|
+
tags: true,
|
|
121
|
+
createdAt: true,
|
|
122
|
+
updatedAt: true,
|
|
123
|
+
}),
|
|
124
|
+
}),
|
|
125
|
+
),
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export const UserWithPostBookmarksEntitySchema = z.object({
|
|
129
|
+
userId: z.cuid2(),
|
|
130
|
+
postBookmarks: z.array(
|
|
131
|
+
BookmarkEntitySchema.extend({
|
|
132
|
+
post: PostEntitySchema.pick({
|
|
133
|
+
id: true,
|
|
134
|
+
parentId: true,
|
|
135
|
+
title: true,
|
|
136
|
+
content: true,
|
|
137
|
+
tags: true,
|
|
138
|
+
createdAt: true,
|
|
139
|
+
updatedAt: true,
|
|
140
|
+
}),
|
|
141
|
+
}),
|
|
142
|
+
),
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export const UserWithProjectBookmarksEntitySchema = z
|
|
146
|
+
.object({
|
|
147
|
+
userId: z.cuid2(),
|
|
148
|
+
projectBookmarks: z.array(
|
|
149
|
+
BookmarkEntitySchema.extend({
|
|
150
|
+
project: ProjectEntitySchema.pick({
|
|
151
|
+
id: true,
|
|
152
|
+
title: true,
|
|
153
|
+
description: true,
|
|
154
|
+
tags: true,
|
|
155
|
+
startDate: true,
|
|
156
|
+
endDate: true,
|
|
157
|
+
imagePlaceholderUrl: true,
|
|
158
|
+
}),
|
|
159
|
+
}),
|
|
160
|
+
),
|
|
161
|
+
})
|
|
162
|
+
.openapi("UserWithProjectBookmarksEntity");
|
|
163
|
+
|
|
164
|
+
export const GetUserFollowingInputSchema = z.object({
|
|
165
|
+
searchQuery: z.string().optional().openapi({ example: "design systems" }),
|
|
166
|
+
offset: z.number().int().nonnegative().optional().openapi({ example: 20 }),
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
export const GetUserFollowersInputSchema = z.object({
|
|
170
|
+
searchQuery: z.string().optional().openapi({ example: "design systems" }),
|
|
171
|
+
offset: z.number().int().nonnegative().optional().openapi({ example: 20 }),
|
|
172
|
+
});
|
|
173
|
+
export const UserWithFollowingEntitySchema = MinimalUserSchema.extend({
|
|
174
|
+
following: z
|
|
175
|
+
.array(
|
|
176
|
+
MinimalUserSchema.extend({
|
|
177
|
+
isFollowing: z.boolean().optional(),
|
|
178
|
+
followsYou: z.boolean().optional(),
|
|
179
|
+
}),
|
|
180
|
+
)
|
|
181
|
+
.openapi({ description: "List of users this user is following." }),
|
|
182
|
+
}).openapi("UserWithFollowingEntity");
|
|
183
|
+
|
|
184
|
+
export const UserWithFollowersEntitySchema = MinimalUserSchema.extend({
|
|
185
|
+
followers: z
|
|
186
|
+
.array(
|
|
187
|
+
MinimalUserSchema.extend({
|
|
188
|
+
isFollowing: z.boolean().optional(),
|
|
189
|
+
followsYou: z.boolean().optional(),
|
|
190
|
+
}),
|
|
191
|
+
)
|
|
192
|
+
.openapi({ description: "List of users who follow this user." }),
|
|
193
|
+
}).openapi("UserWithFollowersEntity");
|
|
194
|
+
|
|
195
|
+
export const GetUserFollowersOutputSchema = z.object({
|
|
196
|
+
nextCursor: z.string(),
|
|
197
|
+
followers: z.array(
|
|
198
|
+
MinimalUserSchema.extend({
|
|
199
|
+
isFollowing: z.boolean().optional(),
|
|
200
|
+
followsYou: z.boolean().optional(),
|
|
201
|
+
}),
|
|
202
|
+
),
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
export const GetUserFollowingOutputSchema = z.object({
|
|
206
|
+
nextCursor: z.string(),
|
|
207
|
+
following: z.array(
|
|
208
|
+
MinimalUserSchema.extend({
|
|
209
|
+
isFollowing: z.boolean().optional(),
|
|
210
|
+
followsYou: z.boolean().optional(),
|
|
211
|
+
}),
|
|
212
|
+
),
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
export const UserWithPostsEntitySchema = z
|
|
216
|
+
.object({
|
|
217
|
+
userId: z.cuid2(),
|
|
218
|
+
posts: z.array(PostWithFilesEntitySchema),
|
|
219
|
+
})
|
|
220
|
+
.openapi("UserWithPostsEntity");
|
|
221
|
+
|
|
222
|
+
export const GetAuthenticatedUserOutputSchema = UserEntitySchema;
|
|
223
|
+
|
|
224
|
+
export const GetAuthenticatedUserProfileOutputSchema = UserProfileEntitySchema;
|
|
225
|
+
|
|
226
|
+
export const GetAuthenticatedUserWithProjectsOutputSchema =
|
|
227
|
+
UserWithProjectsEntitySchema;
|
|
228
|
+
|
|
229
|
+
export const GetAuthenticatedUserWithProjectBookmarksOutputSchema =
|
|
230
|
+
UserWithProjectBookmarksEntitySchema;
|
|
231
|
+
|
|
232
|
+
export const GetAuthenticatedUserWithUserFollowingOutputSchema =
|
|
233
|
+
UserWithFollowingEntitySchema;
|
|
234
|
+
|
|
235
|
+
export const GetAuthenticatedUserWithUserFollowersOutputSchema =
|
|
236
|
+
UserWithFollowersEntitySchema;
|
|
237
|
+
|
|
238
|
+
export const GetAuthenticatedUserWithProjectLikesOutputSchema =
|
|
239
|
+
UserWithProjectLikesEntitySchema;
|
|
240
|
+
|
|
241
|
+
export const GetUserActivityInputSchema = z.object({
|
|
242
|
+
activityType: z.enum(
|
|
243
|
+
Object.values(ACTIVITY_TYPES) as [ActivityType, ...ActivityType[]],
|
|
244
|
+
),
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
export const GetUserActivityOutputSchema = z.array(
|
|
248
|
+
z.object({
|
|
249
|
+
parentId: z.string(),
|
|
250
|
+
parentType: z.enum(
|
|
251
|
+
Object.values(ACTIVITY_PARENT_TYPES) as [
|
|
252
|
+
ActivityParentType,
|
|
253
|
+
...ActivityParentType[],
|
|
254
|
+
],
|
|
255
|
+
),
|
|
256
|
+
}),
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
export const SearchUsersInputSchema = z.object({
|
|
260
|
+
query: z.string().default("").openapi({
|
|
261
|
+
example: "john",
|
|
262
|
+
description: "Search by name, email, username, or discipline",
|
|
263
|
+
}),
|
|
264
|
+
role: z.enum(Object.values(ROLES) as [Role, ...Role[]]).optional(),
|
|
265
|
+
limit: z.coerce
|
|
266
|
+
.number()
|
|
267
|
+
.min(1)
|
|
268
|
+
.max(100)
|
|
269
|
+
.default(20)
|
|
270
|
+
.openapi({ example: 20 }),
|
|
271
|
+
cursor: z.string().optional().openapi({
|
|
272
|
+
example: 0,
|
|
273
|
+
description: "The offset/cursor for pagination",
|
|
274
|
+
}),
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
export const SearchUsersOutputSchema = z.object({
|
|
278
|
+
users: z.array(MinimalUserSchema),
|
|
279
|
+
nextCursor: z.string().optional().openapi({
|
|
280
|
+
example: "abc123",
|
|
281
|
+
description: "The next cursor for pagination",
|
|
282
|
+
}),
|
|
283
|
+
});
|
package/src/schemas/username.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { z } from "@hono/zod-openapi";
|
|
2
|
-
|
|
3
|
-
export const UsernameSchema = z.object({
|
|
4
|
-
username: z
|
|
5
|
-
.string()
|
|
6
|
-
.min(3, { message: "Username must be at least 3 characters" })
|
|
7
|
-
.max(32, { message: "Username must be at most 32 characters" })
|
|
8
|
-
.regex(/^[a-zA-Z0-9_]+$/, {
|
|
9
|
-
message: "Username may only contain letters, numbers, and underscores",
|
|
10
|
-
}),
|
|
11
|
-
});
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
|
|
3
|
+
export const UsernameSchema = z.object({
|
|
4
|
+
username: z
|
|
5
|
+
.string()
|
|
6
|
+
.min(3, { message: "Username must be at least 3 characters" })
|
|
7
|
+
.max(32, { message: "Username must be at most 32 characters" })
|
|
8
|
+
.regex(/^[a-zA-Z0-9_]+$/, {
|
|
9
|
+
message: "Username may only contain letters, numbers, and underscores",
|
|
10
|
+
}),
|
|
11
|
+
});
|