@zyacreatives/shared 2.5.52 → 2.5.55

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 (114) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/schemas/activity.d.ts +1 -0
  4. package/dist/schemas/auth.d.ts +2 -0
  5. package/dist/schemas/bookmark.d.ts +62 -7
  6. package/dist/schemas/bookmark.js +32 -30
  7. package/dist/schemas/brand.d.ts +3 -3
  8. package/dist/schemas/chat.d.ts +96 -52
  9. package/dist/schemas/chat.js +44 -18
  10. package/dist/schemas/comment.d.ts +65 -21
  11. package/dist/schemas/comment.js +48 -54
  12. package/dist/schemas/common.d.ts +15 -11
  13. package/dist/schemas/creative.d.ts +21 -21
  14. package/dist/schemas/creative.js +3 -3
  15. package/dist/schemas/discipline.d.ts +63 -12
  16. package/dist/schemas/discipline.js +62 -65
  17. package/dist/schemas/entity-stats.d.ts +35 -3
  18. package/dist/schemas/entity-stats.js +24 -38
  19. package/dist/schemas/feed.d.ts +50 -3
  20. package/dist/schemas/feed.js +43 -13
  21. package/dist/schemas/file.d.ts +65 -24
  22. package/dist/schemas/file.js +60 -49
  23. package/dist/schemas/index.d.ts +1 -0
  24. package/dist/schemas/index.js +1 -0
  25. package/dist/schemas/investor-shortlist.d.ts +68 -11
  26. package/dist/schemas/investor-shortlist.js +46 -24
  27. package/dist/schemas/investor-signal.d.ts +52 -12
  28. package/dist/schemas/investor-signal.js +59 -39
  29. package/dist/schemas/investor.d.ts +3 -3
  30. package/dist/schemas/job-application.d.ts +291 -279
  31. package/dist/schemas/job-application.js +59 -95
  32. package/dist/schemas/job.d.ts +200 -659
  33. package/dist/schemas/job.js +98 -231
  34. package/dist/schemas/like.d.ts +3 -0
  35. package/dist/schemas/message.d.ts +125 -94
  36. package/dist/schemas/message.js +54 -55
  37. package/dist/schemas/notification.d.ts +99 -32
  38. package/dist/schemas/notification.js +46 -42
  39. package/dist/schemas/payout-method.d.ts +51 -31
  40. package/dist/schemas/payout-method.js +48 -58
  41. package/dist/schemas/post.d.ts +295 -204
  42. package/dist/schemas/post.js +148 -272
  43. package/dist/schemas/product.d.ts +308 -229
  44. package/dist/schemas/product.js +111 -94
  45. package/dist/schemas/project.d.ts +75 -107
  46. package/dist/schemas/project.js +1 -5
  47. package/dist/schemas/seller.d.ts +10 -10
  48. package/dist/schemas/user-strike.d.ts +3 -0
  49. package/dist/schemas/user.d.ts +128 -126
  50. package/dist/schemas/user.js +10 -1
  51. package/dist/schemas/username.d.ts +1 -0
  52. package/dist/schemas/view.d.ts +1 -0
  53. package/dist/types/activity.d.ts +1 -3
  54. package/dist/types/auth.d.ts +1 -4
  55. package/dist/types/bookmark.d.ts +1 -3
  56. package/dist/types/chat.d.ts +1 -11
  57. package/dist/types/comment.d.ts +1 -5
  58. package/dist/types/common.d.ts +2 -8
  59. package/dist/types/discipline.d.ts +1 -11
  60. package/dist/types/entity-stats.d.ts +1 -3
  61. package/dist/types/feed.d.ts +1 -5
  62. package/dist/types/investor-shortlist.d.ts +1 -6
  63. package/dist/types/investor-signal.d.ts +1 -7
  64. package/dist/types/like.d.ts +1 -3
  65. package/dist/types/message.d.ts +1 -9
  66. package/dist/types/notification.d.ts +1 -9
  67. package/dist/types/user-strike.d.ts +1 -5
  68. package/dist/types/username.d.ts +1 -3
  69. package/package.json +1 -1
  70. package/src/index.ts +4 -5
  71. package/src/schemas/activity.ts +5 -4
  72. package/src/schemas/auth.ts +14 -10
  73. package/src/schemas/bookmark.ts +48 -29
  74. package/src/schemas/chat.ts +79 -18
  75. package/src/schemas/comment.ts +63 -49
  76. package/src/schemas/common.ts +8 -3
  77. package/src/schemas/creative.ts +3 -3
  78. package/src/schemas/discipline.ts +103 -71
  79. package/src/schemas/entity-stats.ts +32 -38
  80. package/src/schemas/feed.ts +62 -15
  81. package/src/schemas/file.ts +85 -58
  82. package/src/schemas/index.ts +1 -0
  83. package/src/schemas/investor-shortlist.ts +57 -8
  84. package/src/schemas/investor-signal.ts +79 -27
  85. package/src/schemas/job-application.ts +81 -115
  86. package/src/schemas/job.ts +160 -301
  87. package/src/schemas/like.ts +5 -1
  88. package/src/schemas/message.ts +71 -64
  89. package/src/schemas/notification.ts +63 -51
  90. package/src/schemas/payout-method.ts +47 -63
  91. package/src/schemas/post.ts +211 -272
  92. package/src/schemas/product.ts +202 -139
  93. package/src/schemas/project.ts +7 -10
  94. package/src/schemas/user-strike.ts +7 -1
  95. package/src/schemas/user.ts +17 -5
  96. package/src/schemas/username.ts +5 -3
  97. package/src/schemas/view.ts +0 -50
  98. package/src/types/activity.ts +0 -4
  99. package/src/types/auth.ts +0 -5
  100. package/src/types/bookmark.ts +0 -4
  101. package/src/types/chat.ts +0 -31
  102. package/src/types/comment.ts +0 -12
  103. package/src/types/common.ts +0 -14
  104. package/src/types/discipline.ts +0 -32
  105. package/src/types/entity-stats.ts +0 -4
  106. package/src/types/feed.ts +0 -10
  107. package/src/types/index.ts +0 -16
  108. package/src/types/investor-shortlist.ts +0 -18
  109. package/src/types/investor-signal.ts +0 -26
  110. package/src/types/like.ts +0 -4
  111. package/src/types/message.ts +0 -26
  112. package/src/types/notification.ts +0 -34
  113. package/src/types/user-strike.ts +0 -10
  114. package/src/types/username.ts +0 -4
