@venturialstd/organization 0.0.11 → 0.0.12
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/constants/organization.constant.d.ts +32 -0
- package/dist/constants/organization.constant.d.ts.map +1 -1
- package/dist/constants/organization.constant.js +39 -1
- package/dist/constants/organization.constant.js.map +1 -1
- package/dist/dtos/CreateOrganization.dto.d.ts +16 -0
- package/dist/dtos/CreateOrganization.dto.d.ts.map +1 -0
- package/dist/dtos/CreateOrganization.dto.js +105 -0
- package/dist/dtos/CreateOrganization.dto.js.map +1 -0
- package/dist/entities/organization-user.entity.d.ts +3 -1
- package/dist/entities/organization-user.entity.d.ts.map +1 -1
- package/dist/entities/organization-user.entity.js +23 -16
- package/dist/entities/organization-user.entity.js.map +1 -1
- package/dist/entities/organization.entity.d.ts +8 -0
- package/dist/entities/organization.entity.d.ts.map +1 -1
- package/dist/entities/organization.entity.js +84 -9
- package/dist/entities/organization.entity.js.map +1 -1
- package/dist/index.d.ts +15 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/organization.module.d.ts.map +1 -1
- package/dist/organization.module.js +2 -9
- package/dist/organization.module.js.map +1 -1
- package/dist/services/organization-user.service.d.ts +6 -6
- package/dist/services/organization-user.service.d.ts.map +1 -1
- package/dist/services/organization-user.service.js +61 -24
- package/dist/services/organization-user.service.js.map +1 -1
- package/dist/services/organization.service.d.ts +6 -5
- package/dist/services/organization.service.d.ts.map +1 -1
- package/dist/services/organization.service.js +20 -14
- package/dist/services/organization.service.js.map +1 -1
- package/package.json +1 -1
- package/dist/constants/repository-provider.constant.d.ts +0 -6
- package/dist/constants/repository-provider.constant.d.ts.map +0 -1
- package/dist/constants/repository-provider.constant.js +0 -10
- package/dist/constants/repository-provider.constant.js.map +0 -1
- package/dist/controllers/organization-repository.controller.d.ts +0 -18
- package/dist/controllers/organization-repository.controller.d.ts.map +0 -1
- package/dist/controllers/organization-repository.controller.js +0 -88
- package/dist/controllers/organization-repository.controller.js.map +0 -1
- package/dist/dtos/repository-auth.dto.d.ts +0 -6
- package/dist/dtos/repository-auth.dto.d.ts.map +0 -1
- package/dist/dtos/repository-auth.dto.js +0 -28
- package/dist/dtos/repository-auth.dto.js.map +0 -1
|
@@ -9,11 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.OrganizationModule = void 0;
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
11
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
12
|
-
const bitbucket_1 = require("@venturialstd/bitbucket");
|
|
13
12
|
const core_1 = require("@venturialstd/core");
|
|
14
|
-
const github_1 = require("@venturialstd/github");
|
|
15
|
-
const gitlab_1 = require("@venturialstd/gitlab");
|
|
16
|
-
const organization_repository_controller_1 = require("./controllers/organization-repository.controller");
|
|
17
13
|
const organization_entity_1 = require("./entities/organization.entity");
|
|
18
14
|
const organization_settings_entity_1 = require("./entities/organization-settings.entity");
|
|
19
15
|
const organization_user_entity_1 = require("./entities/organization-user.entity");
|
|
@@ -27,13 +23,10 @@ exports.OrganizationModule = OrganizationModule = __decorate([
|
|
|
27
23
|
(0, common_1.Module)({
|
|
28
24
|
imports: [
|
|
29
25
|
core_1.SharedModule.forRoot({}),
|
|
30
|
-
github_1.GithubModule,
|
|
31
|
-
gitlab_1.GitlabModule,
|
|
32
|
-
bitbucket_1.BitbucketModule,
|
|
33
26
|
typeorm_1.TypeOrmModule.forFeature([organization_entity_1.Organization, organization_user_entity_1.OrganizationUser, organization_settings_entity_1.OrganizationSettings]),
|
|
34
27
|
],
|
|
35
|
-
providers: [organization_service_1.OrganizationService, organization_user_service_1.OrganizationUserService, organization_settings_service_1.OrganizationSettingsService
|
|
36
|
-
controllers: [
|
|
28
|
+
providers: [organization_service_1.OrganizationService, organization_user_service_1.OrganizationUserService, organization_settings_service_1.OrganizationSettingsService],
|
|
29
|
+
controllers: [],
|
|
37
30
|
exports: [organization_service_1.OrganizationService, organization_user_service_1.OrganizationUserService, organization_settings_service_1.OrganizationSettingsService],
|
|
38
31
|
})
|
|
39
32
|
], OrganizationModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization.module.js","sourceRoot":"","sources":["../src/organization.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"organization.module.js","sourceRoot":"","sources":["../src/organization.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,6CAAkD;AAElD,wEAA8D;AAC9D,0FAA+E;AAC/E,kFAAuE;AACvE,0EAAsE;AACtE,4FAAuF;AACvF,oFAA+E;AAWxE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAT9B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,mBAAY,CAAC,OAAO,CAAC,EAAE,CAAC;YACxB,uBAAa,CAAC,UAAU,CAAC,CAAC,kCAAY,EAAE,2CAAgB,EAAE,mDAAoB,CAAC,CAAC;SACjF;QACD,SAAS,EAAE,CAAC,0CAAmB,EAAE,mDAAuB,EAAE,2DAA2B,CAAC;QACtF,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,CAAC,0CAAmB,EAAE,mDAAuB,EAAE,2DAA2B,CAAC;KACrF,CAAC;GACW,kBAAkB,CAAG"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { TypeOrmCrudService } from
|
|
2
|
-
import { AppLogger } from
|
|
3
|
-
import { Repository } from
|
|
4
|
-
import { ORGANIZATION_USER_ROLE } from
|
|
5
|
-
import { Organization } from
|
|
6
|
-
import { OrganizationUser } from
|
|
1
|
+
import { TypeOrmCrudService } from "@dataui/crud-typeorm";
|
|
2
|
+
import { AppLogger } from "@venturialstd/core";
|
|
3
|
+
import { Repository } from "typeorm";
|
|
4
|
+
import { ORGANIZATION_USER_ROLE } from "../constants/organization.constant";
|
|
5
|
+
import { Organization } from "../entities/organization.entity";
|
|
6
|
+
import { OrganizationUser } from "../entities/organization-user.entity";
|
|
7
7
|
export declare class OrganizationUserService extends TypeOrmCrudService<OrganizationUser> {
|
|
8
8
|
readonly repo: Repository<OrganizationUser>;
|
|
9
9
|
private readonly organizationRepo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization-user.service.d.ts","sourceRoot":"","sources":["../../src/services/organization-user.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAQ1D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EACL,sBAAsB,EAEvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,qBACa,uBAAwB,SAAQ,kBAAkB,CAAC,gBAAgB,CAAC;aAG7D,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;IAElD,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAHP,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC,EAEjC,gBAAgB,EAAE,UAAU,CAAC,YAAY,CAAC,EAC1C,MAAM,EAAE,SAAS;IAS9B,qBAAqB,CACzB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,sBAAsD,EAC5D,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"organization-user.service.d.ts","sourceRoot":"","sources":["../../src/services/organization-user.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAA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G,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAYjE,oBAAoB,CACxB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,gBAAgB,EAAE,CAAC;IASxB,0BAA0B,CAC9B,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,gBAAgB,EAAE,CAAC;IASxB,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAenE,OAAO,CACX,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,OAAO,CAAC;IAgBb,cAAc,CAClB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC;IAsBb,WAAW,CACf,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;IAenC,eAAe,CACnB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,CAAC;IA8BtB,iBAAiB,CACrB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IA2CV,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAS/D,WAAW,CACf,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,CAAC;IAyBtB,cAAc,CAClB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,CAAC;CAqB7B"}
|
|
@@ -34,18 +34,20 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
34
34
|
this.logger.setContext(OrganizationUserService_1.name);
|
|
35
35
|
}
|
|
36
36
|
async addUserToOrganization(organizationId, userId, role = organization_constant_1.ORGANIZATION_USER_ROLE.MEMBER, invitedBy) {
|
|
37
|
-
const organization = await this.organizationRepo.findOne({
|
|
37
|
+
const organization = await this.organizationRepo.findOne({
|
|
38
|
+
where: { id: organizationId },
|
|
39
|
+
});
|
|
38
40
|
if (!organization) {
|
|
39
41
|
throw new common_1.NotFoundException(`Organization with id "${organizationId}" not found`);
|
|
40
42
|
}
|
|
41
43
|
if (!organization.isActive) {
|
|
42
|
-
throw new common_1.BadRequestException(
|
|
44
|
+
throw new common_1.BadRequestException("Cannot add users to an inactive organization");
|
|
43
45
|
}
|
|
44
46
|
const existing = await this.repo.findOne({
|
|
45
47
|
where: { organizationId, userId },
|
|
46
48
|
});
|
|
47
49
|
if (existing) {
|
|
48
|
-
throw new common_1.BadRequestException(
|
|
50
|
+
throw new common_1.BadRequestException("User is already a member of this organization");
|
|
49
51
|
}
|
|
50
52
|
const organizationUser = this.repo.create({
|
|
51
53
|
organizationId,
|
|
@@ -61,7 +63,9 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
61
63
|
return saved;
|
|
62
64
|
}
|
|
63
65
|
async inviteUserToOrganization(organizationId, userId, role, invitedBy) {
|
|
64
|
-
const organization = await this.organizationRepo.findOne({
|
|
66
|
+
const organization = await this.organizationRepo.findOne({
|
|
67
|
+
where: { id: organizationId },
|
|
68
|
+
});
|
|
65
69
|
if (!organization) {
|
|
66
70
|
throw new common_1.NotFoundException(`Organization with id "${organizationId}" not found`);
|
|
67
71
|
}
|
|
@@ -69,7 +73,7 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
69
73
|
where: { organizationId, userId },
|
|
70
74
|
});
|
|
71
75
|
if (existing) {
|
|
72
|
-
throw new common_1.BadRequestException(
|
|
76
|
+
throw new common_1.BadRequestException("User is already a member or has a pending invitation");
|
|
73
77
|
}
|
|
74
78
|
const organizationUser = this.repo.create({
|
|
75
79
|
organizationId,
|
|
@@ -86,10 +90,14 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
86
90
|
}
|
|
87
91
|
async acceptInvitation(organizationId, userId) {
|
|
88
92
|
const organizationUser = await this.repo.findOne({
|
|
89
|
-
where: {
|
|
93
|
+
where: {
|
|
94
|
+
organizationId,
|
|
95
|
+
userId,
|
|
96
|
+
status: organization_constant_1.ORGANIZATION_USER_STATUS.INVITED,
|
|
97
|
+
},
|
|
90
98
|
});
|
|
91
99
|
if (!organizationUser) {
|
|
92
|
-
throw new common_1.NotFoundException(
|
|
100
|
+
throw new common_1.NotFoundException("Invitation not found");
|
|
93
101
|
}
|
|
94
102
|
organizationUser.status = organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE;
|
|
95
103
|
organizationUser.joinedAt = new Date();
|
|
@@ -102,10 +110,10 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
102
110
|
where: { organizationId, userId },
|
|
103
111
|
});
|
|
104
112
|
if (!organizationUser) {
|
|
105
|
-
throw new common_1.NotFoundException(
|
|
113
|
+
throw new common_1.NotFoundException("User is not a member of this organization");
|
|
106
114
|
}
|
|
107
115
|
if (organizationUser.isPrimary) {
|
|
108
|
-
throw new common_1.BadRequestException(
|
|
116
|
+
throw new common_1.BadRequestException("Cannot remove the primary owner of an organization");
|
|
109
117
|
}
|
|
110
118
|
await this.repo.remove(organizationUser);
|
|
111
119
|
this.logger.log(`User ${userId} removed from organization ${organizationId}`);
|
|
@@ -115,10 +123,11 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
115
123
|
where: { organizationId, userId },
|
|
116
124
|
});
|
|
117
125
|
if (!organizationUser) {
|
|
118
|
-
throw new common_1.NotFoundException(
|
|
126
|
+
throw new common_1.NotFoundException("User is not a member of this organization");
|
|
119
127
|
}
|
|
120
|
-
if (organizationUser.isPrimary &&
|
|
121
|
-
|
|
128
|
+
if (organizationUser.isPrimary &&
|
|
129
|
+
newRole !== organization_constant_1.ORGANIZATION_USER_ROLE.OWNER) {
|
|
130
|
+
throw new common_1.BadRequestException("Cannot change role of primary owner");
|
|
122
131
|
}
|
|
123
132
|
organizationUser.role = newRole;
|
|
124
133
|
const updated = await this.repo.save(organizationUser);
|
|
@@ -128,6 +137,9 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
128
137
|
async getUserOrganizations(userId) {
|
|
129
138
|
return this.repo.find({
|
|
130
139
|
where: { userId, status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE },
|
|
140
|
+
relations: {
|
|
141
|
+
organization: true,
|
|
142
|
+
},
|
|
131
143
|
});
|
|
132
144
|
}
|
|
133
145
|
async getOrganizationUsers(organizationId) {
|
|
@@ -142,19 +154,32 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
142
154
|
}
|
|
143
155
|
async hasAccess(organizationId, userId) {
|
|
144
156
|
const organizationUser = await this.repo.findOne({
|
|
145
|
-
where: {
|
|
157
|
+
where: {
|
|
158
|
+
organizationId,
|
|
159
|
+
userId,
|
|
160
|
+
status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE,
|
|
161
|
+
},
|
|
146
162
|
});
|
|
147
163
|
return !!organizationUser;
|
|
148
164
|
}
|
|
149
165
|
async hasRole(organizationId, userId, role) {
|
|
150
166
|
const organizationUser = await this.repo.findOne({
|
|
151
|
-
where: {
|
|
167
|
+
where: {
|
|
168
|
+
organizationId,
|
|
169
|
+
userId,
|
|
170
|
+
status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE,
|
|
171
|
+
role,
|
|
172
|
+
},
|
|
152
173
|
});
|
|
153
174
|
return !!organizationUser;
|
|
154
175
|
}
|
|
155
176
|
async isAdminOrOwner(organizationId, userId) {
|
|
156
177
|
const organizationUser = await this.repo.findOne({
|
|
157
|
-
where: {
|
|
178
|
+
where: {
|
|
179
|
+
organizationId,
|
|
180
|
+
userId,
|
|
181
|
+
status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE,
|
|
182
|
+
},
|
|
158
183
|
});
|
|
159
184
|
if (!organizationUser) {
|
|
160
185
|
return false;
|
|
@@ -164,7 +189,11 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
164
189
|
}
|
|
165
190
|
async getUserRole(organizationId, userId) {
|
|
166
191
|
const organizationUser = await this.repo.findOne({
|
|
167
|
-
where: {
|
|
192
|
+
where: {
|
|
193
|
+
organizationId,
|
|
194
|
+
userId,
|
|
195
|
+
status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE,
|
|
196
|
+
},
|
|
168
197
|
});
|
|
169
198
|
return organizationUser?.role || null;
|
|
170
199
|
}
|
|
@@ -174,7 +203,7 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
174
203
|
where: { organizationId, userId },
|
|
175
204
|
});
|
|
176
205
|
if (!organizationUser) {
|
|
177
|
-
throw new common_1.NotFoundException(
|
|
206
|
+
throw new common_1.NotFoundException("User is not a member of this organization");
|
|
178
207
|
}
|
|
179
208
|
organizationUser.isPrimary = true;
|
|
180
209
|
organizationUser.role = organization_constant_1.ORGANIZATION_USER_ROLE.OWNER;
|
|
@@ -187,13 +216,17 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
187
216
|
where: { organizationId, userId: fromUserId, isPrimary: true },
|
|
188
217
|
});
|
|
189
218
|
if (!currentOwner) {
|
|
190
|
-
throw new common_1.ForbiddenException(
|
|
219
|
+
throw new common_1.ForbiddenException("Only the primary owner can transfer ownership");
|
|
191
220
|
}
|
|
192
221
|
const newOwner = await this.repo.findOne({
|
|
193
|
-
where: {
|
|
222
|
+
where: {
|
|
223
|
+
organizationId,
|
|
224
|
+
userId: toUserId,
|
|
225
|
+
status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE,
|
|
226
|
+
},
|
|
194
227
|
});
|
|
195
228
|
if (!newOwner) {
|
|
196
|
-
throw new common_1.NotFoundException(
|
|
229
|
+
throw new common_1.NotFoundException("New owner must be an active member of the organization");
|
|
197
230
|
}
|
|
198
231
|
await this.setPrimaryOwner(organizationId, toUserId);
|
|
199
232
|
currentOwner.isPrimary = false;
|
|
@@ -211,10 +244,10 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
211
244
|
where: { organizationId, userId },
|
|
212
245
|
});
|
|
213
246
|
if (!organizationUser) {
|
|
214
|
-
throw new common_1.NotFoundException(
|
|
247
|
+
throw new common_1.NotFoundException("User is not a member of this organization");
|
|
215
248
|
}
|
|
216
249
|
if (organizationUser.isPrimary) {
|
|
217
|
-
throw new common_1.BadRequestException(
|
|
250
|
+
throw new common_1.BadRequestException("Cannot suspend the primary owner");
|
|
218
251
|
}
|
|
219
252
|
organizationUser.status = organization_constant_1.ORGANIZATION_USER_STATUS.SUSPENDED;
|
|
220
253
|
const updated = await this.repo.save(organizationUser);
|
|
@@ -223,10 +256,14 @@ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUser
|
|
|
223
256
|
}
|
|
224
257
|
async reactivateUser(organizationId, userId) {
|
|
225
258
|
const organizationUser = await this.repo.findOne({
|
|
226
|
-
where: {
|
|
259
|
+
where: {
|
|
260
|
+
organizationId,
|
|
261
|
+
userId,
|
|
262
|
+
status: organization_constant_1.ORGANIZATION_USER_STATUS.SUSPENDED,
|
|
263
|
+
},
|
|
227
264
|
});
|
|
228
265
|
if (!organizationUser) {
|
|
229
|
-
throw new common_1.NotFoundException(
|
|
266
|
+
throw new common_1.NotFoundException("User is not suspended in this organization");
|
|
230
267
|
}
|
|
231
268
|
organizationUser.status = organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE;
|
|
232
269
|
const updated = await this.repo.save(organizationUser);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization-user.service.js","sourceRoot":"","sources":["../../src/services/organization-user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAA0D;AAC1D,2CAKwB;AACxB,6CAAmD;AACnD,6CAA+C;AAC/C,qCAAqC;AAErC,8EAG4C;AAC5C,yEAA+D;AAC/D,mFAAwE;AAGjE,IAAM,uBAAuB,+BAA7B,MAAM,uBAAwB,SAAQ,iCAAoC;IAG7D;IAEC;IACA;IALnB,YAEkB,IAAkC,EAEjC,gBAA0C,EAC1C,MAAiB;QAElC,KAAK,CAAC,IAAI,CAAC,CAAC;QALI,SAAI,GAAJ,IAAI,CAA8B;QAEjC,qBAAgB,GAAhB,gBAAgB,CAA0B;QAC1C,WAAM,GAAN,MAAM,CAAW;QAGlC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAKD,KAAK,CAAC,qBAAqB,CACzB,cAAsB,EACtB,MAAc,EACd,OAA+B,8CAAsB,CAAC,MAAM,EAC5D,SAAkB;QAGlB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"organization-user.service.js","sourceRoot":"","sources":["../../src/services/organization-user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAA0D;AAC1D,2CAKwB;AACxB,6CAAmD;AACnD,6CAA+C;AAC/C,qCAAqC;AAErC,8EAG4C;AAC5C,yEAA+D;AAC/D,mFAAwE;AAGjE,IAAM,uBAAuB,+BAA7B,MAAM,uBAAwB,SAAQ,iCAAoC;IAG7D;IAEC;IACA;IALnB,YAEkB,IAAkC,EAEjC,gBAA0C,EAC1C,MAAiB;QAElC,KAAK,CAAC,IAAI,CAAC,CAAC;QALI,SAAI,GAAJ,IAAI,CAA8B;QAEjC,qBAAgB,GAAhB,gBAAgB,CAA0B;QAC1C,WAAM,GAAN,MAAM,CAAW;QAGlC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAKD,KAAK,CAAC,qBAAqB,CACzB,cAAsB,EACtB,MAAc,EACd,OAA+B,8CAAsB,CAAC,MAAM,EAC5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,EAAE,gDAAwB,CAAC,SAAS;aAC3C;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,IAAI,0BAAiB,CAAC,4CAA4C,CAAC,CAAC;QAC5E,CAAC;QAED,gBAAgB,CAAC,MAAM,GAAG,gDAAwB,CAAC,MAAM,CAAC;QAC1D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACvD,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,QAAQ,MAAM,gCAAgC,cAAc,EAAE,CAC/D,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AA3cY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,2CAAgB,CAAC,CAAA;IAElC,WAAA,IAAA,0BAAgB,EAAC,kCAAY,CAAC,CAAA;qCADT,oBAAU;QAEG,oBAAU;QACpB,gBAAS;GANzB,uBAAuB,CA2cnC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { TypeOrmCrudService } from
|
|
2
|
-
import { AppLogger, SettingsService } from
|
|
3
|
-
import { Repository } from
|
|
4
|
-
import { Organization } from
|
|
1
|
+
import { TypeOrmCrudService } from "@dataui/crud-typeorm";
|
|
2
|
+
import { AppLogger, SettingsService } from "@venturialstd/core";
|
|
3
|
+
import { Repository } from "typeorm";
|
|
4
|
+
import { Organization } from "../entities/organization.entity";
|
|
5
|
+
import { CreateOrganizationDto } from "../dtos/CreateOrganization.dto";
|
|
5
6
|
export declare class OrganizationService extends TypeOrmCrudService<Organization> {
|
|
6
7
|
readonly repo: Repository<Organization>;
|
|
7
8
|
private readonly settingsService;
|
|
8
9
|
private readonly logger;
|
|
9
10
|
constructor(repo: Repository<Organization>, settingsService: SettingsService, logger: AppLogger);
|
|
10
|
-
createOrganization(
|
|
11
|
+
createOrganization(data: CreateOrganizationDto): Promise<Organization>;
|
|
11
12
|
getOrganizationBySlug(slug: string): Promise<Organization>;
|
|
12
13
|
getOrganizationByDomain(domain: string): Promise<Organization>;
|
|
13
14
|
updateOrganizationSettings(organizationId: string, settings: Record<string, unknown>): Promise<Organization>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization.service.d.ts","sourceRoot":"","sources":["../../src/services/organization.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"organization.service.d.ts","sourceRoot":"","sources":["../../src/services/organization.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAS/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,qBACa,mBAAoB,SAAQ,kBAAkB,CAAC,YAAY,CAAC;aAGrD,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC;IAC9C,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAFP,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,EAC7B,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,SAAS;IAS9B,kBAAkB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC;IA+EtE,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAW1D,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAa9D,0BAA0B,CAC9B,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,YAAY,CAAC;IAoBlB,qBAAqB,CACzB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,YAAY,CAAC;IAsBlB,sBAAsB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAOjD,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CAGxE"}
|
|
@@ -19,7 +19,6 @@ const common_1 = require("@nestjs/common");
|
|
|
19
19
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
20
20
|
const core_1 = require("@venturialstd/core");
|
|
21
21
|
const typeorm_2 = require("typeorm");
|
|
22
|
-
const organization_settings_constant_1 = require("../constants/organization.settings.constant");
|
|
23
22
|
const organization_entity_1 = require("../entities/organization.entity");
|
|
24
23
|
let OrganizationService = OrganizationService_1 = class OrganizationService extends crud_typeorm_1.TypeOrmCrudService {
|
|
25
24
|
repo;
|
|
@@ -32,16 +31,12 @@ let OrganizationService = OrganizationService_1 = class OrganizationService exte
|
|
|
32
31
|
this.logger = logger;
|
|
33
32
|
this.logger.setContext(OrganizationService_1.name);
|
|
34
33
|
}
|
|
35
|
-
async createOrganization(
|
|
34
|
+
async createOrganization(data) {
|
|
36
35
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (ownerOrganizationCount >= parseInt(maxOrganizations)) {
|
|
42
|
-
throw new common_1.BadRequestException(`Maximum number of organizations (${maxOrganizations}) reached for this owner`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
36
|
+
const { name, slug, domain, description, industry, timezone, type, expectedTeamSize, primaryUseCase, securityRequirements, logoUrl, ownerId, } = data;
|
|
37
|
+
const existingByName = await this.repo.findOne({ where: { name } });
|
|
38
|
+
if (existingByName) {
|
|
39
|
+
throw new common_1.BadRequestException(`Organization with name "${name}" already exists`);
|
|
45
40
|
}
|
|
46
41
|
const existingOrganization = await this.repo.findOne({ where: { slug } });
|
|
47
42
|
if (existingOrganization) {
|
|
@@ -52,6 +47,13 @@ let OrganizationService = OrganizationService_1 = class OrganizationService exte
|
|
|
52
47
|
slug,
|
|
53
48
|
domain,
|
|
54
49
|
description,
|
|
50
|
+
industry,
|
|
51
|
+
timezone,
|
|
52
|
+
type,
|
|
53
|
+
expectedTeamSize,
|
|
54
|
+
primaryUseCase,
|
|
55
|
+
securityRequirements,
|
|
56
|
+
logoUrl,
|
|
55
57
|
ownerId,
|
|
56
58
|
isActive: true,
|
|
57
59
|
settings: {},
|
|
@@ -61,7 +63,7 @@ let OrganizationService = OrganizationService_1 = class OrganizationService exte
|
|
|
61
63
|
return savedOrganization;
|
|
62
64
|
}
|
|
63
65
|
catch (error) {
|
|
64
|
-
this.logger.error(
|
|
66
|
+
this.logger.error("Error creating organization:", error);
|
|
65
67
|
throw error;
|
|
66
68
|
}
|
|
67
69
|
}
|
|
@@ -80,7 +82,9 @@ let OrganizationService = OrganizationService_1 = class OrganizationService exte
|
|
|
80
82
|
return organization;
|
|
81
83
|
}
|
|
82
84
|
async updateOrganizationSettings(organizationId, settings) {
|
|
83
|
-
const organization = await this.repo.findOne({
|
|
85
|
+
const organization = await this.repo.findOne({
|
|
86
|
+
where: { id: organizationId },
|
|
87
|
+
});
|
|
84
88
|
if (!organization) {
|
|
85
89
|
throw new common_1.NotFoundException(`Organization with id "${organizationId}" not found`);
|
|
86
90
|
}
|
|
@@ -90,13 +94,15 @@ let OrganizationService = OrganizationService_1 = class OrganizationService exte
|
|
|
90
94
|
return updatedOrganization;
|
|
91
95
|
}
|
|
92
96
|
async setOrganizationStatus(organizationId, isActive) {
|
|
93
|
-
const organization = await this.repo.findOne({
|
|
97
|
+
const organization = await this.repo.findOne({
|
|
98
|
+
where: { id: organizationId },
|
|
99
|
+
});
|
|
94
100
|
if (!organization) {
|
|
95
101
|
throw new common_1.NotFoundException(`Organization with id "${organizationId}" not found`);
|
|
96
102
|
}
|
|
97
103
|
organization.isActive = isActive;
|
|
98
104
|
const updatedOrganization = await this.repo.save(organization);
|
|
99
|
-
this.logger.log(`Organization ${isActive ?
|
|
105
|
+
this.logger.log(`Organization ${isActive ? "activated" : "deactivated"}: ${organizationId}`);
|
|
100
106
|
return updatedOrganization;
|
|
101
107
|
}
|
|
102
108
|
async getActiveOrganizations() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization.service.js","sourceRoot":"","sources":["../../src/services/organization.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAA0D;AAC1D,
|
|
1
|
+
{"version":3,"file":"organization.service.js","sourceRoot":"","sources":["../../src/services/organization.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAA0D;AAC1D,2CAIwB;AACxB,6CAAmD;AACnD,6CAAgE;AAChE,qCAAqC;AAGrC,yEAA+D;AAYxD,IAAM,mBAAmB,2BAAzB,MAAM,mBAAoB,SAAQ,iCAAgC;IAGrD;IACC;IACA;IAJnB,YAEkB,IAA8B,EAC7B,eAAgC,EAChC,MAAiB;QAElC,KAAK,CAAC,IAAI,CAAC,CAAC;QAJI,SAAI,GAAJ,IAAI,CAA0B;QAC7B,oBAAe,GAAf,eAAe,CAAiB;QAChC,WAAM,GAAN,MAAM,CAAW;QAGlC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAKD,KAAK,CAAC,kBAAkB,CAAC,IAA2B;QAClD,IAAI,CAAC;YAeH,MAAM,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,OAAO,EACP,OAAO,GACR,GAAG,IAAI,CAAC;YAET,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EA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YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,0BAAiB,CACzB,yBAAyB,cAAc,aAAa,CACrD,CAAC;QACJ,CAAC;QAED,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACjC,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,gBAAgB,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,KAAK,cAAc,EAAE,CAC5E,CAAC;QAEF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAKD,KAAK,CAAC,sBAAsB;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACvD,CAAC;IAKD,KAAK,CAAC,uBAAuB,CAAC,OAAe;QAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC;CACF,CAAA;AA/KY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,kCAAY,CAAC,CAAA;qCACT,oBAAU;QACE,sBAAe;QACxB,gBAAS;GALzB,mBAAmB,CA+K/B"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repository-provider.constant.d.ts","sourceRoot":"","sources":["../../src/constants/repository-provider.constant.ts"],"names":[],"mappings":"AAAA,oBAAY,oBAAoB;IAC9B,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REPOSITORY_PROVIDERS = void 0;
|
|
4
|
-
var REPOSITORY_PROVIDERS;
|
|
5
|
-
(function (REPOSITORY_PROVIDERS) {
|
|
6
|
-
REPOSITORY_PROVIDERS["BITBUCKET"] = "BITBUCKET";
|
|
7
|
-
REPOSITORY_PROVIDERS["GITLAB"] = "GITLAB";
|
|
8
|
-
REPOSITORY_PROVIDERS["GITHUB"] = "GITHUB";
|
|
9
|
-
})(REPOSITORY_PROVIDERS || (exports.REPOSITORY_PROVIDERS = REPOSITORY_PROVIDERS = {}));
|
|
10
|
-
//# sourceMappingURL=repository-provider.constant.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repository-provider.constant.js","sourceRoot":"","sources":["../../src/constants/repository-provider.constant.ts"],"names":[],"mappings":";;;AAAA,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,+CAAuB,CAAA;IACvB,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;AACnB,CAAC,EAJW,oBAAoB,oCAApB,oBAAoB,QAI/B"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BitbucketOAuthService } from '@venturialstd/bitbucket';
|
|
2
|
-
import { AppLogger } from '@venturialstd/core';
|
|
3
|
-
import { GithubOAuthService } from '@venturialstd/github';
|
|
4
|
-
import { GitlabOAuthService } from '@venturialstd/gitlab';
|
|
5
|
-
import { RepositoryAuthDto } from '../dtos/repository-auth.dto';
|
|
6
|
-
import { OrganizationSettingsService } from '../services/organization-settings.service';
|
|
7
|
-
export declare class OrganizationRepositoryController {
|
|
8
|
-
private readonly organizationSettingsService;
|
|
9
|
-
private readonly bitbucketOAuthService;
|
|
10
|
-
private readonly gitlabOAuthService;
|
|
11
|
-
private readonly githubOAuthService;
|
|
12
|
-
private readonly logger;
|
|
13
|
-
constructor(organizationSettingsService: OrganizationSettingsService, bitbucketOAuthService: BitbucketOAuthService, gitlabOAuthService: GitlabOAuthService, githubOAuthService: GithubOAuthService, logger: AppLogger);
|
|
14
|
-
authenticateRepository(organizationId: string, body: RepositoryAuthDto): Promise<{
|
|
15
|
-
success: boolean;
|
|
16
|
-
}>;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=organization-repository.controller.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"organization-repository.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/organization-repository.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AAExF,qBACa,gCAAgC;IAEzC,OAAO,CAAC,QAAQ,CAAC,2BAA2B;IAC5C,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAJN,2BAA2B,EAAE,2BAA2B,EACxD,qBAAqB,EAAE,qBAAqB,EAC5C,kBAAkB,EAAE,kBAAkB,EACtC,kBAAkB,EAAE,kBAAkB,EACtC,MAAM,EAAE,SAAS;IAK9B,sBAAsB,CACb,cAAc,EAAE,MAAM,EAC3B,IAAI,EAAE,iBAAiB,GAC9B,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CA6CjC"}
|
|
@@ -1,88 +0,0 @@
|
|
|
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.OrganizationRepositoryController = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const bitbucket_1 = require("@venturialstd/bitbucket");
|
|
18
|
-
const core_1 = require("@venturialstd/core");
|
|
19
|
-
const github_1 = require("@venturialstd/github");
|
|
20
|
-
const gitlab_1 = require("@venturialstd/gitlab");
|
|
21
|
-
const repository_provider_constant_1 = require("../constants/repository-provider.constant");
|
|
22
|
-
const repository_auth_dto_1 = require("../dtos/repository-auth.dto");
|
|
23
|
-
const organization_settings_service_1 = require("../services/organization-settings.service");
|
|
24
|
-
let OrganizationRepositoryController = class OrganizationRepositoryController {
|
|
25
|
-
organizationSettingsService;
|
|
26
|
-
bitbucketOAuthService;
|
|
27
|
-
gitlabOAuthService;
|
|
28
|
-
githubOAuthService;
|
|
29
|
-
logger;
|
|
30
|
-
constructor(organizationSettingsService, bitbucketOAuthService, gitlabOAuthService, githubOAuthService, logger) {
|
|
31
|
-
this.organizationSettingsService = organizationSettingsService;
|
|
32
|
-
this.bitbucketOAuthService = bitbucketOAuthService;
|
|
33
|
-
this.gitlabOAuthService = gitlabOAuthService;
|
|
34
|
-
this.githubOAuthService = githubOAuthService;
|
|
35
|
-
this.logger = logger;
|
|
36
|
-
}
|
|
37
|
-
async authenticateRepository(organizationId, body) {
|
|
38
|
-
try {
|
|
39
|
-
const { provider, code } = body;
|
|
40
|
-
let tokenResponse;
|
|
41
|
-
switch (provider) {
|
|
42
|
-
case repository_provider_constant_1.REPOSITORY_PROVIDERS.GITHUB:
|
|
43
|
-
tokenResponse = await this.githubOAuthService.exchangeCode(code);
|
|
44
|
-
break;
|
|
45
|
-
case repository_provider_constant_1.REPOSITORY_PROVIDERS.GITLAB:
|
|
46
|
-
tokenResponse = await this.gitlabOAuthService.exchangeCode(code);
|
|
47
|
-
break;
|
|
48
|
-
case repository_provider_constant_1.REPOSITORY_PROVIDERS.BITBUCKET:
|
|
49
|
-
tokenResponse = await this.bitbucketOAuthService.exchangeCode(code);
|
|
50
|
-
break;
|
|
51
|
-
default:
|
|
52
|
-
return { success: false };
|
|
53
|
-
}
|
|
54
|
-
if (!tokenResponse?.access_token) {
|
|
55
|
-
return { success: false };
|
|
56
|
-
}
|
|
57
|
-
await this.organizationSettingsService.setOrganizationSetting(organizationId, {
|
|
58
|
-
module: 'repository',
|
|
59
|
-
section: provider.toLowerCase(),
|
|
60
|
-
key: 'access_token',
|
|
61
|
-
value: tokenResponse.access_token,
|
|
62
|
-
});
|
|
63
|
-
return { success: true };
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
return { success: false };
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
exports.OrganizationRepositoryController = OrganizationRepositoryController;
|
|
71
|
-
__decorate([
|
|
72
|
-
(0, common_1.Post)(':id/repository/auth'),
|
|
73
|
-
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
74
|
-
__param(0, (0, common_1.Param)('id')),
|
|
75
|
-
__param(1, (0, common_1.Body)()),
|
|
76
|
-
__metadata("design:type", Function),
|
|
77
|
-
__metadata("design:paramtypes", [String, repository_auth_dto_1.RepositoryAuthDto]),
|
|
78
|
-
__metadata("design:returntype", Promise)
|
|
79
|
-
], OrganizationRepositoryController.prototype, "authenticateRepository", null);
|
|
80
|
-
exports.OrganizationRepositoryController = OrganizationRepositoryController = __decorate([
|
|
81
|
-
(0, common_1.Controller)('organization'),
|
|
82
|
-
__metadata("design:paramtypes", [organization_settings_service_1.OrganizationSettingsService,
|
|
83
|
-
bitbucket_1.BitbucketOAuthService,
|
|
84
|
-
gitlab_1.GitlabOAuthService,
|
|
85
|
-
github_1.GithubOAuthService,
|
|
86
|
-
core_1.AppLogger])
|
|
87
|
-
], OrganizationRepositoryController);
|
|
88
|
-
//# sourceMappingURL=organization-repository.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"organization-repository.controller.js","sourceRoot":"","sources":["../../src/controllers/organization-repository.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAqF;AACrF,uDAAgE;AAChE,6CAA+C;AAC/C,iDAA0D;AAC1D,iDAA0D;AAE1D,4FAAiF;AACjF,qEAAgE;AAChE,6FAAwF;AAGjF,IAAM,gCAAgC,GAAtC,MAAM,gCAAgC;IAExB;IACA;IACA;IACA;IACA;IALnB,YACmB,2BAAwD,EACxD,qBAA4C,EAC5C,kBAAsC,EACtC,kBAAsC,EACtC,MAAiB;QAJjB,gCAA2B,GAA3B,2BAA2B,CAA6B;QACxD,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,WAAM,GAAN,MAAM,CAAW;IACjC,CAAC;IAIE,AAAN,KAAK,CAAC,sBAAsB,CACb,cAAsB,EAC3B,IAAuB;QAE/B,IAAI,CAAC;YACH,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;YAEhC,IAAI,aAMS,CAAC;YAEd,QAAQ,QAAQ,EAAE,CAAC;gBACjB,KAAK,mDAAoB,CAAC,M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