@zyacreatives/shared 2.5.55 → 2.5.57

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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProjectIdSchema = exports.CommentOnProjectOutputSchema = exports.DeleteProjectOutputSchema = exports.UpdateProjectOutputSchema = exports.CreateProjectOutputSchema = exports.ProjectUpdateOutputEntitySchema = exports.ProjectWithProjectBookmarksEntitySchema = exports.GetProjectWithLikesOutputSchema = exports.ProjectWithLikesEntitySchema = exports.GetProjectWithCommentsOutputSchema = exports.ProjectWithProjectCommentsEntitySchema = exports.SearchProjectsOutputSchema = exports.SearchProjectsInputSchema = exports.ProjectSearchDocumentSchema = exports.GetProjectOutputSchema = exports.ProjectDetailsEntitySchema = exports.CommentOnProjectInputSchema = exports.UpdateProjectInputSchema = exports.CreateProjectInputSchema = exports.ProjectSocialGraphEntitySchema = exports.MinimalProjectSchema = exports.ProjectWithFilesEntitySchema = exports.ProjectEntitySchema = void 0;
3
+ exports.CommentOnProjectOutputSchema = exports.DeleteProjectOutputSchema = exports.UpdateProjectOutputSchema = exports.CreateProjectOutputSchema = exports.ProjectUpdateOutputEntitySchema = exports.GetProjectWithLikesOutputSchema = exports.GetProjectWithCommentsOutputSchema = exports.SearchProjectsOutputSchema = exports.GetProjectOutputSchema = exports.ProjectSearchDocumentSchema = exports.ProjectIdSchema = exports.SearchProjectsInputSchema = exports.CommentOnProjectInputSchema = exports.UpdateProjectInputSchema = exports.CreateProjectInputSchema = exports.ProjectWithProjectBookmarksEntitySchema = exports.ProjectWithLikesEntitySchema = exports.ProjectWithProjectCommentsEntitySchema = exports.ProjectDetailsEntitySchema = exports.ProjectSocialGraphEntitySchema = exports.MinimalProjectSchema = exports.ProjectWithFilesEntitySchema = exports.ProjectEntitySchema = void 0;
4
4
  const zod_openapi_1 = require("@hono/zod-openapi");
5
5
  const constants_1 = require("../constants");
6
6
  const comment_1 = require("./comment");
@@ -8,10 +8,12 @@ const bookmark_1 = require("./bookmark");
8
8
  const user_1 = require("./user");
9
9
  const activity_1 = require("./activity");
10
10
  const file_1 = require("./file");
11
- exports.ProjectEntitySchema = zod_openapi_1.z
12
- .object({
13
- id: zod_openapi_1.z.cuid2(),
14
- userId: zod_openapi_1.z.cuid2(),
11
+ /**
12
+ * --------------------------------
13
+ * SHAPE
14
+ * --------------------------------
15
+ */
16
+ const ProjectShape = zod_openapi_1.z.object({
15
17
  title: zod_openapi_1.z.string(),
16
18
  description: zod_openapi_1.z.string().optional(),
17
19
  overview: zod_openapi_1.z.string().optional(),
@@ -20,9 +22,9 @@ exports.ProjectEntitySchema = zod_openapi_1.z
20
22
  tags: zod_openapi_1.z.array(zod_openapi_1.z.string()).optional(),
21
23
  projectCreatorType: zod_openapi_1.z.enum(constants_1.ROLES),
22
24
  clientId: zod_openapi_1.z.cuid2().optional(),
23
- status: zod_openapi_1.z.enum(constants_1.PROJECT_STATUS),
24
25
  clientType: zod_openapi_1.z.enum(constants_1.CLIENT_TYPES).optional(),
25
26
  clientName: zod_openapi_1.z.string().optional(),
27
+ status: zod_openapi_1.z.enum(constants_1.PROJECT_STATUS),
26
28
  isFeatured: zod_openapi_1.z.boolean().optional(),
27
29
  problemBeingSolved: zod_openapi_1.z.string().max(600).optional(),
28
30
  whoItsFor: zod_openapi_1.z.string().max(600).optional(),
@@ -31,16 +33,32 @@ exports.ProjectEntitySchema = zod_openapi_1.z
31
33
  capitalLookingToRaiseCurrency: zod_openapi_1.z.enum(constants_1.WAGES_CURRENCY).optional(),
32
34
  currentTraction: zod_openapi_1.z.string().max(600),
33
35
  isOpenToInvestment: zod_openapi_1.z.boolean().default(false),
34
- startDate: zod_openapi_1.z.coerce.date().optional(),
35
- endDate: zod_openapi_1.z.coerce.date().optional(),
36
- createdAt: zod_openapi_1.z.coerce.date(),
37
- updatedAt: zod_openapi_1.z.coerce.date(),
38
- version: zod_openapi_1.z.number().int(),
36
+ startDate: zod_openapi_1.z.iso.datetime().optional(),
37
+ endDate: zod_openapi_1.z.iso.datetime().optional(),
38
+ });
39
+ /**
40
+ * --------------------------------
41
+ * BASE ENTITY
42
+ * --------------------------------
43
+ */
44
+ exports.ProjectEntitySchema = zod_openapi_1.z
45
+ .object({
46
+ id: zod_openapi_1.z.cuid2(),
47
+ userId: zod_openapi_1.z.cuid2(),
48
+ ...ProjectShape.shape,
49
+ createdAt: zod_openapi_1.z.iso.datetime(),
50
+ updatedAt: zod_openapi_1.z.iso.datetime(),
51
+ version: zod_openapi_1.z.int(),
39
52
  })
40
- .openapi("ProjectEntity");
53
+ .openapi("Project");
54
+ /**
55
+ * --------------------------------
56
+ * DERIVED ENTITIES
57
+ * --------------------------------
58
+ */
41
59
  exports.ProjectWithFilesEntitySchema = exports.ProjectEntitySchema.extend({
42
60
  files: zod_openapi_1.z.array(file_1.FileEntitySchema).optional(),
43
- }).openapi("ProjectWithFilesEntity");
61
+ }).openapi("ProjectWithFiles");
44
62
  exports.MinimalProjectSchema = exports.ProjectEntitySchema.pick({
45
63
  id: true,
46
64
  title: true,
@@ -57,7 +75,61 @@ exports.ProjectSocialGraphEntitySchema = zod_openapi_1.z
57
75
  noOfBookmarks: zod_openapi_1.z.number().int().optional(),
58
76
  noOfViews: zod_openapi_1.z.number().int().optional(),
59
77
  })
