@nest-omni/core 3.1.1-9 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/.hygen/new/crud/controller.ejs.t +82 -0
  2. package/.hygen/new/crud/create.dto.ejs.t +12 -0
  3. package/.hygen/new/crud/entity.ejs.t +26 -0
  4. package/.hygen/new/crud/get.dto.ejs.t +19 -0
  5. package/.hygen/new/crud/index-dto.ejs.t +29 -0
  6. package/.hygen/new/crud/index-response.dto.ejs.t +18 -0
  7. package/.hygen/new/crud/module.ejs.t +32 -0
  8. package/.hygen/new/crud/prompt.js +89 -0
  9. package/.hygen/new/crud/service.ejs.t +76 -0
  10. package/.hygen/new/crud/update.dto.ejs.t +11 -0
  11. package/.hygen/new/module/controller.ejs.t +93 -0
  12. package/.hygen/new/module/create-command.ejs.t +90 -0
  13. package/.hygen/new/module/create.dto.ejs.t +11 -0
  14. package/.hygen/new/module/dto.ejs.t +24 -0
  15. package/.hygen/new/module/entity.ejs.t +33 -0
  16. package/.hygen/new/module/get-query.ejs.t +57 -0
  17. package/.hygen/new/module/module.ejs.t +44 -0
  18. package/.hygen/new/module/not-found.exception.ejs.t +18 -0
  19. package/.hygen/new/module/page-options.dto.ejs.t +12 -0
  20. package/.hygen/new/module/prompt.js +104 -0
  21. package/.hygen/new/module/repository.ejs.t +16 -0
  22. package/.hygen/new/module/service.ejs.t +139 -0
  23. package/.hygen/new/module/translation-dto.ejs.t +27 -0
  24. package/.hygen/new/module/translation-entity.ejs.t +40 -0
  25. package/.hygen/new/module/translation-repository.ejs.t +16 -0
  26. package/.hygen/new/module/update.dto.ejs.t +10 -0
  27. package/.hygen.js +116 -0
  28. package/cache/cache-metrics.service.d.ts +83 -0
  29. package/cache/cache-metrics.service.js +298 -0
  30. package/cache/cache-serialization.service.d.ts +22 -0
  31. package/cache/cache-serialization.service.js +122 -0
  32. package/cache/cache.constants.d.ts +2 -0
  33. package/cache/cache.constants.js +5 -0
  34. package/cache/cache.health.d.ts +35 -0
  35. package/cache/cache.health.js +193 -0
  36. package/cache/cache.module.d.ts +26 -0
  37. package/cache/cache.module.js +155 -0
  38. package/cache/cache.service.d.ts +37 -0
  39. package/cache/cache.service.js +308 -0
  40. package/cache/cache.warmup.service.d.ts +34 -0
  41. package/cache/cache.warmup.service.js +199 -0
  42. package/cache/decorators/cache-evict.decorator.d.ts +2 -0
  43. package/cache/decorators/cache-evict.decorator.js +72 -0
  44. package/cache/decorators/cache-put.decorator.d.ts +2 -0
  45. package/cache/decorators/cache-put.decorator.js +48 -0
  46. package/cache/decorators/cacheable.decorator.d.ts +4 -0
  47. package/cache/decorators/cacheable.decorator.js +68 -0
  48. package/cache/decorators/index.d.ts +3 -0
  49. package/cache/decorators/index.js +11 -0
  50. package/cache/dependencies/callback.dependency.d.ts +11 -0
  51. package/cache/dependencies/callback.dependency.js +92 -0
  52. package/cache/dependencies/chain.dependency.d.ts +20 -0
  53. package/cache/dependencies/chain.dependency.js +113 -0
  54. package/cache/dependencies/db.dependency.d.ts +15 -0
  55. package/cache/dependencies/db.dependency.js +71 -0
  56. package/cache/dependencies/file.dependency.d.ts +17 -0
  57. package/cache/dependencies/file.dependency.js +63 -0
  58. package/cache/dependencies/index.d.ts +6 -0
  59. package/cache/dependencies/index.js +22 -0
  60. package/cache/dependencies/tag.dependency.d.ts +16 -0
  61. package/cache/dependencies/tag.dependency.js +75 -0
  62. package/cache/dependencies/time.dependency.d.ts +19 -0
  63. package/cache/dependencies/time.dependency.js +71 -0
  64. package/cache/examples/basic-usage.d.ts +58 -0
  65. package/cache/examples/basic-usage.js +379 -0
  66. package/cache/index.d.ts +15 -0
  67. package/cache/index.js +44 -0
  68. package/cache/interfaces/cache-dependency.interface.d.ts +11 -0
  69. package/cache/interfaces/cache-dependency.interface.js +2 -0
  70. package/cache/interfaces/cache-options.interface.d.ts +32 -0
  71. package/cache/interfaces/cache-options.interface.js +9 -0
  72. package/cache/interfaces/cache-provider.interface.d.ts +28 -0
  73. package/cache/interfaces/cache-provider.interface.js +2 -0
  74. package/cache/interfaces/index.d.ts +3 -0
  75. package/cache/interfaces/index.js +19 -0
  76. package/cache/providers/base-cache.provider.d.ts +16 -0
  77. package/cache/providers/base-cache.provider.js +32 -0
  78. package/cache/providers/cls-cache.provider.d.ts +16 -0
  79. package/cache/providers/cls-cache.provider.js +140 -0
  80. package/cache/providers/index.d.ts +4 -0
  81. package/cache/providers/index.js +23 -0
  82. package/cache/providers/memory-cache.provider.d.ts +26 -0
  83. package/cache/providers/memory-cache.provider.js +171 -0
  84. package/cache/providers/redis-cache.provider.d.ts +23 -0
  85. package/cache/providers/redis-cache.provider.js +215 -0
  86. package/cache/utils/dependency-manager.util.d.ts +15 -0
  87. package/cache/utils/dependency-manager.util.js +141 -0
  88. package/cache/utils/index.d.ts +2 -0
  89. package/cache/utils/index.js +18 -0
  90. package/cache/utils/key-generator.util.d.ts +13 -0
  91. package/cache/utils/key-generator.util.js +74 -0
  92. package/common/abstract.entity.d.ts +20 -0
  93. package/common/abstract.entity.js +81 -0
  94. package/common/boilerplate.polyfill.d.ts +50 -0
  95. package/common/boilerplate.polyfill.js +152 -0
  96. package/common/dto/abstract.dto.d.ts +13 -0
  97. package/common/dto/abstract.dto.js +59 -0
  98. package/common/dto/bulk-id.dto.d.ts +3 -0
  99. package/common/dto/bulk-id.dto.js +27 -0
  100. package/common/dto/create-translation.dto.d.ts +5 -0
  101. package/common/dto/create-translation.dto.js +25 -0
  102. package/common/dto/dto-container.d.ts +9 -0
  103. package/common/dto/dto-container.js +59 -0
  104. package/common/dto/dto-decorators.d.ts +18 -0
  105. package/common/dto/dto-decorators.js +59 -0
  106. package/common/dto/dto-extensions.d.ts +12 -0
  107. package/common/dto/dto-extensions.js +63 -0
  108. package/common/dto/dto-service-accessor.d.ts +7 -0
  109. package/common/dto/dto-service-accessor.js +49 -0
  110. package/common/dto/dto-transformer.d.ts +11 -0
  111. package/common/dto/dto-transformer.js +49 -0
  112. package/common/dto/index.d.ts +12 -0
  113. package/common/dto/index.js +28 -0
  114. package/common/dto/page-meta.dto.d.ts +15 -0
  115. package/common/dto/page-meta.dto.js +48 -0
  116. package/common/dto/page-options.dto.d.ts +5 -0
  117. package/common/dto/page-options.dto.js +40 -0
  118. package/common/dto/page.dto.d.ts +11 -0
  119. package/common/dto/page.dto.js +53 -0
  120. package/common/examples/paginate-and-map.example.d.ts +14 -0
  121. package/common/examples/paginate-and-map.example.js +158 -0
  122. package/common/index.d.ts +6 -0
  123. package/common/index.js +22 -0
  124. package/common/snake-naming.strategy.d.ts +11 -0
  125. package/common/snake-naming.strategy.js +37 -0
  126. package/common/types.d.ts +9 -0
  127. package/common/types.js +2 -0
  128. package/common/utils.d.ts +3 -0
  129. package/common/utils.js +24 -0
  130. package/constants/index.d.ts +2 -0
  131. package/constants/index.js +18 -0
  132. package/constants/language-code.d.ts +5 -0
  133. package/constants/language-code.js +9 -0
  134. package/constants/order.d.ts +4 -0
  135. package/constants/order.js +8 -0
  136. package/decorators/api-page-ok-response.decorator.d.ts +5 -0
  137. package/decorators/api-page-ok-response.decorator.js +24 -0
  138. package/decorators/auth-user.decorator.d.ts +1 -0
  139. package/decorators/auth-user.decorator.js +14 -0
  140. package/decorators/controller.decorator.d.ts +1 -0
  141. package/decorators/controller.decorator.js +10 -0
  142. package/decorators/examples/validation-decorators.example.d.ts +69 -0
  143. package/decorators/examples/validation-decorators.example.js +331 -0
  144. package/decorators/field.decorators.d.ts +79 -0
  145. package/decorators/field.decorators.js +499 -0
  146. package/decorators/http.decorators.d.ts +3 -0
  147. package/decorators/http.decorators.js +7 -0
  148. package/decorators/index.d.ts +12 -0
  149. package/decorators/index.js +28 -0
  150. package/decorators/operation.decorator.d.ts +1 -0
  151. package/decorators/operation.decorator.js +6 -0
  152. package/decorators/property.decorators.d.ts +15 -0
  153. package/decorators/property.decorators.js +31 -0
  154. package/decorators/public-route.decorator.d.ts +3 -0
  155. package/decorators/public-route.decorator.js +7 -0
  156. package/decorators/swagger.schema.d.ts +5 -0
  157. package/decorators/swagger.schema.js +78 -0
  158. package/decorators/timestamp-column.decorator.d.ts +1 -0
  159. package/decorators/timestamp-column.decorator.js +27 -0
  160. package/decorators/transform.decorators.d.ts +8 -0
  161. package/decorators/transform.decorators.js +100 -0
  162. package/decorators/translate.decorator.d.ts +5 -0
  163. package/decorators/translate.decorator.js +17 -0
  164. package/decorators/use-dto.decorator.d.ts +4 -0
  165. package/decorators/use-dto.decorator.js +8 -0
  166. package/decorators/user-check.decorator.d.ts +6 -0
  167. package/decorators/user-check.decorator.js +21 -0
  168. package/decorators/user.decorator.d.ts +12 -0
  169. package/decorators/user.decorator.js +44 -0
  170. package/decorators/user_auth.decorator.d.ts +1 -0
  171. package/decorators/user_auth.decorator.js +15 -0
  172. package/decorators/validator.decorators.d.ts +18 -0
  173. package/decorators/validator.decorators.js +193 -0
  174. package/exceptions/file-not-image.exception.d.ts +4 -0
  175. package/exceptions/file-not-image.exception.js +10 -0
  176. package/exceptions/index.d.ts +2 -0
  177. package/exceptions/index.js +18 -0
  178. package/exceptions/page-type.exception.d.ts +4 -0
  179. package/exceptions/page-type.exception.js +10 -0
  180. package/exceptions/user-not-found.exception.d.ts +4 -0
  181. package/exceptions/user-not-found.exception.js +10 -0
  182. package/filters/bad-request.filter.d.ts +5 -0
  183. package/filters/bad-request.filter.js +71 -0
  184. package/filters/constraint-errors.d.ts +1 -0
  185. package/filters/constraint-errors.js +6 -0
  186. package/filters/index.d.ts +3 -0
  187. package/filters/index.js +19 -0
  188. package/filters/query-failed.filter.d.ts +10 -0
  189. package/filters/query-failed.filter.js +42 -0
  190. package/health-checker/health-checker.controller.d.ts +13 -0
  191. package/health-checker/health-checker.controller.js +69 -0
  192. package/health-checker/health-checker.module.d.ts +2 -0
  193. package/health-checker/health-checker.module.js +24 -0
  194. package/health-checker/index.d.ts +2 -0
  195. package/health-checker/index.js +18 -0
  196. package/helpers/common.helper.d.ts +3 -0
  197. package/helpers/common.helper.js +36 -0
  198. package/helpers/date.helper.d.ts +10 -0
  199. package/helpers/date.helper.js +57 -0
  200. package/helpers/index.d.ts +2 -0
  201. package/helpers/index.js +18 -0
  202. package/i18n/en_US/validation.json +44 -0
  203. package/i18n/zh_CN/validation.json +44 -0
  204. package/index.d.ts +18 -0
  205. package/index.js +3 -0
  206. package/interceptors/index.d.ts +2 -0
  207. package/interceptors/index.js +18 -0
  208. package/interceptors/language-interceptor.service.d.ts +6 -0
  209. package/interceptors/language-interceptor.service.js +29 -0
  210. package/interceptors/translation-interceptor.service.d.ts +5 -0
  211. package/interceptors/translation-interceptor.service.js +34 -0
  212. package/interfaces/IApiFile.d.ts +4 -0
  213. package/interfaces/IApiFile.js +2 -0
  214. package/interfaces/IFile.d.ts +8 -0
  215. package/interfaces/IFile.js +2 -0
  216. package/interfaces/ITranslationDecoratorInterface.d.ts +3 -0
  217. package/interfaces/ITranslationDecoratorInterface.js +2 -0
  218. package/interfaces/index.d.ts +3 -0
  219. package/interfaces/index.js +19 -0
  220. package/interfaces/response.d.ts +25 -0
  221. package/interfaces/response.js +2 -0
  222. package/middlewares/index.d.ts +4 -0
  223. package/middlewares/index.js +20 -0
  224. package/middlewares/omni-auth.middleware.d.ts +1 -0
  225. package/middlewares/omni-auth.middleware.js +13 -0
  226. package/middlewares/powerby.middleware.d.ts +1 -0
  227. package/middlewares/powerby.middleware.js +10 -0
  228. package/middlewares/request-id.middleware.d.ts +7 -0
  229. package/middlewares/request-id.middleware.js +22 -0
  230. package/middlewares/xml.middleware.d.ts +4 -0
  231. package/middlewares/xml.middleware.js +24 -0
  232. package/package.json +41 -116
  233. package/providers/context.provider.d.ts +34 -0
  234. package/providers/context.provider.js +80 -0
  235. package/providers/generator.provider.d.ts +9 -0
  236. package/providers/generator.provider.js +50 -0
  237. package/providers/index.d.ts +2 -0
  238. package/providers/index.js +18 -0
  239. package/redis-lock/examples/lock-strategy.examples.d.ts +73 -0
  240. package/redis-lock/examples/lock-strategy.examples.js +387 -0
  241. package/redis-lock/index.d.ts +4 -0
  242. package/redis-lock/index.js +16 -0
  243. package/redis-lock/redis-lock.decorator.d.ts +12 -0
  244. package/redis-lock/redis-lock.decorator.js +125 -0
  245. package/redis-lock/redis-lock.module.d.ts +23 -0
  246. package/redis-lock/redis-lock.module.js +117 -0
  247. package/redis-lock/redis-lock.service.d.ts +66 -0
  248. package/redis-lock/redis-lock.service.js +413 -0
  249. package/setup/bootstrap.setup.d.ts +2 -0
  250. package/setup/bootstrap.setup.js +184 -0
  251. package/setup/index.d.ts +4 -0
  252. package/setup/index.js +20 -0
  253. package/setup/mode.setup.d.ts +12 -0
  254. package/setup/mode.setup.js +60 -0
  255. package/setup/schedule.decorator.d.ts +23 -0
  256. package/setup/schedule.decorator.js +233 -0
  257. package/setup/worker.decorator.d.ts +14 -0
  258. package/setup/worker.decorator.js +130 -0
  259. package/shared/index.d.ts +2 -0
  260. package/shared/index.js +18 -0
  261. package/shared/serviceRegistryModule.d.ts +2 -0
  262. package/shared/serviceRegistryModule.js +170 -0
  263. package/shared/services/api-config.service.d.ts +54 -0
  264. package/shared/services/api-config.service.js +287 -0
  265. package/shared/services/generator.service.d.ts +4 -0
  266. package/shared/services/generator.service.js +23 -0
  267. package/shared/services/index.d.ts +4 -0
  268. package/shared/services/index.js +20 -0
  269. package/shared/services/translation.service.d.ts +9 -0
  270. package/shared/services/translation.service.js +70 -0
  271. package/shared/services/validator.service.d.ts +3 -0
  272. package/shared/services/validator.service.js +20 -0
  273. package/validator-json/decorators.d.ts +6 -0
  274. package/validator-json/decorators.js +22 -0
  275. package/validator-json/default.d.ts +6 -0
  276. package/validator-json/default.js +138 -0
  277. package/validator-json/defaultConverters.d.ts +8 -0
  278. package/validator-json/defaultConverters.js +376 -0
  279. package/validator-json/index.d.ts +4 -0
  280. package/validator-json/index.js +20 -0
  281. package/validator-json/options.d.ts +11 -0
  282. package/validator-json/options.js +10 -0
  283. package/validators/file-mimetype.validator.d.ts +13 -0
  284. package/validators/file-mimetype.validator.js +21 -0
  285. package/validators/index.d.ts +6 -0
  286. package/validators/index.js +22 -0
  287. package/validators/is-exists.validator.d.ts +18 -0
  288. package/validators/is-exists.validator.js +60 -0
  289. package/validators/is-unique.validator.d.ts +17 -0
  290. package/validators/is-unique.validator.js +91 -0
  291. package/validators/phone-country-code.validator.d.ts +2 -0
  292. package/validators/phone-country-code.validator.js +29 -0
  293. package/validators/same-as.validator.d.ts +2 -0
  294. package/validators/same-as.validator.js +24 -0
  295. package/validators/skip-empty.validator.d.ts +1 -0
  296. package/validators/skip-empty.validator.js +17 -0
  297. package/vault/index.d.ts +4 -0
  298. package/vault/index.js +20 -0
  299. package/vault/interfaces/vault-options.interface.d.ts +22 -0
  300. package/vault/interfaces/vault-options.interface.js +2 -0
  301. package/vault/vault-config.loader.d.ts +13 -0
  302. package/vault/vault-config.loader.js +246 -0
  303. package/vault/vault-config.service.d.ts +18 -0
  304. package/vault/vault-config.service.js +174 -0
  305. package/vault/vault.module.d.ts +2 -0
  306. package/vault/vault.module.js +21 -0
