@rafikidota/iroh 0.24.1 → 0.25.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/README.md +48 -5
- package/dist/common/decorators/generic-get-by-id.decorator.js +2 -1
- package/dist/common/decorators/generic-get-by-id.decorator.js.map +1 -1
- package/dist/common/decorators/generic-get.decorator.js +3 -2
- package/dist/common/decorators/generic-get.decorator.js.map +1 -1
- package/dist/common/dto/index.d.ts +3 -0
- package/dist/common/dto/index.js +3 -0
- package/dist/common/dto/index.js.map +1 -1
- package/dist/common/dto/parsed-query-option.dto.d.ts +4 -0
- package/dist/common/dto/parsed-query-option.dto.js +32 -0
- package/dist/common/dto/parsed-query-option.dto.js.map +1 -0
- package/dist/common/dto/parsed-search.dto.d.ts +5 -0
- package/dist/common/dto/parsed-search.dto.js +33 -0
- package/dist/common/dto/parsed-search.dto.js.map +1 -0
- package/dist/common/dto/query-option.dto.d.ts +3 -0
- package/dist/common/dto/query-option.dto.js +30 -0
- package/dist/common/dto/query-option.dto.js.map +1 -0
- package/dist/common/dto/search.dto.d.ts +0 -4
- package/dist/common/dto/search.dto.js +4 -20
- package/dist/common/dto/search.dto.js.map +1 -1
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +1 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/interfaces/crud.controller.d.ts +2 -1
- package/dist/common/interfaces/crud.repository.d.ts +2 -1
- package/dist/common/interfaces/crud.service.d.ts +2 -1
- package/dist/common/loggers/index.d.ts +2 -1
- package/dist/common/loggers/index.js +2 -1
- package/dist/common/loggers/index.js.map +1 -1
- package/dist/common/loggers/notification/index.d.ts +3 -0
- package/dist/common/loggers/notification/index.js +20 -0
- package/dist/common/loggers/notification/index.js.map +1 -0
- package/dist/common/loggers/notification/notification.type.d.ts +8 -0
- package/dist/common/loggers/notification/notification.type.enum.d.ts +6 -0
- package/dist/common/loggers/notification/notification.type.enum.js +10 -0
- package/dist/common/loggers/notification/notification.type.enum.js.map +1 -0
- package/dist/common/loggers/notification/notification.type.js +3 -0
- package/dist/common/loggers/notification/notification.type.js.map +1 -0
- package/dist/common/loggers/notification/notifier.d.ts +11 -0
- package/dist/common/loggers/notification/notifier.js +57 -0
- package/dist/common/loggers/notification/notifier.js.map +1 -0
- package/dist/common/pipes/index.d.ts +1 -0
- package/dist/common/pipes/index.js +1 -0
- package/dist/common/pipes/index.js.map +1 -1
- package/dist/common/pipes/parse-query.pipe.d.ts +10 -0
- package/dist/common/pipes/parse-query.pipe.js +21 -0
- package/dist/common/pipes/parse-query.pipe.js.map +1 -0
- package/dist/common/types/find-by-id-params.d.ts +3 -0
- package/dist/common/types/find-by-id-params.js +3 -0
- package/dist/common/types/find-by-id-params.js.map +1 -0
- package/dist/common/types/index.d.ts +1 -0
- package/dist/common/types/index.js +18 -0
- package/dist/common/types/index.js.map +1 -0
- package/dist/core/infra/iroh.repository.d.ts +4 -2
- package/dist/core/infra/iroh.repository.js +44 -39
- package/dist/core/infra/iroh.repository.js.map +1 -1
- package/dist/core/iroh.controller.d.ts +2 -1
- package/dist/core/iroh.controller.js +9 -8
- package/dist/core/iroh.controller.js.map +1 -1
- package/dist/core/iroh.service.d.ts +3 -1
- package/dist/core/iroh.service.js +28 -43
- package/dist/core/iroh.service.js.map +1 -1
- package/dist/schematics/crud/files/ts/__name__.controller.ts +46 -3
- package/dist/schematics/crud/files/ts/infra/__name__.mapper.ts +1 -1
- package/dist/security/modules/device/device.controller.d.ts +2 -10
- package/dist/security/modules/device/device.controller.js +4 -97
- package/dist/security/modules/device/device.controller.js.map +1 -1
- package/dist/security/modules/device/device.service.d.ts +2 -19
- package/dist/security/modules/device/device.service.js +3 -154
- package/dist/security/modules/device/device.service.js.map +1 -1
- package/dist/security/modules/permission/permission.controller.d.ts +2 -10
- package/dist/security/modules/permission/permission.controller.js +4 -97
- package/dist/security/modules/permission/permission.controller.js.map +1 -1
- package/dist/security/modules/permission/permission.service.d.ts +2 -19
- package/dist/security/modules/permission/permission.service.js +3 -154
- package/dist/security/modules/permission/permission.service.js.map +1 -1
- package/dist/security/modules/role/role.controller.d.ts +2 -10
- package/dist/security/modules/role/role.controller.js +4 -97
- package/dist/security/modules/role/role.controller.js.map +1 -1
- package/dist/security/modules/role/role.service.d.ts +2 -19
- package/dist/security/modules/role/role.service.js +3 -154
- package/dist/security/modules/role/role.service.js.map +1 -1
- package/dist/security/modules/user/user.controller.d.ts +2 -10
- package/dist/security/modules/user/user.controller.js +4 -97
- package/dist/security/modules/user/user.controller.js.map +1 -1
- package/dist/security/modules/user/user.service.d.ts +3 -17
- package/dist/security/modules/user/user.service.js +7 -123
- package/dist/security/modules/user/user.service.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ParseQueryPipe = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const query_parser_1 = require("../parsers/query.parser");
|
|
12
|
+
let ParseQueryPipe = class ParseQueryPipe {
|
|
13
|
+
transform(query) {
|
|
14
|
+
return query_parser_1.QueryParser.parse(query);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.ParseQueryPipe = ParseQueryPipe;
|
|
18
|
+
exports.ParseQueryPipe = ParseQueryPipe = __decorate([
|
|
19
|
+
(0, common_1.Injectable)()
|
|
20
|
+
], ParseQueryPipe);
|
|
21
|
+
//# sourceMappingURL=parse-query.pipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-query.pipe.js","sourceRoot":"","sources":["../../../src/common/pipes/parse-query.pipe.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAG5C,0DAAsD;AAG/C,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,SAAS,CAAC,KAAgB;QACxB,OAAO,0BAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACF,CAAA;AAJY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;GACA,cAAc,CAI1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-by-id-params.js","sourceRoot":"","sources":["../../../src/common/types/find-by-id-params.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './find-by-id-params';
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./find-by-id-params"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC"}
|
|
@@ -12,6 +12,7 @@ import { IEntityMapper } from '../../common';
|
|
|
12
12
|
import { IGenericRepository } from '../../common';
|
|
13
13
|
import { ParsedSearchDto } from '../../common';
|
|
14
14
|
import { QueryBuilder } from '../../common';
|
|
15
|
+
import { FindByIdParam } from '../../common/types/find-by-id-params';
|
|
15
16
|
export declare abstract class IrohRepository<M extends IEntityMapper<T, D, V>, T extends GenericPersistence = ReturnType<M['DomainToPersistence']>, D extends GenericDomain = ReturnType<M['PersistenceToDomain']>, V extends GenericView = ReturnType<M['DomainToView']>> implements IGenericRepository<T, D, V> {
|
|
16
17
|
repository: Repository<T>;
|
|
17
18
|
readonly logger: TimestampLogger;
|
|
@@ -24,8 +25,9 @@ export declare abstract class IrohRepository<M extends IEntityMapper<T, D, V>, T
|
|
|
24
25
|
saveList(domains: D[]): Promise<D[]>;
|
|
25
26
|
create(domain: D): Promise<D>;
|
|
26
27
|
paginate(query?: ParsedSearchDto<T>): Promise<D[]>;
|
|
28
|
+
private find;
|
|
27
29
|
findAll(): Promise<D[]>;
|
|
28
|
-
findById(id: string,
|
|
30
|
+
findById(id: string, params?: FindByIdParam<T>): Promise<D>;
|
|
29
31
|
findOne(query: FindOneOptions<T>, options?: LoggerOptions): Promise<D>;
|
|
30
32
|
update(id: string, updateDto: Partial<D>): Promise<D>;
|
|
31
33
|
remove(id: string): Promise<D>;
|
|
@@ -33,5 +35,5 @@ export declare abstract class IrohRepository<M extends IEntityMapper<T, D, V>, T
|
|
|
33
35
|
getMetadata(): EntityMetadata;
|
|
34
36
|
private prepare;
|
|
35
37
|
setTransactionalRepository(entityManager: EntityManager): void;
|
|
36
|
-
private
|
|
38
|
+
private notify;
|
|
37
39
|
}
|
|
@@ -17,6 +17,8 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
17
17
|
const typeorm_2 = require("typeorm");
|
|
18
18
|
const common_1 = require("../../common");
|
|
19
19
|
const common_2 = require("../../common");
|
|
20
|
+
const notification_1 = require("../../common/loggers/notification");
|
|
21
|
+
const notification_2 = require("../../common/loggers/notification");
|
|
20
22
|
let IrohRepository = class IrohRepository {
|
|
21
23
|
constructor(repository) {
|
|
22
24
|
this.repository = repository;
|
|
@@ -54,6 +56,15 @@ let IrohRepository = class IrohRepository {
|
|
|
54
56
|
}
|
|
55
57
|
async paginate(query = {}) {
|
|
56
58
|
this.logger.start();
|
|
59
|
+
const persistences = await this.find(query);
|
|
60
|
+
const domains = persistences.map((p) => this.mapper.PersistenceToDomain(p));
|
|
61
|
+
this.notify({
|
|
62
|
+
count: persistences.length,
|
|
63
|
+
type: notification_2.NoficationTypeEnum.PAGINATION,
|
|
64
|
+
});
|
|
65
|
+
return domains;
|
|
66
|
+
}
|
|
67
|
+
async find(query = {}) {
|
|
57
68
|
const options = {};
|
|
58
69
|
const { limit, page, offset } = query;
|
|
59
70
|
if (limit) {
|
|
@@ -70,50 +81,55 @@ let IrohRepository = class IrohRepository {
|
|
|
70
81
|
this.builder.addOptions(query.options);
|
|
71
82
|
this.builder.addLimit(options.take);
|
|
72
83
|
this.builder.addOffset(options.skip);
|
|
73
|
-
|
|
74
|
-
this.logCount(data.length);
|
|
75
|
-
return data.map((p) => this.mapper.PersistenceToDomain(p));
|
|
84
|
+
return await this.builder.getMany();
|
|
76
85
|
}
|
|
77
|
-
|
|
78
|
-
const domains = persistenceList.map((p) => this.mapper.PersistenceToDomain(p));
|
|
79
|
-
this.logCount(persistenceList.length);
|
|
80
|
-
return domains;
|
|
86
|
+
return await this.repository.find(options);
|
|
81
87
|
}
|
|
82
88
|
async findAll() {
|
|
83
89
|
this.logger.start();
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
const persistences = await this.repository.find();
|
|
91
|
+
this.notify({
|
|
92
|
+
count: persistences.length,
|
|
93
|
+
type: notification_2.NoficationTypeEnum.PAGINATION,
|
|
94
|
+
});
|
|
95
|
+
return persistences.map((p) => this.mapper.PersistenceToDomain(p));
|
|
88
96
|
}
|
|
89
|
-
async findById(id,
|
|
97
|
+
async findById(id, params = { logging: false }) {
|
|
90
98
|
this.logger.start();
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
if (params.options) {
|
|
100
|
+
this.prepare();
|
|
101
|
+
this.builder.addOptions(params.options);
|
|
102
|
+
const data = await this.builder.getOne();
|
|
103
|
+
return this.mapper.PersistenceToDomain(data);
|
|
104
|
+
}
|
|
105
|
+
const find = { where: { id } };
|
|
106
|
+
const persistence = await this.repository.findOne(find);
|
|
94
107
|
if (!persistence) {
|
|
95
|
-
this.
|
|
108
|
+
this.notify({ found: false, type: notification_2.NoficationTypeEnum.ID });
|
|
96
109
|
return null;
|
|
97
110
|
}
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
111
|
+
if (params.logging) {
|
|
112
|
+
this.notify({
|
|
113
|
+
found: false,
|
|
114
|
+
type: notification_2.NoficationTypeEnum.ID,
|
|
115
|
+
id: persistence.id,
|
|
116
|
+
});
|
|
102
117
|
}
|
|
103
118
|
return this.mapper.PersistenceToDomain(persistence);
|
|
104
119
|
}
|
|
105
120
|
async findOne(query, options = { logging: false }) {
|
|
106
121
|
this.logger.start();
|
|
107
|
-
const { name } = this.repository.metadata;
|
|
108
122
|
const persistence = await this.repository.findOne(query);
|
|
109
123
|
if (!persistence) {
|
|
110
|
-
this.
|
|
124
|
+
this.notify({ found: false, type: notification_2.NoficationTypeEnum.QUERY });
|
|
111
125
|
return null;
|
|
112
126
|
}
|
|
113
127
|
if (options.logging) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
128
|
+
this.notify({
|
|
129
|
+
found: false,
|
|
130
|
+
type: notification_2.NoficationTypeEnum.QUERY,
|
|
131
|
+
id: persistence.id,
|
|
132
|
+
});
|
|
117
133
|
}
|
|
118
134
|
return this.mapper.PersistenceToDomain(persistence);
|
|
119
135
|
}
|
|
@@ -158,20 +174,9 @@ let IrohRepository = class IrohRepository {
|
|
|
158
174
|
this.repository = entityManager.getRepository(this.Entity);
|
|
159
175
|
this.logger.setContext(this.constructor.name);
|
|
160
176
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
this.logger.log(`No entities found`);
|
|
165
|
-
break;
|
|
166
|
-
case 1:
|
|
167
|
-
this.logger.log(`Successfully retrieved one entity`);
|
|
168
|
-
break;
|
|
169
|
-
default: {
|
|
170
|
-
const message = `Successfully retrieved ${count} entities`;
|
|
171
|
-
this.logger.log(message);
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
177
|
+
notify(notification) {
|
|
178
|
+
const notifier = new notification_1.NotifierLogger(this.logger);
|
|
179
|
+
notifier.notify(notification);
|
|
175
180
|
}
|
|
176
181
|
};
|
|
177
182
|
exports.IrohRepository = IrohRepository;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iroh.repository.js","sourceRoot":"","sources":["../../../src/core/infra/iroh.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,6CAAmD;AAInD,qCAAqC;AAErC,yCAA+C;AAS/C,yCAA4C;AAE5C,IAAsB,cAAc,GAApC,MAAsB,cAAc;IAalC,YAIE,UAAgC;QAAzB,eAAU,GAAV,UAAU,CAAe;QAN1B,UAAK,GAAW,OAAO,CAAC;QAQ9B,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAe,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAAS;QACzB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,MAAM,WAAW,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Ac,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;CACF,CAAA;AAvMqB,wCAAc;yBAAd,cAAc;IAc/B,WAAA,IAAA,0BAAgB,EAAC,GAAY,EAAE;QAC9B,OAAO,EAAa,CAAC;IACvB,CAAC,CAAC,CAAA;qCACiB,oBAAU;GAjBX,cAAc,CAuMnC"}
|
|
@@ -2,6 +2,7 @@ import type { IEntityMapper } from '../common/interfaces';
|
|
|
2
2
|
import type { IGenericController } from '../common/interfaces';
|
|
3
3
|
import type { IGenericService } from '../common/interfaces';
|
|
4
4
|
import { SearchDto } from '../common/dto';
|
|
5
|
+
import { QueryOptionDto } from '../common/dto';
|
|
5
6
|
import { GenericPersistence } from './infra';
|
|
6
7
|
import { GenericDomain } from './domain';
|
|
7
8
|
import { IUpdatableDomain } from './domain';
|
|
@@ -12,7 +13,7 @@ export declare abstract class IrohController<M extends IEntityMapper<T, D, V>, T
|
|
|
12
13
|
constructor(service: IGenericService<T, D, V, DTO>);
|
|
13
14
|
create(body: DTO): Promise<V>;
|
|
14
15
|
paginate(query: SearchDto): Promise<V[]>;
|
|
15
|
-
findById(id: string): Promise<V>;
|
|
16
|
+
findById(id: string, query: QueryOptionDto): Promise<V>;
|
|
16
17
|
update(id: string, body: Partial<DTO>): Promise<V>;
|
|
17
18
|
remove(id: string): Promise<V>;
|
|
18
19
|
mapView(domain: D): V;
|
|
@@ -22,8 +22,9 @@ const common_6 = require("@nestjs/common");
|
|
|
22
22
|
const interceptors_1 = require("../common/interceptors");
|
|
23
23
|
const filters_1 = require("../common/filters");
|
|
24
24
|
const response_handler_1 = require("./app/response-handler");
|
|
25
|
-
const query_parser_1 = require("../common/parsers/query.parser");
|
|
26
25
|
const dto_1 = require("../common/dto");
|
|
26
|
+
const dto_2 = require("../common/dto");
|
|
27
|
+
const parse_query_pipe_1 = require("../common/pipes/parse-query.pipe");
|
|
27
28
|
let IrohController = class IrohController {
|
|
28
29
|
constructor(service) {
|
|
29
30
|
this.service = service;
|
|
@@ -35,16 +36,15 @@ let IrohController = class IrohController {
|
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
async paginate(query) {
|
|
38
|
-
const parsedQuery = query_parser_1.QueryParser.parse(query);
|
|
39
39
|
return response_handler_1.ResponseHandler.async({
|
|
40
|
-
promise: this.service.paginate(
|
|
40
|
+
promise: this.service.paginate(query),
|
|
41
41
|
mapper: this.mapViewList.bind(this),
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
async findById(id) {
|
|
45
|
-
const
|
|
44
|
+
async findById(id, query) {
|
|
45
|
+
const params = { ...query, logging: true };
|
|
46
46
|
return response_handler_1.ResponseHandler.async({
|
|
47
|
-
promise: this.service.findById(id,
|
|
47
|
+
promise: this.service.findById(id, params),
|
|
48
48
|
mapper: this.mapView.bind(this),
|
|
49
49
|
});
|
|
50
50
|
}
|
|
@@ -75,15 +75,16 @@ __decorate([
|
|
|
75
75
|
__metadata("design:returntype", Promise)
|
|
76
76
|
], IrohController.prototype, "create", null);
|
|
77
77
|
__decorate([
|
|
78
|
-
__param(0, (0, common_2.Query)()),
|
|
78
|
+
__param(0, (0, common_2.Query)(parse_query_pipe_1.ParseQueryPipe)),
|
|
79
79
|
__metadata("design:type", Function),
|
|
80
80
|
__metadata("design:paramtypes", [dto_1.SearchDto]),
|
|
81
81
|
__metadata("design:returntype", Promise)
|
|
82
82
|
], IrohController.prototype, "paginate", null);
|
|
83
83
|
__decorate([
|
|
84
84
|
__param(0, (0, common_3.Param)('id', common_4.ParseUUIDPipe)),
|
|
85
|
+
__param(1, (0, common_2.Query)(parse_query_pipe_1.ParseQueryPipe)),
|
|
85
86
|
__metadata("design:type", Function),
|
|
86
|
-
__metadata("design:paramtypes", [String]),
|
|
87
|
+
__metadata("design:paramtypes", [String, dto_2.QueryOptionDto]),
|
|
87
88
|
__metadata("design:returntype", Promise)
|
|
88
89
|
], IrohController.prototype, "findById", null);
|
|
89
90
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iroh.controller.js","sourceRoot":"","sources":["../../src/core/iroh.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsC;AACtC,2CAAuC;AACvC,2CAAuC;AACvC,2CAA+C;AAC/C,2CAAiD;AACjD,2CAA4C;AAC5C,yDAA4D;AAC5D,+CAAwD;AACxD,6DAAyD;AAIzD,
|
|
1
|
+
{"version":3,"file":"iroh.controller.js","sourceRoot":"","sources":["../../src/core/iroh.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsC;AACtC,2CAAuC;AACvC,2CAAuC;AACvC,2CAA+C;AAC/C,2CAAiD;AACjD,2CAA4C;AAC5C,yDAA4D;AAC5D,+CAAwD;AACxD,6DAAyD;AAIzD,uCAA0C;AAC1C,uCAA+C;AAM/C,uEAAkE;AAK3D,IAAe,cAAc,GAA7B,MAAe,cAAc;IASlC,YAAqB,OAAsC;QAAtC,YAAO,GAAP,OAAO,CAA+B;IAAG,CAAC;IAEzD,AAAN,KAAK,CAAC,MAAM,CAAS,IAAS;QAC5B,OAAO,kCAAe,CAAC,KAAK,CAAC;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;YAClC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;SAChC,CAAC,CAAC;IACL,CAAC;IAEK,AAAN,KAAK,CAAC,QAAQ,CAAwB,KAAgB;QACpD,OAAO,kCAAe,CAAC,KAAK,CAAC;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;YACrC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;SACpC,CAAC,CAAC;IACL,CAAC;IAEK,AAAN,KAAK,CAAC,QAAQ,CACgB,EAAU,EACf,KAAqB;QAE5C,MA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,eAAS;;8CAKrD;AAEK;IACH,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,sBAAa,CAAC,CAAA;IAC1B,WAAA,IAAA,cAAK,EAAC,iCAAc,CAAC,CAAA;;6CAAQ,oBAAc;;8CAO7C;AAEK;IACH,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,sBAAa,CAAC,CAAA;IAC1B,WAAA,IAAA,aAAI,GAAE,CAAA;;;;4CAMR;AAEK;IAAQ,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,sBAAa,CAAC,CAAA;;;;4CAKvC;yBAnDmB,cAAc;IAFnC,IAAA,mBAAU,EAAC,6BAAmB,CAAC;IAC/B,IAAA,wBAAe,EAAC,iCAAkB,CAAC;;GACd,cAAc,CA4DnC"}
|
|
@@ -12,6 +12,7 @@ import type { IGenericRepository } from '../common';
|
|
|
12
12
|
import type { IEntityMapper } from '../common';
|
|
13
13
|
import { ParsedSearchDto } from '../common';
|
|
14
14
|
import { Result } from './app/result';
|
|
15
|
+
import { FindByIdParam } from '../common/types/find-by-id-params';
|
|
15
16
|
export declare abstract class IrohService<M extends IEntityMapper<T, D, V>, T extends GenericPersistence = ReturnType<M['DomainToPersistence']>, D extends GenericDomain = ReturnType<M['PersistenceToDomain']> & IUpdatableDomain<ReturnType<M['PersistenceToDomain']>>, V extends GenericView = ReturnType<M['DomainToView']>, DTO extends DtoMapper<D, DTO> = DtoMapper<D>> implements IGenericService<T, D, V, DTO> {
|
|
16
17
|
readonly repository: IGenericRepository<T, D, V>;
|
|
17
18
|
readonly logger: TimestampLogger;
|
|
@@ -21,9 +22,10 @@ export declare abstract class IrohService<M extends IEntityMapper<T, D, V>, T ex
|
|
|
21
22
|
create(dto: DTO): Promise<Result<D>>;
|
|
22
23
|
paginate(query: ParsedSearchDto<T>): Promise<Result<D[]>>;
|
|
23
24
|
findAll(): Promise<Result<D[]>>;
|
|
24
|
-
findById(id: string,
|
|
25
|
+
findById(id: string, params?: FindByIdParam<T>): Promise<Result<D>>;
|
|
25
26
|
findOne(query: FindOneOptions<T>, options?: LoggerOptions): Promise<Result<D>>;
|
|
26
27
|
update(id: string, updateDto: Partial<DTO>): Promise<Result<D>>;
|
|
27
28
|
remove(id: string): Promise<Result<D>>;
|
|
28
29
|
getRepository(): IGenericRepository<T, D, V>;
|
|
30
|
+
private notify;
|
|
29
31
|
}
|
|
@@ -5,6 +5,8 @@ const common_1 = require("@nestjs/common");
|
|
|
5
5
|
const common_2 = require("../common");
|
|
6
6
|
const common_3 = require("../common");
|
|
7
7
|
const result_1 = require("./app/result");
|
|
8
|
+
const notifier_1 = require("../common/loggers/notification/notifier");
|
|
9
|
+
const notification_type_enum_1 = require("../common/loggers/notification/notification.type.enum");
|
|
8
10
|
class IrohService {
|
|
9
11
|
constructor(repository) {
|
|
10
12
|
this.repository = repository;
|
|
@@ -29,22 +31,10 @@ class IrohService {
|
|
|
29
31
|
try {
|
|
30
32
|
this.logger.start();
|
|
31
33
|
const domains = await this.repository.paginate(query);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return result_1.Result.Ok([]);
|
|
37
|
-
case 1: {
|
|
38
|
-
const message = `Successfully retrieved one entity with pagination`;
|
|
39
|
-
this.logger.log(message);
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
default: {
|
|
43
|
-
const message = `Successfully retrieved ${count} entities with pagination`;
|
|
44
|
-
this.logger.log(message);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
34
|
+
this.notify({
|
|
35
|
+
count: domains.length,
|
|
36
|
+
type: notification_type_enum_1.NoficationTypeEnum.PAGINATION,
|
|
37
|
+
});
|
|
48
38
|
return result_1.Result.Ok(domains);
|
|
49
39
|
}
|
|
50
40
|
catch (error) {
|
|
@@ -54,41 +44,31 @@ class IrohService {
|
|
|
54
44
|
async findAll() {
|
|
55
45
|
try {
|
|
56
46
|
const domains = await this.repository.findAll();
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return result_1.Result.Ok([]);
|
|
62
|
-
case 1: {
|
|
63
|
-
const message = `Successfully retrieved one entity with pagination`;
|
|
64
|
-
this.logger.log(message);
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
default: {
|
|
68
|
-
const message = `Successfully retrieved ${count} entities with pagination`;
|
|
69
|
-
this.logger.log(message);
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
47
|
+
this.notify({
|
|
48
|
+
count: domains.length,
|
|
49
|
+
type: notification_type_enum_1.NoficationTypeEnum.PAGINATION,
|
|
50
|
+
});
|
|
73
51
|
return result_1.Result.Ok(domains);
|
|
74
52
|
}
|
|
75
53
|
catch (error) {
|
|
76
54
|
this.handler.catch(error);
|
|
77
55
|
}
|
|
78
56
|
}
|
|
79
|
-
async findById(id,
|
|
57
|
+
async findById(id, params = { logging: false }) {
|
|
80
58
|
try {
|
|
81
59
|
this.logger.start();
|
|
82
|
-
const domain = await this.repository.findById(id,
|
|
60
|
+
const domain = await this.repository.findById(id, params);
|
|
83
61
|
if (!domain) {
|
|
84
|
-
this.logger.warn(`${id} not found`);
|
|
85
62
|
const { name } = this.repository.getMetadata();
|
|
63
|
+
this.logger.warn(`${id} not found`);
|
|
86
64
|
return result_1.Result.Fail(new common_1.NotFoundException(`${name} with id ${id} not found`));
|
|
87
65
|
}
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
66
|
+
if (params.logging) {
|
|
67
|
+
this.notify({
|
|
68
|
+
id: domain.id,
|
|
69
|
+
found: true,
|
|
70
|
+
type: notification_type_enum_1.NoficationTypeEnum.ID,
|
|
71
|
+
});
|
|
92
72
|
}
|
|
93
73
|
return result_1.Result.Ok(domain);
|
|
94
74
|
}
|
|
@@ -101,14 +81,15 @@ class IrohService {
|
|
|
101
81
|
this.logger.start();
|
|
102
82
|
const domain = await this.repository.findOne(query, options);
|
|
103
83
|
if (!domain) {
|
|
104
|
-
this.logger.warn(`Entity not found by query`);
|
|
105
84
|
const { name } = this.repository.getMetadata();
|
|
85
|
+
this.logger.warn(`${name} not found by query`);
|
|
106
86
|
return result_1.Result.Fail(new common_1.NotFoundException(`${name} not found`));
|
|
107
87
|
}
|
|
108
88
|
if (options.logging) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
89
|
+
this.notify({
|
|
90
|
+
found: true,
|
|
91
|
+
type: notification_type_enum_1.NoficationTypeEnum.QUERY,
|
|
92
|
+
});
|
|
112
93
|
}
|
|
113
94
|
return result_1.Result.Ok(domain);
|
|
114
95
|
}
|
|
@@ -155,6 +136,10 @@ class IrohService {
|
|
|
155
136
|
getRepository() {
|
|
156
137
|
return this.repository;
|
|
157
138
|
}
|
|
139
|
+
notify(notification) {
|
|
140
|
+
const notifier = new notifier_1.NotifierLogger(this.logger);
|
|
141
|
+
notifier.notify(notification);
|
|
142
|
+
}
|
|
158
143
|
}
|
|
159
144
|
exports.IrohService = IrohService;
|
|
160
145
|
//# sourceMappingURL=iroh.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iroh.service.js","sourceRoot":"","sources":["../../src/core/iroh.service.ts"],"names":[],"mappings":";;;AAAA,2CAAmD;AAGnD,sCAAyC;AACzC,sCAA4C;AAY5C,yCAAsC;AAEtC,MAAsB,WAAW;IAY/B,YAAqB,UAAuC;QAAvC,eAAU,GAAV,UAAU,CAA6B;QAC1D,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAe,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,CAAC,OAAO,GAAG,qBAAY,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,GAAQ;QAC1B,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CA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C,CAAC;QACxC,CAAC;IACH,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,YAAwB;QACrC,MAAM,QAAQ,GAAG,IAAI,yBAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;CACF;AA7JD,kCA6JC"}
|
|
@@ -1,23 +1,66 @@
|
|
|
1
1
|
import { Controller } from '@nestjs/common';
|
|
2
|
+
import { Query } from '@nestjs/common';
|
|
3
|
+
import { Body } from '@nestjs/common';
|
|
4
|
+
import { Param } from '@nestjs/common';
|
|
5
|
+
import { ParseUUIDPipe } from '@nestjs/common';
|
|
2
6
|
import { ApiBearerAuth } from '@nestjs/swagger';
|
|
3
7
|
import { ApiTags } from '@nestjs/swagger';
|
|
8
|
+
|
|
4
9
|
import { IrohController } from '@rafikidota/iroh';
|
|
5
10
|
import { SecurityGuard } from '@rafikidota/iroh';
|
|
6
|
-
import {
|
|
11
|
+
import { GenericPost } from '@rafikidota/iroh';
|
|
12
|
+
import { GenericGet } from '@rafikidota/iroh';
|
|
13
|
+
import { GenericGetById } from '@rafikidota/iroh';
|
|
14
|
+
import { GenericPatch } from '@rafikidota/iroh';
|
|
15
|
+
import { GenericDelete } from '@rafikidota/iroh';
|
|
16
|
+
import { ParseQueryPipe } from '@rafikidota/iroh';
|
|
17
|
+
import { SearchDto } from '@rafikidota/iroh';
|
|
18
|
+
import { QueryOptionDto } from '@rafikidota/iroh';
|
|
19
|
+
|
|
7
20
|
import { PermissionPersistence } from '../../common/security/permission';
|
|
8
21
|
import { <%= classify(name) %>Service } from './<%= lowerCase(name) %>.service';
|
|
22
|
+
import { <%= classify(name) %>Mapper } from './infra';
|
|
9
23
|
import { Create<%= classify(name) %>Dto } from './app/dto';
|
|
10
24
|
import { Update<%= classify(name) %>Dto } from './app/dto/<%= lowerCase(name) %>.update.dto';
|
|
11
25
|
import { <%= classify(name) %>View } from './app/dto/<%= lowerCase(name) %>.view';
|
|
12
|
-
import { <%= classify(name) %>Mapper } from './infra';
|
|
13
26
|
|
|
14
27
|
@ApiBearerAuth()
|
|
15
28
|
@ApiTags('<%= classify(name) %>')
|
|
16
29
|
@Controller('<%= dasherize(name) %>')
|
|
17
30
|
@SecurityGuard(PermissionPersistence)
|
|
18
|
-
@UseDtos(Create<%= classify(name) %>Dto, Update<%= classify(name) %>Dto, <%= classify(name) %>View)
|
|
19
31
|
export class <%= classify(name) %>Controller extends IrohController<<%= classify(name) %>Mapper> {
|
|
20
32
|
constructor(readonly service: <%= classify(name) %>Service) {
|
|
21
33
|
super(service);
|
|
22
34
|
}
|
|
35
|
+
|
|
36
|
+
@GenericPost(Create <%= classify(name) %> Dto, <%= classify(name) %> View)
|
|
37
|
+
create(body: Create<%= classify(name) %>Dto): Promise<<%= classify(name) %>View> {
|
|
38
|
+
return super.create(body);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@GenericGet(<%= classify(name) %>View)
|
|
42
|
+
paginate(@Query(ParseQueryPipe) query: SearchDto): Promise<<%= classify(name) %>View[]> {
|
|
43
|
+
return super.paginate(query);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@GenericGetById(<%= classify(name) %>View)
|
|
47
|
+
findById(
|
|
48
|
+
@Param('id', ParseUUIDPipe) id: string,
|
|
49
|
+
@Query(ParseQueryPipe) query: QueryOptionDto,
|
|
50
|
+
): Promise<<%= classify(name) %>View> {
|
|
51
|
+
return super.findById(id, query);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@GenericPatch(Update<%= classify(name) %>Dto, <%= classify(name) %>View)
|
|
55
|
+
update(
|
|
56
|
+
@Param('id', ParseUUIDPipe) id: string,
|
|
57
|
+
@Body() body: Update<%= classify(name) %>Dto,
|
|
58
|
+
): Promise<<%= classify(name) %>View> {
|
|
59
|
+
return super.update(id, body);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@GenericDelete()
|
|
63
|
+
remove(@Param('id', ParseUUIDPipe) id: string): Promise<<%= classify(name) %>View> {
|
|
64
|
+
return super.remove(id);
|
|
65
|
+
}
|
|
23
66
|
}
|
|
@@ -16,7 +16,7 @@ export class <%= classify(name) %>Mapper extends Mapper {
|
|
|
16
16
|
updatedAt: persistence.updatedAt,
|
|
17
17
|
deletedAt: persistence.deletedAt,
|
|
18
18
|
};
|
|
19
|
-
return DomainFactory.
|
|
19
|
+
return DomainFactory.instance(<%= classify(name) %>Domain, { ...props });
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
DomainToPersistence(domain: <%= classify(name) %>Domain): <%= classify(name) %>Persistence {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { IrohController } from '../../../core/iroh.controller';
|
|
2
2
|
import type { IGenericService } from '../../../common/interfaces';
|
|
3
3
|
import type { IEntityMapper } from '../../../common/interfaces/generic.mapper';
|
|
4
4
|
import { GenericDevicePersistence } from './infra';
|
|
@@ -6,15 +6,7 @@ import { GenericDeviceDomain } from './domain';
|
|
|
6
6
|
import { GenericDeviceView } from './app';
|
|
7
7
|
import { IUpdatableDomain } from '../../../core/domain/generic.domain';
|
|
8
8
|
import { DtoMapper } from '../../../core/app';
|
|
9
|
-
|
|
10
|
-
export declare abstract class IrohDeviceController<M extends IEntityMapper<T, D, V>, T extends GenericDevicePersistence = ReturnType<M['DomainToPersistence']>, D extends GenericDeviceDomain = ReturnType<M['PersistenceToDomain']> & IUpdatableDomain<ReturnType<M['PersistenceToDomain']>>, V extends GenericDeviceView = ReturnType<M['DomainToView']>, DTO extends DtoMapper<D, DTO> = DtoMapper<D>> implements IGenericController<D, V, DTO> {
|
|
9
|
+
export declare abstract class IrohDeviceController<M extends IEntityMapper<T, D, V>, T extends GenericDevicePersistence = ReturnType<M['DomainToPersistence']>, D extends GenericDeviceDomain = ReturnType<M['PersistenceToDomain']> & IUpdatableDomain<ReturnType<M['PersistenceToDomain']>>, V extends GenericDeviceView = ReturnType<M['DomainToView']>, DTO extends DtoMapper<D, DTO> = DtoMapper<D>> extends IrohController<M, T, D, V, DTO> {
|
|
11
10
|
readonly service: IGenericService<T, D, V, DTO>;
|
|
12
11
|
constructor(service: IGenericService<T, D, V, DTO>);
|
|
13
|
-
create(body: DTO): Promise<V>;
|
|
14
|
-
paginate(query: SearchDto): Promise<V[]>;
|
|
15
|
-
findById(id: string): Promise<V>;
|
|
16
|
-
update(id: string, body: Partial<DTO>): Promise<V>;
|
|
17
|
-
remove(id: string): Promise<V>;
|
|
18
|
-
mapView(domain: D): V;
|
|
19
|
-
mapViewList(domains: D[]): V[];
|
|
20
12
|
}
|