@venturialstd/organization 0.0.1

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.
Files changed (50) hide show
  1. package/README.md +678 -0
  2. package/dist/constants/organization.constant.d.ts +12 -0
  3. package/dist/constants/organization.constant.d.ts.map +1 -0
  4. package/dist/constants/organization.constant.js +17 -0
  5. package/dist/constants/organization.constant.js.map +1 -0
  6. package/dist/constants/organization.settings.constant.d.ts +11 -0
  7. package/dist/constants/organization.settings.constant.d.ts.map +1 -0
  8. package/dist/constants/organization.settings.constant.js +14 -0
  9. package/dist/constants/organization.settings.constant.js.map +1 -0
  10. package/dist/decorators/organization.decorator.d.ts +4 -0
  11. package/dist/decorators/organization.decorator.d.ts.map +1 -0
  12. package/dist/decorators/organization.decorator.js +22 -0
  13. package/dist/decorators/organization.decorator.js.map +1 -0
  14. package/dist/decorators/roles.decorator.d.ts +3 -0
  15. package/dist/decorators/roles.decorator.d.ts.map +1 -0
  16. package/dist/decorators/roles.decorator.js +7 -0
  17. package/dist/decorators/roles.decorator.js.map +1 -0
  18. package/dist/entities/organization-user.entity.d.ts +16 -0
  19. package/dist/entities/organization-user.entity.d.ts.map +1 -0
  20. package/dist/entities/organization-user.entity.js +120 -0
  21. package/dist/entities/organization-user.entity.js.map +1 -0
  22. package/dist/entities/organization.entity.d.ts +13 -0
  23. package/dist/entities/organization.entity.d.ts.map +1 -0
  24. package/dist/entities/organization.entity.js +94 -0
  25. package/dist/entities/organization.entity.js.map +1 -0
  26. package/dist/guards/organization.guard.d.ts +16 -0
  27. package/dist/guards/organization.guard.d.ts.map +1 -0
  28. package/dist/guards/organization.guard.js +90 -0
  29. package/dist/guards/organization.guard.js.map +1 -0
  30. package/dist/index.d.ts +12 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +28 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/organization.module.d.ts +3 -0
  35. package/dist/organization.module.d.ts.map +1 -0
  36. package/dist/organization.module.js +28 -0
  37. package/dist/organization.module.js.map +1 -0
  38. package/dist/services/organization-user.service.d.ts +30 -0
  39. package/dist/services/organization-user.service.d.ts.map +1 -0
  40. package/dist/services/organization-user.service.js +246 -0
  41. package/dist/services/organization-user.service.js.map +1 -0
  42. package/dist/services/organization.service.d.ts +18 -0
  43. package/dist/services/organization.service.d.ts.map +1 -0
  44. package/dist/services/organization.service.js +117 -0
  45. package/dist/services/organization.service.js.map +1 -0
  46. package/dist/settings/organization.settings.d.ts +3 -0
  47. package/dist/settings/organization.settings.d.ts.map +1 -0
  48. package/dist/settings/organization.settings.js +79 -0
  49. package/dist/settings/organization.settings.js.map +1 -0
  50. package/package.json +42 -0
