@darraghor/nest-backend-libs 2.27.0 → 2.28.0
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/dist/authorization/authz.module.js +2 -2
- package/dist/authorization/authz.module.js.map +1 -1
- package/dist/authorization/services/UserValidation.service.d.ts +7 -3
- package/dist/authorization/services/UserValidation.service.js +97 -65
- package/dist/authorization/services/UserValidation.service.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/invitations/dto/create-invitation.dto.js +5 -0
- package/dist/invitations/dto/create-invitation.dto.js.map +1 -1
- package/dist/invitations/entities/invitation.entity.d.ts +1 -1
- package/dist/invitations/entities/invitation.entity.js +8 -6
- package/dist/invitations/entities/invitation.entity.js.map +1 -1
- package/dist/invitations/invitation.controller.d.ts +2 -0
- package/dist/invitations/invitation.controller.js +42 -4
- package/dist/invitations/invitation.controller.js.map +1 -1
- package/dist/invitations/invitation.service.d.ts +2 -2
- package/dist/invitations/invitation.service.js +78 -44
- package/dist/invitations/invitation.service.js.map +1 -1
- package/dist/organisation/dto/create-organisation.dto.js +9 -0
- package/dist/organisation/dto/create-organisation.dto.js.map +1 -1
- package/dist/organisation/entities/member-role.entity.d.ts +0 -1
- package/dist/organisation/entities/member-role.entity.js +4 -8
- package/dist/organisation/entities/member-role.entity.js.map +1 -1
- package/dist/organisation/entities/organisation.entity.d.ts +2 -3
- package/dist/organisation/entities/organisation.entity.js +1 -15
- package/dist/organisation/entities/organisation.entity.js.map +1 -1
- package/dist/organisation/organisation.service.js +4 -0
- package/dist/organisation/organisation.service.js.map +1 -1
- package/dist/organisation-memberships/dtos/create-membership-dto.js +3 -0
- package/dist/organisation-memberships/dtos/create-membership-dto.js.map +1 -1
- package/dist/organisation-memberships/entities/organisation-membership.entity.d.ts +3 -4
- package/dist/organisation-memberships/entities/organisation-membership.entity.js +9 -29
- package/dist/organisation-memberships/entities/organisation-membership.entity.js.map +1 -1
- package/dist/organisation-memberships/organisation-memberships.service.js +9 -9
- package/dist/organisation-memberships/organisation-memberships.service.js.map +1 -1
- package/dist/organisation-subscriptions/organisation-subscriptions.service.js +2 -2
- package/dist/organisation-subscriptions/organisation-subscriptions.service.js.map +1 -1
- package/dist/root-app/models/QueueItemDto.js +11 -1
- package/dist/root-app/models/QueueItemDto.js.map +1 -1
- package/dist/smtp-email-client/email.entity.js +4 -4
- package/dist/smtp-email-client/email.entity.js.map +1 -1
- package/dist/stripe-client/models/StripeCheckoutSessionResponseDto.js +3 -0
- package/dist/stripe-client/models/StripeCheckoutSessionResponseDto.js.map +1 -1
- package/dist/stripe-client/models/StripeCustomerPortalResponseDto.js +2 -0
- package/dist/stripe-client/models/StripeCustomerPortalResponseDto.js.map +1 -1
- package/dist/stripe-client/services/stripe-checkout.service.js +4 -3
- package/dist/stripe-client/services/stripe-checkout.service.js.map +1 -1
- package/dist/super-powers/super-powers.controller.d.ts +1 -1
- package/dist/super-powers/super-powers.controller.js +2 -2
- package/dist/super-powers/super-powers.controller.js.map +1 -1
- package/dist/super-powers/super-powers.service.js +2 -2
- package/dist/user-internal/dto/userResponseDto.js +0 -2
- package/dist/user-internal/dto/userResponseDto.js.map +1 -1
- package/dist/user-internal/entities/user.entity.d.ts +2 -3
- package/dist/user-internal/entities/user.entity.js +3 -20
- package/dist/user-internal/entities/user.entity.js.map +1 -1
- package/dist/user-internal/user.controller.js +4 -0
- package/dist/user-internal/user.controller.js.map +1 -1
- package/dist/user-internal/user.service.js +2 -2
- package/dist/user-internal/user.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,9 +11,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
13
|
var InvitationService_1;
|
|
14
|
-
import { Injectable, Logger, NotFoundException } from "@nestjs/common";
|
|
14
|
+
import { BadRequestException, ForbiddenException, Injectable, Logger, NotFoundException, } from "@nestjs/common";
|
|
15
15
|
import { InjectRepository } from "@nestjs/typeorm";
|
|
16
|
-
import { IsNull,
|
|
16
|
+
import { IsNull, MoreThan, Repository } from "typeorm";
|
|
17
17
|
import { Roles } from "../organisation/dto/RolesEnum.js";
|
|
18
18
|
import { Invitation } from "./entities/invitation.entity.js";
|
|
19
19
|
import { SmtpEmailClient } from "../smtp-email-client/email-client.service.js";
|
|
@@ -40,7 +40,7 @@ let InvitationService = InvitationService_1 = class InvitationService {
|
|
|
40
40
|
where: {
|
|
41
41
|
uuid: invitationCode,
|
|
42
42
|
acceptedOn: IsNull(),
|
|
43
|
-
expiresOn:
|
|
43
|
+
expiresOn: MoreThan(new Date()),
|
|
44
44
|
},
|
|
45
45
|
relations: {
|
|
46
46
|
organisationMembership: {
|
|
@@ -50,30 +50,26 @@ let InvitationService = InvitationService_1 = class InvitationService {
|
|
|
50
50
|
},
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
async
|
|
54
|
-
await this.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
async getAllForOrg(orgId, requestUser) {
|
|
54
|
+
await this.canManageInvitationsForThisOrg({
|
|
55
|
+
orgUuid: orgId,
|
|
56
|
+
user: requestUser,
|
|
57
|
+
});
|
|
58
|
+
return this.invitationRepository.find({
|
|
59
|
+
where: {
|
|
60
|
+
organisationMembership: {
|
|
61
|
+
organisation: {
|
|
62
|
+
uuid: orgId,
|
|
63
|
+
},
|
|
60
64
|
},
|
|
61
|
-
}
|
|
62
|
-
if (!latestInvitation) {
|
|
63
|
-
throw new NotFoundException(`Invitation with id ${invitationId} not found`);
|
|
64
|
-
}
|
|
65
|
-
// set the invitation to accepted
|
|
66
|
-
latestInvitation.acceptedOn = new Date();
|
|
67
|
-
await transactionalEntityManager.save(latestInvitation);
|
|
68
|
-
// set the user's membership to member and remove the invitation role
|
|
69
|
-
const memberRole = new MembershipRole();
|
|
70
|
-
memberRole.name = Roles.member;
|
|
71
|
-
latestInvitation.organisationMembership.roles = [memberRole];
|
|
72
|
-
await transactionalEntityManager.save(latestInvitation.organisationMembership);
|
|
65
|
+
},
|
|
73
66
|
});
|
|
74
67
|
}
|
|
75
68
|
async create(createDto, createdBy) {
|
|
76
|
-
await this.canManageInvitationsForThisOrg(
|
|
69
|
+
await this.canManageInvitationsForThisOrg({
|
|
70
|
+
orgId: createDto.organisationId,
|
|
71
|
+
user: createdBy,
|
|
72
|
+
});
|
|
77
73
|
const existingMemberships = await this.orgMembershipRepository.find({
|
|
78
74
|
where: {
|
|
79
75
|
user: {
|
|
@@ -84,21 +80,20 @@ let InvitationService = InvitationService_1 = class InvitationService {
|
|
|
84
80
|
},
|
|
85
81
|
},
|
|
86
82
|
relations: {
|
|
87
|
-
|
|
83
|
+
invitations: true,
|
|
88
84
|
roles: true,
|
|
89
85
|
},
|
|
90
86
|
});
|
|
91
|
-
if (existingMemberships.some((m) => m.roles
|
|
87
|
+
if (existingMemberships.some((m) => m.roles?.some((r) => r.name === Roles.member || r.name === Roles.owner))) {
|
|
92
88
|
const message = "A user with this email address is already a member of this organisation";
|
|
93
89
|
this.logger.error(message, { createDto, createdBy });
|
|
94
90
|
throw new Error(message);
|
|
95
91
|
}
|
|
96
|
-
if (existingMemberships.some((m) => m.
|
|
97
|
-
m.
|
|
98
|
-
m.invitation.expiresOn > new Date())) {
|
|
92
|
+
if (existingMemberships.some((m) => m.invitations &&
|
|
93
|
+
m.invitations.some((mi) => mi.acceptedOn === null && mi.expiresOn > new Date()))) {
|
|
99
94
|
const message = "An valid invitation with this email already exists for this organisation";
|
|
100
95
|
this.logger.error(message, { createDto, createdBy });
|
|
101
|
-
throw new
|
|
96
|
+
throw new BadRequestException(message);
|
|
102
97
|
}
|
|
103
98
|
// new empty user
|
|
104
99
|
const user = new User();
|
|
@@ -114,54 +109,90 @@ let InvitationService = InvitationService_1 = class InvitationService {
|
|
|
114
109
|
unsavedInvitation.expiresOn.setDate(unsavedInvitation.expiresOn.getDate() + 1);
|
|
115
110
|
unsavedInvitation.givenName = createDto.givenName;
|
|
116
111
|
// create a new membership
|
|
117
|
-
const membership = this.orgMembershipRepository.create(
|
|
112
|
+
const membership = this.orgMembershipRepository.create({
|
|
113
|
+
invitations: [],
|
|
114
|
+
});
|
|
118
115
|
membership.organisationId = createDto.organisationId;
|
|
119
116
|
membership.userId = savedUser.id;
|
|
120
|
-
membership.
|
|
117
|
+
membership.invitations?.push(unsavedInvitation);
|
|
121
118
|
membership.roles = [role];
|
|
122
119
|
const savedMembership = await this.orgMembershipRepository.save(membership);
|
|
123
120
|
const retrievedMembership = await this.orgMembershipRepository.findOne({
|
|
124
121
|
where: { id: savedMembership.id },
|
|
125
122
|
relations: {
|
|
126
|
-
|
|
123
|
+
invitations: true,
|
|
127
124
|
organisation: true,
|
|
128
125
|
},
|
|
129
126
|
});
|
|
130
|
-
if (!retrievedMembership
|
|
131
|
-
this.logger.error("
|
|
127
|
+
if (!retrievedMembership) {
|
|
128
|
+
this.logger.error("New membership did not save correctly", {
|
|
129
|
+
createDto,
|
|
130
|
+
createdBy,
|
|
131
|
+
createdMembershipId: savedMembership?.id,
|
|
132
|
+
});
|
|
133
|
+
throw new Error("New membership did not save correctly");
|
|
134
|
+
}
|
|
135
|
+
const validInvitation = retrievedMembership.invitations?.find((invitation) => invitation.expiresOn > new Date() && !invitation.acceptedOn);
|
|
136
|
+
if (!validInvitation) {
|
|
137
|
+
this.logger.error("New invitation did not save correctly", {
|
|
132
138
|
createDto,
|
|
133
139
|
createdBy,
|
|
134
140
|
createdMembershipId: savedMembership?.id,
|
|
135
141
|
});
|
|
136
|
-
throw new Error("
|
|
142
|
+
throw new Error("New invitation did not save correctly");
|
|
137
143
|
}
|
|
138
144
|
// try to email the invitation
|
|
139
145
|
await this.emailClient.sendMail([unsavedInvitation.emailAddress], [], `Invitation to join ${retrievedMembership.organisation.name}`, createdBy.uuid, `You have been invited to join ${retrievedMembership.organisation.name} by ${createdBy.givenName || "another member"}. Please click the link below to accept the invitation.
|
|
140
146
|
|
|
141
|
-
${this.configService.baseUrl}/accept-invitation/${
|
|
147
|
+
${this.configService.baseUrl}/accept-invitation/${validInvitation.uuid}`);
|
|
142
148
|
// if it gets to here we have a queued invitation
|
|
143
|
-
|
|
144
|
-
|
|
149
|
+
validInvitation.notificationSent = new Date();
|
|
150
|
+
const savedInvitation = await this.invitationRepository.save(validInvitation);
|
|
151
|
+
// we need to return the membership with the invitation
|
|
152
|
+
// torm doesn't like if we just assign and return so get it again
|
|
153
|
+
const fullInvitation = await this.invitationRepository.findOne({
|
|
154
|
+
where: {
|
|
155
|
+
id: savedInvitation.id,
|
|
156
|
+
},
|
|
157
|
+
relations: {
|
|
158
|
+
organisationMembership: {
|
|
159
|
+
user: true,
|
|
160
|
+
roles: true,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
165
|
+
return fullInvitation;
|
|
145
166
|
}
|
|
146
|
-
async canManageInvitationsForThisOrg(
|
|
167
|
+
async canManageInvitationsForThisOrg(parameters) {
|
|
168
|
+
const { orgId, orgUuid, user } = parameters;
|
|
169
|
+
if (orgId === undefined && orgUuid === undefined) {
|
|
170
|
+
throw new BadRequestException("Either orgId or orgUuid must be provided");
|
|
171
|
+
}
|
|
172
|
+
// super admin can do anything
|
|
173
|
+
if (user.permissions.includes("modify:all")) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
147
176
|
const requesterMembership = await this.orgMembershipRepository.findOneOrFail({
|
|
148
177
|
where: {
|
|
149
178
|
organisation: {
|
|
150
179
|
id: orgId,
|
|
180
|
+
uuid: orgUuid,
|
|
151
181
|
},
|
|
152
182
|
user: {
|
|
153
|
-
id:
|
|
183
|
+
id: user.id,
|
|
154
184
|
},
|
|
155
185
|
},
|
|
156
186
|
relations: {
|
|
157
187
|
roles: true,
|
|
158
188
|
},
|
|
159
189
|
});
|
|
160
|
-
if (requesterMembership.roles
|
|
161
|
-
|
|
190
|
+
if (requesterMembership.roles?.some((role) => role.name === Roles.owner)) {
|
|
191
|
+
return;
|
|
162
192
|
}
|
|
193
|
+
throw new ForbiddenException("You don't have permission to work with invitations");
|
|
163
194
|
}
|
|
164
|
-
async remove(uuid,
|
|
195
|
+
async remove(uuid, currentUser) {
|
|
165
196
|
const invitation = await this.invitationRepository.findOneOrFail({
|
|
166
197
|
where: {
|
|
167
198
|
uuid,
|
|
@@ -173,7 +204,10 @@ let InvitationService = InvitationService_1 = class InvitationService {
|
|
|
173
204
|
if (!invitation) {
|
|
174
205
|
throw new NotFoundException();
|
|
175
206
|
}
|
|
176
|
-
await this.canManageInvitationsForThisOrg(
|
|
207
|
+
await this.canManageInvitationsForThisOrg({
|
|
208
|
+
orgId: invitation.organisationMembership.organisation.id,
|
|
209
|
+
user: currentUser,
|
|
210
|
+
});
|
|
177
211
|
return this.invitationRepository.remove(invitation);
|
|
178
212
|
}
|
|
179
213
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitation.service.js","sourceRoot":"","sources":["../../src/invitations/invitation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"invitation.service.js","sourceRoot":"","sources":["../../src/invitations/invitation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EACH,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,MAAM,EACN,iBAAiB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AACrD,OAAO,EAAC,KAAK,EAAC,MAAM,kCAAkC,CAAC;AAEvD,OAAO,EAAC,UAAU,EAAC,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,8CAA8C,CAAC;AAC7E,O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C,EACtE;YACE,OAAO;SACV;QAED,MAAM,IAAI,kBAAkB,CACxB,oDAAoD,CACvD,CAAC;IACN,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,WAAwB;QAC/C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAC;YAC7D,KAAK,EAAE;gBACH,IAAI;aACP;YACD,SAAS,EAAE;gBACP,sBAAsB,EAAE,EAAC,YAAY,EAAE,IAAI,EAAC;aAC/C;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,EAAE;YACb,MAAM,IAAI,iBAAiB,EAAE,CAAC;SACjC;QACD,MAAM,IAAI,CAAC,8BAA8B,CAAC;YACtC,KAAK,EAAE,UAAU,CAAC,sBAAsB,CAAC,YAAY,CAAC,EAAE;YACxD,IAAI,EAAE,WAAW;SACpB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AAxQY,iBAAiB;IAD7B,UAAU,EAAE;IAIJ,WAAA,gBAAgB,CAAC,UAAU,CAAC,CAAA;IAE5B,WAAA,gBAAgB,CAAC,sBAAsB,CAAC,CAAA;IAExC,WAAA,gBAAgB,CAAC,IAAI,CAAC,CAAA;qCAHO,UAAU;QAEP,UAAU;QAEnB,UAAU;QACJ,eAAe;QACb,+BAA+B;GAV1D,iBAAiB,CAwQ7B;SAxQY,iBAAiB"}
|
|
@@ -8,6 +8,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { ApiProperty } from "@nestjs/swagger";
|
|
11
|
+
import { Type } from "class-transformer";
|
|
12
|
+
import { IsArray, IsDefined, IsString, MinLength, ValidateNested, } from "class-validator";
|
|
11
13
|
import { User } from "../../user-internal/entities/user.entity.js";
|
|
12
14
|
export class CreateOrganisationDto {
|
|
13
15
|
members;
|
|
@@ -15,15 +17,22 @@ export class CreateOrganisationDto {
|
|
|
15
17
|
name;
|
|
16
18
|
}
|
|
17
19
|
__decorate([
|
|
20
|
+
Type(() => User),
|
|
18
21
|
ApiProperty({ type: User, isArray: true }),
|
|
22
|
+
ValidateNested({ each: true }),
|
|
23
|
+
IsArray(),
|
|
19
24
|
__metadata("design:type", Array)
|
|
20
25
|
], CreateOrganisationDto.prototype, "members", void 0);
|
|
21
26
|
__decorate([
|
|
27
|
+
Type(() => User),
|
|
28
|
+
IsDefined(),
|
|
22
29
|
ApiProperty({ type: User }),
|
|
23
30
|
__metadata("design:type", User)
|
|
24
31
|
], CreateOrganisationDto.prototype, "owner", void 0);
|
|
25
32
|
__decorate([
|
|
26
33
|
ApiProperty(),
|
|
34
|
+
IsString(),
|
|
35
|
+
MinLength(1),
|
|
27
36
|
__metadata("design:type", String)
|
|
28
37
|
], CreateOrganisationDto.prototype, "name", void 0);
|
|
29
38
|
//# sourceMappingURL=create-organisation.dto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-organisation.dto.js","sourceRoot":"","sources":["../../../src/organisation/dto/create-organisation.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,IAAI,EAAC,MAAM,6CAA6C,CAAC;AAEjE,MAAM,OAAO,qBAAqB;
|
|
1
|
+
{"version":3,"file":"create-organisation.dto.js","sourceRoot":"","sources":["../../../src/organisation/dto/create-organisation.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AACvC,OAAO,EACH,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,cAAc,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,IAAI,EAAC,MAAM,6CAA6C,CAAC;AAEjE,MAAM,OAAO,qBAAqB;IAK9B,OAAO,CAAU;IAKjB,KAAK,CAAQ;IAKb,IAAI,CAAU;CACjB;AAfG;IAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IAChB,WAAW,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;IACxC,cAAc,CAAC,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC;IAC5B,OAAO,EAAE;;sDACO;AAEjB;IAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IAChB,SAAS,EAAE;IACX,WAAW,CAAC,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC;8BAClB,IAAI;oDAAC;AAEb;IAAC,WAAW,EAAE;IACb,QAAQ,EAAE;IACV,SAAS,CAAC,CAAC,CAAC;;mDACC"}
|
|
@@ -7,9 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { ApiProperty } from "@nestjs/swagger";
|
|
11
|
-
import { Column, CreateDateColumn,
|
|
10
|
+
import { ApiExtraModels, ApiProperty } from "@nestjs/swagger";
|
|
11
|
+
import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn, } from "typeorm";
|
|
12
12
|
import { OrganisationMembership } from "../../organisation-memberships/entities/organisation-membership.entity.js";
|
|
13
|
+
import { Roles } from "../dto/RolesEnum.js";
|
|
13
14
|
let MembershipRole = class MembershipRole {
|
|
14
15
|
id;
|
|
15
16
|
// we don't expose this because the roles are exposed on the membership
|
|
@@ -18,7 +19,6 @@ let MembershipRole = class MembershipRole {
|
|
|
18
19
|
name;
|
|
19
20
|
createdDate;
|
|
20
21
|
updateDate;
|
|
21
|
-
deletedDate;
|
|
22
22
|
};
|
|
23
23
|
__decorate([
|
|
24
24
|
PrimaryGeneratedColumn(),
|
|
@@ -38,6 +38,7 @@ __decorate([
|
|
|
38
38
|
__decorate([
|
|
39
39
|
ApiProperty(),
|
|
40
40
|
Column(),
|
|
41
|
+
ApiExtraModels(() => Roles),
|
|
41
42
|
__metadata("design:type", String)
|
|
42
43
|
], MembershipRole.prototype, "name", void 0);
|
|
43
44
|
__decorate([
|
|
@@ -50,11 +51,6 @@ __decorate([
|
|
|
50
51
|
ApiProperty(),
|
|
51
52
|
__metadata("design:type", Date)
|
|
52
53
|
], MembershipRole.prototype, "updateDate", void 0);
|
|
53
|
-
__decorate([
|
|
54
|
-
DeleteDateColumn(),
|
|
55
|
-
ApiProperty(),
|
|
56
|
-
__metadata("design:type", Date)
|
|
57
|
-
], MembershipRole.prototype, "deletedDate", void 0);
|
|
58
54
|
MembershipRole = __decorate([
|
|
59
55
|
Entity()
|
|
60
56
|
], MembershipRole);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"member-role.entity.js","sourceRoot":"","sources":["../../../src/organisation/entities/member-role.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"member-role.entity.js","sourceRoot":"","sources":["../../../src/organisation/entities/member-role.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,cAAc,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EACH,MAAM,EACN,gBAAgB,EAChB,MAAM,EACN,SAAS,EACT,sBAAsB,EAEtB,UAAU,EACV,gBAAgB,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,sBAAsB,EAAC,MAAM,2EAA2E,CAAC;AACjH,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAGnC,IAAM,cAAc,GAApB,MAAM,cAAc;IAGvB,EAAE,CAAU;IAEZ,uEAAuE;IAEvE,UAAU,CAAoC;IAKvC,YAAY,CAAU;IAK7B,IAAI,CAAU;IAId,WAAW,CAAQ;IAInB,UAAU,CAAQ;CACrB,CAAA;AAzBG;IAAC,sBAAsB,EAAE;IACxB,WAAW,EAAE;;0CACF;AAGZ;IAAC,SAAS,CAAC,GAAG,EAAE,CAAC,sBAAsB,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;;kDAC5B;AAE9C;IAAC,WAAW,EAAE;IACb,MAAM,EAAE;IACR,UAAU,CAAC,CAAC,EAAkB,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC;;oDACrB;AAE7B;IAAC,WAAW,EAAE;IACb,MAAM,EAAE;IACR,cAAc,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;;4CACd;AAEd;IAAC,gBAAgB,EAAE;IAClB,WAAW,EAAE;8BACA,IAAI;mDAAC;AAEnB;IAAC,gBAAgB,EAAE;IAClB,WAAW,EAAE;8BACD,IAAI;kDAAC;AAzBT,cAAc;IAD1B,MAAM,EAAE;GACI,cAAc,CA0B1B;SA1BY,cAAc"}
|
|
@@ -3,11 +3,10 @@ import { OrganisationSubscriptionRecord } from "../../organisation-subscriptions
|
|
|
3
3
|
export declare class Organisation {
|
|
4
4
|
id: number;
|
|
5
5
|
uuid: string;
|
|
6
|
-
memberships
|
|
7
|
-
subscriptionRecords
|
|
6
|
+
memberships?: OrganisationMembership[];
|
|
7
|
+
subscriptionRecords?: OrganisationSubscriptionRecord[];
|
|
8
8
|
name: string;
|
|
9
9
|
createdDate: Date;
|
|
10
10
|
updateDate: Date;
|
|
11
11
|
deletedDate: Date;
|
|
12
|
-
nullChecks(): Promise<void>;
|
|
13
12
|
}
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import { ApiProperty } from "@nestjs/swagger";
|
|
11
11
|
import { Type } from "class-transformer";
|
|
12
|
-
import {
|
|
12
|
+
import { Column, CreateDateColumn, DeleteDateColumn, Entity, Generated, Index, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn, } from "typeorm";
|
|
13
13
|
import { OrganisationMembership } from "../../organisation-memberships/entities/organisation-membership.entity.js";
|
|
14
14
|
import { OrganisationSubscriptionRecord } from "../../organisation-subscriptions/entities/organisation-subscription.entity.js";
|
|
15
15
|
let Organisation = class Organisation {
|
|
@@ -21,12 +21,6 @@ let Organisation = class Organisation {
|
|
|
21
21
|
createdDate;
|
|
22
22
|
updateDate;
|
|
23
23
|
deletedDate;
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
25
|
-
async nullChecks() {
|
|
26
|
-
if (!this.memberships) {
|
|
27
|
-
this.memberships = [];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
24
|
};
|
|
31
25
|
__decorate([
|
|
32
26
|
PrimaryGeneratedColumn(),
|
|
@@ -77,14 +71,6 @@ __decorate([
|
|
|
77
71
|
ApiProperty(),
|
|
78
72
|
__metadata("design:type", Date)
|
|
79
73
|
], Organisation.prototype, "deletedDate", void 0);
|
|
80
|
-
__decorate([
|
|
81
|
-
AfterLoad(),
|
|
82
|
-
AfterInsert(),
|
|
83
|
-
AfterUpdate(),
|
|
84
|
-
__metadata("design:type", Function),
|
|
85
|
-
__metadata("design:paramtypes", []),
|
|
86
|
-
__metadata("design:returntype", Promise)
|
|
87
|
-
], Organisation.prototype, "nullChecks", null);
|
|
88
74
|
Organisation = __decorate([
|
|
89
75
|
Entity()
|
|
90
76
|
], Organisation);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation.entity.js","sourceRoot":"","sources":["../../../src/organisation/entities/organisation.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACH,
|
|
1
|
+
{"version":3,"file":"organisation.entity.js","sourceRoot":"","sources":["../../../src/organisation/entities/organisation.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACH,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EACN,SAAS,EACT,KAAK,EACL,SAAS,EACT,sBAAsB,EACtB,gBAAgB,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,sBAAsB,EAAC,MAAM,2EAA2E,CAAC;AACjH,OAAO,EAAC,8BAA8B,EAAC,MAAM,+EAA+E,CAAC;AAGtH,IAAM,YAAY,GAAlB,MAAM,YAAY;IAGrB,EAAE,CAAU;IASL,IAAI,CAAU;IAMrB,WAAW,CAA4B;IAUvC,mBAAmB,CAAoC;IAIvD,IAAI,CAAU;IAId,WAAW,CAAQ;IAInB,UAAU,CAAQ;IAIlB,WAAW,CAAQ;CACtB,CAAA;AA5CG;IAAC,sBAAsB,EAAE;IACxB,WAAW,EAAE;;wCACF;AAEZ;IAAC,MAAM,CAAC,MAAM,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAoB;KACtC,CAAC;IACD,SAAS,CAAC,MAAM,CAAC;IACjB,WAAW,EAAE;IACb,KAAK,EAAE;;0CACa;AAErB;IAAC,SAAS,CAAC,GAAG,EAAE,CAAC,sBAAsB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE;QAC9D,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;KAChC,CAAC;IACD,IAAI,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC;;iDACI;AAEvC;IAAC,SAAS,CACN,GAAG,EAAE,CAAC,8BAA8B,EACpC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,EACzB;QACI,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;KAChC,CACJ;IACA,IAAI,CAAC,GAAG,EAAE,CAAC,8BAA8B,CAAC;;yDACY;AAEvD;IAAC,MAAM,EAAE;IACR,WAAW,EAAE;;0CACA;AAEd;IAAC,gBAAgB,EAAE;IAClB,WAAW,EAAE;8BACA,IAAI;iDAAC;AAEnB;IAAC,gBAAgB,EAAE;IAClB,WAAW,EAAE;8BACD,IAAI;gDAAC;AAElB;IAAC,gBAAgB,EAAE;IAClB,WAAW,EAAE;8BACA,IAAI;iDAAC;AA5CV,YAAY;IADxB,MAAM,EAAE;GACI,YAAY,CA6CxB;SA7CY,YAAY"}
|
|
@@ -33,6 +33,8 @@ let OrganisationService = class OrganisationService {
|
|
|
33
33
|
ownerMembership.user = createOrganisationDto.owner;
|
|
34
34
|
const ownerRole = new MembershipRole();
|
|
35
35
|
ownerRole.name = Roles.owner;
|
|
36
|
+
if (!ownerMembership.roles)
|
|
37
|
+
ownerMembership.roles = [];
|
|
36
38
|
ownerMembership.roles.push(ownerRole);
|
|
37
39
|
unsavedOrganisation.memberships.push(ownerMembership);
|
|
38
40
|
// add all the others
|
|
@@ -41,6 +43,8 @@ let OrganisationService = class OrganisationService {
|
|
|
41
43
|
membership.user = member;
|
|
42
44
|
const memberRole = new MembershipRole();
|
|
43
45
|
memberRole.name = Roles.member;
|
|
46
|
+
if (!membership.roles)
|
|
47
|
+
membership.roles = [];
|
|
44
48
|
membership.roles.push(memberRole);
|
|
45
49
|
return membership;
|
|
46
50
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation.service.js","sourceRoot":"","sources":["../../src/organisation/organisation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AACjD,OAAO,E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AAE,qBAAqB,CAAC,CAAC;QAEzD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,aAAqB;QAC5C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;YACnD,KAAK,EAAE;gBACH,IAAI;gBACJ,WAAW,EAAE;oBACT,IAAI,EAAE;wBACF,EAAE,EAAE,aAAa;qBACpB;oBACD,KAAK,EAAE;wBACH,IAAI,EAAE,KAAK,CAAC,KAAK;qBACpB;iBACJ;aACJ;SACJ,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YAC1B,EAAE,EAAE,UAAU,CAAC,EAAE;SACpB,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;
|
|
1
|
+
{"version":3,"file":"organisation.service.js","sourceRoot":"","sources":["../../src/organisation/organisation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAe,UAAU,EAAe,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAC,sBAAsB,EAAC,MAAM,wEAAwE,CAAC;AAE9G,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAGxD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAGhB;IAFZ,YAEY,UAAoC;QAApC,eAAU,GAAV,UAAU,CAA0B;IAC7C,CAAC;IACI,eAAe,GACnB,mDAAmD,CAAC;IACxD,KAAK,CAAC,MAAM,CACR,qBAA4C;QAE5C,4BA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J,WAAW,EAAE;oBACT,IAAI,EAAE;wBACF,EAAE,EAAE,aAAa;qBACpB;oBACD,KAAK,EAAE;wBACH,IAAI,EAAE,KAAK,CAAC,KAAK;qBACpB;iBACJ;aACJ;SACJ,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YAC1B,EAAE,EAAE,UAAU,CAAC,EAAE;SACpB,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAnHY,mBAAmB;IAD/B,UAAU,EAAE;IAGJ,WAAA,gBAAgB,CAAC,YAAY,CAAC,CAAA;qCACX,UAAU;GAHzB,mBAAmB,CAmH/B;SAnHY,mBAAmB"}
|
|
@@ -8,16 +8,19 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { ApiProperty } from "@nestjs/swagger";
|
|
11
|
+
import { IsArray, IsInt } from "class-validator";
|
|
11
12
|
export class CreateUpdateMembershipDto {
|
|
12
13
|
userId;
|
|
13
14
|
roles;
|
|
14
15
|
}
|
|
15
16
|
__decorate([
|
|
16
17
|
ApiProperty(),
|
|
18
|
+
IsInt(),
|
|
17
19
|
__metadata("design:type", Number)
|
|
18
20
|
], CreateUpdateMembershipDto.prototype, "userId", void 0);
|
|
19
21
|
__decorate([
|
|
20
22
|
ApiProperty({ type: String, isArray: true }),
|
|
23
|
+
IsArray(),
|
|
21
24
|
__metadata("design:type", Array)
|
|
22
25
|
], CreateUpdateMembershipDto.prototype, "roles", void 0);
|
|
23
26
|
//# sourceMappingURL=create-membership-dto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-membership-dto.js","sourceRoot":"","sources":["../../../src/organisation-memberships/dtos/create-membership-dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-membership-dto.js","sourceRoot":"","sources":["../../../src/organisation-memberships/dtos/create-membership-dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAE/C,MAAM,OAAO,yBAAyB;IAGlC,MAAM,CAAU;IAIhB,KAAK,CAAY;CACpB;AAPG;IAAC,WAAW,EAAE;IACb,KAAK,EAAE;;yDACQ;AAEhB;IAAC,WAAW,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;IAC1C,OAAO,EAAE;;wDACO"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Relation } from "typeorm";
|
|
1
2
|
import { Invitation } from "../../invitations/entities/invitation.entity.js";
|
|
2
3
|
import { MembershipRole } from "../../organisation/entities/member-role.entity.js";
|
|
3
4
|
import { Organisation } from "../../organisation/entities/organisation.entity.js";
|
|
@@ -9,11 +10,9 @@ export declare class OrganisationMembership {
|
|
|
9
10
|
userId: number;
|
|
10
11
|
organisation: Organisation;
|
|
11
12
|
organisationId: number;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
roles: MembershipRole[];
|
|
13
|
+
invitations?: Relation<Invitation>[];
|
|
14
|
+
roles?: MembershipRole[];
|
|
15
15
|
createdDate: Date;
|
|
16
16
|
updateDate: Date;
|
|
17
17
|
deletedDate: Date;
|
|
18
|
-
nullChecks(): Promise<void>;
|
|
19
18
|
}
|
|
@@ -7,9 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { ApiProperty } from "@nestjs/swagger";
|
|
10
|
+
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
11
11
|
import { Type } from "class-transformer";
|
|
12
|
-
import {
|
|
12
|
+
import { Column, CreateDateColumn, DeleteDateColumn, Entity, Generated, Index, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn, RelationId, UpdateDateColumn, } from "typeorm";
|
|
13
13
|
import { Invitation } from "../../invitations/entities/invitation.entity.js";
|
|
14
14
|
import { MembershipRole } from "../../organisation/entities/member-role.entity.js";
|
|
15
15
|
import { Organisation } from "../../organisation/entities/organisation.entity.js";
|
|
@@ -21,18 +21,11 @@ let OrganisationMembership = class OrganisationMembership {
|
|
|
21
21
|
userId;
|
|
22
22
|
organisation;
|
|
23
23
|
organisationId;
|
|
24
|
-
|
|
25
|
-
invitationId;
|
|
24
|
+
invitations;
|
|
26
25
|
roles;
|
|
27
26
|
createdDate;
|
|
28
27
|
updateDate;
|
|
29
28
|
deletedDate;
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
31
|
-
async nullChecks() {
|
|
32
|
-
if (!this.roles) {
|
|
33
|
-
this.roles = [];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
29
|
};
|
|
37
30
|
__decorate([
|
|
38
31
|
PrimaryGeneratedColumn(),
|
|
@@ -76,27 +69,22 @@ __decorate([
|
|
|
76
69
|
__metadata("design:type", Number)
|
|
77
70
|
], OrganisationMembership.prototype, "organisationId", void 0);
|
|
78
71
|
__decorate([
|
|
79
|
-
|
|
72
|
+
OneToMany(() => Invitation, (inv) => inv.organisationMembership, {
|
|
80
73
|
eager: true,
|
|
81
74
|
nullable: true,
|
|
82
75
|
cascade: ["insert", "update"],
|
|
83
76
|
}),
|
|
84
77
|
JoinColumn(),
|
|
85
|
-
__metadata("design:type",
|
|
86
|
-
], OrganisationMembership.prototype, "
|
|
87
|
-
__decorate([
|
|
88
|
-
Column(),
|
|
89
|
-
ApiProperty(),
|
|
90
|
-
RelationId((membership) => membership.invitation),
|
|
91
|
-
__metadata("design:type", Number)
|
|
92
|
-
], OrganisationMembership.prototype, "invitationId", void 0);
|
|
78
|
+
__metadata("design:type", Array)
|
|
79
|
+
], OrganisationMembership.prototype, "invitations", void 0);
|
|
93
80
|
__decorate([
|
|
94
|
-
|
|
81
|
+
ApiPropertyOptional({ type: () => MembershipRole, isArray: true })
|
|
95
82
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
96
83
|
,
|
|
97
84
|
OneToMany(() => MembershipRole, (role) => role.membership, {
|
|
98
85
|
eager: true,
|
|
99
|
-
cascade:
|
|
86
|
+
cascade: ["insert", "update"],
|
|
87
|
+
orphanedRowAction: "delete",
|
|
100
88
|
}),
|
|
101
89
|
Type(() => MembershipRole),
|
|
102
90
|
__metadata("design:type", Array)
|
|
@@ -116,14 +104,6 @@ __decorate([
|
|
|
116
104
|
ApiProperty(),
|
|
117
105
|
__metadata("design:type", Date)
|
|
118
106
|
], OrganisationMembership.prototype, "deletedDate", void 0);
|
|
119
|
-
__decorate([
|
|
120
|
-
AfterLoad(),
|
|
121
|
-
AfterInsert(),
|
|
122
|
-
AfterUpdate(),
|
|
123
|
-
__metadata("design:type", Function),
|
|
124
|
-
__metadata("design:paramtypes", []),
|
|
125
|
-
__metadata("design:returntype", Promise)
|
|
126
|
-
], OrganisationMembership.prototype, "nullChecks", null);
|
|
127
107
|
OrganisationMembership = __decorate([
|
|
128
108
|
Entity()
|
|
129
109
|
], OrganisationMembership);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation-membership.entity.js","sourceRoot":"","sources":["../../../src/organisation-memberships/entities/organisation-membership.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"organisation-membership.entity.js","sourceRoot":"","sources":["../../../src/organisation-memberships/entities/organisation-membership.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,iBAAiB,CA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AAhEV,sBAAsB;IADlC,MAAM,EAAE;GACI,sBAAsB,CAiElC;SAjEY,sBAAsB"}
|
|
@@ -63,19 +63,19 @@ let OrganisationMembershipsService = class OrganisationMembershipsService {
|
|
|
63
63
|
// check if the user is allowed to work with memberships
|
|
64
64
|
this.currentUserIsOwnerGuard(org, currentUserId);
|
|
65
65
|
// existing membership for this user?
|
|
66
|
-
const existingMembership = org.memberships
|
|
66
|
+
const existingMembership = org.memberships?.find((m) => m.user.id === createOmDto.userId);
|
|
67
67
|
if (existingMembership) {
|
|
68
68
|
// add all roles to the existing membership
|
|
69
69
|
for (const role of createOmDto.roles) {
|
|
70
|
-
const existingRole = existingMembership.roles
|
|
70
|
+
const existingRole = existingMembership.roles?.find((r) => r.name === role);
|
|
71
71
|
if (!existingRole) {
|
|
72
72
|
const newRole = new MembershipRole();
|
|
73
73
|
newRole.name = role;
|
|
74
|
-
existingMembership.roles
|
|
74
|
+
existingMembership.roles?.push(newRole);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
// remove all roles that are not in the DTO
|
|
78
|
-
existingMembership.roles = existingMembership.roles
|
|
78
|
+
existingMembership.roles = existingMembership.roles?.filter((r) => createOmDto.roles.includes(r.name));
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
81
|
// create a new membership
|
|
@@ -84,15 +84,15 @@ let OrganisationMembershipsService = class OrganisationMembershipsService {
|
|
|
84
84
|
for (const role of createOmDto.roles) {
|
|
85
85
|
const newRole = new MembershipRole();
|
|
86
86
|
newRole.name = role;
|
|
87
|
-
newMembership.roles
|
|
87
|
+
newMembership.roles?.push(newRole);
|
|
88
88
|
}
|
|
89
|
-
org.memberships
|
|
89
|
+
org.memberships?.push(newMembership);
|
|
90
90
|
}
|
|
91
91
|
return await this.orgRepo.save(org);
|
|
92
92
|
}
|
|
93
93
|
currentUserIsOwnerGuard(org, currentUserId) {
|
|
94
|
-
const membership = org.memberships
|
|
95
|
-
m.roles
|
|
94
|
+
const membership = org.memberships?.find((m) => m.user.id === currentUserId &&
|
|
95
|
+
m.roles?.some((r) => r.name === Roles.owner));
|
|
96
96
|
if (!membership) {
|
|
97
97
|
throw new NotFoundException("You are not allowed to add a member to this organisation");
|
|
98
98
|
}
|
|
@@ -115,7 +115,7 @@ let OrganisationMembershipsService = class OrganisationMembershipsService {
|
|
|
115
115
|
// check if the user is allowed to work with memberships
|
|
116
116
|
this.currentUserIsOwnerGuard(org, currentUserId);
|
|
117
117
|
// remove the membership
|
|
118
|
-
const membership = org.memberships
|
|
118
|
+
const membership = org.memberships?.find((m) => m.uuid === membershipUuid);
|
|
119
119
|
if (!membership) {
|
|
120
120
|
throw new Error("Membership not found");
|
|
121
121
|
}
|