@@ -0,0 +1,57 @@
1
+ ---
2
+ to: "src/modules/<%= h.fileName(name) %>/queries/<%= h.getQueryFileName(name) %>.ts"
3
+ unless_exists: true
4
+ skip_if: <%= !blocks.includes('GetQuery') %>
5
+ ---
6
+ <%
7
+
8
+ ClassName = h.ClassName(name);
9
+ fieldName = h.changeCase.camel(ClassName);
10
+
11
+ GetQueryName = h.GetQueryName(name);
12
+ GetHandlerName = h.GetHandlerName(name);
13
+
14
+ CreateDtoName = h.CreateDtoName(name);
15
+ createDtoName = h.changeCase.camel(CreateDtoName);
16
+ createDtoFileName = h.createDtoFileName(name);
17
+
18
+ EntityName = h.EntityName(name);
19
+ entityName = h.changeCase.camel(EntityName);
20
+
21
+ EntityName = h.EntityName(name);
22
+ entityName = h.changeCase.camel(EntityName);
23
+ entityFileName = h.entityFileName(name);
24
+
25
+ RepositoryName = h.RepositoryName(name);
26
+ TranslationRepositoryName = h.TranslationRepositoryName(name);
27
+ repositoryName = h.changeCase.camel(RepositoryName);
28
+ translationRepositoryName = h.changeCase.camel(TranslationRepositoryName);
29
+ repositoryFileName = h.repositoryFileName(name);
30
+
31
+ TranslationEntityName = h.TranslationEntityName(name);
32
+ TranslationDtoName = h.TranslationDtoName(name);
33
+ translationEntityFileName = h.translationEntityFileName(name);
34
+ translationRepositoryFileName = h.translationRepositoryFileName(name);
35
+ translationEntityName = h.changeCase.camel(TranslationEntityName);
36
+
37
+ %>import type { ICommand, IQueryHandler } from '@nestjs/cqrs';
38
+ import { QueryHandler } from '@nestjs/cqrs';
39
+
40
+ import { <%= RepositoryName %> } from '../<%= repositoryFileName %>';
41
+
42
+ export class <%= GetQueryName %> implements ICommand {
43
+ constructor(
44
+ public readonly userId: Uuid,
45
+ ) {}
46
+ }
47
+
48
+ @QueryHandler(<%= GetQueryName %>)
49
+ export class <%= GetHandlerName %> implements IQueryHandler<<%= GetQueryName %>> {
50
+ constructor(private <%= repositoryName %>: <%= RepositoryName %>) {}
51
+
52
+ async execute(query: <%= GetQueryName %>) {
53
+ return this.<%= repositoryName %>.find({
54
+ userId: query.userId,
55
+ });
56
+ }
57
+ }
@@ -0,0 +1,44 @@
1
+ ---
2
+ to: "src/modules/<%= h.fileName(name) %>/<%= h.moduleFileName(name) %>.ts"
3
+ unless_exists: true
4
+ ---
5
+ <%
6
+
7
+ ModuleName = h.ModuleName(name);
8
+ fileName = h.inflection.dasherize(name);
9
+
10
+ ControllerName = h.ControllerName(name);
11
+ controllerFileName = h.controllerFileName(name);
12
+
13
+ ServiceName = h.ServiceName(name);
14
+ serviceFileName = h.serviceFileName(name);
15
+
16
+ RepositoryName = h.RepositoryName(name);
17
+ repositoryFileName = h.repositoryFileName(name);
18
+
19
+ createCommandFileName = h.createCommandFileName(name);
20
+ getQueryFileName = h.getQueryFileName(name);
21
+
22
+ %>import { Module } from '@nestjs/common';
23
+ import { TypeOrmModule } from '@nestjs/typeorm';
24
+
25
+ import { <%= CreateHandlerName %> } from './commands/<%= createCommandFileName %>';
26
+ import { <%= ControllerName %> } from './<%= controllerFileName %>';
27
+ import { <%= RepositoryName %> } from './<%= repositoryFileName %>';
28
+ import { <%= TranslationRepositoryName %> } from './<%= translationRepositoryFileName %>';
29
+ import { <%= ServiceName %> } from './<%= serviceFileName %>';
30
+ import { <%= GetHandlerName %> } from './queries/<%= getQueryFileName %>';
31
+
32
+ export const handlers = [
33
+ <%= CreateHandlerName %>,
34
+ <%= GetHandlerName %>,
35
+ ];
36
+
37
+ @Module({
38
+ imports: [
39
+ TypeOrmModule.forFeature([<%= RepositoryName %>, <%= TranslationRepositoryName %>]),
40
+ ],
41
+ providers: [<%= ServiceName %>, ...handlers],
42
+ controllers: [<%= ControllerName %>],
43
+ })
44
+ export class <%= ModuleName %> {}
@@ -0,0 +1,18 @@
1
+ ---
2
+ to: "src/modules/<%= h.fileName(name) %>/exceptions/<%= h.notFoundExceptionFileName(name) %>.ts"
3
+ unless_exists: true
4
+ skip_if: <%= !blocks.includes('NotFoundException') %>
5
+ ---
6
+ <%
7
+
8
+ ClassName = h.ClassName(name);
9
+ fieldName = h.changeCase.camel(ClassName);
10
+ NotFoundExceptionName = h.NotFoundExceptionName(name);
11
+
12
+ %>import { NotFoundException } from '@nestjs/common';
13
+
14
+ export class <%= NotFoundExceptionName %> extends NotFoundException {
15
+ constructor(error?: string) {
16
+ super('error.<%= fieldName %>NotFound', error);
17
+ }
18
+ }
@@ -0,0 +1,12 @@
1
+ ---
2
+ to: "src/modules/<%= h.fileName(name) %>/dtos/<%= h.pageOptionsDtoFileName(name) %>.ts"
3
+ unless_exists: true
4
+ skip_if: <%= !blocks.includes('PageOptionsDTO') %>
5
+ ---
6
+ <%
7
+
8
+ PageOptionsDtoName = h.PageOptionsDtoName(name);
9
+
10
+ %>import { PageOptionsDto } from '@nest-omni/core/common/dto/page-options.dto';
11
+
12
+ export class <%= PageOptionsDtoName %> extends PageOptionsDto {}
@@ -0,0 +1,104 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ prompt: ({ prompter, args }) => {
5
+ return prompter.prompt([
6
+ {
7
+ type: 'input',
8
+ name: 'name',
9
+ message: 'Name:',
10
+ validate(value) {
11
+ if (!value.length) {
12
+ return 'Module must have a name.';
13
+ }
14
+ return true;
15
+ },
16
+ },
17
+ {
18
+ type: 'MultiSelect',
19
+ name: 'blocks',
20
+ message: 'Blocks:',
21
+ initial: [
22
+ 'Controller',
23
+ 'CreateCommand',
24
+ 'CreateDTO',
25
+ 'DTO',
26
+ 'Entity',
27
+ 'GetQuery',
28
+ //'Module',
29
+ 'NotFoundException',
30
+ 'PageOptionsDTO',
31
+ 'Repository',
32
+ 'Service',
33
+ 'TranslationDTO',
34
+ 'TranslationEntity',
35
+ 'TranslationRepository',
36
+ 'UpdateDTO'
37
+ ],
38
+ choices: [
39
+ {
40
+ name: 'Controller',
41
+ value: 'controller',
42
+ },
43
+ {
44
+ name: 'CreateCommand',
45
+ value: 'create-command',
46
+ },
47
+ {
48
+ name: 'CreateDTO',
49
+ value: 'create-dto',
50
+ },
51
+ {
52
+ name: 'DTO',
53
+ value: 'dto',
54
+ },
55
+ {
56
+ name: 'Entity',
57
+ value: 'entity',
58
+ },
59
+ {
60
+ name: 'GetQuery',
61
+ value: 'get-query',
62
+ },
63
+ {
64
+ name: 'NotFoundException',
65
+ value: 'not-found-exception',
66
+ },
67
+ {
68
+ name: 'PageOptionsDTO',
69
+ value: 'page-options-dto',
70
+ },
71
+ {
72
+ name: 'Repository',
73
+ value: 'repository',
74
+ },
75
+ {
76
+ name: 'Service',
77
+ value: 'service',
78
+ },
79
+ {
80
+ name: 'TranslationDTO',
81
+ value: 'translation-dto',
82
+ },
83
+ {
84
+ name: 'TranslationEntity',
85
+ value: 'translationEntity',
86
+ },
87
+ {
88
+ name: 'TranslationRepository',
89
+ value: 'translation-repository',
90
+ },
91
+ {
92
+ name: 'UpdateDTO',
93
+ value: 'update-dto',
94
+ },
95
+ ],
96
+ }
97
+ ])
98
+ .then(answer => {
99
+ //// For debugging
100
+ // console.log(answer)
101
+ return answer;
102
+ })
103
+ }
104
+ }
@@ -0,0 +1,16 @@
1
+ ---
2
+ to: "src/modules/<%= h.fileName(name) %>/<%= h.repositoryFileName(name) %>.ts"
3
+ unless_exists: true
4
+ skip_if: <%= !blocks.includes('Repository') %>
5
+ ---
6
+ <%
7
+ EntityName = h.EntityName(name);
8
+ entityFileName = h.entityFileName(name);
9
+
10
+ RepositoryName = h.RepositoryName(name);
11
+ %>import { EntityRepository, Repository } from 'typeorm';
12
+
13
+ import { <%= EntityName %> } from './<%= entityFileName %>';
14
+
15
+ @EntityRepository(<%= EntityName %>)
16
+ export class <%= RepositoryName %> extends Repository<<%= EntityName %>> {}
@@ -0,0 +1,139 @@
1
+ ---
2
+ to: "src/modules/<%= h.fileName(name) %>/<%= h.serviceFileName(name) %>.ts"
3
+ unless_exists: true
4
+ skip_if: <%= !blocks.includes('Service') %>
5
+ ---
6
+ <%
7
+
8
+ ClassName = h.ClassName(name);
9
+ fieldName = h.changeCase.camel(ClassName);
10
+
11
+ DtoName = h.DtoName(name);
12
+ dtoFileName = h.dtoFileName(name);
13
+
14
+
15
+ CreateCommandName = h.CreateCommandName(name);
16
+ createCommandFileName = h.createCommandFileName(name);
17
+
18
+
19
+ EntityName = h.EntityName(name);
20
+ entityName = h.changeCase.camel(EntityName);
21
+ entityFileName = h.entityFileName(name);
22
+
23
+ ServiceName = h.ServiceName(name);
24
+
25
+ UpdateDtoName = h.UpdateDtoName(name);
26
+ updateDtoFileName = h.updateDtoFileName(name);
27
+ updateDtoName = h.changeCase.camel(UpdateDtoName);
28
+
29
+ fileName = h.fileName(name);
30
+
31
+ RepositoryName = h.RepositoryName(name);
32
+ repositoryName = h.changeCase.camel(RepositoryName);
33
+ repositoryFileName = h.repositoryFileName(name);
34
+
35
+ NotFoundExceptionName = h.NotFoundExceptionName(name);
36
+ notFoundExceptionFileName = h.notFoundExceptionFileName(name);
37
+
38
+ createFunctionName = 'create' + ClassName;
39
+ updateFunctionName = 'update' + ClassName;
40
+ deleteFunctionName = 'delete' + ClassName;
41
+ getAllFunctionName = 'getAll' + ClassName;
42
+ getSingleFunctionName = 'getSingle' + ClassName;
43
+ controllerName = moduleName + 'Controller';
44
+ serviceName = moduleName + 'Service';
45
+ CreateDtoName = h.CreateDtoName(name);
46
+ createDtoFileName = h.createDtoFileName(name);
47
+
48
+ PageOptionsDtoName = h.PageOptionsDtoName(name);
49
+ pageOptionsDtoName = h.changeCase.camel(PageOptionsDtoName);
50
+ pageOptionsDtoFileName = h.pageOptionsDtoFileName(name);
51
+
52
+ %>import { Injectable } from '@nestjs/common';
53
+ import { CommandBus } from '@nestjs/cqrs';
54
+ import { Transactional } from 'typeorm-transactional';
55
+
56
+ import type { PageDto } from '@nest-omni/core/common/dto/page.dto';
57
+ import { ValidatorService } from '@nest-omni/core/shared/services/validator.service';
58
+ import { <%= CreateCommandName %> } from './commands/<%= createCommandFileName %>';
59
+ import type { <%= DtoName %> } from './dtos/<%= dtoFileName %>';
60
+ import type { <%= PageOptionsDtoName %> } from './dtos/<%= pageOptionsDtoFileName %>';
61
+ import { <%= NotFoundExceptionName %> } from './exceptions/<%= notFoundExceptionFileName %>';
62
+ import type { <%= EntityName %> } from './<%= entityFileName %>';
63
+ import { <%= RepositoryName %> } from './<%= repositoryFileName %>';
64
+ import { <%= CreateDtoName %> } from './dtos/<%= createDtoFileName %>';
65
+ import type { <%= UpdateDtoName %> } from './dtos/<%= updateDtoFileName %>';
66
+
67
+ @Injectable()
68
+ export class <%= ServiceName %> {
69
+ constructor(
70
+ private <%= repositoryName %>: <%= RepositoryName %>,
71
+ private validatorService: ValidatorService,
72
+ private commandBus: CommandBus,
73
+ ) {}
74
+
75
+ @Transactional()
76
+ <%= createFunctionName %>(<%= createDtoName %>: <%= CreateDtoName %>): Promise<<%= EntityName %>> {
77
+ return this.commandBus.execute<<%= CreateCommandName %>, <%= EntityName %>>(
78
+ new <%= CreateCommandName %>(<%= createDtoName %>),
79
+ );
80
+ }
81
+
82
+ async <%= getAllFunctionName %>(
83
+ <%= pageOptionsDtoName %>: <%= PageOptionsDtoName %>,
84
+ ): Promise<PageDto<<%= DtoName %>>> {
85
+ const queryBuilder = this.<%= repositoryName %>
86
+ .createQueryBuilder('<%= fieldName %>')
87
+ .leftJoinAndSelect('<%= fieldName %>.translations', '<%= fieldName %>Translation');
88
+ const [items, pageMetaDto] = await queryBuilder.paginate(<%= pageOptionsDtoName %>);
89
+
90
+ return items.toPageDto(pageMetaDto);
91
+ }
92
+
93
+ async <%= getSingleFunctionName %>(id: Uuid): Promise<<%= EntityName %>> {
94
+ const queryBuilder = this.<%= repositoryName %>
95
+ .createQueryBuilder('<%= fieldName %>')
96
+ .where('<%= fieldName %>.id = :id', { id });
97
+
98
+ const <%= entityName %> = await queryBuilder.getOne();
99
+
100
+ if (!<%= entityName %>) {
101
+ throw new <%= NotFoundExceptionName %>();
102
+ }
103
+
104
+ return <%= entityName %>;
105
+ }
106
+
107
+ async <%= updateFunctionName %>(
108
+ id: Uuid,
109
+ <%= updateDtoName %>: <%= UpdateDtoName %>,
110
+ ): Promise<void> {
111
+ const queryBuilder = this.<%= repositoryName %>
112
+ .createQueryBuilder('<%= fieldName %>')
113
+ .where('<%= fieldName %>.id = :id', { id });
114
+
115
+ const <%= entityName %> = await queryBuilder.getOne();
116
+
117
+ if (!<%= entityName %>) {
118
+ throw new <%= NotFoundExceptionName %>();
119
+ }
120
+
121
+ this.<%= repositoryName %>.merge(<%= entityName %>, <%= updateDtoName %>);
122
+
123
+ await this.<%= repositoryName %>.save(<%= updateDtoName %>);
124
+ }
125
+
126
+ async <%= deleteFunctionName %>(id: Uuid): Promise<void> {
127
+ const queryBuilder = this.<%= repositoryName %>
128
+ .createQueryBuilder('<%= fieldName %>')
129
+ .where('<%= fieldName %>.id = :id', { id });
130
+
131
+ const <%= entityName %> = await queryBuilder.getOne();
132
+
133
+ if (!<%= entityName %>) {
134
+ throw new <%= NotFoundExceptionName %>();
135
+ }
136
+
137
+ await this.<%= repositoryName %>.remove(<%= entityName %>);
138
+ }
139
+ }
@@ -0,0 +1,27 @@
1
+ ---
2
+ to: "src/modules/<%= h.fileName(name) %>/dtos/<%= h.translationDtoFileName(name) %>.ts"
3
+ unless_exists: true
4
+ skip_if: <%= !blocks.includes('TranslationDTO') %>
5
+ ---
6
+ <%
7
+
8
+ TranslationDtoName = h.TranslationDtoName(name);
9
+ translationEntityFileName = h.translationEntityFileName(name);
10
+ TranslationEntityName = h.TranslationEntityName(name);
11
+ translationEntityName = h.changeCase.camel(TranslationEntityName);
12
+
13
+ %>import { AbstractTranslationDto } from '@nest-omni/core/common/dto/abstract.dto';
14
+ import { LanguageCode } from '../../../constants';
15
+ import { ApiEnumPropertyOptional } from '../@nest-omni/core/decorators';
16
+ import type { <%= TranslationEntityName %> } from '../<%= translationEntityFileName %>';
17
+
18
+ export class <%= TranslationDtoName %> extends AbstractTranslationDto {
19
+ @ApiEnumPropertyOptional(() => LanguageCode)
20
+ languageCode: LanguageCode;
21
+
22
+ constructor(<%= translationEntityName %>: <%= TranslationEntityName %>) {
23
+ super(<%= translationEntityName %>);
24
+
25
+ this.languageCode = <%= translationEntityName %>.languageCode;
26
+ }
27
+ }
@@ -0,0 +1,40 @@
1
+ ---
2
+ to: "src/modules/<%= h.fileName(name) %>/<%= h.translationEntityFileName(name) %>.ts"
3
+ unless_exists: true
4
+ skip_if: <%= !blocks.includes('TranslationEntity') %>
5
+ ---
6
+ <%
7
+ ClassName = h.ClassName(name);
8
+ fieldName = h.changeCase.camel(ClassName);
9
+ DtoName = h.DtoName(name);
10
+ dtoFileName = h.dtoFileName(name);
11
+ translationDtoFileName = h.translationDtoFileName(name);
12
+ translationEntityFileName = h.translationEntityFileName(name);
13
+ DtoOptionName = h.DtoOptionName(name);
14
+ var_name = h.inflection.dasherize(name);
15
+ EntityName = h.EntityName(name);
16
+ entityName = h.changeCase.camel(EntityName);
17
+ TranslationEntityName = h.TranslationEntityName(name);
18
+ TranslationDtoName = h.TranslationDtoName(name);
19
+ translationEntityName = h.changeCase.camel(TranslationEntityName);
20
+ %>import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
21
+
22
+ import { AbstractTranslationEntity } from '@nest-omni/core/common/abstract.entity';
23
+ import { UseDto } from '@nest-omni/core/decorators';
24
+ import { <%= TranslationDtoName %> } from './dtos/<%= translationDtoFileName %>';
25
+ import { <%= EntityName %> } from './<%= entityFileName %>';
26
+
27
+ @Entity({ name: '<%= var_name %>_translations' })
28
+ @UseDto(<%= TranslationDtoName %>)
29
+ export class <%= TranslationEntityName %> extends AbstractTranslationEntity<<%= TranslationDtoName %>> {
30
+ @Column({ type: 'uuid' })
31
+ <%= fieldName %>Id: Uuid;
32
+
33
+ @ManyToOne(() => <%= EntityName %>, (<%= entityName %>) => <%= entityName %>.translations, {
34
+ onDelete: 'CASCADE',
35
+ onUpdate: 'CASCADE',
36
+ })
37
+ @JoinColumn({ name: '<%= var_name %>_id' })
38
+ <%= fieldName %>: <%= EntityName %>;
39
+ }
40
+
@@ -0,0 +1,16 @@
1
+ ---
2
+ to: "src/modules/<%= h.fileName(name) %>/<%= h.translationRepositoryFileName(name) %>.ts"
3
+ unless_exists: true
4
+ skip_if: <%= !blocks.includes('TranslationRepository') %>
5
+ ---
6
+ <%
7
+ TranslationEntityName = h.TranslationEntityName(name);
8
+ translationEntityFileName = h.translationEntityFileName(name);
9
+
10
+ TranslationRepositoryName = h.TranslationRepositoryName(name);
11
+ %>import { EntityRepository, Repository } from 'typeorm';
12
+
13
+ import { <%= TranslationEntityName %> } from './<%= translationEntityFileName %>';
14
+
15
+ @EntityRepository(<%= TranslationEntityName %>)
16
+ export class <%= TranslationRepositoryName %> extends Repository<<%= TranslationEntityName %>> {}
@@ -0,0 +1,10 @@
1
+ ---
2
+ to: "src/modules/<%= h.fileName(name) %>/dtos/<%= h.updateDtoFileName(name) %>.ts"
3
+ unless_exists: true
4
+ skip_if: <%= !blocks.includes('UpdateDTO') %>
5
+ ---
6
+ <%
7
+
8
+ UpdateDtoName = h.UpdateDtoName(name);
9
+
10
+ %>export class <%= UpdateDtoName %> {}
package/.hygen.js ADDED
@@ -0,0 +1,116 @@
1
+ module.exports = {
2
+ templates: `${__dirname}/.hygen`,
3
+ helpers: {
4
+ ControllerName(name) {
5
+ return `${this.ClassName(name)}Controller`;
6
+ },
7
+ ServiceName(name) {
8
+ return `${this.ClassName(name)}Service`;
9
+ },
10
+ ModuleName(name) {
11
+ return `${this.ClassName(name)}Module`;
12
+ },
13
+ DtoName(name) {
14
+ return `${this.ClassName(name)}Dto`;
15
+ },
16
+ TranslationDtoName(name) {
17
+ return `${this.ClassName(name)}TranslationDto`;
18
+ },
19
+ UpdateDtoName(name) {
20
+ return `Update${this.DtoName(name)}`;
21
+ },
22
+ DtoOptionName(name) {
23
+ return `I${this.DtoName(name)}Options`;
24
+ },
25
+ CreateDtoName(name) {
26
+ return `Create${this.DtoName(name)}`;
27
+ },
28
+ EntityName(name) {
29
+ return `${this.ClassName(name)}Entity`;
30
+ },
31
+ TranslationEntityName(name) {
32
+ return `${this.ClassName(name)}TranslationEntity`;
33
+ },
34
+ CreateCommandName(name) {
35
+ return `Create${this.ClassName(name)}Command`;
36
+ },
37
+ CreateHandlerName(name) {
38
+ return `Create${this.ClassName(name)}Handler`;
39
+ },
40
+ GetHandlerName(name) {
41
+ return `Get${this.ClassName(name)}Handler`;
42
+ },
43
+ GetQueryName(name) {
44
+ return `Get${this.ClassName(name)}Query`;
45
+ },
46
+ PageOptionsDtoName(name) {
47
+ return this.ClassName(name) + 'PageOptionsDto';
48
+ },
49
+ NotFoundExceptionName(name) {
50
+ return this.ClassName(name) + 'NotFoundException';
51
+ },
52
+ entityFileName(name) {
53
+ return `${this.fileName(name)}.entity`;
54
+ },
55
+ translationEntityFileName(name) {
56
+ return `${this.fileName(name)}-translation.entity`;
57
+ },
58
+ translationDtoFileName(name) {
59
+ return `${this.fileName(name)}-translation.dto`;
60
+ },
61
+ repositoryFileName(name) {
62
+ return `${this.fileName(name)}.repository`;
63
+ },
64
+ translationRepositoryFileName(name) {
65
+ return `${this.fileName(name)}-translation.repository`;
66
+ },
67
+ createCommandFileName(name) {
68
+ return `create-${this.fileName(name)}.command`;
69
+ },
70
+ getQueryFileName(name) {
71
+ return `get-${this.fileName(name)}.query`;
72
+ },
73
+ controllerFileName(name) {
74
+ return `${this.fileName(name)}.controller`;
75
+ },
76
+ dtoFileName(name) {
77
+ return `${this.fileName(name)}.dto`;
78
+ },
79
+ notFoundExceptionFileName(name) {
80
+ return `${this.fileName(name)}-not-found.exception`;
81
+ },
82
+ createDtoFileName(name) {
83
+ return `create-${this.fileName(name)}.dto`;
84
+ },
85
+ updateDtoFileName(name) {
86
+ return `update-${this.fileName(name)}.dto`;
87
+ },
88
+ pageOptionsDtoFileName(name) {
89
+ return `${this.fileName(name)}-page-options.dto`;
90
+ },
91
+ serviceFileName(name) {
92
+ return `${this.fileName(name)}.service`;
93
+ },
94
+ moduleFileName(name) {
95
+ return `${this.fileName(name)}.module`;
96
+ },
97
+ ClassName(name) {
98
+ return this.changeCase.pascal(name);
99
+ },
100
+ TableName(name) {
101
+ return this.inflection.underscore(this.ClassName(name));
102
+ },
103
+ RepositoryName(name) {
104
+ return `${this.ClassName(name)}Repository`;
105
+ },
106
+ TranslationRepositoryName(name) {
107
+ return `${this.ClassName(name)}TranslationRepository`;
108
+ },
109
+ moduleName(name) {
110
+ return this.changeCase.camel(name);
111
+ },
112
+ fileName(name) {
113
+ return this.inflection.dasherize(name).toLowerCase();
114
+ },
115
+ },
116
+ }
@@ -0,0 +1,83 @@
1
+ import { EventEmitter } from 'events';
2
+ export interface CacheOperationRecord {
3
+ type: 'get' | 'set' | 'delete' | 'clear';
4
+ layer: string;
5
+ hit: boolean;
6
+ latency: number;
7
+ error?: string;
8
+ key?: string;
9
+ timestamp: Date;
10
+ }
11
+ export interface CacheMetrics {
12
+ totalOperations: number;
13
+ hits: number;
14
+ misses: number;
15
+ hitRate: number;
16
+ avgLatency: number;
17
+ minLatency: number;
18
+ maxLatency: number;
19
+ p95Latency: number;
20
+ p99Latency: number;
21
+ gets: number;
22
+ sets: number;
23
+ deletes: number;
24
+ clears: number;
25
+ totalKeys: number;
26
+ totalSize: number;
27
+ errors: number;
28
+ errorRate: number;
29
+ layerMetrics: {
30
+ cls: {
31
+ hits: number;
32
+ misses: number;
33
+ avgLatency: number;
34
+ };
35
+ memory: {
36
+ hits: number;
37
+ misses: number;
38
+ avgLatency: number;
39
+ size: number;
40
+ };
41
+ redis: {
42
+ hits: number;
43
+ misses: number;
44
+ avgLatency: number;
45
+ };
46
+ };
47
+ timeWindow: {
48
+ start: Date;
49
+ end: Date;
50
+ duration: number;
51
+ };
52
+ }
53
+ export declare class CacheMetricsService extends EventEmitter {
54
+ private readonly logger;
55
+ private readonly operations;
56
+ private readonly maxOperations;
57
+ private readonly maxAge;
58
+ constructor();
59
+ recordOperation(type: 'get' | 'set' | 'delete' | 'clear', layer: string, hit: boolean, latency: number, error?: string, key?: string): void;
60
+ getMetrics(timeWindowMs?: number): CacheMetrics;
61
+ getSnapshot(): Partial<CacheMetrics>;
62
+ getSlowOperations(limit?: number): CacheOperationRecord[];
63
+ getMostAccessedKeys(limit?: number): {
64
+ key: string;
65
+ count: number;
66
+ avgLatency: number;
67
+ }[];
68
+ getErrorBreakdown(): {
69
+ error: string;
70
+ count: number;
71
+ lastOccurrence: Date;
72
+ }[];
73
+ resetMetrics(): void;
74
+ exportMetrics(format?: 'prometheus' | 'json'): string;
75
+ private cleanupOldRecords;
76
+ private createEmptyMetrics;
77
+ private calculateLayerMetrics;
78
+ private average;
79
+ private percentile;
80
+ private getUniqueKeyCount;
81
+ private estimateTotalSize;
82
+ private toPrometheusFormat;
83
+ }