@@ -1,3 +1 @@
1
- import { z } from "@hono/zod-openapi";
2
- import { UsernameSchema } from "../schemas";
3
- export type UsernameInput = z.infer<typeof UsernameSchema>;
1
+ export type { UsernameInput } from "../schemas/username";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyacreatives/shared",
3
- "version": "2.5.52",
3
+ "version": "2.5.55",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -1,5 +1,4 @@
1
- export * from "./types/index";
2
- export * from "./constants";
3
- export * from "./schemas/index";
4
- export * from "./utils/slugify";
5
- export * from "./utils/generate-file-url"
1
+ export * from "./constants";
2
+ export * from "./schemas/index";
3
+ export * from "./utils/slugify";
4
+ export * from "./utils/generate-file-url"
@@ -1,7 +1,7 @@
1
1
  import z from "zod";
2
2
  import { ACTIVITY_TYPES } from "../constants";
3
3
 
4
- export const ActivitySchema = z.object({
4
+ export const ActivitySchema = z.object({
5
5
  id: z.cuid2().openapi({
6
6
  description: "Unique identifier for the bookmarked entity.",
7
7
  title: "Entity ID",
@@ -12,6 +12,7 @@ export const ActivitySchema = z.object({
12
12
  actorUsername: z.string(),
13
13
  actorImageUrl: z.url().optional(),
14
14
  followsYou: z.boolean().optional(),
15
- isFollowing: z.boolean().optional(),
16
- });
17
-
15
+ isFollowing: z.boolean().optional(),
16
+ });
17
+
18
+ export type ActivityEntity = z.infer<typeof ActivitySchema>;
@@ -1,6 +1,6 @@
1
1
  import z from "zod";
2
2
 
3
- export const RegisterSchema = z.object({
3
+ export const RegisterSchema = z.object({
4
4
  firstName: z.string().max(255, { message: "First name is too long" }),
5
5
  lastName: z.string().max(255, { message: "Last name is too long" }),
6
6
  email: z
@@ -13,13 +13,15 @@ export const RegisterSchema = z.object({
13
13
  .regex(/^[a-zA-Z0-9_]+$/, {
14
14
  error: "Username can only contain letters, numbers, and underscores",
15
15
  }),
16
- password: z
17
- .string()
18
- .min(8, { message: "Password must be at least 8 characters" })
19
- .max(100, { message: "Password must be at most 100 characters" }),
20
- });
21
-
22
- export const LoginSchema = z.object({
16
+ password: z
17
+ .string()
18
+ .min(8, { message: "Password must be at least 8 characters" })
19
+ .max(100, { message: "Password must be at most 100 characters" }),
20
+ });
21
+
22
+ export type RegisterInput = z.infer<typeof RegisterSchema>;
23
+
24
+ export const LoginSchema = z.object({
23
25
  identifier: z
24
26
  .string()
25
27
  .trim()
@@ -39,5 +41,7 @@ export const LoginSchema = z.object({
39
41
  .string()
40
42
  .min(8, { message: "Password must be at least 8 characters" })
41
43
  .max(100, { message: "Password must be at most 100 characters" }),
42
- rememberMe: z.boolean(),
43
- });
44
+ rememberMe: z.boolean(),
45
+ });
46
+
47
+ export type LoginInput = z.infer<typeof LoginSchema>;
@@ -1,38 +1,57 @@
1
1
  import { z } from "@hono/zod-openapi";
2
+
2
3
  import { ACTIVITY_PARENT_TYPES } from "../constants";
3
4
 
5
+ /**
6
+ * --------------------------------
7
+ * SHAPE
8
+ * --------------------------------
9
+ */
10
+
11
+ const BookmarkShape = z.object({
12
+ parentId: z.cuid2(),
13
+ parentType: z.enum(ACTIVITY_PARENT_TYPES),
14
+ });
15
+
16
+ export type BookmarkShapeType = z.infer<typeof BookmarkShape>;
17
+
18
+ /**
19
+ * --------------------------------
20
+ * BASE ENTITY
21
+ * --------------------------------
22
+ */
23
+
4
24
  export const BookmarkEntitySchema = z
5
25
  .object({
6
- id: z.cuid2().openapi({
7
- description: "Unique identifier for the bookmark.",
8
- title: "Bookmark ID",
9
- }),
10
- createdAt: z.coerce.date().optional().openapi({
11
- description: "Timestamp when the bookmark was created.",
12
- title: "Created At",
13
- }),
14
- userId: z.cuid2().openapi({
15
- description: "Identifier of the user who created the bookmark.",
16
- title: "User ID",
17
- }),
18
- parentId: z.cuid2().openapi({
19
- description: "Identifier of the parent entity that was bookmarked.",
20
- title: "Parent ID",
21
- }),
22
- parentType: z.enum(ACTIVITY_PARENT_TYPES).openapi({
23
- description: "Type of the parent entity this statistic belongs to.",
24
- title: "Parent Type",
25
- }),
26
+ id: z.cuid2(),
27
+ userId: z.cuid2(),
28
+ ...BookmarkShape.shape,
29
+ createdAt: z.iso.datetime(),
26
30
  })
27
- .openapi({
28
- title: "Bookmark",
29
- description: "Represents a user bookmark on a specific parent entity.",
30
- });
31
+ .openapi("Bookmark");
31
32
 
32
- export const BookmarkInputSchema = z.object({
33
- parentId: z.string(),
34
- parentType: z.enum(ACTIVITY_PARENT_TYPES),
35
- userId: z.string(),
36
- });
33
+ export type BookmarkEntity = z.infer<typeof BookmarkEntitySchema>;
34
+
35
+ /**
36
+ * --------------------------------
37
+ * INPUTS
38
+ * --------------------------------
39
+ */
40
+
41
+ export const CreateBookmarkInputSchema = BookmarkShape.extend({});
42
+
43
+ export type CreateBookmarkInput = z.infer<typeof CreateBookmarkInputSchema>;
44
+
45
+ export const DeleteBookmarkInputSchema = BookmarkShape.extend({});
46
+
47
+ export type DeleteBookmarkInput = z.infer<typeof DeleteBookmarkInputSchema>;
48
+
49
+ /**
50
+ * --------------------------------
51
+ * OUTPUTS
52
+ * --------------------------------
53
+ */
37
54
 
38
55
  export const BookmarkOutputSchema = BookmarkEntitySchema;
56
+
57
+ export type BookmarkOutput = z.infer<typeof BookmarkOutputSchema>;
@@ -1,19 +1,48 @@
1
1
  import { z } from "@hono/zod-openapi";
2
+
2
3
  import { MESSAGE_REQUEST_STATUS } from "../constants";
3
4
 
4
- export const BaseChatEntitySchema = z.object({
5
- id: z.cuid2(),
5
+ /**
6
+ * --------------------------------
7
+ * SHAPE
8
+ * --------------------------------
9
+ */
10
+
11
+ const ChatShape = z.object({
6
12
  senderId: z.cuid2(),
7
13
  receiverId: z.cuid2(),
8
14
  isMessageRequest: z.boolean().default(true),
9
15
  messageRequestStatus: z.enum(MESSAGE_REQUEST_STATUS).default("PENDING"),
10
- acceptedAt: z.coerce.date().nullable(),
11
- declinedAt: z.coerce.date().nullable(),
12
- createdAt: z.coerce.date(),
13
- updatedAt: z.coerce.date().nullable(),
14
- deletedAt: z.coerce.date().nullable(),
15
16
  });
16
17
 
18
+ export type ChatShapeType = z.infer<typeof ChatShape>;
19
+
20
+ /**
21
+ * --------------------------------
22
+ * BASE ENTITY
23
+ * --------------------------------
24
+ */
25
+
26
+ export const BaseChatEntitySchema = z
27
+ .object({
28
+ id: z.cuid2(),
29
+ ...ChatShape.shape,
30
+ acceptedAt: z.iso.datetime().nullable(),
31
+ declinedAt: z.iso.datetime().nullable(),
32
+ createdAt: z.iso.datetime(),
33
+ updatedAt: z.iso.datetime().nullable(),
34
+ deletedAt: z.iso.datetime().nullable(),
35
+ })
36
+ .openapi("BaseChat");
37
+
38
+ export type BaseChatEntity = z.infer<typeof BaseChatEntitySchema>;
39
+
40
+ /**
41
+ * --------------------------------
42
+ * DERIVED ENTITIES
43
+ * --------------------------------
44
+ */
45
+
17
46
  export const ChatEntitySchema = BaseChatEntitySchema.extend({
18
47
  senderName: z.string(),
19
48
  senderUsername: z.string(),
@@ -24,35 +53,67 @@ export const ChatEntitySchema = BaseChatEntitySchema.extend({
24
53
  receiverImgUrl: z.string().nullable(),
25
54
 
26
55
  lastMessageSent: z.string().nullable(),
27
- lastMessageAt: z.coerce.date().nullable(),
56
+ lastMessageAt: z.iso.datetime().nullable(),
28
57
  isUnread: z.boolean().default(false),
29
58
  isOnline: z.boolean().default(false),
30
- });
59
+ }).openapi("Chat");
60
+
61
+ export type ChatEntity = z.infer<typeof ChatEntitySchema>;
62
+
63
+ /**
64
+ * --------------------------------
65
+ * INPUTS
66
+ * --------------------------------
67
+ */
31
68
 
32
69
  export const CreateChatInputSchema = z.object({
33
- senderId: z.cuid2(),
34
70
  receiverId: z.cuid2(),
35
71
  });
36
72
 
37
- export const CreateChatOutputSchema = BaseChatEntitySchema;
73
+ export type CreateChatInput = z.infer<typeof CreateChatInputSchema>;
38
74
 
39
- export const ChatIdSchema = z.object({
75
+ export const ChatIdInputSchema = z.object({
40
76
  chatId: z.cuid2(),
41
77
  });
42
78
 
79
+ export type ChatIdInput = z.infer<typeof ChatIdInputSchema>;
80
+
81
+ export const AcceptMessageRequestInputSchema = ChatIdInputSchema.extend({});
82
+
83
+ export type AcceptMessageRequestInput = z.infer<
84
+ typeof AcceptMessageRequestInputSchema
85
+ >;
86
+
87
+ export const DeclineMessageRequestInputSchema = ChatIdInputSchema.extend({});
88
+
89
+ export type DeclineMessageRequestInput = z.infer<
90
+ typeof DeclineMessageRequestInputSchema
91
+ >;
92
+
93
+ /**
94
+ * --------------------------------
95
+ * OUTPUTS
96
+ * --------------------------------
97
+ */
98
+
99
+ export const CreateChatOutputSchema = BaseChatEntitySchema;
100
+
101
+ export type CreateChatOutput = z.infer<typeof CreateChatOutputSchema>;
102
+
43
103
  export const GetChatsOutputSchema = z.array(ChatEntitySchema);
44
104
 
105
+ export type GetChatsOutput = z.infer<typeof GetChatsOutputSchema>;
106
+
45
107
  export const GetChatsForUserOutputSchema = z.object({
46
108
  chats: z.array(ChatEntitySchema),
47
109
  nextCursor: z.string().nullable(),
48
110
  });
49
111
 
112
+ export type GetChatsForUserOutput = z.infer<typeof GetChatsForUserOutputSchema>;
113
+
50
114
  export const GetMessageRequestsForUserOutputSchema =
51
115
  GetChatsForUserOutputSchema;
52
116
 
53
- export const AcceptMessageRequestInputSchema = z.object({
54
- chatId: z.cuid2(),
55
- userId: z.cuid2(),
56
- });
57
-
58
- export const DeclineMessageRequestInputSchema = AcceptMessageRequestInputSchema;
117
+ export type GetMessageRequestsForUserOutput = z.infer<
118
+ typeof GetMessageRequestsForUserOutputSchema
119
+ >;
@@ -1,62 +1,76 @@
1
- import z from "zod";
1
+ import { z } from "@hono/zod-openapi";
2
+
2
3
  import { ACTIVITY_PARENT_TYPES } from "../constants";
3
4
 
4
- export const CommentEntitySchema = z.object({
5
- id: z.cuid2().openapi({
6
- description: "The unique CUID2 identifier for the comment.",
7
- example: "tr4q2k7k0000c7625z2k8ggy",
8
- }),
9
- userId: z.cuid2().openapi({
10
- description: "The CUID2 of the user who created the comment.",
11
- example: "clq9p8f2z0000c762s7k4g1b",
12
- }),
13
- parentId: z.cuid2().openapi({
14
- description:
15
- "The CUID2 of the parent entity (e.g., a post or project) this comment belongs to.",
16
- example: "clq9p8f2z0000c762s7k4g1b",
17
- }),
5
+ /**
6
+ * --------------------------------
7
+ * SHAPE
8
+ * --------------------------------
9
+ */
10
+
11
+ const CommentShape = z.object({
12
+ parentId: z.cuid2(),
13
+ parentType: z.enum(ACTIVITY_PARENT_TYPES),
14
+ content: z.string(),
18
15
  parentCommentId: z.cuid2().optional(),
19
- parentType: z.enum(ACTIVITY_PARENT_TYPES).openapi({
20
- description: "The type of the parent entity this comment is attached to.",
21
- example: "POST", // Assuming 'POST' is a value in ACTIVITY_PARENT_TYPES
22
- }),
23
- content: z.string().openapi({
24
- description: "The text content of the comment. May contain Markdown.",
25
- example: "This is a great point! I hadn't considered that perspective.",
26
- }),
27
- commenterUsername: z.string().optional(),
28
- commenterName: z.string().optional(),
29
- commenterImageUrl: z.string().optional(),
30
- replyToId: z.cuid2().optional().nullable().openapi({
31
- description:
32
- "The ID of the parent comment if this is a reply. Null for top-level comments.",
33
- example: "tr4q2k7k0000c7625z2k8ggy", // Example of a parent comment's ID
34
- }),
35
- createdAt: z.coerce.date().optional().openapi({
36
- description: "The date and time the comment was created.",
37
- example: "2023-10-27T10:00:00.000Z",
38
- format: "date-time",
39
- }),
40
- isLiked: z.boolean().default(false),
41
- likesCount: z.int().default(0),
42
- hasReplies: z.boolean().optional(),
43
- updatedAt: z.coerce.date().optional().openapi({
44
- description: "The date and time the comment was last updated.",
45
- example: "2023-10-27T10:05:00.000Z",
46
- format: "date-time",
47
- }),
16
+ replyToId: z.cuid2().optional().nullable(),
48
17
  });
49
18
 
50
- export const CommentInputSchema = z
19
+ export type CommentShapeType = z.infer<typeof CommentShape>;
20
+
21
+ /**
22
+ * --------------------------------
23
+ * BASE ENTITY
24
+ * --------------------------------
25
+ */
26
+
27
+ export const CommentEntitySchema = z
51
28
  .object({
52
- content: z.string(),
53
- parentCommentId: z.cuid2().optional(),
54
- replyToId: z.cuid2().optional(),
29
+ id: z.cuid2(),
30
+ userId: z.cuid2(),
31
+ ...CommentShape.shape,
32
+
33
+ commenterUsername: z.string().optional(),
34
+ commenterName: z.string().optional(),
35
+ commenterImageUrl: z.string().optional(),
36
+
37
+ isLiked: z.boolean().default(false),
38
+ likesCount: z.int().default(0),
39
+ hasReplies: z.boolean().optional(),
40
+
41
+ createdAt: z.iso.datetime(),
42
+ updatedAt: z.iso.datetime().optional(),
55
43
  })
56
- .openapi({ title: "Comment on Project" });
44
+ .openapi("Comment");
45
+
46
+ export type CommentEntity = z.infer<typeof CommentEntitySchema>;
47
+
48
+ /**
49
+ * --------------------------------
50
+ * INPUTS
51
+ * --------------------------------
52
+ */
53
+
54
+ export const CreateCommentInputSchema = z.object({
55
+ content: z.string(),
56
+ parentCommentId: z.cuid2().optional(),
57
+ replyToId: z.cuid2().optional().nullable(),
58
+ });
59
+
60
+ export type CreateCommentInput = z.infer<typeof CreateCommentInputSchema>;
57
61
 
58
62
  export const DeleteCommentInputSchema = z.object({
59
63
  commentId: z.cuid2(),
60
64
  });
61
65
 
66
+ export type DeleteCommentInput = z.infer<typeof DeleteCommentInputSchema>;
67
+
68
+ /**
69
+ * --------------------------------
70
+ * OUTPUTS
71
+ * --------------------------------
72
+ */
73
+
62
74
  export const CommentOutputSchema = CommentEntitySchema;
75
+
76
+ export type CommentOutput = z.infer<typeof CommentOutputSchema>;
@@ -74,12 +74,17 @@ export const WorkExperienceSchema = z.object({
74
74
  description: z.string().default(""),
75
75
  });
76
76
 
77
- export const WebsiteUrlInputSchema = z
77
+ export const WebsiteUrlInputSchema = z
78
78
  .string()
79
79
  .transform((val) => {
80
80
  if (!val) return val;
81
81
  if (val.startsWith("http://") || val.startsWith("https://")) return val;
82
82
  return `https://${val}`;
83
83
  })
84
- .pipe(z.url("Invalid URL").or(z.literal("")))
85
- .optional();
84
+ .pipe(z.url("Invalid URL").or(z.literal("")))
85
+ .optional();
86
+
87
+ export type Cursor = {
88
+ id: string;
89
+ createdAt: string;
90
+ };
@@ -23,10 +23,10 @@ const CreativeShape = z.object({
23
23
  z.object({
24
24
  companyName: z.string(),
25
25
  position: z.string(),
26
- startDate: z.string().datetime().optional(),
27
- endDate: z.string().datetime().optional(),
26
+ startDate: z.iso.datetime().optional(),
27
+ endDate: z.iso.datetime().optional(),
28
28
  currentlyWorking: z.boolean().default(false),
29
- description: z.string().default(""),
29
+ description: z.string().optional(),
30
30
  }),
31
31
  )
32
32
  .default([]),
@@ -1,88 +1,120 @@
1
1
  import { z } from "@hono/zod-openapi";
2
2
 
3
- export const BaseDisciplineEntitySchema = z.object({
4
- slug: z.string().openapi({ example: "digital-art" }),
5
- name: z.string().openapi({ example: "Digital Art" }),
3
+ /**
4
+ * --------------------------------
5
+ * SHAPE
6
+ * --------------------------------
7
+ */
8
+
9
+ const DisciplineShape = z.object({
10
+ slug: z.string(),
11
+ name: z.string(),
6
12
  });
7
13
 
8
- export const TagEntitySchema = z.object({
9
- id: z.int(),
14
+ export type DisciplineShapeType = z.infer<typeof DisciplineShape>;
15
+
16
+ const TagShape = z.object({
10
17
  name: z.string(),
11
18
  disciplineSlug: z.string().optional(),
12
19
  });
13
20
 
14
- export const DisciplineEntitySchema = BaseDisciplineEntitySchema.extend({
15
- tags: z
16
- .array(z.string().openapi({ example: "illustration" }))
17
- .optional()
18
- .openapi({ example: ["illustration", "concept-art"] }),
19
- }).openapi({ title: "DisciplineEntity" });
21
+ export type TagShapeType = z.infer<typeof TagShape>;
20
22
 
21
- export const DisciplineUpdateOutputSchema = z
22
- .object({
23
- slug: z.string().openapi({ example: "digital-art" }),
24
- })
25
- .openapi({ title: "DisciplineUpdateOutput" });
23
+ /**
24
+ * --------------------------------
25
+ * BASE ENTITY
26
+ * --------------------------------
27
+ */
26
28
 
27
- export const CreateDisciplinesInputSchema = z
28
- .object({
29
- disciplines: z
30
- .array(
31
- z.object({
32
- name: z.string().max(128).openapi({ example: "Mathematics" }),
33
- tags: z
34
- .array(z.string().openapi({ example: "algebra" }))
35
- .default([])
36
- .openapi({ example: ["algebra", "geometry"] }),
37
- })
38
- )
39
- .openapi({
40
- description: "Array of disciplines to upsert.",
41
- example: [
42
- { name: "Mathematics", tags: ["algebra", "geometry"] },
43
- { name: "Physics", tags: ["mechanics", "optics"] },
44
- ],
45
- }),
46
- })
47
- .openapi({ title: "CreateDisciplinesInput" });
29
+ export const BaseDisciplineEntitySchema =
30
+ DisciplineShape.openapi("BaseDiscipline");
31
+
32
+ export type BaseDisciplineEntity = z.infer<typeof BaseDisciplineEntitySchema>;
48
33
 
49
- export const CreateDisciplinesOutputSchema = z
34
+ export const TagEntitySchema = z
50
35
  .object({
51
- disciplines: z.array(z.string()),
36
+ id: z.int(),
37
+ ...TagShape.shape,
52
38
  })
53
- .openapi({ title: "CreateDisciplinesOutput" });
39
+ .openapi("Tag");
54
40
 
55
- export const GetDisciplinesInputSchema = z
56
- .object({
57
- withTags: z
58
- .union([z.literal("true"), z.literal("false")])
59
- .optional()
60
- .openapi({
61
- description: "Whether to include tags in the response.",
62
- example: "true",
63
- }),
64
- getDefault: z
65
- .union([z.literal("true"), z.literal("false")])
66
- .optional()
67
- .openapi({
68
- description:
69
- "Fetch the default list of disciplines (non user-added disciplines).",
70
- }),
71
- slugs: z.string().optional().openapi({
72
- description: "Comma-separated list of discipline slugs to filter by.",
73
- example: "mathematics,physics",
41
+ export type TagEntity = z.infer<typeof TagEntitySchema>;
42
+
43
+ /**
44
+ * --------------------------------
45
+ * DERIVED ENTITIES
46
+ * --------------------------------
47
+ */
48
+
49
+ export const DisciplineEntitySchema = BaseDisciplineEntitySchema.extend({
50
+ tags: z.array(z.string()).optional(),
51
+ }).openapi("Discipline");
52
+
53
+ export type DisciplineEntity = z.infer<typeof DisciplineEntitySchema>;
54
+
55
+ /**
56
+ * --------------------------------
57
+ * INPUTS
58
+ * --------------------------------
59
+ */
60
+
61
+ export const CreateDisciplinesInputSchema = z.object({
62
+ disciplines: z.array(
63
+ z.object({
64
+ name: z.string().max(128),
65
+ tags: z.array(z.string()).default([]),
74
66
  }),
75
- })
76
- .openapi({ title: "GetDisciplinesInput" });
67
+ ),
68
+ });
77
69
 
78
- export const GetDisciplinesOutputSchema = z
79
- .object({
80
- disciplines: z.array(DisciplineEntitySchema),
81
- })
82
- .openapi({ title: "GetDisciplinesOutput" });
70
+ export type CreateDisciplinesInput = z.infer<
71
+ typeof CreateDisciplinesInputSchema
72
+ >;
83
73
 
84
- export const SlugInputSchema = z
85
- .object({
86
- slug: z.string().max(128).openapi({ example: "mathematics" }),
87
- })
88
- .openapi({ title: "SlugInput" });
74
+ export const GetDisciplinesInputSchema = z.object({
75
+ withTags: z
76
+ .enum(["true", "false"])
77
+ .optional()
78
+ .transform((value) => value === "true"),
79
+ getDefault: z
80
+ .enum(["true", "false"])
81
+ .optional()
82
+ .transform((value) => value === "true"),
83
+ slugs: z.string().optional(),
84
+ });
85
+
86
+ export type GetDisciplinesInput = z.infer<typeof GetDisciplinesInputSchema>;
87
+
88
+ export const SlugInputSchema = z.object({
89
+ slug: z.string().max(128),
90
+ });
91
+
92
+ export type SlugInput = z.infer<typeof SlugInputSchema>;
93
+
94
+ /**
95
+ * --------------------------------
96
+ * OUTPUTS
97
+ * --------------------------------
98
+ */
99
+
100
+ export const DisciplineUpdateOutputSchema = z.object({
101
+ slug: z.string(),
102
+ });
103
+
104
+ export type DisciplineUpdateOutput = z.infer<
105
+ typeof DisciplineUpdateOutputSchema
106
+ >;
107
+
108
+ export const CreateDisciplinesOutputSchema = z.object({
109
+ disciplines: z.array(z.string()),
110
+ });
111
+
112
+ export type CreateDisciplinesOutput = z.infer<
113
+ typeof CreateDisciplinesOutputSchema
114
+ >;
115
+
116
+ export const GetDisciplinesOutputSchema = z.object({
117
+ disciplines: z.array(DisciplineEntitySchema),
118
+ });
119
+
120
+ export type GetDisciplinesOutput = z.infer<typeof GetDisciplinesOutputSchema>;