launchbase 1.1.2 → 1.1.3
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/bin/launchbase.js +2 -119
- package/package.json +1 -1
- package/template/frontend/src/App.tsx +6 -0
- package/template/frontend/src/components/Layout.tsx +6 -0
- package/template/frontend/src/lib/api.ts +0 -2
- package/template/frontend/src/lib/sdk.ts +1 -3
- package/template/frontend/src/pages/Deployments.tsx +332 -0
- package/template/frontend/src/pages/EdgeFunctions.tsx +478 -0
- package/template/prisma/migrations/0_init/migration.sql +262 -75
- package/template/prisma/schema.prisma +211 -147
- package/template/sdk/README.md +1 -2
- package/template/sdk/index.ts +1 -3
- package/template/src/modules/audit/audit.interceptor.ts +1 -1
- package/template/src/modules/auth/auth.service.ts +12 -7
- package/template/src/modules/billing/billing.service.ts +1 -1
- package/template/src/modules/common/filters/all-exceptions.filter.ts +15 -5
- package/template/src/modules/common/project.guard.ts +52 -0
- package/template/src/modules/common/tenant.guard.ts +3 -3
- package/template/src/modules/orgs/orgs.service.ts +18 -15
- package/template/src/modules/projects/dto/create-project.dto.ts +1 -5
- package/template/types/src/index.ts +0 -2
|
@@ -14,34 +14,37 @@ export class OrgsService {
|
|
|
14
14
|
) {}
|
|
15
15
|
|
|
16
16
|
async listMyOrgs(userId: string) {
|
|
17
|
-
const memberships = await this.prisma.
|
|
17
|
+
const memberships = await this.prisma.organizationMember.findMany({
|
|
18
18
|
where: { userId },
|
|
19
|
-
include: {
|
|
19
|
+
include: { organization: true }
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
return memberships.map((m) => ({
|
|
23
|
-
org: { id: m.
|
|
23
|
+
org: { id: m.organization.id, name: m.organization.name, slug: m.organization.slug },
|
|
24
24
|
role: m.role
|
|
25
25
|
}));
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
async createOrg(userId: string, dto: CreateOrgDto) {
|
|
29
|
+
// Generate slug from org name
|
|
30
|
+
const slug = dto.name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
|
31
|
+
|
|
29
32
|
const org = await this.prisma.organization.create({
|
|
30
|
-
data: { name: dto.name }
|
|
33
|
+
data: { name: dto.name, slug, ownerId: userId }
|
|
31
34
|
});
|
|
32
35
|
|
|
33
|
-
await this.prisma.
|
|
34
|
-
data: { userId,
|
|
36
|
+
await this.prisma.organizationMember.create({
|
|
37
|
+
data: { userId, organizationId: org.id, role: Role.OWNER }
|
|
35
38
|
});
|
|
36
39
|
|
|
37
|
-
return { org };
|
|
40
|
+
return { org: { id: org.id, name: org.name, slug: org.slug } };
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
async inviteMember(requesterUserId: string, orgId: string, dto: InviteMemberDto) {
|
|
41
44
|
// Ensure requester is owner/admin of that org
|
|
42
|
-
const requesterMembership = await this.prisma.
|
|
45
|
+
const requesterMembership = await this.prisma.organizationMember.findUnique({
|
|
43
46
|
where: {
|
|
44
|
-
|
|
47
|
+
organizationId_userId: { userId: requesterUserId, organizationId: orgId }
|
|
45
48
|
}
|
|
46
49
|
});
|
|
47
50
|
|
|
@@ -53,9 +56,9 @@ export class OrgsService {
|
|
|
53
56
|
// Check for existing membership
|
|
54
57
|
const existingUser = await this.prisma.user.findUnique({ where: { email: dto.email } });
|
|
55
58
|
if (existingUser) {
|
|
56
|
-
const existingMembership = await this.prisma.
|
|
59
|
+
const existingMembership = await this.prisma.organizationMember.findUnique({
|
|
57
60
|
where: {
|
|
58
|
-
|
|
61
|
+
organizationId_userId: { userId: existingUser.id, organizationId: orgId }
|
|
59
62
|
}
|
|
60
63
|
});
|
|
61
64
|
if (existingMembership) throw new BadRequestException('User is already a member');
|
|
@@ -117,10 +120,10 @@ export class OrgsService {
|
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
await this.prisma.$transaction([
|
|
120
|
-
this.prisma.
|
|
123
|
+
this.prisma.organizationMember.create({
|
|
121
124
|
data: {
|
|
122
125
|
userId,
|
|
123
|
-
|
|
126
|
+
organizationId: invitation.orgId,
|
|
124
127
|
role: invitation.role,
|
|
125
128
|
},
|
|
126
129
|
}),
|
|
@@ -134,8 +137,8 @@ export class OrgsService {
|
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
async listMembers(orgId: string) {
|
|
137
|
-
const members = await this.prisma.
|
|
138
|
-
where: { orgId },
|
|
140
|
+
const members = await this.prisma.organizationMember.findMany({
|
|
141
|
+
where: { organizationId: orgId },
|
|
139
142
|
include: { user: true }
|
|
140
143
|
});
|
|
141
144
|
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { IsString, MinLength
|
|
1
|
+
import { IsString, MinLength } from 'class-validator';
|
|
2
2
|
|
|
3
3
|
export class CreateProjectDto {
|
|
4
4
|
@IsString()
|
|
5
5
|
@MinLength(2)
|
|
6
6
|
name!: string;
|
|
7
|
-
|
|
8
|
-
@IsOptional()
|
|
9
|
-
@IsString()
|
|
10
|
-
description?: string;
|
|
11
7
|
}
|
|
@@ -29,7 +29,6 @@ export interface AuthResponse {
|
|
|
29
29
|
export interface Organization {
|
|
30
30
|
id: string;
|
|
31
31
|
name: string;
|
|
32
|
-
slug: string;
|
|
33
32
|
plan: string;
|
|
34
33
|
stripeCustomerId?: string;
|
|
35
34
|
createdAt: Date;
|
|
@@ -55,7 +54,6 @@ export interface OrgMembership {
|
|
|
55
54
|
export interface Project {
|
|
56
55
|
id: string;
|
|
57
56
|
name: string;
|
|
58
|
-
description?: string;
|
|
59
57
|
orgId: string;
|
|
60
58
|
createdAt: Date;
|
|
61
59
|
}
|