60
- .openapi("ProjectSocialGraphEntity");
78
+ .openapi("ProjectSocialGraph");
79
+ exports.ProjectDetailsEntitySchema = exports.ProjectEntitySchema.extend({
80
+ user: user_1.MinimalUserSchema,
81
+ files: zod_openapi_1.z.array(file_1.FileEntitySchema).optional(),
82
+ }).openapi("ProjectDetails");
83
+ exports.ProjectWithProjectCommentsEntitySchema = exports.MinimalProjectSchema.extend({
84
+ comments: zod_openapi_1.z.array(comment_1.CommentEntitySchema),
85
+ }).openapi("ProjectWithProjectComments");
86
+ exports.ProjectWithLikesEntitySchema = exports.MinimalProjectSchema.extend({
87
+ likes: zod_openapi_1.z.array(activity_1.ActivitySchema.extend({
88
+ followsYou: zod_openapi_1.z.boolean().optional(),
89
+ isFollowing: zod_openapi_1.z.boolean().optional(),
90
+ })),
91
+ }).openapi("ProjectWithLikes");
92
+ exports.ProjectWithProjectBookmarksEntitySchema = exports.MinimalProjectSchema.extend({
93
+ bookmarks: zod_openapi_1.z.array(bookmark_1.BookmarkEntitySchema),
94
+ }).openapi("ProjectWithProjectBookmarks");
95
+ /**
96
+ * --------------------------------
97
+ * INPUT HELPERS
98
+ * --------------------------------
99
+ */
100
+ const coerceArray = (value) => {
101
+ if (typeof value === "string")
102
+ return value === "" ? [] : value.split(",");
103
+ return value;
104
+ };
105
+ const coerceBoolean = (value) => {
106
+ if (value === "true")
107
+ return true;
108
+ if (value === "false")
109
+ return false;
110
+ return value;
111
+ };
112
+ const nullableStringToUndefined = (value) => {
113
+ if (value === "" || value === null || value === undefined)
114
+ return undefined;
115
+ return value;
116
+ };
117
+ const urlInputSchema = zod_openapi_1.z
118
+ .string()
119
+ .transform((value) => {
120
+ if (!value)
121
+ return value;
122
+ if (value.startsWith("http://") || value.startsWith("https://")) {
123
+ return value;
124
+ }
125
+ return `https://${value}`;
126
+ })
127
+ .pipe(zod_openapi_1.z.url().or(zod_openapi_1.z.literal("")));
128
+ /**
129
+ * --------------------------------
130
+ * INPUTS
131
+ * --------------------------------
132
+ */
61
133
  exports.CreateProjectInputSchema = zod_openapi_1.z
