@darraghor/nest-backend-libs 1.49.1 → 2.1.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/core-config/CoreConfigurationService.d.ts +1 -2
- package/dist/core-config/CoreConfigurationService.js +3 -12
- package/dist/core-config/CoreConfigurationService.js.map +1 -1
- package/dist/core-config/CoreConfigurationVariables.d.ts +2 -4
- package/dist/core-config/CoreConfigurationVariables.js +1 -2
- package/dist/core-config/CoreConfigurationVariables.js.map +1 -1
- package/dist/database-postgres/PostgresDatabaseConfigurationService.d.ts +0 -2
- package/dist/database-postgres/PostgresDatabaseConfigurationService.js +0 -2
- package/dist/database-postgres/PostgresDatabaseConfigurationService.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/invitations/InvitationConfigurationService.d.ts +7 -0
- package/dist/invitations/InvitationConfigurationService.js +38 -0
- package/dist/invitations/InvitationConfigurationService.js.map +1 -0
- package/dist/invitations/InvitationConfigurationVariables.d.ts +6 -0
- package/dist/invitations/InvitationConfigurationVariables.js +7 -0
- package/dist/invitations/InvitationConfigurationVariables.js.map +1 -0
- package/dist/invitations/dto/create-invitation.dto.d.ts +5 -0
- package/dist/invitations/dto/create-invitation.dto.js +29 -0
- package/dist/invitations/dto/create-invitation.dto.js.map +1 -0
- package/dist/invitations/entities/invitation.entity.d.ts +14 -0
- package/dist/invitations/entities/invitation.entity.js +85 -0
- package/dist/invitations/entities/invitation.entity.js.map +1 -0
- package/dist/invitations/invitation.controller.d.ts +10 -0
- package/dist/invitations/invitation.controller.js +60 -0
- package/dist/invitations/invitation.controller.js.map +1 -0
- package/dist/invitations/invitation.module.d.ts +2 -0
- package/dist/invitations/invitation.module.js +41 -0
- package/dist/invitations/invitation.module.js.map +1 -0
- package/dist/invitations/invitation.service.d.ts +16 -0
- package/dist/invitations/invitation.service.js +92 -0
- package/dist/invitations/invitation.service.js.map +1 -0
- package/dist/organisation/dto/RolesEnum.d.ts +4 -0
- package/dist/organisation/dto/RolesEnum.js +10 -0
- package/dist/organisation/dto/RolesEnum.js.map +1 -0
- package/dist/organisation/entities/member-role.entity.d.ts +10 -0
- package/dist/organisation/entities/member-role.entity.js +60 -0
- package/dist/organisation/entities/member-role.entity.js.map +1 -0
- package/dist/organisation/entities/organisation-membership.entity.d.ts +16 -0
- package/dist/organisation/entities/organisation-membership.entity.js +105 -0
- package/dist/organisation/entities/organisation-membership.entity.js.map +1 -0
- package/dist/organisation/entities/organisation.entity.d.ts +4 -4
- package/dist/organisation/entities/organisation.entity.js +12 -19
- package/dist/organisation/entities/organisation.entity.js.map +1 -1
- package/dist/organisation/organisation.service.js +73 -17
- package/dist/organisation/organisation.service.js.map +1 -1
- package/dist/person/entities/person.entity.d.ts +2 -3
- package/dist/person/entities/person.entity.js +6 -17
- package/dist/person/entities/person.entity.js.map +1 -1
- package/dist/person/person.service.js +33 -11
- package/dist/person/person.service.js.map +1 -1
- package/dist/root-app/core-app.module.js +4 -2
- package/dist/root-app/core-app.module.js.map +1 -1
- package/dist/smtp-email-client/EmailClientProvider.d.ts +1 -1
- package/dist/smtp-email-client/EmailClientProvider.js +3 -3
- package/dist/smtp-email-client/EmailClientProvider.js.map +1 -1
- package/dist/smtp-email-client/EmailConfigurationService.d.ts +1 -1
- package/dist/smtp-email-client/EmailConfigurationService.js +3 -3
- package/dist/smtp-email-client/EmailConfigurationService.js.map +1 -1
- package/dist/smtp-email-client/EmailConfigurationVariables.d.ts +2 -2
- package/dist/smtp-email-client/EmailConfigurationVariables.js +1 -1
- package/dist/smtp-email-client/EmailConfigurationVariables.js.map +1 -1
- package/dist/smtp-email-client/email-client.service.d.ts +4 -2
- package/dist/smtp-email-client/email-client.service.js +20 -26
- package/dist/smtp-email-client/email-client.service.js.map +1 -1
- package/dist/smtp-email-client/email.entity.d.ts +3 -1
- package/dist/smtp-email-client/email.entity.js +12 -2
- package/dist/smtp-email-client/email.entity.js.map +1 -1
- package/dist/smtp-email-client/smtp-email-client.module.d.ts +1 -0
- package/dist/smtp-email-client/smtp-email-client.module.js +9 -2
- package/dist/smtp-email-client/smtp-email-client.module.js.map +1 -1
- package/dist/smtp-email-client/smtp-email-handler.d.ts +17 -0
- package/dist/smtp-email-client/smtp-email-handler.js +108 -0
- package/dist/smtp-email-client/smtp-email-handler.js.map +1 -0
- package/dist/stripe-client/StripeClientConfigurationService.d.ts +9 -0
- package/dist/stripe-client/StripeClientConfigurationService.js +56 -0
- package/dist/stripe-client/StripeClientConfigurationService.js.map +1 -0
- package/dist/stripe-client/StripeClientProvider.d.ts +7 -0
- package/dist/stripe-client/StripeClientProvider.js +22 -0
- package/dist/stripe-client/StripeClientProvider.js.map +1 -0
- package/dist/stripe-client/StripeConfigurationVariables.d.ts +10 -0
- package/dist/stripe-client/StripeConfigurationVariables.js +9 -0
- package/dist/stripe-client/StripeConfigurationVariables.js.map +1 -0
- package/dist/stripe-client/models/StripeCheckoutSessionParams.d.ts +11 -0
- package/dist/stripe-client/models/StripeCheckoutSessionParams.js +63 -0
- package/dist/stripe-client/models/StripeCheckoutSessionParams.js.map +1 -0
- package/dist/stripe-client/services/stripe-checkout.service.d.ts +15 -0
- package/dist/stripe-client/services/stripe-checkout.service.js +65 -0
- package/dist/stripe-client/services/stripe-checkout.service.js.map +1 -0
- package/dist/stripe-client/services/stripe-event-handler.d.ts +11 -0
- package/dist/stripe-client/services/stripe-event-handler.js +148 -0
- package/dist/stripe-client/services/stripe-event-handler.js.map +1 -0
- package/dist/stripe-client/services/stripe-webhook-handler.service.d.ts +14 -0
- package/dist/stripe-client/services/stripe-webhook-handler.service.js +56 -0
- package/dist/stripe-client/services/stripe-webhook-handler.service.js.map +1 -0
- package/dist/stripe-client/stripe-account.module.d.ts +4 -0
- package/dist/stripe-client/stripe-account.module.js +45 -0
- package/dist/stripe-client/stripe-account.module.js.map +1 -0
- package/dist/stripe-client/stripe-controller.d.ts +14 -0
- package/dist/stripe-client/stripe-controller.js +86 -0
- package/dist/stripe-client/stripe-controller.js.map +1 -0
- package/package.json +20 -17
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.InvitationService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const RolesEnum_1 = require("../organisation/dto/RolesEnum");
|
|
20
|
+
const invitation_entity_1 = require("./entities/invitation.entity");
|
|
21
|
+
const email_client_service_1 = require("../smtp-email-client/email-client.service");
|
|
22
|
+
const organisation_entity_1 = require("../organisation/entities/organisation.entity");
|
|
23
|
+
const InvitationConfigurationService_1 = require("./InvitationConfigurationService");
|
|
24
|
+
let InvitationService = class InvitationService {
|
|
25
|
+
constructor(invitationRepository, organisationRepository, emailClient, configService) {
|
|
26
|
+
this.invitationRepository = invitationRepository;
|
|
27
|
+
this.organisationRepository = organisationRepository;
|
|
28
|
+
this.emailClient = emailClient;
|
|
29
|
+
this.configService = configService;
|
|
30
|
+
}
|
|
31
|
+
async create(createDto, createdBy) {
|
|
32
|
+
const existingInvitations = await this.invitationRepository.find({
|
|
33
|
+
where: {
|
|
34
|
+
emailAddress: createDto.emailAddress,
|
|
35
|
+
organisation: {
|
|
36
|
+
id: createDto.organisationId,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const hasUnexpiredInvitations = existingInvitations.some((invitation) => invitation.expiresOn > new Date());
|
|
41
|
+
if (hasUnexpiredInvitations) {
|
|
42
|
+
throw new Error("An valid invitation already exists for this email address for this organisation");
|
|
43
|
+
}
|
|
44
|
+
// otherwise, create a new invitation
|
|
45
|
+
const unsavedInvitation = new invitation_entity_1.Invitation();
|
|
46
|
+
unsavedInvitation.emailAddress = createDto.emailAddress;
|
|
47
|
+
unsavedInvitation.expiresOn = new Date();
|
|
48
|
+
unsavedInvitation.expiresOn.setDate(unsavedInvitation.expiresOn.getDate() + 1);
|
|
49
|
+
unsavedInvitation.organisation =
|
|
50
|
+
await this.organisationRepository.findOneOrFail({
|
|
51
|
+
where: { id: createDto.organisationId },
|
|
52
|
+
});
|
|
53
|
+
unsavedInvitation.givenName = createDto.givenName;
|
|
54
|
+
const savedInvitation = await this.invitationRepository.save(unsavedInvitation);
|
|
55
|
+
// try to email the invitation
|
|
56
|
+
await this.emailClient.sendMail([unsavedInvitation.emailAddress], [], `Invitation to join ${unsavedInvitation.organisation.name}`, createdBy.uuid, `You have been invited to join ${unsavedInvitation.organisation.name} by ${createdBy.givenName || "another "} ${createdBy.familyName || "member"}. Please click the link below to accept the invitation.
|
|
57
|
+
|
|
58
|
+
${this.configService.baseUrl}/accept-invitation/${savedInvitation.uuid}`);
|
|
59
|
+
// if it gets to here we have a sent invitation
|
|
60
|
+
savedInvitation.notificationSent = new Date();
|
|
61
|
+
return this.invitationRepository.save(savedInvitation);
|
|
62
|
+
}
|
|
63
|
+
async remove(uuid, currentUserId) {
|
|
64
|
+
const invitation = await this.invitationRepository.findOneOrFail({
|
|
65
|
+
where: {
|
|
66
|
+
uuid,
|
|
67
|
+
organisation: {
|
|
68
|
+
memberships: {
|
|
69
|
+
person: {
|
|
70
|
+
id: currentUserId,
|
|
71
|
+
},
|
|
72
|
+
roles: {
|
|
73
|
+
name: RolesEnum_1.Roles.owner,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
return this.invitationRepository.remove(invitation);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
InvitationService = __decorate([
|
|
83
|
+
(0, common_1.Injectable)(),
|
|
84
|
+
__param(0, (0, typeorm_1.InjectRepository)(invitation_entity_1.Invitation)),
|
|
85
|
+
__param(1, (0, typeorm_1.InjectRepository)(organisation_entity_1.Organisation)),
|
|
86
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
87
|
+
typeorm_2.Repository,
|
|
88
|
+
email_client_service_1.SmtpEmailClient,
|
|
89
|
+
InvitationConfigurationService_1.InvitationsConfigurationService])
|
|
90
|
+
], InvitationService);
|
|
91
|
+
exports.InvitationService = InvitationService;
|
|
92
|
+
//# sourceMappingURL=invitation.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invitation.service.js","sourceRoot":"","sources":["../../src/invitations/invitation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0C;AAC1C,6CAAiD;AACjD,qCAAmC;AACnC,6DAAoD;AAEpD,oEAAwD;AACxD,oFAA0E;AAE1E,sFAA0E;AAC1E,qFAAiF;AAG1E,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC1B,YAEY,oBAA4C,EAE5C,sBAAgD,EACvC,WAA4B,EAC5B,aAA8C;QAJvD,yBAAoB,GAApB,oBAAoB,CAAwB;QAE5C,2BAAsB,GAAtB,sBAAsB,CAA0B;QACvC,gBAAW,G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|
4
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
5
|
+
var Roles;
|
|
6
|
+
(function (Roles) {
|
|
7
|
+
Roles["owner"] = "owner";
|
|
8
|
+
Roles["member"] = "member";
|
|
9
|
+
})(Roles = exports.Roles || (exports.Roles = {}));
|
|
10
|
+
//# sourceMappingURL=RolesEnum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RolesEnum.js","sourceRoot":"","sources":["../../../src/organisation/dto/RolesEnum.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,IAAY,KAGX;AAHD,WAAY,KAAK;IACb,wBAAe,CAAA;IACf,0BAAiB,CAAA;AACrB,CAAC,EAHW,KAAK,GAAL,aAAK,KAAL,aAAK,QAGhB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OrganisationMembership } from "./organisation-membership.entity";
|
|
2
|
+
export declare class MembershipRole {
|
|
3
|
+
id: number;
|
|
4
|
+
membership: OrganisationMembership;
|
|
5
|
+
membershipId: number;
|
|
6
|
+
name: string;
|
|
7
|
+
createdDate: Date;
|
|
8
|
+
updateDate: Date;
|
|
9
|
+
deletedDate: Date;
|
|
10
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MembershipRole = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const organisation_membership_entity_1 = require("./organisation-membership.entity");
|
|
16
|
+
let MembershipRole = class MembershipRole {
|
|
17
|
+
};
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
20
|
+
(0, swagger_1.ApiProperty)(),
|
|
21
|
+
__metadata("design:type", Number)
|
|
22
|
+
], MembershipRole.prototype, "id", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, typeorm_1.ManyToOne)(() => organisation_membership_entity_1.OrganisationMembership, (membership) => membership.roles, {
|
|
25
|
+
eager: true,
|
|
26
|
+
cascade: true,
|
|
27
|
+
}),
|
|
28
|
+
(0, typeorm_1.Index)(),
|
|
29
|
+
(0, typeorm_1.JoinColumn)(),
|
|
30
|
+
__metadata("design:type", organisation_membership_entity_1.OrganisationMembership)
|
|
31
|
+
], MembershipRole.prototype, "membership", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.Column)(),
|
|
34
|
+
(0, typeorm_1.RelationId)((membership) => membership.membership),
|
|
35
|
+
__metadata("design:type", Number)
|
|
36
|
+
], MembershipRole.prototype, "membershipId", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)(),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], MembershipRole.prototype, "name", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
43
|
+
(0, swagger_1.ApiProperty)(),
|
|
44
|
+
__metadata("design:type", Date)
|
|
45
|
+
], MembershipRole.prototype, "createdDate", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
48
|
+
(0, swagger_1.ApiProperty)(),
|
|
49
|
+
__metadata("design:type", Date)
|
|
50
|
+
], MembershipRole.prototype, "updateDate", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typeorm_1.DeleteDateColumn)(),
|
|
53
|
+
(0, swagger_1.ApiProperty)(),
|
|
54
|
+
__metadata("design:type", Date)
|
|
55
|
+
], MembershipRole.prototype, "deletedDate", void 0);
|
|
56
|
+
MembershipRole = __decorate([
|
|
57
|
+
(0, typeorm_1.Entity)()
|
|
58
|
+
], MembershipRole);
|
|
59
|
+
exports.MembershipRole = MembershipRole;
|
|
60
|
+
//# sourceMappingURL=member-role.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"member-role.entity.js","sourceRoot":"","sources":["../../../src/organisation/entities/member-role.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAE5C,qCAWiB;AACjB,qFAAwE;AAGjE,IAAM,cAAc,GAApB,MAAM,cAAc;CA+B1B,CAAA;AA9BG;IAAC,IAAA,gCAAsB,GAAE;IACxB,IAAA,qBAAW,GAAE;;0CACF;AAEZ;IAAC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uDAAsB,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE;QACvE,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,IAAI;KAChB,CAAC;IACD,IAAA,eAAK,GAAE;IACP,IAAA,oBAAU,GAAE;8BACA,uDAAsB;kDAAC;AAEpC;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAU,EAAC,CAAC,UAA0B,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;;oDACrC;AAE7B;IAAC,IAAA,gBAAM,GAAE;;4CACK;AAEd;IAAC,IAAA,0BAAgB,GAAE;IAClB,IAAA,qBAAW,GAAE;8BACA,IAAI;mDAAC;AAEnB;IAAC,IAAA,0BAAgB,GAAE;IAClB,IAAA,qBAAW,GAAE;8BACD,IAAI;kDAAC;AAElB;IAAC,IAAA,0BAAgB,GAAE;IAClB,IAAA,qBAAW,GAAE;8BACA,IAAI;mDAAC;AA9BV,cAAc;IAD1B,IAAA,gBAAM,GAAE;GACI,cAAc,CA+B1B;AA/BY,wCAAc"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Organisation } from "../../organisation/entities/organisation.entity";
|
|
2
|
+
import { Person } from "../../person/entities/person.entity";
|
|
3
|
+
import { MembershipRole } from "./member-role.entity";
|
|
4
|
+
export declare class OrganisationMembership {
|
|
5
|
+
id: number;
|
|
6
|
+
uuid: string;
|
|
7
|
+
person: Person;
|
|
8
|
+
personId: number;
|
|
9
|
+
organisation: Organisation;
|
|
10
|
+
organisationId: number;
|
|
11
|
+
roles: MembershipRole[];
|
|
12
|
+
createdDate: Date;
|
|
13
|
+
updateDate: Date;
|
|
14
|
+
deletedDate: Date;
|
|
15
|
+
nullChecks(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OrganisationMembership = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
15
|
+
const typeorm_1 = require("typeorm");
|
|
16
|
+
const organisation_entity_1 = require("../../organisation/entities/organisation.entity");
|
|
17
|
+
const person_entity_1 = require("../../person/entities/person.entity");
|
|
18
|
+
const member_role_entity_1 = require("./member-role.entity");
|
|
19
|
+
let OrganisationMembership = class OrganisationMembership {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
21
|
+
async nullChecks() {
|
|
22
|
+
if (!this.roles) {
|
|
23
|
+
this.roles = [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
29
|
+
(0, swagger_1.ApiProperty)(),
|
|
30
|
+
__metadata("design:type", Number)
|
|
31
|
+
], OrganisationMembership.prototype, "id", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.Column)("uuid", {
|
|
34
|
+
name: "uuid",
|
|
35
|
+
default: () => "uuid_generate_v4()",
|
|
36
|
+
}),
|
|
37
|
+
(0, typeorm_1.Generated)("uuid"),
|
|
38
|
+
(0, swagger_1.ApiProperty)(),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], OrganisationMembership.prototype, "uuid", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.ManyToOne)(() => person_entity_1.Person, (person) => person.memberships, {
|
|
43
|
+
eager: true,
|
|
44
|
+
cascade: ["insert", "update"],
|
|
45
|
+
}),
|
|
46
|
+
(0, class_transformer_1.Exclude)(),
|
|
47
|
+
(0, typeorm_1.JoinColumn)(),
|
|
48
|
+
__metadata("design:type", person_entity_1.Person)
|
|
49
|
+
], OrganisationMembership.prototype, "person", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.Column)(),
|
|
52
|
+
(0, typeorm_1.RelationId)((membership) => membership.person),
|
|
53
|
+
__metadata("design:type", Number)
|
|
54
|
+
], OrganisationMembership.prototype, "personId", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, typeorm_1.ManyToOne)(() => organisation_entity_1.Organisation, (org) => org.memberships, {
|
|
57
|
+
eager: true,
|
|
58
|
+
cascade: ["insert", "update"],
|
|
59
|
+
}),
|
|
60
|
+
(0, class_transformer_1.Exclude)(),
|
|
61
|
+
(0, typeorm_1.JoinColumn)(),
|
|
62
|
+
__metadata("design:type", organisation_entity_1.Organisation)
|
|
63
|
+
], OrganisationMembership.prototype, "organisation", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, typeorm_1.Column)(),
|
|
66
|
+
(0, typeorm_1.RelationId)((membership) => membership.organisation),
|
|
67
|
+
__metadata("design:type", Number)
|
|
68
|
+
], OrganisationMembership.prototype, "organisationId", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, typeorm_1.OneToMany)(() => member_role_entity_1.MembershipRole, (role) => role.membership, {
|
|
71
|
+
eager: true,
|
|
72
|
+
cascade: true,
|
|
73
|
+
}),
|
|
74
|
+
(0, typeorm_1.Index)(),
|
|
75
|
+
(0, typeorm_1.JoinColumn)(),
|
|
76
|
+
__metadata("design:type", Array)
|
|
77
|
+
], OrganisationMembership.prototype, "roles", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
80
|
+
(0, swagger_1.ApiProperty)(),
|
|
81
|
+
__metadata("design:type", Date)
|
|
82
|
+
], OrganisationMembership.prototype, "createdDate", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
85
|
+
(0, swagger_1.ApiProperty)(),
|
|
86
|
+
__metadata("design:type", Date)
|
|
87
|
+
], OrganisationMembership.prototype, "updateDate", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, typeorm_1.DeleteDateColumn)(),
|
|
90
|
+
(0, swagger_1.ApiProperty)(),
|
|
91
|
+
__metadata("design:type", Date)
|
|
92
|
+
], OrganisationMembership.prototype, "deletedDate", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, typeorm_1.AfterLoad)(),
|
|
95
|
+
(0, typeorm_1.AfterInsert)(),
|
|
96
|
+
(0, typeorm_1.AfterUpdate)(),
|
|
97
|
+
__metadata("design:type", Function),
|
|
98
|
+
__metadata("design:paramtypes", []),
|
|
99
|
+
__metadata("design:returntype", Promise)
|
|
100
|
+
], OrganisationMembership.prototype, "nullChecks", null);
|
|
101
|
+
OrganisationMembership = __decorate([
|
|
102
|
+
(0, typeorm_1.Entity)()
|
|
103
|
+
], OrganisationMembership);
|
|
104
|
+
exports.OrganisationMembership = OrganisationMembership;
|
|
105
|
+
//# sourceMappingURL=organisation-membership.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organisation-membership.entity.js","sourceRoot":"","sources":["../../../src/organisation/entities/organisation-membership.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAC5C,yDAA0C;AAC1C,qCAgBiB;AACjB,yFAA6E;AAC7E,uEAA2D;AAC3D,6DAAoD;AAG7C,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAyD/B,4DAA4D;IAItD,AAAN,KAAK,CAAC,UAAU;QACZ,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACb,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;SACnB;IACL,CAAC;CACJ,CAAA;AAjEG;IAAC,IAAA,gCAAsB,GAAE;IACxB,IAAA,qBAAW,GAAE;;kDACF;AAEZ;IAAC,IAAA,gBAAM,EAAC,MAAM,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAoB;KACtC,CAAC;IACD,IAAA,mBAAS,EAAC,MAAM,CAAC;IACjB,IAAA,qBAAW,GAAE;;oDACO;AAErB;IAAC,IAAA,m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AAMb;IAHL,IAAA,mBAAS,GAAE;IACX,IAAA,qBAAW,GAAE;IACb,IAAA,qBAAW,GAAE;;;;wDAKb;AAjEQ,sBAAsB;IADlC,IAAA,gBAAM,GAAE;GACI,sBAAsB,CAkElC;AAlEY,wDAAsB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Invitation } from "../../invitations/entities/invitation.entity";
|
|
2
|
+
import { OrganisationMembership } from "./organisation-membership.entity";
|
|
2
3
|
export declare class Organisation {
|
|
3
4
|
id: number;
|
|
4
5
|
uuid: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ownerId: number;
|
|
6
|
+
memberships: OrganisationMembership[];
|
|
7
|
+
invitations: Invitation[];
|
|
8
8
|
name: string;
|
|
9
9
|
createdDate: Date;
|
|
10
10
|
updateDate: Date;
|
|
@@ -11,14 +11,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Organisation = void 0;
|
|
13
13
|
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
-
const class_transformer_1 = require("class-transformer");
|
|
15
14
|
const typeorm_1 = require("typeorm");
|
|
16
|
-
const
|
|
15
|
+
const invitation_entity_1 = require("../../invitations/entities/invitation.entity");
|
|
16
|
+
const organisation_membership_entity_1 = require("./organisation-membership.entity");
|
|
17
17
|
let Organisation = class Organisation {
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
19
19
|
async nullChecks() {
|
|
20
|
-
if (!this.
|
|
21
|
-
this.
|
|
20
|
+
if (!this.memberships) {
|
|
21
|
+
this.memberships = [];
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
};
|
|
@@ -37,28 +37,21 @@ __decorate([
|
|
|
37
37
|
__metadata("design:type", String)
|
|
38
38
|
], Organisation.prototype, "uuid", void 0);
|
|
39
39
|
__decorate([
|
|
40
|
-
(0, typeorm_1.
|
|
40
|
+
(0, typeorm_1.OneToMany)(() => organisation_membership_entity_1.OrganisationMembership, (om) => om.organisation, {
|
|
41
41
|
eager: true,
|
|
42
|
-
|
|
42
|
+
cascade: ["insert", "update"],
|
|
43
43
|
}),
|
|
44
|
-
(0,
|
|
45
|
-
(0, typeorm_1.JoinTable)(),
|
|
44
|
+
(0, typeorm_1.Index)(),
|
|
46
45
|
__metadata("design:type", Array)
|
|
47
|
-
], Organisation.prototype, "
|
|
46
|
+
], Organisation.prototype, "memberships", void 0);
|
|
48
47
|
__decorate([
|
|
49
|
-
(0, typeorm_1.
|
|
48
|
+
(0, typeorm_1.OneToMany)(() => invitation_entity_1.Invitation, (om) => om.organisation, {
|
|
50
49
|
eager: true,
|
|
51
|
-
|
|
50
|
+
cascade: ["insert", "update"],
|
|
52
51
|
}),
|
|
53
52
|
(0, typeorm_1.Index)(),
|
|
54
|
-
(
|
|
55
|
-
|
|
56
|
-
], Organisation.prototype, "owner", void 0);
|
|
57
|
-
__decorate([
|
|
58
|
-
(0, typeorm_1.RelationId)((organisation) => organisation.owner),
|
|
59
|
-
(0, swagger_1.ApiProperty)(),
|
|
60
|
-
__metadata("design:type", Number)
|
|
61
|
-
], Organisation.prototype, "ownerId", void 0);
|
|
53
|
+
__metadata("design:type", Array)
|
|
54
|
+
], Organisation.prototype, "invitations", void 0);
|
|
62
55
|
__decorate([
|
|
63
56
|
(0, typeorm_1.Column)(),
|
|
64
57
|
(0, swagger_1.ApiProperty)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation.entity.js","sourceRoot":"","sources":["../../../src/organisation/entities/organisation.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;
|
|
1
|
+
{"version":3,"file":"organisation.entity.js","sourceRoot":"","sources":["../../../src/organisation/entities/organisation.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAE5C,qCAaiB;AACjB,oFAAwE;AACxE,qFAAwE;AAGjE,IAAM,YAAY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,GAAE;IACX,IAAA,qBAAW,GAAE;IACb,IAAA,qBAAW,GAAE;;;;8CAKb;AAnDQ,YAAY;IADxB,IAAA,gBAAM,GAAE;GACI,YAAY,CAoDxB;AApDY,oCAAY"}
|
|
@@ -16,38 +16,94 @@ exports.OrganisationService = void 0;
|
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
18
|
const typeorm_2 = require("typeorm");
|
|
19
|
+
const RolesEnum_1 = require("./dto/RolesEnum");
|
|
20
|
+
const member_role_entity_1 = require("./entities/member-role.entity");
|
|
21
|
+
const organisation_membership_entity_1 = require("./entities/organisation-membership.entity");
|
|
19
22
|
const organisation_entity_1 = require("./entities/organisation.entity");
|
|
20
23
|
let OrganisationService = class OrganisationService {
|
|
21
24
|
constructor(repository) {
|
|
22
25
|
this.repository = repository;
|
|
23
26
|
}
|
|
24
27
|
async create(createOrganisationDto) {
|
|
25
|
-
|
|
28
|
+
// create a new organisation
|
|
29
|
+
const unsavedOrganisation = new organisation_entity_1.Organisation();
|
|
30
|
+
unsavedOrganisation.name = createOrganisationDto.name;
|
|
31
|
+
unsavedOrganisation.memberships = [];
|
|
32
|
+
// add the owner
|
|
33
|
+
const ownerMembership = new organisation_membership_entity_1.OrganisationMembership();
|
|
34
|
+
ownerMembership.person = createOrganisationDto.owner;
|
|
35
|
+
const ownerRole = new member_role_entity_1.MembershipRole();
|
|
36
|
+
ownerRole.name = RolesEnum_1.Roles.owner;
|
|
37
|
+
ownerMembership.roles.push(ownerRole);
|
|
38
|
+
unsavedOrganisation.memberships.push(ownerMembership);
|
|
39
|
+
// add all the others
|
|
40
|
+
const normalMemberships = createOrganisationDto.members.map((member) => {
|
|
41
|
+
const membership = new organisation_membership_entity_1.OrganisationMembership();
|
|
42
|
+
membership.person = member;
|
|
43
|
+
const memberRole = new member_role_entity_1.MembershipRole();
|
|
44
|
+
memberRole.name = RolesEnum_1.Roles.member;
|
|
45
|
+
membership.roles.push(memberRole);
|
|
46
|
+
return membership;
|
|
47
|
+
});
|
|
48
|
+
unsavedOrganisation.memberships.push(...normalMemberships);
|
|
49
|
+
return this.repository.save(unsavedOrganisation);
|
|
26
50
|
}
|
|
27
51
|
async findAllForUser(currentUserId) {
|
|
28
|
-
return this.repository
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
return this.repository.find({
|
|
53
|
+
where: {
|
|
54
|
+
memberships: {
|
|
55
|
+
person: {
|
|
56
|
+
id: currentUserId,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
});
|
|
34
61
|
}
|
|
35
62
|
async findOne(uuid, currentUserId) {
|
|
36
|
-
return this.repository
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
63
|
+
return this.repository.findOneOrFail({
|
|
64
|
+
where: {
|
|
65
|
+
uuid,
|
|
66
|
+
memberships: {
|
|
67
|
+
person: {
|
|
68
|
+
id: currentUserId,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
});
|
|
43
73
|
}
|
|
44
74
|
async update(uuid, updateOrganisationDto, currentUserId) {
|
|
45
|
-
|
|
75
|
+
const ownerOfOrg = await this.repository.findOneOrFail({
|
|
76
|
+
where: {
|
|
77
|
+
uuid,
|
|
78
|
+
memberships: {
|
|
79
|
+
person: {
|
|
80
|
+
id: currentUserId,
|
|
81
|
+
},
|
|
82
|
+
roles: {
|
|
83
|
+
name: RolesEnum_1.Roles.owner,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
this.repository.merge(ownerOfOrg, updateOrganisationDto);
|
|
89
|
+
return this.repository.update(ownerOfOrg.id, ownerOfOrg);
|
|
46
90
|
}
|
|
47
91
|
async remove(uuid, currentUserId) {
|
|
92
|
+
const ownerOfOrg = await this.repository.findOneOrFail({
|
|
93
|
+
where: {
|
|
94
|
+
uuid,
|
|
95
|
+
memberships: {
|
|
96
|
+
person: {
|
|
97
|
+
id: currentUserId,
|
|
98
|
+
},
|
|
99
|
+
roles: {
|
|
100
|
+
name: RolesEnum_1.Roles.owner,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
});
|
|
48
105
|
return this.repository.delete({
|
|
49
|
-
|
|
50
|
-
ownerId: currentUserId,
|
|
106
|
+
id: ownerOfOrg.id,
|
|
51
107
|
});
|
|
52
108
|
}
|
|
53
109
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation.service.js","sourceRoot":"","sources":["../../src/organisation/organisation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0C;AAC1C,6CAAiD;AACjD,qCAA+D;
|
|
1
|
+
{"version":3,"file":"organisation.service.js","sourceRoot":"","sources":["../../src/organisation/organisation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0C;AAC1C,6CAAiD;AACjD,qCAA+D;AAE/D,+CAAsC;AAEtC,sEAA6D;AAC7D,8FAAiF;AACjF,wEAA4D;AAGrD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC5B,YAEY,UAAoC;QAApC,eAAU,GAAV,UAAU,CAA0B;IAC7C,CAAC;IAEJ,KAAK,CAAC,MAAM,CACR,qBAA4C;QAE5C,4BAA4B;QAC5B,MAAM,mBAAmB,GAAG,IAAI,kCAAY,EAAE,CAAC;QAC/C,mBAAmB,CAAC,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC;QACtD,mBAAmB,CAAC,WAAW,GAAG,EAAE,CAAC;QAErC,gBAAgB;QAChB,MAAM,eAAe,GAAG,IAAI,uDAAsB,EAAE,CAAC;QACrD,eAAe,CAAC,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC;QACrD,MAAM,SAAS,GAAG,IAAI,mCAAc,EAAE,CAAC;QACvC,SAAS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,EAC5C,aAAqB;QAErB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;YACnD,KAAK,EAAE;gBACH,IAAI;gBACJ,WAAW,EAAE;oBACT,MAAM,EAAE;wBACJ,EAAE,EAAE,aAAa;qBACpB;oBACD,KAAK,EAAE;wBACH,IAAI,EAAE,iBAAK,CAAC,KAAK;qBACpB;iBACJ;aACJ;SACJ,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,EAAE,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,MAAM,EAAE;wBACJ,EAAE,EAAE,aAAa;qBACpB;oBACD,KAAK,EAAE;wBACH,IAAI,EAAE,iBAAK,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;AA1GY,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,0BAAgB,EAAC,kCAAY,CAAC,CAAA;qCACX,oBAAU;GAHzB,mBAAmB,CA0G/B;AA1GY,kDAAmB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OrganisationMembership } from "../../organisation/entities/organisation-membership.entity";
|
|
2
2
|
export declare class Person {
|
|
3
3
|
id: number;
|
|
4
4
|
email: string;
|
|
@@ -11,8 +11,7 @@ export declare class Person {
|
|
|
11
11
|
picture: string;
|
|
12
12
|
auth0UserId: string;
|
|
13
13
|
username?: string;
|
|
14
|
-
|
|
15
|
-
ownerOfOrganisations: Organisation[];
|
|
14
|
+
memberships: OrganisationMembership[];
|
|
16
15
|
createdDate: Date;
|
|
17
16
|
updateDate: Date;
|
|
18
17
|
deletedDate: Date;
|
|
@@ -13,15 +13,12 @@ exports.Person = void 0;
|
|
|
13
13
|
const swagger_1 = require("@nestjs/swagger");
|
|
14
14
|
const class_transformer_1 = require("class-transformer");
|
|
15
15
|
const typeorm_1 = require("typeorm");
|
|
16
|
-
const
|
|
16
|
+
const organisation_membership_entity_1 = require("../../organisation/entities/organisation-membership.entity");
|
|
17
17
|
let Person = class Person {
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
19
19
|
async nullChecks() {
|
|
20
|
-
if (!this.
|
|
21
|
-
this.
|
|
22
|
-
}
|
|
23
|
-
if (!this.ownerOfOrganisations) {
|
|
24
|
-
this.ownerOfOrganisations = [];
|
|
20
|
+
if (!this.memberships) {
|
|
21
|
+
this.memberships = [];
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
24
|
};
|
|
@@ -87,19 +84,11 @@ __decorate([
|
|
|
87
84
|
], Person.prototype, "username", void 0);
|
|
88
85
|
__decorate([
|
|
89
86
|
(0, class_transformer_1.Exclude)(),
|
|
90
|
-
(0, typeorm_1.
|
|
91
|
-
cascade:
|
|
92
|
-
onDelete: "CASCADE",
|
|
93
|
-
}),
|
|
94
|
-
__metadata("design:type", Array)
|
|
95
|
-
], Person.prototype, "memberOfOrganisations", void 0);
|
|
96
|
-
__decorate([
|
|
97
|
-
(0, class_transformer_1.Exclude)(),
|
|
98
|
-
(0, typeorm_1.OneToMany)(() => organisation_entity_1.Organisation, (org) => org.owner, {
|
|
99
|
-
cascade: true,
|
|
87
|
+
(0, typeorm_1.OneToMany)(() => organisation_membership_entity_1.OrganisationMembership, (om) => om.person, {
|
|
88
|
+
cascade: ["insert", "update"],
|
|
100
89
|
}),
|
|
101
90
|
__metadata("design:type", Array)
|
|
102
|
-
], Person.prototype, "
|
|
91
|
+
], Person.prototype, "memberships", void 0);
|
|
103
92
|
__decorate([
|
|
104
93
|
(0, typeorm_1.CreateDateColumn)(),
|
|
105
94
|
(0, swagger_1.ApiProperty)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"person.entity.js","sourceRoot":"","sources":["../../../src/person/entities/person.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAiE;AACjE,yDAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"person.entity.js","sourceRoot":"","sources":["../../../src/person/entities/person.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAiE;AACjE,yDAA0C;AAC1C,qCAaiB;AACjB,+GAAkG;AAG3F,IAAM,MAAM,GAAZ,MAAM,MAAM;IAoEf,4DAA4D;IAItD,AAAN,KAAK,CAAC,UAAU;QACZ,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;SACzB;IACL,CAAC;CACJ,CAAA;AA5EG;IAAC,IAAA,gCAAsB,GAAE;IACxB,IAAA,qBAAW,GAAE;;kCACF;AAEZ;IAAC,IAAA,qBAAW,GAAE;IACb,IAAA,gBAAM,GAAE;;qCACM;AAEf;IAAC,IAAA,gBAAM,EAAC,MAAM,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAoB;KACtC,CAAC;IACD,IAAA,mBAAS,EAAC,MAAM,CAAC;IACjB,IAAA,qBAAW,GAAE;;oCACO;AAErB;IAAC,IAAA,qBAAW,GAAE;IACb,IAAA,gBAAM,EAAC,EAAC,OAAO,EAAE,KAAK,EAAC,CAAC;;6CACD;AAExB;IAAC,IAAA,qBAAW,GAAE;IACb,IAAA,gBAAM,EAAC,EAAC,OAAO,EAAE,KAAK,EAAC,CAAC;;uCACP;AAElB;IAAC,IAA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