@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
|
@@ -12,18 +12,17 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.OrganizationCollection = void 0;
|
|
16
16
|
const mongodb_1 = require("mongodb");
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
|
-
const zod_1 = require("zod");
|
|
19
18
|
const db_1 = require("@trailmix-cms/db");
|
|
20
19
|
const constants_1 = require("../constants");
|
|
21
|
-
const
|
|
22
|
-
|
|
20
|
+
const zod_1 = require("zod");
|
|
21
|
+
const collectionName = constants_1.CMSCollectionName.Organization;
|
|
22
|
+
let OrganizationCollection = class OrganizationCollection extends db_1.AuditedCollection {
|
|
23
23
|
entitySchema;
|
|
24
24
|
setup;
|
|
25
25
|
config;
|
|
26
|
-
collection;
|
|
27
26
|
databaseService;
|
|
28
27
|
auditCollection;
|
|
29
28
|
logger = new common_1.Logger(this.constructor.name);
|
|
@@ -33,27 +32,28 @@ let FileCollection = class FileCollection extends db_1.AuditedCollection {
|
|
|
33
32
|
this.entitySchema = entitySchema;
|
|
34
33
|
this.setup = setup;
|
|
35
34
|
this.config = config;
|
|
36
|
-
this.collection = collection;
|
|
37
35
|
this.databaseService = databaseService;
|
|
38
36
|
this.auditCollection = auditCollection;
|
|
39
37
|
}
|
|
40
38
|
async onModuleInit() {
|
|
41
39
|
this.logger.verbose(`creating custom indexes for collection_${collectionName}`);
|
|
42
40
|
if (!this.config.disableDefaultIndexes) {
|
|
43
|
-
await this.collection.createIndex({
|
|
44
|
-
|
|
41
|
+
// await this.collection.createIndex({ name: 1 });
|
|
42
|
+
}
|
|
43
|
+
if (this.setup) {
|
|
44
|
+
await this.setup(this.collection);
|
|
45
45
|
}
|
|
46
|
-
await this.setup(this.collection);
|
|
47
46
|
}
|
|
48
47
|
};
|
|
49
|
-
exports.
|
|
50
|
-
exports.
|
|
48
|
+
exports.OrganizationCollection = OrganizationCollection;
|
|
49
|
+
exports.OrganizationCollection = OrganizationCollection = __decorate([
|
|
51
50
|
(0, common_1.Injectable)(),
|
|
52
|
-
__param(0, (0, common_1.Inject)(constants_1.PROVIDER_SYMBOLS.
|
|
53
|
-
__param(1, (0, common_1.
|
|
54
|
-
__param(
|
|
51
|
+
__param(0, (0, common_1.Inject)(constants_1.PROVIDER_SYMBOLS.ORGANIZATION_SCHEMA)),
|
|
52
|
+
__param(1, (0, common_1.Optional)()),
|
|
53
|
+
__param(1, (0, common_1.Inject)(constants_1.PROVIDER_SYMBOLS.ORGANIZATION_SETUP)),
|
|
54
|
+
__param(2, (0, common_1.Inject)(constants_1.PROVIDER_SYMBOLS.ORGANIZATION_CONFIG)),
|
|
55
55
|
__param(3, (0, db_1.DocumentCollection)(collectionName)),
|
|
56
|
-
__metadata("design:paramtypes", [zod_1.ZodType,
|
|
56
|
+
__metadata("design:paramtypes", [zod_1.ZodType, Object, Object, mongodb_1.Collection,
|
|
57
57
|
db_1.DatabaseService, db_1.Collections.AuditCollection])
|
|
58
|
-
],
|
|
59
|
-
//# sourceMappingURL=
|
|
58
|
+
], OrganizationCollection);
|
|
59
|
+
//# sourceMappingURL=organization.collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.collection.js","sourceRoot":"","sources":["../../src/collections/organization.collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qCAA+D;AAC/D,2CAAoF;AACpF,yCAAuG;AACvG,4CAAmE;AAEnE,6BAA8B;AAI9B,MAAM,cAAc,GAAG,6BAAiB,CAAC,YAAY,CAAC;AAG/C,IAAM,sBAAsB,GAA5B,MAAM,sBAAkD,SAAQ,sBAAoB;IAKlB;IACW;IACX;IAE9C;IACA;IATN,MAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5C,cAAc,GAAG,cAAc,CAAC;IAEhD,YACqE,YAAkD,EACvC,KAA4D,EACvE,MAAwB,EACrD,UAAyB,EAC1C,eAAgC,EAChC,eAA4C;QAE/D,KAAK,CAAC,UAAU,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;QAPa,iBAAY,GAAZ,YAAY,CAAsC;QACvC,UAAK,GAAL,KAAK,CAAuD;QACvE,WAAM,GAAN,MAAM,CAAkB;QAEtE,oBAAe,GAAf,eAAe,CAAiB;QAChC,oBAAe,GAAf,eAAe,CAA6B;IAGnE,CAAC;IAED,KAAK,CAAC,YAAY;QACd,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,0CAA0C,cAAc,EAAE,CAAC,CAAC;QAChF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC;YACrC,kDAAkD;QACtD,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACtC,CAAC;IACL,CAAC;CACJ,CAAA;AAxBY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAMJ,WAAA,IAAA,eAAM,EAAC,4BAAgB,CAAC,mBAAmB,CAAC,CAAA;IAC5C,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,4BAAgB,CAAC,kBAAkB,CAAC,CAAA;IACvD,WAAA,IAAA,eAAM,EAAC,4BAAgB,CAAC,mBAAmB,CAAC,CAAA;IAC5C,WAAA,IAAA,uBAAkB,EAAC,cAAc,CAAC,CAAA;qCAH4C,aAAO,kBAGtC,oBAAU;QACtB,oBAAe,EACf,gBAAW,CAAC,eAAe;GAV1D,sBAAsB,CAwBlC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Collection, ObjectId } from 'mongodb';
|
|
2
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
3
|
+
import { DatabaseService, Collections, AuditedCollection } from '@trailmix-cms/db';
|
|
4
|
+
import * as trailmixModels from '@trailmix-cms/models';
|
|
5
|
+
type Record = trailmixModels.Role.Entity;
|
|
6
|
+
export declare class RoleCollection extends AuditedCollection<Record> implements OnModuleInit {
|
|
7
|
+
protected readonly collection: Collection<Record>;
|
|
8
|
+
protected readonly databaseService: DatabaseService;
|
|
9
|
+
protected readonly auditCollection: Collections.AuditCollection;
|
|
10
|
+
private readonly logger;
|
|
11
|
+
readonly collectionName: "role";
|
|
12
|
+
readonly entitySchema: import("zod").ZodObject<{
|
|
13
|
+
_id: import("zod").ZodCodec<import("zod").ZodString, import("zod").ZodCustom<import("bson").ObjectId, import("bson").ObjectId>>;
|
|
14
|
+
created_at: import("zod").ZodCodec<import("zod").ZodISODateTime, import("zod").ZodDate>;
|
|
15
|
+
updated_at: import("zod").ZodOptional<import("zod").ZodCodec<import("zod").ZodISODateTime, import("zod").ZodDate>>;
|
|
16
|
+
type: import("zod").ZodEnum<{
|
|
17
|
+
organization: "organization";
|
|
18
|
+
global: "global";
|
|
19
|
+
}>;
|
|
20
|
+
principal_id: import("zod").ZodCodec<import("zod").ZodString, import("zod").ZodCustom<import("bson").ObjectId, import("bson").ObjectId>>;
|
|
21
|
+
principal_type: import("zod").ZodEnum<{
|
|
22
|
+
account: "account";
|
|
23
|
+
api_key: "api_key";
|
|
24
|
+
}>;
|
|
25
|
+
organization_id: import("zod").ZodOptional<import("zod").ZodCodec<import("zod").ZodString, import("zod").ZodCustom<import("bson").ObjectId, import("bson").ObjectId>>>;
|
|
26
|
+
role: import("zod").ZodString;
|
|
27
|
+
}, import("zod/v4/core").$strip>;
|
|
28
|
+
constructor(collection: Collection<Record>, databaseService: DatabaseService, auditCollection: Collections.AuditCollection);
|
|
29
|
+
onModuleInit(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=role.collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role.collection.d.ts","sourceRoot":"","sources":["../../src/collections/role.collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAsB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAsB,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEvG,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AAEvD,KAAK,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC;AAGzC,qBACa,cAAe,SAAQ,iBAAiB,CAAC,MAAM,CAAE,YAAW,YAAY;IAO7E,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC;IACjD,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,eAAe;IACnD,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,eAAe;IARnE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqC;IAC5D,SAAgB,cAAc,SAAkB;IAChD,SAAgB,YAAY;;;;;;;;;;;;;;;qCAA8B;gBAInC,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,EAC9B,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,WAAW,CAAC,eAAe;IAK7D,YAAY;CAcrB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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.RoleCollection = void 0;
|
|
49
|
+
const mongodb_1 = require("mongodb");
|
|
50
|
+
const common_1 = require("@nestjs/common");
|
|
51
|
+
const db_1 = require("@trailmix-cms/db");
|
|
52
|
+
const constants_1 = require("../constants");
|
|
53
|
+
const trailmixModels = __importStar(require("@trailmix-cms/models"));
|
|
54
|
+
const collectionName = constants_1.CMSCollectionName.Role;
|
|
55
|
+
let RoleCollection = class RoleCollection extends db_1.AuditedCollection {
|
|
56
|
+
collection;
|
|
57
|
+
databaseService;
|
|
58
|
+
auditCollection;
|
|
59
|
+
logger = new common_1.Logger(this.constructor.name);
|
|
60
|
+
collectionName = collectionName;
|
|
61
|
+
entitySchema = trailmixModels.Role.schema;
|
|
62
|
+
constructor(collection, databaseService, auditCollection) {
|
|
63
|
+
super(collection, databaseService, auditCollection);
|
|
64
|
+
this.collection = collection;
|
|
65
|
+
this.databaseService = databaseService;
|
|
66
|
+
this.auditCollection = auditCollection;
|
|
67
|
+
}
|
|
68
|
+
async onModuleInit() {
|
|
69
|
+
this.logger.verbose(`creating custom indexes for collection_${collectionName}`);
|
|
70
|
+
await this.collection.createIndex({ type: 1 });
|
|
71
|
+
// Index for finding roles by organization
|
|
72
|
+
await this.collection.createIndex({ type: 1, organization_id: 1 }, { sparse: true });
|
|
73
|
+
// Index for finding roles by principal
|
|
74
|
+
await this.collection.createIndex({ type: 1, principal_id: 1, principal_type: 1 });
|
|
75
|
+
// Index for finding specific role assignments
|
|
76
|
+
await this.collection.createIndex({ type: 1, principal_id: 1, principal_type: 1, organization_id: 1 }, { sparse: true });
|
|
77
|
+
// Unique index to prevent duplicate organization role assignments
|
|
78
|
+
await this.collection.createIndex({ type: 1, principal_id: 1, principal_type: 1, organization_id: 1, role: 1 }, { unique: true, sparse: true });
|
|
79
|
+
// Index for finding roles by organization and role name
|
|
80
|
+
await this.collection.createIndex({ type: 1, organization_id: 1, role: 1 }, { sparse: true });
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
exports.RoleCollection = RoleCollection;
|
|
84
|
+
exports.RoleCollection = RoleCollection = __decorate([
|
|
85
|
+
(0, common_1.Injectable)(),
|
|
86
|
+
__param(0, (0, db_1.DocumentCollection)(collectionName)),
|
|
87
|
+
__metadata("design:paramtypes", [mongodb_1.Collection,
|
|
88
|
+
db_1.DatabaseService, db_1.Collections.AuditCollection])
|
|
89
|
+
], RoleCollection);
|
|
90
|
+
//# sourceMappingURL=role.collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role.collection.js","sourceRoot":"","sources":["../../src/collections/role.collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA+C;AAC/C,2CAAkE;AAClE,yCAAuG;AACvG,4CAAiD;AACjD,qEAAuD;AAGvD,MAAM,cAAc,GAAG,6BAAiB,CAAC,IAAI,CAAC;AAGvC,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,sBAAyB;IAOlC;IACA;IACA;IARN,MAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5C,cAAc,GAAG,cAAc,CAAC;IAChC,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC;IAE1D,YAEuB,UAA8B,EAC9B,eAAgC,EAChC,eAA4C;QAE/D,KAAK,CAAC,UAAU,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;QAJjC,eAAU,GAAV,UAAU,CAAoB;QAC9B,oBAAe,GAAf,eAAe,CAAiB;QAChC,oBAAe,GAAf,eAAe,CAA6B;IAGnE,CAAC;IAED,KAAK,CAAC,YAAY;QACd,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,0CAA0C,cAAc,EAAE,CAAC,CAAC;QAChF,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/C,0CAA0C;QAC1C,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACrF,uCAAuC;QACvC,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC;QACnF,8CAA8C;QAC9C,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACzH,mEAAmE;QACnE,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAChJ,wDAAwD;QACxD,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAClG,CAAC;CACJ,CAAA;AA5BY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAOJ,WAAA,IAAA,uBAAkB,EAAC,cAAc,CAAC,CAAA;qCACJ,oBAAU;QACL,oBAAe,EACf,gBAAW,CAAC,eAAe;GAT1D,cAAc,CA4B1B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Collection } from 'mongodb';
|
|
2
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
3
|
+
import { DatabaseService, BaseCollection } from '@trailmix-cms/db';
|
|
4
|
+
import * as trailmixModels from '@trailmix-cms/models';
|
|
5
|
+
type Record = trailmixModels.SecurityAudit.Entity;
|
|
6
|
+
export declare class SecurityAuditCollection extends BaseCollection<Record> implements OnModuleInit {
|
|
7
|
+
protected readonly collection: Collection<Record>;
|
|
8
|
+
protected readonly databaseService: DatabaseService;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
readonly collectionName: "security-audit";
|
|
11
|
+
readonly entitySchema: import("zod").ZodObject<{
|
|
12
|
+
_id: import("zod").ZodCodec<import("zod").ZodString, import("zod").ZodCustom<import("bson").ObjectId, import("bson").ObjectId>>;
|
|
13
|
+
created_at: import("zod").ZodCodec<import("zod").ZodISODateTime, import("zod").ZodDate>;
|
|
14
|
+
updated_at: import("zod").ZodOptional<import("zod").ZodCodec<import("zod").ZodISODateTime, import("zod").ZodDate>>;
|
|
15
|
+
event_type: import("zod").ZodEnum<{
|
|
16
|
+
unauthorized_access: "unauthorized_access";
|
|
17
|
+
}>;
|
|
18
|
+
principal_id: import("zod").ZodCodec<import("zod").ZodString, import("zod").ZodCustom<import("bson").ObjectId, import("bson").ObjectId>>;
|
|
19
|
+
principal_type: import("zod").ZodEnum<{
|
|
20
|
+
account: "account";
|
|
21
|
+
api_key: "api_key";
|
|
22
|
+
}>;
|
|
23
|
+
message: import("zod").ZodOptional<import("zod").ZodString>;
|
|
24
|
+
source: import("zod").ZodOptional<import("zod").ZodString>;
|
|
25
|
+
}, import("zod/v4/core").$strip>;
|
|
26
|
+
constructor(collection: Collection<Record>, databaseService: DatabaseService);
|
|
27
|
+
onModuleInit(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=security-audit.collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-audit.collection.d.ts","sourceRoot":"","sources":["../../src/collections/security-audit.collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAsB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAsB,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvF,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AAEvD,KAAK,MAAM,GAAG,cAAc,CAAC,aAAa,CAAC,MAAM,CAAC;AAGlD,qBACa,uBAAwB,SAAQ,cAAc,CAAC,MAAM,CAAE,YAAW,YAAY;IAOnF,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC;IACjD,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,eAAe;IAPvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqC;IAC5D,SAAgB,cAAc,mBAAkB;IAChD,SAAgB,YAAY;;;;;;;;;;;;;;qCAAuC;gBAI5C,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,EAC9B,eAAe,EAAE,eAAe;IAKjD,YAAY;CAKrB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
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.SecurityAuditCollection = void 0;
|
|
49
|
+
const mongodb_1 = require("mongodb");
|
|
50
|
+
const common_1 = require("@nestjs/common");
|
|
51
|
+
const db_1 = require("@trailmix-cms/db");
|
|
52
|
+
const constants_1 = require("../constants");
|
|
53
|
+
const trailmixModels = __importStar(require("@trailmix-cms/models"));
|
|
54
|
+
const collectionName = constants_1.CMSCollectionName.SecurityAudit;
|
|
55
|
+
let SecurityAuditCollection = class SecurityAuditCollection extends db_1.BaseCollection {
|
|
56
|
+
collection;
|
|
57
|
+
databaseService;
|
|
58
|
+
logger = new common_1.Logger(this.constructor.name);
|
|
59
|
+
collectionName = collectionName;
|
|
60
|
+
entitySchema = trailmixModels.SecurityAudit.schema;
|
|
61
|
+
constructor(collection, databaseService) {
|
|
62
|
+
super(collection, databaseService);
|
|
63
|
+
this.collection = collection;
|
|
64
|
+
this.databaseService = databaseService;
|
|
65
|
+
}
|
|
66
|
+
async onModuleInit() {
|
|
67
|
+
this.logger.verbose(`creating custom indexes for collection_${collectionName}`);
|
|
68
|
+
await this.collection.createIndex({ principal_id: 1, principal_type: 1, created_at: -1 });
|
|
69
|
+
await this.collection.createIndex({ event_type: 1, created_at: -1 });
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.SecurityAuditCollection = SecurityAuditCollection;
|
|
73
|
+
exports.SecurityAuditCollection = SecurityAuditCollection = __decorate([
|
|
74
|
+
(0, common_1.Injectable)(),
|
|
75
|
+
__param(0, (0, db_1.DocumentCollection)(collectionName)),
|
|
76
|
+
__metadata("design:paramtypes", [mongodb_1.Collection,
|
|
77
|
+
db_1.DatabaseService])
|
|
78
|
+
], SecurityAuditCollection);
|
|
79
|
+
//# sourceMappingURL=security-audit.collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-audit.collection.js","sourceRoot":"","sources":["../../src/collections/security-audit.collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAqC;AACrC,2CAAkE;AAClE,yCAAuF;AACvF,4CAAiD;AACjD,qEAAuD;AAGvD,MAAM,cAAc,GAAG,6BAAiB,CAAC,aAAa,CAAC;AAGhD,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,mBAAsB;IAOxC;IACA;IAPN,MAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5C,cAAc,GAAG,cAAc,CAAC;IAChC,YAAY,GAAG,cAAc,CAAC,aAAa,CAAC,MAAM,CAAC;IAEnE,YAEuB,UAA8B,EAC9B,eAAgC;QAEnD,KAAK,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QAHhB,eAAU,GAAV,UAAU,CAAoB;QAC9B,oBAAe,GAAf,eAAe,CAAiB;IAGvD,CAAC;IAED,KAAK,CAAC,YAAY;QACd,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,0CAA0C,cAAc,EAAE,CAAC,CAAC;QAChF,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAC1F,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC;CACJ,CAAA;AAlBY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;IAOJ,WAAA,IAAA,uBAAkB,EAAC,cAAc,CAAC,CAAA;qCACJ,oBAAU;QACL,oBAAe;GAR9C,uBAAuB,CAkBnC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export declare const CMSCollectionName: {
|
|
2
|
+
readonly Organization: "organization";
|
|
3
|
+
readonly Role: "role";
|
|
4
|
+
readonly ApiKey: "api-key";
|
|
5
|
+
readonly SecurityAudit: "security-audit";
|
|
2
6
|
readonly Account: "account";
|
|
3
|
-
readonly File: "file";
|
|
4
|
-
readonly Text: "text";
|
|
5
7
|
};
|
|
6
8
|
export type CMSCollectionName = typeof CMSCollectionName[keyof typeof CMSCollectionName];
|
|
7
9
|
//# sourceMappingURL=cms-collection-names.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-collection-names.d.ts","sourceRoot":"","sources":["../../src/constants/cms-collection-names.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"cms-collection-names.d.ts","sourceRoot":"","sources":["../../src/constants/cms-collection-names.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB;;;;;;CAMpB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CMSCollectionName = void 0;
|
|
4
4
|
exports.CMSCollectionName = {
|
|
5
|
+
Organization: 'organization',
|
|
6
|
+
Role: 'role',
|
|
7
|
+
ApiKey: 'api-key',
|
|
8
|
+
SecurityAudit: 'security-audit',
|
|
5
9
|
Account: 'account',
|
|
6
|
-
File: 'file',
|
|
7
|
-
Text: 'text',
|
|
8
10
|
};
|
|
9
11
|
//# sourceMappingURL=cms-collection-names.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-collection-names.js","sourceRoot":"","sources":["../../src/constants/cms-collection-names.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG;IAC7B,
|
|
1
|
+
{"version":3,"file":"cms-collection-names.js","sourceRoot":"","sources":["../../src/constants/cms-collection-names.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG;IAC7B,YAAY,EAAE,cAAc;IAC5B,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,SAAS;IACjB,aAAa,EAAE,gBAAgB;IAC/B,OAAO,EAAE,SAAS;CACZ,CAAC"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
export declare const PROVIDER_SYMBOLS: {
|
|
2
|
-
readonly
|
|
3
|
-
readonly
|
|
4
|
-
readonly
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
10
|
-
readonly
|
|
11
|
-
readonly
|
|
12
|
-
readonly TRAILMIXCMS_CMS_TEXT_SETUP: "TRAILMIXCMS_CMS_TEXT_SETUP";
|
|
13
|
-
readonly TRAILMIXCMS_CMS_AUTH_GUARD_HOOK: "TRAILMIXCMS_CMS_AUTH_GUARD_HOOK";
|
|
2
|
+
readonly ACCOUNT_CONFIG: "TRAILMIXCMS_CMS_ACCOUNT_CONFIG";
|
|
3
|
+
readonly ACCOUNT_SCHEMA: "TRAILMIXCMS_CMS_ACCOUNT_SCHEMA";
|
|
4
|
+
readonly ACCOUNT_SETUP: "TRAILMIXCMS_CMS_ACCOUNT_SETUP";
|
|
5
|
+
readonly ACCOUNT_MAP_ENTITY: "TRAILMIXCMS_CMS_ACCOUNT_MAP_ENTITY";
|
|
6
|
+
readonly ORGANIZATION_CONFIG: "TRAILMIXCMS_CMS_ORGANIZATION_CONFIG";
|
|
7
|
+
readonly ORGANIZATION_SCHEMA: "TRAILMIXCMS_CMS_ORGANIZATION_SCHEMA";
|
|
8
|
+
readonly ORGANIZATION_SETUP: "TRAILMIXCMS_CMS_ORGANIZATION_SETUP";
|
|
9
|
+
readonly ORGANIZATION_MAP_ENTITY: "TRAILMIXCMS_CMS_ORGANIZATION_MAP_ENTITY";
|
|
10
|
+
readonly AUTH_GUARD_HOOK: "TRAILMIXCMS_CMS_AUTH_GUARD_HOOK";
|
|
11
|
+
readonly ORGANIZATION_DELETE_HOOK: "TRAILMIXCMS_CMS_ORGANIZATION_DELETE_HOOK";
|
|
14
12
|
};
|
|
15
13
|
//# sourceMappingURL=provider-symbols.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-symbols.d.ts","sourceRoot":"","sources":["../../src/constants/provider-symbols.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"provider-symbols.d.ts","sourceRoot":"","sources":["../../src/constants/provider-symbols.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;;CAanB,CAAC"}
|
|
@@ -2,17 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROVIDER_SYMBOLS = void 0;
|
|
4
4
|
exports.PROVIDER_SYMBOLS = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
TRAILMIXCMS_CMS_TEXT_SETUP: 'TRAILMIXCMS_CMS_TEXT_SETUP',
|
|
16
|
-
TRAILMIXCMS_CMS_AUTH_GUARD_HOOK: 'TRAILMIXCMS_CMS_AUTH_GUARD_HOOK',
|
|
5
|
+
ACCOUNT_CONFIG: 'TRAILMIXCMS_CMS_ACCOUNT_CONFIG',
|
|
6
|
+
ACCOUNT_SCHEMA: 'TRAILMIXCMS_CMS_ACCOUNT_SCHEMA',
|
|
7
|
+
ACCOUNT_SETUP: 'TRAILMIXCMS_CMS_ACCOUNT_SETUP',
|
|
8
|
+
ACCOUNT_MAP_ENTITY: 'TRAILMIXCMS_CMS_ACCOUNT_MAP_ENTITY',
|
|
9
|
+
ORGANIZATION_CONFIG: 'TRAILMIXCMS_CMS_ORGANIZATION_CONFIG',
|
|
10
|
+
ORGANIZATION_SCHEMA: 'TRAILMIXCMS_CMS_ORGANIZATION_SCHEMA',
|
|
11
|
+
ORGANIZATION_SETUP: 'TRAILMIXCMS_CMS_ORGANIZATION_SETUP',
|
|
12
|
+
ORGANIZATION_MAP_ENTITY: 'TRAILMIXCMS_CMS_ORGANIZATION_MAP_ENTITY',
|
|
13
|
+
AUTH_GUARD_HOOK: 'TRAILMIXCMS_CMS_AUTH_GUARD_HOOK',
|
|
14
|
+
ORGANIZATION_DELETE_HOOK: 'TRAILMIXCMS_CMS_ORGANIZATION_DELETE_HOOK',
|
|
17
15
|
};
|
|
18
16
|
//# sourceMappingURL=provider-symbols.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-symbols.js","sourceRoot":"","sources":["../../src/constants/provider-symbols.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG;IAC5B,
|
|
1
|
+
{"version":3,"file":"provider-symbols.js","sourceRoot":"","sources":["../../src/constants/provider-symbols.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG;IAC5B,cAAc,EAAE,gCAAgC;IAChD,cAAc,EAAE,gCAAgC;IAChD,aAAa,EAAE,+BAA+B;IAC9C,kBAAkB,EAAE,oCAAoC;IAExD,mBAAmB,EAAE,qCAAqC;IAC1D,mBAAmB,EAAE,qCAAqC;IAC1D,kBAAkB,EAAE,oCAAoC;IACxD,uBAAuB,EAAE,yCAAyC;IAElE,eAAe,EAAE,iCAAiC;IAClD,wBAAwB,EAAE,0CAA0C;CAC9D,CAAC"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { Logger } from '@nestjs/common';
|
|
2
2
|
import * as models from '@trailmix-cms/models';
|
|
3
|
+
import { type RequestPrincipal } from '../types';
|
|
4
|
+
import * as dto from '../dto/account.dto';
|
|
5
|
+
import { GlobalRoleService } from '../services';
|
|
3
6
|
export declare function buildAccountController<AccountEntity extends models.Account.Entity = models.Account.Entity, AccountDtoEntity = AccountEntity>(accountDto?: any): {
|
|
4
|
-
new (accountMapEntity: (entity: AccountEntity) => AccountDtoEntity): {
|
|
7
|
+
new (accountMapEntity: (entity: AccountEntity) => AccountDtoEntity, globalRoleService: GlobalRoleService): {
|
|
5
8
|
readonly logger: Logger;
|
|
6
9
|
readonly accountMapEntity: (entity: AccountEntity) => AccountDtoEntity;
|
|
7
|
-
|
|
10
|
+
readonly globalRoleService: GlobalRoleService;
|
|
11
|
+
info(principal: RequestPrincipal): Promise<AccountDtoEntity>;
|
|
12
|
+
getGlobalRoles(principal: RequestPrincipal): Promise<dto.AccountGlobalRoleListResponseDto>;
|
|
8
13
|
};
|
|
9
14
|
};
|
|
10
15
|
export declare const AccountController: {
|
|
@@ -12,42 +17,33 @@ export declare const AccountController: {
|
|
|
12
17
|
_id: import("bson").ObjectId;
|
|
13
18
|
created_at: Date;
|
|
14
19
|
user_id: string;
|
|
15
|
-
roles: string[];
|
|
16
20
|
updated_at?: Date | undefined;
|
|
17
21
|
}) => {
|
|
18
22
|
_id: import("bson").ObjectId;
|
|
19
23
|
created_at: Date;
|
|
20
24
|
user_id: string;
|
|
21
|
-
roles: string[];
|
|
22
25
|
updated_at?: Date | undefined;
|
|
23
|
-
}): {
|
|
26
|
+
}, globalRoleService: GlobalRoleService): {
|
|
24
27
|
readonly logger: Logger;
|
|
25
28
|
readonly accountMapEntity: (entity: {
|
|
26
29
|
_id: import("bson").ObjectId;
|
|
27
30
|
created_at: Date;
|
|
28
31
|
user_id: string;
|
|
29
|
-
roles: string[];
|
|
30
32
|
updated_at?: Date | undefined;
|
|
31
33
|
}) => {
|
|
32
34
|
_id: import("bson").ObjectId;
|
|
33
35
|
created_at: Date;
|
|
34
36
|
user_id: string;
|
|
35
|
-
roles: string[];
|
|
36
37
|
updated_at?: Date | undefined;
|
|
37
38
|
};
|
|
38
|
-
|
|
39
|
+
readonly globalRoleService: GlobalRoleService;
|
|
40
|
+
info(principal: RequestPrincipal): Promise<{
|
|
39
41
|
_id: import("bson").ObjectId;
|
|
40
42
|
created_at: Date;
|
|
41
43
|
user_id: string;
|
|
42
|
-
roles: string[];
|
|
43
|
-
updated_at?: Date | undefined;
|
|
44
|
-
}): Promise<{
|
|
45
|
-
_id: import("bson").ObjectId;
|
|
46
|
-
created_at: Date;
|
|
47
|
-
user_id: string;
|
|
48
|
-
roles: string[];
|
|
49
44
|
updated_at?: Date | undefined;
|
|
50
45
|
}>;
|
|
46
|
+
getGlobalRoles(principal: RequestPrincipal): Promise<dto.AccountGlobalRoleListResponseDto>;
|
|
51
47
|
};
|
|
52
48
|
};
|
|
53
49
|
//# sourceMappingURL=account.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/account.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"account.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/account.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGjE,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAI/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAgB,sBAAsB,CAClC,aAAa,SAAS,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EACnE,gBAAgB,GAAG,aAAa,EAClC,UAAU,GAAE,GAAyC;2BAQ6B,CAAC,MAAM,EAAE,aAAa,KAAK,gBAAgB,qBACvF,iBAAiB;;mCAD2B,CAAC,MAAM,EAAE,aAAa,KAAK,gBAAgB;oCACvF,iBAAiB;wBAMP,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;kCAUnD,gBAAgB,GAChD,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC;;EAavD;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;0BAhCU,iBAAiB;;;;;;;;;;;;;oCAAjB,iBAAiB;wBAMP,gBAAgB;;;;;;kCAUvB,gBAAgB,GAChD,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC;;CAeC,CAAC"}
|
|
@@ -1,10 +1,43 @@
|
|
|
1
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
|
+
});
|
|
2
18
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
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;
|
|
6
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
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
|
+
})();
|
|
8
41
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
42
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
43
|
};
|
|
@@ -15,41 +48,64 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
48
|
exports.AccountController = void 0;
|
|
16
49
|
exports.buildAccountController = buildAccountController;
|
|
17
50
|
const common_1 = require("@nestjs/common");
|
|
51
|
+
const nestjs_zod_1 = require("nestjs-zod");
|
|
18
52
|
const swagger_1 = require("@nestjs/swagger");
|
|
19
|
-
const
|
|
53
|
+
const models = __importStar(require("@trailmix-cms/models"));
|
|
54
|
+
const decorators_1 = require("../decorators");
|
|
20
55
|
const provider_symbols_1 = require("../constants/provider-symbols");
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
function buildAccountController(accountDto = (0, nestjs_zod_1.createZodDto)(models_1.Account.entitySchema)) {
|
|
56
|
+
const dto = __importStar(require("../dto/account.dto"));
|
|
57
|
+
const services_1 = require("../services");
|
|
58
|
+
function buildAccountController(accountDto = (0, nestjs_zod_1.createZodDto)(models.Account.schema)) {
|
|
25
59
|
var AccountController_1;
|
|
26
60
|
let AccountController = AccountController_1 = class AccountController {
|
|
27
61
|
accountMapEntity;
|
|
62
|
+
globalRoleService;
|
|
28
63
|
logger = new common_1.Logger(AccountController_1.name);
|
|
29
|
-
constructor(accountMapEntity) {
|
|
64
|
+
constructor(accountMapEntity, globalRoleService) {
|
|
30
65
|
this.accountMapEntity = accountMapEntity;
|
|
66
|
+
this.globalRoleService = globalRoleService;
|
|
31
67
|
}
|
|
32
|
-
async info(
|
|
68
|
+
async info(principal) {
|
|
33
69
|
this.logger.log('info');
|
|
34
|
-
this.logger.log(
|
|
35
|
-
return this.accountMapEntity(
|
|
70
|
+
this.logger.log(principal);
|
|
71
|
+
return this.accountMapEntity(principal.entity);
|
|
72
|
+
}
|
|
73
|
+
async getGlobalRoles(principal) {
|
|
74
|
+
this.logger.log('getGlobalRoles');
|
|
75
|
+
const roles = await this.globalRoleService.find({
|
|
76
|
+
principal_id: principal.entity._id,
|
|
77
|
+
principal_type: principal.principal_type,
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
items: roles,
|
|
81
|
+
count: roles.length,
|
|
82
|
+
};
|
|
36
83
|
}
|
|
37
84
|
};
|
|
38
85
|
__decorate([
|
|
39
86
|
(0, common_1.Get)(),
|
|
40
87
|
(0, swagger_1.ApiOperation)({ summary: 'Get account info' }),
|
|
41
88
|
(0, swagger_1.ApiOkResponse)({ description: 'Account info.', type: accountDto }),
|
|
42
|
-
__param(0, (0,
|
|
89
|
+
__param(0, (0, decorators_1.PrincipalContext)()),
|
|
43
90
|
__metadata("design:type", Function),
|
|
44
91
|
__metadata("design:paramtypes", [Object]),
|
|
45
92
|
__metadata("design:returntype", Promise)
|
|
46
93
|
], AccountController.prototype, "info", null);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, common_1.Get)('global-roles'),
|
|
96
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get global roles for the current account' }),
|
|
97
|
+
(0, swagger_1.ApiOkResponse)({ description: 'Global roles for the account.', type: dto.AccountGlobalRoleListResponseDto }),
|
|
98
|
+
__param(0, (0, decorators_1.PrincipalContext)()),
|
|
99
|
+
__metadata("design:type", Function),
|
|
100
|
+
__metadata("design:paramtypes", [Object]),
|
|
101
|
+
__metadata("design:returntype", Promise)
|
|
102
|
+
], AccountController.prototype, "getGlobalRoles", null);
|
|
47
103
|
AccountController = AccountController_1 = __decorate([
|
|
48
|
-
(0,
|
|
104
|
+
(0, decorators_1.Auth)({ principalTypes: [models.Principal.Account] }),
|
|
49
105
|
(0, swagger_1.ApiTags)('account'),
|
|
50
106
|
(0, common_1.Controller)('account'),
|
|
51
|
-
__param(0, (0, common_1.Inject)(provider_symbols_1.PROVIDER_SYMBOLS.
|
|
52
|
-
__metadata("design:paramtypes", [Function])
|
|
107
|
+
__param(0, (0, common_1.Inject)(provider_symbols_1.PROVIDER_SYMBOLS.ACCOUNT_MAP_ENTITY)),
|
|
108
|
+
__metadata("design:paramtypes", [Function, services_1.GlobalRoleService])
|
|
53
109
|
], AccountController);
|
|
54
110
|
return AccountController;
|
|
55
111
|
}
|