@zyacreatives/shared 2.2.19 → 2.2.21
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/dist/schemas/common.d.ts +4 -0
- package/dist/schemas/common.js +4 -1
- package/dist/schemas/project.d.ts +421 -285
- package/dist/schemas/project.js +117 -158
- package/dist/schemas/user.d.ts +24 -24
- package/dist/types/project.d.ts +6 -1
- package/package.json +1 -1
- package/src/schemas/common.ts +5 -0
- package/src/schemas/project.ts +132 -167
- package/src/types/project.ts +18 -0
package/src/schemas/project.ts
CHANGED
|
@@ -12,116 +12,62 @@ import { ViewEntitySchema } from "./view";
|
|
|
12
12
|
import { MinimalUserSchema } from "./user";
|
|
13
13
|
import { ActivitySchema } from "./activity";
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* BASE ENTITY SCHEMAS
|
|
17
|
+
*/
|
|
18
|
+
|
|
15
19
|
export const ProjectEntitySchema = z
|
|
16
20
|
.object({
|
|
17
|
-
id: z.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
example: "E-commerce Mobile App",
|
|
28
|
-
}),
|
|
29
|
-
description: z.string().optional().openapi({
|
|
30
|
-
description: "Detailed description of the project, max 1000 characters.",
|
|
31
|
-
example:
|
|
32
|
-
"A modern e-commerce mobile application built with React Native.",
|
|
33
|
-
}),
|
|
34
|
-
overview: z.string().optional().openapi({
|
|
35
|
-
description: "Brief overview of the project.",
|
|
36
|
-
example: "A comprehensive e-commerce solution for mobile devices.",
|
|
37
|
-
}),
|
|
38
|
-
url: z.string().optional().openapi({
|
|
39
|
-
description: "URL to the project or live demo.",
|
|
40
|
-
example: "https://example.com/project",
|
|
41
|
-
}),
|
|
42
|
-
imagePlaceholderUrl: z.url().openapi({
|
|
43
|
-
description: "URL for the placeholder image of the project.",
|
|
44
|
-
example: "https://img.com",
|
|
45
|
-
}),
|
|
46
|
-
tags: z
|
|
47
|
-
.array(z.string())
|
|
48
|
-
.optional()
|
|
49
|
-
.openapi({
|
|
50
|
-
description: "Array of tags associated with the project.",
|
|
51
|
-
example: ["react-native", "e-commerce", "mobile"],
|
|
52
|
-
}),
|
|
53
|
-
projectCreatorType: z.enum(ROLES).openapi({
|
|
54
|
-
description: "Type of creator who made this project.",
|
|
55
|
-
example: "CREATIVE",
|
|
56
|
-
}),
|
|
57
|
-
clientId: z.string().optional().openapi({
|
|
58
|
-
description: "CUID2 of the client if this is a client project.",
|
|
59
|
-
example: "ckl1y9xyz0000qv7a0h1efgh4",
|
|
60
|
-
}),
|
|
21
|
+
id: z.cuid2(),
|
|
22
|
+
userId: z.cuid2(),
|
|
23
|
+
title: z.string(),
|
|
24
|
+
description: z.string().optional(),
|
|
25
|
+
overview: z.string().optional(),
|
|
26
|
+
url: z.url().optional(),
|
|
27
|
+
imagePlaceholderUrl: z.url(),
|
|
28
|
+
tags: z.array(z.string()).optional(),
|
|
29
|
+
projectCreatorType: z.enum(ROLES),
|
|
30
|
+
clientId: z.cuid2().optional(),
|
|
61
31
|
status: z.enum(PROJECT_STATUS),
|
|
62
|
-
clientType: z.enum(CLIENT_TYPES).optional()
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}),
|
|
66
|
-
clientName: z.string().optional().openapi({
|
|
67
|
-
description: "Name of the client.",
|
|
68
|
-
example: "Acme Corp",
|
|
69
|
-
}),
|
|
70
|
-
isFeatured: z.boolean().optional().openapi({
|
|
71
|
-
description: "Whether the project is featured.",
|
|
72
|
-
example: true,
|
|
73
|
-
}),
|
|
32
|
+
clientType: z.enum(CLIENT_TYPES).optional(),
|
|
33
|
+
clientName: z.string().optional(),
|
|
34
|
+
isFeatured: z.boolean().optional(),
|
|
74
35
|
problemBeingSolved: z.string().max(600).optional(),
|
|
75
36
|
whoItsFor: z.string().max(600).optional(),
|
|
76
37
|
ventureStage: z.enum(VENTURE_STAGES).optional(),
|
|
77
38
|
capitalLookingToRaise: z.string(),
|
|
78
39
|
capitalLookingToRaiseCurrency: z.enum(WAGES_CURRENCY).optional(),
|
|
79
40
|
currentTraction: z.string().max(600),
|
|
80
|
-
startDate: z.coerce
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
example: new Date("2024-01-01"),
|
|
86
|
-
}),
|
|
87
|
-
endDate: z.coerce
|
|
88
|
-
.date()
|
|
89
|
-
.optional()
|
|
90
|
-
.openapi({
|
|
91
|
-
description: "End date of the project.",
|
|
92
|
-
example: new Date("2024-06-30"),
|
|
93
|
-
}),
|
|
94
|
-
createdAt: z.coerce.date().openapi({
|
|
95
|
-
description: "Timestamp when the project was created.",
|
|
96
|
-
example: new Date("2024-01-01T00:00:00.000Z"),
|
|
97
|
-
}),
|
|
98
|
-
updatedAt: z.coerce.date().openapi({
|
|
99
|
-
description: "Timestamp when the project was last updated.",
|
|
100
|
-
example: new Date("2024-06-30T00:00:00.000Z"),
|
|
101
|
-
}),
|
|
102
|
-
version: z.int(),
|
|
41
|
+
startDate: z.coerce.date().optional(),
|
|
42
|
+
endDate: z.coerce.date().optional(),
|
|
43
|
+
createdAt: z.coerce.date(),
|
|
44
|
+
updatedAt: z.coerce.date(),
|
|
45
|
+
version: z.number().int(),
|
|
103
46
|
})
|
|
104
|
-
.openapi(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
47
|
+
.openapi("ProjectEntity");
|
|
48
|
+
|
|
49
|
+
export const MinimalProjectSchema = ProjectEntitySchema.pick({
|
|
50
|
+
id: true,
|
|
51
|
+
title: true,
|
|
52
|
+
description: true,
|
|
53
|
+
tags: true,
|
|
54
|
+
startDate: true,
|
|
55
|
+
endDate: true,
|
|
56
|
+
imagePlaceholderUrl: true,
|
|
57
|
+
}).openapi("MinimalProject");
|
|
108
58
|
|
|
109
59
|
export const ProjectSocialGraphEntitySchema = z
|
|
110
60
|
.object({
|
|
111
|
-
noOfLikes: z.number().int().optional()
|
|
112
|
-
noOfComments: z.number().int().optional()
|
|
113
|
-
noOfBookmarks: z.number().int().optional()
|
|
114
|
-
noOfViews: z.number().int().optional()
|
|
61
|
+
noOfLikes: z.number().int().optional(),
|
|
62
|
+
noOfComments: z.number().int().optional(),
|
|
63
|
+
noOfBookmarks: z.number().int().optional(),
|
|
64
|
+
noOfViews: z.number().int().optional(),
|
|
115
65
|
})
|
|
116
66
|
.openapi("ProjectSocialGraphEntity");
|
|
117
67
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
export const ProjectUpdateOutputEntitySchema = z
|
|
123
|
-
.object({ id: z.cuid2() })
|
|
124
|
-
.openapi("ProjectUpdateOutputEntity");
|
|
68
|
+
/**
|
|
69
|
+
* INPUT SCHEMAS
|
|
70
|
+
*/
|
|
125
71
|
|
|
126
72
|
export const CreateProjectInputSchema = z
|
|
127
73
|
.object({
|
|
@@ -130,10 +76,8 @@ export const CreateProjectInputSchema = z
|
|
|
130
76
|
description: z.string().max(1000).optional(),
|
|
131
77
|
overview: z.string().optional(),
|
|
132
78
|
status: z.enum(PROJECT_STATUS).default(PROJECT_STATUS.DRAFT),
|
|
133
|
-
|
|
134
79
|
})
|
|
135
|
-
|
|
136
|
-
.openapi({ title: "Create Project" });
|
|
80
|
+
.openapi("CreateProjectInput");
|
|
137
81
|
|
|
138
82
|
export const UpdateProjectInputSchema = z
|
|
139
83
|
.object({
|
|
@@ -158,91 +102,91 @@ export const UpdateProjectInputSchema = z
|
|
|
158
102
|
currentTraction: z.string().max(600).optional(),
|
|
159
103
|
startDate: z.coerce.date().optional(),
|
|
160
104
|
endDate: z.coerce.date().optional(),
|
|
161
|
-
version: z.int(),
|
|
105
|
+
version: z.number().int(),
|
|
162
106
|
})
|
|
163
107
|
.superRefine(({ startDate, endDate }, ctx) => {
|
|
164
108
|
const today = new Date();
|
|
165
109
|
today.setHours(0, 0, 0, 0);
|
|
166
|
-
if (
|
|
167
|
-
if (startDate > today)
|
|
110
|
+
if (startDate && startDate > today) {
|
|
168
111
|
ctx.addIssue({
|
|
169
112
|
path: ["startDate"],
|
|
170
113
|
code: "custom",
|
|
171
114
|
message: "Start date cannot be in the future",
|
|
172
115
|
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
116
|
+
}
|
|
117
|
+
if (startDate && endDate && startDate > endDate) {
|
|
118
|
+
ctx.addIssue({
|
|
119
|
+
path: ["startDate"],
|
|
120
|
+
code: "custom",
|
|
121
|
+
message: "Start date cannot be after end date",
|
|
122
|
+
});
|
|
180
123
|
}
|
|
181
124
|
})
|
|
182
|
-
.openapi(
|
|
125
|
+
.openapi("UpdateProjectInput");
|
|
183
126
|
|
|
184
|
-
export const
|
|
185
|
-
|
|
186
|
-
|
|
127
|
+
export const SearchProjectsInputSchema = z
|
|
128
|
+
.object({
|
|
129
|
+
query: z.string().optional(),
|
|
130
|
+
tags: z.array(z.string()).optional(),
|
|
131
|
+
limit: z.coerce.number().min(1).max(100).default(20),
|
|
132
|
+
cursor: z.string().optional(),
|
|
133
|
+
})
|
|
134
|
+
.openapi("SearchProjectsInput");
|
|
135
|
+
|
|
136
|
+
export const CommentOnProjectInputSchema = CommentEntitySchema;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* OUTPUT / VIEW SCHEMAS
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
export const ProjectDetailsEntitySchema = ProjectEntitySchema.extend({
|
|
143
|
+
user: MinimalUserSchema,
|
|
144
|
+
}).openapi("ProjectDetailsEntity");
|
|
187
145
|
|
|
188
146
|
export const GetProjectOutputSchema = ProjectDetailsEntitySchema.extend({
|
|
189
147
|
isLiked: z.boolean().optional(),
|
|
190
148
|
isBookmarked: z.boolean().optional(),
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
export const ProjectIdSchema = z.object({ projectId: z.cuid2() });
|
|
194
|
-
export const MinimalProjectSchema = ProjectEntitySchema.pick({
|
|
195
|
-
id: true,
|
|
196
|
-
title: true,
|
|
197
|
-
description: true,
|
|
198
|
-
tags: true,
|
|
199
|
-
startDate: true,
|
|
200
|
-
endDate: true,
|
|
201
|
-
imagePlaceholderUrl: true,
|
|
202
|
-
}).openapi({
|
|
203
|
-
title: "MinimalProject",
|
|
204
|
-
});
|
|
149
|
+
}).openapi("GetProjectOutput");
|
|
205
150
|
|
|
206
|
-
export const
|
|
151
|
+
export const ProjectSearchDocumentSchema = z
|
|
207
152
|
.object({
|
|
208
|
-
|
|
153
|
+
id: z.string(),
|
|
154
|
+
userId: z.string(),
|
|
155
|
+
title: z.string(),
|
|
156
|
+
imagePlaceholderUrl: z.url(),
|
|
157
|
+
projectCreatorType: z.enum(ROLES),
|
|
158
|
+
createdAt: z.number(),
|
|
159
|
+
updatedAt: z.number(),
|
|
160
|
+
description: z.string().optional(),
|
|
161
|
+
capitalLookingToRaise: z.string().optional(),
|
|
162
|
+
capitalLookingToRaiseCurrency: z.enum(WAGES_CURRENCY).optional(),
|
|
163
|
+
url: z.url().optional(),
|
|
209
164
|
tags: z.array(z.string()).optional(),
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
cursor: z
|
|
217
|
-
.string()
|
|
218
|
-
.optional()
|
|
219
|
-
.openapi({ example: "ckl1y9xyz0000qv7a0h1efgh4" }),
|
|
165
|
+
clientId: z.string().optional(),
|
|
166
|
+
clientType: z.enum(CLIENT_TYPES).optional(),
|
|
167
|
+
clientName: z.string().optional(),
|
|
168
|
+
isFeatured: z.boolean().optional(),
|
|
169
|
+
startDate: z.number().optional(),
|
|
170
|
+
endDate: z.number().optional(),
|
|
220
171
|
})
|
|
221
|
-
.openapi(
|
|
222
|
-
title: "ListProjectsInput",
|
|
223
|
-
});
|
|
172
|
+
.openapi("ProjectSearchDocument");
|
|
224
173
|
|
|
225
174
|
export const SearchProjectsOutputSchema = z
|
|
226
175
|
.object({
|
|
227
|
-
projects: z.array(
|
|
176
|
+
projects: z.array(ProjectSearchDocumentSchema),
|
|
228
177
|
nextCursor: z.string().optional().nullable(),
|
|
229
178
|
})
|
|
230
|
-
.openapi(
|
|
231
|
-
title: "SearchProjectsOutput",
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
export const ProjectWithProjectViewsEntitySchema = MinimalProjectSchema.extend({
|
|
235
|
-
views: z.array(ViewEntitySchema),
|
|
236
|
-
}).openapi({
|
|
237
|
-
title: "ProjectWithProjectViewsEntity",
|
|
238
|
-
});
|
|
179
|
+
.openapi("SearchProjectsOutput");
|
|
239
180
|
|
|
240
181
|
export const ProjectWithProjectCommentsEntitySchema =
|
|
241
182
|
MinimalProjectSchema.extend({
|
|
242
183
|
comments: z.array(CommentEntitySchema),
|
|
243
|
-
}).openapi(
|
|
244
|
-
|
|
245
|
-
|
|
184
|
+
}).openapi("ProjectWithProjectCommentsEntity");
|
|
185
|
+
|
|
186
|
+
export const GetProjectWithCommentsOutputSchema =
|
|
187
|
+
ProjectWithProjectCommentsEntitySchema.extend({
|
|
188
|
+
nextCursor: z.string().optional().nullable(),
|
|
189
|
+
}).openapi("GetProjectWithCommentsOutput");
|
|
246
190
|
|
|
247
191
|
export const ProjectWithLikesEntitySchema = MinimalProjectSchema.extend({
|
|
248
192
|
likes: z.array(
|
|
@@ -251,23 +195,44 @@ export const ProjectWithLikesEntitySchema = MinimalProjectSchema.extend({
|
|
|
251
195
|
isFollowing: z.boolean().optional(),
|
|
252
196
|
}),
|
|
253
197
|
),
|
|
254
|
-
}).openapi(
|
|
255
|
-
|
|
256
|
-
|
|
198
|
+
}).openapi("ProjectWithLikesEntity");
|
|
199
|
+
|
|
200
|
+
export const GetProjectWithLikesOutputSchema =
|
|
201
|
+
ProjectWithLikesEntitySchema.extend({
|
|
202
|
+
nextCursor: z.string().optional().nullable(),
|
|
203
|
+
}).openapi("GetProjectWithLikesOutput");
|
|
204
|
+
|
|
205
|
+
export const ProjectWithProjectViewsEntitySchema = MinimalProjectSchema.extend({
|
|
206
|
+
views: z.array(ViewEntitySchema),
|
|
207
|
+
}).openapi("ProjectWithProjectViewsEntity");
|
|
257
208
|
|
|
258
209
|
export const ProjectWithProjectBookmarksEntitySchema =
|
|
259
210
|
MinimalProjectSchema.extend({
|
|
260
211
|
bookmarks: z.array(BookmarkEntitySchema),
|
|
261
|
-
}).openapi(
|
|
262
|
-
title: "ProjectWithProjectBookmarksEntity",
|
|
263
|
-
});
|
|
212
|
+
}).openapi("ProjectWithProjectBookmarksEntity");
|
|
264
213
|
|
|
265
|
-
export const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
214
|
+
export const ProjectUpdateOutputEntitySchema = z.object({
|
|
215
|
+
id: z.cuid2(),
|
|
216
|
+
});
|
|
217
|
+
export const CreateProjectOutputSchema = ProjectEntitySchema;
|
|
218
|
+
export const UpdateProjectOutputSchema = ProjectEntitySchema;
|
|
219
|
+
export const DeleteProjectOutputSchema = ProjectEntitySchema;
|
|
220
|
+
export const CommentOnProjectOutputSchema = CommentEntitySchema.omit({
|
|
221
|
+
likesCount: true,
|
|
222
|
+
isLiked: true,
|
|
223
|
+
});
|
|
269
224
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
225
|
+
/**
|
|
226
|
+
* SEARCH & UTILITY SCHEMAS
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
export const ProjectIdSchema = z.object({ projectId: z.cuid2() });
|
|
230
|
+
|
|
231
|
+
export const CreateProjectFileInputSchema = z.object({
|
|
232
|
+
key: z.string().max(500),
|
|
233
|
+
projectId: z.cuid2(),
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
export const DeleteProjectFileInputSchema = z.object({
|
|
237
|
+
keys: z.array(z.string()),
|
|
238
|
+
});
|
package/src/types/project.ts
CHANGED
|
@@ -18,6 +18,11 @@ import type {
|
|
|
18
18
|
SearchProjectsOutputSchema,
|
|
19
19
|
GetProjectWithLikesOutputSchema,
|
|
20
20
|
GetProjectWithCommentsOutputSchema,
|
|
21
|
+
CommentOnProjectInputSchema,
|
|
22
|
+
CommentOnProjectOutputSchema,
|
|
23
|
+
ProjectSearchDocumentSchema,
|
|
24
|
+
CreateProjectFileInputSchema,
|
|
25
|
+
DeleteProjectFileInputSchema,
|
|
21
26
|
} from "../schemas/project";
|
|
22
27
|
import { ViewEntitySchema } from "../schemas/view";
|
|
23
28
|
import { LikeEntitySchema } from "../schemas/like";
|
|
@@ -61,3 +66,16 @@ export type GetProjectWithCommentsOutput = z.infer<
|
|
|
61
66
|
export type GetProjectWithLikesOutput = z.infer<
|
|
62
67
|
typeof GetProjectWithLikesOutputSchema
|
|
63
68
|
>;
|
|
69
|
+
|
|
70
|
+
export type CommentOnProjectInput = z.infer<typeof CommentOnProjectInputSchema>;
|
|
71
|
+
|
|
72
|
+
export type CommentOnProjectOutput = z.infer<
|
|
73
|
+
typeof CommentOnProjectOutputSchema
|
|
74
|
+
>;
|
|
75
|
+
|
|
76
|
+
export type ProjectSearchDocument = z.infer<typeof ProjectSearchDocumentSchema>;
|
|
77
|
+
|
|
78
|
+
export type ProjectFileInput = z.infer<typeof CreateProjectFileInputSchema>;
|
|
79
|
+
export type DeleteProjectFileInput = z.infer<
|
|
80
|
+
typeof DeleteProjectFileInputSchema
|
|
81
|
+
>;
|