@shophost/rest-api 2.0.27 → 2.0.29
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/package.json +1 -1
- package/src/app.js +2 -1
- package/src/app.js.map +1 -1
- package/src/core/lib/prisma.d.ts +26 -26
- package/src/features/access/access.handler.d.ts +2 -0
- package/src/features/access/access.handler.js +91 -0
- package/src/features/access/access.handler.js.map +1 -0
- package/src/features/access/access.route.d.ts +12 -0
- package/src/features/access/access.route.js +220 -0
- package/src/features/access/access.route.js.map +1 -0
- package/src/features/access/access.schema.d.ts +47 -0
- package/src/features/access/access.schema.js +108 -0
- package/src/features/access/access.schema.js.map +1 -0
- package/src/features/access/access.service.d.ts +112 -0
- package/src/features/access/access.service.js +294 -0
- package/src/features/access/access.service.js.map +1 -0
- package/src/features/cart/cart.schema.d.ts +3 -3
- package/src/features/cart/cart.service.d.ts +2 -2
- package/src/features/index.d.ts +1 -0
- package/src/features/index.js +1 -0
- package/src/features/index.js.map +1 -1
- package/src/features/order/recipient.schema.d.ts +2 -2
- package/src/features/organization/organization.schema.d.ts +2 -2
- package/src/features/product/product-modifier.schema.d.ts +1 -1
- package/src/features/product/product.schema.d.ts +3 -3
- package/src/features/product/product.service.d.ts +4 -4
- package/src/features/product-category/product-category.schema.d.ts +14 -14
- package/src/features/product-category/product-category.service.d.ts +2 -2
- package/src/schemas/index.d.ts +1 -0
- package/src/schemas/index.js +1 -0
- package/src/schemas/index.js.map +1 -1
- package/src/test/integration/test-helpers.d.ts +41 -41
|
@@ -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":["../../../../../../packages/rest-api/src/features/access/access.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,MAAM,CAAC;IACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC;QACrB,OAAO,EAAE,qBAAqB;QAC9B,WAAW,EAAE,kBAAkB;KAChC,CAAC;IACF,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC;QACjC,OAAO,EAAE,2BAA2B;QACpC,WAAW,EAAE,wBAAwB;KACtC,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC;QACzB,OAAO,EAAE,SAAS;QAClB,WAAW,EAAE,gBAAgB;KAC9B,CAAC;IACF,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC;QACvB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,wCAAwC;KACtD,CAAC;IACF,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE;IACnB,IAAI,EAAE,CAAC;SACJ,MAAM,CAAC;QACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;QACd,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;QACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;QACjB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;KACxC,CAAC;SACD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,CAAC;QACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;QACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;KACjB,CAAC;SACD,OAAO,CAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;CACpD,CAAC;KACD,OAAO,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from "@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
|
+
leaveOrganization(organizationId: string, userId: string): Promise<void>;
|
|
66
|
+
createInvitation(organizationId: string, inviterId: string, body: z.infer<typeof CreateInvitationSchema>): Promise<{
|
|
67
|
+
id: string;
|
|
68
|
+
organizationId: string;
|
|
69
|
+
email: string;
|
|
70
|
+
status: string;
|
|
71
|
+
expiresAt: Date;
|
|
72
|
+
inviterId: string;
|
|
73
|
+
role?: string | null | undefined;
|
|
74
|
+
createdAt?: Date | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
getInvitations(organizationId: string): Promise<{
|
|
77
|
+
id: string;
|
|
78
|
+
organizationId: string;
|
|
79
|
+
email: string;
|
|
80
|
+
status: string;
|
|
81
|
+
expiresAt: Date;
|
|
82
|
+
inviterId: string;
|
|
83
|
+
role?: string | null | undefined;
|
|
84
|
+
createdAt?: Date | undefined;
|
|
85
|
+
}[]>;
|
|
86
|
+
deleteInvitation(organizationId: string, invitationId: string): Promise<void>;
|
|
87
|
+
getUserInvitations(email: string): Promise<{
|
|
88
|
+
id: string;
|
|
89
|
+
organizationId: string;
|
|
90
|
+
expiresAt: Date;
|
|
91
|
+
organization: {
|
|
92
|
+
id: string;
|
|
93
|
+
name: string;
|
|
94
|
+
};
|
|
95
|
+
role?: string | null | undefined;
|
|
96
|
+
}[]>;
|
|
97
|
+
acceptInvitation(invitationId: string, userId: string): Promise<{
|
|
98
|
+
id: string;
|
|
99
|
+
organizationId: string;
|
|
100
|
+
userId: string;
|
|
101
|
+
role: string;
|
|
102
|
+
createdAt: Date;
|
|
103
|
+
user: {
|
|
104
|
+
id: string;
|
|
105
|
+
firstname: string;
|
|
106
|
+
lastname: string;
|
|
107
|
+
email: string;
|
|
108
|
+
image?: string | null | undefined;
|
|
109
|
+
};
|
|
110
|
+
}>;
|
|
111
|
+
}
|
|
112
|
+
export { AccessService };
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { z } from "@hono/zod-openapi";
|
|
3
|
+
import { HttpException } from "../../core/exceptions/http-exception";
|
|
4
|
+
import { PaginationMetaSchema } from "../../schemas";
|
|
5
|
+
import { InvitationSchema, MemberSchema, UserInvitationSchema, } from "./access.schema";
|
|
6
|
+
class AccessService {
|
|
7
|
+
constructor(prisma) {
|
|
8
|
+
this.prisma = prisma;
|
|
9
|
+
}
|
|
10
|
+
getMembers(organizationId, query) {
|
|
11
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
const { page = 1, limit = 10, search } = query;
|
|
13
|
+
const [list, meta] = yield this.prisma.member
|
|
14
|
+
.paginate({
|
|
15
|
+
orderBy: { createdAt: "desc" },
|
|
16
|
+
where: Object.assign({ organizationId }, (search && {
|
|
17
|
+
user: {
|
|
18
|
+
OR: [
|
|
19
|
+
{ firstname: { contains: search, mode: "insensitive" } },
|
|
20
|
+
{ lastname: { contains: search, mode: "insensitive" } },
|
|
21
|
+
{ email: { contains: search, mode: "insensitive" } },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
})),
|
|
25
|
+
include: {
|
|
26
|
+
user: {
|
|
27
|
+
select: {
|
|
28
|
+
id: true,
|
|
29
|
+
firstname: true,
|
|
30
|
+
lastname: true,
|
|
31
|
+
email: true,
|
|
32
|
+
image: true,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
.withPages({ page, limit });
|
|
38
|
+
return z
|
|
39
|
+
.object({
|
|
40
|
+
meta: PaginationMetaSchema,
|
|
41
|
+
list: z.array(MemberSchema),
|
|
42
|
+
})
|
|
43
|
+
.parse({ meta, list });
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
getMember(organizationId, memberId) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const member = yield this.prisma.member.findUnique({
|
|
49
|
+
where: { id: memberId, organizationId },
|
|
50
|
+
include: {
|
|
51
|
+
user: {
|
|
52
|
+
select: {
|
|
53
|
+
id: true,
|
|
54
|
+
firstname: true,
|
|
55
|
+
lastname: true,
|
|
56
|
+
email: true,
|
|
57
|
+
image: true,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
if (!member) {
|
|
63
|
+
throw new HttpException(404, "Member not found");
|
|
64
|
+
}
|
|
65
|
+
return MemberSchema.parse(member);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
updateMemberRole(organizationId, memberId, currentUserId, body) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const member = yield this.prisma.member.findUnique({
|
|
71
|
+
where: { id: memberId, organizationId },
|
|
72
|
+
include: { user: { select: { id: true, firstname: true, lastname: true, email: true, image: true } } },
|
|
73
|
+
});
|
|
74
|
+
if (!member) {
|
|
75
|
+
throw new HttpException(404, "Member not found");
|
|
76
|
+
}
|
|
77
|
+
// Prevent demotion of the last owner
|
|
78
|
+
if (member.role === "owner" && body.role !== "owner") {
|
|
79
|
+
const ownerCount = yield this.prisma.member.count({
|
|
80
|
+
where: { organizationId, role: "owner" },
|
|
81
|
+
});
|
|
82
|
+
if (ownerCount <= 1) {
|
|
83
|
+
throw new HttpException(400, "Cannot change the role of the last owner. Promote another member to owner first.");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const updated = yield this.prisma.member.update({
|
|
87
|
+
where: { id: memberId, organizationId },
|
|
88
|
+
data: { role: body.role },
|
|
89
|
+
include: {
|
|
90
|
+
user: {
|
|
91
|
+
select: {
|
|
92
|
+
id: true,
|
|
93
|
+
firstname: true,
|
|
94
|
+
lastname: true,
|
|
95
|
+
email: true,
|
|
96
|
+
image: true,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
return MemberSchema.parse(updated);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
deleteMember(organizationId, memberId, currentUserId) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const member = yield this.prisma.member.findUnique({
|
|
107
|
+
where: { id: memberId, organizationId },
|
|
108
|
+
});
|
|
109
|
+
if (!member) {
|
|
110
|
+
throw new HttpException(404, "Member not found");
|
|
111
|
+
}
|
|
112
|
+
// Prevent self-removal
|
|
113
|
+
if (member.userId === currentUserId) {
|
|
114
|
+
throw new HttpException(400, "You cannot remove yourself from the organization");
|
|
115
|
+
}
|
|
116
|
+
// Prevent removal of the last owner
|
|
117
|
+
if (member.role === "owner") {
|
|
118
|
+
const ownerCount = yield this.prisma.member.count({
|
|
119
|
+
where: { organizationId, role: "owner" },
|
|
120
|
+
});
|
|
121
|
+
if (ownerCount <= 1) {
|
|
122
|
+
throw new HttpException(400, "Cannot remove the last owner. Transfer ownership first.");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
yield this.prisma.member.delete({
|
|
126
|
+
where: { id: memberId, organizationId },
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
leaveOrganization(organizationId, userId) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
const member = yield this.prisma.member.findFirst({
|
|
133
|
+
where: { organizationId, userId },
|
|
134
|
+
});
|
|
135
|
+
if (!member) {
|
|
136
|
+
throw new HttpException(404, "You are not a member of this organization");
|
|
137
|
+
}
|
|
138
|
+
if (member.role === "owner") {
|
|
139
|
+
const ownerCount = yield this.prisma.member.count({
|
|
140
|
+
where: { organizationId, role: "owner" },
|
|
141
|
+
});
|
|
142
|
+
if (ownerCount <= 1) {
|
|
143
|
+
throw new HttpException(400, "Cannot leave as the last owner. Transfer ownership first.");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
yield this.prisma.member.delete({
|
|
147
|
+
where: { id: member.id, organizationId },
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
createInvitation(organizationId, inviterId, body) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
// Check for duplicate active invitation
|
|
154
|
+
const existing = yield this.prisma.invitation.findFirst({
|
|
155
|
+
where: {
|
|
156
|
+
organizationId,
|
|
157
|
+
email: body.email,
|
|
158
|
+
status: "pending",
|
|
159
|
+
expiresAt: { gt: new Date() },
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
if (existing) {
|
|
163
|
+
throw new HttpException(400, "An active invitation already exists for this email address");
|
|
164
|
+
}
|
|
165
|
+
// Check if user is already a member
|
|
166
|
+
const existingMember = yield this.prisma.member.findFirst({
|
|
167
|
+
where: {
|
|
168
|
+
organizationId,
|
|
169
|
+
user: { email: body.email },
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
if (existingMember) {
|
|
173
|
+
throw new HttpException(400, "This user is already a member of the organization");
|
|
174
|
+
}
|
|
175
|
+
const invitation = yield this.prisma.invitation.create({
|
|
176
|
+
data: {
|
|
177
|
+
id: crypto.randomUUID(),
|
|
178
|
+
organizationId,
|
|
179
|
+
email: body.email,
|
|
180
|
+
role: body.role,
|
|
181
|
+
status: "pending",
|
|
182
|
+
inviterId,
|
|
183
|
+
expiresAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // 7 days
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
return InvitationSchema.parse(invitation);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
getInvitations(organizationId) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
const invitations = yield this.prisma.invitation.findMany({
|
|
192
|
+
where: {
|
|
193
|
+
organizationId,
|
|
194
|
+
status: "pending",
|
|
195
|
+
},
|
|
196
|
+
orderBy: { expiresAt: "desc" },
|
|
197
|
+
});
|
|
198
|
+
return z.array(InvitationSchema).parse(invitations);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
deleteInvitation(organizationId, invitationId) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
const invitation = yield this.prisma.invitation.findUnique({
|
|
204
|
+
where: { id: invitationId, organizationId },
|
|
205
|
+
});
|
|
206
|
+
if (!invitation) {
|
|
207
|
+
throw new HttpException(404, "Invitation not found");
|
|
208
|
+
}
|
|
209
|
+
if (invitation.status !== "pending") {
|
|
210
|
+
throw new HttpException(400, "Only pending invitations can be revoked");
|
|
211
|
+
}
|
|
212
|
+
yield this.prisma.invitation.delete({
|
|
213
|
+
where: { id: invitationId },
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
getUserInvitations(email) {
|
|
218
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
219
|
+
const invitations = yield this.prisma.invitation.findMany({
|
|
220
|
+
where: {
|
|
221
|
+
email,
|
|
222
|
+
status: "pending",
|
|
223
|
+
expiresAt: { gt: new Date() },
|
|
224
|
+
},
|
|
225
|
+
include: {
|
|
226
|
+
organization: {
|
|
227
|
+
select: { id: true, name: true },
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
orderBy: { expiresAt: "desc" },
|
|
231
|
+
});
|
|
232
|
+
return z.array(UserInvitationSchema).parse(invitations);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
acceptInvitation(invitationId, userId) {
|
|
236
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
var _a;
|
|
238
|
+
const invitation = yield this.prisma.invitation.findUnique({
|
|
239
|
+
where: { id: invitationId },
|
|
240
|
+
});
|
|
241
|
+
if (!invitation) {
|
|
242
|
+
throw new HttpException(404, "Invitation not found");
|
|
243
|
+
}
|
|
244
|
+
if (invitation.status !== "pending") {
|
|
245
|
+
throw new HttpException(400, "Invitation is no longer pending");
|
|
246
|
+
}
|
|
247
|
+
if (invitation.expiresAt < new Date()) {
|
|
248
|
+
throw new HttpException(400, "Invitation has expired");
|
|
249
|
+
}
|
|
250
|
+
const user = yield this.prisma.user.findUnique({
|
|
251
|
+
where: { id: userId },
|
|
252
|
+
});
|
|
253
|
+
if (!user || user.email !== invitation.email) {
|
|
254
|
+
throw new HttpException(400, "Invitation does not belong to this user");
|
|
255
|
+
}
|
|
256
|
+
const existingMember = yield this.prisma.member.findFirst({
|
|
257
|
+
where: {
|
|
258
|
+
organizationId: invitation.organizationId,
|
|
259
|
+
userId,
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
if (existingMember) {
|
|
263
|
+
throw new HttpException(400, "You are already a member of this organization");
|
|
264
|
+
}
|
|
265
|
+
const [member] = yield this.prisma.$transaction([
|
|
266
|
+
this.prisma.member.create({
|
|
267
|
+
data: {
|
|
268
|
+
organizationId: invitation.organizationId,
|
|
269
|
+
userId,
|
|
270
|
+
role: (_a = invitation.role) !== null && _a !== void 0 ? _a : "member",
|
|
271
|
+
},
|
|
272
|
+
include: {
|
|
273
|
+
user: {
|
|
274
|
+
select: {
|
|
275
|
+
id: true,
|
|
276
|
+
firstname: true,
|
|
277
|
+
lastname: true,
|
|
278
|
+
email: true,
|
|
279
|
+
image: true,
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
}),
|
|
284
|
+
this.prisma.invitation.update({
|
|
285
|
+
where: { id: invitationId },
|
|
286
|
+
data: { status: "accepted" },
|
|
287
|
+
}),
|
|
288
|
+
]);
|
|
289
|
+
return MemberSchema.parse(member);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
export { AccessService };
|
|
294
|
+
//# sourceMappingURL=access.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.service.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/access/access.service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAEL,gBAAgB,EAChB,YAAY,EAEZ,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,aAAa;IACjB,YAA6B,MAAwB;QAAxB,WAAM,GAAN,MAAM,CAAkB;IAAG,CAAC;IAE5C,UAAU,CACrB,cAAsB,EACtB,KAAyD;;YAEzD,MAAM,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;YAE/C,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM;iBAC1C,QAAQ,CAAC;gBACR,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;gBAC9B,KAAK,kBACH,cAAc,IACX,CAAC,MAAM,IAAI;oBACZ,IAAI,EAAE;wBACJ,EAAE,EAAE;4BACF,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE;4BACxD,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE;4BACvD,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE;yBAC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ACF;iBACF,CAAC;gBACF,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;oBAC5B,KAAK,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE;oBAC3B,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;iBAC7B,CAAC;aACH,CAAC,CAAC;YAEH,OAAO,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC;KAAA;CACF;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from "@hono/zod-openapi";
|
|
2
2
|
export declare const CartProductsMappingSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
3
|
-
id: z.ZodString;
|
|
4
3
|
description: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
5
4
|
title: z.ZodDefault<z.ZodString>;
|
|
6
|
-
|
|
5
|
+
id: z.ZodString;
|
|
7
6
|
createdAt: z.ZodDate;
|
|
7
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
8
8
|
publishedAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
9
9
|
sku: z.ZodOptional<z.ZodString>;
|
|
10
10
|
basePrice: z.ZodCoercedNumber<unknown>;
|
|
@@ -18,6 +18,7 @@ export declare const CartProductsMappingSchema: z.ZodRecord<z.ZodString, z.ZodOb
|
|
|
18
18
|
filename: z.ZodString;
|
|
19
19
|
}, z.core.$strip>>>;
|
|
20
20
|
modifierGroups: z.ZodArray<z.ZodObject<{
|
|
21
|
+
title: z.ZodNullable<z.ZodDefault<z.ZodString>>;
|
|
21
22
|
id: z.ZodString;
|
|
22
23
|
defaultLocale: z.ZodOptional<z.ZodEnum<{
|
|
23
24
|
id: "id";
|
|
@@ -134,7 +135,6 @@ export declare const CartProductsMappingSchema: z.ZodRecord<z.ZodString, z.ZodOb
|
|
|
134
135
|
ji: "ji";
|
|
135
136
|
zu: "zu";
|
|
136
137
|
}>>;
|
|
137
|
-
title: z.ZodNullable<z.ZodDefault<z.ZodString>>;
|
|
138
138
|
selectMin: z.ZodCoercedNumber<unknown>;
|
|
139
139
|
selectMax: z.ZodCoercedNumber<unknown>;
|
|
140
140
|
modifiers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -17,16 +17,16 @@ declare class CartService {
|
|
|
17
17
|
}): Promise<{
|
|
18
18
|
invalidProductIds: string[];
|
|
19
19
|
products: Record<string, {
|
|
20
|
-
id: string;
|
|
21
20
|
description: string | null;
|
|
22
21
|
title: string;
|
|
22
|
+
id: string;
|
|
23
23
|
createdAt: Date;
|
|
24
24
|
basePrice: number;
|
|
25
25
|
discountedBasePrice: number | null;
|
|
26
26
|
currency: string;
|
|
27
27
|
modifierGroups: {
|
|
28
|
-
id: string;
|
|
29
28
|
title: string | null;
|
|
29
|
+
id: string;
|
|
30
30
|
selectMin: number;
|
|
31
31
|
selectMax: number;
|
|
32
32
|
defaultLocale?: "id" | "af" | "sq" | "ar_dz" | "ar_bh" | "ar_eg" | "ar_iq" | "ar_jo" | "ar_kw" | "ar_lb" | "ar_ly" | "ar_ma" | "ar_om" | "ar_qa" | "ar_sa" | "ar_sy" | "ar_tn" | "ar_ae" | "ar_ye" | "eu" | "be" | "bg" | "ca" | "zh_hk" | "zh_cn" | "zh_sg" | "zh_tw" | "hr" | "cs" | "da" | "nl_be" | "nl" | "en" | "en_au" | "en_bz" | "en_ca" | "en_ie" | "en_jm" | "en_nz" | "en_za" | "en_tt" | "en_gb" | "en_us" | "et" | "fo" | "fa" | "fi" | "fr_be" | "fr_ca" | "fr_lu" | "fr" | "fr_ch" | "gd" | "de_at" | "de_li" | "de_lu" | "de" | "de_ch" | "el" | "he" | "hi" | "hu" | "is" | "ga" | "it" | "it_ch" | "ja" | "ko" | "ku" | "lv" | "lt" | "mk" | "ml" | "ms" | "mt" | "no" | "nb" | "nn" | "pl" | "pt_br" | "pt" | "pa" | "rm" | "ro" | "ro_md" | "ru" | "ru_md" | "sr" | "sk" | "sl" | "sb" | "es_ar" | "es_bo" | "es_cl" | "es_co" | "es_cr" | "es_do" | "es_ec" | "es_sv" | "es_gt" | "es_hn" | "es_mx" | "es" | "sv" | "sv_fi" | "th" | "tr" | "uk" | "ur" | "vi" | "cy" | "ji" | "zu" | undefined;
|
package/src/features/index.d.ts
CHANGED
package/src/features/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/rest-api/src/features/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6CAA6C,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/rest-api/src/features/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,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