62
134
  .object({
63
135
  id: zod_openapi_1.z.cuid2().optional(),
@@ -76,25 +148,11 @@ exports.UpdateProjectInputSchema = zod_openapi_1.z
76
148
  .min(10, "Add a bit more detail to your description.")
77
149
  .optional(),
78
150
  overview: zod_openapi_1.z.string().optional(),
79
- url: zod_openapi_1.z
80
- .string()
81
- .transform((val) => {
82
- if (!val)
83
- return val;
84
- if (val.startsWith("http://") || val.startsWith("https://"))
85
- return val;
86
- return `https://${val}`;
87
- })
88
- .pipe(zod_openapi_1.z.url("Check your link.").or(zod_openapi_1.z.literal("")))
89
- .optional(),
151
+ url: urlInputSchema.optional(),
90
152
  imagePlaceholderUrl: zod_openapi_1.z.url().optional().or(zod_openapi_1.z.literal("")),
91
153
  tags: zod_openapi_1.z.array(zod_openapi_1.z.string()).optional(),
92
154
  projectCreatorType: zod_openapi_1.z.enum(constants_1.ROLES).optional(),
93
- clientId: zod_openapi_1.z
94
- .string()
95
- .optional()
96
- .transform((val) => (val === "" || val === undefined ? undefined : val))
97
- .pipe(zod_openapi_1.z.cuid2().optional()),
155
+ clientId: zod_openapi_1.z.preprocess(nullableStringToUndefined, zod_openapi_1.z.cuid2().optional()),
98
156
  clientType: zod_openapi_1.z.enum(constants_1.CLIENT_TYPES).optional(),
99
157
  clientName: zod_openapi_1.z.string().optional(),
100
158
  isFeatured: zod_openapi_1.z.boolean().optional(),
@@ -118,21 +176,25 @@ exports.UpdateProjectInputSchema = zod_openapi_1.z
118
176
  .max(600)
119
177
  .optional(),
120
178
  isOpenToInvestment: zod_openapi_1.z.boolean().default(false),
121
- startDate: zod_openapi_1.z.coerce.date().optional(),
122
- endDate: zod_openapi_1.z.coerce.date().optional(),
123
- version: zod_openapi_1.z.number().int().default(1),
179
+ startDate: zod_openapi_1.z.iso.datetime().optional(),
180
+ endDate: zod_openapi_1.z.iso.datetime().optional(),
181
+ version: zod_openapi_1.z.int().default(1),
124
182
  })
