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.
@@ -14,34 +14,37 @@ export class OrgsService {
14
14
  ) {}
15
15
 
16
16
  async listMyOrgs(userId: string) {
17
- const memberships = await this.prisma.membership.findMany({
17
+ const memberships = await this.prisma.organizationMember.findMany({
18
18
  where: { userId },
19
- include: { org: true }
19
+ include: { organization: true }
20
20
  });
21
21
 
22
22
  return memberships.map((m) => ({
23
- org: { id: m.org.id, name: m.org.name },
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.membership.create({
34
- data: { userId, orgId: org.id, role: Role.OWNER }
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.membership.findUnique({
45
+ const requesterMembership = await this.prisma.organizationMember.findUnique({
43
46
  where: {
44
- userId_orgId: { userId: requesterUserId, orgId }
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.membership.findUnique({
59
+ const existingMembership = await this.prisma.organizationMember.findUnique({
57
60
  where: {
58
- userId_orgId: { userId: existingUser.id, orgId }
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.membership.create({
123
+ this.prisma.organizationMember.create({
121
124
  data: {
122
125
  userId,
123
- orgId: invitation.orgId,
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.membership.findMany({
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, IsOptional } from 'class-validator';
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
  }