@darraghor/nest-backend-libs 2.17.14 → 2.17.16
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/organisation/entities/member-role.entity.js +3 -0
- package/dist/organisation/entities/member-role.entity.js.map +1 -1
- package/dist/organisation/organisation.service.d.ts +1 -0
- package/dist/organisation/organisation.service.js +6 -1
- package/dist/organisation/organisation.service.js.map +1 -1
- package/dist/organisation-memberships/entities/organisation-membership.entity.js +3 -1
- package/dist/organisation-memberships/entities/organisation-membership.entity.js.map +1 -1
- package/dist/organisation-memberships/organisation-memberships.service.d.ts +1 -0
- package/dist/organisation-memberships/organisation-memberships.service.js +10 -3
- package/dist/organisation-memberships/organisation-memberships.service.js.map +1 -1
- package/dist/organisation-subscriptions/entities/organisation-subscription.entity.js +1 -0
- package/dist/organisation-subscriptions/entities/organisation-subscription.entity.js.map +1 -1
- package/dist/organisation-subscriptions/organisation-subscriptions.service.d.ts +1 -0
- package/dist/organisation-subscriptions/organisation-subscriptions.service.js +17 -4
- package/dist/organisation-subscriptions/organisation-subscriptions.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ const typeorm_1 = require("typeorm");
|
|
|
15
15
|
const organisation_membership_entity_1 = require("../../organisation-memberships/entities/organisation-membership.entity");
|
|
16
16
|
let MembershipRole = class MembershipRole {
|
|
17
17
|
id;
|
|
18
|
+
// we don't expose this because the roles are exposed on the membership
|
|
18
19
|
membership;
|
|
19
20
|
membershipId;
|
|
20
21
|
name;
|
|
@@ -32,11 +33,13 @@ __decorate([
|
|
|
32
33
|
__metadata("design:type", organisation_membership_entity_1.OrganisationMembership)
|
|
33
34
|
], MembershipRole.prototype, "membership", void 0);
|
|
34
35
|
__decorate([
|
|
36
|
+
(0, swagger_1.ApiProperty)(),
|
|
35
37
|
(0, typeorm_1.Column)(),
|
|
36
38
|
(0, typeorm_1.RelationId)((mr) => mr.membership),
|
|
37
39
|
__metadata("design:type", Number)
|
|
38
40
|
], MembershipRole.prototype, "membershipId", void 0);
|
|
39
41
|
__decorate([
|
|
42
|
+
(0, swagger_1.ApiProperty)(),
|
|
40
43
|
(0, typeorm_1.Column)(),
|
|
41
44
|
__metadata("design:type", String)
|
|
42
45
|
], MembershipRole.prototype, "name", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"member-role.entity.js","sourceRoot":"","sources":["../../../src/organisation/entities/member-role.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAE5C,qCASiB;AACjB,2HAA8G;AAGvG,IAAM,cAAc,GAApB,MAAM,cAAc;IAGvB,EAAE,CAAU;
|
|
1
|
+
{"version":3,"file":"member-role.entity.js","sourceRoot":"","sources":["../../../src/organisation/entities/member-role.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAE5C,qCASiB;AACjB,2HAA8G;AAGvG,IAAM,cAAc,GAApB,MAAM,cAAc;IAGvB,EAAE,CAAU;IAEZ,uEAAuE;IAEvE,UAAU,CAA0B;IAK7B,YAAY,CAAU;IAI7B,IAAI,CAAU;IAId,WAAW,CAAQ;IAInB,UAAU,CAAQ;IAIlB,WAAW,CAAQ;CACtB,CAAA;AA5BG;IAAC,IAAA,gCAAsB,GAAE;IACxB,IAAA,qBAAW,GAAE;;0CACF;AAGZ;IAAC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uDAAsB,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;8BAC7D,uDAAsB;kDAAC;AAEpC;IAAC,IAAA,qBAAW,GAAE;IACb,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAU,EAAC,CAAC,EAAkB,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC;;oDACrB;AAE7B;IAAC,IAAA,qBAAW,GAAE;IACb,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;AA5BV,cAAc;IAD1B,IAAA,gBAAM,GAAE;GACI,cAAc,CA6B1B;AA7BY,wCAAc"}
|
|
@@ -5,6 +5,7 @@ import { Organisation } from "./entities/organisation.entity";
|
|
|
5
5
|
export declare class OrganisationService {
|
|
6
6
|
private repository;
|
|
7
7
|
constructor(repository: Repository<Organisation>);
|
|
8
|
+
private notFoundMessage;
|
|
8
9
|
create(createOrganisationDto: CreateOrganisationDto): Promise<Organisation>;
|
|
9
10
|
findAllForUser(currentUserId: number): Promise<Organisation[]>;
|
|
10
11
|
findOne(uuid: string, currentUserId: number): Promise<Organisation>;
|
|
@@ -25,6 +25,7 @@ let OrganisationService = class OrganisationService {
|
|
|
25
25
|
constructor(repository) {
|
|
26
26
|
this.repository = repository;
|
|
27
27
|
}
|
|
28
|
+
notFoundMessage = "Organisation not found or you are not owner of it";
|
|
28
29
|
async create(createOrganisationDto) {
|
|
29
30
|
// create a new organisation
|
|
30
31
|
const unsavedOrganisation = new organisation_entity_1.Organisation();
|
|
@@ -61,7 +62,7 @@ let OrganisationService = class OrganisationService {
|
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
64
|
async findOne(uuid, currentUserId) {
|
|
64
|
-
|
|
65
|
+
const org = await this.repository.findOne({
|
|
65
66
|
where: {
|
|
66
67
|
uuid,
|
|
67
68
|
memberships: {
|
|
@@ -71,6 +72,10 @@ let OrganisationService = class OrganisationService {
|
|
|
71
72
|
},
|
|
72
73
|
},
|
|
73
74
|
});
|
|
75
|
+
if (!org) {
|
|
76
|
+
throw new common_1.NotFoundException(this.notFoundMessage);
|
|
77
|
+
}
|
|
78
|
+
return org;
|
|
74
79
|
}
|
|
75
80
|
async update(uuid, updateOrganisationDto, currentUserId) {
|
|
76
81
|
const ownerOfOrg = await this.repository.findOneOrFail({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation.service.js","sourceRoot":"","sources":["../../src/organisation/organisation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"organisation.service.js","sourceRoot":"","sources":["../../src/organisation/organisation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA6D;AAC7D,6CAAiD;AACjD,qCAA+D;AAC/D,wHAA2G;AAE3G,+CAAsC;AAEtC,sEAA6D;AAC7D,wEAA4D;AAGrD,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,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,CAAC,IAAI,GAAG,iBAAK,CAAC,KAAK,CAAC;QAC7B,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEtC,mBAAmB,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAEtD,qBAAqB;QACrB,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,OAAO,CAAC,GAAG,CACvD,CAAC,MAAM,EAAE,EAAE;YACP,MAAM,UAAU,GAAG,IA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,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;AAjHY,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,0BAAgB,EAAC,kCAAY,CAAC,CAAA;qCACX,oBAAU;GAHzB,mBAAmB,CAiH/B;AAjHY,kDAAmB"}
|
|
@@ -22,7 +22,6 @@ let OrganisationMembership = class OrganisationMembership {
|
|
|
22
22
|
personId;
|
|
23
23
|
organisation;
|
|
24
24
|
organisationId;
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
26
25
|
roles;
|
|
27
26
|
createdDate;
|
|
28
27
|
updateDate;
|
|
@@ -74,6 +73,9 @@ __decorate([
|
|
|
74
73
|
__metadata("design:type", Number)
|
|
75
74
|
], OrganisationMembership.prototype, "organisationId", void 0);
|
|
76
75
|
__decorate([
|
|
76
|
+
(0, swagger_1.ApiProperty)({ type: () => member_role_entity_1.MembershipRole, isArray: true })
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
78
|
+
,
|
|
77
79
|
(0, typeorm_1.OneToMany)(() => member_role_entity_1.MembershipRole, (role) => role.membership, {
|
|
78
80
|
eager: true,
|
|
79
81
|
cascade: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation-membership.entity.js","sourceRoot":"","sources":["../../../src/organisation-memberships/entities/organisation-membership.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAE5C,qCAeiB;AACjB,uFAA8E;AAC9E,yFAA6E;AAC7E,uEAA2D;AAGpD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAG/B,EAAE,CAAU;IASL,IAAI,CAAU;IAMrB,MAAM,CAAU;IAIT,QAAQ,CAAU;IAMzB,YAAY,CAAgB;IAIrB,cAAc,CAAU;
|
|
1
|
+
{"version":3,"file":"organisation-membership.entity.js","sourceRoot":"","sources":["../../../src/organisation-memberships/entities/organisation-membership.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAE5C,qCAeiB;AACjB,uFAA8E;AAC9E,yFAA6E;AAC7E,uEAA2D;AAGpD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAG/B,EAAE,CAAU;IASL,IAAI,CAAU;IAMrB,MAAM,CAAU;IAIT,QAAQ,CAAU;IAMzB,YAAY,CAAgB;IAIrB,cAAc,CAAU;IAQ/B,KAAK,CAAoB;IAIzB,WAAW,CAAQ;IAInB,UAAU,CAAQ;IAIlB,WAAW,CAAQ;IAEnB,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;AA9DG;IAAC,IAAA,gCAAsB,GAAE;IACxB,IAAA,qBAAW,GAAE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C,IAAA,0BAAgB,GAAE;IAClB,IAAA,qBAAW,GAAE;8BACA,IAAI;2DAAC;AAEnB;IAAC,IAAA,0BAAgB,GAAE;IAClB,IAAA,qBAAW,GAAE;8BACD,IAAI;0DAAC;AAElB;IAAC,IAAA,0BAAgB,GAAE;IAClB,IAAA,qBAAW,GAAE;8BACA,IAAI;2DAAC;AAMb;IAHL,IAAA,mBAAS,GAAE;IACX,IAAA,qBAAW,GAAE;IACb,IAAA,qBAAW,GAAE;;;;wDAKb;AA9DQ,sBAAsB;IADlC,IAAA,gBAAM,GAAE;GACI,sBAAsB,CA+DlC;AA/DY,wDAAsB"}
|
|
@@ -6,6 +6,7 @@ export declare class OrganisationMembershipsService {
|
|
|
6
6
|
private orgRepo;
|
|
7
7
|
private membershipRepo;
|
|
8
8
|
constructor(orgRepo: Repository<Organisation>, membershipRepo: Repository<OrganisationMembership>);
|
|
9
|
+
private notFoundMessage;
|
|
9
10
|
findAllForOrgUser(orgUuid: string, currentUserId: number): Promise<OrganisationMembership[]>;
|
|
10
11
|
createOrUpdate(orgUuid: string, createOmDto: CreateUpdateMembershipDto, currentUserId: number): Promise<Organisation>;
|
|
11
12
|
private currentUserIsOwnerGuard;
|
|
@@ -27,6 +27,7 @@ let OrganisationMembershipsService = class OrganisationMembershipsService {
|
|
|
27
27
|
this.orgRepo = orgRepo;
|
|
28
28
|
this.membershipRepo = membershipRepo;
|
|
29
29
|
}
|
|
30
|
+
notFoundMessage = "Organisation not found or you are not owner of it";
|
|
30
31
|
async findAllForOrgUser(orgUuid, currentUserId) {
|
|
31
32
|
// no paging here ... yet!
|
|
32
33
|
const memberships = await this.membershipRepo.find({
|
|
@@ -45,7 +46,7 @@ let OrganisationMembershipsService = class OrganisationMembershipsService {
|
|
|
45
46
|
}
|
|
46
47
|
async createOrUpdate(orgUuid, createOmDto, currentUserId) {
|
|
47
48
|
// find the org
|
|
48
|
-
const org = await this.orgRepo.
|
|
49
|
+
const org = await this.orgRepo.findOne({
|
|
49
50
|
where: {
|
|
50
51
|
uuid: orgUuid,
|
|
51
52
|
},
|
|
@@ -55,6 +56,9 @@ let OrganisationMembershipsService = class OrganisationMembershipsService {
|
|
|
55
56
|
},
|
|
56
57
|
},
|
|
57
58
|
});
|
|
59
|
+
if (!org) {
|
|
60
|
+
throw new common_1.NotFoundException(this.notFoundMessage);
|
|
61
|
+
}
|
|
58
62
|
// check if the user is allowed to work with memberships
|
|
59
63
|
this.currentUserIsOwnerGuard(org, currentUserId);
|
|
60
64
|
// existing membership for this person?
|
|
@@ -89,12 +93,12 @@ let OrganisationMembershipsService = class OrganisationMembershipsService {
|
|
|
89
93
|
const membership = org.memberships.find((m) => m.person.id === currentUserId &&
|
|
90
94
|
m.roles.some((r) => r.name === RolesEnum_1.Roles.owner));
|
|
91
95
|
if (!membership) {
|
|
92
|
-
throw new
|
|
96
|
+
throw new common_1.NotFoundException("You are not allowed to add a member to this organisation");
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
async remove(orgUuid, membershipUuid, currentUserId) {
|
|
96
100
|
// find the org
|
|
97
|
-
const org = await this.orgRepo.
|
|
101
|
+
const org = await this.orgRepo.findOne({
|
|
98
102
|
where: {
|
|
99
103
|
uuid: orgUuid,
|
|
100
104
|
},
|
|
@@ -104,6 +108,9 @@ let OrganisationMembershipsService = class OrganisationMembershipsService {
|
|
|
104
108
|
},
|
|
105
109
|
},
|
|
106
110
|
});
|
|
111
|
+
if (!org) {
|
|
112
|
+
throw new common_1.NotFoundException(this.notFoundMessage);
|
|
113
|
+
}
|
|
107
114
|
// check if the user is allowed to work with memberships
|
|
108
115
|
this.currentUserIsOwnerGuard(org, currentUserId);
|
|
109
116
|
// remove the membership
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation-memberships.service.js","sourceRoot":"","sources":["../../src/organisation-memberships/organisation-memberships.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"organisation-memberships.service.js","sourceRoot":"","sources":["../../src/organisation-memberships/organisation-memberships.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA6D;AAC7D,6CAAiD;AACjD,qCAAiD;AACjD,6DAAoD;AACpD,oFAA2E;AAC3E,sFAA0E;AAE1E,8FAAiF;AAG1E,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAG3B;IAEA;IAJZ,YAEY,OAAiC,EAEjC,cAAkD;QAFlD,YAAO,GAAP,OAAO,CAA0B;QAEjC,mBAAc,GAAd,cAAc,CAAoC;IAC3D,CAAC;IACI,eAAe,GACnB,mDAAmD,CAAC;IACxD,KAAK,CAAC,iBAAiB,CACnB,OAAe,EACf,aAAqB;QAErB,0BAA0B;QAC1B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;YAC/C,KAAK,EAAE;gBACH,YAAY,EAAE;oBACV,IAAI,EAAE,OAAO;iBAChB;aACJ;SACJ,CAAC,CAAC;QAEH,8CAA8C;QAC9C,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAC9B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,aAAa,CACvC,CAAC;QAEF,IAAI,CAAC,SAAS,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;SAChE;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;IACD,KAAK,CAAC,cAAc,CAChB,OAAe,EACf,WAAsC,EACtC,aAAqB;QAErB,eAAe;QACf,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;YACnC,KAAK,EAAE;gBACH,IAAI,EAAE,OAAO;aAChB;YACD,SAAS,EAAE;gBACP,WAAW,EAAE;oBACT,KAAK,EAAE,IAAI;iBACd;aACJ;SACJ,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,EAAE;YACN,MAAM,IAAI,0BAAiB,CAAC,IAAI,CAAC,eAAe,CAA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SAC3C;QACD,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;CACJ,CAAA;AArIY,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,0BAAgB,EAAC,kCAAY,CAAC,CAAA;IAE9B,WAAA,IAAA,0BAAgB,EAAC,uDAAsB,CAAC,CAAA;qCADxB,oBAAU;QAEH,oBAAU;GAL7B,8BAA8B,CAqI1C;AArIY,wEAA8B"}
|
|
@@ -66,6 +66,7 @@ __decorate([
|
|
|
66
66
|
__metadata("design:type", organisation_entity_1.Organisation)
|
|
67
67
|
], OrganisationSubscriptionRecord.prototype, "organisation", void 0);
|
|
68
68
|
__decorate([
|
|
69
|
+
(0, swagger_1.ApiProperty)(),
|
|
69
70
|
(0, typeorm_1.Column)(),
|
|
70
71
|
(0, typeorm_1.RelationId)((sub) => sub.organisation),
|
|
71
72
|
__metadata("design:type", Number)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation-subscription.entity.js","sourceRoot":"","sources":["../../../src/organisation-subscriptions/entities/organisation-subscription.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAC5C,yDAAuC;AAEvC,qCASiB;AACjB,yFAA6E;AAGtE,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAGvC,EAAE,CAAU;IASL,IAAI,CAAU;IAIrB,oBAAoB,CAAU;IAI9B,gBAAgB,CAAU;IAI1B,aAAa,CAAU;IAKvB,UAAU,CAAQ;IAGlB,YAAY,CAAgB;
|
|
1
|
+
{"version":3,"file":"organisation-subscription.entity.js","sourceRoot":"","sources":["../../../src/organisation-subscriptions/entities/organisation-subscription.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAC5C,yDAAuC;AAEvC,qCASiB;AACjB,yFAA6E;AAGtE,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAGvC,EAA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wEAA8B"}
|
|
@@ -6,6 +6,7 @@ export declare class OrganisationSubscriptionService {
|
|
|
6
6
|
private orgRepo;
|
|
7
7
|
private orgSubRepository;
|
|
8
8
|
constructor(orgRepo: Repository<Organisation>, orgSubRepository: Repository<OrganisationSubscriptionRecord>);
|
|
9
|
+
private notFoundMessage;
|
|
9
10
|
findAllForOwnerOfOrg(orgUuid: string, currentUserId: number): Promise<OrganisationSubscriptionRecord[]>;
|
|
10
11
|
create(subRecord: SaveOrganisationSubscriptionRecordDto, orgUuid: string): Promise<OrganisationSubscriptionRecord>;
|
|
11
12
|
update(subUuid: string, subRecord: SaveOrganisationSubscriptionRecordDto, orgUuid: string): Promise<OrganisationSubscriptionRecord>;
|
|
@@ -26,9 +26,10 @@ let OrganisationSubscriptionService = class OrganisationSubscriptionService {
|
|
|
26
26
|
this.orgRepo = orgRepo;
|
|
27
27
|
this.orgSubRepository = orgSubRepository;
|
|
28
28
|
}
|
|
29
|
+
notFoundMessage = "Organisation not found or you are not owner of it";
|
|
29
30
|
async findAllForOwnerOfOrg(orgUuid, currentUserId) {
|
|
30
31
|
// find the org if the user is owner
|
|
31
|
-
const org = await this.orgRepo.
|
|
32
|
+
const org = await this.orgRepo.findOne({
|
|
32
33
|
where: {
|
|
33
34
|
uuid: orgUuid,
|
|
34
35
|
memberships: {
|
|
@@ -42,15 +43,21 @@ let OrganisationSubscriptionService = class OrganisationSubscriptionService {
|
|
|
42
43
|
subscriptionRecords: true,
|
|
43
44
|
},
|
|
44
45
|
});
|
|
46
|
+
if (!org) {
|
|
47
|
+
throw new common_1.NotFoundException(this.notFoundMessage);
|
|
48
|
+
}
|
|
45
49
|
return org.subscriptionRecords;
|
|
46
50
|
}
|
|
47
51
|
async create(subRecord, orgUuid) {
|
|
48
52
|
// find the org
|
|
49
|
-
const org = await this.orgRepo.
|
|
53
|
+
const org = await this.orgRepo.findOne({
|
|
50
54
|
where: {
|
|
51
55
|
uuid: orgUuid,
|
|
52
56
|
},
|
|
53
57
|
});
|
|
58
|
+
if (!org) {
|
|
59
|
+
throw new common_1.NotFoundException(this.notFoundMessage);
|
|
60
|
+
}
|
|
54
61
|
const sub = this.orgSubRepository.create();
|
|
55
62
|
sub.organisationId = org.id;
|
|
56
63
|
sub.stripeCustomerId = subRecord.stripeCustomerId;
|
|
@@ -60,16 +67,22 @@ let OrganisationSubscriptionService = class OrganisationSubscriptionService {
|
|
|
60
67
|
return this.orgSubRepository.save(sub);
|
|
61
68
|
}
|
|
62
69
|
async update(subUuid, subRecord, orgUuid) {
|
|
63
|
-
const org = await this.orgRepo.
|
|
70
|
+
const org = await this.orgRepo.findOne({
|
|
64
71
|
where: {
|
|
65
72
|
uuid: orgUuid,
|
|
66
73
|
},
|
|
67
74
|
});
|
|
68
|
-
|
|
75
|
+
if (!org) {
|
|
76
|
+
throw new common_1.NotFoundException(this.notFoundMessage);
|
|
77
|
+
}
|
|
78
|
+
const sub = await this.orgSubRepository.findOne({
|
|
69
79
|
where: {
|
|
70
80
|
uuid: subUuid,
|
|
71
81
|
},
|
|
72
82
|
});
|
|
83
|
+
if (!sub) {
|
|
84
|
+
throw new common_1.NotFoundException(this.notFoundMessage);
|
|
85
|
+
}
|
|
73
86
|
sub.organisationId = org.id;
|
|
74
87
|
sub.stripeCustomerId = subRecord.stripeCustomerId;
|
|
75
88
|
sub.stripePriceId = subRecord.stripePriceId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation-subscriptions.service.js","sourceRoot":"","sources":["../../src/organisation-subscriptions/organisation-subscriptions.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"organisation-subscriptions.service.js","sourceRoot":"","sources":["../../src/organisation-subscriptions/organisation-subscriptions.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA6D;AAC7D,6CAAiD;AACjD,qCAAmC;AACnC,6DAAoD;AACpD,sFAA0E;AAC1E,kGAA2F;AAIpF,IAAM,+BAA+B,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M,CAAC,QAAQ,KAAK,SAAS;YAC7B,MAAM,CAAC,QAAQ,KAAK,IAAI;YACxB,MAAM,CAAC,QAAQ,GAAG,CAAC,CACtB,CAAC;IACN,CAAC;CACJ,CAAA;AApGY,+BAA+B;IAD3C,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,0BAAgB,EAAC,kCAAY,CAAC,CAAA;IAE9B,WAAA,IAAA,0BAAgB,EAAC,iEAA8B,CAAC,CAAA;qCADhC,oBAAU;QAED,oBAAU;GAL/B,+BAA+B,CAoG3C;AApGY,0EAA+B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darraghor/nest-backend-libs",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.16",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"description": "Some helpers for personal projects in nestjs",
|
|
6
6
|
"homepage": "https://github.com/darraghoriordan/nest-backend-libs",
|