@@ -0,0 +1,246 @@
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
+ var OrganizationUserService_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.OrganizationUserService = void 0;
17
+ const crud_typeorm_1 = require("@dataui/crud-typeorm");
18
+ const common_1 = require("@nestjs/common");
19
+ const typeorm_1 = require("@nestjs/typeorm");
20
+ const core_1 = require("@venturialstd/core");
21
+ const typeorm_2 = require("typeorm");
22
+ const organization_constant_1 = require("../constants/organization.constant");
23
+ const organization_entity_1 = require("../entities/organization.entity");
24
+ const organization_user_entity_1 = require("../entities/organization-user.entity");
25
+ let OrganizationUserService = OrganizationUserService_1 = class OrganizationUserService extends crud_typeorm_1.TypeOrmCrudService {
26
+ repo;
27
+ organizationRepo;
28
+ logger;
29
+ constructor(repo, organizationRepo, logger) {
30
+ super(repo);
31
+ this.repo = repo;
32
+ this.organizationRepo = organizationRepo;
33
+ this.logger = logger;
34
+ this.logger.setContext(OrganizationUserService_1.name);
35
+ }
36
+ async addUserToOrganization(organizationId, userId, role = organization_constant_1.ORGANIZATION_USER_ROLE.MEMBER, invitedBy) {
37
+ const organization = await this.organizationRepo.findOne({ where: { id: organizationId } });
38
+ if (!organization) {
39
+ throw new common_1.NotFoundException(`Organization with id "${organizationId}" not found`);
40
+ }
41
+ if (!organization.isActive) {
42
+ throw new common_1.BadRequestException('Cannot add users to an inactive organization');
43
+ }
44
+ const existing = await this.repo.findOne({
45
+ where: { organizationId, userId },
46
+ });
47
+ if (existing) {
48
+ throw new common_1.BadRequestException('User is already a member of this organization');
49
+ }
50
+ const organizationUser = this.repo.create({
51
+ organizationId,
52
+ userId,
53
+ role,
54
+ status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE,
55
+ invitedBy,
56
+ joinedAt: new Date(),
57
+ isPrimary: false,
58
+ });
59
+ const saved = await this.repo.save(organizationUser);
60
+ this.logger.log(`User ${userId} added to organization ${organizationId} with role ${role}`);
61
+ return saved;
62
+ }
63
+ async inviteUserToOrganization(organizationId, userId, role, invitedBy) {
64
+ const organization = await this.organizationRepo.findOne({ where: { id: organizationId } });
65
+ if (!organization) {
66
+ throw new common_1.NotFoundException(`Organization with id "${organizationId}" not found`);
67
+ }
68
+ const existing = await this.repo.findOne({
69
+ where: { organizationId, userId },
70
+ });
71
+ if (existing) {
72
+ throw new common_1.BadRequestException('User is already a member or has a pending invitation');
73
+ }
74
+ const organizationUser = this.repo.create({
75
+ organizationId,
76
+ userId,
77
+ role,
78
+ status: organization_constant_1.ORGANIZATION_USER_STATUS.INVITED,
79
+ invitedBy,
80
+ invitedAt: new Date(),
81
+ isPrimary: false,
82
+ });
83
+ const saved = await this.repo.save(organizationUser);
84
+ this.logger.log(`User ${userId} invited to organization ${organizationId} by ${invitedBy}`);
85
+ return saved;
86
+ }
87
+ async acceptInvitation(organizationId, userId) {
88
+ const organizationUser = await this.repo.findOne({
89
+ where: { organizationId, userId, status: organization_constant_1.ORGANIZATION_USER_STATUS.INVITED },
90
+ });
91
+ if (!organizationUser) {
92
+ throw new common_1.NotFoundException('Invitation not found');
93
+ }
94
+ organizationUser.status = organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE;
95
+ organizationUser.joinedAt = new Date();
96
+ const updated = await this.repo.save(organizationUser);
97
+ this.logger.log(`User ${userId} accepted invitation to organization ${organizationId}`);
98
+ return updated;
99
+ }
100
+ async removeUserFromOrganization(organizationId, userId) {
101
+ const organizationUser = await this.repo.findOne({
102
+ where: { organizationId, userId },
103
+ });
104
+ if (!organizationUser) {
105
+ throw new common_1.NotFoundException('User is not a member of this organization');
106
+ }
107
+ if (organizationUser.isPrimary) {
108
+ throw new common_1.BadRequestException('Cannot remove the primary owner of an organization');
109
+ }
110
+ await this.repo.remove(organizationUser);
111
+ this.logger.log(`User ${userId} removed from organization ${organizationId}`);
112
+ }
113
+ async updateUserRole(organizationId, userId, newRole) {
114
+ const organizationUser = await this.repo.findOne({
115
+ where: { organizationId, userId },
116
+ });
117
+ if (!organizationUser) {
118
+ throw new common_1.NotFoundException('User is not a member of this organization');
119
+ }
120
+ if (organizationUser.isPrimary && newRole !== organization_constant_1.ORGANIZATION_USER_ROLE.OWNER) {
121
+ throw new common_1.BadRequestException('Cannot change role of primary owner');
122
+ }
123
+ organizationUser.role = newRole;
124
+ const updated = await this.repo.save(organizationUser);
125
+ this.logger.log(`User ${userId} role updated to ${newRole} in organization ${organizationId}`);
126
+ return updated;
127
+ }
128
+ async getUserOrganizations(userId) {
129
+ return this.repo.find({
130
+ where: { userId, status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE },
131
+ });
132
+ }
133
+ async getOrganizationUsers(organizationId) {
134
+ return this.repo.find({
135
+ where: { organizationId },
136
+ });
137
+ }
138
+ async getActiveOrganizationUsers(organizationId) {
139
+ return this.repo.find({
140
+ where: { organizationId, status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE },
141
+ });
142
+ }
143
+ async hasAccess(organizationId, userId) {
144
+ const organizationUser = await this.repo.findOne({
145
+ where: { organizationId, userId, status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE },
146
+ });
147
+ return !!organizationUser;
148
+ }
149
+ async hasRole(organizationId, userId, role) {
150
+ const organizationUser = await this.repo.findOne({
151
+ where: { organizationId, userId, status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE, role },
152
+ });
153
+ return !!organizationUser;
154
+ }
155
+ async isAdminOrOwner(organizationId, userId) {
156
+ const organizationUser = await this.repo.findOne({
157
+ where: { organizationId, userId, status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE },
158
+ });
159
+ if (!organizationUser) {
160
+ return false;
161
+ }
162
+ return (organizationUser.role === organization_constant_1.ORGANIZATION_USER_ROLE.OWNER ||
163
+ organizationUser.role === organization_constant_1.ORGANIZATION_USER_ROLE.ADMIN);
164
+ }
165
+ async getUserRole(organizationId, userId) {
166
+ const organizationUser = await this.repo.findOne({
167
+ where: { organizationId, userId, status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE },
168
+ });
169
+ return organizationUser?.role || null;
170
+ }
171
+ async setPrimaryOwner(organizationId, userId) {
172
+ await this.repo.update({ organizationId, isPrimary: true }, { isPrimary: false });
173
+ const organizationUser = await this.repo.findOne({
174
+ where: { organizationId, userId },
175
+ });
176
+ if (!organizationUser) {
177
+ throw new common_1.NotFoundException('User is not a member of this organization');
178
+ }
179
+ organizationUser.isPrimary = true;
180
+ organizationUser.role = organization_constant_1.ORGANIZATION_USER_ROLE.OWNER;
181
+ const updated = await this.repo.save(organizationUser);
182
+ this.logger.log(`User ${userId} set as primary owner of organization ${organizationId}`);
183
+ return updated;
184
+ }
185
+ async transferOwnership(organizationId, fromUserId, toUserId) {
186
+ const currentOwner = await this.repo.findOne({
187
+ where: { organizationId, userId: fromUserId, isPrimary: true },
188
+ });
189
+ if (!currentOwner) {
190
+ throw new common_1.ForbiddenException('Only the primary owner can transfer ownership');
191
+ }
192
+ const newOwner = await this.repo.findOne({
193
+ where: { organizationId, userId: toUserId, status: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE },
194
+ });
195
+ if (!newOwner) {
196
+ throw new common_1.NotFoundException('New owner must be an active member of the organization');
197
+ }
198
+ await this.setPrimaryOwner(organizationId, toUserId);
199
+ currentOwner.isPrimary = false;
200
+ currentOwner.role = organization_constant_1.ORGANIZATION_USER_ROLE.ADMIN;
201
+ await this.repo.save(currentOwner);
202
+ this.logger.log(`Ownership of organization ${organizationId} transferred from ${fromUserId} to ${toUserId}`);
203
+ }
204
+ async getUserInvitations(userId) {
205
+ return this.repo.find({
206
+ where: { userId, status: organization_constant_1.ORGANIZATION_USER_STATUS.INVITED },
207
+ });
208
+ }
209
+ async suspendUser(organizationId, userId) {
210
+ const organizationUser = await this.repo.findOne({
211
+ where: { organizationId, userId },
212
+ });
213
+ if (!organizationUser) {
214
+ throw new common_1.NotFoundException('User is not a member of this organization');
215
+ }
216
+ if (organizationUser.isPrimary) {
217
+ throw new common_1.BadRequestException('Cannot suspend the primary owner');
218
+ }
219
+ organizationUser.status = organization_constant_1.ORGANIZATION_USER_STATUS.SUSPENDED;
220
+ const updated = await this.repo.save(organizationUser);
221
+ this.logger.log(`User ${userId} suspended in organization ${organizationId}`);
222
+ return updated;
223
+ }
224
+ async reactivateUser(organizationId, userId) {
225
+ const organizationUser = await this.repo.findOne({
226
+ where: { organizationId, userId, status: organization_constant_1.ORGANIZATION_USER_STATUS.SUSPENDED },
227
+ });
228
+ if (!organizationUser) {
229
+ throw new common_1.NotFoundException('User is not suspended in this organization');
230
+ }
231
+ organizationUser.status = organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE;
232
+ const updated = await this.repo.save(organizationUser);
233
+ this.logger.log(`User ${userId} reactivated in organization ${organizationId}`);
234
+ return updated;
235
+ }
236
+ };
237
+ exports.OrganizationUserService = OrganizationUserService;
238
+ exports.OrganizationUserService = OrganizationUserService = OrganizationUserService_1 = __decorate([
239
+ (0, common_1.Injectable)(),
240
+ __param(0, (0, typeorm_1.InjectRepository)(organization_user_entity_1.OrganizationUser)),
241
+ __param(1, (0, typeorm_1.InjectRepository)(organization_entity_1.Organization)),
242
+ __metadata("design:paramtypes", [typeorm_2.Repository,
243
+ typeorm_2.Repository,
244
+ core_1.AppLogger])
245
+ ], OrganizationUserService);
246
+ //# sourceMappingURL=organization-user.service.js.map
@@ -0,0 +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,gB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,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,CAAC,QAAQ,MAAM,gCAAgC,cAAc,EAAE,CAAC,CAAC;QAEhF,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AA3WY,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,CA2WnC"}
@@ -0,0 +1,18 @@
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
+ export declare class OrganizationService extends TypeOrmCrudService<Organization> {
6
+ readonly repo: Repository<Organization>;
7
+ private readonly settingsService;
8
+ private readonly logger;
9
+ constructor(repo: Repository<Organization>, settingsService: SettingsService, logger: AppLogger);
10
+ createOrganization(name: string, slug: string, domain?: string, description?: string, ownerId?: string): Promise<Organization>;
11
+ getOrganizationBySlug(slug: string): Promise<Organization>;
12
+ getOrganizationByDomain(domain: string): Promise<Organization>;
13
+ updateOrganizationSettings(organizationId: string, settings: Record<string, unknown>): Promise<Organization>;
14
+ setOrganizationStatus(organizationId: string, isActive: boolean): Promise<Organization>;
15
+ getActiveOrganizations(): Promise<Organization[]>;
16
+ getOrganizationsByOwner(ownerId: string): Promise<Organization[]>;
17
+ }
18
+ //# sourceMappingURL=organization.service.d.ts.map
@@ -0,0 +1 @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AC;CAGxE"}
@@ -0,0 +1,117 @@
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
+ var OrganizationService_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.OrganizationService = void 0;
17
+ const crud_typeorm_1 = require("@dataui/crud-typeorm");
18
+ const common_1 = require("@nestjs/common");
19
+ const typeorm_1 = require("@nestjs/typeorm");
20
+ const core_1 = require("@venturialstd/core");
21
+ const typeorm_2 = require("typeorm");
22
+ const organization_settings_constant_1 = require("../constants/organization.settings.constant");
23
+ const organization_entity_1 = require("../entities/organization.entity");
24
+ let OrganizationService = OrganizationService_1 = class OrganizationService extends crud_typeorm_1.TypeOrmCrudService {
25
+ repo;
26
+ settingsService;
27
+ logger;
28
+ constructor(repo, settingsService, logger) {
29
+ super(repo);
30
+ this.repo = repo;
31
+ this.settingsService = settingsService;
32
+ this.logger = logger;
33
+ this.logger.setContext(OrganizationService_1.name);
34
+ }
35
+ async createOrganization(name, slug, domain, description, ownerId) {
36
+ try {
37
+ if (ownerId) {
38
+ const maxOrganizations = await this.settingsService.get(organization_settings_constant_1.ORGANIZATION_SETTING_KEYS.GENERAL_MAX_ORGANIZATIONS);
39
+ if (maxOrganizations && parseInt(maxOrganizations) > 0) {
40
+ const ownerOrganizationCount = await this.repo.count({ where: { ownerId } });
41
+ if (ownerOrganizationCount >= parseInt(maxOrganizations)) {
42
+ throw new common_1.BadRequestException(`Maximum number of organizations (${maxOrganizations}) reached for this owner`);
43
+ }
44
+ }
45
+ }
46
+ const existingOrganization = await this.repo.findOne({ where: { slug } });
47
+ if (existingOrganization) {
48
+ throw new common_1.BadRequestException(`Organization with slug "${slug}" already exists`);
49
+ }
50
+ const organization = this.repo.create({
51
+ name,
52
+ slug,
53
+ domain,
54
+ description,
55
+ ownerId,
56
+ isActive: true,
57
+ settings: {},
58
+ });
59
+ const savedOrganization = await this.repo.save(organization);
60
+ this.logger.log(`Organization created: ${savedOrganization.id} - ${savedOrganization.name}`);
61
+ return savedOrganization;
62
+ }
63
+ catch (error) {
64
+ this.logger.error('Error creating organization:', error);
65
+ throw error;
66
+ }
67
+ }
68
+ async getOrganizationBySlug(slug) {
69
+ const organization = await this.repo.findOne({ where: { slug } });
70
+ if (!organization) {
71
+ throw new common_1.NotFoundException(`Organization with slug "${slug}" not found`);
72
+ }
73
+ return organization;
74
+ }
75
+ async getOrganizationByDomain(domain) {
76
+ const organization = await this.repo.findOne({ where: { domain } });
77
+ if (!organization) {
78
+ throw new common_1.NotFoundException(`Organization with domain "${domain}" not found`);
79
+ }
80
+ return organization;
81
+ }
82
+ async updateOrganizationSettings(organizationId, settings) {
83
+ const organization = await this.repo.findOne({ where: { id: organizationId } });
84
+ if (!organization) {
85
+ throw new common_1.NotFoundException(`Organization with id "${organizationId}" not found`);
86
+ }
87
+ organization.settings = { ...organization.settings, ...settings };
88
+ const updatedOrganization = await this.repo.save(organization);
89
+ this.logger.log(`Organization settings updated: ${organizationId}`);
90
+ return updatedOrganization;
91
+ }
92
+ async setOrganizationStatus(organizationId, isActive) {
93
+ const organization = await this.repo.findOne({ where: { id: organizationId } });
94
+ if (!organization) {
95
+ throw new common_1.NotFoundException(`Organization with id "${organizationId}" not found`);
96
+ }
97
+ organization.isActive = isActive;
98
+ const updatedOrganization = await this.repo.save(organization);
99
+ this.logger.log(`Organization ${isActive ? 'activated' : 'deactivated'}: ${organizationId}`);
100
+ return updatedOrganization;
101
+ }
102
+ async getActiveOrganizations() {
103
+ return this.repo.find({ where: { isActive: true } });
104
+ }
105
+ async getOrganizationsByOwner(ownerId) {
106
+ return this.repo.find({ where: { ownerId } });
107
+ }
108
+ };
109
+ exports.OrganizationService = OrganizationService;
110
+ exports.OrganizationService = OrganizationService = OrganizationService_1 = __decorate([
111
+ (0, common_1.Injectable)(),
112
+ __param(0, (0, typeorm_1.InjectRepository)(organization_entity_1.Organization)),
113
+ __metadata("design:paramtypes", [typeorm_2.Repository,
114
+ core_1.SettingsService,
115
+ core_1.AppLogger])
116
+ ], OrganizationService);
117
+ //# sourceMappingURL=organization.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.service.js","sourceRoot":"","sources":["../../src/services/organization.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAA0D;AAC1D,2CAAoF;AACpF,6CAAmD;AACnD,6CAAgE;AAChE,qCAAqC;AAErC,gGAAwF;AACxF,yEAA+D;AAGxD,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,CACtB,IAAY,EACZ,IAAY,EACZ,MAAe,EACf,WAAoB,EACpB,OAAgB;QAEhB,IAAI,CAAC;YAEH,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,gBAAgB,G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>[];
3
+ //# sourceMappingURL=organization.settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.settings.d.ts","sourceRoot":"","sources":["../../src/settings/organization.settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,oBAAoB,CAAC;AAE7D,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,WAAW,GAAG,WAAW,CAAC,EAyEtE,CAAC"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SETTINGS = void 0;
4
+ const core_1 = require("@venturialstd/core");
5
+ exports.SETTINGS = [
6
+ {
7
+ scope: 'GLOBAL',
8
+ module: 'ORGANIZATION',
9
+ section: 'GENERAL',
10
+ key: 'ENABLED',
11
+ label: 'Enabled',
12
+ description: 'Enable or disable the organization module',
13
+ type: core_1.SETTINGS_TYPE.BOOLEAN,
14
+ value: 'true',
15
+ options: null,
16
+ sortOrder: 1,
17
+ },
18
+ {
19
+ scope: 'GLOBAL',
20
+ module: 'ORGANIZATION',
21
+ section: 'GENERAL',
22
+ key: 'MAX_ORGANIZATIONS',
23
+ label: 'Max Organizations',
24
+ description: 'Maximum number of organizations allowed per owner (0 for unlimited)',
25
+ type: core_1.SETTINGS_TYPE.NUMBER,
26
+ value: '0',
27
+ options: null,
28
+ sortOrder: 2,
29
+ },
30
+ {
31
+ scope: 'GLOBAL',
32
+ module: 'ORGANIZATION',
33
+ section: 'GENERAL',
34
+ key: 'MAX_MEMBERS',
35
+ label: 'Max Members',
36
+ description: 'Maximum number of members per organization (0 for unlimited)',
37
+ type: core_1.SETTINGS_TYPE.NUMBER,
38
+ value: '0',
39
+ options: null,
40
+ sortOrder: 3,
41
+ },
42
+ {
43
+ scope: 'GLOBAL',
44
+ module: 'ORGANIZATION',
45
+ section: 'FEATURES',
46
+ key: 'CUSTOM_DOMAIN',
47
+ label: 'Custom Domain Enabled',
48
+ description: 'Allow organizations to use custom domains',
49
+ type: core_1.SETTINGS_TYPE.BOOLEAN,
50
+ value: 'false',
51
+ options: null,
52
+ sortOrder: 4,
53
+ },
54
+ {
55
+ scope: 'GLOBAL',
56
+ module: 'ORGANIZATION',
57
+ section: 'FEATURES',
58
+ key: 'API_ACCESS',
59
+ label: 'API Access Enabled',
60
+ description: 'Allow organizations to access the API',
61
+ type: core_1.SETTINGS_TYPE.BOOLEAN,
62
+ value: 'true',
63
+ options: null,
64
+ sortOrder: 5,
65
+ },
66
+ {
67
+ scope: 'GLOBAL',
68
+ module: 'ORGANIZATION',
69
+ section: 'FEATURES',
70
+ key: 'SSO',
71
+ label: 'SSO Enabled',
72
+ description: 'Enable Single Sign-On for organizations',
73
+ type: core_1.SETTINGS_TYPE.BOOLEAN,
74
+ value: 'false',
75
+ options: null,
76
+ sortOrder: 6,
77
+ },
78
+ ];
79
+ //# sourceMappingURL=organization.settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.settings.js","sourceRoot":"","sources":["../../src/settings/organization.settings.ts"],"names":[],"mappings":";;;AAAA,6CAA6D;AAEhD,QAAA,QAAQ,GAAuD;IAC1E;QACE,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,SAAS;QAClB,GAAG,EAAE,SAAS;QACd,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,2CAA2C;QACxD,IAAI,EAAE,oBAAa,CAAC,OAAO;QAC3B,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,CAAC;KACb;IACD;QACE,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,SAAS;QAClB,GAAG,EAAE,mBAAmB;QACxB,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EAAE,qEAAqE;QAClF,IAAI,EAAE,oBAAa,CAAC,MAAM;QAC1B,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,CAAC;KACb;IACD;QACE,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,SAAS;QAClB,GAAG,EAAE,aAAa;QAClB,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,8DAA8D;QAC3E,IAAI,EAAE,oBAAa,CAAC,MAAM;QAC1B,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,CAAC;KACb;IACD;QACE,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,UAAU;QACnB,GAAG,EAAE,eAAe;QACpB,KAAK,EAAE,uBAAuB;QAC9B,WAAW,EAAE,2CAA2C;QACxD,IAAI,EAAE,oBAAa,CAAC,OAAO;QAC3B,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,CAAC;KACb;IACD;QACE,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,UAAU;QACnB,GAAG,EAAE,YAAY;QACjB,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EAAE,uCAAuC;QACpD,IAAI,EAAE,oBAAa,CAAC,OAAO;QAC3B,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,CAAC;KACb;IACD;QACE,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,UAAU;QACnB,GAAG,EAAE,KAAK;QACV,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,yCAAyC;QACtD,IAAI,EAAE,oBAAa,CAAC,OAAO;QAC3B,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,CAAC;KACb;CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@venturialstd/organization",
3
+ "version": "0.0.1",
4
+ "description": "Organization Management Module for Venturial",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "commonjs",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.json",
16
+ "prepublishOnly": "npm run build",
17
+ "release:patch": "npm run build && npm version patch --no-git-tag-version && npm publish",
18
+ "test:dev": "ts-node -r tsconfig-paths/register test/main.ts",
19
+ "test:watch": "nodemon --watch src --watch test --ext ts --exec npm run test:dev",
20
+ "migration:generate": "ts-node node_modules/.bin/typeorm migration:generate -d test/data-source.ts test/migrations/$npm_config_name",
21
+ "migration:run": "ts-node node_modules/.bin/typeorm migration:run -d test/data-source.ts",
22
+ "migration:revert": "ts-node node_modules/.bin/typeorm migration:revert -d test/data-source.ts"
23
+ },
24
+ "devDependencies": {
25
+ "@nestjs/config": "^3.0.0",
26
+ "@types/node": "^20.0.0",
27
+ "dotenv": "^17.2.3",
28
+ "nodemon": "^3.0.0",
29
+ "ts-node": "^10.9.0",
30
+ "tsconfig-paths": "^4.2.0",
31
+ "typescript": "^5.9.3"
32
+ },
33
+ "peerDependencies": {
34
+ "@nestjs/common": "^11.0.11",
35
+ "@nestjs/core": "^11.0.5",
36
+ "@nestjs/typeorm": "^10.0.0",
37
+ "@venturialstd/core": "^1.0.16",
38
+ "class-transformer": "^0.5.1",
39
+ "class-validator": "^0.14.1",
40
+ "typeorm": "^0.3.20"
41
+ }
42
+ }