@trailmix-cms/cms 0.4.3 → 0.7.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.
- package/dist/auth.guard.d.ts +5 -13
- package/dist/auth.guard.d.ts.map +1 -1
- package/dist/auth.guard.js +23 -91
- package/dist/auth.guard.js.map +1 -1
- package/dist/collections/account.collection.d.ts +5 -3
- package/dist/collections/account.collection.d.ts.map +1 -1
- package/dist/collections/account.collection.js +15 -8
- package/dist/collections/account.collection.js.map +1 -1
- package/dist/collections/api-key.collection.d.ts +54 -0
- package/dist/collections/api-key.collection.d.ts.map +1 -0
- package/dist/collections/api-key.collection.js +142 -0
- package/dist/collections/api-key.collection.js.map +1 -0
- package/dist/collections/index.d.ts +4 -2
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/collections/index.js +9 -5
- package/dist/collections/index.js.map +1 -1
- package/dist/collections/organization.collection.d.ts +20 -0
- package/dist/collections/organization.collection.d.ts.map +1 -0
- package/dist/collections/{file.collection.js → organization.collection.js} +17 -17
- package/dist/collections/organization.collection.js.map +1 -0
- package/dist/collections/role.collection.d.ts +32 -0
- package/dist/collections/role.collection.d.ts.map +1 -0
- package/dist/collections/role.collection.js +90 -0
- package/dist/collections/role.collection.js.map +1 -0
- package/dist/collections/security-audit.collection.d.ts +30 -0
- package/dist/collections/security-audit.collection.d.ts.map +1 -0
- package/dist/collections/security-audit.collection.js +79 -0
- package/dist/collections/security-audit.collection.js.map +1 -0
- package/dist/constants/cms-collection-names.d.ts +4 -2
- package/dist/constants/cms-collection-names.d.ts.map +1 -1
- package/dist/constants/cms-collection-names.js +4 -2
- package/dist/constants/cms-collection-names.js.map +1 -1
- package/dist/constants/provider-symbols.d.ts +10 -12
- package/dist/constants/provider-symbols.d.ts.map +1 -1
- package/dist/constants/provider-symbols.js +10 -12
- package/dist/constants/provider-symbols.js.map +1 -1
- package/dist/controllers/account.controller.d.ts +11 -15
- package/dist/controllers/account.controller.d.ts.map +1 -1
- package/dist/controllers/account.controller.js +69 -13
- package/dist/controllers/account.controller.js.map +1 -1
- package/dist/controllers/api-keys.controller.d.ts +13 -0
- package/dist/controllers/api-keys.controller.d.ts.map +1 -0
- package/dist/controllers/api-keys.controller.js +125 -0
- package/dist/controllers/api-keys.controller.js.map +1 -0
- package/dist/controllers/audit.controller.d.ts.map +1 -1
- package/dist/controllers/audit.controller.js +3 -3
- package/dist/controllers/audit.controller.js.map +1 -1
- package/dist/controllers/audits.controller.d.ts +10 -0
- package/dist/controllers/audits.controller.d.ts.map +1 -0
- package/dist/controllers/audits.controller.js +107 -0
- package/dist/controllers/audits.controller.js.map +1 -0
- package/dist/controllers/global-roles.controller.d.ts +16 -0
- package/dist/controllers/global-roles.controller.d.ts.map +1 -0
- package/dist/controllers/global-roles.controller.js +137 -0
- package/dist/controllers/global-roles.controller.js.map +1 -0
- package/dist/controllers/index.d.ts +6 -1
- package/dist/controllers/index.d.ts.map +1 -1
- package/dist/controllers/index.js +6 -1
- package/dist/controllers/index.js.map +1 -1
- package/dist/controllers/organization-roles.controller.d.ts +16 -0
- package/dist/controllers/organization-roles.controller.d.ts.map +1 -0
- package/dist/controllers/organization-roles.controller.js +145 -0
- package/dist/controllers/organization-roles.controller.js.map +1 -0
- package/dist/controllers/organizations.controller.d.ts +65 -0
- package/dist/controllers/organizations.controller.d.ts.map +1 -0
- package/dist/controllers/organizations.controller.js +140 -0
- package/dist/controllers/organizations.controller.js.map +1 -0
- package/dist/controllers/security-audits.controller.d.ts +11 -0
- package/dist/controllers/security-audits.controller.d.ts.map +1 -0
- package/dist/controllers/security-audits.controller.js +130 -0
- package/dist/controllers/security-audits.controller.js.map +1 -0
- package/dist/decorators/account.decorator.d.ts +1 -3
- package/dist/decorators/account.decorator.d.ts.map +1 -1
- package/dist/decorators/account.decorator.js +3 -10
- package/dist/decorators/account.decorator.js.map +1 -1
- package/dist/decorators/audit-context.decorator.d.ts +6 -0
- package/dist/decorators/audit-context.decorator.d.ts.map +1 -1
- package/dist/decorators/audit-context.decorator.js +12 -3
- package/dist/decorators/audit-context.decorator.js.map +1 -1
- package/dist/decorators/auth.decorator.d.ts +5 -3
- package/dist/decorators/auth.decorator.d.ts.map +1 -1
- package/dist/decorators/auth.decorator.js +38 -3
- package/dist/decorators/auth.decorator.js.map +1 -1
- package/dist/decorators/index.d.ts +4 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +20 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/dto/account.dto.d.ts +33 -0
- package/dist/dto/account.dto.d.ts.map +1 -0
- package/dist/dto/account.dto.js +14 -0
- package/dist/dto/account.dto.js.map +1 -0
- package/dist/dto/api-key.dto.d.ts +89 -0
- package/dist/dto/api-key.dto.d.ts.map +1 -0
- package/dist/dto/api-key.dto.js +27 -0
- package/dist/dto/api-key.dto.js.map +1 -0
- package/dist/dto/audit.dto.d.ts +11 -5
- package/dist/dto/audit.dto.d.ts.map +1 -1
- package/dist/dto/audit.dto.js +1 -1
- package/dist/dto/audit.dto.js.map +1 -1
- package/dist/dto/global-role.dto.d.ts +99 -0
- package/dist/dto/global-role.dto.d.ts.map +1 -0
- package/dist/dto/global-role.dto.js +26 -0
- package/dist/dto/global-role.dto.js.map +1 -0
- package/dist/dto/organization-role.dto.d.ts +107 -0
- package/dist/dto/organization-role.dto.d.ts.map +1 -0
- package/dist/dto/organization-role.dto.js +26 -0
- package/dist/dto/organization-role.dto.js.map +1 -0
- package/dist/dto/organization.dto.d.ts +57 -0
- package/dist/dto/organization.dto.d.ts.map +1 -0
- package/dist/dto/organization.dto.js +32 -0
- package/dist/dto/organization.dto.js.map +1 -0
- package/dist/dto/security-audit.dto.d.ts +95 -0
- package/dist/dto/security-audit.dto.d.ts.map +1 -0
- package/dist/dto/security-audit.dto.js +26 -0
- package/dist/dto/security-audit.dto.js.map +1 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/managers/global-role.manager.d.ts +42 -0
- package/dist/managers/global-role.manager.d.ts.map +1 -0
- package/dist/managers/global-role.manager.js +117 -0
- package/dist/managers/global-role.manager.js.map +1 -0
- package/dist/managers/index.d.ts +4 -0
- package/dist/managers/index.d.ts.map +1 -0
- package/dist/managers/index.js +20 -0
- package/dist/managers/index.js.map +1 -0
- package/dist/managers/organization-role.manager.d.ts +47 -0
- package/dist/managers/organization-role.manager.d.ts.map +1 -0
- package/dist/managers/organization-role.manager.js +218 -0
- package/dist/managers/organization-role.manager.js.map +1 -0
- package/dist/managers/organization.manager.d.ts +39 -0
- package/dist/managers/organization.manager.d.ts.map +1 -0
- package/dist/managers/organization.manager.js +196 -0
- package/dist/managers/organization.manager.js.map +1 -0
- package/dist/module.d.ts +92 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +137 -0
- package/dist/module.js.map +1 -0
- package/dist/pipes/api-key.pipe.d.ts +8 -0
- package/dist/pipes/api-key.pipe.d.ts.map +1 -0
- package/dist/pipes/api-key.pipe.js +28 -0
- package/dist/pipes/api-key.pipe.js.map +1 -0
- package/dist/pipes/organization.pipe.d.ts +8 -0
- package/dist/pipes/organization.pipe.d.ts.map +1 -0
- package/dist/pipes/organization.pipe.js +28 -0
- package/dist/pipes/organization.pipe.js.map +1 -0
- package/dist/pipes/role.pipe.d.ts +8 -0
- package/dist/pipes/{file.pipe.d.ts.map → role.pipe.d.ts.map} +1 -1
- package/dist/pipes/{file.pipe.js → role.pipe.js} +8 -8
- package/dist/pipes/{file.pipe.js.map → role.pipe.js.map} +1 -1
- package/dist/services/account.service.d.ts +0 -2
- package/dist/services/account.service.d.ts.map +1 -1
- package/dist/services/account.service.js +1 -37
- package/dist/services/account.service.js.map +1 -1
- package/dist/services/api-key.service.d.ts +42 -0
- package/dist/services/api-key.service.d.ts.map +1 -0
- package/dist/services/api-key.service.js +306 -0
- package/dist/services/api-key.service.js.map +1 -0
- package/dist/services/auth.service.d.ts +40 -0
- package/dist/services/auth.service.d.ts.map +1 -0
- package/dist/services/auth.service.js +227 -0
- package/dist/services/auth.service.js.map +1 -0
- package/dist/services/authorization.service.d.ts +44 -9
- package/dist/services/authorization.service.d.ts.map +1 -1
- package/dist/services/authorization.service.js +107 -41
- package/dist/services/authorization.service.js.map +1 -1
- package/dist/services/feature.service.d.ts +23 -0
- package/dist/services/feature.service.d.ts.map +1 -0
- package/dist/services/feature.service.js +49 -0
- package/dist/services/feature.service.js.map +1 -0
- package/dist/services/global-role.service.d.ts +17 -0
- package/dist/services/global-role.service.d.ts.map +1 -0
- package/dist/services/global-role.service.js +99 -0
- package/dist/services/global-role.service.js.map +1 -0
- package/dist/services/index.d.ts +9 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +25 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/organization-role.service.d.ts +33 -0
- package/dist/services/organization-role.service.d.ts.map +1 -0
- package/dist/services/organization-role.service.js +102 -0
- package/dist/services/organization-role.service.js.map +1 -0
- package/dist/services/organization.service.d.ts +29 -0
- package/dist/services/organization.service.d.ts.map +1 -0
- package/dist/services/organization.service.js +95 -0
- package/dist/services/organization.service.js.map +1 -0
- package/dist/types/feature-config.d.ts +9 -0
- package/dist/types/feature-config.d.ts.map +1 -0
- package/dist/types/feature-config.js +3 -0
- package/dist/types/feature-config.js.map +1 -0
- package/dist/types/hooks/auth-guard-hook.d.ts.map +1 -0
- package/dist/types/hooks/auth-guard-hook.js.map +1 -0
- package/dist/types/hooks/index.d.ts +3 -0
- package/dist/types/hooks/index.d.ts.map +1 -0
- package/dist/types/hooks/index.js +19 -0
- package/dist/types/hooks/index.js.map +1 -0
- package/dist/types/hooks/organization-delete-hook.d.ts +20 -0
- package/dist/types/hooks/organization-delete-hook.d.ts.map +1 -0
- package/dist/types/hooks/organization-delete-hook.js +3 -0
- package/dist/types/hooks/organization-delete-hook.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/request-principal.d.ts +9 -0
- package/dist/types/request-principal.d.ts.map +1 -0
- package/dist/types/request-principal.js +3 -0
- package/dist/types/request-principal.js.map +1 -0
- package/dist/utils/provider-helpers.d.ts +6 -1
- package/dist/utils/provider-helpers.d.ts.map +1 -1
- package/dist/utils/provider-helpers.js +11 -1
- package/dist/utils/provider-helpers.js.map +1 -1
- package/package.json +59 -17
- package/test/unit/collections/api-key.collection.spec.ts +416 -0
- package/test/unit/managers/global-role.manager.spec.ts +269 -0
- package/test/unit/managers/organization-role.manager.spec.ts +632 -0
- package/test/unit/managers/organization.manager.spec.ts +395 -0
- package/test/unit/module.spec.ts +596 -0
- package/test/unit/services/account.service.spec.ts +90 -0
- package/test/unit/services/api-key.service.spec.ts +1244 -0
- package/test/unit/services/auth.service.spec.ts +790 -0
- package/test/unit/services/authorization.service.spec.ts +636 -0
- package/test/unit/services/feature.service.spec.ts +56 -0
- package/test/unit/services/global-role.service.spec.ts +289 -0
- package/test/unit/services/organization-role.service.spec.ts +300 -0
- package/test/unit/services/organization.service.spec.ts +385 -0
- package/test/utils/auth-guard.ts +114 -0
- package/test/utils/base.ts +16 -0
- package/test/utils/entities/account.ts +13 -0
- package/test/utils/entities/api-key.ts +15 -0
- package/test/utils/entities/audit.ts +18 -0
- package/test/utils/entities/index.ts +6 -0
- package/test/utils/entities/mapping.ts +20 -0
- package/test/utils/entities/organization.ts +13 -0
- package/test/utils/entities/role.ts +21 -0
- package/test/utils/entities/security-audit.ts +16 -0
- package/test/utils/index.ts +4 -0
- package/test/utils/models/audit-context.ts +10 -0
- package/test/utils/models/authorization.ts +7 -0
- package/test/utils/models/global-role.ts +22 -0
- package/test/utils/models/index.ts +5 -0
- package/test/utils/models/organization-role.ts +23 -0
- package/test/utils/models/publishable.ts +7 -0
- package/tsconfig.build.json +36 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/dist/auth-guard-hook.d.ts.map +0 -1
- package/dist/auth-guard-hook.js.map +0 -1
- package/dist/cms.module.d.ts +0 -8
- package/dist/cms.module.d.ts.map +0 -1
- package/dist/cms.module.js +0 -44
- package/dist/cms.module.js.map +0 -1
- package/dist/cms.providers.d.ts +0 -120
- package/dist/cms.providers.d.ts.map +0 -1
- package/dist/cms.providers.js +0 -126
- package/dist/cms.providers.js.map +0 -1
- package/dist/collections/file.collection.d.ts +0 -21
- package/dist/collections/file.collection.d.ts.map +0 -1
- package/dist/collections/file.collection.js.map +0 -1
- package/dist/collections/text.collection.d.ts +0 -20
- package/dist/collections/text.collection.d.ts.map +0 -1
- package/dist/collections/text.collection.js +0 -56
- package/dist/collections/text.collection.js.map +0 -1
- package/dist/pipes/file.pipe.d.ts +0 -8
- /package/dist/{auth-guard-hook.d.ts → types/hooks/auth-guard-hook.d.ts} +0 -0
- /package/dist/{auth-guard-hook.js → types/hooks/auth-guard-hook.js} +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.OrganizationRolesController = void 0;
|
|
49
|
+
const mongodb_1 = require("mongodb");
|
|
50
|
+
const common_1 = require("@nestjs/common");
|
|
51
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
52
|
+
const trailmixModels = __importStar(require("@trailmix-cms/models"));
|
|
53
|
+
const utils_1 = require("@trailmix-cms/utils");
|
|
54
|
+
const decorators_1 = require("../decorators");
|
|
55
|
+
const dto = __importStar(require("../dto/organization-role.dto"));
|
|
56
|
+
const managers_1 = require("../managers");
|
|
57
|
+
let OrganizationRolesController = class OrganizationRolesController {
|
|
58
|
+
organizationRoleManager;
|
|
59
|
+
constructor(organizationRoleManager) {
|
|
60
|
+
this.organizationRoleManager = organizationRoleManager;
|
|
61
|
+
}
|
|
62
|
+
async assignRole(assignRoleDto, principal, auditContext) {
|
|
63
|
+
const role = await this.organizationRoleManager.insertOne({
|
|
64
|
+
organization_id: assignRoleDto.organization_id,
|
|
65
|
+
principal_id: assignRoleDto.principal_id,
|
|
66
|
+
principal_type: assignRoleDto.principal_type,
|
|
67
|
+
role: assignRoleDto.role,
|
|
68
|
+
}, principal, auditContext);
|
|
69
|
+
return {
|
|
70
|
+
items: [role],
|
|
71
|
+
count: 1,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async getOrganizationRoleAssignments(queryParams, principal) {
|
|
75
|
+
const result = await this.organizationRoleManager.find({
|
|
76
|
+
organization_id: queryParams.organization_id,
|
|
77
|
+
principal_id: queryParams.principal_id,
|
|
78
|
+
principal_type: queryParams.principal_type,
|
|
79
|
+
role: queryParams.role,
|
|
80
|
+
}, principal);
|
|
81
|
+
return {
|
|
82
|
+
items: result,
|
|
83
|
+
count: result.length,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
async getOrganizationRoleAssignment(id, principal) {
|
|
87
|
+
return await this.organizationRoleManager.get(id, principal);
|
|
88
|
+
}
|
|
89
|
+
async removeRole(id, principal, auditContext) {
|
|
90
|
+
await this.organizationRoleManager.deleteOne(id, principal, auditContext);
|
|
91
|
+
return { success: true };
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
exports.OrganizationRolesController = OrganizationRolesController;
|
|
95
|
+
__decorate([
|
|
96
|
+
(0, common_1.Post)(),
|
|
97
|
+
(0, swagger_1.ApiOperation)({ summary: 'Assign an organization role to a principal' }),
|
|
98
|
+
(0, swagger_1.ApiCreatedResponse)({ description: 'Organization role assigned successfully.', type: dto.OrganizationRoleListResponseDto }),
|
|
99
|
+
__param(0, (0, common_1.Body)()),
|
|
100
|
+
__param(1, (0, decorators_1.PrincipalContext)()),
|
|
101
|
+
__param(2, (0, decorators_1.AuditContext)()),
|
|
102
|
+
__metadata("design:type", Function),
|
|
103
|
+
__metadata("design:paramtypes", [dto.AssignOrganizationRoleDto, Object, Object]),
|
|
104
|
+
__metadata("design:returntype", Promise)
|
|
105
|
+
], OrganizationRolesController.prototype, "assignRole", null);
|
|
106
|
+
__decorate([
|
|
107
|
+
(0, common_1.Get)(),
|
|
108
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get all organization role assignments' }),
|
|
109
|
+
(0, swagger_1.ApiOkResponse)({ description: 'Organization role assignments found.', type: dto.OrganizationRoleListResponseDto }),
|
|
110
|
+
__param(0, (0, common_1.Query)()),
|
|
111
|
+
__param(1, (0, decorators_1.PrincipalContext)()),
|
|
112
|
+
__metadata("design:type", Function),
|
|
113
|
+
__metadata("design:paramtypes", [dto.GetOrganizationRoleAssignmentsQueryDto, Object]),
|
|
114
|
+
__metadata("design:returntype", Promise)
|
|
115
|
+
], OrganizationRolesController.prototype, "getOrganizationRoleAssignments", null);
|
|
116
|
+
__decorate([
|
|
117
|
+
(0, common_1.Get)(':id'),
|
|
118
|
+
(0, swagger_1.ApiParam)({ name: 'id', description: 'Organization role assignment ID', type: String }),
|
|
119
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get an organization role assignment' }),
|
|
120
|
+
(0, swagger_1.ApiOkResponse)({ description: 'Organization role assignment found.', type: dto.OrganizationRoleDto }),
|
|
121
|
+
__param(0, (0, common_1.Param)('id', utils_1.ObjectIdPipe)),
|
|
122
|
+
__param(1, (0, decorators_1.PrincipalContext)()),
|
|
123
|
+
__metadata("design:type", Function),
|
|
124
|
+
__metadata("design:paramtypes", [mongodb_1.ObjectId, Object]),
|
|
125
|
+
__metadata("design:returntype", Promise)
|
|
126
|
+
], OrganizationRolesController.prototype, "getOrganizationRoleAssignment", null);
|
|
127
|
+
__decorate([
|
|
128
|
+
(0, common_1.Delete)(':id'),
|
|
129
|
+
(0, swagger_1.ApiParam)({ name: 'id', description: 'Organization role assignment ID', type: String }),
|
|
130
|
+
(0, swagger_1.ApiOperation)({ summary: 'Remove an organization role assignment' }),
|
|
131
|
+
(0, swagger_1.ApiOkResponse)({ description: 'Organization role removed successfully.' }),
|
|
132
|
+
__param(0, (0, common_1.Param)('id', utils_1.ObjectIdPipe)),
|
|
133
|
+
__param(1, (0, decorators_1.PrincipalContext)()),
|
|
134
|
+
__param(2, (0, decorators_1.AuditContext)()),
|
|
135
|
+
__metadata("design:type", Function),
|
|
136
|
+
__metadata("design:paramtypes", [mongodb_1.ObjectId, Object, Object]),
|
|
137
|
+
__metadata("design:returntype", Promise)
|
|
138
|
+
], OrganizationRolesController.prototype, "removeRole", null);
|
|
139
|
+
exports.OrganizationRolesController = OrganizationRolesController = __decorate([
|
|
140
|
+
(0, decorators_1.Auth)(),
|
|
141
|
+
(0, swagger_1.ApiTags)('organization-roles'),
|
|
142
|
+
(0, common_1.Controller)('organization-roles'),
|
|
143
|
+
__metadata("design:paramtypes", [managers_1.OrganizationRoleManager])
|
|
144
|
+
], OrganizationRolesController);
|
|
145
|
+
//# sourceMappingURL=organization-roles.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-roles.controller.js","sourceRoot":"","sources":["../../src/controllers/organization-roles.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAmC;AACnC,2CAAmF;AACnF,6CAAqG;AACrG,qEAAuD;AACvD,+CAAmD;AAEnD,8CAAqE;AACrE,kEAAoD;AAEpD,0CAAsD;AAK/C,IAAM,2BAA2B,GAAjC,MAAM,2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A,kBAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,iCAAiC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACtF,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,wCAAwC,EAAE,CAAC;IACnE,IAAA,uBAAa,EAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;IAErE,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,oBAAY,CAAC,CAAA;IACzB,WAAA,IAAA,6BAAgB,GAAE,CAAA;IAClB,WAAA,IAAA,yBAAY,GAAE,CAAA;;qCAFgB,kBAAQ;;6DAM1C;sCA1EQ,2BAA2B;IAHvC,IAAA,iBAAI,GAAE;IACN,IAAA,iBAAO,EAAC,oBAAoB,CAAC;IAC7B,IAAA,mBAAU,EAAC,oBAAoB,CAAC;qCAGiB,kCAAuB;GAF5D,2BAA2B,CA2EvC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import * as trailmixModels from '@trailmix-cms/models';
|
|
3
|
+
import { type RequestPrincipal } from '../types';
|
|
4
|
+
import { OrganizationManager } from '../managers/organization.manager';
|
|
5
|
+
export declare function buildOrganizationsController<OrganizationEntity extends trailmixModels.Organization.Entity = trailmixModels.Organization.Entity, OrganizationDtoEntity = OrganizationEntity>(organizationSchema?: any): {
|
|
6
|
+
new (organizationMapEntity: (entity: OrganizationEntity) => OrganizationDtoEntity, organizationManager: OrganizationManager): {
|
|
7
|
+
readonly logger: Logger;
|
|
8
|
+
readonly organizationMapEntity: (entity: OrganizationEntity) => OrganizationDtoEntity;
|
|
9
|
+
readonly organizationManager: OrganizationManager;
|
|
10
|
+
getOrganizations(principal: RequestPrincipal): Promise<{
|
|
11
|
+
items: any[];
|
|
12
|
+
count: number;
|
|
13
|
+
}>;
|
|
14
|
+
getOrganization(principal: RequestPrincipal, organization: trailmixModels.Organization.Entity): Promise<OrganizationDtoEntity>;
|
|
15
|
+
updateOrganization(principal: RequestPrincipal, organization: trailmixModels.Organization.Entity, update: {
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
}, auditContext: trailmixModels.AuditContext.Model): Promise<OrganizationDtoEntity>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare const OrganizationsController: {
|
|
21
|
+
new (organizationMapEntity: (entity: {
|
|
22
|
+
_id: import("bson").ObjectId;
|
|
23
|
+
created_at: Date;
|
|
24
|
+
name: string;
|
|
25
|
+
updated_at?: Date | undefined;
|
|
26
|
+
}) => {
|
|
27
|
+
_id: import("bson").ObjectId;
|
|
28
|
+
created_at: Date;
|
|
29
|
+
name: string;
|
|
30
|
+
updated_at?: Date | undefined;
|
|
31
|
+
}, organizationManager: OrganizationManager): {
|
|
32
|
+
readonly logger: Logger;
|
|
33
|
+
readonly organizationMapEntity: (entity: {
|
|
34
|
+
_id: import("bson").ObjectId;
|
|
35
|
+
created_at: Date;
|
|
36
|
+
name: string;
|
|
37
|
+
updated_at?: Date | undefined;
|
|
38
|
+
}) => {
|
|
39
|
+
_id: import("bson").ObjectId;
|
|
40
|
+
created_at: Date;
|
|
41
|
+
name: string;
|
|
42
|
+
updated_at?: Date | undefined;
|
|
43
|
+
};
|
|
44
|
+
readonly organizationManager: OrganizationManager;
|
|
45
|
+
getOrganizations(principal: RequestPrincipal): Promise<{
|
|
46
|
+
items: any[];
|
|
47
|
+
count: number;
|
|
48
|
+
}>;
|
|
49
|
+
getOrganization(principal: RequestPrincipal, organization: trailmixModels.Organization.Entity): Promise<{
|
|
50
|
+
_id: import("bson").ObjectId;
|
|
51
|
+
created_at: Date;
|
|
52
|
+
name: string;
|
|
53
|
+
updated_at?: Date | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
updateOrganization(principal: RequestPrincipal, organization: trailmixModels.Organization.Entity, update: {
|
|
56
|
+
[x: string]: any;
|
|
57
|
+
}, auditContext: trailmixModels.AuditContext.Model): Promise<{
|
|
58
|
+
_id: import("bson").ObjectId;
|
|
59
|
+
created_at: Date;
|
|
60
|
+
name: string;
|
|
61
|
+
updated_at?: Date | undefined;
|
|
62
|
+
}>;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=organizations.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizations.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/organizations.controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,MAAM,EAAwC,MAAM,gBAAgB,CAAC;AAItG,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,wBAAgB,4BAA4B,CACxC,kBAAkB,SAAS,cAAc,CAAC,YAAY,CAAC,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,MAAM,EAClG,qBAAqB,GAAG,kBAAkB,EAE1C,kBAAkB,GAAE,GAAwC;gCAsB8B,CAAC,MAAM,EAAE,kBAAkB,KAAK,qBAAqB,uBACzG,mBAAmB;;wCADiC,CAAC,MAAM,EAAE,kBAAkB,KAAK,qBAAqB;sCACzG,mBAAmB;oCAOlB,gBAAgB,GAChD,OAAO;;;UAA6B;mCAeJ,gBAAgB,gBACE,cAAc,CAAC,YAAY,CAAC,MAAM,GACpF,OAAO,CAAC,qBAAqB,CAAC;sCAUE,gBAAgB,gBACE,cAAc,CAAC,YAAY,CAAC,MAAM;;yBAErD,cAAc,CAAC,YAAY,CAAC,KAAK,GAChE,OAAO,CAAC,qBAAqB,CAAC;;EAYxC;AAED,eAAO,MAAM,uBAAuB;;;;;;;;;;;4BArDM,mBAAmB;;;;;;;;;;;;;sCAAnB,mBAAmB;oCAOlB,gBAAgB;;;;mCAgBhB,gBAAgB,gBACE,cAAc,CAAC,YAAY,CAAC,MAAM;;;;;;sCAWpD,gBAAgB,gBACE,cAAc,CAAC,YAAY,CAAC,MAAM;;yBAErD,cAAc,CAAC,YAAY,CAAC,KAAK;;;;;;;CAeN,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.OrganizationsController = void 0;
|
|
49
|
+
exports.buildOrganizationsController = buildOrganizationsController;
|
|
50
|
+
const zod_1 = require("zod");
|
|
51
|
+
const common_1 = require("@nestjs/common");
|
|
52
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
53
|
+
const nestjs_zod_1 = require("nestjs-zod");
|
|
54
|
+
const trailmixModels = __importStar(require("@trailmix-cms/models"));
|
|
55
|
+
const decorators_1 = require("../decorators");
|
|
56
|
+
const organization_pipe_1 = require("../pipes/organization.pipe");
|
|
57
|
+
const constants_1 = require("../constants");
|
|
58
|
+
const organization_manager_1 = require("../managers/organization.manager");
|
|
59
|
+
function buildOrganizationsController(organizationSchema = trailmixModels.Organization.schema) {
|
|
60
|
+
var OrganizationsController_1;
|
|
61
|
+
class OrganizationDto extends (0, nestjs_zod_1.createZodDto)(organizationSchema) {
|
|
62
|
+
}
|
|
63
|
+
const UpdateOrganizationSchema = organizationSchema.omit(trailmixModels.InternalFields);
|
|
64
|
+
class UpdateOrganizationDto extends (0, nestjs_zod_1.createZodDto)(UpdateOrganizationSchema) {
|
|
65
|
+
}
|
|
66
|
+
const OrganizationListResponseSchema = zod_1.z.object({
|
|
67
|
+
items: zod_1.z.array(organizationSchema),
|
|
68
|
+
count: zod_1.z.number(),
|
|
69
|
+
});
|
|
70
|
+
class OrganizationListResponseDto extends (0, nestjs_zod_1.createZodDto)(OrganizationListResponseSchema) {
|
|
71
|
+
}
|
|
72
|
+
let OrganizationsController = OrganizationsController_1 = class OrganizationsController {
|
|
73
|
+
organizationMapEntity;
|
|
74
|
+
organizationManager;
|
|
75
|
+
logger = new common_1.Logger(OrganizationsController_1.name);
|
|
76
|
+
constructor(organizationMapEntity, organizationManager) {
|
|
77
|
+
this.organizationMapEntity = organizationMapEntity;
|
|
78
|
+
this.organizationManager = organizationManager;
|
|
79
|
+
}
|
|
80
|
+
async getOrganizations(principal) {
|
|
81
|
+
this.logger.log('Getting all organizations');
|
|
82
|
+
const organizations = await this.organizationManager.find({}, principal);
|
|
83
|
+
return {
|
|
84
|
+
items: organizations.map((organization) => this.organizationMapEntity(organization)),
|
|
85
|
+
count: organizations.length,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
async getOrganization(principal, organization) {
|
|
89
|
+
const org = await this.organizationManager.get(organization, principal);
|
|
90
|
+
return this.organizationMapEntity(org);
|
|
91
|
+
}
|
|
92
|
+
async updateOrganization(principal, organization, update, auditContext) {
|
|
93
|
+
const updatedOrganization = await this.organizationManager.update(organization, update, principal, auditContext);
|
|
94
|
+
return this.organizationMapEntity(updatedOrganization);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, common_1.Get)(),
|
|
99
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get all organizations' }),
|
|
100
|
+
(0, swagger_1.ApiOkResponse)({ description: 'Organizations found.', type: OrganizationListResponseDto }),
|
|
101
|
+
__param(0, (0, decorators_1.PrincipalContext)()),
|
|
102
|
+
__metadata("design:type", Function),
|
|
103
|
+
__metadata("design:paramtypes", [Object]),
|
|
104
|
+
__metadata("design:returntype", Promise)
|
|
105
|
+
], OrganizationsController.prototype, "getOrganizations", null);
|
|
106
|
+
__decorate([
|
|
107
|
+
(0, common_1.Get)(':id'),
|
|
108
|
+
(0, swagger_1.ApiParam)({ name: 'id', description: 'Organization ID' }),
|
|
109
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get an organization by ID' }),
|
|
110
|
+
(0, swagger_1.ApiOkResponse)({ description: 'Organization found.', type: OrganizationDto }),
|
|
111
|
+
__param(0, (0, decorators_1.PrincipalContext)()),
|
|
112
|
+
__param(1, (0, common_1.Param)('id', organization_pipe_1.OrganizationByIdPipe)),
|
|
113
|
+
__metadata("design:type", Function),
|
|
114
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
115
|
+
__metadata("design:returntype", Promise)
|
|
116
|
+
], OrganizationsController.prototype, "getOrganization", null);
|
|
117
|
+
__decorate([
|
|
118
|
+
(0, common_1.Put)(':id'),
|
|
119
|
+
(0, swagger_1.ApiParam)({ name: 'id', description: 'Organization ID' }),
|
|
120
|
+
(0, swagger_1.ApiOperation)({ summary: 'Update an organization by ID' }),
|
|
121
|
+
(0, swagger_1.ApiOkResponse)({ description: 'Organization updated.', type: OrganizationDto }),
|
|
122
|
+
__param(0, (0, decorators_1.PrincipalContext)()),
|
|
123
|
+
__param(1, (0, common_1.Param)('id', organization_pipe_1.OrganizationByIdPipe)),
|
|
124
|
+
__param(2, (0, common_1.Body)()),
|
|
125
|
+
__param(3, (0, decorators_1.AuditContext)()),
|
|
126
|
+
__metadata("design:type", Function),
|
|
127
|
+
__metadata("design:paramtypes", [Object, Object, UpdateOrganizationDto, Object]),
|
|
128
|
+
__metadata("design:returntype", Promise)
|
|
129
|
+
], OrganizationsController.prototype, "updateOrganization", null);
|
|
130
|
+
OrganizationsController = OrganizationsController_1 = __decorate([
|
|
131
|
+
(0, decorators_1.Auth)(),
|
|
132
|
+
(0, swagger_1.ApiTags)('organizations'),
|
|
133
|
+
(0, common_1.Controller)('organizations'),
|
|
134
|
+
__param(0, (0, common_1.Inject)(constants_1.PROVIDER_SYMBOLS.ORGANIZATION_MAP_ENTITY)),
|
|
135
|
+
__metadata("design:paramtypes", [Function, organization_manager_1.OrganizationManager])
|
|
136
|
+
], OrganizationsController);
|
|
137
|
+
return OrganizationsController;
|
|
138
|
+
}
|
|
139
|
+
exports.OrganizationsController = buildOrganizationsController();
|
|
140
|
+
//# sourceMappingURL=organizations.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizations.controller.js","sourceRoot":"","sources":["../../src/controllers/organizations.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,oEA8EC;AA5FD,6BAAiC;AAEjC,2CAAsG;AACtG,6CAAiF;AACjF,2CAA0C;AAE1C,qEAAuD;AAEvD,8CAAqE;AAErE,kEAAkE;AAClE,4CAAgD;AAChD,2EAAuE;AAEvE,SAAgB,4BAA4B,CAIxC,qBAA0B,cAAc,CAAC,YAAY,CAAC,MAAM;;IAG5D,MAAM,eAAgB,SAAQ,IAAA,yBAAY,EAAC,kBAAkB,CAAC;KAAI;IAElE,MAAM,wBAAwB,GAAG,kBAAkB,CAAC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IACxF,MAAM,qBAAsB,SAAQ,IAAA,yBAAY,EAAC,wBAAwB,CAAC;KAAI;IAE9E,MAAM,8BAA8B,GAAG,OAAC,CAAC,MAAM,CAAC;QAC5C,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC;QAClC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;KACpB,CAAC,CAAC;IACH,MAAM,2BAA4B,SAAQ,IAAA,yBAAY,EAAC,8BAA8B,CAAC;KAAI;IAG1F,IAGM,uBAAuB,+BAH7B,MAGM,uBAAuB;QAIsC;QAClD;QAJJ,MAAM,GAAG,IAAI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A,uBAAuB,GAAG,4BAA4B,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SecurityAuditCollection } from '../collections/security-audit.collection';
|
|
2
|
+
import * as dto from '../dto/security-audit.dto';
|
|
3
|
+
import * as trailmixModels from '@trailmix-cms/models';
|
|
4
|
+
export declare class SecurityAuditsController {
|
|
5
|
+
private readonly securityAuditCollection;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(securityAuditCollection: SecurityAuditCollection);
|
|
8
|
+
getSecurityAudits(queryParams: dto.GetSecurityAuditsQueryDto): Promise<dto.SecurityAuditListResponseDto>;
|
|
9
|
+
getSecurityAuditById(id: string): Promise<trailmixModels.SecurityAudit.Entity>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=security-audits.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-audits.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/security-audits.controller.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAGnF,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACjD,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AAEvD,qBAGa,wBAAwB;IAI7B,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IAH5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6C;gBAG/C,uBAAuB,EAAE,uBAAuB;IAY/D,iBAAiB,CACV,WAAW,EAAE,GAAG,CAAC,yBAAyB,GACpD,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;IAqCtC,oBAAoB,CACT,EAAE,EAAE,MAAM,GACxB,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,MAAM,CAAC;CAYlD"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
var SecurityAuditsController_1;
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.SecurityAuditsController = void 0;
|
|
50
|
+
const common_1 = require("@nestjs/common");
|
|
51
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
52
|
+
const auth_decorator_1 = require("../decorators/auth.decorator");
|
|
53
|
+
const models_1 = require("@trailmix-cms/models");
|
|
54
|
+
const security_audit_collection_1 = require("../collections/security-audit.collection");
|
|
55
|
+
const utils_1 = require("@trailmix-cms/utils");
|
|
56
|
+
const dto = __importStar(require("../dto/security-audit.dto"));
|
|
57
|
+
const trailmixModels = __importStar(require("@trailmix-cms/models"));
|
|
58
|
+
let SecurityAuditsController = SecurityAuditsController_1 = class SecurityAuditsController {
|
|
59
|
+
securityAuditCollection;
|
|
60
|
+
logger = new common_1.Logger(SecurityAuditsController_1.name);
|
|
61
|
+
constructor(securityAuditCollection) {
|
|
62
|
+
this.securityAuditCollection = securityAuditCollection;
|
|
63
|
+
}
|
|
64
|
+
async getSecurityAudits(queryParams) {
|
|
65
|
+
this.logger.log(`Getting security audit records with query: ${JSON.stringify(queryParams)}`);
|
|
66
|
+
const filter = {};
|
|
67
|
+
if (queryParams.principal_id) {
|
|
68
|
+
filter.principal_id = queryParams.principal_id;
|
|
69
|
+
}
|
|
70
|
+
if (queryParams.principal_type) {
|
|
71
|
+
filter.principal_type = queryParams.principal_type;
|
|
72
|
+
}
|
|
73
|
+
if (queryParams.event_type) {
|
|
74
|
+
filter.event_type = queryParams.event_type;
|
|
75
|
+
}
|
|
76
|
+
const audits = await this.securityAuditCollection.find(filter, {
|
|
77
|
+
sort: { created_at: -1 },
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
items: audits,
|
|
81
|
+
count: audits.length,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async getSecurityAuditById(id) {
|
|
85
|
+
this.logger.log(`Getting security audit record ${id}`);
|
|
86
|
+
const auditId = (0, utils_1.validateObjectId)(id, { type: 'param', data: 'id' });
|
|
87
|
+
const audit = await this.securityAuditCollection.get(auditId);
|
|
88
|
+
if (!audit) {
|
|
89
|
+
throw new common_1.NotFoundException('Security audit record not found');
|
|
90
|
+
}
|
|
91
|
+
return audit;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
exports.SecurityAuditsController = SecurityAuditsController;
|
|
95
|
+
__decorate([
|
|
96
|
+
(0, common_1.Get)(),
|
|
97
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get all security audit records' }),
|
|
98
|
+
(0, swagger_1.ApiQuery)({ name: 'principal_id', required: false, description: 'Filter by principal ID' }),
|
|
99
|
+
(0, swagger_1.ApiQuery)({ name: 'principal_type', required: false, description: 'Filter by principal type', enum: trailmixModels.Principal }),
|
|
100
|
+
(0, swagger_1.ApiQuery)({ name: 'event_type', required: false, description: 'Filter by event type', enum: trailmixModels.SecurityAuditEventType }),
|
|
101
|
+
(0, swagger_1.ApiOkResponse)({
|
|
102
|
+
description: 'Security audit records found.',
|
|
103
|
+
type: dto.SecurityAuditListResponseDto,
|
|
104
|
+
}),
|
|
105
|
+
__param(0, (0, common_1.Query)()),
|
|
106
|
+
__metadata("design:type", Function),
|
|
107
|
+
__metadata("design:paramtypes", [dto.GetSecurityAuditsQueryDto]),
|
|
108
|
+
__metadata("design:returntype", Promise)
|
|
109
|
+
], SecurityAuditsController.prototype, "getSecurityAudits", null);
|
|
110
|
+
__decorate([
|
|
111
|
+
(0, common_1.Get)(':id'),
|
|
112
|
+
(0, swagger_1.ApiParam)({ name: 'id', description: 'Security audit record ID' }),
|
|
113
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get a specific security audit record by ID' }),
|
|
114
|
+
(0, swagger_1.ApiOkResponse)({
|
|
115
|
+
description: 'Security audit record found.',
|
|
116
|
+
type: dto.SecurityAuditResponseDto,
|
|
117
|
+
}),
|
|
118
|
+
(0, swagger_1.ApiNotFoundResponse)({ description: 'Security audit record not found.' }),
|
|
119
|
+
__param(0, (0, common_1.Param)('id')),
|
|
120
|
+
__metadata("design:type", Function),
|
|
121
|
+
__metadata("design:paramtypes", [String]),
|
|
122
|
+
__metadata("design:returntype", Promise)
|
|
123
|
+
], SecurityAuditsController.prototype, "getSecurityAuditById", null);
|
|
124
|
+
exports.SecurityAuditsController = SecurityAuditsController = SecurityAuditsController_1 = __decorate([
|
|
125
|
+
(0, auth_decorator_1.Auth)({ globalRoles: [models_1.RoleValue.Admin], principalTypes: [models_1.Principal.Account, models_1.Principal.ApiKey] }),
|
|
126
|
+
(0, swagger_1.ApiTags)('security-audits'),
|
|
127
|
+
(0, common_1.Controller)('security-audits'),
|
|
128
|
+
__metadata("design:paramtypes", [security_audit_collection_1.SecurityAuditCollection])
|
|
129
|
+
], SecurityAuditsController);
|
|
130
|
+
//# sourceMappingURL=security-audits.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-audits.controller.js","sourceRoot":"","sources":["../../src/controllers/security-audits.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0F;AAC1F,6CAAgH;AAGhH,iEAAoD;AACpD,iDAA4D;AAC5D,wFAAmF;AACnF,+CAAuD;AAEvD,+DAAiD;AACjD,qEAAuD;AAKhD,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAIZ;IAHJ,MAAM,GAA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AAI,CAAC,CAAA;;;;oEAYf;mCApEQ,wBAAwB;IAHpC,IAAA,qBAAI,EAAC,EAAE,WAAW,EAAE,CAAC,kBAAS,CAAC,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC,kBAAS,CAAC,OAAO,EAAE,kBAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAC/F,IAAA,iBAAO,EAAC,iBAAiB,CAAC;IAC1B,IAAA,mBAAU,EAAC,iBAAiB,CAAC;qCAKoB,mDAAuB;GAJ5D,wBAAwB,CAqEpC"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function buildAccountContextDecorator<T extends models.Account.Entity = models.Account.Entity>(): ParameterDecorator;
|
|
3
|
-
export declare const AccountContext: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
1
|
+
export declare const PrincipalContext: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
4
2
|
//# sourceMappingURL=account.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/account.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"account.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/account.decorator.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,mDAK5B,CAAC"}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.buildAccountContextDecorator = buildAccountContextDecorator;
|
|
3
|
+
exports.PrincipalContext = void 0;
|
|
5
4
|
const common_1 = require("@nestjs/common");
|
|
6
|
-
|
|
7
|
-
return (0, common_1.createParamDecorator)((data, ctx) => {
|
|
8
|
-
const request = ctx.switchToHttp().getRequest();
|
|
9
|
-
return request.account;
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
exports.AccountContext = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
5
|
+
exports.PrincipalContext = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
13
6
|
const request = ctx.switchToHttp().getRequest();
|
|
14
|
-
return request.
|
|
7
|
+
return request.principal;
|
|
15
8
|
});
|
|
16
9
|
//# sourceMappingURL=account.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.decorator.js","sourceRoot":"","sources":["../../src/decorators/account.decorator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"account.decorator.js","sourceRoot":"","sources":["../../src/decorators/account.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAG3D,QAAA,gBAAgB,GAAG,IAAA,6BAAoB,EAChD,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE;IACrC,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAkB,CAAC;IAChE,OAAO,OAAO,CAAC,SAAS,CAAC;AAC7B,CAAC,CACJ,CAAC"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import { RequestPrincipal } from '../types';
|
|
1
2
|
export declare const AuditContext: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
3
|
+
export declare function createAuditContextForPrincipal(requestPrincipal: RequestPrincipal): {
|
|
4
|
+
principal_id: import("bson").ObjectId;
|
|
5
|
+
principal_type: "account" | "api_key";
|
|
6
|
+
system: boolean;
|
|
7
|
+
};
|
|
2
8
|
//# sourceMappingURL=audit-context.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-context.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/audit-context.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"audit-context.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/audit-context.decorator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,eAAO,MAAM,YAAY,mDAcxB,CAAC;AAGF,wBAAgB,8BAA8B,CAAC,gBAAgB,EAAE,gBAAgB;;;;EAMhF"}
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AuditContext = void 0;
|
|
4
|
+
exports.createAuditContextForPrincipal = createAuditContextForPrincipal;
|
|
4
5
|
const common_1 = require("@nestjs/common");
|
|
5
6
|
exports.AuditContext = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
6
7
|
const request = ctx.switchToHttp().getRequest();
|
|
7
|
-
if (!request.
|
|
8
|
+
if (!request.principal) {
|
|
8
9
|
// TODO: Log this error
|
|
9
|
-
throw new common_1.InternalServerErrorException('No
|
|
10
|
+
throw new common_1.InternalServerErrorException('No principal found in request');
|
|
10
11
|
}
|
|
11
12
|
const auditContext = {
|
|
12
|
-
|
|
13
|
+
principal_id: request.principal.entity._id,
|
|
14
|
+
principal_type: request.principal.principal_type,
|
|
13
15
|
system: false,
|
|
14
16
|
};
|
|
15
17
|
return auditContext;
|
|
16
18
|
});
|
|
19
|
+
function createAuditContextForPrincipal(requestPrincipal) {
|
|
20
|
+
return {
|
|
21
|
+
principal_id: requestPrincipal.entity._id,
|
|
22
|
+
principal_type: requestPrincipal.principal_type,
|
|
23
|
+
system: false,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
17
26
|
//# sourceMappingURL=audit-context.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-context.decorator.js","sourceRoot":"","sources":["../../src/decorators/audit-context.decorator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"audit-context.decorator.js","sourceRoot":"","sources":["../../src/decorators/audit-context.decorator.ts"],"names":[],"mappings":";;;AAsBA,wEAMC;AA5BD,2CAAsG;AAKzF,QAAA,YAAY,GAAG,IAAA,6BAAoB,EAC5C,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE;IACrC,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAkB,CAAC;IAChE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACrB,uBAAuB;QACvB,MAAM,IAAI,qCAA4B,CAAC,+BAA+B,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,YAAY,GAA8B;QAC5C,YAAY,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG;QAC1C,cAAc,EAAE,OAAO,CAAC,SAAS,CAAC,cAAc;QAChD,MAAM,EAAE,KAAK;KAChB,CAAC;IACF,OAAO,YAAY,CAAC;AACxB,CAAC,CACJ,CAAC;AAGF,SAAgB,8BAA8B,CAAC,gBAAkC;IAC7E,OAAO;QACH,YAAY,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG;QACzC,cAAc,EAAE,gBAAgB,CAAC,cAAc;QAC/C,MAAM,EAAE,KAAK;KAChB,CAAC;AACN,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as trailmixModels from '@trailmix-cms/models';
|
|
2
2
|
export declare const ALLOW_ANONYMOUS_KEY = "allowAnonymous";
|
|
3
3
|
export declare const ROLES_KEY = "roles";
|
|
4
|
+
export declare const PRINCIPAL_TYPES_KEY = "principalTypes";
|
|
4
5
|
export interface AuthOptions {
|
|
5
|
-
|
|
6
|
+
globalRoles?: trailmixModels.RoleValue[];
|
|
6
7
|
allowAnonymous?: boolean;
|
|
8
|
+
principalTypes?: trailmixModels.Principal[];
|
|
7
9
|
}
|
|
8
|
-
export declare function Auth({
|
|
10
|
+
export declare function Auth({ globalRoles, allowAnonymous, principalTypes }?: AuthOptions): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
9
11
|
//# sourceMappingURL=auth.decorator.d.ts.map
|