125
183
  .superRefine(({ startDate, endDate }, ctx) => {
184
+ if (!startDate)
185
+ return;
126
186
  const today = new Date();
127
187
  today.setHours(0, 0, 0, 0);
128
- if (startDate && startDate > today) {
188
+ const parsedStartDate = new Date(startDate);
189
+ const parsedEndDate = endDate ? new Date(endDate) : undefined;
190
+ if (parsedStartDate > today) {
129
191
  ctx.addIssue({
130
192
  path: ["startDate"],
131
193
  code: "custom",
132
194
  message: "Start date cannot be in the future.",
133
195
  });
134
196
  }
135
- if (startDate && endDate && startDate > endDate) {
197
+ if (parsedEndDate && parsedStartDate > parsedEndDate) {
136
198
  ctx.addIssue({
137
199
  path: ["endDate"],
138
200
  code: "custom",
@@ -142,24 +204,44 @@ exports.UpdateProjectInputSchema = zod_openapi_1.z
142
204
  })
143
205
  .openapi("UpdateProjectInput");
144
206
  exports.CommentOnProjectInputSchema = comment_1.CommentEntitySchema;
145
- exports.ProjectDetailsEntitySchema = exports.ProjectEntitySchema.extend({
146
- user: user_1.MinimalUserSchema,
147
- files: zod_openapi_1.z.array(file_1.FileEntitySchema).optional(),
148
- }).openapi("ProjectDetailsEntity");
149
- exports.GetProjectOutputSchema = exports.ProjectDetailsEntitySchema.extend({
150
- isLiked: zod_openapi_1.z.boolean().optional(),
151
- isBookmarked: zod_openapi_1.z.boolean().optional(),
152
- }).openapi("GetProjectOutput");
207
+ exports.SearchProjectsInputSchema = zod_openapi_1.z
208
+ .object({
209
+ query: zod_openapi_1.z.string().optional(),
210
+ limit: zod_openapi_1.z.coerce.number().min(1).max(100).default(40),
211
+ cursor: zod_openapi_1.z.string().optional(),
212
+ tags: zod_openapi_1.z.preprocess(coerceArray, zod_openapi_1.z.array(zod_openapi_1.z.string())).optional(),
213
+ isOpenToInvestment: zod_openapi_1.z.preprocess(coerceBoolean, zod_openapi_1.z.boolean()).optional(),
214
+ minCapital: zod_openapi_1.z.coerce.number().optional(),
215
+ maxCapital: zod_openapi_1.z.coerce.number().optional(),
216
+ ventureStages: zod_openapi_1.z
217
+ .preprocess(coerceArray, zod_openapi_1.z.array(zod_openapi_1.z.enum(constants_1.VENTURE_STAGES)))
218
+ .optional(),
219
+ projectCreatorTypes: zod_openapi_1.z
220
+ .preprocess(coerceArray, zod_openapi_1.z.array(zod_openapi_1.z.enum(constants_1.ROLES)))
221
+ .optional(),
222
+ clientTypes: zod_openapi_1.z
223
+ .preprocess(coerceArray, zod_openapi_1.z.array(zod_openapi_1.z.enum(constants_1.CLIENT_TYPES)))
224
+ .optional(),
225
+ })
226
+ .openapi("SearchProjectsInput");
227
+ exports.ProjectIdSchema = zod_openapi_1.z.object({
228
+ projectId: zod_openapi_1.z.cuid2(),
229
+ });
230
+ /**
231
+ * --------------------------------
232
+ * SEARCH DOCUMENT
233
+ * --------------------------------
234
+ */
153
235
  exports.ProjectSearchDocumentSchema = zod_openapi_1.z
154
236
  .object({
155
- id: zod_openapi_1.z.string(),
156
- userId: zod_openapi_1.z.string(),
237
+ id: zod_openapi_1.z.cuid2(),
238
+ userId: zod_openapi_1.z.cuid2(),
157
239
  title: zod_openapi_1.z.string(),
158
240
  imagePlaceholderUrl: zod_openapi_1.z.url(),
159
241
  projectCreatorType: zod_openapi_1.z.enum(constants_1.ROLES),
160
242
  isOpenToInvestment: zod_openapi_1.z.boolean(),
161
- createdAt: zod_openapi_1.z.number(),
162
- updatedAt: zod_openapi_1.z.number(),
243
+ createdAt: zod_openapi_1.z.iso.datetime(),
244
+ updatedAt: zod_openapi_1.z.iso.datetime(),
163
245
  description: zod_openapi_1.z.string().optional(),
164
246
  capitalLookingToRaise: zod_openapi_1.z.number().optional(),
165
247
  capitalLookingToRaiseCurrency: zod_openapi_1.z.enum(constants_1.WAGES_CURRENCY).optional(),
@@ -169,71 +251,36 @@ exports.ProjectSearchDocumentSchema = zod_openapi_1.z
169
251
  creatorUsername: zod_openapi_1.z.string(),
170
252
  creatorImageUrl: zod_openapi_1.z.string(),
171
253
  creatorName: zod_openapi_1.z.string(),
172
- clientId: zod_openapi_1.z.string().optional(),
254
+ clientId: zod_openapi_1.z.cuid2().optional(),
173
255
  clientType: zod_openapi_1.z.enum(constants_1.CLIENT_TYPES).optional(),
174
256
  clientName: zod_openapi_1.z.string().optional(),
175
257
  isFeatured: zod_openapi_1.z.boolean().optional(),
176
- startDate: zod_openapi_1.z.number().optional(),
177
- endDate: zod_openapi_1.z.number().optional(),
258
+ startDate: zod_openapi_1.z.iso.datetime().optional(),
259
+ endDate: zod_openapi_1.z.iso.datetime().optional(),
178
260
  files: zod_openapi_1.z.array(file_1.FileEntitySchema).optional(),
179
261
  })
180
262
  .openapi("ProjectSearchDocument");
181
- const coerceArray = (val) => {
182
- if (typeof val === "string")
183
- return val === "" ? [] : val.split(",");
184
- return val;
185
- };
186
- const coerceBoolean = (val) => {
187
- if (val === "true")
188
- return true;
189
- if (val === "false")
190
- return false;
191
- return val;
192
- };
193
- exports.SearchProjectsInputSchema = zod_openapi_1.z
194
- .object({
195
- query: zod_openapi_1.z.string().optional(),
196
- limit: zod_openapi_1.z.coerce.number().optional().default(40),
197
- cursor: zod_openapi_1.z.string().optional().nullable(),
198
- tags: zod_openapi_1.z.preprocess(coerceArray, zod_openapi_1.z.array(zod_openapi_1.z.string())).optional(),
199
- isOpenToInvestment: zod_openapi_1.z.preprocess(coerceBoolean, zod_openapi_1.z.boolean()).optional(),
200
- minCapital: zod_openapi_1.z.coerce.number().optional(),
201
- maxCapital: zod_openapi_1.z.coerce.number().optional(),
202
- ventureStages: zod_openapi_1.z
203
- .preprocess(coerceArray, zod_openapi_1.z.array(zod_openapi_1.z.enum(constants_1.VENTURE_STAGES)))
204
- .optional(),
205
- projectCreatorTypes: zod_openapi_1.z
206
- .preprocess(coerceArray, zod_openapi_1.z.array(zod_openapi_1.z.enum(constants_1.ROLES)))
207
- .optional(),
208
- clientTypes: zod_openapi_1.z
209
- .preprocess(coerceArray, zod_openapi_1.z.array(zod_openapi_1.z.enum(constants_1.CLIENT_TYPES)))
210
- .optional(),
211
- })
212
- .openapi("SearchProjectsInput");
263
+ /**
264
+ * --------------------------------
265
+ * OUTPUTS
266
+ * --------------------------------
267
+ */
268
+ exports.GetProjectOutputSchema = exports.ProjectDetailsEntitySchema.extend({
269
+ isLiked: zod_openapi_1.z.boolean().optional(),
270
+ isBookmarked: zod_openapi_1.z.boolean().optional(),
271
+ }).openapi("GetProjectOutput");
213
272
  exports.SearchProjectsOutputSchema = zod_openapi_1.z
214
273
  .object({
215
274
  projects: zod_openapi_1.z.array(exports.ProjectSearchDocumentSchema),
216
- nextCursor: zod_openapi_1.z.string().optional().nullable(),
275
+ nextCursor: zod_openapi_1.z.string().optional(),
217
276
  })
218
277
  .openapi("SearchProjectsOutput");
219
- exports.ProjectWithProjectCommentsEntitySchema = exports.MinimalProjectSchema.extend({
220
- comments: zod_openapi_1.z.array(comment_1.CommentEntitySchema),
221
- }).openapi("ProjectWithProjectCommentsEntity");
222
278
  exports.GetProjectWithCommentsOutputSchema = exports.ProjectWithProjectCommentsEntitySchema.extend({
223
- nextCursor: zod_openapi_1.z.string().optional().nullable(),
279
+ nextCursor: zod_openapi_1.z.string().optional(),
224
280
  }).openapi("GetProjectWithCommentsOutput");
225
- exports.ProjectWithLikesEntitySchema = exports.MinimalProjectSchema.extend({
226
- likes: zod_openapi_1.z.array(activity_1.ActivitySchema.extend({
227
- followsYou: zod_openapi_1.z.boolean().optional(),
228
- isFollowing: zod_openapi_1.z.boolean().optional(),
229
- })),
230
- }).openapi("ProjectWithLikesEntity");
231
281
  exports.GetProjectWithLikesOutputSchema = exports.ProjectWithLikesEntitySchema.extend({
232
- nextCursor: zod_openapi_1.z.string().optional().nullable(),
282
+ nextCursor: zod_openapi_1.z.string().optional(),
233
283
  }).openapi("GetProjectWithLikesOutput");
234
- exports.ProjectWithProjectBookmarksEntitySchema = exports.MinimalProjectSchema.extend({
235
- bookmarks: zod_openapi_1.z.array(bookmark_1.BookmarkEntitySchema),
236
- }).openapi("ProjectWithProjectBookmarksEntity");
237
284
  exports.ProjectUpdateOutputEntitySchema = zod_openapi_1.z.object({
238
285
  id: zod_openapi_1.z.cuid2(),
239
286
  });
@@ -244,4 +291,3 @@ exports.CommentOnProjectOutputSchema = comment_1.CommentEntitySchema.omit({
244
291
  likesCount: true,
245
292
  isLiked: true,
246
293
  });
247
- exports.ProjectIdSchema = zod_openapi_1.z.object({ projectId: zod_openapi_1.z.cuid2() });
@@ -288,8 +288,8 @@ export declare const UserWithProjectsEntitySchema: z.ZodObject<{
288
288
  projects: z.ZodArray<z.ZodObject<{
289
289
  id: z.ZodCUID2;
290
290
  userId: z.ZodCUID2;
291
- createdAt: z.ZodCoercedDate<unknown>;
292
- updatedAt: z.ZodCoercedDate<unknown>;
291
+ createdAt: z.ZodISODateTime;
292
+ updatedAt: z.ZodISODateTime;
293
293
  description: z.ZodOptional<z.ZodString>;
294
294
  title: z.ZodString;
295
295
  url: z.ZodOptional<z.ZodURL>;
@@ -298,8 +298,8 @@ export declare const UserWithProjectsEntitySchema: z.ZodObject<{
298
298
  readonly DRAFT: "DRAFT";
299
299
  readonly ARCHIVED: "ARCHIVED";
300
300
  }>;
301
- startDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
302
- endDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
301
+ startDate: z.ZodOptional<z.ZodISODateTime>;
302
+ endDate: z.ZodOptional<z.ZodISODateTime>;
303
303
  imagePlaceholderUrl: z.ZodURL;
304
304
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
305
305
  projectCreatorType: z.ZodEnum<{
@@ -344,7 +344,7 @@ export declare const UserWithProjectsEntitySchema: z.ZodObject<{
344
344
  }>>;
345
345
  currentTraction: z.ZodString;
346
346
  isOpenToInvestment: z.ZodDefault<z.ZodBoolean>;
347
- version: z.ZodNumber;
347
+ version: z.ZodInt;
348
348
  }, z.core.$strip>>;
349
349
  }, z.core.$strip>;
350
350
  export type UserWithProjectsEntity = z.infer<typeof UserWithProjectsEntitySchema>;
@@ -451,8 +451,8 @@ export declare const UserWithProjectLikesEntitySchema: z.ZodObject<{
451
451
  id: z.ZodCUID2;
452
452
  description: z.ZodOptional<z.ZodString>;
453
453
  title: z.ZodString;
454
- startDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
455
- endDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
454
+ startDate: z.ZodOptional<z.ZodISODateTime>;
455
+ endDate: z.ZodOptional<z.ZodISODateTime>;
456
456
  imagePlaceholderUrl: z.ZodURL;
457
457
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
458
458
  }, z.core.$strip>;
@@ -555,8 +555,8 @@ export declare const UserWithProjectBookmarksEntitySchema: z.ZodObject<{
555
555
  id: z.ZodCUID2;
556
556
  userId: z.ZodCUID2;
557
557
  project: z.ZodObject<{
558
- id: z.ZodString;
559
- userId: z.ZodString;
558
+ id: z.ZodCUID2;
559
+ userId: z.ZodCUID2;
560
560
  title: z.ZodString;
561
561
  imagePlaceholderUrl: z.ZodURL;
562
562
  projectCreatorType: z.ZodEnum<{
@@ -566,8 +566,8 @@ export declare const UserWithProjectBookmarksEntitySchema: z.ZodObject<{
566
566
  readonly ADMIN: "ADMIN";
567
567
  }>;
568
568
  isOpenToInvestment: z.ZodBoolean;
569
- createdAt: z.ZodNumber;
570
- updatedAt: z.ZodNumber;
569
+ createdAt: z.ZodISODateTime;
570
+ updatedAt: z.ZodISODateTime;
571
571
  description: z.ZodOptional<z.ZodString>;
572
572
  capitalLookingToRaise: z.ZodOptional<z.ZodNumber>;
573
573
  capitalLookingToRaiseCurrency: z.ZodOptional<z.ZodEnum<{
@@ -598,7 +598,7 @@ export declare const UserWithProjectBookmarksEntitySchema: z.ZodObject<{
598
598
  creatorUsername: z.ZodString;
599
599
  creatorImageUrl: z.ZodString;
600
600
  creatorName: z.ZodString;
601
- clientId: z.ZodOptional<z.ZodString>;
601
+ clientId: z.ZodOptional<z.ZodCUID2>;
602
602
  clientType: z.ZodOptional<z.ZodEnum<{
603
603
  readonly CREATIVE: "CREATIVE";
604
604
  readonly BRAND: "BRAND";
@@ -606,8 +606,8 @@ export declare const UserWithProjectBookmarksEntitySchema: z.ZodObject<{
606
606
  }>>;
607
607
  clientName: z.ZodOptional<z.ZodString>;
608
608
  isFeatured: z.ZodOptional<z.ZodBoolean>;
609
- startDate: z.ZodOptional<z.ZodNumber>;
610
- endDate: z.ZodOptional<z.ZodNumber>;
609
+ startDate: z.ZodOptional<z.ZodISODateTime>;
610
+ endDate: z.ZodOptional<z.ZodISODateTime>;
611
611
  files: z.ZodOptional<z.ZodArray<z.ZodObject<{
612
612
  createdAt: z.ZodISODateTime;
613
613
  updatedAt: z.ZodISODateTime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyacreatives/shared",
3
- "version": "2.5.55",
3
+ "version": "2.5.57",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -2,24 +2,24 @@ import { z } from "@hono/zod-openapi";
2
2
 
3
3
  import {
4
4
  EMPLOYMENT_TYPE,
5
- EmploymentType,
5
+ type EmploymentType,
6
6
  EXPERIENCE_LEVELS,
7
- ExperienceLevel,
7
+ type ExperienceLevel,
8
8
  GIG_TYPE,
9
- GigType,
9
+ type GigType,
10
10
  JOB_LOCATIONS,
11
11
  JOB_SECTIONS,
12
12
  JOB_STATUS,
13
+ type JobStatus,
13
14
  JOB_TYPE,
14
- JobLocation,
15
- JobStatus,
16
- JobType,
15
+ type JobType,
17
16
  WAGES_CURRENCY,
18
- WagesCurrency,
17
+ type WagesCurrency,
19
18
  WAGE_TYPES,
20
- WageTypes,
19
+ type WageTypes,
21
20
  WORK_MODE,
22
- WorkMode,
21
+ type WorkMode,
22
+ JobLocation,
23
23
  } from "../constants";
24
24
 
25
25
  /**
@@ -28,59 +28,61 @@ import {
28
28
  * --------------------------------
29
29
  */
30
30
 
31
- const JobTypeSchema = z.enum(
31
+ export const JobTypeSchema = z.enum(
32
32
  Object.values(JOB_TYPE) as [JobType, ...JobType[]],
33
33
  );
34
34
 
35
- const EmploymentTypeSchema = z.enum(
35
+ export const EmploymentTypeSchema = z.enum(
36
36
  Object.values(EMPLOYMENT_TYPE) as [EmploymentType, ...EmploymentType[]],
37
37
  );
38
38
 
39
- const WorkModeSchema = z.enum(
39
+ export const WorkModeSchema = z.enum(
40
40
  Object.values(WORK_MODE) as [WorkMode, ...WorkMode[]],
41
41
  );
42
42
 
43
- const JobStatusSchema = z.enum(
43
+ export const JobStatusSchema = z.enum(
44
44
  Object.values(JOB_STATUS) as [JobStatus, ...JobStatus[]],
45
45
  );
46
46
 
47
- const GigTypeSchema = z.enum(
47
+ export const GigTypeSchema = z.enum(
48
48
  Object.values(GIG_TYPE) as [GigType, ...GigType[]],
49
49
  );
50
50
 
51
- const LocationSchema = z.enum(
51
+ export const JobLocationSchema = z.enum(
52
52
  Object.values(JOB_LOCATIONS) as [JobLocation, ...JobLocation[]],
53
53
  );
54
54
 
55
- const ExperienceLevelSchema = z.enum(
55
+ export const ExperienceLevelSchema = z.enum(
56
56
  Object.values(EXPERIENCE_LEVELS) as [ExperienceLevel, ...ExperienceLevel[]],
57
57
  );
58
58
 
59
- const WageCurrencySchema = z.enum(
59
+ export const WageCurrencySchema = z.enum(
60
60
  Object.values(WAGES_CURRENCY) as [WagesCurrency, ...WagesCurrency[]],
61
61
  );
62
62
 
63
- const WageTypeSchema = z.enum(
63
+ export const WageTypeSchema = z.enum(
64
64
  Object.values(WAGE_TYPES) as [WageTypes, ...WageTypes[]],
65
65
  );
66
66
 
67
+ export const JobSectionSchema = z.enum(
68
+ Object.values(JOB_SECTIONS) as [string, ...string[]],
69
+ );
70
+
67
71
  /**
68
72
  * --------------------------------
69
73
  * SHAPE
70
74
  * --------------------------------
71
75
  */
72
76
 
73
- const JobShape = z.object({
77
+ export const JobShape = z.object({
74
78
  title: z.string().min(3).max(255),
75
79
  brandId: z.cuid2(),
76
80
  jobType: JobTypeSchema,
77
81
  employmentType: EmploymentTypeSchema.optional(),
78
82
  workMode: WorkModeSchema,
79
83
  gigType: GigTypeSchema.optional(),
80
- location: LocationSchema,
81
- jobSections: z.array(
82
- z.enum(Object.values(JOB_SECTIONS) as [string, ...string[]]),
83
- ),
84
+ location: JobLocationSchema,
85
+ jobSections: z.array(JobSectionSchema),
84
86
  });
85
87
 
86
88
  export type JobShapeType = z.infer<typeof JobShape>;
@@ -94,6 +96,7 @@ export type JobShapeType = z.infer<typeof JobShape>;
94
96
  export const JobEntitySchema = z
95
97
  .object({
96
98
  id: z.cuid2(),
99
+
97
100
  ...JobShape.shape,
98
101
 
99
102
  status: JobStatusSchema,
@@ -118,7 +121,7 @@ export type JobEntity = z.infer<typeof JobEntitySchema>;
118
121
  * --------------------------------
119
122
  */
120
123
 
121
- const GigDetailsSchema = z.object({
124
+ export const GigDetailsSchema = z.object({
122
125
  overview: z.string(),
123
126
  deliverables: z.string(),
124
127
  employeeRequirements: z.string().optional(),
@@ -130,7 +133,7 @@ const GigDetailsSchema = z.object({
130
133
  wagesType: WageTypeSchema.optional(),
131
134
  });
132
135
 
133
- const RoleDetailsSchema = z.object({
136
+ export const RoleDetailsSchema = z.object({
134
137
  experienceLevel: ExperienceLevelSchema,
135
138
  overview: z.string(),
136
139
  keyResponsibilities: z.string(),
@@ -143,25 +146,49 @@ const RoleDetailsSchema = z.object({
143
146
  wagesType: WageTypeSchema.optional(),
144
147
  });
145
148
 
146
- export const JobWithGigDetailsEntitySchema = JobEntitySchema.extend(
147
- GigDetailsSchema.shape,
148
- );
149
+ /**
150
+ * --------------------------------
151
+ * DETAILED ENTITIES
152
+ * --------------------------------
153
+ */
149
154
 
150
- export type JobWithGigDetailsEntity = z.infer<
151
- typeof JobWithGigDetailsEntitySchema
152
- >;
155
+ export const GigJobEntitySchema = JobEntitySchema.extend({
156
+ jobType: z.literal(JOB_TYPE.GIG),
157
+ gigType: GigTypeSchema,
158
+ employmentType: EmploymentTypeSchema.optional(),
159
+ ...GigDetailsSchema.shape,
160
+ }).openapi("GigJob");
153
161
 
154
- export const JobWithRoleDetailsEntitySchema = JobEntitySchema.extend(
155
- RoleDetailsSchema.shape,
156
- );
162
+ export type GigJobEntity = z.infer<typeof GigJobEntitySchema>;
163
+
164
+ export const RoleJobEntitySchema = JobEntitySchema.extend({
165
+ jobType: z.literal(JOB_TYPE.ROLE),
166
+ employmentType: EmploymentTypeSchema,
167
+ gigType: GigTypeSchema.optional(),
168
+ ...RoleDetailsSchema.shape,
169
+ }).openapi("RoleJob");
170
+
171
+ export type RoleJobEntity = z.infer<typeof RoleJobEntitySchema>;
157
172
 
158
- export type JobWithRoleDetailsEntity = z.infer<
159
- typeof JobWithRoleDetailsEntitySchema
160
- >;
173
+ /**
174
+ * Backwards-compatible names.
175
+ */
176
+ export const JobWithGigDetailsEntitySchema = GigJobEntitySchema;
177
+ export type JobWithGigDetailsEntity = GigJobEntity;
161
178
 
179
+ export const JobWithRoleDetailsEntitySchema = RoleJobEntitySchema;
180
+ export type JobWithRoleDetailsEntity = RoleJobEntity;
181
+
182
+ /**
183
+ * Keep this as a regular union.
184
+ *
185
+ * Do not use discriminatedUnion here because JobEntitySchema has jobType as
186
+ * "GIG" | "ROLE", while GigJobEntitySchema and RoleJobEntitySchema use
187
+ * literals. That makes the discriminator ambiguous.
188
+ */
162
189
  export const NormalizedJobSchema = z.union([
163
- JobWithGigDetailsEntitySchema,
164
- JobWithRoleDetailsEntitySchema,
190
+ GigJobEntitySchema,
191
+ RoleJobEntitySchema,
165
192
  JobEntitySchema,
166
193
  ]);
167
194
 
@@ -181,6 +208,7 @@ export const CreateJobInputSchema = JobShape.superRefine((data, ctx) => {
181
208
  message: "employmentType is required for ROLE jobs",
182
209
  });
183
210
  }
211
+
184
212
  if (data.jobType === JOB_TYPE.GIG && !data.gigType) {
185
213
  ctx.addIssue({
186
214
  path: ["gigType"],
@@ -227,13 +255,19 @@ export const GetJobsOutputSchema = z.object({
227
255
 
228
256
  export type GetJobsOutput = z.infer<typeof GetJobsOutputSchema>;
229
257
 
258
+ /**
259
+ * --------------------------------
260
+ * SEARCH DOCUMENT
261
+ * --------------------------------
262
+ */
263
+
230
264
  export const JobSearchDocumentSchema = z.object({
231
265
  id: z.cuid2(),
232
266
  title: z.string(),
233
267
  brandId: z.cuid2(),
234
268
  brandName: z.string(),
235
269
  brandImgUrl: z.string().nullable().optional(),
236
- jobType: z.enum(["GIG", "ROLE"]),
270
+ jobType: z.enum([JOB_TYPE.GIG, JOB_TYPE.ROLE]),
237
271
  location: z.string(),
238
272
  overview: z.string(),
239
273
  requiredSkills: z.array(z.string()),