@trailmix-cms/cms 0.0.3 → 0.1.0
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/cms.module.d.ts +4 -1
- package/dist/cms.module.d.ts.map +1 -1
- package/dist/cms.module.js +2 -4
- package/dist/cms.module.js.map +1 -1
- package/dist/cms.providers.d.ts +2 -1
- package/dist/cms.providers.d.ts.map +1 -1
- package/dist/cms.providers.js +4 -0
- package/dist/cms.providers.js.map +1 -1
- package/dist/controllers/audit.controller.d.ts +10 -0
- package/dist/controllers/audit.controller.d.ts.map +1 -0
- package/dist/controllers/audit.controller.js +107 -0
- package/dist/controllers/audit.controller.js.map +1 -0
- package/dist/dto/audit.dto.d.ts +51 -0
- package/dist/dto/audit.dto.d.ts.map +1 -0
- package/dist/dto/audit.dto.js +14 -0
- package/dist/dto/audit.dto.js.map +1 -0
- package/package.json +9 -7
- package/dist/controllers/file.controller.d.ts +0 -2
- package/dist/controllers/file.controller.d.ts.map +0 -1
- package/dist/controllers/file.controller.js +0 -80
- package/dist/controllers/file.controller.js.map +0 -1
- package/dist/controllers/text.controller.d.ts +0 -2
- package/dist/controllers/text.controller.d.ts.map +0 -1
- package/dist/controllers/text.controller.js +0 -48
- package/dist/controllers/text.controller.js.map +0 -1
package/dist/cms.module.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
2
|
import * as models from '@trailmix-cms/models';
|
|
3
3
|
import { createCmsProviders } from './cms.providers';
|
|
4
|
+
export type CmsModuleOptions = {
|
|
5
|
+
disableAuditController: boolean;
|
|
6
|
+
};
|
|
4
7
|
export declare class CmsModule {
|
|
5
|
-
static forRoot<AccountEntity extends models.Account.Entity = models.Account.Entity, AccountDtoEntity = AccountEntity, FileEntity extends models.File.Entity = models.File.Entity, TextEntity extends models.Text.Entity = models.Text.Entity>(options?: Parameters<typeof createCmsProviders<AccountEntity, AccountDtoEntity, FileEntity, TextEntity>>[0]): Promise<DynamicModule>;
|
|
8
|
+
static forRoot<AccountEntity extends models.Account.Entity = models.Account.Entity, AccountDtoEntity = AccountEntity, FileEntity extends models.File.Entity = models.File.Entity, TextEntity extends models.Text.Entity = models.Text.Entity>(options?: CmsModuleOptions & Parameters<typeof createCmsProviders<AccountEntity, AccountDtoEntity, FileEntity, TextEntity>>[0]): Promise<DynamicModule>;
|
|
6
9
|
}
|
|
7
10
|
//# sourceMappingURL=cms.module.d.ts.map
|
package/dist/cms.module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms.module.d.ts","sourceRoot":"","sources":["../src/cms.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAGvD,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAI/C,OAAO,EAAwB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAI3E,
|
|
1
|
+
{"version":3,"file":"cms.module.d.ts","sourceRoot":"","sources":["../src/cms.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAGvD,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAI/C,OAAO,EAAwB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAI3E,MAAM,MAAM,gBAAgB,GAAG;IAC3B,sBAAsB,EAAE,OAAO,CAAC;CACnC,CAAA;AAED,qBASa,SAAS;WACL,OAAO,CAChB,aAAa,SAAS,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EACnE,gBAAgB,GAAG,aAAa,EAChC,UAAU,SAAS,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAC1D,UAAU,SAAS,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAC5D,OAAO,CAAC,EAAE,gBAAgB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;CAiB5J"}
|
package/dist/cms.module.js
CHANGED
|
@@ -14,7 +14,7 @@ const db_1 = require("@trailmix-cms/db");
|
|
|
14
14
|
const config_2 = require("./config");
|
|
15
15
|
const cms_providers_1 = require("./cms.providers");
|
|
16
16
|
const account_controller_1 = require("./controllers/account.controller");
|
|
17
|
-
const
|
|
17
|
+
const audit_controller_1 = require("./controllers/audit.controller");
|
|
18
18
|
let CmsModule = CmsModule_1 = class CmsModule {
|
|
19
19
|
static async forRoot(options) {
|
|
20
20
|
const providers = (0, cms_providers_1.createCmsProviders)(options);
|
|
@@ -23,6 +23,7 @@ let CmsModule = CmsModule_1 = class CmsModule {
|
|
|
23
23
|
module: CmsModule_1,
|
|
24
24
|
providers,
|
|
25
25
|
controllers: [
|
|
26
|
+
...(!options?.disableAuditController ? [audit_controller_1.AuditController] : []),
|
|
26
27
|
(0, account_controller_1.buildAccountController)(options?.entities?.accountDto),
|
|
27
28
|
],
|
|
28
29
|
exports: [
|
|
@@ -42,9 +43,6 @@ exports.CmsModule = CmsModule = CmsModule_1 = __decorate([
|
|
|
42
43
|
}),
|
|
43
44
|
db_1.DatabaseModule
|
|
44
45
|
],
|
|
45
|
-
providers: [
|
|
46
|
-
account_service_1.AccountService,
|
|
47
|
-
],
|
|
48
46
|
exports: []
|
|
49
47
|
})
|
|
50
48
|
], CmsModule);
|
package/dist/cms.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms.module.js","sourceRoot":"","sources":["../src/cms.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,2CAA8C;AAG9C,yCAAyD;AAEzD,qCAAyC;AACzC,mDAA2E;AAC3E,yEAA0E;AAC1E,
|
|
1
|
+
{"version":3,"file":"cms.module.js","sourceRoot":"","sources":["../src/cms.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,2CAA8C;AAG9C,yCAAyD;AAEzD,qCAAyC;AACzC,mDAA2E;AAC3E,yEAA0E;AAC1E,qEAAiE;AAe1D,IAAM,SAAS,iBAAf,MAAM,SAAS;IAClB,MAAM,CAAC,KAAK,CAAC,OAAO,CAKlB,OAA8H;QAC5H,MAAM,SAAS,GAAG,IAAA,kCAAkB,EAA0D,OAAO,CAAC,CAAC;QACvG,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,GAAG,IAAA,oCAAoB,EAAC,OAAO,CAAC,CAAC;QACvE,OAAO;YACH,MAAM,EAAE,WAAS;YACjB,SAAS;YACT,WAAW,EAAE;gBACT,GAAG,CAAC,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,kCAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC9D,IAAA,2CAAsB,EAAkC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC;aACzF;YACD,OAAO,EAAE;gBACL,GAAG,SAAS;gBACZ,GAAG,UAAK,CAAC,qBAAqB,CAAC,eAAe,CAAC;gBAC/C,GAAG,WAAW;aACjB;SACJ,CAAC;IACN,CAAC;CACJ,CAAA;AAvBY,8BAAS;oBAAT,SAAS;IATrB,IAAA,eAAM,EAAC;QACJ,OAAO,EAAE;YACL,qBAAY,CAAC,OAAO,CAAC;gBACjB,IAAI,EAAE,CAAC,sBAAa,CAAC;aACxB,CAAC;YACF,mBAAc;SACjB;QACD,OAAO,EAAE,EAAE;KACd,CAAC;GACW,SAAS,CAuBrB"}
|
package/dist/cms.providers.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as models from '@trailmix-cms/models';
|
|
|
4
4
|
import { CollectionConfig } from './types/collection-config';
|
|
5
5
|
import { Collection } from 'mongodb';
|
|
6
6
|
import { AccountCollection, FileCollection, TextCollection } from './collections';
|
|
7
|
+
import { AccountService } from './services/account.service';
|
|
7
8
|
export declare function configureCollections(options?: {
|
|
8
9
|
features?: {
|
|
9
10
|
file?: boolean;
|
|
@@ -32,7 +33,7 @@ export declare function createCmsProviders<AccountEntity extends models.Account.
|
|
|
32
33
|
file?: boolean;
|
|
33
34
|
text?: boolean;
|
|
34
35
|
};
|
|
35
|
-
}): (typeof AccountCollection | typeof FileCollection | typeof TextCollection | {
|
|
36
|
+
}): (typeof AccountCollection | typeof FileCollection | typeof TextCollection | typeof AccountService | {
|
|
36
37
|
provide: string;
|
|
37
38
|
useFactory: (databaseService: import("@trailmix-cms/db").DatabaseService) => Promise<Collection<import("bson").Document>>;
|
|
38
39
|
inject: (typeof import("@trailmix-cms/db").DatabaseService)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms.providers.d.ts","sourceRoot":"","sources":["../src/cms.providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC9B,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAI/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"cms.providers.d.ts","sourceRoot":"","sources":["../src/cms.providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC9B,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAI/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,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U,CAAC,EAAE,gBAAgB,CAAC;QAC9B,UAAU,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC,CAAC;QAC3D,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QAClE,UAAU,CAAC,EAAE,gBAAgB,CAAC;KACjC,CAAC;IACF,QAAQ,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,IAAI,CAAC,EAAE,OAAO,CAAC;KAClB,CAAA;CACJ;;;;;;;;;;;;;;;2BAhBmC,UAAU,CAAC,aAAa,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;wBAG3C,aAAa,KAAK,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAGrC,UAAU,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;2BAGxC,UAAU,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC;;;;KA2ExE"}
|
package/dist/cms.providers.js
CHANGED
|
@@ -40,6 +40,7 @@ const constants_1 = require("./constants");
|
|
|
40
40
|
const constants_2 = require("./constants");
|
|
41
41
|
const db_1 = require("@trailmix-cms/db");
|
|
42
42
|
const collections_1 = require("./collections");
|
|
43
|
+
const account_service_1 = require("./services/account.service");
|
|
43
44
|
function configureCollections(options) {
|
|
44
45
|
return {
|
|
45
46
|
collectionNames: [
|
|
@@ -64,6 +65,9 @@ function createCmsProviders(options) {
|
|
|
64
65
|
disableDefaultIndexes: false
|
|
65
66
|
};
|
|
66
67
|
return [
|
|
68
|
+
// Services
|
|
69
|
+
account_service_1.AccountService,
|
|
70
|
+
// Collections
|
|
67
71
|
...mongodbCollectionProviders,
|
|
68
72
|
// Account
|
|
69
73
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms.providers.js","sourceRoot":"","sources":["../src/cms.providers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"cms.providers.js","sourceRoot":"","sources":["../src/cms.providers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,oDAkBC;AAED,gDA4FC;AA1HD,6DAA+C;AAC/C,2CAA+C;AAC/C,2CAAgD;AAChD,yCAAqD;AAIrD,+CAAkF;AAClF,gEAA4D;AAE5D,SAAgB,oBAAoB,CAAC,OAKpC;IACG,OAAO;QACH,eAAe,EAAE;YACb,6BAAiB,CAAC,OAAO;YACzB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,6BAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,6BAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/D;QACD,WAAW,EAAE;YACT,+BAAiB;YACjB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,4BAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACpD,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,4BAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACvD;KACJ,CAAA;AACL,CAAC;AAED,SAAgB,kBAAkB,CAKhC,OAmBD;IACG,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC;QAC7C,6BAAiB,CAAC,OAAO;QACzB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,6BAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5D,GAAG,CAAC,OA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EAAE,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY;aACtE;YACD;gBACI,OAAO,EAAE,4BAAgB,CAAC,0BAA0B;gBACpD,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,UAAkC,EAAE,EAAE,GAAG,CAAC,CAAC;aAChG;YACD;gBACI,OAAO,EAAE,4BAAgB,CAAC,2BAA2B;gBACrD,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,IAAI,uBAAuB;aACrE;SACJ,CAAC,CAAC,CAAC,EAAE,CAAC;QACP,OAAO;QACP,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;YAC1B;gBACI,OAAO,EAAE,4BAAgB,CAAC,2BAA2B;gBACrD,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY;aACtE;YACD;gBACI,OAAO,EAAE,4BAAgB,CAAC,0BAA0B;gBACpD,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,UAAkC,EAAE,EAAE,GAAG,CAAC,CAAC;aAChG;YACD;gBACI,OAAO,EAAE,4BAAgB,CAAC,2BAA2B;gBACrD,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,IAAI,uBAAuB;aACrE;SACJ,CAAC,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC,WAAW;KAC/C,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DatabaseService, Collections } from '@trailmix-cms/db';
|
|
2
|
+
import * as dto from '../dto/audit.dto';
|
|
3
|
+
export declare class AuditController {
|
|
4
|
+
private readonly auditCollection;
|
|
5
|
+
private readonly databaseService;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(auditCollection: Collections.AuditCollection, databaseService: DatabaseService);
|
|
8
|
+
getAuditRecord(type: string, id: string): Promise<dto.AuditListResponseDto>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=audit.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/audit.controller.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAGxC,qBAGa,eAAe;IAIpB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAJpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;gBAGtC,eAAe,EAAE,WAAW,CAAC,eAAe,EAC5C,eAAe,EAAE,eAAe;IAY/C,cAAc,CACD,IAAI,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,GACxB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;CAoBvC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
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 AuditController_1;
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.AuditController = 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 db_1 = require("@trailmix-cms/db");
|
|
55
|
+
const dto = __importStar(require("../dto/audit.dto"));
|
|
56
|
+
const utils_1 = require("@trailmix-cms/utils");
|
|
57
|
+
let AuditController = AuditController_1 = class AuditController {
|
|
58
|
+
auditCollection;
|
|
59
|
+
databaseService;
|
|
60
|
+
logger = new common_1.Logger(AuditController_1.name);
|
|
61
|
+
constructor(auditCollection, databaseService) {
|
|
62
|
+
this.auditCollection = auditCollection;
|
|
63
|
+
this.databaseService = databaseService;
|
|
64
|
+
}
|
|
65
|
+
async getAuditRecord(type, id) {
|
|
66
|
+
this.logger.log(`Getting audit history for entity type: ${type} and entity ID: ${id}`);
|
|
67
|
+
// Check if the collection type exists in MongoDB
|
|
68
|
+
const collections = await this.databaseService.db.listCollections().toArray();
|
|
69
|
+
const collectionNames = collections.map(c => c.name);
|
|
70
|
+
if (!collectionNames.includes(type)) {
|
|
71
|
+
this.logger.warn(`Collection type '${type}' does not exist.`);
|
|
72
|
+
}
|
|
73
|
+
const entityId = (0, utils_1.validateObjectId)(id, { type: 'param', data: 'id' });
|
|
74
|
+
const result = await this.auditCollection.find({
|
|
75
|
+
entity_type: type,
|
|
76
|
+
entity_id: entityId
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
items: result,
|
|
80
|
+
count: result.length,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
exports.AuditController = AuditController;
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, common_1.Get)(':type/:id'),
|
|
87
|
+
(0, swagger_1.ApiParam)({ name: 'type', description: 'Entity type' }),
|
|
88
|
+
(0, swagger_1.ApiParam)({ name: 'id', description: 'Entity ID' }),
|
|
89
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get audit history for a record' }),
|
|
90
|
+
(0, swagger_1.ApiOkResponse)({
|
|
91
|
+
description: 'Audit record found.',
|
|
92
|
+
type: dto.AuditListResponseDto,
|
|
93
|
+
}),
|
|
94
|
+
(0, swagger_1.ApiNotFoundResponse)({ description: 'Audit record not found.' }),
|
|
95
|
+
__param(0, (0, common_1.Param)('type')),
|
|
96
|
+
__param(1, (0, common_1.Param)('id')),
|
|
97
|
+
__metadata("design:type", Function),
|
|
98
|
+
__metadata("design:paramtypes", [String, String]),
|
|
99
|
+
__metadata("design:returntype", Promise)
|
|
100
|
+
], AuditController.prototype, "getAuditRecord", null);
|
|
101
|
+
exports.AuditController = AuditController = AuditController_1 = __decorate([
|
|
102
|
+
(0, auth_decorator_1.Auth)({ roles: [models_1.Role.Admin] }),
|
|
103
|
+
(0, swagger_1.ApiTags)('audit'),
|
|
104
|
+
(0, common_1.Controller)('audit'),
|
|
105
|
+
__metadata("design:paramtypes", [db_1.Collections.AuditCollection, db_1.DatabaseService])
|
|
106
|
+
], AuditController);
|
|
107
|
+
//# sourceMappingURL=audit.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.controller.js","sourceRoot":"","sources":["../../src/controllers/audit.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAqF;AACrF,6CAAsG;AAGtG,iEAAoD;AACpD,iDAA4C;AAC5C,yCAAgE;AAEhE,sDAAwC;AACxC,+CAAuD;AAKhD,IAAM,eAAe,uBAArB,MAAM,eAAe;IAIH;IACA;IAJJ,MAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;IAE3D,YACqB,eAA4C,EAC5C,eAAgC;QADhC,oBAAe,GAAf,eAAe,CAA6B;QAC5C,oBAAe,GAAf,eAAe,CAAiB;IACjD,CAAC;IAWC,AAAN,KAAK,CAAC,cAAc,CACD,IAAY,EACd,EAAU;QAEv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6BAAmB,EAAC,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IAE3D,WAAA,IAAA,cAAK,EAAC,MAAM,CAAC,CAAA;IACb,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;qDAoBf;0BAvCQ,eAAe;IAH3B,IAAA,qBAAI,EAAC,EAAE,KAAK,EAAE,CAAC,aAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IAC7B,IAAA,iBAAO,EAAC,OAAO,CAAC;IAChB,IAAA,mBAAU,EAAC,OAAO,CAAC;qCAKsB,gBAAW,CAAC,eAAe,EAC3B,oBAAe;GAL5C,eAAe,CAwC3B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AuditListResponseSchema: z.ZodObject<{
|
|
3
|
+
items: z.ZodArray<z.ZodObject<{
|
|
4
|
+
_id: z.ZodCodec<z.ZodString, z.ZodCustom<import("bson").ObjectId, import("bson").ObjectId>>;
|
|
5
|
+
created_at: z.ZodCodec<z.ZodISODateTime, z.ZodDate>;
|
|
6
|
+
updated_at: z.ZodOptional<z.ZodCodec<z.ZodISODateTime, z.ZodDate>>;
|
|
7
|
+
entity_id: z.ZodCodec<z.ZodString, z.ZodCustom<import("bson").ObjectId, import("bson").ObjectId>>;
|
|
8
|
+
entity_type: z.ZodString;
|
|
9
|
+
action: z.ZodEnum<{
|
|
10
|
+
create: "create";
|
|
11
|
+
update: "update";
|
|
12
|
+
delete: "delete";
|
|
13
|
+
}>;
|
|
14
|
+
context: z.ZodObject<{
|
|
15
|
+
account_id: z.ZodOptional<z.ZodCodec<z.ZodString, z.ZodCustom<import("bson").ObjectId, import("bson").ObjectId>>>;
|
|
16
|
+
anonymous: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
system: z.ZodBoolean;
|
|
18
|
+
source: z.ZodOptional<z.ZodString>;
|
|
19
|
+
message: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
count: z.ZodNumber;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
declare const AuditListResponseDto_base: import("nestjs-zod").ZodDto<z.ZodObject<{
|
|
25
|
+
items: z.ZodArray<z.ZodObject<{
|
|
26
|
+
_id: z.ZodCodec<z.ZodString, z.ZodCustom<import("bson").ObjectId, import("bson").ObjectId>>;
|
|
27
|
+
created_at: z.ZodCodec<z.ZodISODateTime, z.ZodDate>;
|
|
28
|
+
updated_at: z.ZodOptional<z.ZodCodec<z.ZodISODateTime, z.ZodDate>>;
|
|
29
|
+
entity_id: z.ZodCodec<z.ZodString, z.ZodCustom<import("bson").ObjectId, import("bson").ObjectId>>;
|
|
30
|
+
entity_type: z.ZodString;
|
|
31
|
+
action: z.ZodEnum<{
|
|
32
|
+
create: "create";
|
|
33
|
+
update: "update";
|
|
34
|
+
delete: "delete";
|
|
35
|
+
}>;
|
|
36
|
+
context: z.ZodObject<{
|
|
37
|
+
account_id: z.ZodOptional<z.ZodCodec<z.ZodString, z.ZodCustom<import("bson").ObjectId, import("bson").ObjectId>>>;
|
|
38
|
+
anonymous: z.ZodOptional<z.ZodBoolean>;
|
|
39
|
+
system: z.ZodBoolean;
|
|
40
|
+
source: z.ZodOptional<z.ZodString>;
|
|
41
|
+
message: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
count: z.ZodNumber;
|
|
45
|
+
}, z.core.$strip>> & {
|
|
46
|
+
io: "input";
|
|
47
|
+
};
|
|
48
|
+
export declare class AuditListResponseDto extends AuditListResponseDto_base {
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=audit.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.dto.d.ts","sourceRoot":"","sources":["../../src/dto/audit.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;iBAGlC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AACH,qBAAa,oBAAqB,SAAQ,yBAAqC;CAAI"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuditListResponseDto = exports.AuditListResponseSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const nestjs_zod_1 = require("nestjs-zod");
|
|
6
|
+
const models_1 = require("@trailmix-cms/models");
|
|
7
|
+
exports.AuditListResponseSchema = zod_1.z.object({
|
|
8
|
+
items: zod_1.z.array(models_1.Audit.entitySchema),
|
|
9
|
+
count: zod_1.z.number(),
|
|
10
|
+
});
|
|
11
|
+
class AuditListResponseDto extends (0, nestjs_zod_1.createZodDto)(exports.AuditListResponseSchema) {
|
|
12
|
+
}
|
|
13
|
+
exports.AuditListResponseDto = AuditListResponseDto;
|
|
14
|
+
//# sourceMappingURL=audit.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.dto.js","sourceRoot":"","sources":["../../src/dto/audit.dto.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2CAA0C;AAC1C,iDAA6C;AAEhC,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,cAAK,CAAC,YAAY,CAAC;IAClC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AACH,MAAa,oBAAqB,SAAQ,IAAA,yBAAY,EAAC,+BAAuB,CAAC;CAAI;AAAnF,oDAAmF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trailmix-cms/cms",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
"@nestjs/config": "^4.0.2",
|
|
16
16
|
"@nestjs/core": "^11.1.9",
|
|
17
17
|
"@nestjs/swagger": "^11.2.3",
|
|
18
|
-
"@trailmix-cms/db": "0.0
|
|
19
|
-
"@trailmix-cms/models": "0.0
|
|
20
|
-
"@trailmix-cms/utils": "0.0
|
|
18
|
+
"@trailmix-cms/db": "0.1.0",
|
|
19
|
+
"@trailmix-cms/models": "0.1.0",
|
|
20
|
+
"@trailmix-cms/utils": "0.1.0",
|
|
21
21
|
"cache-manager": "^7.2.5",
|
|
22
22
|
"envalid": "^8.1.1",
|
|
23
23
|
"mongodb": "^7.0.0",
|
|
24
|
+
"nestjs-zod": "^5.0.1",
|
|
24
25
|
"reflect-metadata": "^0.2.2",
|
|
25
26
|
"rxjs": "^7.8.2",
|
|
26
27
|
"zod": "^4.1.12"
|
|
@@ -34,10 +35,11 @@
|
|
|
34
35
|
"@clerk/fastify": "^2.6.8",
|
|
35
36
|
"@nestjs/common": "^11.1.9",
|
|
36
37
|
"@nestjs/config": "^4.0.2",
|
|
37
|
-
"@trailmix-cms/db": "0.0
|
|
38
|
-
"@trailmix-cms/models": "0.0
|
|
39
|
-
"@trailmix-cms/utils": "0.0
|
|
38
|
+
"@trailmix-cms/db": "0.1.0",
|
|
39
|
+
"@trailmix-cms/models": "0.1.0",
|
|
40
|
+
"@trailmix-cms/utils": "0.1.0",
|
|
40
41
|
"mongodb": "^7.0.0",
|
|
42
|
+
"nestjs-zod": "^5.0.1",
|
|
41
43
|
"reflect-metadata": "^0.2.2",
|
|
42
44
|
"rxjs": "^7.8.2",
|
|
43
45
|
"zod": "^4.1.12"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/file.controller.ts"],"names":[],"mappings":""}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { Controller, Get, Res, Param, Query, BadRequestException } from '@nestjs/common';
|
|
3
|
-
// import { ApiOperation, ApiTags, ApiOkResponse, ApiParam, ApiExtraModels } from '@nestjs/swagger';
|
|
4
|
-
// import { FastifyReply } from 'fastify';
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// import * as models from '@trailmix-cms/models';
|
|
7
|
-
// import { StorageService } from '@trailmix-cms/storage';
|
|
8
|
-
// import { Collections } from '@trailmix-cms/db';
|
|
9
|
-
// import { FileCollection } from '../collections/file.collection';
|
|
10
|
-
// import * as dto from '../dto/file';
|
|
11
|
-
// import { FileByIdPipe } from '../pipes/file.pipe';
|
|
12
|
-
// import { FileService } from '../services/file.service';
|
|
13
|
-
// import { Auth } from '../auth/auth.decorator';
|
|
14
|
-
// import { AccountAuthorization, AuthorizationService } from '../services/authorization.service';
|
|
15
|
-
// import { FileDto } from '../dto/file';
|
|
16
|
-
// @ApiExtraModels(FileDto)
|
|
17
|
-
// @Auth({ allowAnonymous: true })
|
|
18
|
-
// @ApiTags('file')
|
|
19
|
-
// @Controller('file')
|
|
20
|
-
// export class FileController {
|
|
21
|
-
// constructor(
|
|
22
|
-
// private readonly storageService: StorageService,
|
|
23
|
-
// private readonly fileService: FileService,
|
|
24
|
-
// private readonly fileCollection: FileCollection,
|
|
25
|
-
// private readonly authorizationService: AuthorizationService,
|
|
26
|
-
// ) { }
|
|
27
|
-
// @Get()
|
|
28
|
-
// @ApiOperation({ summary: 'Get all files' })
|
|
29
|
-
// @ApiOkResponse({ description: 'List of files.', type: dto.FileListResponseDto })
|
|
30
|
-
// async list(
|
|
31
|
-
// @Query() query: dto.FileListQueryDto,
|
|
32
|
-
// @AccountAuthorization() accountAuthorization: AccountAuthorization,
|
|
33
|
-
// ): Promise<dto.FileListResponseDto> {
|
|
34
|
-
// if (!query.guid) {
|
|
35
|
-
// throw new BadRequestException('Guid is required');
|
|
36
|
-
// }
|
|
37
|
-
// const files = await this.fileCollection.find({
|
|
38
|
-
// guid: query.guid,
|
|
39
|
-
// });
|
|
40
|
-
// return {
|
|
41
|
-
// items: files
|
|
42
|
-
// .filter(entity => this.authorizationService.checkAccountAuthorizationOnEntity(accountAuthorization, entity))
|
|
43
|
-
// .map((file: models.File.Entity) => ({
|
|
44
|
-
// ...models.File.entityToDto(file),
|
|
45
|
-
// cdn_url: this.fileService.getCDNUrl(file),
|
|
46
|
-
// direct_url: `/file/${file._id}/download`
|
|
47
|
-
// }))
|
|
48
|
-
// };
|
|
49
|
-
// }
|
|
50
|
-
// @Get(':id')
|
|
51
|
-
// @ApiParam({ name: 'id', type: String })
|
|
52
|
-
// @ApiOperation({ summary: 'Get file by id' })
|
|
53
|
-
// @ApiOkResponse({ description: 'File.', type: dto.FileResponseDto })
|
|
54
|
-
// async get(
|
|
55
|
-
// @Param('id', FileByIdPipe) entity: models.File.Entity,
|
|
56
|
-
// @AccountAuthorization() accountAuthorization: AccountAuthorization,
|
|
57
|
-
// ): Promise<dto.FileResponseDto> {
|
|
58
|
-
// await this.authorizationService.validateAuthorization(accountAuthorization, entity);
|
|
59
|
-
// return {
|
|
60
|
-
// ...models.File.entityToDto(entity),
|
|
61
|
-
// cdn_url: this.fileService.getCDNUrl(entity),
|
|
62
|
-
// direct_url: `/file/${entity._id}/download`
|
|
63
|
-
// };
|
|
64
|
-
// }
|
|
65
|
-
// @Get(':id/download')
|
|
66
|
-
// @ApiParam({ name: 'id', type: String })
|
|
67
|
-
// @ApiOperation({ summary: 'Get file contents by id' })
|
|
68
|
-
// async getRaw(
|
|
69
|
-
// @Param('id', FileByIdPipe) entity: models.File.Entity,
|
|
70
|
-
// @AccountAuthorization() accountAuthorization: AccountAuthorization,
|
|
71
|
-
// @Res() reply: FastifyReply,
|
|
72
|
-
// ) {
|
|
73
|
-
// await this.authorizationService.validateAuthorization(accountAuthorization, entity);
|
|
74
|
-
// reply.header('Content-Type', `application/${entity.file_extension}`);
|
|
75
|
-
// reply.header('Content-disposition', `attachment; filename=${entity.file_name}`);
|
|
76
|
-
// const fileStream = await this.fileService.downloadFile(entity);
|
|
77
|
-
// reply.send(fileStream);
|
|
78
|
-
// }
|
|
79
|
-
// }
|
|
80
|
-
//# sourceMappingURL=file.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.controller.js","sourceRoot":"","sources":["../../src/controllers/file.controller.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,oGAAoG;AACpG,0CAA0C;;AAE1C,kDAAkD;AAClD,0DAA0D;AAC1D,kDAAkD;AAClD,mEAAmE;AAEnE,sCAAsC;AACtC,qDAAqD;AACrD,0DAA0D;AAC1D,iDAAiD;AACjD,kGAAkG;AAClG,yCAAyC;AAEzC,2BAA2B;AAC3B,kCAAkC;AAClC,mBAAmB;AACnB,sBAAsB;AACtB,gCAAgC;AAChC,mBAAmB;AACnB,2DAA2D;AAC3D,qDAAqD;AACrD,2DAA2D;AAC3D,uEAAuE;AACvE,YAAY;AAEZ,aAAa;AACb,kDAAkD;AAClD,uFAAuF;AACvF,kBAAkB;AAClB,gDAAgD;AAChD,8EAA8E;AAC9E,4CAA4C;AAC5C,6BAA6B;AAC7B,iEAAiE;AACjE,YAAY;AAEZ,yDAAyD;AACzD,gCAAgC;AAChC,cAAc;AAEd,mBAAmB;AACnB,2BAA2B;AAC3B,+HAA+H;AAC/H,wDAAwD;AACxD,wDAAwD;AACxD,iEAAiE;AACjE,+DAA+D;AAC/D,sBAAsB;AACtB,aAAa;AACb,QAAQ;AAER,kBAAkB;AAClB,8CAA8C;AAC9C,mDAAmD;AACnD,0EAA0E;AAC1E,iBAAiB;AACjB,iEAAiE;AACjE,8EAA8E;AAC9E,wCAAwC;AACxC,+FAA+F;AAE/F,mBAAmB;AACnB,kDAAkD;AAClD,2DAA2D;AAC3D,yDAAyD;AACzD,aAAa;AACb,QAAQ;AAER,2BAA2B;AAC3B,8CAA8C;AAC9C,4DAA4D;AAC5D,oBAAoB;AACpB,iEAAiE;AACjE,8EAA8E;AAC9E,sCAAsC;AACtC,UAAU;AACV,+FAA+F;AAE/F,gFAAgF;AAChF,2FAA2F;AAE3F,0EAA0E;AAC1E,kCAAkC;AAClC,QAAQ;AACR,IAAI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/text.controller.ts"],"names":[],"mappings":""}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { Controller, Get, Param, Query, BadRequestException, NotFoundException } from '@nestjs/common';
|
|
3
|
-
// import { ApiOperation, ApiTags, ApiOkResponse, ApiParam } from '@nestjs/swagger';
|
|
4
|
-
// import { Collections } from '@trailmix-cms/db';
|
|
5
|
-
// import * as models from '@trailmix-cms/models';
|
|
6
|
-
// import * as dto from '../dto/text';
|
|
7
|
-
// import { TextPipe } from '../pipes/text.pipe';
|
|
8
|
-
// import { Auth } from '../auth/auth.decorator';
|
|
9
|
-
// import { AccountAuthorization, AuthorizationService } from '../services/authorization.service';
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
// @Auth({ allowAnonymous: true })
|
|
12
|
-
// @ApiTags('text')
|
|
13
|
-
// @Controller('text')
|
|
14
|
-
// export class TextController {
|
|
15
|
-
// constructor(
|
|
16
|
-
// private readonly textCollection: Collections.TextCollection,
|
|
17
|
-
// private readonly authorizationService: AuthorizationService,
|
|
18
|
-
// ) { }
|
|
19
|
-
// @Get()
|
|
20
|
-
// @ApiOperation({ summary: 'Search texts by guid' })
|
|
21
|
-
// @ApiOkResponse({ description: 'Texts.', type: dto.TextListResponseDto })
|
|
22
|
-
// async list(
|
|
23
|
-
// @Query() query: dto.TextListQueryDto,
|
|
24
|
-
// @AccountAuthorization() accountAuthorization: AccountAuthorization,
|
|
25
|
-
// ) {
|
|
26
|
-
// if (!query.guid) {
|
|
27
|
-
// throw new BadRequestException('Guid is required');
|
|
28
|
-
// }
|
|
29
|
-
// const texts = await this.textCollection.find({ guid: query.guid });
|
|
30
|
-
// return {
|
|
31
|
-
// items: texts
|
|
32
|
-
// .filter(entity => this.authorizationService.checkAccountAuthorizationOnEntity(accountAuthorization, entity))
|
|
33
|
-
// .map((entity: models.Text.Entity) => models.Text.entityToDto(entity))
|
|
34
|
-
// };
|
|
35
|
-
// }
|
|
36
|
-
// @Get(':id')
|
|
37
|
-
// @ApiParam({ name: 'id', type: String })
|
|
38
|
-
// @ApiOperation({ summary: 'Get text by id' })
|
|
39
|
-
// @ApiOkResponse({ description: 'Text details.', type: dto.TextDto })
|
|
40
|
-
// async get(
|
|
41
|
-
// @Param('id', TextPipe) entity: models.Text.Entity,
|
|
42
|
-
// @AccountAuthorization() accountAuthorization: AccountAuthorization,
|
|
43
|
-
// ) {
|
|
44
|
-
// await this.authorizationService.validateAuthorization(accountAuthorization, entity);
|
|
45
|
-
// return models.Text.entityToDto(entity);
|
|
46
|
-
// }
|
|
47
|
-
// }
|
|
48
|
-
//# sourceMappingURL=text.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.controller.js","sourceRoot":"","sources":["../../src/controllers/text.controller.ts"],"names":[],"mappings":";AAAA,0GAA0G;AAC1G,oFAAoF;AACpF,kDAAkD;AAClD,kDAAkD;AAClD,sCAAsC;AACtC,iDAAiD;AACjD,iDAAiD;AACjD,kGAAkG;;AAElG,kCAAkC;AAClC,mBAAmB;AACnB,sBAAsB;AACtB,gCAAgC;AAChC,mBAAmB;AACnB,uEAAuE;AACvE,uEAAuE;AACvE,YAAY;AAEZ,aAAa;AACb,yDAAyD;AACzD,+EAA+E;AAC/E,kBAAkB;AAClB,gDAAgD;AAChD,8EAA8E;AAC9E,UAAU;AACV,6BAA6B;AAC7B,iEAAiE;AACjE,YAAY;AACZ,8EAA8E;AAE9E,mBAAmB;AACnB,2BAA2B;AAC3B,+HAA+H;AAC/H,wFAAwF;AACxF,aAAa;AACb,QAAQ;AAER,kBAAkB;AAClB,8CAA8C;AAC9C,mDAAmD;AACnD,0EAA0E;AAC1E,iBAAiB;AACjB,6DAA6D;AAC7D,8EAA8E;AAC9E,UAAU;AACV,+FAA+F;AAC/F,kDAAkD;AAClD,QAAQ;AACR,KAAK"}
|