@zyacreatives/shared 1.7.4 → 1.7.6

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.
@@ -1,11 +1,13 @@
1
1
  import { z } from "@hono/zod-openapi";
2
2
  export declare const PostEntitySchema: z.ZodObject<{
3
3
  id: z.ZodCUID2;
4
- parentId: z.ZodCUID2;
4
+ parentId: z.ZodOptional<z.ZodCUID2>;
5
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
+ badge: z.ZodOptional<z.ZodString>;
5
7
  userId: z.ZodCUID2;
6
8
  content: z.ZodString;
7
9
  title: z.ZodNullable<z.ZodString>;
8
- parentType: z.ZodEnum<{
10
+ postType: z.ZodEnum<{
9
11
  readonly MARKETPLACE: "MARKETPLACE";
10
12
  readonly PROJECT: "PROJECT";
11
13
  readonly JOB_OPENING: "JOB_OPENING";
@@ -22,11 +24,13 @@ export declare const PostFileEntitySchema: z.ZodObject<{
22
24
  }, z.core.$strip>;
23
25
  export declare const PostWithFilesEntitySchema: z.ZodObject<{
24
26
  id: z.ZodCUID2;
25
- parentId: z.ZodCUID2;
27
+ parentId: z.ZodOptional<z.ZodCUID2>;
28
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
29
+ badge: z.ZodOptional<z.ZodString>;
26
30
  userId: z.ZodCUID2;
27
31
  content: z.ZodString;
28
32
  title: z.ZodNullable<z.ZodString>;
29
- parentType: z.ZodEnum<{
33
+ postType: z.ZodEnum<{
30
34
  readonly MARKETPLACE: "MARKETPLACE";
31
35
  readonly PROJECT: "PROJECT";
32
36
  readonly JOB_OPENING: "JOB_OPENING";
@@ -50,3 +54,81 @@ export declare const PostWithFilesEntitySchema: z.ZodObject<{
50
54
  }, z.core.$strip>;
51
55
  }, z.core.$strip>>>;
52
56
  }, z.core.$strip>;
57
+ export declare const CreatePostInputSchema: z.ZodObject<{
58
+ parentId: z.ZodOptional<z.ZodCUID2>;
59
+ userId: z.ZodCUID2;
60
+ content: z.ZodString;
61
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
62
+ postType: z.ZodDefault<z.ZodEnum<{
63
+ readonly MARKETPLACE: "MARKETPLACE";
64
+ readonly PROJECT: "PROJECT";
65
+ readonly JOB_OPENING: "JOB_OPENING";
66
+ readonly DEFAULT_POST: "DEFAULT_POST";
67
+ readonly POST_WITH_MEDIA: "POST_WITH_MEDIA";
68
+ }>>;
69
+ files: z.ZodArray<z.ZodObject<{
70
+ key: z.ZodString;
71
+ mimeType: z.ZodString;
72
+ order: z.ZodDefault<z.ZodInt>;
73
+ }, z.core.$strip>>;
74
+ }, z.core.$strip>;
75
+ export declare const MinimalPostSchema: z.ZodObject<{
76
+ id: z.ZodCUID2;
77
+ title: z.ZodNullable<z.ZodString>;
78
+ parentId: z.ZodOptional<z.ZodCUID2>;
79
+ content: z.ZodString;
80
+ }, z.core.$strip>;
81
+ export declare const PostWithLikesEntitySchema: z.ZodObject<{
82
+ id: z.ZodCUID2;
83
+ title: z.ZodNullable<z.ZodString>;
84
+ parentId: z.ZodOptional<z.ZodCUID2>;
85
+ content: z.ZodString;
86
+ likes: z.ZodArray<z.ZodObject<{
87
+ id: z.ZodCUID2;
88
+ createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
89
+ userId: z.ZodCUID2;
90
+ parentId: z.ZodCUID2;
91
+ parentType: z.ZodEnum<{
92
+ readonly PROJECT: "PROJECT";
93
+ readonly POST: "POST";
94
+ }>;
95
+ }, z.core.$strip>>;
96
+ }, z.core.$strip>;
97
+ export declare const PostWithCommentsEntitySchema: z.ZodObject<{
98
+ id: z.ZodCUID2;
99
+ title: z.ZodNullable<z.ZodString>;
100
+ parentId: z.ZodOptional<z.ZodCUID2>;
101
+ content: z.ZodString;
102
+ comments: z.ZodArray<z.ZodObject<{
103
+ id: z.ZodCUID2;
104
+ userId: z.ZodCUID2;
105
+ parentId: z.ZodCUID2;
106
+ parentType: z.ZodEnum<{
107
+ readonly PROJECT: "PROJECT";
108
+ readonly POST: "POST";
109
+ }>;
110
+ content: z.ZodString;
111
+ commenterUsername: z.ZodString;
112
+ commenterName: z.ZodString;
113
+ commenterImageUrl: z.ZodOptional<z.ZodString>;
114
+ replyToId: z.ZodNullable<z.ZodOptional<z.ZodCUID2>>;
115
+ createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
116
+ updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
117
+ }, z.core.$strip>>;
118
+ }, z.core.$strip>;
119
+ export declare const PostWithBookmarksEntitySchema: z.ZodObject<{
120
+ id: z.ZodCUID2;
121
+ title: z.ZodNullable<z.ZodString>;
122
+ parentId: z.ZodOptional<z.ZodCUID2>;
123
+ content: z.ZodString;
124
+ bookmarks: z.ZodArray<z.ZodObject<{
125
+ id: z.ZodCUID2;
126
+ createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
127
+ userId: z.ZodCUID2;
128
+ parentId: z.ZodCUID2;
129
+ parentType: z.ZodEnum<{
130
+ readonly PROJECT: "PROJECT";
131
+ readonly POST: "POST";
132
+ }>;
133
+ }, z.core.$strip>>;
134
+ }, z.core.$strip>;
@@ -1,16 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostWithFilesEntitySchema = exports.PostFileEntitySchema = exports.PostEntitySchema = void 0;
3
+ exports.PostWithBookmarksEntitySchema = exports.PostWithCommentsEntitySchema = exports.PostWithLikesEntitySchema = exports.MinimalPostSchema = exports.CreatePostInputSchema = exports.PostWithFilesEntitySchema = exports.PostFileEntitySchema = exports.PostEntitySchema = void 0;
4
4
  const zod_openapi_1 = require("@hono/zod-openapi");
5
5
  const constants_1 = require("../constants");
6
6
  const file_1 = require("./file");
7
+ const bookmark_1 = require("./bookmark");
8
+ const comment_1 = require("./comment");
9
+ const like_1 = require("./like");
7
10
  exports.PostEntitySchema = zod_openapi_1.z.object({
8
11
  id: zod_openapi_1.z
9
12
  .cuid2()
10
13
  .openapi({ description: "Post id", example: "ckj1a2b3c0000xyz" }),
11
14
  parentId: zod_openapi_1.z
12
15
  .cuid2()
16
+ .optional()
13
17
  .openapi({ description: "Parent id", example: "ckj1a2b3c0000abc" }),
18
+ tags: zod_openapi_1.z.array(zod_openapi_1.z.string()).optional(),
19
+ badge: zod_openapi_1.z.string().optional(),
14
20
  userId: zod_openapi_1.z
15
21
  .cuid2()
16
22
  .openapi({ description: "User id", example: "ckj1a2b3c0000def" }),
@@ -21,7 +27,7 @@ exports.PostEntitySchema = zod_openapi_1.z.object({
21
27
  .string()
22
28
  .nullable()
23
29
  .openapi({ description: "Optional title", example: "My first post" }),
24
- parentType: zod_openapi_1.z.enum(constants_1.POST_TYPES).openapi({
30
+ postType: zod_openapi_1.z.enum(constants_1.POST_TYPES).openapi({
25
31
  description: "Type of the post entity this statistic belongs to.",
26
32
  title: "Post Type",
27
33
  }),
@@ -53,3 +59,49 @@ exports.PostWithFilesEntitySchema = exports.PostEntitySchema.extend({
53
59
  .optional()
54
60
  .openapi({ description: "Files associated with the project." }),
55
61
  }).openapi({ title: "ProjectWithFilesEntity" });
62
+ exports.CreatePostInputSchema = zod_openapi_1.z.object({
63
+ parentId: zod_openapi_1.z
64
+ .cuid2()
65
+ .optional()
66
+ .openapi({ description: "Parent id", example: "ckl1a2b3c0000abc" }),
67
+ userId: zod_openapi_1.z
68
+ .cuid2()
69
+ .openapi({ description: "User id", example: "ckl1a2b3c0000def" }),
70
+ content: zod_openapi_1.z.string().openapi({
71
+ description: "Post content",
72
+ example: "New project announcement",
73
+ }),
74
+ title: zod_openapi_1.z
75
+ .string()
76
+ .nullable()
77
+ .optional()
78
+ .openapi({ description: "Optional title", example: "Project launch" }),
79
+ postType: zod_openapi_1.z
80
+ .enum(constants_1.POST_TYPES)
81
+ .default("DEFAULT_POST")
82
+ .openapi({ description: "Post type", example: "PROJECT" }),
83
+ files: zod_openapi_1.z.array(file_1.CreateFileInputSchema.extend({
84
+ order: zod_openapi_1.z.int().default(1),
85
+ })),
86
+ });
87
+ exports.MinimalPostSchema = exports.PostEntitySchema.pick({
88
+ title: true,
89
+ id: true,
90
+ parentId: true,
91
+ content: true,
92
+ });
93
+ exports.PostWithLikesEntitySchema = exports.MinimalPostSchema.extend({
94
+ likes: zod_openapi_1.z.array(like_1.LikeEntitySchema),
95
+ }).openapi({
96
+ title: "PostWithPostLikesEntity",
97
+ });
98
+ exports.PostWithCommentsEntitySchema = exports.MinimalPostSchema.extend({
99
+ comments: zod_openapi_1.z.array(comment_1.CommentEntitySchema),
100
+ }).openapi({
101
+ title: "PostWithPostCommentsEntity",
102
+ });
103
+ exports.PostWithBookmarksEntitySchema = exports.MinimalPostSchema.extend({
104
+ bookmarks: zod_openapi_1.z.array(bookmark_1.BookmarkEntitySchema),
105
+ }).openapi({
106
+ title: "PostWithPostBookmarksEntity",
107
+ });
@@ -1,4 +1,5 @@
1
1
  import z from "zod";
2
2
  import { ProjectSocialGraphEntitySchema, UserSocialGraphEntitySchema } from "../schemas";
3
3
  export type ProjectSocialGraphEntity = z.infer<typeof ProjectSocialGraphEntitySchema>;
4
+ export type PostSocialGraphEntity = z.infer<typeof ProjectSocialGraphEntitySchema>;
4
5
  export type UserSocialGraphEntity = z.infer<typeof UserSocialGraphEntitySchema>;
@@ -1,5 +1,9 @@
1
1
  import { z } from "@hono/zod-openapi";
2
- import { PostEntitySchema, PostFileEntitySchema, PostWithFilesEntitySchema } from "../schemas/post";
2
+ import { CreatePostInputSchema, PostEntitySchema, PostFileEntitySchema, PostWithBookmarksEntitySchema, PostWithCommentsEntitySchema, PostWithFilesEntitySchema, PostWithLikesEntitySchema } from "../schemas/post";
3
3
  export type PostEntity = z.infer<typeof PostEntitySchema>;
4
4
  export type PostFileEntity = z.infer<typeof PostFileEntitySchema>;
5
5
  export type PostWithFilesEntity = z.infer<typeof PostWithFilesEntitySchema>;
6
+ export type CreatePostInput = z.infer<typeof CreatePostInputSchema>;
7
+ export type PostWithPostLikesEntity = z.infer<typeof PostWithLikesEntitySchema>;
8
+ export type PostWithPostBookmarksEntity = z.infer<typeof PostWithBookmarksEntitySchema>;
9
+ export type PostWithPostCommentsEntity = z.infer<typeof PostWithCommentsEntitySchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyacreatives/shared",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,6 +1,9 @@
1
1
  import { z } from "@hono/zod-openapi";
2
2
  import { POST_TYPES } from "../constants";
3
- import { FileEntitySchema } from "./file";
3
+ import { CreateFileInputSchema, FileEntitySchema } from "./file";
4
+ import { BookmarkEntitySchema } from "./bookmark";
5
+ import { CommentEntitySchema } from "./comment";
6
+ import { LikeEntitySchema } from "./like";
4
7
 
5
8
  export const PostEntitySchema = z.object({
6
9
  id: z
@@ -8,7 +11,10 @@ export const PostEntitySchema = z.object({
8
11
  .openapi({ description: "Post id", example: "ckj1a2b3c0000xyz" }),
9
12
  parentId: z
10
13
  .cuid2()
14
+ .optional()
11
15
  .openapi({ description: "Parent id", example: "ckj1a2b3c0000abc" }),
16
+ tags: z.array(z.string()).optional(),
17
+ badge: z.string().optional(),
12
18
  userId: z
13
19
  .cuid2()
14
20
  .openapi({ description: "User id", example: "ckj1a2b3c0000def" }),
@@ -19,7 +25,7 @@ export const PostEntitySchema = z.object({
19
25
  .string()
20
26
  .nullable()
21
27
  .openapi({ description: "Optional title", example: "My first post" }),
22
- parentType: z.enum(POST_TYPES).openapi({
28
+ postType: z.enum(POST_TYPES).openapi({
23
29
  description: "Type of the post entity this statistic belongs to.",
24
30
  title: "Post Type",
25
31
  }),
@@ -56,3 +62,55 @@ export const PostWithFilesEntitySchema = PostEntitySchema.extend({
56
62
  .openapi({ description: "Files associated with the project." }),
57
63
  }).openapi({ title: "ProjectWithFilesEntity" });
58
64
 
65
+ export const CreatePostInputSchema = z.object({
66
+ parentId: z
67
+ .cuid2()
68
+ .optional()
69
+ .openapi({ description: "Parent id", example: "ckl1a2b3c0000abc" }),
70
+ userId: z
71
+ .cuid2()
72
+ .openapi({ description: "User id", example: "ckl1a2b3c0000def" }),
73
+ content: z.string().openapi({
74
+ description: "Post content",
75
+ example: "New project announcement",
76
+ }),
77
+ title: z
78
+ .string()
79
+ .nullable()
80
+ .optional()
81
+ .openapi({ description: "Optional title", example: "Project launch" }),
82
+ postType: z
83
+ .enum(POST_TYPES)
84
+ .default("DEFAULT_POST")
85
+ .openapi({ description: "Post type", example: "PROJECT" }),
86
+ files: z.array(
87
+ CreateFileInputSchema.extend({
88
+ order: z.int().default(1),
89
+ })
90
+ ),
91
+ });
92
+
93
+ export const MinimalPostSchema = PostEntitySchema.pick({
94
+ title: true,
95
+ id: true,
96
+ parentId: true,
97
+ content: true,
98
+ });
99
+
100
+ export const PostWithLikesEntitySchema = MinimalPostSchema.extend({
101
+ likes: z.array(LikeEntitySchema),
102
+ }).openapi({
103
+ title: "PostWithPostLikesEntity",
104
+ });
105
+
106
+ export const PostWithCommentsEntitySchema = MinimalPostSchema.extend({
107
+ comments: z.array(CommentEntitySchema),
108
+ }).openapi({
109
+ title: "PostWithPostCommentsEntity",
110
+ });
111
+
112
+ export const PostWithBookmarksEntitySchema = MinimalPostSchema.extend({
113
+ bookmarks: z.array(BookmarkEntitySchema),
114
+ }).openapi({
115
+ title: "PostWithPostBookmarksEntity",
116
+ });
@@ -7,4 +7,7 @@ import {
7
7
  export type ProjectSocialGraphEntity = z.infer<
8
8
  typeof ProjectSocialGraphEntitySchema
9
9
  >;
10
+ export type PostSocialGraphEntity = z.infer<
11
+ typeof ProjectSocialGraphEntitySchema
12
+ >;
10
13
  export type UserSocialGraphEntity = z.infer<typeof UserSocialGraphEntitySchema>;
package/src/types/post.ts CHANGED
@@ -1,10 +1,22 @@
1
1
  import { z } from "@hono/zod-openapi";
2
2
  import {
3
+ CreatePostInputSchema,
3
4
  PostEntitySchema,
4
5
  PostFileEntitySchema,
6
+ PostWithBookmarksEntitySchema,
7
+ PostWithCommentsEntitySchema,
5
8
  PostWithFilesEntitySchema,
9
+ PostWithLikesEntitySchema,
6
10
  } from "../schemas/post";
7
11
 
8
12
  export type PostEntity = z.infer<typeof PostEntitySchema>;
9
13
  export type PostFileEntity = z.infer<typeof PostFileEntitySchema>;
10
14
  export type PostWithFilesEntity = z.infer<typeof PostWithFilesEntitySchema>;
15
+ export type CreatePostInput = z.infer<typeof CreatePostInputSchema>;
16
+ export type PostWithPostLikesEntity = z.infer<typeof PostWithLikesEntitySchema>;
17
+ export type PostWithPostBookmarksEntity = z.infer<
18
+ typeof PostWithBookmarksEntitySchema
19
+ >;
20
+ export type PostWithPostCommentsEntity = z.infer<
21
+ typeof PostWithCommentsEntitySchema
22
+ >;