@sisques-labs/nestjs-kit 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.
Files changed (294) hide show
  1. package/README.md +770 -0
  2. package/dist/index.d.ts +93 -0
  3. package/dist/index.js +110 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/shared/application/commands/base/base-command.handler.d.ts +6 -0
  6. package/dist/shared/application/commands/base/base-command.handler.js +14 -0
  7. package/dist/shared/application/commands/base/base-command.handler.js.map +1 -0
  8. package/dist/shared/application/commands/interfaces/base-command-handler.interface.d.ts +3 -0
  9. package/dist/shared/application/commands/interfaces/base-command-handler.interface.js +3 -0
  10. package/dist/shared/application/commands/interfaces/base-command-handler.interface.js.map +1 -0
  11. package/dist/shared/application/commands/update/base-update/base-update.command-handler.d.ts +9 -0
  12. package/dist/shared/application/commands/update/base-update/base-update.command-handler.js +25 -0
  13. package/dist/shared/application/commands/update/base-update/base-update.command-handler.js.map +1 -0
  14. package/dist/shared/application/dtos/commands/field-changed/base-field-changed-command.dto.d.ts +5 -0
  15. package/dist/shared/application/dtos/commands/field-changed/base-field-changed-command.dto.js +3 -0
  16. package/dist/shared/application/dtos/commands/field-changed/base-field-changed-command.dto.js.map +1 -0
  17. package/dist/shared/application/services/base-service/base-service.interface.d.ts +3 -0
  18. package/dist/shared/application/services/base-service/base-service.interface.js +3 -0
  19. package/dist/shared/application/services/base-service/base-service.interface.js.map +1 -0
  20. package/dist/shared/domain/aggregates/base-aggregate/base.aggregate.d.ts +9 -0
  21. package/dist/shared/domain/aggregates/base-aggregate/base.aggregate.js +19 -0
  22. package/dist/shared/domain/aggregates/base-aggregate/base.aggregate.js.map +1 -0
  23. package/dist/shared/domain/entities/criteria.d.ts +21 -0
  24. package/dist/shared/domain/entities/criteria.js +12 -0
  25. package/dist/shared/domain/entities/criteria.js.map +1 -0
  26. package/dist/shared/domain/entities/paginated-result.entity.d.ts +8 -0
  27. package/dist/shared/domain/entities/paginated-result.entity.js +16 -0
  28. package/dist/shared/domain/entities/paginated-result.entity.js.map +1 -0
  29. package/dist/shared/domain/enums/filter-operator.enum.d.ts +10 -0
  30. package/dist/shared/domain/enums/filter-operator.enum.js +15 -0
  31. package/dist/shared/domain/enums/filter-operator.enum.js.map +1 -0
  32. package/dist/shared/domain/enums/length-unit/length-unit.enum.d.ts +7 -0
  33. package/dist/shared/domain/enums/length-unit/length-unit.enum.js +12 -0
  34. package/dist/shared/domain/enums/length-unit/length-unit.enum.js.map +1 -0
  35. package/dist/shared/domain/enums/sort-direction.enum.d.ts +4 -0
  36. package/dist/shared/domain/enums/sort-direction.enum.js +9 -0
  37. package/dist/shared/domain/enums/sort-direction.enum.js.map +1 -0
  38. package/dist/shared/domain/enums/user-context/user/user-role/user-role.enum.d.ts +4 -0
  39. package/dist/shared/domain/enums/user-context/user/user-role/user-role.enum.js +9 -0
  40. package/dist/shared/domain/enums/user-context/user/user-role/user-role.enum.js.map +1 -0
  41. package/dist/shared/domain/enums/user-context/user/user-status/user-status.enum.d.ts +5 -0
  42. package/dist/shared/domain/enums/user-context/user/user-status/user-status.enum.js +10 -0
  43. package/dist/shared/domain/enums/user-context/user/user-status/user-status.enum.js.map +1 -0
  44. package/dist/shared/domain/events/base-event.interface.d.ts +13 -0
  45. package/dist/shared/domain/events/base-event.interface.js +21 -0
  46. package/dist/shared/domain/events/base-event.interface.js.map +1 -0
  47. package/dist/shared/domain/exceptions/base.exception.d.ts +6 -0
  48. package/dist/shared/domain/exceptions/base.exception.js +23 -0
  49. package/dist/shared/domain/exceptions/base.exception.js.map +1 -0
  50. package/dist/shared/domain/exceptions/value-objects/invalid-boolean/invalid-boolean.exception.d.ts +4 -0
  51. package/dist/shared/domain/exceptions/value-objects/invalid-boolean/invalid-boolean.exception.js +12 -0
  52. package/dist/shared/domain/exceptions/value-objects/invalid-boolean/invalid-boolean.exception.js.map +1 -0
  53. package/dist/shared/domain/exceptions/value-objects/invalid-color/invalid-color.exception.d.ts +4 -0
  54. package/dist/shared/domain/exceptions/value-objects/invalid-color/invalid-color.exception.js +11 -0
  55. package/dist/shared/domain/exceptions/value-objects/invalid-color/invalid-color.exception.js.map +1 -0
  56. package/dist/shared/domain/exceptions/value-objects/invalid-dimensions/invalid-dimensions.exception.d.ts +4 -0
  57. package/dist/shared/domain/exceptions/value-objects/invalid-dimensions/invalid-dimensions.exception.js +11 -0
  58. package/dist/shared/domain/exceptions/value-objects/invalid-dimensions/invalid-dimensions.exception.js.map +1 -0
  59. package/dist/shared/domain/exceptions/value-objects/invalid-email/invalid-email.exception.d.ts +4 -0
  60. package/dist/shared/domain/exceptions/value-objects/invalid-email/invalid-email.exception.js +11 -0
  61. package/dist/shared/domain/exceptions/value-objects/invalid-email/invalid-email.exception.js.map +1 -0
  62. package/dist/shared/domain/exceptions/value-objects/invalid-enum-value/invalid-enum-value.exception.d.ts +4 -0
  63. package/dist/shared/domain/exceptions/value-objects/invalid-enum-value/invalid-enum-value.exception.js +11 -0
  64. package/dist/shared/domain/exceptions/value-objects/invalid-enum-value/invalid-enum-value.exception.js.map +1 -0
  65. package/dist/shared/domain/exceptions/value-objects/invalid-hex/invalid-hex.exception.d.ts +4 -0
  66. package/dist/shared/domain/exceptions/value-objects/invalid-hex/invalid-hex.exception.js +11 -0
  67. package/dist/shared/domain/exceptions/value-objects/invalid-hex/invalid-hex.exception.js.map +1 -0
  68. package/dist/shared/domain/exceptions/value-objects/invalid-ip/invalid-ip.exception.d.ts +4 -0
  69. package/dist/shared/domain/exceptions/value-objects/invalid-ip/invalid-ip.exception.js +11 -0
  70. package/dist/shared/domain/exceptions/value-objects/invalid-ip/invalid-ip.exception.js.map +1 -0
  71. package/dist/shared/domain/exceptions/value-objects/invalid-json/invalid-json.exception.d.ts +4 -0
  72. package/dist/shared/domain/exceptions/value-objects/invalid-json/invalid-json.exception.js +11 -0
  73. package/dist/shared/domain/exceptions/value-objects/invalid-json/invalid-json.exception.js.map +1 -0
  74. package/dist/shared/domain/exceptions/value-objects/invalid-locale/invalid-locale.exception.d.ts +4 -0
  75. package/dist/shared/domain/exceptions/value-objects/invalid-locale/invalid-locale.exception.js +12 -0
  76. package/dist/shared/domain/exceptions/value-objects/invalid-locale/invalid-locale.exception.js.map +1 -0
  77. package/dist/shared/domain/exceptions/value-objects/invalid-number/invalid-number.exception.d.ts +4 -0
  78. package/dist/shared/domain/exceptions/value-objects/invalid-number/invalid-number.exception.js +11 -0
  79. package/dist/shared/domain/exceptions/value-objects/invalid-number/invalid-number.exception.js.map +1 -0
  80. package/dist/shared/domain/exceptions/value-objects/invalid-numeric-range/invalid-numeric-range.exception.d.ts +4 -0
  81. package/dist/shared/domain/exceptions/value-objects/invalid-numeric-range/invalid-numeric-range.exception.js +11 -0
  82. package/dist/shared/domain/exceptions/value-objects/invalid-numeric-range/invalid-numeric-range.exception.js.map +1 -0
  83. package/dist/shared/domain/exceptions/value-objects/invalid-password/invalid-password.exception.d.ts +4 -0
  84. package/dist/shared/domain/exceptions/value-objects/invalid-password/invalid-password.exception.js +11 -0
  85. package/dist/shared/domain/exceptions/value-objects/invalid-password/invalid-password.exception.js.map +1 -0
  86. package/dist/shared/domain/exceptions/value-objects/invalid-phone/invalid-phone.exception.d.ts +4 -0
  87. package/dist/shared/domain/exceptions/value-objects/invalid-phone/invalid-phone.exception.js +11 -0
  88. package/dist/shared/domain/exceptions/value-objects/invalid-phone/invalid-phone.exception.js.map +1 -0
  89. package/dist/shared/domain/exceptions/value-objects/invalid-string/invalid-string.exception.d.ts +4 -0
  90. package/dist/shared/domain/exceptions/value-objects/invalid-string/invalid-string.exception.js +11 -0
  91. package/dist/shared/domain/exceptions/value-objects/invalid-string/invalid-string.exception.js.map +1 -0
  92. package/dist/shared/domain/exceptions/value-objects/invalid-timezone/invalid-timezone.exception.d.ts +4 -0
  93. package/dist/shared/domain/exceptions/value-objects/invalid-timezone/invalid-timezone.exception.js +12 -0
  94. package/dist/shared/domain/exceptions/value-objects/invalid-timezone/invalid-timezone.exception.js.map +1 -0
  95. package/dist/shared/domain/exceptions/value-objects/invalid-url/invalid-url.exception.d.ts +4 -0
  96. package/dist/shared/domain/exceptions/value-objects/invalid-url/invalid-url.exception.js +11 -0
  97. package/dist/shared/domain/exceptions/value-objects/invalid-url/invalid-url.exception.js.map +1 -0
  98. package/dist/shared/domain/exceptions/value-objects/invalid-uuid/invalid-uuid.exception.d.ts +4 -0
  99. package/dist/shared/domain/exceptions/value-objects/invalid-uuid/invalid-uuid.exception.js +11 -0
  100. package/dist/shared/domain/exceptions/value-objects/invalid-uuid/invalid-uuid.exception.js.map +1 -0
  101. package/dist/shared/domain/interfaces/base-aggregate-dto.interface.d.ts +5 -0
  102. package/dist/shared/domain/interfaces/base-aggregate-dto.interface.js +3 -0
  103. package/dist/shared/domain/interfaces/base-aggregate-dto.interface.js.map +1 -0
  104. package/dist/shared/domain/interfaces/base-view-model-dto.interface.d.ts +5 -0
  105. package/dist/shared/domain/interfaces/base-view-model-dto.interface.js +3 -0
  106. package/dist/shared/domain/interfaces/base-view-model-dto.interface.js.map +1 -0
  107. package/dist/shared/domain/interfaces/event-metadata.interface.d.ts +7 -0
  108. package/dist/shared/domain/interfaces/event-metadata.interface.js +3 -0
  109. package/dist/shared/domain/interfaces/event-metadata.interface.js.map +1 -0
  110. package/dist/shared/domain/interfaces/events/base-event-data.interface.d.ts +4 -0
  111. package/dist/shared/domain/interfaces/events/base-event-data.interface.js +3 -0
  112. package/dist/shared/domain/interfaces/events/base-event-data.interface.js.map +1 -0
  113. package/dist/shared/domain/interfaces/factories/read-factory.interface.d.ts +5 -0
  114. package/dist/shared/domain/interfaces/factories/read-factory.interface.js +3 -0
  115. package/dist/shared/domain/interfaces/factories/read-factory.interface.js.map +1 -0
  116. package/dist/shared/domain/interfaces/factories/write-factory.interface.d.ts +4 -0
  117. package/dist/shared/domain/interfaces/factories/write-factory.interface.js +3 -0
  118. package/dist/shared/domain/interfaces/factories/write-factory.interface.js.map +1 -0
  119. package/dist/shared/domain/interfaces/numeric-range.interface.d.ts +4 -0
  120. package/dist/shared/domain/interfaces/numeric-range.interface.js +3 -0
  121. package/dist/shared/domain/interfaces/numeric-range.interface.js.map +1 -0
  122. package/dist/shared/domain/interfaces/repository/base-read-repository.interface.d.ts +8 -0
  123. package/dist/shared/domain/interfaces/repository/base-read-repository.interface.js +3 -0
  124. package/dist/shared/domain/interfaces/repository/base-read-repository.interface.js.map +1 -0
  125. package/dist/shared/domain/interfaces/repository/base-write-repository.interface.d.ts +5 -0
  126. package/dist/shared/domain/interfaces/repository/base-write-repository.interface.js +3 -0
  127. package/dist/shared/domain/interfaces/repository/base-write-repository.interface.js.map +1 -0
  128. package/dist/shared/domain/interfaces/updated-field.interface.d.ts +5 -0
  129. package/dist/shared/domain/interfaces/updated-field.interface.js +3 -0
  130. package/dist/shared/domain/interfaces/updated-field.interface.js.map +1 -0
  131. package/dist/shared/domain/primitives/base-primitives/base.primitives.d.ts +4 -0
  132. package/dist/shared/domain/primitives/base-primitives/base.primitives.js +3 -0
  133. package/dist/shared/domain/primitives/base-primitives/base.primitives.js.map +1 -0
  134. package/dist/shared/domain/value-objects/base/value-object.base.d.ts +11 -0
  135. package/dist/shared/domain/value-objects/base/value-object.base.js +40 -0
  136. package/dist/shared/domain/value-objects/base/value-object.base.js.map +1 -0
  137. package/dist/shared/domain/value-objects/boolean/boolean.vo.d.ts +26 -0
  138. package/dist/shared/domain/value-objects/boolean/boolean.vo.js +102 -0
  139. package/dist/shared/domain/value-objects/boolean/boolean.vo.js.map +1 -0
  140. package/dist/shared/domain/value-objects/color/color.vo.d.ts +21 -0
  141. package/dist/shared/domain/value-objects/color/color.vo.js +127 -0
  142. package/dist/shared/domain/value-objects/color/color.vo.js.map +1 -0
  143. package/dist/shared/domain/value-objects/date/date.vo.d.ts +9 -0
  144. package/dist/shared/domain/value-objects/date/date.vo.js +23 -0
  145. package/dist/shared/domain/value-objects/date/date.vo.js.map +1 -0
  146. package/dist/shared/domain/value-objects/dimensions/dimensions.vo.d.ts +68 -0
  147. package/dist/shared/domain/value-objects/dimensions/dimensions.vo.js +182 -0
  148. package/dist/shared/domain/value-objects/dimensions/dimensions.vo.js.map +1 -0
  149. package/dist/shared/domain/value-objects/email/email.vo.d.ts +12 -0
  150. package/dist/shared/domain/value-objects/email/email.vo.js +48 -0
  151. package/dist/shared/domain/value-objects/email/email.vo.js.map +1 -0
  152. package/dist/shared/domain/value-objects/enum/enum.vo.d.ts +35 -0
  153. package/dist/shared/domain/value-objects/enum/enum.vo.js +137 -0
  154. package/dist/shared/domain/value-objects/enum/enum.vo.js.map +1 -0
  155. package/dist/shared/domain/value-objects/hex/hex.vo.d.ts +11 -0
  156. package/dist/shared/domain/value-objects/hex/hex.vo.js +38 -0
  157. package/dist/shared/domain/value-objects/hex/hex.vo.js.map +1 -0
  158. package/dist/shared/domain/value-objects/ip/ip.vo.d.ts +19 -0
  159. package/dist/shared/domain/value-objects/ip/ip.vo.js +90 -0
  160. package/dist/shared/domain/value-objects/ip/ip.vo.js.map +1 -0
  161. package/dist/shared/domain/value-objects/json/json.vo.d.ts +43 -0
  162. package/dist/shared/domain/value-objects/json/json.vo.js +224 -0
  163. package/dist/shared/domain/value-objects/json/json.vo.js.map +1 -0
  164. package/dist/shared/domain/value-objects/length-unit/length-unit.vo.d.ts +5 -0
  165. package/dist/shared/domain/value-objects/length-unit/length-unit.vo.js +12 -0
  166. package/dist/shared/domain/value-objects/length-unit/length-unit.vo.js.map +1 -0
  167. package/dist/shared/domain/value-objects/locale/locale.vo.d.ts +27 -0
  168. package/dist/shared/domain/value-objects/locale/locale.vo.js +292 -0
  169. package/dist/shared/domain/value-objects/locale/locale.vo.js.map +1 -0
  170. package/dist/shared/domain/value-objects/number/number.vo.d.ts +23 -0
  171. package/dist/shared/domain/value-objects/number/number.vo.js +77 -0
  172. package/dist/shared/domain/value-objects/number/number.vo.js.map +1 -0
  173. package/dist/shared/domain/value-objects/numeric-range/numeric-range.vo.d.ts +13 -0
  174. package/dist/shared/domain/value-objects/numeric-range/numeric-range.vo.js +35 -0
  175. package/dist/shared/domain/value-objects/numeric-range/numeric-range.vo.js.map +1 -0
  176. package/dist/shared/domain/value-objects/password/password.vo.d.ts +14 -0
  177. package/dist/shared/domain/value-objects/password/password.vo.js +90 -0
  178. package/dist/shared/domain/value-objects/password/password.vo.js.map +1 -0
  179. package/dist/shared/domain/value-objects/phone/phone.vo.d.ts +13 -0
  180. package/dist/shared/domain/value-objects/phone/phone.vo.js +56 -0
  181. package/dist/shared/domain/value-objects/phone/phone.vo.js.map +1 -0
  182. package/dist/shared/domain/value-objects/phone-code/phone-code.vo.d.ts +25 -0
  183. package/dist/shared/domain/value-objects/phone-code/phone-code.vo.js +344 -0
  184. package/dist/shared/domain/value-objects/phone-code/phone-code.vo.js.map +1 -0
  185. package/dist/shared/domain/value-objects/slug/slug.vo.d.ts +25 -0
  186. package/dist/shared/domain/value-objects/slug/slug.vo.js +87 -0
  187. package/dist/shared/domain/value-objects/slug/slug.vo.js.map +1 -0
  188. package/dist/shared/domain/value-objects/string/string.vo.d.ts +38 -0
  189. package/dist/shared/domain/value-objects/string/string.vo.js +146 -0
  190. package/dist/shared/domain/value-objects/string/string.vo.js.map +1 -0
  191. package/dist/shared/domain/value-objects/timezone/timezone.vo.d.ts +23 -0
  192. package/dist/shared/domain/value-objects/timezone/timezone.vo.js +116 -0
  193. package/dist/shared/domain/value-objects/timezone/timezone.vo.js.map +1 -0
  194. package/dist/shared/domain/value-objects/url/url.vo.d.ts +9 -0
  195. package/dist/shared/domain/value-objects/url/url.vo.js +31 -0
  196. package/dist/shared/domain/value-objects/url/url.vo.js.map +1 -0
  197. package/dist/shared/domain/value-objects/uuid/uuid.vo.d.ts +13 -0
  198. package/dist/shared/domain/value-objects/uuid/uuid.vo.js +49 -0
  199. package/dist/shared/domain/value-objects/uuid/uuid.vo.js.map +1 -0
  200. package/dist/shared/domain/view-models/base-view-model/base-view-model.d.ts +14 -0
  201. package/dist/shared/domain/view-models/base-view-model/base-view-model.js +24 -0
  202. package/dist/shared/domain/view-models/base-view-model/base-view-model.js.map +1 -0
  203. package/dist/shared/infrastructure/database/base-database.repository.d.ts +11 -0
  204. package/dist/shared/infrastructure/database/base-database.repository.js +14 -0
  205. package/dist/shared/infrastructure/database/base-database.repository.js.map +1 -0
  206. package/dist/shared/infrastructure/database/mongodb/base-mongo/base-mongo-database.repository.d.ts +9 -0
  207. package/dist/shared/infrastructure/database/mongodb/base-mongo/base-mongo-database.repository.js +78 -0
  208. package/dist/shared/infrastructure/database/mongodb/base-mongo/base-mongo-database.repository.js.map +1 -0
  209. package/dist/shared/infrastructure/database/mongodb/base-mongo/base-mongo-master/base-mongo-master.repository.d.ts +6 -0
  210. package/dist/shared/infrastructure/database/mongodb/base-mongo/base-mongo-master/base-mongo-master.repository.js +12 -0
  211. package/dist/shared/infrastructure/database/mongodb/base-mongo/base-mongo-master/base-mongo-master.repository.js.map +1 -0
  212. package/dist/shared/infrastructure/database/mongodb/dtos/base-mongo.dto.d.ts +5 -0
  213. package/dist/shared/infrastructure/database/mongodb/dtos/base-mongo.dto.js +3 -0
  214. package/dist/shared/infrastructure/database/mongodb/dtos/base-mongo.dto.js.map +1 -0
  215. package/dist/shared/infrastructure/database/mongodb/mongodb.module.d.ts +2 -0
  216. package/dist/shared/infrastructure/database/mongodb/mongodb.module.js +23 -0
  217. package/dist/shared/infrastructure/database/mongodb/mongodb.module.js.map +1 -0
  218. package/dist/shared/infrastructure/database/mongodb/services/mongo-master/mongo-master.service.d.ts +14 -0
  219. package/dist/shared/infrastructure/database/mongodb/services/mongo-master/mongo-master.service.js +57 -0
  220. package/dist/shared/infrastructure/database/mongodb/services/mongo-master/mongo-master.service.js.map +1 -0
  221. package/dist/shared/infrastructure/database/typeorm/base-typeorm/base-typeorm-master/base-typeorm-master.repository.d.ts +9 -0
  222. package/dist/shared/infrastructure/database/typeorm/base-typeorm/base-typeorm-master/base-typeorm-master.repository.js +18 -0
  223. package/dist/shared/infrastructure/database/typeorm/base-typeorm/base-typeorm-master/base-typeorm-master.repository.js.map +1 -0
  224. package/dist/shared/infrastructure/database/typeorm/data-source.d.ts +4 -0
  225. package/dist/shared/infrastructure/database/typeorm/data-source.js +33 -0
  226. package/dist/shared/infrastructure/database/typeorm/data-source.js.map +1 -0
  227. package/dist/shared/infrastructure/database/typeorm/dtos/base-typeorm.dto.d.ts +4 -0
  228. package/dist/shared/infrastructure/database/typeorm/dtos/base-typeorm.dto.js +3 -0
  229. package/dist/shared/infrastructure/database/typeorm/dtos/base-typeorm.dto.js.map +1 -0
  230. package/dist/shared/infrastructure/database/typeorm/entities/base-typeorm.entity.d.ts +6 -0
  231. package/dist/shared/infrastructure/database/typeorm/entities/base-typeorm.entity.js +36 -0
  232. package/dist/shared/infrastructure/database/typeorm/entities/base-typeorm.entity.js.map +1 -0
  233. package/dist/shared/infrastructure/database/typeorm/services/typeorm-master/typeorm-master.service.d.ts +9 -0
  234. package/dist/shared/infrastructure/database/typeorm/services/typeorm-master/typeorm-master.service.js +42 -0
  235. package/dist/shared/infrastructure/database/typeorm/services/typeorm-master/typeorm-master.service.js.map +1 -0
  236. package/dist/shared/infrastructure/database/typeorm/typeorm-module-options.factory.d.ts +3 -0
  237. package/dist/shared/infrastructure/database/typeorm/typeorm-module-options.factory.js +32 -0
  238. package/dist/shared/infrastructure/database/typeorm/typeorm-module-options.factory.js.map +1 -0
  239. package/dist/shared/infrastructure/database/typeorm/typeorm.module.d.ts +2 -0
  240. package/dist/shared/infrastructure/database/typeorm/typeorm.module.js +34 -0
  241. package/dist/shared/infrastructure/database/typeorm/typeorm.module.js.map +1 -0
  242. package/dist/shared/infrastructure/logging/factories/create-shared-winston-logger-options.d.ts +6 -0
  243. package/dist/shared/infrastructure/logging/factories/create-shared-winston-logger-options.js +92 -0
  244. package/dist/shared/infrastructure/logging/factories/create-shared-winston-logger-options.js.map +1 -0
  245. package/dist/shared/infrastructure/logging/formats/shared-winston.formats.d.ts +3 -0
  246. package/dist/shared/infrastructure/logging/formats/shared-winston.formats.js +30 -0
  247. package/dist/shared/infrastructure/logging/formats/shared-winston.formats.js.map +1 -0
  248. package/dist/shared/infrastructure/logging/interfaces/shared-winston-logger-factory-options.interface.d.ts +21 -0
  249. package/dist/shared/infrastructure/logging/interfaces/shared-winston-logger-factory-options.interface.js +3 -0
  250. package/dist/shared/infrastructure/logging/interfaces/shared-winston-logger-factory-options.interface.js.map +1 -0
  251. package/dist/shared/shared.module.d.ts +3 -0
  252. package/dist/shared/shared.module.js +51 -0
  253. package/dist/shared/shared.module.js.map +1 -0
  254. package/dist/shared/transport/graphql/dtos/requests/base-filter/base-filter.input.d.ts +6 -0
  255. package/dist/shared/transport/graphql/dtos/requests/base-filter/base-filter.input.js +40 -0
  256. package/dist/shared/transport/graphql/dtos/requests/base-filter/base-filter.input.js.map +1 -0
  257. package/dist/shared/transport/graphql/dtos/requests/base-find-by-criteria/base-find-by-criteria.input.d.ts +8 -0
  258. package/dist/shared/transport/graphql/dtos/requests/base-find-by-criteria/base-find-by-criteria.input.js +56 -0
  259. package/dist/shared/transport/graphql/dtos/requests/base-find-by-criteria/base-find-by-criteria.input.js.map +1 -0
  260. package/dist/shared/transport/graphql/dtos/requests/base-pagination/base-pagination.input.d.ts +4 -0
  261. package/dist/shared/transport/graphql/dtos/requests/base-pagination/base-pagination.input.js +33 -0
  262. package/dist/shared/transport/graphql/dtos/requests/base-pagination/base-pagination.input.js.map +1 -0
  263. package/dist/shared/transport/graphql/dtos/requests/base-sort/base-sort.input.d.ts +5 -0
  264. package/dist/shared/transport/graphql/dtos/requests/base-sort/base-sort.input.js +34 -0
  265. package/dist/shared/transport/graphql/dtos/requests/base-sort/base-sort.input.js.map +1 -0
  266. package/dist/shared/transport/graphql/dtos/requests/numeric-range/numeric-range.input.d.ts +4 -0
  267. package/dist/shared/transport/graphql/dtos/requests/numeric-range/numeric-range.input.js +31 -0
  268. package/dist/shared/transport/graphql/dtos/requests/numeric-range/numeric-range.input.js.map +1 -0
  269. package/dist/shared/transport/graphql/dtos/responses/base-paginated-result/base-paginated-result.dto.d.ts +6 -0
  270. package/dist/shared/transport/graphql/dtos/responses/base-paginated-result/base-paginated-result.dto.js +36 -0
  271. package/dist/shared/transport/graphql/dtos/responses/base-paginated-result/base-paginated-result.dto.js.map +1 -0
  272. package/dist/shared/transport/graphql/dtos/responses/numeric-range/numeric-range.dto.d.ts +4 -0
  273. package/dist/shared/transport/graphql/dtos/responses/numeric-range/numeric-range.dto.js +31 -0
  274. package/dist/shared/transport/graphql/dtos/responses/numeric-range/numeric-range.dto.js.map +1 -0
  275. package/dist/shared/transport/graphql/dtos/responses/success-response/success-response.dto.d.ts +5 -0
  276. package/dist/shared/transport/graphql/dtos/responses/success-response/success-response.dto.js +32 -0
  277. package/dist/shared/transport/graphql/dtos/responses/success-response/success-response.dto.js.map +1 -0
  278. package/dist/shared/transport/graphql/dtos/success-response-array.dto.d.ts +5 -0
  279. package/dist/shared/transport/graphql/dtos/success-response-array.dto.js +32 -0
  280. package/dist/shared/transport/graphql/dtos/success-response-array.dto.js.map +1 -0
  281. package/dist/shared/transport/graphql/enums/shared-registered-enums.graphql.d.ts +1 -0
  282. package/dist/shared/transport/graphql/enums/shared-registered-enums.graphql.js +15 -0
  283. package/dist/shared/transport/graphql/enums/shared-registered-enums.graphql.js.map +1 -0
  284. package/dist/shared/transport/graphql/mappers/mutation-response/mutation-response.mapper.d.ts +6 -0
  285. package/dist/shared/transport/graphql/mappers/mutation-response/mutation-response.mapper.js +31 -0
  286. package/dist/shared/transport/graphql/mappers/mutation-response/mutation-response.mapper.js.map +1 -0
  287. package/dist/shared/transport/graphql/plugins/complexity.plugin.d.ts +4 -0
  288. package/dist/shared/transport/graphql/plugins/complexity.plugin.js +40 -0
  289. package/dist/shared/transport/graphql/plugins/complexity.plugin.js.map +1 -0
  290. package/dist/shared/transport/graphql/registered-enums/registered-enums.graphql.d.ts +1 -0
  291. package/dist/shared/transport/graphql/registered-enums/registered-enums.graphql.js +33 -0
  292. package/dist/shared/transport/graphql/registered-enums/registered-enums.graphql.js.map +1 -0
  293. package/dist/tsconfig.build.tsbuildinfo +1 -0
  294. package/package.json +152 -0
