@zyacreatives/shared 2.5.50 → 2.5.52

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.
@@ -7,6 +7,7 @@ import {
7
7
  ACTIVITY_TYPES,
8
8
  ACTIVITY_PARENT_TYPES,
9
9
  } from "../constants";
10
+
10
11
  import type {
11
12
  Role,
12
13
  UserStatus,
@@ -26,48 +27,55 @@ import {
26
27
  PostEntitySchema,
27
28
  PostWithFilesEntitySchema,
28
29
  } from "./post";
29
- import { JobEntitySchema, JobSearchDocumentSchema } from "./job";
30
+ import { JobSearchDocumentSchema } from "./job";
30
31
  import { ProductEntitySchema } from "./product";
31
32
 
33
+ /**
34
+ * --------------------------------
35
+ * SHAPE
36
+ * --------------------------------
37
+ */
38
+
39
+ const UserShape = z.object({
40
+ email: z.email(),
41
+ emailVerified: z.boolean(),
42
+ name: z.string().default(""),
43
+ image: z.string().default(""),
44
+ username: z.string().default(""),
45
+ displayUsername: z.string().default(""),
46
+ role: z.enum(Object.values(ROLES) as [Role, ...Role[]]),
47
+ status: z.enum(Object.values(USER_STATUSES) as [UserStatus, ...UserStatus[]]),
48
+ onboardingPage: z.enum(
49
+ Object.values(ONBOARDING_PAGES) as [OnboardingPage, ...OnboardingPage[]],
50
+ ),
51
+ });
52
+
53
+ export type UserShapeType = z.infer<typeof UserShape>;
54
+
55
+ /**
56
+ * --------------------------------
57
+ * BASE ENTITY
58
+ * --------------------------------
59
+ */
60
+
32
61
  export const UserEntitySchema = z
33
62
  .object({
34
- id: z.cuid2().openapi({ example: "cksd0v6q0000s9a5y8z7p3x9" }),
35
- email: z.email().openapi({ example: "user@example.com" }),
36
- emailVerified: z.boolean().openapi({ example: true }),
37
- name: z.string().optional().openapi({ example: "John Doe" }),
38
- image: z
39
- .string()
40
- .optional()
41
- .openapi({ example: "https://example.com/avatar.png" }),
42
- username: z.string().optional().openapi({ example: "johndoe" }),
43
- displayUsername: z.string().optional().openapi({ example: "@johndoe" }),
44
- role: z.enum(Object.values(ROLES) as [Role, ...Role[]]).openapi({
45
- example: "CREATIVE",
46
- }),
47
- status: z
48
- .enum(Object.values(USER_STATUSES) as [UserStatus, ...UserStatus[]])
49
- .openapi({
50
- example: "ACTIVE",
51
- }),
52
- onboardingPage: z
53
- .enum(
54
- Object.values(ONBOARDING_PAGES) as [
55
- OnboardingPage,
56
- ...OnboardingPage[],
57
- ],
58
- )
59
- .openapi({
60
- example: "DONE",
61
- }),
62
- createdAt: z.coerce.date().openapi({ example: "2026-03-11T09:00:00.000Z" }),
63
- version: z.int().openapi({ example: 1 }),
64
- updatedAt: z.coerce.date().openapi({ example: "2026-03-11T09:00:00.000Z" }),
63
+ id: z.cuid2(),
64
+ ...UserShape.shape,
65
+ createdAt: z.iso.datetime(),
66
+ updatedAt: z.iso.datetime(),
67
+ version: z.int(),
65
68
  })
66
- .openapi("BaseUserEntity");
69
+ .openapi("User");
67
70
 
68
- export type BaseUserEntity = z.infer<typeof UserEntitySchema>;
69
71
  export type UserEntity = z.infer<typeof UserEntitySchema>;
70
72
 
73
+ /**
74
+ * --------------------------------
75
+ * DERIVED ENTITIES
76
+ * --------------------------------
77
+ */
78
+
71
79
  export const MinimalUserSchema = UserEntitySchema.pick({
72
80
  id: true,
73
81
  name: true,
@@ -80,164 +88,118 @@ export const MinimalUserSchema = UserEntitySchema.pick({
80
88
  export type MinimalUser = z.infer<typeof MinimalUserSchema>;
81
89
 
82
90
  export const UserProfileEntitySchema = UserEntitySchema.extend({
83
- profileType: z
84
- .enum(["creative", "brand", "investor"])
85
- .optional()
86
- .openapi({ example: "creative" }),
87
- brand: BrandEntitySchema,
88
- creative: CreativeEntitySchema,
89
- investor: InvestorEntitySchema,
90
- }).openapi("UserProfileEntity");
91
+ profileType: z.enum(["creative", "brand", "investor"]).optional(),
92
+ brand: BrandEntitySchema.optional(),
93
+ creative: CreativeEntitySchema.optional(),
94
+ investor: InvestorEntitySchema.optional(),
95
+ }).openapi("UserProfile");
91
96
 
92
97
  export type UserProfileEntity = z.infer<typeof UserProfileEntitySchema>;
93
98
 
94
99
  export const UserStatsEntitySchema = z.object({
95
- followerCount: z.int().openapi({ example: 1540 }),
96
- followingCount: z.int().openapi({ example: 234 }),
97
- followingIds: z
98
- .array(z.cuid2())
99
- .openapi({ example: ["cksd0v6q0000s9a5y8z7p3x9", "clm1a2b3c0000abc"] }),
100
+ followerCount: z.int(),
101
+ followingCount: z.int(),
102
+ followingIds: z.array(z.cuid2()),
100
103
  });
101
104
 
102
105
  export type UserStatsEntity = z.infer<typeof UserStatsEntitySchema>;
103
106
 
104
- export const UserWithProjectsEntitySchema = z
105
- .object({
106
- userId: z.cuid2().openapi({ example: "cksd0v6q0000s9a5y8z7p3x9" }),
107
- projects: z
108
- .array(ProjectEntitySchema.omit({ overview: true }))
109
- .openapi({ example: [] }),
110
- })
111
- .openapi("UserWithProjectsEntity");
107
+ /**
108
+ * --------------------------------
109
+ * COMPOSED ENTITIES
110
+ * --------------------------------
111
+ */
112
112
 
113
+ const UserWithId = z.object({ userId: z.cuid2() });
114
+ export type UserWithIdType = z.infer<typeof UserWithId>;
115
+
116
+ export const UserWithProjectsEntitySchema = UserWithId.extend({
117
+ projects: z.array(ProjectEntitySchema.omit({ overview: true })),
118
+ });
113
119
  export type UserWithProjectsEntity = z.infer<
114
120
  typeof UserWithProjectsEntitySchema
115
121
  >;
116
122
 
117
- export const UserWithPostsEntitySchema = z
118
- .object({
119
- userId: z.cuid2().openapi({ example: "cksd0v6q0000s9a5y8z7p3x9" }),
120
- posts: z.array(PostWithFilesEntitySchema).openapi({ example: [] }),
121
- })
122
- .openapi("UserWithPostsEntity");
123
-
124
- export type UserWithUserPostsEntity = z.infer<typeof UserWithPostsEntitySchema>;
125
-
126
- export const UserAuthStatusEntitySchema = z.object({
127
- exists: z.boolean(),
128
- isOAuthOnly: z.boolean(),
129
- providers: z.array(z.string()),
123
+ export const UserWithPostsEntitySchema = UserWithId.extend({
124
+ posts: z.array(PostWithFilesEntitySchema),
130
125
  });
131
-
132
- export type UserAuthStatusEntity = z.infer<typeof UserAuthStatusEntitySchema>;
133
-
134
- export const UserWithProjectLikesEntitySchema = z.object({
135
- userId: z.cuid2().openapi({ example: "cksd0v6q0000s9a5y8z7p3x9" }),
136
- projectLikes: z
137
- .array(
138
- LikeEntitySchema.extend({
139
- project: ProjectEntitySchema.pick({
140
- id: true,
141
- title: true,
142
- description: true,
143
- tags: true,
144
- startDate: true,
145
- endDate: true,
146
- imagePlaceholderUrl: true,
147
- }),
126
+ export type UserWithPostsEntity = z.infer<typeof UserWithPostsEntitySchema>;
127
+
128
+ export const UserWithProjectLikesEntitySchema = UserWithId.extend({
129
+ projectLikes: z.array(
130
+ LikeEntitySchema.extend({
131
+ project: ProjectEntitySchema.pick({
132
+ id: true,
133
+ title: true,
134
+ description: true,
135
+ tags: true,
136
+ startDate: true,
137
+ endDate: true,
138
+ imagePlaceholderUrl: true,
148
139
  }),
149
- )
150
- .openapi({ example: [] }),
140
+ }),
141
+ ),
151
142
  });
152
-
153
143
  export type UserWithProjectLikesEntity = z.infer<
154
144
  typeof UserWithProjectLikesEntitySchema
155
145
  >;
156
146
 
157
- export const UserWithPostLikesEntitySchema = z.object({
158
- userId: z.cuid2().openapi({ example: "cksd0v6q0000s9a5y8z7p3x9" }),
159
- postLikes: z
160
- .array(
161
- LikeEntitySchema.extend({
162
- post: PostEntitySchema.pick({
163
- id: true,
164
- parentId: true,
165
- title: true,
166
- content: true,
167
- tags: true,
168
- createdAt: true,
169
- updatedAt: true,
170
- }),
147
+ export const UserWithPostLikesEntitySchema = UserWithId.extend({
148
+ postLikes: z.array(
149
+ LikeEntitySchema.extend({
150
+ post: PostEntitySchema.pick({
151
+ id: true,
152
+ parentId: true,
153
+ title: true,
154
+ content: true,
155
+ tags: true,
156
+ createdAt: true,
157
+ updatedAt: true,
171
158
  }),
172
- )
173
- .openapi({ example: [] }),
159
+ }),
160
+ ),
174
161
  });
175
-
176
162
  export type UserWithPostLikesEntity = z.infer<
177
163
  typeof UserWithPostLikesEntitySchema
178
164
  >;
179
165
 
180
- export const UserWithJobBookmarksEntitySchema = z.object({
181
- userId: z.cuid2().openapi({ example: "afoaifaofi" }),
182
- jobBookmarks: z
183
- .array(
184
- BookmarkEntitySchema.extend({
185
- job: JobSearchDocumentSchema.extend({
186
- isBookmarked: z.boolean().default(true),
187
- }),
166
+ /**
167
+ * --------------------------------
168
+ * BOOKMARKS
169
+ * --------------------------------
170
+ */
171
+
172
+ export const UserWithJobBookmarksEntitySchema = UserWithId.extend({
173
+ jobBookmarks: z.array(
174
+ BookmarkEntitySchema.extend({
175
+ job: JobSearchDocumentSchema.extend({
176
+ isBookmarked: z.boolean().default(true),
188
177
  }),
189
- )
190
- .optional(),
178
+ }),
179
+ ),
191
180
  });
192
-
193
181
  export type UserWithJobBookmarksEntity = z.infer<
194
182
  typeof UserWithJobBookmarksEntitySchema
195
183
  >;
196
184
 
197
- export const UserWithJobBookmarksInputSchema = z.object({
198
- cursor: z.string().optional().nullable(),
199
- limit: z.int().positive().optional().nullable(),
200
- });
201
-
202
- export type UserWithJobBookmarksInput = z.infer<
203
- typeof UserWithJobBookmarksInputSchema
204
- >;
205
-
206
- export const UserWithJobBookmarksOutputSchema = z.object({
207
- bookmarks: UserWithJobBookmarksEntitySchema,
208
- nextCursor: z.string().nullable(),
185
+ export const UserWithProjectBookmarksEntitySchema = UserWithId.extend({
186
+ projectBookmarks: z.array(
187
+ BookmarkEntitySchema.extend({
188
+ project: ProjectSearchDocumentSchema,
189
+ }),
190
+ ),
209
191
  });
210
-
211
- export type UserWithJobBookmarksOutput = z.infer<
212
- typeof UserWithJobBookmarksOutputSchema
213
- >;
214
-
215
- export const UserWithProjectBookmarksEntitySchema = z
216
- .object({
217
- userId: z.cuid2().openapi({ example: "cksd0v6q0000s9a5y8z7p3x9" }),
218
- projectBookmarks: z
219
- .array(
220
- BookmarkEntitySchema.extend({
221
- project: ProjectSearchDocumentSchema,
222
- }),
223
- )
224
- .openapi({ example: [] }),
225
- })
226
- .openapi("UserWithProjectBookmarksEntity");
227
-
228
192
  export type UserWithProjectBookmarksEntity = z.infer<
229
193
  typeof UserWithProjectBookmarksEntitySchema
230
194
  >;
231
195
 
232
- export const UserWithPostBookmarksEntitySchema = z.object({
233
- userId: z.cuid2().openapi({ example: "cksd0v6q0000s9a5y8z7p3x9" }),
196
+ export const UserWithPostBookmarksEntitySchema = UserWithId.extend({
234
197
  postBookmarks: z.array(
235
198
  BookmarkEntitySchema.extend({
236
199
  post: PostWithFilesEntitySchema,
237
200
  }),
238
201
  ),
239
202
  });
240
-
241
203
  export type UserWithPostBookmarksEntity = z.infer<
242
204
  typeof UserWithPostBookmarksEntitySchema
243
205
  >;
@@ -246,211 +208,47 @@ export const UserWithProductsEntitySchema = z.object({
246
208
  userId: z.cuid2(),
247
209
  products: z.array(ProductEntitySchema),
248
210
  });
249
-
250
211
  export type UserWithProductsEntity = z.infer<
251
212
  typeof UserWithProductsEntitySchema
252
213
  >;
253
214
 
254
- export const GetUserWithProjectBookmarksInputSchema =
255
- UserWithJobBookmarksInputSchema;
256
-
257
- export type GetUserWithProjectBookmarksInput = z.infer<
258
- typeof GetUserWithProjectBookmarksInputSchema
259
- >;
260
-
261
- export const GetUserWithPostBookmarksInputSchema =
262
- UserWithJobBookmarksInputSchema;
263
-
264
- export type GetUserWithPostBookmarksInput = z.infer<
265
- typeof GetUserWithPostBookmarksInputSchema
266
- >;
267
-
268
- export const GetUserWithProjectBookmarksOutputSchema = z.object({
269
- bookmarks: UserWithProjectBookmarksEntitySchema,
270
- nextCursor: z.string().nullable(),
271
- });
215
+ /**
216
+ * --------------------------------
217
+ * FOLLOW SYSTEM
218
+ * --------------------------------
219
+ */
272
220
 
273
- export type GetUserWithProjectBookmarksOutput = z.infer<
274
- typeof GetUserWithProjectBookmarksOutputSchema
275
- >;
276
-
277
- export const GetUserWithProductsOutputSchema = z.object({
278
- products: UserWithProductsEntitySchema,
279
- noOfProducts: z.int().nullable(),
280
- nextCursor: z.string().nullable(),
281
- });
282
-
283
- export type UserWithProductsOutput = z.infer<
284
- typeof GetUserWithProductsOutputSchema
285
- >;
286
-
287
- export const GetUserWithPostBookmarksOutputSchema = z.object({
288
- bookmarks: z.array(
289
- BookmarkEntitySchema.extend({
290
- post: FeedPostEntitySchema,
291
- }),
292
- ),
293
- nextCursor: z.string().nullable(),
221
+ const FollowMeta = z.object({
222
+ isFollowing: z.boolean(),
223
+ followsYou: z.boolean(),
294
224
  });
295
-
296
- export type GetUserWithPostBookmarksOutput = z.infer<
297
- typeof GetUserWithPostBookmarksOutputSchema
298
- >;
225
+ export type FollowMeta = z.infer<typeof FollowMeta>;
299
226
 
300
227
  export const UserWithFollowingEntitySchema = MinimalUserSchema.extend({
301
- following: z
302
- .array(
303
- MinimalUserSchema.extend({
304
- isFollowing: z.boolean().optional().openapi({ example: true }),
305
- followsYou: z.boolean().optional().openapi({ example: false }),
306
- }),
307
- )
308
- .openapi({
309
- description: "List of users this user is following.",
310
- example: [],
311
- }),
312
- }).openapi("UserWithFollowingEntity");
313
-
228
+ following: z.array(MinimalUserSchema.extend(FollowMeta.shape)),
229
+ });
314
230
  export type UserWithFollowingEntity = z.infer<
315
231
  typeof UserWithFollowingEntitySchema
316
232
  >;
317
233
 
318
234
  export const UserWithFollowersEntitySchema = MinimalUserSchema.extend({
319
- followers: z
320
- .array(
321
- MinimalUserSchema.extend({
322
- isFollowing: z.boolean().optional().openapi({ example: false }),
323
- followsYou: z.boolean().optional().openapi({ example: true }),
324
- }),
325
- )
326
- .openapi({
327
- description: "List of users who follow this user.",
328
- example: [],
329
- }),
330
- }).openapi("UserWithFollowersEntity");
331
-
235
+ followers: z.array(MinimalUserSchema.extend(FollowMeta.shape)),
236
+ });
332
237
  export type UserWithFollowersEntity = z.infer<
333
238
  typeof UserWithFollowersEntitySchema
334
239
  >;
335
240
 
336
- export const GetUserFollowingInputSchema = z.object({
337
- searchQuery: z.string().optional().openapi({ example: "design systems" }),
338
- offset: z.number().int().nonnegative().optional().openapi({ example: 20 }),
339
- });
340
-
341
- export type GetUserFollowingInput = z.infer<typeof GetUserFollowingInputSchema>;
342
-
343
- export const GetUserFollowersInputSchema = z.object({
344
- searchQuery: z.string().optional().openapi({ example: "design systems" }),
345
- offset: z.number().int().nonnegative().optional().openapi({ example: 20 }),
346
- });
347
-
348
- export type GetUserFollowersInput = z.infer<typeof GetUserFollowersInputSchema>;
349
-
350
- export const GetUserFollowingOutputSchema = z.object({
351
- nextCursor: z.string().openapi({ example: "cksd0v6q0000nxtcur" }),
352
- following: z
353
- .array(
354
- MinimalUserSchema.extend({
355
- isFollowing: z.boolean().optional().openapi({ example: true }),
356
- followsYou: z.boolean().optional().openapi({ example: false }),
357
- }),
358
- )
359
- .openapi({ example: [] }),
360
- });
241
+ /**
242
+ * --------------------------------
243
+ * SEARCH USERS
244
+ * --------------------------------
245
+ */
361
246
 
362
- export type GetUserFollowingOutput = z.infer<
363
- typeof GetUserFollowingOutputSchema
364
- >;
365
-
366
- export const GetUserFollowersOutputSchema = z.object({
367
- nextCursor: z.string().openapi({ example: "cksd0v6q0000nxtcur" }),
368
- followers: z
369
- .array(
370
- MinimalUserSchema.extend({
371
- isFollowing: z.boolean().optional().openapi({ example: false }),
372
- followsYou: z.boolean().optional().openapi({ example: true }),
373
- }),
374
- )
375
- .openapi({ example: [] }),
247
+ const CursorPaginationInput = z.object({
248
+ cursor: z.string().optional(),
249
+ limit: z.coerce.number().int().min(1).max(100).default(20),
376
250
  });
377
-
378
- export type GetUserFollowersOutput = z.infer<
379
- typeof GetUserFollowersOutputSchema
380
- >;
381
-
382
- export const GetAuthenticatedUserOutputSchema = UserEntitySchema;
383
-
384
- export type GetAuthenticatedUserOutput = z.infer<
385
- typeof GetAuthenticatedUserOutputSchema
386
- >;
387
-
388
- export const GetAuthenticatedUserProfileOutputSchema = UserProfileEntitySchema;
389
-
390
- export type GetAuthenticatedUserProfileOutput = z.infer<
391
- typeof GetAuthenticatedUserProfileOutputSchema
392
- >;
393
-
394
- export const GetAuthenticatedUserWithProjectsOutputSchema =
395
- UserWithProjectsEntitySchema;
396
-
397
- export type GetAuthenticatedUserWithProjectsOutput = z.infer<
398
- typeof GetAuthenticatedUserWithProjectsOutputSchema
399
- >;
400
-
401
- export const GetAuthenticatedUserWithProjectBookmarksOutputSchema =
402
- UserWithProjectBookmarksEntitySchema;
403
-
404
- export type GetAuthenticatedUserWithProjectBookmarksOutput = z.infer<
405
- typeof GetAuthenticatedUserWithProjectBookmarksOutputSchema
406
- >;
407
-
408
- export const GetAuthenticatedUserWithProjectLikesOutputSchema =
409
- UserWithProjectLikesEntitySchema;
410
-
411
- export type GetAuthenticatedUserWithProjectLikesOutput = z.infer<
412
- typeof GetAuthenticatedUserWithProjectLikesOutputSchema
413
- >;
414
-
415
- export const GetAuthenticatedUserWithUserFollowingOutputSchema =
416
- UserWithFollowingEntitySchema;
417
-
418
- export type GetAuthenticatedUserWithUserFollowingOutput = z.infer<
419
- typeof GetAuthenticatedUserWithUserFollowingOutputSchema
420
- >;
421
-
422
- export const GetAuthenticatedUserWithUserFollowersOutputSchema =
423
- UserWithFollowersEntitySchema;
424
-
425
- export type GetAuthenticatedUserWithUserFollowersOutput = z.infer<
426
- typeof GetAuthenticatedUserWithUserFollowersOutputSchema
427
- >;
428
-
429
- export const GetUserActivityInputSchema = z.object({
430
- activityType: z
431
- .enum(Object.values(ACTIVITY_TYPES) as [ActivityType, ...ActivityType[]])
432
- .openapi({ example: "LIKE" }),
433
- });
434
-
435
- export type GetUserActivityInput = z.infer<typeof GetUserActivityInputSchema>;
436
-
437
- export const GetUserActivityOutputSchema = z
438
- .array(
439
- z.object({
440
- parentId: z.cuid2().openapi({ example: "ckj1a2b3c0000prt" }),
441
- parentType: z
442
- .enum(
443
- Object.values(ACTIVITY_PARENT_TYPES) as [
444
- ActivityParentType,
445
- ...ActivityParentType[],
446
- ],
447
- )
448
- .openapi({ example: "POST" }),
449
- }),
450
- )
451
- .openapi({ example: [] });
452
-
453
- export type GetUserActivityOutput = z.infer<typeof GetUserActivityOutputSchema>;
251
+ export type CursorPaginationInput = z.infer<typeof CursorPaginationInput>;
454
252
 
455
253
  const coerceArray = (val: unknown) => {
456
254
  if (typeof val === "string") return val === "" ? [] : val.split(",");
@@ -458,91 +256,74 @@ const coerceArray = (val: unknown) => {
458
256
  };
459
257
 
460
258
  export const SearchUsersInputSchema = z.object({
461
- query: z.string().default("").openapi({
462
- example: "john",
463
- description: "Search by name, email, username, or discipline",
464
- }),
259
+ query: z.string().default(""),
465
260
  roles: z
466
261
  .preprocess(
467
262
  coerceArray,
468
263
  z.array(z.enum(Object.values(ROLES) as [Role, ...Role[]])),
469
264
  )
470
- .optional()
471
- .openapi({ example: ["CREATIVE", "BRAND"] }),
472
- disciplines: z
473
- .preprocess(coerceArray, z.array(z.string()))
474
- .optional()
475
- .openapi({ example: ["Design Systems", "Web Development"] }),
476
- locations: z
477
- .preprocess(coerceArray, z.array(z.string()))
478
- .optional()
479
- .openapi({ example: ["Lagos, Nigeria", "London, UK"] }),
480
- limit: z.coerce.number().min(1).max(100).default(20).openapi({ example: 20 }),
481
- cursor: z.string().nullable().optional().openapi({
482
- example: "cksd0v6q0000cursor",
483
- description: "The offset/cursor for pagination",
484
- }),
265
+ .optional(),
266
+ disciplines: z.preprocess(coerceArray, z.array(z.string())).optional(),
267
+ locations: z.preprocess(coerceArray, z.array(z.string())).optional(),
268
+ ...CursorPaginationInput.shape,
485
269
  });
486
-
487
270
  export type SearchUsersInput = z.infer<typeof SearchUsersInputSchema>;
488
271
 
489
272
  export const SearchUsersOutputSchema = z.object({
490
- users: z
491
- .array(
492
- MinimalUserSchema.extend({
493
- isFollowing: z.boolean().optional().openapi({ example: false }),
494
- followsYou: z.boolean().optional().openapi({ example: true }),
495
- noOfFollowers: z
496
- .number()
497
- .int()
498
- .nonnegative()
499
- .optional()
500
- .openapi({ example: 1200 }),
501
- disciplines: z
502
- .array(z.string())
503
- .optional()
504
- .openapi({ example: ["UI/UX", "Frontend"] }),
505
- }),
506
- )
507
- .openapi({ example: [] }),
508
- nextCursor: z.string().optional().openapi({
509
- example: "abc123nxt",
510
- description: "The next cursor for pagination",
511
- }),
273
+ users: z.array(
274
+ MinimalUserSchema.extend({
275
+ isFollowing: z.boolean(),
276
+ followsYou: z.boolean(),
277
+ noOfFollowers: z.number().int(),
278
+ disciplines: z.array(z.string()),
279
+ }),
280
+ ),
281
+ nextCursor: z.string().optional(),
512
282
  });
513
-
514
283
  export type SearchUsersOutput = z.infer<typeof SearchUsersOutputSchema>;
515
284
 
516
- export const UserSearchDocumentSchema = z
517
- .object({
518
- id: z.cuid2().openapi({ example: "cksd0v6q0000s9a5y8z7p3x9" }),
519
- email: z.email().openapi({ example: "user@example.com" }),
520
- username: z.string().nullable().openapi({ example: "johndoe" }),
521
- name: z.string().nullable().openapi({ example: "John Doe" }),
522
- image: z
523
- .string()
524
- .nullable()
525
- .openapi({ example: "https://example.com/avatar.png" }),
526
- role: z
527
- .enum(Object.values(ROLES) as [Role, ...Role[]])
528
- .openapi({ example: "CREATIVE" }),
529
- location: z.string().nullable().openapi({ example: "Lagos, Nigeria" }),
530
- disciplines: z
531
- .array(z.string())
532
- .nullable()
533
- .openapi({ example: ["Design Systems", "Web Development"] }),
534
- updatedAt: z
535
- .string()
536
- .nullable()
537
- .openapi({ example: "2026-03-11T09:00:00.000Z" }),
538
- createdAt: z
539
- .string()
540
- .nullable()
541
- .openapi({ example: "2026-03-11T09:00:00.000Z" }),
542
- })
543
- .openapi({
544
- title: "User Search Document",
545
- description: "Flattened schema used for indexing users in search engines.",
546
- });
285
+ /**
286
+ * --------------------------------
287
+ * ACTIVITY
288
+ * --------------------------------
289
+ */
547
290
 
291
+ export const GetUserActivityInputSchema = z.object({
292
+ activityType: z.enum(
293
+ Object.values(ACTIVITY_TYPES) as [ActivityType, ...ActivityType[]],
294
+ ),
295
+ });
296
+ export type GetUserActivityInput = z.infer<typeof GetUserActivityInputSchema>;
297
+
298
+ export const GetUserActivityOutputSchema = z.array(
299
+ z.object({
300
+ parentId: z.cuid2(),
301
+ parentType: z.enum(
302
+ Object.values(ACTIVITY_PARENT_TYPES) as [
303
+ ActivityParentType,
304
+ ...ActivityParentType[],
305
+ ],
306
+ ),
307
+ }),
308
+ );
309
+ export type GetUserActivityOutput = z.infer<typeof GetUserActivityOutputSchema>;
310
+
311
+ /**
312
+ * --------------------------------
313
+ * SEARCH DOCUMENT
314
+ * --------------------------------
315
+ */
316
+
317
+ export const UserSearchDocumentSchema = z.object({
318
+ id: z.cuid2(),
319
+ email: z.email(),
320
+ username: z.string().nullable(),
321
+ name: z.string().nullable(),
322
+ image: z.string().nullable(),
323
+ role: z.enum(Object.values(ROLES) as [Role, ...Role[]]),
324
+ location: z.string().nullable(),
325
+ disciplines: z.array(z.string()).nullable(),
326
+ updatedAt: z.iso.datetime().nullable(),
327
+ createdAt: z.iso.datetime().nullable(),
328
+ });
548
329
  export type UserSearchDocument = z.infer<typeof UserSearchDocumentSchema>;