@shophost/rest-api 2.0.26 → 2.0.28

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 (39) hide show
  1. package/README.md +3 -3
  2. package/package.json +1 -1
  3. package/prisma.config.ts +1 -1
  4. package/scripts/shophost-rest-api.mjs +6 -9
  5. package/src/app.js +2 -1
  6. package/src/app.js.map +1 -1
  7. package/src/core/lib/prisma.d.ts +26 -26
  8. package/src/features/access/access.handler.d.ts +2 -0
  9. package/src/features/access/access.handler.js +83 -0
  10. package/src/features/access/access.handler.js.map +1 -0
  11. package/src/features/access/access.route.d.ts +11 -0
  12. package/src/features/access/access.route.js +203 -0
  13. package/src/features/access/access.route.js.map +1 -0
  14. package/src/features/access/access.schema.d.ts +47 -0
  15. package/src/features/access/access.schema.js +108 -0
  16. package/src/features/access/access.schema.js.map +1 -0
  17. package/src/features/access/access.service.d.ts +111 -0
  18. package/src/features/access/access.service.js +273 -0
  19. package/src/features/access/access.service.js.map +1 -0
  20. package/src/features/cart/cart.schema.d.ts +3 -3
  21. package/src/features/cart/cart.service.d.ts +2 -2
  22. package/src/features/index.d.ts +1 -0
  23. package/src/features/index.js +1 -0
  24. package/src/features/index.js.map +1 -1
  25. package/src/features/order/recipient.schema.d.ts +2 -2
  26. package/src/features/organization/organization.schema.d.ts +2 -2
  27. package/src/features/product/product-modifier.schema.d.ts +1 -1
  28. package/src/features/product/product.schema.d.ts +3 -3
  29. package/src/features/product/product.service.d.ts +4 -4
  30. package/src/features/product-category/product-category.schema.d.ts +14 -14
  31. package/src/features/product-category/product-category.service.d.ts +2 -2
  32. package/src/schemas/index.d.ts +1 -0
  33. package/src/schemas/index.js +1 -0
  34. package/src/schemas/index.js.map +1 -1
  35. package/src/test/integration/test-helpers.d.ts +41 -41
  36. package/src/test/integration/test-helpers.js +2 -2
  37. package/src/test/integration/test-helpers.js.map +1 -1
  38. package/src/test/setup-test-env.js +3 -3
  39. package/src/test/setup-test-env.js.map +1 -1