package/README.md ADDED
@@ -0,0 +1,770 @@
1
+ # @sisques-labs/nestjs-kit
2
+
3
+ **NestJS Kit** — a shared NestJS library providing **Domain-Driven Design (DDD)** and **CQRS** building blocks, **validated value objects**, **repository abstractions**, optional **MongoDB** and **TypeORM** helpers, **GraphQL** DTOs and plugins, and optional **Winston logger configuration** (for use with `nest-winston` in consuming apps) for microservices and modular monoliths.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Publishing](#publishing)
8
+ - [CI](#ci)
9
+ - [Release workflow](#release-workflow)
10
+ - [Publish from your machine](#publish-from-your-machine)
11
+ - [Installation](#installation)
12
+ - [Peer Dependencies](#peer-dependencies)
13
+ - [Local development](#local-development)
14
+ - [Module Setup](#module-setup)
15
+ - [Domain Layer](#domain-layer)
16
+ - [Base Aggregate](#base-aggregate)
17
+ - [Value Objects](#value-objects)
18
+ - [Aggregate and entity IDs](#aggregate-and-entity-ids)
19
+ - [Domain Exceptions](#domain-exceptions)
20
+ - [Criteria & Pagination](#criteria--pagination)
21
+ - [Repository Interfaces](#repository-interfaces)
22
+ - [Factory Interfaces](#factory-interfaces)
23
+ - [View Models](#view-models)
24
+ - [Domain Events](#domain-events)
25
+ - [Application Layer](#application-layer)
26
+ - [Command Handlers](#command-handlers)
27
+ - [Service Interface](#service-interface)
28
+ - [Infrastructure Layer](#infrastructure-layer)
29
+ - [Logging (Winston)](#logging-winston)
30
+ - [MongoDB](#mongodb)
31
+ - [TypeORM](#typeorm)
32
+ - [Transport Layer (GraphQL)](#transport-layer-graphql)
33
+ - [Input DTOs](#input-dtos)
34
+ - [Response DTOs](#response-dtos)
35
+ - [Mappers](#mappers)
36
+ - [Complexity Plugin](#complexity-plugin)
37
+ - [Enums](#enums)
38
+
39
+ ---
40
+
41
+ ## Publishing
42
+
43
+ The package is published to the public npm registry as [`@sisques-labs/nestjs-kit`](https://www.npmjs.com/package/@sisques-labs/nestjs-kit) (see `publishConfig` in `package.json`). Releases are automated with GitHub Actions.
44
+
45
+ | Workflow | File | Trigger |
46
+ |---|---|---|
47
+ | **CI** | `.github/workflows/ci.yml` | Push and pull requests targeting `main` |
48
+ | **Release** | `.github/workflows/release.yml` | Manual (`workflow_dispatch`) |
49
+
50
+ ### CI
51
+
52
+ Runs `pnpm install --frozen-lockfile`, **`pnpm lint`** (ESLint with `--fix`), **`pnpm build`**, and **`pnpm test`**.
53
+
54
+ ### Release workflow
55
+
56
+ Open **GitHub → Actions → Release → Run workflow** and choose:
57
+
58
+ | Input | Purpose |
59
+ |---|---|
60
+ | **version** | `patch`, `minor`, or `major` ([SemVer](https://semver.org)) |
61
+ | **release_type** | `stable` (default dist-tag) or prerelease **`alpha`** / **`beta`** (separate dist-tags) |
62
+
63
+ The job then: runs lint and tests, bumps the version with `npm version`, builds, publishes with **`pnpm publish`** using the **`NPM_TOKEN`** repository secret, commits `package.json` / lockfile, creates a git tag, pushes to `main`, and creates a GitHub Release with generated notes.
64
+
65
+ **Repository setup:** add an [npm automation token](https://docs.npmjs.com/creating-and-viewing-access-tokens) with publish rights as the **`NPM_TOKEN`** secret (GitHub → Settings → Secrets and variables → Actions).
66
+
67
+ ### Publish from your machine
68
+
69
+ ```bash
70
+ npm login
71
+ pnpm build
72
+ pnpm publish
73
+ ```
74
+
75
+ The `prepublishOnly` script runs **`npm run build`** before publish so `dist/` is current.
76
+
77
+ ---
78
+
79
+ ## Installation
80
+
81
+ The package is **public** on npm; a normal install is enough:
82
+
83
+ ```bash
84
+ pnpm add @sisques-labs/nestjs-kit
85
+ # or: npm install / yarn add @sisques-labs/nestjs-kit
86
+ ```
87
+
88
+ Use your organization’s registry or mirror policy if applicable.
89
+
90
+ If you previously used **`@sisques-labs/shared-nestjs`**, uninstall it and depend on **`@sisques-labs/nestjs-kit`** instead; replace every import path from `'@sisques-labs/shared-nestjs'` to `'@sisques-labs/nestjs-kit'` (API unchanged).
91
+
92
+ ---
93
+
94
+ ## Peer Dependencies
95
+
96
+ Install only what your app uses. Peers marked **optional** in `peerDependenciesMeta` can be omitted if you do not import that part of the library.
97
+
98
+ ```bash
99
+ # Core NestJS (required for any integration)
100
+ pnpm add @nestjs/common @nestjs/core reflect-metadata rxjs
101
+
102
+ # CQRS (command handlers, EventBus)
103
+ pnpm add @nestjs/cqrs
104
+
105
+ # MongoDB module + repositories in this package
106
+ pnpm add mongodb @nestjs/config
107
+
108
+ # TypeORM module + repositories in this package
109
+ pnpm add typeorm @nestjs/typeorm @nestjs/config
110
+
111
+ # GraphQL DTOs, Apollo, complexity plugin
112
+ pnpm add graphql @nestjs/graphql @nestjs/apollo @apollo/server graphql-query-complexity
113
+
114
+ # class-validator / class-transformer (typical for GraphQL inputs)
115
+ pnpm add class-validator class-transformer
116
+
117
+ # Winston logging (shared config + nest-winston in your app)
118
+ pnpm add nest-winston winston winston-daily-rotate-file
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Local development
124
+
125
+ For contributors working on this repository:
126
+
127
+ | Script | Description |
128
+ |---|---|
129
+ | `pnpm install` | Installs dependencies; **`prepare`** runs Husky and **`pnpm build`**. |
130
+ | `pnpm build` | Compiles TypeScript to `dist/` (`nest build`). |
131
+ | `pnpm lint` | ESLint with `--fix` on `src`, `apps`, `libs`, `test`. |
132
+ | `pnpm lint:check` | ESLint without autofix (used by **Husky pre-commit**). |
133
+ | `pnpm test` | Jest unit tests (`*.spec.ts` under `src/`). |
134
+ | `pnpm test:cov` | Tests with coverage. |
135
+ | `pnpm format` | Prettier on `src` and `test` TypeScript. |
136
+
137
+ **Git hooks:** [Husky](https://typicode.github.io/husky/) runs **`pnpm lint:check`** and **`pnpm test`** on **pre-commit** (see `.husky/pre-commit`). To skip hooks for a one-off commit: `HUSKY=0 git commit ...`.
138
+
139
+ ---
140
+
141
+
142
+ ## Module Setup
143
+
144
+ Import **`SharedModule`** in your root or core module. It is **`@Global()`** and only registers cross-cutting pieces that do not require a database (for example **`MutationResponseGraphQLMapper`** and shared GraphQL enum registration). It does **not** import MongoDB or TypeORM—you add those only if you need them.
145
+
146
+ ```typescript
147
+ import { Module } from '@nestjs/common';
148
+ import { SharedModule } from '@sisques-labs/nestjs-kit';
149
+
150
+ @Module({
151
+ imports: [SharedModule],
152
+ })
153
+ export class AppModule {}
154
+ ```
155
+
156
+ **Optional database modules** (import alongside `SharedModule` when you use them):
157
+
158
+ - **`MongoModule`** — provides `MongoMasterService` (`MONGODB_URI`, `MONGODB_DATABASE` via `ConfigService`).
159
+ - **`TypeOrmModule`** — registers `TypeOrmModule.forRootAsync` using `DATABASE_*` config; requires **`ConfigModule`** in the app (for example `ConfigModule.forRoot({ isGlobal: true })`).
160
+
161
+ ```typescript
162
+ import { Module } from '@nestjs/common';
163
+ import { ConfigModule } from '@nestjs/config';
164
+ import {
165
+ SharedModule,
166
+ MongoModule,
167
+ TypeOrmModule,
168
+ } from '@sisques-labs/nestjs-kit';
169
+
170
+ @Module({
171
+ imports: [
172
+ ConfigModule.forRoot({ isGlobal: true }),
173
+ SharedModule,
174
+ MongoModule, // omit if you do not use MongoDB
175
+ TypeOrmModule, // omit if you do not use TypeORM
176
+ ],
177
+ })
178
+ export class AppModule {}
179
+ ```
180
+
181
+ **Logging is separate:** this library does **not** register `WinstonModule`. Import **`WinstonModule`** from `nest-winston` in your app and pass **`createSharedWinstonLoggerOptions()`** or **`defaultSharedWinstonLoggerOptions`**—see [Logging (Winston)](#logging-winston).
182
+
183
+ ---
184
+
185
+ ## Domain Layer
186
+
187
+ ### Base Aggregate
188
+
189
+ `BaseAggregate` extends `@nestjs/cqrs` **`AggregateRoot`** and wires **`createdAt`** and **`updatedAt`** as `DateValueObject` properties. Add identity and domain fields in your subclass (for example a `UuidValueObject` or app-specific id type).
190
+
191
+ ```typescript
192
+ import {
193
+ BaseAggregate,
194
+ DateValueObject,
195
+ EmailValueObject,
196
+ UuidValueObject,
197
+ } from '@sisques-labs/nestjs-kit';
198
+
199
+ export class UserAggregate extends BaseAggregate {
200
+ constructor(
201
+ private readonly _id: UuidValueObject,
202
+ private _email: EmailValueObject,
203
+ createdAt: DateValueObject,
204
+ updatedAt: DateValueObject,
205
+ ) {
206
+ super(createdAt, updatedAt);
207
+ }
208
+
209
+ get id(): UuidValueObject {
210
+ return this._id;
211
+ }
212
+ }
213
+ ```
214
+
215
+ Use `apply()`, `commit()`, and related `AggregateRoot` APIs for domain events as usual.
216
+
217
+ ---
218
+
219
+ ### Value Objects
220
+
221
+ All value objects are immutable and validate their input on construction, throwing a typed domain exception on invalid data.
222
+
223
+ #### Basic Scalars
224
+
225
+ | Class | Description |
226
+ |---|---|
227
+ | `StringValueObject` | String with optional min/max length, pattern, and trim |
228
+ | `NumberValueObject` | Numeric value with validation |
229
+ | `BooleanValueObject` | Boolean wrapper |
230
+ | `DateValueObject` | Date wrapper |
231
+ | `JsonValueObject` | Valid JSON value |
232
+ | `EnumValueObject<T>` | Typed enum wrapper |
233
+
234
+ #### Format-Specific
235
+
236
+ | Class | Description |
237
+ |---|---|
238
+ | `EmailValueObject` | RFC 5322 compliant. Methods: `getLocalPart()`, `getDomain()` |
239
+ | `UuidValueObject` | RFC 4122. Methods: `getVersion()`, `isNil()`, static `generate()` |
240
+ | `PhoneValueObject` | E.164 format. Methods: `getCountryCode()`, `toE164()` |
241
+ | `UrlValueObject` | Valid URL |
242
+ | `IpValueObject` | IPv4/IPv6 validation |
243
+ | `HexValueObject` | Hexadecimal string |
244
+ | `ColorValueObject` | Hex, RGB, HSL, and named colors with conversion methods |
245
+ | `SlugValueObject` | URL-friendly slug. Methods: `toHumanReadable()`, `addPrefix()`, `addSuffix()`, static `generateSlug()` |
246
+ | `PasswordValueObject` | Strength scoring, common password detection. Methods: `getStrengthScore()`, `meetsRequirements()` |
247
+ | `LocaleValueObject` | BCP 47 locale (50+ supported). Methods: `getLanguageCode()`, `getCountryCode()`, `getDisplayName()` |
248
+ | `TimezoneValueObject` | IANA timezone |
249
+ | `PhoneCodeValueObject` | Phone dial code |
250
+ | `LengthUnitValueObject` | Unit of length measurement |
251
+ | `DimensionsValueObject` | Length, width, height with unit and optional bounds |
252
+ | `NumericRangeValueObject` | Min/max numeric range |
253
+
254
+ **Usage example:**
255
+
256
+ ```typescript
257
+ import {
258
+ EmailValueObject,
259
+ UuidValueObject,
260
+ PasswordValueObject,
261
+ } from '@sisques-labs/nestjs-kit';
262
+
263
+ const email = new EmailValueObject('user@example.com');
264
+ console.log(email.getDomain()); // 'example.com'
265
+
266
+ const id = UuidValueObject.generate();
267
+ console.log(id.getVersion()); // 4
268
+
269
+ const password = new PasswordValueObject('MyS3cur3P@ss!');
270
+ console.log(password.getStrengthScore()); // number 0-5
271
+ console.log(password.meetsRequirements()); // boolean
272
+ ```
273
+
274
+ Many value objects also have a **folder-level `README.md`** under `src/shared/domain/value-objects/<name>/` with API tables and examples.
275
+
276
+ ---
277
+
278
+ ### Aggregate and entity IDs
279
+
280
+ The library exports **`UuidValueObject`** for validated RFC 4122 UUID strings (construction, `generate()`, `getVersion()`, `isNil()`, etc.).
281
+
282
+ For **aggregate- or entity-specific** identifiers (nominal typing per bounded context), define thin subclasses or wrappers **in your application**, for example:
283
+
284
+ ```typescript
285
+ import { UuidValueObject } from '@sisques-labs/nestjs-kit';
286
+
287
+ export class UserId extends UuidValueObject {
288
+ // optional: narrow type or factory methods for your domain
289
+ }
290
+ ```
291
+
292
+ ---
293
+
294
+ ### Domain Exceptions
295
+
296
+ `BaseException` is the root exception class. Each value object has a corresponding typed exception thrown on validation failure.
297
+
298
+ ```typescript
299
+ import { BaseException } from '@sisques-labs/nestjs-kit';
300
+
301
+ // BaseException provides:
302
+ // - timestamp: Date
303
+ // - getDetailedMessage(): string → "[ClassName]: message"
304
+ // - toJSON(): object
305
+ ```
306
+
307
+ Available typed exceptions (all extend `BaseException`):
308
+
309
+ `InvalidBooleanException`, `InvalidColorException`, `InvalidDimensionsException`, `InvalidEmailException`, `InvalidEnumValueException`, `InvalidHexException`, `InvalidIpException`, `InvalidJsonException`, `InvalidLocaleException`, `InvalidNumberException`, `InvalidNumericRangeException`, `InvalidPasswordException`, `InvalidPhoneException`, `InvalidStringException`, `InvalidTimezoneException`, `InvalidUrlException`, `InvalidUuidException`
310
+
311
+ ---
312
+
313
+ ### Criteria & Pagination
314
+
315
+ Use `Criteria` to build type-safe query parameters with filters, sorts, and pagination.
316
+
317
+ ```typescript
318
+ import {
319
+ Criteria,
320
+ FilterOperator,
321
+ SortDirection,
322
+ } from '@sisques-labs/nestjs-kit';
323
+
324
+ const criteria = new Criteria(
325
+ [{ field: 'email', operator: FilterOperator.EQUALS, value: 'user@example.com' }],
326
+ [{ field: 'createdAt', direction: SortDirection.DESC }],
327
+ { page: 1, perPage: 20 },
328
+ );
329
+ ```
330
+
331
+ `PaginatedResult<T>` wraps paginated query results:
332
+
333
+ ```typescript
334
+ import { PaginatedResult } from '@sisques-labs/nestjs-kit';
335
+
336
+ // { data: T[], total: number, page: number, perPage: number }
337
+ const result: PaginatedResult<User> = await repository.findByCriteria(criteria);
338
+ ```
339
+
340
+ ---
341
+
342
+ ### Repository Interfaces
343
+
344
+ Implement these interfaces in your infrastructure layer to keep the domain free of database concerns.
345
+
346
+ ```typescript
347
+ import {
348
+ IBaseReadRepository,
349
+ IBaseWriteRepository,
350
+ } from '@sisques-labs/nestjs-kit';
351
+
352
+ // Read side: findById, findByCriteria, save, delete
353
+ interface IUserReadRepository extends IBaseReadRepository<UserAggregate> {}
354
+
355
+ // Write side: findById, save, delete
356
+ interface IUserWriteRepository extends IBaseWriteRepository<UserAggregate> {}
357
+ ```
358
+
359
+ ---
360
+
361
+ ### Factory Interfaces
362
+
363
+ Factories handle deserialization of aggregates from different sources.
364
+
365
+ ```typescript
366
+ import { IReadFactory, IWriteFactory } from '@sisques-labs/nestjs-kit';
367
+
368
+ // Read factory: creates view models from aggregates, DTOs, or primitives
369
+ class UserReadFactory implements IReadFactory<UserViewModel, UserAggregate, UserDto> {
370
+ create(data: UserDto): UserViewModel { ... }
371
+ fromAggregate(aggregate: UserAggregate): UserViewModel { ... }
372
+ fromPrimitives(primitives: object): UserViewModel { ... }
373
+ }
374
+
375
+ // Write factory: creates aggregates from commands or primitives
376
+ class UserWriteFactory implements IWriteFactory<UserAggregate, CreateUserCommand, UserPrimitives> {
377
+ create(command: CreateUserCommand): UserAggregate { ... }
378
+ fromPrimitives(primitives: UserPrimitives): UserAggregate { ... }
379
+ }
380
+ ```
381
+
382
+ ---
383
+
384
+ ### View Models
385
+
386
+ `BaseViewModel` provides a base for read-side projections with typed accessors for `id`, `createdAt`, and `updatedAt`.
387
+
388
+ ```typescript
389
+ import { BaseViewModel } from '@sisques-labs/nestjs-kit';
390
+
391
+ export class UserViewModel extends BaseViewModel {
392
+ // Inherited: getId(), getCreatedAt(), getUpdatedAt()
393
+ }
394
+ ```
395
+
396
+ ---
397
+
398
+ ### Domain Events
399
+
400
+ `IBaseEventData` and `IEventMetadata` provide a structured shape for domain events with aggregate and entity metadata.
401
+
402
+ ```typescript
403
+ import { IBaseEventData, IEventMetadata } from '@sisques-labs/nestjs-kit';
404
+
405
+ // IEventMetadata shape:
406
+ // {
407
+ // aggregateRootId: string;
408
+ // aggregateRootType: string;
409
+ // entityId: string;
410
+ // entityType: string;
411
+ // eventType: string;
412
+ // }
413
+ ```
414
+
415
+ ---
416
+
417
+ ## Application Layer
418
+
419
+ ### Command Handlers
420
+
421
+ `BaseCommandHandler` integrates the `EventBus` to publish domain events automatically after command execution.
422
+
423
+ ```typescript
424
+ import { BaseCommandHandler } from '@sisques-labs/nestjs-kit';
425
+ import { CommandHandler, EventBus } from '@nestjs/cqrs';
426
+
427
+ @CommandHandler(CreateUserCommand)
428
+ export class CreateUserCommandHandler extends BaseCommandHandler<CreateUserCommand> {
429
+ constructor(
430
+ private readonly repository: IUserWriteRepository,
431
+ eventBus: EventBus,
432
+ ) {
433
+ super(eventBus);
434
+ }
435
+
436
+ async execute(command: CreateUserCommand): Promise<void> {
437
+ const user = UserWriteFactory.create(command);
438
+ await this.repository.save(user);
439
+ this.publishEvents(user); // publishes domain events from the aggregate
440
+ }
441
+ }
442
+ ```
443
+
444
+ `BaseUpdateCommandHandler` adds utilities to extract changed fields from update commands, useful for partial updates.
445
+
446
+ ---
447
+
448
+ ### Service Interface
449
+
450
+ `IBaseService` is a marker interface for application services.
451
+
452
+ ```typescript
453
+ import { IBaseService } from '@sisques-labs/nestjs-kit';
454
+
455
+ @Injectable()
456
+ export class UserService implements IBaseService {}
457
+ ```
458
+
459
+ ---
460
+
461
+ ## Infrastructure Layer
462
+
463
+ ### Logging (Winston)
464
+
465
+ Optional **Winston `LoggerOptions`** (JSON file rotation + console formats) for use with **`WinstonModule.forRoot`** from **`nest-winston`** in the consuming app. Install `nest-winston`, `winston`, and `winston-daily-rotate-file` there; this package lists `winston` and `winston-daily-rotate-file` as optional peers.
466
+
467
+ **Main exports:** `createSharedWinstonLoggerOptions`, `defaultSharedWinstonLoggerOptions`, `mergeSharedWinstonLoggerOptions`, `createSharedJsonLogFormat`, `createSharedConsoleLogFormat`, and `SharedWinstonLoggerFactoryOptions`.
468
+
469
+ **Full guide:** [src/shared/infrastructure/logging/README.md](src/shared/infrastructure/logging/README.md)
470
+
471
+ ---
472
+
473
+ ### MongoDB
474
+
475
+ Import **`MongoModule`** from this package when you use MongoDB repositories. It is **not** part of **`SharedModule`**.
476
+
477
+ #### Environment Variables
478
+
479
+ The shared `MongoMasterService` reads:
480
+
481
+ ```env
482
+ MONGODB_URI=mongodb://localhost:27017
483
+ MONGODB_DATABASE=my_database
484
+ ```
485
+
486
+ #### Base Repository
487
+
488
+ Extend `BaseMongoMasterRepository` to get filter, sort, and pagination support out of the box.
489
+
490
+ ```typescript
491
+ import {
492
+ BaseMongoMasterRepository,
493
+ MongoMasterService,
494
+ Criteria,
495
+ PaginatedResult,
496
+ } from '@sisques-labs/nestjs-kit';
497
+
498
+ @Injectable()
499
+ export class UserMongoRepository extends BaseMongoMasterRepository<UserMongoDto> {
500
+ constructor(mongoService: MongoMasterService) {
501
+ super(mongoService, 'users'); // collection name
502
+ }
503
+
504
+ async findByCriteria(criteria: Criteria): Promise<PaginatedResult<UserAggregate>> {
505
+ return this.executeQueryWithPagination(criteria);
506
+ // Automatically maps FilterOperator → MongoDB $operators
507
+ // Applies sorts and pagination (skip/limit)
508
+ }
509
+ }
510
+ ```
511
+
512
+ `FilterOperator` → MongoDB operator mapping:
513
+
514
+ | Enum value | MongoDB operator |
515
+ |---|---|
516
+ | `EQUALS` | `$eq` |
517
+ | `NOT_EQUALS` | `$ne` |
518
+ | `LIKE` | `$regex` |
519
+ | `IN` | `$in` |
520
+ | `GT` | `$gt` |
521
+ | `LT` | `$lt` |
522
+ | `GTE` | `$gte` |
523
+ | `LTE` | `$lte` |
524
+
525
+ #### Base DTO
526
+
527
+ ```typescript
528
+ import { BaseMongoDto } from '@sisques-labs/nestjs-kit';
529
+
530
+ // Type: { id: string; createdAt: Date; updatedAt: Date }
531
+ type UserMongoDto = BaseMongoDto & {
532
+ email: string;
533
+ name: string;
534
+ };
535
+ ```
536
+
537
+ ---
538
+
539
+ ### TypeORM
540
+
541
+ Import **`TypeOrmModule`** when you use TypeORM. It is **not** part of **`SharedModule`**. Use **`ConfigModule.forRoot`** (global or imported) so `ConfigService` is available; options are built at runtime via **`buildTypeOrmModuleOptions`** inside `forRootAsync`—no database env is read when you merely `import` the package.
542
+
543
+ #### Environment Variables
544
+
545
+ ```env
546
+ DATABASE_DRIVER=postgres
547
+ DATABASE_HOST=localhost
548
+ DATABASE_PORT=5432
549
+ DATABASE_USERNAME=postgres
550
+ DATABASE_PASSWORD=secret
551
+ DATABASE_DATABASE=my_database
552
+ DATABASE_SYNCHRONIZE=false
553
+ DATABASE_MIGRATIONS_TABLE_NAME=migrations
554
+ ```
555
+
556
+ Optional: `NODE_ENV` (affects query logging). For TypeORM CLI migrations that use `data-source.ts`, the same variables must be set in the environment when the CLI runs.
557
+
558
+ #### Base Entity
559
+
560
+ ```typescript
561
+ import { BaseTypeormEntity } from '@sisques-labs/nestjs-kit';
562
+ import { Entity, Column } from 'typeorm';
563
+
564
+ @Entity('users')
565
+ export class UserTypeormEntity extends BaseTypeormEntity {
566
+ // Inherited: id (UUID, primary key), createdAt, updatedAt, deletedAt (soft delete)
567
+
568
+ @Column()
569
+ email: string;
570
+ }
571
+ ```
572
+
573
+ #### Base Repository
574
+
575
+ ```typescript
576
+ import {
577
+ BaseTypeormMasterRepository,
578
+ TypeormMasterService,
579
+ } from '@sisques-labs/nestjs-kit';
580
+
581
+ @Injectable()
582
+ export class UserTypeormRepository extends BaseTypeormMasterRepository {
583
+ constructor(typeormService: TypeormMasterService) {
584
+ super(typeormService);
585
+ }
586
+
587
+ async findById(id: string): Promise<UserAggregate | null> {
588
+ const repo = this.getRepository(UserTypeormEntity);
589
+ const entity = await repo.findOneBy({ id });
590
+ return entity ? UserWriteFactory.fromPrimitives(entity) : null;
591
+ }
592
+ }
593
+ ```
594
+
595
+ #### Base DTO
596
+
597
+ ```typescript
598
+ import { BaseTypeormDto } from '@sisques-labs/nestjs-kit';
599
+
600
+ // Type: { id: string; createdAt: Date; updatedAt: Date }
601
+ type UserTypeormDto = BaseTypeormDto & {
602
+ email: string;
603
+ };
604
+ ```
605
+
606
+ ---
607
+
608
+ ## Transport Layer (GraphQL)
609
+
610
+ ### Input DTOs
611
+
612
+ #### `BaseFindByCriteriaInput`
613
+
614
+ Composite input for list queries combining filters, sorts, and pagination.
615
+
616
+ ```graphql
617
+ query {
618
+ users(
619
+ criteria: {
620
+ filters: [{ field: "email", operator: EQUALS, value: "user@example.com" }]
621
+ sorts: [{ field: "createdAt", direction: DESC }]
622
+ pagination: { page: 1, perPage: 20 }
623
+ }
624
+ ) {
625
+ total
626
+ page
627
+ perPage
628
+ totalPages
629
+ data { id email }
630
+ }
631
+ }
632
+ ```
633
+
634
+ ```typescript
635
+ import { BaseFindByCriteriaInput } from '@sisques-labs/nestjs-kit';
636
+
637
+ @Resolver()
638
+ export class UserResolver {
639
+ @Query(() => UsersPaginatedResult)
640
+ users(@Args('criteria') criteria: BaseFindByCriteriaInput) {
641
+ return this.userService.findByCriteria(criteria);
642
+ }
643
+ }
644
+ ```
645
+
646
+ Individual input types: `BaseFilterInput`, `BaseSortInput`, `BasePaginationInput`, `NumericRangeInput`.
647
+
648
+ ---
649
+
650
+ ### Response DTOs
651
+
652
+ #### `BasePaginatedResultDto`
653
+
654
+ ```typescript
655
+ import { BasePaginatedResultDto } from '@sisques-labs/nestjs-kit';
656
+ import { ObjectType, Field } from '@nestjs/graphql';
657
+
658
+ @ObjectType()
659
+ export class UsersPaginatedResult extends BasePaginatedResultDto {
660
+ @Field(() => [UserDto])
661
+ data: UserDto[];
662
+ // Inherited: total, page, perPage, totalPages (computed automatically)
663
+ }
664
+ ```
665
+
666
+ #### `MutationResponseDto`
667
+
668
+ ```typescript
669
+ import { MutationResponseDto } from '@sisques-labs/nestjs-kit';
670
+
671
+ // Shape: { success: boolean; message?: string; id?: string }
672
+
673
+ @Mutation(() => MutationResponseDto)
674
+ createUser(@Args('input') input: CreateUserInput): Promise<MutationResponseDto> { ... }
675
+ ```
676
+
677
+ #### `MutationResponseArrayDto`
678
+
679
+ ```typescript
680
+ import { MutationResponseArrayDto } from '@sisques-labs/nestjs-kit';
681
+
682
+ // Shape: { success: boolean; message?: string; ids: string[] }
683
+
684
+ @Mutation(() => MutationResponseArrayDto)
685
+ deleteUsers(@Args('ids', { type: () => [String] }) ids: string[]): Promise<MutationResponseArrayDto> { ... }
686
+ ```
687
+
688
+ ---
689
+
690
+ ### Mappers
691
+
692
+ `MutationResponseGraphQLMapper` is a NestJS injectable service provided by `SharedModule` that maps domain results to `MutationResponseDto`.
693
+
694
+ ```typescript
695
+ import { MutationResponseGraphQLMapper } from '@sisques-labs/nestjs-kit';
696
+
697
+ @Resolver()
698
+ export class UserResolver {
699
+ constructor(private readonly mutationMapper: MutationResponseGraphQLMapper) {}
700
+
701
+ @Mutation(() => MutationResponseDto)
702
+ async createUser(@Args('input') input: CreateUserInput) {
703
+ const result = await this.commandBus.execute(new CreateUserCommand(input));
704
+ return this.mutationMapper.map(result);
705
+ }
706
+ }
707
+ ```
708
+
709
+ ---
710
+
711
+ ### Complexity Plugin
712
+
713
+ `ComplexityPlugin` is an **Apollo Server plugin** (`@Plugin()` from `@nestjs/apollo`) that rejects operations whose estimated complexity exceeds **1000** (see `graphql-query-complexity`). It is **exported** from this package but **not** registered inside `SharedModule`—add it to your GraphQL module’s **`providers`** (or equivalent) so Nest discovers the plugin.
714
+
715
+ To assign complexity weights to fields use the `@Complexity` decorator from `@nestjs/graphql`:
716
+
717
+ ```typescript
718
+ import { Field, ObjectType, Complexity } from '@nestjs/graphql';
719
+
720
+ @ObjectType()
721
+ export class UserDto {
722
+ @Field()
723
+ @Complexity(1)
724
+ id: string;
725
+ }
726
+ ```
727
+
728
+ Register the plugin (for example next to your GraphQL module):
729
+
730
+ ```typescript
731
+ import { Module } from '@nestjs/common';
732
+ import { ComplexityPlugin } from '@sisques-labs/nestjs-kit';
733
+
734
+ @Module({
735
+ providers: [ComplexityPlugin],
736
+ })
737
+ export class GraphqlPluginsModule {}
738
+ ```
739
+
740
+ ---
741
+
742
+ ## Enums
743
+
744
+ ```typescript
745
+ import {
746
+ FilterOperator,
747
+ SortDirection,
748
+ LengthUnitEnum,
749
+ UserRoleEnum,
750
+ UserStatusEnum,
751
+ } from '@sisques-labs/nestjs-kit';
752
+
753
+ FilterOperator.EQUALS // 'eq'
754
+ FilterOperator.NOT_EQUALS // 'ne'
755
+ FilterOperator.LIKE // 'like'
756
+ FilterOperator.IN // 'in'
757
+ FilterOperator.GT // 'gt'
758
+ FilterOperator.LT // 'lt'
759
+ FilterOperator.GTE // 'gte'
760
+ FilterOperator.LTE // 'lte'
761
+
762
+ SortDirection.ASC
763
+ SortDirection.DESC
764
+ ```
765
+
766
+ ---
767
+
768
+ ## License
769
+
770
+ MIT — [Sisques Labs](https://github.com/JSisques)