@zyacreatives/shared 1.1.4 → 1.2.1

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,29 +1,14 @@
1
1
  import { z } from "@hono/zod-openapi";
2
2
 
3
- import {
4
- ROLES,
5
- USER_STATUSES,
6
- ONBOARDING_PAGES,
7
- EXPERIENCE_LEVELS,
8
- INVESTOR_TYPES,
9
- INVESTMENT_SIZES,
10
- GEOGRAPHIC_FOCUS,
11
- } from "../constants";
12
- import type {
13
- Role,
14
- UserStatus,
15
- OnboardingPage,
16
- ExperienceLevel,
17
- InvestorType,
18
- InvestmentSize,
19
- GeographicFocus,
20
- } from "../constants";
3
+ import { ROLES, USER_STATUSES, ONBOARDING_PAGES } from "../constants";
4
+ import type { Role, UserStatus, OnboardingPage } from "../constants";
21
5
  import { UserSocialGraphEntitySchema } from "./common";
6
+ import { ProjectBookmarkEntitySchema, ProjectEntitySchema } from "./project";
22
7
 
23
8
  export const BaseUserEntitySchema = z
24
9
  .object({
25
10
  id: z.cuid2().openapi({ example: "cksd0v6q0000s9a5y8z7p3x9" }),
26
- email: z.email().openapi({ example: "user@example.com" }),
11
+ email: z.string().email().openapi({ example: "user@example.com" }),
27
12
  emailVerified: z.boolean().openapi({ example: true }),
28
13
  name: z.string().optional().openapi({ example: "John Doe" }),
29
14
  image: z
@@ -70,56 +55,53 @@ export const UserEntitySchema = BaseUserEntitySchema.merge(
70
55
  ).openapi("UserEntity");
71
56
 
72
57
  export const UserProfileEntitySchema = UserEntitySchema.extend({
73
- profileType: z.enum(["creative", "brand", "investor"]).optional().openapi({
74
- example: "creative",
75
- }),
76
- bio: z.string().optional().openapi({
77
- example: "Passionate digital artist focusing on UI/UX.",
78
- }),
79
- location: z.string().optional().openapi({
80
- example: "Lagos, Nigeria",
81
- }),
82
- experienceLevel: z
83
- .enum(
84
- Object.values(EXPERIENCE_LEVELS) as [
85
- ExperienceLevel,
86
- ...ExperienceLevel[]
87
- ]
88
- )
89
- .optional()
90
- .openapi({ example: EXPERIENCE_LEVELS.YEAR_1_3 }),
91
- disciplines: z
92
- .array(z.string())
93
- .optional()
94
- .openapi({
95
- example: ["ui-ux", "frontend"],
96
- }),
97
- tags: z
98
- .array(z.string())
99
- .optional()
100
- .openapi({
101
- example: ["react", "design", "product"],
102
- }),
103
- brandName: z.string().optional().openapi({
104
- example: "Acme Creative Studio",
105
- }),
106
- websiteURL: z.string().optional().openapi({
107
- example: "https://acme-creative.com",
108
- }),
109
- investorType: z
110
- .enum(Object.values(INVESTOR_TYPES) as [InvestorType, ...InvestorType[]])
111
- .optional()
112
- .openapi({ example: INVESTOR_TYPES.ANGEL_INVESTOR }),
113
- investmentSize: z
114
- .enum(
115
- Object.values(INVESTMENT_SIZES) as [InvestmentSize, ...InvestmentSize[]]
116
- )
117
- .optional()
118
- .openapi({ example: INVESTMENT_SIZES.BETWEEN_25K_100K }),
119
- geographicFocus: z
120
- .enum(
121
- Object.values(GEOGRAPHIC_FOCUS) as [GeographicFocus, ...GeographicFocus[]]
122
- )
123
- .optional()
124
- .openapi({ example: GEOGRAPHIC_FOCUS.AFRICA }),
58
+ profileType: z.enum(["creative", "brand", "investor"]).optional(),
59
+ bio: z.string().optional(),
60
+ location: z.string().optional(),
61
+ experienceLevel: z.string().optional(),
62
+ disciplines: z.array(z.any()).optional(),
63
+ tags: z.array(z.any()).optional(),
64
+ brandName: z.string().optional(),
65
+ websiteURL: z.string().url().optional(),
66
+ investorType: z.string().optional(),
67
+ investmentSize: z.string().optional(),
68
+ geographicFocus: z.string().optional(),
125
69
  }).openapi("UserProfileEntity");
70
+
71
+ export const UserWithProjectsEntitySchema = z
72
+ .object({
73
+ userId: z.cuid2(),
74
+ projects: z.array(ProjectEntitySchema.omit({ overview: true })),
75
+ })
76
+ .openapi("UserWithProjectsEntity");
77
+
78
+ export const UserWithProjectBookmarksEntitySchema = z
79
+ .object({
80
+ userId: z.cuid2(),
81
+ projectBookmarks: z.array(
82
+ ProjectBookmarkEntitySchema.extend({
83
+ project: ProjectEntitySchema.pick({
84
+ id: true,
85
+ title: true,
86
+ description: true,
87
+ tags: true,
88
+ startDate: true,
89
+ endDate: true,
90
+ imagePlaceholderUrl: true,
91
+ }),
92
+ })
93
+ ),
94
+ })
95
+ .openapi("UserWithProjectBookmarksEntity");
96
+
97
+ export const UserWithFollowingEntitySchema = MinimalUserSchema.extend({
98
+ following: z
99
+ .array(MinimalUserSchema)
100
+ .openapi({ description: "List of users this user is following." }),
101
+ }).openapi("UserWithFollowingEntity");
102
+
103
+ export const UserWithFollowersEntitySchema = MinimalUserSchema.extend({
104
+ followers: z
105
+ .array(MinimalUserSchema)
106
+ .openapi({ description: "List of users who follow this user." }),
107
+ }).openapi("UserWithFollowersEntity");
File without changes
@@ -1,27 +1,41 @@
1
- import type { MinimalUser } from "./user";
1
+ import { z } from "@hono/zod-openapi";
2
+ import {
3
+ BrandEntitySchema,
4
+ BrandWithUserEntitySchema,
5
+ CreateBrandEndpointResponseSchema,
6
+ CreateBrandProfileSchema,
7
+ GetBrandEndpointResponseSchema,
8
+ GetBrandParamsSchema,
9
+ GetBrandQuerySchema,
10
+ ListBrandsInputSchema,
11
+ UpdateBrandEndpointResponseSchema,
12
+ UpdateBrandProfileSchema,
13
+ } from "../schemas";
2
14
 
3
- export type BrandEntity = {
4
- id: string;
15
+ export type BrandEntity = z.infer<typeof BrandEntitySchema>;
16
+
17
+ export type BrandWithUserEntity = z.infer<typeof BrandWithUserEntitySchema>;
18
+
19
+ export type ListBrandsInput = z.infer<typeof ListBrandsInputSchema>;
20
+
21
+ export type CreateBrandDto = z.infer<typeof CreateBrandProfileSchema> & {
5
22
  userId: string;
6
- brandName: string;
7
- searchVector?: string;
8
- bio?: string;
9
- tags?: string[];
10
- createdAt: Date;
11
- updatedAt: Date;
12
23
  };
13
24
 
14
- export type BrandWithUserEntity = BrandEntity & {
15
- user: MinimalUser;
16
- disciplines: string[];
25
+ export type UpdateBrandDto = z.infer<typeof UpdateBrandProfileSchema> & {
26
+ userId: string;
17
27
  };
18
28
 
19
- export type ListBrandsInput = {
20
- query?: string;
21
- disciplines?: string[];
22
- experienceLevels?: string[];
23
- location?: string;
24
- tags?: string[];
25
- page?: number;
26
- perPage?: number;
27
- };
29
+ export type GetBrandParams = z.infer<typeof GetBrandParamsSchema>;
30
+
31
+ export type GetBrandQuery = z.infer<typeof GetBrandQuerySchema>;
32
+
33
+ export type CreateBrandEndpointResponse = z.infer<
34
+ typeof CreateBrandEndpointResponseSchema
35
+ >;
36
+ export type GetBrandEndpointResponse = z.infer<
37
+ typeof GetBrandEndpointResponseSchema
38
+ >;
39
+ export type UpdateBrandEndpointResponse = z.infer<
40
+ typeof UpdateBrandEndpointResponseSchema
41
+ >;
@@ -1,32 +1,44 @@
1
- import type { ExperienceLevel } from "../constants";
2
- import type { MinimalUser } from "./user";
1
+ import { z } from "@hono/zod-openapi";
2
+ import {
3
+ CreateCreativeEndpointResponseSchema,
4
+ CreateCreativeProfileSchema,
5
+ CreativeEntitySchema,
6
+ CreativeWithUserEntitySchema,
7
+ GetCreativeEndpointResponseSchema,
8
+ GetCreativeParamsSchema,
9
+ GetCreativeQuerySchema,
10
+ ListCreativesInputSchema,
11
+ UpdateCreativeEndpointResponseSchema,
12
+ UpdateCreativeProfileSchema,
13
+ } from "../schemas";
3
14
 
4
- export type BaseCreativeEntity = {
5
- id: string;
15
+ export type CreativeEntity = z.infer<typeof CreativeEntitySchema>;
16
+
17
+ export type CreativeWithUserEntity = z.infer<
18
+ typeof CreativeWithUserEntitySchema
19
+ >
20
+
21
+ export type ListCreativesDto = z.infer<typeof ListCreativesInputSchema>;
22
+
23
+ export type CreateCreativeDto = z.infer<typeof CreateCreativeProfileSchema> & {
24
+ userId: string;
25
+ };
26
+ export type UpdateCreativeDto = z.infer<typeof UpdateCreativeProfileSchema> & {
6
27
  userId: string;
7
- bio?: string;
8
- location?: string;
9
- experienceLevel?: ExperienceLevel;
10
- tags?: string[];
11
- disciplines?: string[];
12
- user?: any;
13
- createdAt: Date;
14
- updatedAt: Date;
15
28
  };
16
29
 
17
- export type CreativeEntity = BaseCreativeEntity;
30
+ export type GetCreativeParams = z.infer<typeof GetCreativeParamsSchema>;
18
31
 
19
- export type CreativeWithUserEntity = CreativeEntity & {
20
- user: MinimalUser;
21
- disciplines: string[];
22
- };
32
+ export type GetCreativeQuery = z.infer<typeof GetCreativeQuerySchema>;
33
+
34
+ export type CreateCreativeEndpointResponse = z.infer<
35
+ typeof CreateCreativeEndpointResponseSchema
36
+ >;
37
+
38
+ export type GetCreativeEndpointResponse = z.infer<
39
+ typeof GetCreativeEndpointResponseSchema
40
+ >;
23
41
 
24
- export type ListCreativesInput = {
25
- query?: string;
26
- disciplines?: string[];
27
- experienceLevels?: string[];
28
- location?: string;
29
- tags?: string[];
30
- page?: number;
31
- perPage?: number;
32
- };
42
+ export type UpdateCreativeEndpointResponse = z.infer<
43
+ typeof UpdateCreativeEndpointResponseSchema
44
+ >;
@@ -1,38 +1,43 @@
1
- import type {
2
- ExperienceLevel,
3
- GeographicFocus,
4
- InvestmentSize,
5
- InvestorType,
6
- } from "../constants";
7
- import type { MinimalUser } from "./user";
8
-
9
- export type InvestorEntity = {
10
- id: string;
1
+ import { z } from "@hono/zod-openapi";
2
+ import {
3
+ CreateInvestorEndpointResponseSchema,
4
+ CreateInvestorProfileSchema,
5
+ GetInvestorEndpointResponseSchema,
6
+ GetInvestorParamsSchema,
7
+ GetInvestorQuerySchema,
8
+ InvestorEntitySchema,
9
+ InvestorWithUserEntitySchema,
10
+ ListInvestorsInputSchema,
11
+ UpdateInvestorEndpointResponseSchema,
12
+ UpdateInvestorProfileSchema,
13
+ } from "../schemas/investor";
14
+
15
+ export type InvestorEntity = z.infer<typeof InvestorEntitySchema>;
16
+
17
+ export type InvestorWithUserEntity = z.infer<
18
+ typeof InvestorWithUserEntitySchema
19
+ >;
20
+
21
+ export type ListInvestorsInput = z.infer<typeof ListInvestorsInputSchema>;
22
+
23
+ export type CreateInvestorDto = z.infer<typeof CreateInvestorProfileSchema> & {
11
24
  userId: string;
12
- bio?: string;
13
- location?: string;
14
- experienceLevel?: ExperienceLevel;
15
- geographicFocus?: GeographicFocus;
16
- investmentSize?: InvestmentSize;
17
- investorType?: InvestorType;
18
- websiteURL?: string;
19
- disciplines?: string[];
20
- user?: any;
21
- createdAt: Date;
22
- updatedAt: Date;
23
25
  };
24
26
 
25
- export type InvestorWithUserEntity = InvestorEntity & {
26
- user: MinimalUser;
27
- disciplines: string[];
27
+ export type UpdateInvestorDto = z.infer<typeof UpdateInvestorProfileSchema> & {
28
+ userId: string;
28
29
  };
29
30
 
30
- export type ListInvestorsInput = {
31
- query?: string;
32
- disciplines?: string[];
33
- experienceLevels?: string[];
34
- location?: string;
35
- tags?: string[];
36
- page?: number;
37
- perPage?: number;
38
- };
31
+ export type GetInvestorParams = z.infer<typeof GetInvestorParamsSchema>;
32
+
33
+ export type GetInvestorQuery = z.infer<typeof GetInvestorQuerySchema>;
34
+
35
+ export type CreateInvestorEndpointResponse = z.infer<
36
+ typeof CreateInvestorEndpointResponseSchema
37
+ >;
38
+ export type GetInvestorEndpointResponse = z.infer<
39
+ typeof GetInvestorEndpointResponseSchema
40
+ >;
41
+ export type UpdateInvestorEndpointResponse = z.infer<
42
+ typeof UpdateInvestorEndpointResponseSchema
43
+ >;
@@ -25,9 +25,9 @@ export type ProjectEntity = {
25
25
  projectCreatorType: Role;
26
26
  tags?: string[];
27
27
  isFeatured?: boolean;
28
- startDate?: Date | null;
28
+ startDate?: Date;
29
29
  imagePlaceholderUrl?: string;
30
- endDate?: Date | null;
30
+ endDate?: Date;
31
31
  };
32
32
 
33
33
  export type ProjectWithFilesEntity = ProjectEntity &
package/src/types/user.ts CHANGED
@@ -1,61 +1,35 @@
1
- import type { OnboardingPage, Role, UserStatus } from "../constants";
2
- import type { UserSocialGraphEntity } from "./common";
3
- import type { ProjectBookmarkEntity, ProjectEntity } from "./project";
4
-
5
- export type BaseUserEntity = {
6
- id: string;
7
- email: string;
8
- emailVerified: boolean;
9
- name?: string;
10
- image?: string;
11
- username?: string;
12
- displayUsername?: string;
13
- searchVector?: string;
14
- role: Role;
15
- status: UserStatus;
16
- onboardingPage: OnboardingPage;
17
- createdAt: Date;
18
- updatedAt: Date;
19
- };
20
-
21
- export type MinimalUser = Pick<
22
- BaseUserEntity,
23
- "id" | "name" | "email" | "image" | "username" | "role"
1
+ import { z } from "@hono/zod-openapi";
2
+ import {
3
+ BaseUserEntitySchema,
4
+ UserWithFollowingEntitySchema,
5
+ MinimalUserSchema,
6
+ UserEntitySchema,
7
+ UserProfileEntitySchema,
8
+ UserWithProjectBookmarksEntitySchema,
9
+ UserWithProjectsEntitySchema,
10
+ UserWithFollowersEntitySchema,
11
+ } from "../schemas";
12
+
13
+ export type BaseUserEntity = z.infer<typeof BaseUserEntitySchema>;
14
+
15
+ export type MinimalUser = z.infer<typeof MinimalUserSchema>;
16
+
17
+ export type UserEntity = z.infer<typeof UserEntitySchema>;
18
+
19
+ export type UserProfileEntity = z.infer<typeof UserProfileEntitySchema>;
20
+
21
+ export type UserWithProjectsEntity = z.infer<
22
+ typeof UserWithProjectsEntitySchema
24
23
  >;
25
24
 
26
- export type UserEntity = BaseUserEntity & UserSocialGraphEntity;
27
-
28
- export type UserProfileEntity = UserEntity & {
29
- profileType?: "creative" | "brand" | "investor";
30
- bio?: string;
31
- location?: string;
32
- experienceLevel?: string;
33
- disciplines?: any[];
34
- tags?: any[];
35
- brandName?: string;
36
- websiteURL?: string;
37
- investorType?: string;
38
- investmentSize?: string;
39
- geographicFocus?: string;
40
- };
41
-
42
- export type UserWithProjectsEntity = {
43
- userId: string;
44
- projects: Omit<ProjectEntity, "overview">[];
45
- };
46
-
47
- export type UserWithProjectBookmarksEntity = {
48
- userId: string;
49
- projectBookmarks: (ProjectBookmarkEntity & {
50
- project: Pick<
51
- ProjectEntity,
52
- | "id"
53
- | "title"
54
- | "description"
55
- | "tags"
56
- | "startDate"
57
- | "endDate"
58
- | "imagePlaceholderUrl"
59
- >;
60
- })[];
61
- };
25
+ export type UserWithProjectBookmarksEntity = z.infer<
26
+ typeof UserWithProjectBookmarksEntitySchema
27
+ >;
28
+
29
+ export type UserWithFollowingEntity = z.infer<
30
+ typeof UserWithFollowingEntitySchema
31
+ >;
32
+
33
+ export type UserWithFollowersEntity = z.infer<
34
+ typeof UserWithFollowersEntitySchema
35
+ >;
@@ -0,0 +1,10 @@
1
+ export const slugify = ({ value }: { value: string }) => {
2
+ return value
3
+ .normalize("NFKD")
4
+ .replace(/[\u0300-\u036f]/g, "") // Remove diacritics
5
+ .toLowerCase()
6
+ .trim()
7
+ .replace(/[^a-z0-9]+/g, "_") // Replace non-alphanum with underscore
8
+ .replace(/^_+|_+$/g, "") // Trim leading/trailing underscores
9
+ .replace(/__+/g, "_"); // Collapse multiple underscores
10
+ };