@@ -0,0 +1,203 @@
1
+ import { z } from "@hono/zod-openapi";
2
+ import { createApiRoute } from "../../core/hono/hono";
3
+ import { ErrorSchema, HeaderSchema, OrganizationParams, PaginationMetaSchema, PaginationQuerySchema, } from "../../schemas";
4
+ import { CreateInvitationSchema, InvitationSchema, MemberSchema, UpdateMemberRoleSchema, UserInvitationSchema, } from "./access.schema";
5
+ const memberPathParams = z.object({
6
+ memberId: z.string().openapi({
7
+ description: "ID of the member",
8
+ example: "clf9876543210abcdef",
9
+ param: {
10
+ in: "path",
11
+ name: "memberId",
12
+ },
13
+ }),
14
+ organizationId: z.string().openapi({
15
+ description: "ID of the organization",
16
+ example: "cju0z9k4z0000l1qg5z1z1z1z",
17
+ param: {
18
+ in: "path",
19
+ name: "organizationId",
20
+ },
21
+ }),
22
+ });
23
+ const getMembersRoute = createApiRoute({
24
+ description: "Fetches a paginated list of members for an organization",
25
+ headers: HeaderSchema,
26
+ method: "GET",
27
+ operationId: "getMembers",
28
+ path: "/:organizationId/access/members",
29
+ pathParams: OrganizationParams,
30
+ query: PaginationQuerySchema,
31
+ responses: {
32
+ 200: z.object({
33
+ list: z.array(MemberSchema),
34
+ meta: PaginationMetaSchema,
35
+ }),
36
+ 400: ErrorSchema,
37
+ 401: ErrorSchema,
38
+ },
39
+ summary: "Get Members",
40
+ tags: ["Access"],
41
+ });
42
+ const getMemberRoute = createApiRoute({
43
+ headers: HeaderSchema,
44
+ method: "GET",
45
+ operationId: "getMember",
46
+ path: "/:organizationId/access/members/:memberId",
47
+ pathParams: memberPathParams,
48
+ responses: {
49
+ 200: MemberSchema,
50
+ 401: ErrorSchema,
51
+ 404: ErrorSchema,
52
+ },
53
+ summary: "Get Member",
54
+ tags: ["Access"],
55
+ });
56
+ const updateMemberRoleRoute = createApiRoute({
57
+ body: UpdateMemberRoleSchema,
58
+ description: "Updates a member's role in the organization",
59
+ headers: HeaderSchema,
60
+ method: "PUT",
61
+ operationId: "updateMemberRole",
62
+ path: "/:organizationId/access/members/:memberId",
63
+ pathParams: memberPathParams,
64
+ responses: {
65
+ 200: MemberSchema,
66
+ 400: ErrorSchema,
67
+ 401: ErrorSchema,
68
+ 404: ErrorSchema,
69
+ },
70
+ summary: "Update Member Role",
71
+ tags: ["Access"],
72
+ });
73
+ const deleteMemberRoute = createApiRoute({
74
+ description: "Removes a member from the organization",
75
+ headers: HeaderSchema,
76
+ method: "DELETE",
77
+ operationId: "deleteMember",
78
+ path: "/:organizationId/access/members/:memberId",
79
+ pathParams: memberPathParams,
80
+ responses: {
81
+ 204: null,
82
+ 400: ErrorSchema,
83
+ 401: ErrorSchema,
84
+ 404: ErrorSchema,
85
+ },
86
+ summary: "Delete Member",
87
+ tags: ["Access"],
88
+ });
89
+ const createInvitationRoute = createApiRoute({
90
+ body: CreateInvitationSchema,
91
+ description: "Creates a new invitation for the organization",
92
+ headers: HeaderSchema,
93
+ method: "POST",
94
+ operationId: "createInvitation",
95
+ path: "/:organizationId/access/invitations",
96
+ pathParams: OrganizationParams,
97
+ responses: {
98
+ 201: InvitationSchema,
99
+ 400: ErrorSchema,
100
+ 401: ErrorSchema,
101
+ },
102
+ summary: "Create Invitation",
103
+ tags: ["Access"],
104
+ });
105
+ const getInvitationsRoute = createApiRoute({
106
+ description: "Fetches a list of pending invitations for an organization",
107
+ headers: HeaderSchema,
108
+ method: "GET",
109
+ operationId: "getInvitations",
110
+ path: "/:organizationId/access/invitations",
111
+ pathParams: OrganizationParams,
112
+ responses: {
113
+ 200: z.array(InvitationSchema),
114
+ 401: ErrorSchema,
115
+ },
116
+ summary: "Get Invitations",
117
+ tags: ["Access"],
118
+ });
119
+ const invitationPathParams = z.object({
120
+ invitationId: z.string().openapi({
121
+ description: "ID of the invitation",
122
+ example: "inv_123",
123
+ param: {
124
+ in: "path",
125
+ name: "invitationId",
126
+ },
127
+ }),
128
+ });
129
+ const getUserInvitationsRoute = createApiRoute({
130
+ description: "Fetches pending invitations for the currently authenticated user",
131
+ headers: HeaderSchema,
132
+ method: "GET",
133
+ operationId: "getUserInvitations",
134
+ path: "/access/invitations/me",
135
+ responses: {
136
+ 200: z.array(UserInvitationSchema),
137
+ 401: ErrorSchema,
138
+ },
139
+ summary: "Get User Invitations",
140
+ tags: ["Access"],
141
+ });
142
+ const acceptInvitationRoute = createApiRoute({
143
+ description: "Accepts a pending invitation and adds the user as a member",
144
+ headers: HeaderSchema,
145
+ method: "POST",
146
+ operationId: "acceptInvitation",
147
+ path: "/access/invitations/:invitationId/accept",
148
+ pathParams: invitationPathParams,
149
+ responses: {
150
+ 200: MemberSchema,
151
+ 400: ErrorSchema,
152
+ 401: ErrorSchema,
153
+ 404: ErrorSchema,
154
+ },
155
+ summary: "Accept Invitation",
156
+ tags: ["Access"],
157
+ });
158
+ const deleteInvitationPathParams = z.object({
159
+ invitationId: z.string().openapi({
160
+ description: "ID of the invitation",
161
+ example: "inv_123",
162
+ param: {
163
+ in: "path",
164
+ name: "invitationId",
165
+ },
166
+ }),
167
+ organizationId: z.string().openapi({
168
+ description: "ID of the organization",
169
+ example: "cju0z9k4z0000l1qg5z1z1z1z",
170
+ param: {
171
+ in: "path",
172
+ name: "organizationId",
173
+ },
174
+ }),
175
+ });
176
+ const deleteInvitationRoute = createApiRoute({
177
+ description: "Revokes a pending invitation",
178
+ headers: HeaderSchema,
179
+ method: "DELETE",
180
+ operationId: "deleteInvitation",
181
+ path: "/:organizationId/access/invitations/:invitationId",
182
+ pathParams: deleteInvitationPathParams,
183
+ responses: {
184
+ 204: null,
185
+ 400: ErrorSchema,
186
+ 401: ErrorSchema,
187
+ 404: ErrorSchema,
188
+ },
189
+ summary: "Delete Invitation",
190
+ tags: ["Access"],
191
+ });
192
+ export const accessRoute = {
193
+ getMembers: getMembersRoute,
194
+ getMember: getMemberRoute,
195
+ updateMemberRole: updateMemberRoleRoute,
196
+ deleteMember: deleteMemberRoute,
197
+ createInvitation: createInvitationRoute,
198
+ deleteInvitation: deleteInvitationRoute,
199
+ getInvitations: getInvitationsRoute,
200
+ getUserInvitations: getUserInvitationsRoute,
201
+ acceptInvitation: acceptInvitationRoute,
202
+ };
203
+ //# sourceMappingURL=access.route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.route.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/access/access.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC;QAC3B,WAAW,EAAE,kBAAkB;QAC/B,OAAO,EAAE,qBAAqB;QAC9B,KAAK,EAAE;YACL,EAAE,EAAE,MAAM;YACV,IAAI,EAAE,UAAU;SACjB;KACF,CAAC;IACF,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC;QACjC,WAAW,EAAE,wBAAwB;QACrC,OAAO,EAAE,2BAA2B;QACpC,KAAK,EAAE;YACL,EAAE,EAAE,MAAM;YACV,IAAI,EAAE,gBAAgB;SACvB;KACF,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,cAAc,CAAC;IACrC,WAAW,EAAE,yDAAyD;IACtE,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,KAAK;IACb,WAAW,EAAE,YAAY;IACzB,IAAI,EAAE,iCAAiC;IACvC,UAAU,EAAE,kBAAkB;IAC9B,KAAK,EAAE,qBAAqB;IAC5B,SAAS,EAAE;QACT,GAAG,EAAE,CAAC,CAAC,MA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B;IAC3C,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,QAAQ;IAChB,WAAW,EAAE,kBAAkB;IAC/B,IAAI,EAAE,mDAAmD;IACzD,UAAU,EAAE,0BAA0B;IACtC,SAAS,EAAE;QACT,GAAG,EAAE,IAAI;QACT,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,WAAW;KACjB;IACD,OAAO,EAAE,mBAAmB;IAC5B,IAAI,EAAE,CAAC,QAAQ,CAAC;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU,EAAE,eAAe;IAC3B,SAAS,EAAE,cAAc;IACzB,gBAAgB,EAAE,qBAAqB;IACvC,YAAY,EAAE,iBAAiB;IAC/B,gBAAgB,EAAE,qBAAqB;IACvC,gBAAgB,EAAE,qBAAqB;IACvC,cAAc,EAAE,mBAAmB;IACnC,kBAAkB,EAAE,uBAAuB;IAC3C,gBAAgB,EAAE,qBAAqB;CACxC,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { z } from "@hono/zod-openapi";
2
+ export declare const MemberSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ organizationId: z.ZodString;
5
+ userId: z.ZodString;
6
+ role: z.ZodString;
7
+ createdAt: z.ZodDate;
8
+ user: z.ZodObject<{
9
+ id: z.ZodString;
10
+ firstname: z.ZodString;
11
+ lastname: z.ZodString;
12
+ email: z.ZodString;
13
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
+ }, z.core.$strip>;
15
+ }, z.core.$strip>;
16
+ export declare const InvitationSchema: z.ZodObject<{
17
+ id: z.ZodString;
18
+ organizationId: z.ZodString;
19
+ email: z.ZodString;
20
+ role: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
+ status: z.ZodString;
22
+ expiresAt: z.ZodDate;
23
+ inviterId: z.ZodString;
24
+ createdAt: z.ZodOptional<z.ZodDate>;
25
+ }, z.core.$strip>;
26
+ export declare const CreateInvitationSchema: z.ZodObject<{
27
+ email: z.ZodString;
28
+ role: z.ZodString;
29
+ }, z.core.$strip>;
30
+ export declare const UpdateMemberRoleSchema: z.ZodObject<{
31
+ role: z.ZodString;
32
+ }, z.core.$strip>;
33
+ export declare const UserInvitationSchema: z.ZodObject<{
34
+ id: z.ZodString;
35
+ organizationId: z.ZodString;
36
+ role: z.ZodOptional<z.ZodNullable<z.ZodString>>;
37
+ expiresAt: z.ZodDate;
38
+ organization: z.ZodObject<{
39
+ id: z.ZodString;
40
+ name: z.ZodString;
41
+ }, z.core.$strip>;
42
+ }, z.core.$strip>;
43
+ export type Member = z.infer<typeof MemberSchema>;
44
+ export type Invitation = z.infer<typeof InvitationSchema>;
45
+ export type UserInvitation = z.infer<typeof UserInvitationSchema>;
46
+ export type CreateInvitation = z.infer<typeof CreateInvitationSchema>;
47
+ export type UpdateMemberRole = z.infer<typeof UpdateMemberRoleSchema>;
@@ -0,0 +1,108 @@
1
+ import { z } from "@hono/zod-openapi";
2
+ export const MemberSchema = z
3
+ .object({
4
+ id: z.string().openapi({
5
+ example: "clf9876543210abcdef",
6
+ description: "ID of the member",
7
+ }),
8
+ organizationId: z.string().openapi({
9
+ example: "cju0z9k4z0000l1qg5z1z1z1z",
10
+ description: "ID of the organization",
11
+ }),
12
+ userId: z.string().openapi({
13
+ example: "usr_123",
14
+ description: "ID of the user",
15
+ }),
16
+ role: z.string().openapi({
17
+ example: "owner",
18
+ description: "Role of the member in the organization",
19
+ }),
20
+ createdAt: z.date(),
21
+ user: z
22
+ .object({
23
+ id: z.string(),
24
+ firstname: z.string(),
25
+ lastname: z.string(),
26
+ email: z.string(),
27
+ image: z.string().nullable().optional(),
28
+ })
29
+ .openapi({ description: "User details" }),
30
+ })
31
+ .openapi("Member");
32
+ export const InvitationSchema = z
33
+ .object({
34
+ id: z.string().openapi({
35
+ example: "inv_123",
36
+ description: "ID of the invitation",
37
+ }),
38
+ organizationId: z.string().openapi({
39
+ example: "cju0z9k4z0000l1qg5z1z1z1z",
40
+ description: "ID of the organization",
41
+ }),
42
+ email: z.string().email().openapi({
43
+ example: "user@example.com",
44
+ description: "Email of the invited user",
45
+ }),
46
+ role: z.string().nullable().optional().openapi({
47
+ example: "member",
48
+ description: "Role assigned to the invitation",
49
+ }),
50
+ status: z.string().openapi({
51
+ example: "pending",
52
+ description: "Status of the invitation",
53
+ }),
54
+ expiresAt: z.date().openapi({
55
+ description: "Expiration date of the invitation",
56
+ }),
57
+ inviterId: z.string().openapi({
58
+ description: "ID of the user who created the invitation",
59
+ }),
60
+ createdAt: z.date().optional(),
61
+ })
62
+ .openapi("Invitation");
63
+ export const CreateInvitationSchema = z
64
+ .object({
65
+ email: z.string().email("A valid email is required").openapi({
66
+ example: "user@example.com",
67
+ description: "Email of the user to invite",
68
+ }),
69
+ role: z.string().min(1, "Role is required").openapi({
70
+ example: "member",
71
+ description: "Role to assign to the invited user",
72
+ }),
73
+ })
74
+ .openapi("CreateInvitation");
75
+ export const UpdateMemberRoleSchema = z
76
+ .object({
77
+ role: z.string().min(1, "Role is required").openapi({
78
+ example: "admin",
79
+ description: "New role for the member",
80
+ }),
81
+ })
82
+ .openapi("UpdateMemberRole");
83
+ export const UserInvitationSchema = z
84
+ .object({
85
+ id: z.string().openapi({
86
+ example: "inv_123",
87
+ description: "ID of the invitation",
88
+ }),
89
+ organizationId: z.string().openapi({
90
+ example: "cju0z9k4z0000l1qg5z1z1z1z",
91
+ description: "ID of the organization",
92
+ }),
93
+ role: z.string().nullable().optional().openapi({
94
+ example: "member",
95
+ description: "Role assigned to the invitation",
96
+ }),
97
+ expiresAt: z.date().openapi({
98
+ description: "Expiration date of the invitation",
99
+ }),
100
+ organization: z
101
+ .object({
102
+ id: z.string(),
103
+ name: z.string(),
104
+ })
105
+ .openapi({ description: "Organization details" }),
106
+ })
107
+ .openapi("UserInvitation");
108
+ //# sourceMappingURL=access.schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.schema.js","sourceRoot":"","sources":["../../../../../../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"@hono/zod-openapi";
2
+ import { PrismaClientType } from "../../core/lib/prisma";
3
+ import { CreateInvitationSchema, UpdateMemberRoleSchema } from "./access.schema";
4
+ declare class AccessService {
5
+ private readonly prisma;
6
+ constructor(prisma: PrismaClientType);
7
+ getMembers(organizationId: string, query: {
8
+ page?: number;
9
+ limit?: number;
10
+ search?: string;
11
+ }): Promise<{
12
+ meta: {
13
+ isFirstPage: boolean;
14
+ isLastPage: boolean;
15
+ currentPage: number;
16
+ previousPage: number | null;
17
+ nextPage: number | null;
18
+ pageCount: number;
19
+ totalCount: number;
20
+ };
21
+ list: {
22
+ id: string;
23
+ organizationId: string;
24
+ userId: string;
25
+ role: string;
26
+ createdAt: Date;
27
+ user: {
28
+ id: string;
29
+ firstname: string;
30
+ lastname: string;
31
+ email: string;
32
+ image?: string | null | undefined;
33
+ };
34
+ }[];
35
+ }>;
36
+ getMember(organizationId: string, memberId: string): Promise<{
37
+ id: string;
38
+ organizationId: string;
39
+ userId: string;
40
+ role: string;
41
+ createdAt: Date;
42
+ user: {
43
+ id: string;
44
+ firstname: string;
45
+ lastname: string;
46
+ email: string;
47
+ image?: string | null | undefined;
48
+ };
49
+ }>;
50
+ updateMemberRole(organizationId: string, memberId: string, currentUserId: string, body: z.infer<typeof UpdateMemberRoleSchema>): Promise<{
51
+ id: string;
52
+ organizationId: string;
53
+ userId: string;
54
+ role: string;
55
+ createdAt: Date;
56
+ user: {
57
+ id: string;
58
+ firstname: string;
59
+ lastname: string;
60
+ email: string;
61
+ image?: string | null | undefined;
62
+ };
63
+ }>;
64
+ deleteMember(organizationId: string, memberId: string, currentUserId: string): Promise<void>;
65
+ createInvitation(organizationId: string, inviterId: string, body: z.infer<typeof CreateInvitationSchema>): Promise<{
66
+ id: string;
67
+ organizationId: string;
68
+ email: string;
69
+ status: string;
70
+ expiresAt: Date;
71
+ inviterId: string;
72
+ role?: string | null | undefined;
73
+ createdAt?: Date | undefined;
74
+ }>;
75
+ getInvitations(organizationId: string): Promise<{
76
+ id: string;
77
+ organizationId: string;
78
+ email: string;
79
+ status: string;
80
+ expiresAt: Date;
81
+ inviterId: string;
82
+ role?: string | null | undefined;
83
+ createdAt?: Date | undefined;
84
+ }[]>;
85
+ deleteInvitation(organizationId: string, invitationId: string): Promise<void>;
86
+ getUserInvitations(email: string): Promise<{
87
+ id: string;
88
+ organizationId: string;
89
+ expiresAt: Date;
90
+ organization: {
91
+ id: string;
92
+ name: string;
93
+ };
94
+ role?: string | null | undefined;
95
+ }[]>;
96
+ acceptInvitation(invitationId: string, userId: string): Promise<{
97
+ id: string;
98
+ organizationId: string;
99
+ userId: string;
100
+ role: string;
101
+ createdAt: Date;
102
+ user: {
103
+ id: string;
104
+ firstname: string;
105
+ lastname: string;
106
+ email: string;
107
+ image?: string | null | undefined;
108
+ };
109
+ }>;
110
+ }
111
+ export { AccessService };