@carlonicora/nestjs-neo4jsonapi 1.115.0 → 1.116.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 (395) hide show
  1. package/dist/bootstrap/app.module.factory.d.ts.map +1 -1
  2. package/dist/bootstrap/app.module.factory.js +1 -0
  3. package/dist/bootstrap/app.module.factory.js.map +1 -1
  4. package/dist/bootstrap/bootstrap.options.d.ts +17 -0
  5. package/dist/bootstrap/bootstrap.options.d.ts.map +1 -1
  6. package/dist/common/guards/jwt.auth.guard.d.ts +3 -2
  7. package/dist/common/guards/jwt.auth.guard.d.ts.map +1 -1
  8. package/dist/common/guards/jwt.auth.guard.js +7 -2
  9. package/dist/common/guards/jwt.auth.guard.js.map +1 -1
  10. package/dist/common/interfaces/entity.schema.interface.d.ts +2 -0
  11. package/dist/common/interfaces/entity.schema.interface.d.ts.map +1 -1
  12. package/dist/common/tokens.d.ts +64 -0
  13. package/dist/common/tokens.d.ts.map +1 -1
  14. package/dist/common/tokens.js +37 -2
  15. package/dist/common/tokens.js.map +1 -1
  16. package/dist/config/base.config.d.ts.map +1 -1
  17. package/dist/config/base.config.js +1 -0
  18. package/dist/config/base.config.js.map +1 -1
  19. package/dist/config/enums/queue.id.d.ts +2 -1
  20. package/dist/config/enums/queue.id.d.ts.map +1 -1
  21. package/dist/config/enums/queue.id.js +1 -0
  22. package/dist/config/enums/queue.id.js.map +1 -1
  23. package/dist/config/interfaces/config.auth.interface.d.ts +7 -0
  24. package/dist/config/interfaces/config.auth.interface.d.ts.map +1 -1
  25. package/dist/config/interfaces/config.email.interface.d.ts +6 -0
  26. package/dist/config/interfaces/config.email.interface.d.ts.map +1 -1
  27. package/dist/core/email/services/email.service.d.ts +1 -0
  28. package/dist/core/email/services/email.service.d.ts.map +1 -1
  29. package/dist/core/email/services/email.service.js +22 -18
  30. package/dist/core/email/services/email.service.js.map +1 -1
  31. package/dist/core/llm/services/llm.service.d.ts +9 -1
  32. package/dist/core/llm/services/llm.service.d.ts.map +1 -1
  33. package/dist/core/llm/services/llm.service.js +13 -3
  34. package/dist/core/llm/services/llm.service.js.map +1 -1
  35. package/dist/core/neo4j/abstracts/abstract.repository.d.ts.map +1 -1
  36. package/dist/core/neo4j/abstracts/abstract.repository.js +33 -2
  37. package/dist/core/neo4j/abstracts/abstract.repository.js.map +1 -1
  38. package/dist/foundations/auth/auth.module.d.ts.map +1 -1
  39. package/dist/foundations/auth/auth.module.js +9 -10
  40. package/dist/foundations/auth/auth.module.js.map +1 -1
  41. package/dist/foundations/auth/controllers/auth.controller.d.ts.map +1 -1
  42. package/dist/foundations/auth/controllers/auth.controller.js +5 -0
  43. package/dist/foundations/auth/controllers/auth.controller.js.map +1 -1
  44. package/dist/foundations/auth/controllers/auth.discord.controller.d.ts.map +1 -1
  45. package/dist/foundations/auth/controllers/auth.discord.controller.js +6 -3
  46. package/dist/foundations/auth/controllers/auth.discord.controller.js.map +1 -1
  47. package/dist/foundations/auth/controllers/auth.google.controller.d.ts.map +1 -1
  48. package/dist/foundations/auth/controllers/auth.google.controller.js +7 -3
  49. package/dist/foundations/auth/controllers/auth.google.controller.js.map +1 -1
  50. package/dist/foundations/auth/entities/auth.code.d.ts +34 -0
  51. package/dist/foundations/auth/entities/auth.code.d.ts.map +1 -0
  52. package/dist/foundations/auth/entities/auth.code.js +53 -0
  53. package/dist/foundations/auth/entities/auth.code.js.map +1 -0
  54. package/dist/foundations/auth/entities/auth.d.ts +41 -0
  55. package/dist/foundations/auth/entities/auth.d.ts.map +1 -0
  56. package/dist/foundations/auth/entities/auth.js +68 -0
  57. package/dist/foundations/auth/entities/auth.js.map +1 -0
  58. package/dist/foundations/auth/entities/pending-auth.d.ts +39 -0
  59. package/dist/foundations/auth/entities/pending-auth.d.ts.map +1 -0
  60. package/dist/foundations/auth/entities/pending-auth.js +41 -0
  61. package/dist/foundations/auth/entities/pending-auth.js.map +1 -0
  62. package/dist/foundations/auth/index.d.ts +13 -0
  63. package/dist/foundations/auth/index.d.ts.map +1 -1
  64. package/dist/foundations/auth/index.js +31 -1
  65. package/dist/foundations/auth/index.js.map +1 -1
  66. package/dist/foundations/auth/repositories/auth.repository.d.ts +49 -9
  67. package/dist/foundations/auth/repositories/auth.repository.d.ts.map +1 -1
  68. package/dist/foundations/auth/repositories/auth.repository.js +115 -63
  69. package/dist/foundations/auth/repositories/auth.repository.js.map +1 -1
  70. package/dist/foundations/auth/services/auth.discord.service.d.ts +1 -1
  71. package/dist/foundations/auth/services/auth.discord.service.d.ts.map +1 -1
  72. package/dist/foundations/auth/services/auth.discord.service.js +5 -2
  73. package/dist/foundations/auth/services/auth.discord.service.js.map +1 -1
  74. package/dist/foundations/auth/services/auth.google.service.d.ts +1 -1
  75. package/dist/foundations/auth/services/auth.google.service.d.ts.map +1 -1
  76. package/dist/foundations/auth/services/auth.google.service.js +6 -2
  77. package/dist/foundations/auth/services/auth.google.service.js.map +1 -1
  78. package/dist/foundations/auth/services/auth.service.d.ts +42 -7
  79. package/dist/foundations/auth/services/auth.service.d.ts.map +1 -1
  80. package/dist/foundations/auth/services/auth.service.js +140 -77
  81. package/dist/foundations/auth/services/auth.service.js.map +1 -1
  82. package/dist/foundations/company/entities/company.d.ts +1 -1
  83. package/dist/foundations/company/entities/company.d.ts.map +1 -1
  84. package/dist/foundations/company/entities/company.js +15 -1
  85. package/dist/foundations/company/entities/company.js.map +1 -1
  86. package/dist/foundations/company/index.d.ts +5 -0
  87. package/dist/foundations/company/index.d.ts.map +1 -1
  88. package/dist/foundations/company/index.js +16 -1
  89. package/dist/foundations/company/index.js.map +1 -1
  90. package/dist/foundations/company/processors/company.processor.js +1 -1
  91. package/dist/foundations/company/processors/company.processor.js.map +1 -1
  92. package/dist/foundations/company/repositories/company.repository.d.ts +65 -9
  93. package/dist/foundations/company/repositories/company.repository.d.ts.map +1 -1
  94. package/dist/foundations/company/repositories/company.repository.js +59 -18
  95. package/dist/foundations/company/repositories/company.repository.js.map +1 -1
  96. package/dist/foundations/company/services/company.service.d.ts +44 -4
  97. package/dist/foundations/company/services/company.service.d.ts.map +1 -1
  98. package/dist/foundations/company/services/company.service.js +33 -7
  99. package/dist/foundations/company/services/company.service.js.map +1 -1
  100. package/dist/foundations/content/content.module.d.ts +20 -8
  101. package/dist/foundations/content/content.module.d.ts.map +1 -1
  102. package/dist/foundations/content/content.module.js +40 -24
  103. package/dist/foundations/content/content.module.js.map +1 -1
  104. package/dist/foundations/content/controllers/content.controller.d.ts +1 -1
  105. package/dist/foundations/content/controllers/content.controller.d.ts.map +1 -1
  106. package/dist/foundations/content/controllers/content.controller.js +2 -2
  107. package/dist/foundations/content/controllers/content.controller.js.map +1 -1
  108. package/dist/foundations/content/entities/content.d.ts +74 -0
  109. package/dist/foundations/content/entities/content.d.ts.map +1 -0
  110. package/dist/foundations/content/entities/content.js +141 -0
  111. package/dist/foundations/content/entities/content.js.map +1 -0
  112. package/dist/foundations/content/index.d.ts +2 -4
  113. package/dist/foundations/content/index.d.ts.map +1 -1
  114. package/dist/foundations/content/index.js +6 -5
  115. package/dist/foundations/content/index.js.map +1 -1
  116. package/dist/foundations/content/interfaces/content.extension.interface.d.ts +126 -0
  117. package/dist/foundations/content/interfaces/content.extension.interface.d.ts.map +1 -1
  118. package/dist/foundations/content/interfaces/content.extension.interface.js +7 -1
  119. package/dist/foundations/content/interfaces/content.extension.interface.js.map +1 -1
  120. package/dist/foundations/content/repositories/content.repository.d.ts +14 -7
  121. package/dist/foundations/content/repositories/content.repository.d.ts.map +1 -1
  122. package/dist/foundations/content/repositories/content.repository.js +18 -16
  123. package/dist/foundations/content/repositories/content.repository.js.map +1 -1
  124. package/dist/foundations/content/services/content.cypher.service.d.ts +19 -0
  125. package/dist/foundations/content/services/content.cypher.service.d.ts.map +1 -1
  126. package/dist/foundations/content/services/content.cypher.service.js +65 -4
  127. package/dist/foundations/content/services/content.cypher.service.js.map +1 -1
  128. package/dist/foundations/content/services/content.service.js +4 -4
  129. package/dist/foundations/content/services/content.service.js.map +1 -1
  130. package/dist/foundations/discord-user/services/discord-user.service.js +2 -2
  131. package/dist/foundations/discord-user/services/discord-user.service.js.map +1 -1
  132. package/dist/foundations/feature/entities/feature.d.ts +32 -0
  133. package/dist/foundations/feature/entities/feature.d.ts.map +1 -0
  134. package/dist/foundations/feature/entities/feature.js +64 -0
  135. package/dist/foundations/feature/entities/feature.js.map +1 -0
  136. package/dist/foundations/feature/entities/feature.model.d.ts +1 -3
  137. package/dist/foundations/feature/entities/feature.model.d.ts.map +1 -1
  138. package/dist/foundations/feature/entities/feature.model.js +3 -11
  139. package/dist/foundations/feature/entities/feature.model.js.map +1 -1
  140. package/dist/foundations/feature/feature.module.d.ts.map +1 -1
  141. package/dist/foundations/feature/feature.module.js +4 -5
  142. package/dist/foundations/feature/feature.module.js.map +1 -1
  143. package/dist/foundations/feature/index.d.ts +12 -0
  144. package/dist/foundations/feature/index.d.ts.map +1 -1
  145. package/dist/foundations/feature/index.js +22 -1
  146. package/dist/foundations/feature/index.js.map +1 -1
  147. package/dist/foundations/feature/repositories/feature.repository.d.ts +37 -13
  148. package/dist/foundations/feature/repositories/feature.repository.d.ts.map +1 -1
  149. package/dist/foundations/feature/repositories/feature.repository.js +41 -35
  150. package/dist/foundations/feature/repositories/feature.repository.js.map +1 -1
  151. package/dist/foundations/feature/services/feature.service.d.ts +31 -4
  152. package/dist/foundations/feature/services/feature.service.d.ts.map +1 -1
  153. package/dist/foundations/feature/services/feature.service.js +20 -12
  154. package/dist/foundations/feature/services/feature.service.js.map +1 -1
  155. package/dist/foundations/foundations.modules.d.ts +6 -0
  156. package/dist/foundations/foundations.modules.d.ts.map +1 -1
  157. package/dist/foundations/foundations.modules.js +14 -3
  158. package/dist/foundations/foundations.modules.js.map +1 -1
  159. package/dist/foundations/google-user/services/google-user.service.js +2 -2
  160. package/dist/foundations/google-user/services/google-user.service.js.map +1 -1
  161. package/dist/foundations/index.d.ts +3 -0
  162. package/dist/foundations/index.d.ts.map +1 -1
  163. package/dist/foundations/index.js +3 -0
  164. package/dist/foundations/index.js.map +1 -1
  165. package/dist/foundations/membership/entities/membership.d.ts.map +1 -1
  166. package/dist/foundations/membership/entities/membership.js +4 -0
  167. package/dist/foundations/membership/entities/membership.js.map +1 -1
  168. package/dist/foundations/notification/controllers/notification.controller.js +2 -2
  169. package/dist/foundations/notification/controllers/notification.controller.js.map +1 -1
  170. package/dist/foundations/notification/entities/notification.d.ts +75 -0
  171. package/dist/foundations/notification/entities/notification.d.ts.map +1 -0
  172. package/dist/foundations/notification/entities/notification.js +73 -0
  173. package/dist/foundations/notification/entities/notification.js.map +1 -0
  174. package/dist/foundations/notification/index.d.ts +6 -2
  175. package/dist/foundations/notification/index.d.ts.map +1 -1
  176. package/dist/foundations/notification/index.js +17 -3
  177. package/dist/foundations/notification/index.js.map +1 -1
  178. package/dist/foundations/notification/notification.module.d.ts.map +1 -1
  179. package/dist/foundations/notification/notification.module.js +3 -4
  180. package/dist/foundations/notification/notification.module.js.map +1 -1
  181. package/dist/foundations/notification/repositories/notification.repository.d.ts +125 -8
  182. package/dist/foundations/notification/repositories/notification.repository.d.ts.map +1 -1
  183. package/dist/foundations/notification/repositories/notification.repository.js +219 -20
  184. package/dist/foundations/notification/repositories/notification.repository.js.map +1 -1
  185. package/dist/foundations/notification/services/notification.service.d.ts +31 -5
  186. package/dist/foundations/notification/services/notification.service.d.ts.map +1 -1
  187. package/dist/foundations/notification/services/notification.service.js +26 -9
  188. package/dist/foundations/notification/services/notification.service.js.map +1 -1
  189. package/dist/foundations/rbac/dump.d.ts +48 -4
  190. package/dist/foundations/rbac/dump.d.ts.map +1 -1
  191. package/dist/foundations/rbac/dump.js +28 -4
  192. package/dist/foundations/rbac/dump.js.map +1 -1
  193. package/dist/foundations/rbac/serializer/matrix-to-ts.d.ts +14 -0
  194. package/dist/foundations/rbac/serializer/matrix-to-ts.d.ts.map +1 -1
  195. package/dist/foundations/rbac/serializer/matrix-to-ts.js +13 -3
  196. package/dist/foundations/rbac/serializer/matrix-to-ts.js.map +1 -1
  197. package/dist/foundations/relevancy/repositories/relevancy.repository.d.ts.map +1 -1
  198. package/dist/foundations/relevancy/repositories/relevancy.repository.js +13 -1
  199. package/dist/foundations/relevancy/repositories/relevancy.repository.js.map +1 -1
  200. package/dist/foundations/role/entities/role.d.ts +1 -1
  201. package/dist/foundations/role/entities/role.d.ts.map +1 -1
  202. package/dist/foundations/stripe/index.d.ts +3 -0
  203. package/dist/foundations/stripe/index.d.ts.map +1 -1
  204. package/dist/foundations/stripe/index.js +6 -0
  205. package/dist/foundations/stripe/index.js.map +1 -1
  206. package/dist/foundations/stripe-price/entities/stripe-price.entity.d.ts +1 -1
  207. package/dist/foundations/stripe-price/entities/stripe-price.entity.d.ts.map +1 -1
  208. package/dist/foundations/tokenusage/entities/tokenusage.d.ts +49 -0
  209. package/dist/foundations/tokenusage/entities/tokenusage.d.ts.map +1 -0
  210. package/dist/foundations/tokenusage/entities/tokenusage.js +64 -0
  211. package/dist/foundations/tokenusage/entities/tokenusage.js.map +1 -0
  212. package/dist/foundations/tokenusage/index.d.ts +2 -2
  213. package/dist/foundations/tokenusage/index.d.ts.map +1 -1
  214. package/dist/foundations/tokenusage/index.js +5 -3
  215. package/dist/foundations/tokenusage/index.js.map +1 -1
  216. package/dist/foundations/tokenusage/repositories/tokenusage.repository.d.ts +33 -5
  217. package/dist/foundations/tokenusage/repositories/tokenusage.repository.d.ts.map +1 -1
  218. package/dist/foundations/tokenusage/repositories/tokenusage.repository.js +40 -14
  219. package/dist/foundations/tokenusage/repositories/tokenusage.repository.js.map +1 -1
  220. package/dist/foundations/tokenusage/services/tokenusage.service.d.ts +36 -9
  221. package/dist/foundations/tokenusage/services/tokenusage.service.d.ts.map +1 -1
  222. package/dist/foundations/tokenusage/services/tokenusage.service.js +32 -3
  223. package/dist/foundations/tokenusage/services/tokenusage.service.js.map +1 -1
  224. package/dist/foundations/tokenusage/tokenusage.module.js +3 -3
  225. package/dist/foundations/tokenusage/tokenusage.module.js.map +1 -1
  226. package/dist/foundations/user/controllers/user.controller.js +4 -4
  227. package/dist/foundations/user/controllers/user.controller.js.map +1 -1
  228. package/dist/foundations/user/dtos/user.put.dto.d.ts +1 -1
  229. package/dist/foundations/user/dtos/user.put.dto.d.ts.map +1 -1
  230. package/dist/foundations/user/dtos/user.put.dto.js +1 -1
  231. package/dist/foundations/user/dtos/user.put.dto.js.map +1 -1
  232. package/dist/foundations/user/entities/user.d.ts +4 -0
  233. package/dist/foundations/user/entities/user.d.ts.map +1 -1
  234. package/dist/foundations/user/entities/user.js +18 -4
  235. package/dist/foundations/user/entities/user.js.map +1 -1
  236. package/dist/foundations/user/index.d.ts +6 -1
  237. package/dist/foundations/user/index.d.ts.map +1 -1
  238. package/dist/foundations/user/index.js +13 -1
  239. package/dist/foundations/user/index.js.map +1 -1
  240. package/dist/foundations/user/repositories/user.repository.d.ts +56 -11
  241. package/dist/foundations/user/repositories/user.repository.d.ts.map +1 -1
  242. package/dist/foundations/user/repositories/user.repository.js +55 -35
  243. package/dist/foundations/user/repositories/user.repository.js.map +1 -1
  244. package/dist/foundations/user/services/user.service.d.ts +48 -9
  245. package/dist/foundations/user/services/user.service.d.ts.map +1 -1
  246. package/dist/foundations/user/services/user.service.js +50 -32
  247. package/dist/foundations/user/services/user.service.js.map +1 -1
  248. package/dist/foundations/user-activity/entities/user-activity.d.ts +36 -0
  249. package/dist/foundations/user-activity/entities/user-activity.d.ts.map +1 -0
  250. package/dist/foundations/user-activity/entities/user-activity.js +86 -0
  251. package/dist/foundations/user-activity/entities/user-activity.js.map +1 -0
  252. package/dist/foundations/user-activity/entities/user-activity.meta.d.ts +3 -0
  253. package/dist/foundations/user-activity/entities/user-activity.meta.d.ts.map +1 -0
  254. package/dist/foundations/user-activity/entities/user-activity.meta.js +10 -0
  255. package/dist/foundations/user-activity/entities/user-activity.meta.js.map +1 -0
  256. package/dist/foundations/user-activity/index.d.ts +10 -0
  257. package/dist/foundations/user-activity/index.d.ts.map +1 -0
  258. package/dist/foundations/user-activity/index.js +22 -0
  259. package/dist/foundations/user-activity/index.js.map +1 -0
  260. package/dist/foundations/user-activity/interceptors/user-activity.interceptor.d.ts +29 -0
  261. package/dist/foundations/user-activity/interceptors/user-activity.interceptor.d.ts.map +1 -0
  262. package/dist/foundations/user-activity/interceptors/user-activity.interceptor.js +98 -0
  263. package/dist/foundations/user-activity/interceptors/user-activity.interceptor.js.map +1 -0
  264. package/dist/foundations/user-activity/interfaces/user-activity.config.interface.d.ts +67 -0
  265. package/dist/foundations/user-activity/interfaces/user-activity.config.interface.d.ts.map +1 -0
  266. package/dist/foundations/user-activity/interfaces/user-activity.config.interface.js +26 -0
  267. package/dist/foundations/user-activity/interfaces/user-activity.config.interface.js.map +1 -0
  268. package/dist/foundations/user-activity/interfaces/user-activity.record.input.d.ts +18 -0
  269. package/dist/foundations/user-activity/interfaces/user-activity.record.input.d.ts.map +1 -0
  270. package/dist/foundations/{auth/entities/auth.entity.js → user-activity/interfaces/user-activity.record.input.js} +1 -1
  271. package/dist/foundations/user-activity/interfaces/user-activity.record.input.js.map +1 -0
  272. package/dist/foundations/user-activity/processors/user-activity.processor.d.ts +25 -0
  273. package/dist/foundations/user-activity/processors/user-activity.processor.d.ts.map +1 -0
  274. package/dist/foundations/user-activity/processors/user-activity.processor.js +74 -0
  275. package/dist/foundations/user-activity/processors/user-activity.processor.js.map +1 -0
  276. package/dist/foundations/user-activity/repositories/user-activity.repository.d.ts +47 -0
  277. package/dist/foundations/user-activity/repositories/user-activity.repository.d.ts.map +1 -0
  278. package/dist/foundations/user-activity/repositories/user-activity.repository.js +124 -0
  279. package/dist/foundations/user-activity/repositories/user-activity.repository.js.map +1 -0
  280. package/dist/foundations/user-activity/services/user-activity.service.d.ts +29 -0
  281. package/dist/foundations/user-activity/services/user-activity.service.d.ts.map +1 -0
  282. package/dist/foundations/user-activity/services/user-activity.service.js +61 -0
  283. package/dist/foundations/user-activity/services/user-activity.service.js.map +1 -0
  284. package/dist/foundations/user-activity/user-activity.module.d.ts +40 -0
  285. package/dist/foundations/user-activity/user-activity.module.d.ts.map +1 -0
  286. package/dist/foundations/user-activity/user-activity.module.js +99 -0
  287. package/dist/foundations/user-activity/user-activity.module.js.map +1 -0
  288. package/package.json +1 -1
  289. package/dist/foundations/auth/entities/auth.code.entity.d.ts +0 -7
  290. package/dist/foundations/auth/entities/auth.code.entity.d.ts.map +0 -1
  291. package/dist/foundations/auth/entities/auth.code.entity.js +0 -3
  292. package/dist/foundations/auth/entities/auth.code.entity.js.map +0 -1
  293. package/dist/foundations/auth/entities/auth.code.map.d.ts +0 -8
  294. package/dist/foundations/auth/entities/auth.code.map.d.ts.map +0 -1
  295. package/dist/foundations/auth/entities/auth.code.map.js +0 -13
  296. package/dist/foundations/auth/entities/auth.code.map.js.map +0 -1
  297. package/dist/foundations/auth/entities/auth.code.model.d.ts +0 -4
  298. package/dist/foundations/auth/entities/auth.code.model.d.ts.map +0 -1
  299. package/dist/foundations/auth/entities/auth.code.model.js +0 -13
  300. package/dist/foundations/auth/entities/auth.code.model.js.map +0 -1
  301. package/dist/foundations/auth/entities/auth.entity.d.ts +0 -18
  302. package/dist/foundations/auth/entities/auth.entity.d.ts.map +0 -1
  303. package/dist/foundations/auth/entities/auth.entity.js.map +0 -1
  304. package/dist/foundations/auth/entities/auth.map.d.ts +0 -8
  305. package/dist/foundations/auth/entities/auth.map.d.ts.map +0 -1
  306. package/dist/foundations/auth/entities/auth.map.js +0 -14
  307. package/dist/foundations/auth/entities/auth.map.js.map +0 -1
  308. package/dist/foundations/auth/entities/auth.model.d.ts +0 -4
  309. package/dist/foundations/auth/entities/auth.model.d.ts.map +0 -1
  310. package/dist/foundations/auth/entities/auth.model.js +0 -15
  311. package/dist/foundations/auth/entities/auth.model.js.map +0 -1
  312. package/dist/foundations/auth/entities/pending-auth.entity.d.ts +0 -16
  313. package/dist/foundations/auth/entities/pending-auth.entity.d.ts.map +0 -1
  314. package/dist/foundations/auth/entities/pending-auth.entity.js +0 -3
  315. package/dist/foundations/auth/entities/pending-auth.entity.js.map +0 -1
  316. package/dist/foundations/auth/entities/pending-auth.map.d.ts +0 -6
  317. package/dist/foundations/auth/entities/pending-auth.map.d.ts.map +0 -1
  318. package/dist/foundations/auth/entities/pending-auth.map.js +0 -20
  319. package/dist/foundations/auth/entities/pending-auth.map.js.map +0 -1
  320. package/dist/foundations/auth/entities/pending-auth.model.d.ts +0 -9
  321. package/dist/foundations/auth/entities/pending-auth.model.d.ts.map +0 -1
  322. package/dist/foundations/auth/entities/pending-auth.model.js +0 -19
  323. package/dist/foundations/auth/entities/pending-auth.model.js.map +0 -1
  324. package/dist/foundations/auth/serialisers/auth.serialiser.d.ts +0 -13
  325. package/dist/foundations/auth/serialisers/auth.serialiser.d.ts.map +0 -1
  326. package/dist/foundations/auth/serialisers/auth.serialiser.js +0 -52
  327. package/dist/foundations/auth/serialisers/auth.serialiser.js.map +0 -1
  328. package/dist/foundations/auth/serialisers/pending-auth.serialiser.d.ts +0 -18
  329. package/dist/foundations/auth/serialisers/pending-auth.serialiser.d.ts.map +0 -1
  330. package/dist/foundations/auth/serialisers/pending-auth.serialiser.js +0 -49
  331. package/dist/foundations/auth/serialisers/pending-auth.serialiser.js.map +0 -1
  332. package/dist/foundations/content/entities/content.entity.d.ts +0 -31
  333. package/dist/foundations/content/entities/content.entity.d.ts.map +0 -1
  334. package/dist/foundations/content/entities/content.entity.js +0 -3
  335. package/dist/foundations/content/entities/content.entity.js.map +0 -1
  336. package/dist/foundations/content/entities/content.map.d.ts +0 -8
  337. package/dist/foundations/content/entities/content.map.d.ts.map +0 -1
  338. package/dist/foundations/content/entities/content.map.js +0 -19
  339. package/dist/foundations/content/entities/content.map.js.map +0 -1
  340. package/dist/foundations/content/entities/content.model.d.ts +0 -4
  341. package/dist/foundations/content/entities/content.model.d.ts.map +0 -1
  342. package/dist/foundations/content/entities/content.model.js +0 -16
  343. package/dist/foundations/content/entities/content.model.js.map +0 -1
  344. package/dist/foundations/content/factories/content.model.factory.d.ts +0 -17
  345. package/dist/foundations/content/factories/content.model.factory.d.ts.map +0 -1
  346. package/dist/foundations/content/factories/content.model.factory.js +0 -65
  347. package/dist/foundations/content/factories/content.model.factory.js.map +0 -1
  348. package/dist/foundations/content/serialisers/content.serialiser.d.ts +0 -14
  349. package/dist/foundations/content/serialisers/content.serialiser.d.ts.map +0 -1
  350. package/dist/foundations/content/serialisers/content.serialiser.js +0 -78
  351. package/dist/foundations/content/serialisers/content.serialiser.js.map +0 -1
  352. package/dist/foundations/feature/entities/feature.entity.d.ts +0 -8
  353. package/dist/foundations/feature/entities/feature.entity.d.ts.map +0 -1
  354. package/dist/foundations/feature/entities/feature.entity.js +0 -3
  355. package/dist/foundations/feature/entities/feature.entity.js.map +0 -1
  356. package/dist/foundations/feature/entities/feature.map.d.ts +0 -8
  357. package/dist/foundations/feature/entities/feature.map.d.ts.map +0 -1
  358. package/dist/foundations/feature/entities/feature.map.js +0 -14
  359. package/dist/foundations/feature/entities/feature.map.js.map +0 -1
  360. package/dist/foundations/feature/serialisers/feature.serialiser.d.ts +0 -12
  361. package/dist/foundations/feature/serialisers/feature.serialiser.d.ts.map +0 -1
  362. package/dist/foundations/feature/serialisers/feature.serialiser.js +0 -45
  363. package/dist/foundations/feature/serialisers/feature.serialiser.js.map +0 -1
  364. package/dist/foundations/notification/entities/notification.entity.d.ts +0 -10
  365. package/dist/foundations/notification/entities/notification.entity.d.ts.map +0 -1
  366. package/dist/foundations/notification/entities/notification.entity.js +0 -3
  367. package/dist/foundations/notification/entities/notification.entity.js.map +0 -1
  368. package/dist/foundations/notification/entities/notification.map.d.ts +0 -8
  369. package/dist/foundations/notification/entities/notification.map.d.ts.map +0 -1
  370. package/dist/foundations/notification/entities/notification.map.js +0 -16
  371. package/dist/foundations/notification/entities/notification.map.js.map +0 -1
  372. package/dist/foundations/notification/entities/notification.model.d.ts +0 -4
  373. package/dist/foundations/notification/entities/notification.model.d.ts.map +0 -1
  374. package/dist/foundations/notification/entities/notification.model.js +0 -15
  375. package/dist/foundations/notification/entities/notification.model.js.map +0 -1
  376. package/dist/foundations/notification/interfaces/notification.service.interface.d.ts +0 -4
  377. package/dist/foundations/notification/interfaces/notification.service.interface.d.ts.map +0 -1
  378. package/dist/foundations/notification/interfaces/notification.service.interface.js +0 -3
  379. package/dist/foundations/notification/interfaces/notification.service.interface.js.map +0 -1
  380. package/dist/foundations/notification/serialisers/notifications.serialiser.d.ts +0 -12
  381. package/dist/foundations/notification/serialisers/notifications.serialiser.d.ts.map +0 -1
  382. package/dist/foundations/notification/serialisers/notifications.serialiser.js +0 -47
  383. package/dist/foundations/notification/serialisers/notifications.serialiser.js.map +0 -1
  384. package/dist/foundations/tokenusage/entities/tokenusage.entity.d.ts +0 -11
  385. package/dist/foundations/tokenusage/entities/tokenusage.entity.d.ts.map +0 -1
  386. package/dist/foundations/tokenusage/entities/tokenusage.entity.js +0 -3
  387. package/dist/foundations/tokenusage/entities/tokenusage.entity.js.map +0 -1
  388. package/dist/foundations/tokenusage/entities/tokenusage.map.d.ts +0 -8
  389. package/dist/foundations/tokenusage/entities/tokenusage.map.d.ts.map +0 -1
  390. package/dist/foundations/tokenusage/entities/tokenusage.map.js +0 -17
  391. package/dist/foundations/tokenusage/entities/tokenusage.map.js.map +0 -1
  392. package/dist/foundations/tokenusage/entities/tokenusage.model.d.ts +0 -4
  393. package/dist/foundations/tokenusage/entities/tokenusage.model.d.ts.map +0 -1
  394. package/dist/foundations/tokenusage/entities/tokenusage.model.js +0 -15
  395. package/dist/foundations/tokenusage/entities/tokenusage.model.js.map +0 -1
@@ -12,28 +12,108 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.NotificationRepository = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
14
  const crypto_1 = require("crypto");
15
+ const nestjs_cls_1 = require("nestjs-cls");
16
+ const registry_1 = require("../../../common/registries/registry");
17
+ const abstract_repository_1 = require("../../../core/neo4j/abstracts/abstract.repository");
15
18
  const update_relationship_1 = require("../../../core/neo4j/queries/update.relationship");
16
19
  const neo4j_service_1 = require("../../../core/neo4j/services/neo4j.service");
20
+ const security_service_1 = require("../../../core/security/services/security.service");
21
+ const notification_1 = require("../../notification/entities/notification");
17
22
  const notification_meta_1 = require("../../notification/entities/notification.meta");
18
- const notification_model_1 = require("../../notification/entities/notification.model");
19
23
  const user_meta_1 = require("../../user/entities/user.meta");
20
- let NotificationRepository = class NotificationRepository {
21
- constructor(neo4j) {
22
- this.neo4j = neo4j;
24
+ /**
25
+ * Neo4j labels cannot be bound as query parameters, so `label` values supplied
26
+ * by callers are interpolated into Cypher. Every interpolated label is checked
27
+ * against this pattern first — ids and every other value stay parameterised.
28
+ */
29
+ const SAFE_LABEL = /^[A-Za-z_][A-Za-z0-9_]*$/;
30
+ /**
31
+ * Every method below is fully custom Cypher: the bell list/detail queries scope
32
+ * by TRIGGERED_FOR user and require a REFERS_TO edge to exist (see
33
+ * `findForUser`), and `createNotification`/`createIdempotent` write a bespoke
34
+ * subject graph. The generic descriptor-driven `create`/`put`/`patch`/`delete`/
35
+ * `find`/`findById` are INHERITED from `AbstractRepository` unchanged.
36
+ *
37
+ * NAMING — `find`/`findById` are named `findForUser`/`findByIdForUser`: their
38
+ * required `userId`/`notificationId` params are incompatible overrides of
39
+ * `AbstractRepository.find(params: {...all optional})` /
40
+ * `findById(params: { id })`. The bespoke creator is named `createNotification`
41
+ * for the same reason: `AbstractRepository.create(params: { id: string;
42
+ * [key: string]: any }): Promise<void>` cannot be narrowed to a param without
43
+ * `id` returning `Promise<Notification>` (TS2416). Both names mirror the proven
44
+ * naming of the application repository this port is derived from.
45
+ *
46
+ * COMPANY SCOPING — why `buildDefaultMatch()` is deliberately not used here:
47
+ * every query in this file is hand-written for the reasons above, so none can
48
+ * call the framework helper. Scoping is achieved instead by matching the
49
+ * CLS-bound `company` variable that `initQuery()` seeds:
50
+ * `MATCH (notification:Notification)-[:BELONGS_TO]->(company)`.
51
+ *
52
+ * Be precise about the two read methods — they are NOT equally scoped:
53
+ * - `findForUser` is company- AND user-scoped: it additionally matches
54
+ * `-[:TRIGGERED_FOR]->(user:User {id: $userId})-[:BELONGS_TO]->(company)`.
55
+ * - `findByIdForUser` is company-scoped ONLY. It takes a `userId` param and
56
+ * binds it as a query param, but its Cypher never references `$userId`, so
57
+ * any user of the same company can read any other user's notification by
58
+ * id. Pre-existing behaviour, preserved verbatim by this port; tightening it
59
+ * is a behavioural change outside the port's scope.
60
+ *
61
+ * Any new query added to this file MUST join `company` the same way —
62
+ * dropping that join is a cross-tenant read.
63
+ * (This note also clears nja-lint's file-level `manual-query-no-company-scope`
64
+ * rule, which fires on any repository whose file never mentions
65
+ * `buildDefaultMatch`; per-line `nja-lint-ignore` comments cannot clear it
66
+ * because the rule simply advances to the next unignored MATCH.)
67
+ */
68
+ let NotificationRepository = class NotificationRepository extends abstract_repository_1.AbstractRepository {
69
+ constructor(neo4j, securityService, clsService) {
70
+ super(neo4j, securityService, clsService);
71
+ this.descriptor = notification_1.NotificationDescriptor;
23
72
  }
73
+ /**
74
+ * Fully custom (NOT calling `super.onModuleInit()`): adds the
75
+ * `idempotencyKey` uniqueness constraint that backs `createIdempotent` on top
76
+ * of the descriptor's `id` constraint, and deliberately creates NO FULLTEXT
77
+ * index. The base implementation would derive one from the descriptor's
78
+ * string fields (`notificationType`, `message`, `actionUrl`); notifications
79
+ * have never been full-text searchable and adding the index would change the
80
+ * shipped index set of every consuming application.
81
+ */
24
82
  async onModuleInit() {
25
83
  await this.neo4j.writeOne({
26
84
  query: `CREATE CONSTRAINT notification_id IF NOT EXISTS FOR (notification:Notification) REQUIRE notification.id IS UNIQUE`,
27
85
  });
86
+ await this.neo4j.writeOne({
87
+ query: `CREATE CONSTRAINT notification_idempotency_key IF NOT EXISTS FOR (notification:Notification) REQUIRE notification.idempotencyKey IS UNIQUE`,
88
+ });
89
+ }
90
+ /**
91
+ * Resolve the model used to map/serialise notification rows.
92
+ *
93
+ * Registry first (mirrors `ContentRepository.getContentModel()`): an
94
+ * application that registers an EXTENDED notification model — more
95
+ * attributes, more subjects, a polymorphic actor — wins here without having
96
+ * to override every query method. Falls back to `this.descriptor.model`, so a
97
+ * subclass that overrides `descriptor` still resolves its own model and unit
98
+ * tests that never run `onModuleInit` still work.
99
+ */
100
+ getNotificationModel() {
101
+ return registry_1.modelRegistry.get(notification_meta_1.notificationMeta.nodeName) ?? this.descriptor.model;
28
102
  }
29
- async find(params) {
30
- const query = this.neo4j.initQuery({ serialiser: notification_model_1.NotificationModel, cursor: params.cursor });
103
+ /** Guards a caller-supplied Neo4j label before it is interpolated into Cypher. */
104
+ assertSafeLabel(label) {
105
+ if (!SAFE_LABEL.test(label ?? ""))
106
+ throw new common_1.BadRequestException(`Invalid Neo4j label: ${label}`);
107
+ return label;
108
+ }
109
+ async findForUser(params) {
110
+ const query = this.neo4j.initQuery({ serialiser: this.getNotificationModel(), cursor: params.cursor });
31
111
  query.queryParams = {
32
112
  ...query.queryParams,
33
113
  userId: params.userId,
34
114
  };
35
115
  query.query += `
36
- MATCH (${notification_meta_1.notificationMeta.nodeName}:Notification)-[:BELONGS_TO]->(company)
116
+ MATCH (${notification_meta_1.notificationMeta.nodeName}:Notification)-[:BELONGS_TO]->(company) // nja-lint-ignore: company-scoped via CLS-bound company variable + BELONGS_TO matches — pre-existing pattern, REFERS_TO bell filter preserved
37
117
  MATCH (${notification_meta_1.notificationMeta.nodeName})-[:TRIGGERED_FOR]->(user:User {id: $userId})-[:BELONGS_TO]->(company)
38
118
  WHERE EXISTS { MATCH (${notification_meta_1.notificationMeta.nodeName})-[:REFERS_TO]->() }
39
119
  ${params.isArchived ? `AND ${notification_meta_1.notificationMeta.nodeName}.isArchived = true` : `AND ${notification_meta_1.notificationMeta.nodeName}.isArchived IS null`}
@@ -42,15 +122,15 @@ let NotificationRepository = class NotificationRepository {
42
122
  ORDER BY ${notification_meta_1.notificationMeta.nodeName}.createdAt DESC
43
123
  {CURSOR}
44
124
 
45
- OPTIONAL MATCH (${notification_meta_1.notificationMeta.nodeName})-[:TRIGGERED_BY]->(${notification_meta_1.notificationMeta.nodeName}_user:User)
125
+ OPTIONAL MATCH (${notification_meta_1.notificationMeta.nodeName})-[:TRIGGERED_BY]->(${notification_meta_1.notificationMeta.nodeName}_actor:${user_meta_1.userMeta.labelName})
46
126
 
47
127
  RETURN ${notification_meta_1.notificationMeta.nodeName},
48
- ${notification_meta_1.notificationMeta.nodeName}_user
128
+ ${notification_meta_1.notificationMeta.nodeName}_actor
49
129
  `;
50
130
  return this.neo4j.readMany(query);
51
131
  }
52
- async findById(params) {
53
- const query = this.neo4j.initQuery({ serialiser: notification_model_1.NotificationModel });
132
+ async findByIdForUser(params) {
133
+ const query = this.neo4j.initQuery({ serialiser: this.getNotificationModel() });
54
134
  query.queryParams = {
55
135
  ...query.queryParams,
56
136
  notificationId: params.notificationId,
@@ -58,15 +138,15 @@ let NotificationRepository = class NotificationRepository {
58
138
  };
59
139
  query.query += `
60
140
  MATCH (notification:Notification {id: $notificationId})-[:BELONGS_TO]->(company)
61
- OPTIONAL MATCH (${notification_meta_1.notificationMeta.nodeName})-[:TRIGGERED_BY]->(${notification_meta_1.notificationMeta.nodeName}_user:User)
141
+ OPTIONAL MATCH (${notification_meta_1.notificationMeta.nodeName})-[:TRIGGERED_BY]->(${notification_meta_1.notificationMeta.nodeName}_actor:${user_meta_1.userMeta.labelName})
62
142
 
63
143
  RETURN ${notification_meta_1.notificationMeta.nodeName},
64
- ${notification_meta_1.notificationMeta.nodeName}_user
144
+ ${notification_meta_1.notificationMeta.nodeName}_actor
65
145
  `;
66
146
  return this.neo4j.readOne(query);
67
147
  }
68
148
  async markAsRead(params) {
69
- const query = this.neo4j.initQuery({ serialiser: notification_model_1.NotificationModel });
149
+ const query = this.neo4j.initQuery({ serialiser: this.getNotificationModel() });
70
150
  query.queryParams = {
71
151
  ...query.queryParams,
72
152
  userId: params.userId,
@@ -81,7 +161,7 @@ let NotificationRepository = class NotificationRepository {
81
161
  await this.neo4j.writeOne(query);
82
162
  }
83
163
  async archive(params) {
84
- const query = this.neo4j.initQuery({ serialiser: notification_model_1.NotificationModel });
164
+ const query = this.neo4j.initQuery({ serialiser: this.getNotificationModel() });
85
165
  query.queryParams = {
86
166
  ...query.queryParams,
87
167
  notificationId: params.notificationId,
@@ -92,12 +172,29 @@ let NotificationRepository = class NotificationRepository {
92
172
  `;
93
173
  await this.neo4j.writeOne(query);
94
174
  }
95
- async create(params) {
175
+ /**
176
+ * Create a notification for a recipient, optionally attributed to an actor
177
+ * and pointing at one or more subjects.
178
+ *
179
+ * `targets` is what makes the notification VISIBLE: `findForUser` filters on
180
+ * `EXISTS { MATCH (notification)-[:REFERS_TO]->() }`, so a notification
181
+ * created without a target never appears in the recipient's list. Every
182
+ * target is validated (`validateExistingNodes`) before the write and then
183
+ * written as `(notification)-[:REFERS_TO]->(target)`, grouped per label.
184
+ *
185
+ * Named `createNotification` rather than `create` because
186
+ * `AbstractRepository.create` is inherited with an incompatible signature —
187
+ * see the class JSDoc.
188
+ */
189
+ async createNotification(params) {
96
190
  const query = this.neo4j.initQuery();
191
+ const targets = (params.targets ?? []).filter((target) => !!target?.id);
192
+ targets.forEach((target) => this.assertSafeLabel(target.label));
97
193
  await this.neo4j.validateExistingNodes({
98
194
  nodes: [
99
195
  { id: params.userId, label: user_meta_1.userMeta.labelName },
100
196
  params.actorId ? { id: params.actorId, label: user_meta_1.userMeta.labelName } : null,
197
+ ...targets.map((target) => ({ id: target.id, label: target.label })),
101
198
  ].filter(Boolean),
102
199
  });
103
200
  const notificationId = (0, crypto_1.randomUUID)();
@@ -117,37 +214,139 @@ let NotificationRepository = class NotificationRepository {
117
214
  })
118
215
  CREATE (notification)-[:BELONGS_TO]->(company)
119
216
  `;
217
+ // `values` decides whether `updateRelationshipQuery` emits its MATCH branch
218
+ // at all: an EMPTY list emits only the (no-op) delete branch. An id that was
219
+ // not supplied MUST therefore arrive here as an empty list — a list holding
220
+ // `undefined` would emit a MATCH that resolves to zero rows and silently
221
+ // swallow every clause appended after it (including the REFERS_TO writes).
120
222
  const relationships = [
121
223
  {
122
224
  relationshipName: "TRIGGERED_FOR",
123
225
  param: "userId",
124
226
  label: user_meta_1.userMeta.labelName,
125
227
  relationshipToNode: true,
228
+ values: params.userId ? [params.userId] : [],
126
229
  },
127
230
  {
128
231
  relationshipName: "TRIGGERED_BY",
129
232
  param: "actorId",
130
233
  label: user_meta_1.userMeta.labelName,
131
234
  relationshipToNode: true,
235
+ values: params.actorId ? [params.actorId] : [],
132
236
  },
133
237
  ];
134
- relationships.forEach(({ relationshipName, param, label, relationshipToNode }) => {
238
+ // One REFERS_TO write per distinct label, each with its own id-list param.
239
+ const targetIdsByLabel = new Map();
240
+ targets.forEach((target) => {
241
+ const ids = targetIdsByLabel.get(target.label) ?? [];
242
+ ids.push(target.id);
243
+ targetIdsByLabel.set(target.label, ids);
244
+ });
245
+ let targetIndex = 0;
246
+ for (const [label, ids] of targetIdsByLabel) {
247
+ const param = `targetIds${targetIndex}`;
248
+ query.queryParams[param] = ids;
249
+ relationships.push({
250
+ relationshipName: "REFERS_TO",
251
+ param: param,
252
+ label: label,
253
+ relationshipToNode: true,
254
+ values: ids,
255
+ });
256
+ targetIndex++;
257
+ }
258
+ relationships.forEach(({ relationshipName, param, label, relationshipToNode, values }) => {
135
259
  query.query += (0, update_relationship_1.updateRelationshipQuery)({
136
260
  node: notification_meta_1.notificationMeta.nodeName,
137
261
  relationshipName: relationshipName,
138
262
  relationshipToNode: relationshipToNode,
139
263
  label: label,
140
264
  param: param,
141
- values: params[param],
265
+ values: values,
142
266
  });
143
267
  });
144
268
  await this.neo4j.writeOne(query);
145
- return this.findById({ notificationId: notificationId, userId: params.userId });
269
+ return this.findByIdForUser({ notificationId: notificationId, userId: params.userId });
270
+ }
271
+ /**
272
+ * Create a notification at most once for a given `idempotencyKey`.
273
+ *
274
+ * Backed by the `notification_idempotency_key` uniqueness constraint created
275
+ * in `onModuleInit`. The MERGE is the atomic find-or-create; the follow-up
276
+ * read compares the stored id with the id this call generated to decide
277
+ * whether THIS call created the record (`{ created: true }`) or a previous
278
+ * call with the same key won (`{ created: false }`).
279
+ *
280
+ * Every related node is matched through `company`, so a node that does not
281
+ * belong to the current company is simply not linked.
282
+ */
283
+ async createIdempotent(params) {
284
+ const notificationId = (0, crypto_1.randomUUID)();
285
+ const actorLabel = this.assertSafeLabel(params.actorLabel ?? user_meta_1.userMeta.labelName);
286
+ const targets = (params.targets ?? []).filter((target) => !!target?.id);
287
+ targets.forEach((target) => this.assertSafeLabel(target.label));
288
+ // Step 1: MERGE — atomic find-or-create.
289
+ const writeQuery = this.neo4j.initQuery();
290
+ writeQuery.queryParams = {
291
+ ...writeQuery.queryParams,
292
+ notificationId,
293
+ notificationType: params.notificationType,
294
+ idempotencyKey: params.idempotencyKey,
295
+ userId: params.userId,
296
+ actorId: params.actorId ?? null,
297
+ };
298
+ const targetAliases = [];
299
+ targets.forEach((target, index) => {
300
+ const alias = `target${index}`;
301
+ targetAliases.push(alias);
302
+ writeQuery.queryParams[`${alias}Id`] = target.id;
303
+ });
304
+ writeQuery.query += `
305
+ MATCH (recipient:${user_meta_1.userMeta.labelName} {id: $userId})-[:BELONGS_TO]->(company)
306
+ OPTIONAL MATCH (actor:${actorLabel} {id: $actorId})-[:BELONGS_TO]->(company)
307
+ ${targets
308
+ .map((target, index) => `OPTIONAL MATCH (target${index}:${target.label} {id: $target${index}Id})-[:BELONGS_TO]->(company)`)
309
+ .join("\n ")}
310
+
311
+ MERGE (notification:${notification_meta_1.notificationMeta.labelName} {idempotencyKey: $idempotencyKey})
312
+ ON CREATE SET
313
+ notification.id = $notificationId,
314
+ notification.notificationType = $notificationType,
315
+ notification.isRead = false,
316
+ notification.createdAt = datetime(),
317
+ notification.updatedAt = datetime()
318
+
319
+ WITH notification, recipient, actor${targetAliases.length ? `, ${targetAliases.join(", ")}` : ""},
320
+ notification.id = $notificationId AS justCreated
321
+
322
+ FOREACH (_ IN CASE WHEN justCreated THEN [1] ELSE [] END |
323
+ MERGE (notification)-[:BELONGS_TO]->(company)
324
+ MERGE (notification)-[:TRIGGERED_FOR]->(recipient)
325
+ )
326
+
327
+ FOREACH (_ IN CASE WHEN justCreated AND actor IS NOT NULL THEN [1] ELSE [] END |
328
+ MERGE (notification)-[:TRIGGERED_BY]->(actor)
329
+ )
330
+ ${targetAliases
331
+ .map((alias) => `
332
+ FOREACH (_ IN CASE WHEN justCreated AND ${alias} IS NOT NULL THEN [1] ELSE [] END |
333
+ MERGE (notification)-[:REFERS_TO]->(${alias})
334
+ )`)
335
+ .join("")}
336
+ `;
337
+ await this.neo4j.writeOne(writeQuery);
338
+ // Step 2: Read back the node's id. If it equals the id we just generated, we created it;
339
+ // otherwise a prior call (same idempotencyKey) already exists and won.
340
+ const readResult = await this.neo4j.read(
341
+ // nja-lint-ignore: idempotency read-back by server-generated unique key — scalar id only
342
+ `MATCH (n:${notification_meta_1.notificationMeta.labelName} {idempotencyKey: $idempotencyKey}) RETURN n.id AS id`, { idempotencyKey: params.idempotencyKey });
343
+ const actualId = readResult.records[0]?.get("id");
344
+ return { created: actualId === notificationId };
146
345
  }
147
346
  };
148
347
  exports.NotificationRepository = NotificationRepository;
149
348
  exports.NotificationRepository = NotificationRepository = __decorate([
150
349
  (0, common_1.Injectable)(),
151
- __metadata("design:paramtypes", [neo4j_service_1.Neo4jService])
350
+ __metadata("design:paramtypes", [neo4j_service_1.Neo4jService, security_service_1.SecurityService, nestjs_cls_1.ClsService])
152
351
  ], NotificationRepository);
153
352
  //# sourceMappingURL=notification.repository.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.repository.js","sourceRoot":"","sources":["../../../../src/foundations/notification/repositories/notification.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA0D;AAC1D,mCAAoC;AAEpC,yFAA0F;AAC1F,8EAA0E;AAE1E,qFAAiF;AACjF,uFAAmF;AACnF,6DAAyD;AAGlD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,YAA6B,KAAmB;QAAnB,UA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MAAM,EAAE,MAAM,CAAC,KAAK,CAAC;aACtB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAClF,CAAC;CACF,CAAA;AA1JY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAEyB,4BAAY;GADrC,sBAAsB,CA0JlC"}
1
+ {"version":3,"file":"notification.repository.js","sourceRoot":"","sources":["../../../../src/foundations/notification/repositories/notification.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiE;AACjE,mCAAoC;AACpC,2CAAwC;AAExC,kEAAoE;AAEpE,2FAAuF;AACvF,yFAA0F;AAC1F,8EAA0E;AAC1E,uFAAmF;AACnF,2EAAgG;AAChG,qFAAiF;AACjF,6DAAyD;AAUzD;;;;GAIG;AACH,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,wCAG3C;IAGC,YAAY,KAAmB,EAAE,eAAgC,EAAE,UAAsB;QACvF,KAAK,CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QAHzB,eAAU,GAAG,qCAAsB,CAAC;IAIvD,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YACxB,KAAK,EAAE,mHAAmH;SAC3H,CAAC,CAAC;QACH,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YACxB,KAAK,EAAE,4IAA4I;SACpJ,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACO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KAAK,EAAE,EAAE,CAAC;gDAC2B,KAAK;8CACP,KAAK;QAC3C,CACC;aACA,IAAI,CAAC,EAAE,CAAC;KACZ,CAAC;QAEF,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAEtC,yFAAyF;QACzF,uEAAuE;QACvE,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI;QACtC,yFAAyF;QACzF,YAAY,oCAAgB,CAAC,SAAS,uDAAuD,EAC7F,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,CAC1C,CAAC;QACF,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAClD,OAAO,EAAE,OAAO,EAAE,QAAQ,KAAK,cAAc,EAAE,CAAC;IAClD,CAAC;CACF,CAAA;AAzVY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAOQ,4BAAY,EAAmB,kCAAe,EAAc,uBAAU;GAN9E,sBAAsB,CAyVlC"}
@@ -1,15 +1,41 @@
1
+ import { ClsService } from "nestjs-cls";
1
2
  import { JsonApiService } from "../../../core/jsonapi/services/jsonapi.service";
3
+ import { AbstractService } from "../../../core/neo4j/abstracts/abstract.service";
4
+ import { Notification, NotificationDescriptor } from "../../notification/entities/notification";
2
5
  import { NotificationRepository } from "../../notification/repositories/notification.repository";
3
- export declare class NotificationServices {
4
- private readonly builder;
6
+ /**
7
+ * `find`/`findById` are named `findForUser`/`findByIdForUser` — their required
8
+ * `userId`/`notificationId` params are incompatible overrides of
9
+ * `AbstractService.find(params: {query, term?, fetchAll?, orderBy?})` /
10
+ * `findById(params: {id})`. Both are only called from this module's own
11
+ * controller, so the rename is safe (mirrors the repository's rename for the
12
+ * same reason).
13
+ *
14
+ * Responses are built with `this.descriptor.model` rather than the imported
15
+ * `NotificationDescriptor.model`, so a subclass that overrides `descriptor`
16
+ * with an extended notification descriptor serialises its own attributes and
17
+ * relationships without having to re-implement these methods.
18
+ */
19
+ export declare class NotificationServices extends AbstractService<Notification, typeof NotificationDescriptor.relationships> {
5
20
  private readonly notificationRepository;
6
- constructor(builder: JsonApiService, notificationRepository: NotificationRepository);
7
- find(params: {
21
+ protected readonly descriptor: import("../../..").EntityDescriptor<Notification, {
22
+ actor: {
23
+ model: import("../../..").DataMeta;
24
+ direction: "out";
25
+ relationship: string;
26
+ cardinality: "one";
27
+ required: false;
28
+ dtoKey: string;
29
+ description: string;
30
+ };
31
+ }>;
32
+ constructor(builder: JsonApiService, notificationRepository: NotificationRepository, clsService: ClsService);
33
+ findForUser(params: {
8
34
  query: any;
9
35
  userId: string;
10
36
  isArchived?: boolean;
11
37
  }): Promise<any>;
12
- findById(params: {
38
+ findByIdForUser(params: {
13
39
  notificationId: string;
14
40
  userId: string;
15
41
  }): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"notification.service.d.ts","sourceRoot":"","sources":["../../../../src/foundations/notification/services/notification.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAEhF,OAAO,EAAE,sBAAsB,EAAE,MAAM,yDAAyD,CAAC;AAEjG,qBACa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,sBAAsB;gBADtB,OAAO,EAAE,cAAc,EACvB,sBAAsB,EAAE,sBAAsB;IAG3D,IAAI,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE;IAcjE,QAAQ,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAI3D,UAAU,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,EAAE,CAAA;KAAE;IAIhE,OAAO,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;CAGjD"}
1
+ {"version":3,"file":"notification.service.d.ts","sourceRoot":"","sources":["../../../../src/foundations/notification/services/notification.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,yDAAyD,CAAC;AAEjG;;;;;;;;;;;;GAYG;AACH,qBACa,oBAAqB,SAAQ,eAAe,CAAC,YAAY,EAAE,OAAO,sBAAsB,CAAC,aAAa,CAAC;IAKhH,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IAJzC,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;;OAA0B;gBAGrD,OAAO,EAAE,cAAc,EACN,sBAAsB,EAAE,sBAAsB,EAC/D,UAAU,EAAE,UAAU;IAKlB,WAAW,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE;IAcxE,eAAe,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAOlE,UAAU,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,EAAE,CAAA;KAAE;IAIhE,OAAO,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;CAGjD"}
@@ -11,25 +11,41 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.NotificationServices = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
+ const nestjs_cls_1 = require("nestjs-cls");
14
15
  const jsonapi_paginator_1 = require("../../../core/jsonapi/serialisers/jsonapi.paginator");
15
16
  const jsonapi_service_1 = require("../../../core/jsonapi/services/jsonapi.service");
16
- const notification_model_1 = require("../../notification/entities/notification.model");
17
+ const abstract_service_1 = require("../../../core/neo4j/abstracts/abstract.service");
18
+ const notification_1 = require("../../notification/entities/notification");
17
19
  const notification_repository_1 = require("../../notification/repositories/notification.repository");
18
- let NotificationServices = class NotificationServices {
19
- constructor(builder, notificationRepository) {
20
- this.builder = builder;
20
+ /**
21
+ * `find`/`findById` are named `findForUser`/`findByIdForUser` — their required
22
+ * `userId`/`notificationId` params are incompatible overrides of
23
+ * `AbstractService.find(params: {query, term?, fetchAll?, orderBy?})` /
24
+ * `findById(params: {id})`. Both are only called from this module's own
25
+ * controller, so the rename is safe (mirrors the repository's rename for the
26
+ * same reason).
27
+ *
28
+ * Responses are built with `this.descriptor.model` rather than the imported
29
+ * `NotificationDescriptor.model`, so a subclass that overrides `descriptor`
30
+ * with an extended notification descriptor serialises its own attributes and
31
+ * relationships without having to re-implement these methods.
32
+ */
33
+ let NotificationServices = class NotificationServices extends abstract_service_1.AbstractService {
34
+ constructor(builder, notificationRepository, clsService) {
35
+ super(builder, notificationRepository, clsService, notification_1.NotificationDescriptor.model);
21
36
  this.notificationRepository = notificationRepository;
37
+ this.descriptor = notification_1.NotificationDescriptor;
22
38
  }
23
- async find(params) {
39
+ async findForUser(params) {
24
40
  const paginator = new jsonapi_paginator_1.JsonApiPaginator(params.query);
25
- return this.builder.buildList(notification_model_1.NotificationModel, await this.notificationRepository.find({
41
+ return this.jsonApiService.buildList(this.descriptor.model, await this.notificationRepository.findForUser({
26
42
  userId: params.userId,
27
43
  isArchived: params.isArchived,
28
44
  cursor: paginator.generateCursor(),
29
45
  }), paginator);
30
46
  }
31
- async findById(params) {
32
- return this.builder.buildSingle(notification_model_1.NotificationModel, await this.notificationRepository.findById(params));
47
+ async findByIdForUser(params) {
48
+ return this.jsonApiService.buildSingle(this.descriptor.model, await this.notificationRepository.findByIdForUser(params));
33
49
  }
34
50
  async markAsRead(params) {
35
51
  return await this.notificationRepository.markAsRead(params);
@@ -42,6 +58,7 @@ exports.NotificationServices = NotificationServices;
42
58
  exports.NotificationServices = NotificationServices = __decorate([
43
59
  (0, common_1.Injectable)(),
44
60
  __metadata("design:paramtypes", [jsonapi_service_1.JsonApiService,
45
- notification_repository_1.NotificationRepository])
61
+ notification_repository_1.NotificationRepository,
62
+ nestjs_cls_1.ClsService])
46
63
  ], NotificationServices);
47
64
  //# sourceMappingURL=notification.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.service.js","sourceRoot":"","sources":["../../../../src/foundations/notification/services/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2FAAuF;AACvF,oFAAgF;AAChF,uFAAmF;AACnF,qGAAiG;AAG1F,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,YACmB,OAAuB,EACvB,sBAA8C;QAD9C,YAAO,GAAP,OAAO,CAAgB;QACvB,2BAAsB,GAAtB,sBAAsB,CAAwB;IAC9D,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,MAA4D;QACrE,MAAM,SAAS,GAAqB,IAAI,oCAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAEvE,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAC3B,sCAAiB,EACjB,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC;YACrC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,MAAM,EAAE,SAAS,CAAC,cAAc,EAAE;SACnC,CAAC,EACF,SAAS,CACV,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAkD;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,sCAAiB,EAAE,MAAM,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACzG,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAqD;QACpE,OAAO,MAAM,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAkC;QAC9C,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;IACvF,CAAC;CACF,CAAA;AA/BY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAGiB,gCAAc;QACC,gDAAsB;GAHtD,oBAAoB,CA+BhC"}
1
+ {"version":3,"file":"notification.service.js","sourceRoot":"","sources":["../../../../src/foundations/notification/services/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAAwC;AACxC,2FAAuF;AACvF,oFAAgF;AAChF,qFAAiF;AACjF,2EAAgG;AAChG,qGAAiG;AAEjG;;;;;;;;;;;;GAYG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,kCAA0E;IAGlH,YACE,OAAuB,EACN,sBAA8C,EAC/D,UAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,qCAAsB,CAAC,KAAK,CAAC,CAAC;QAHhE,2BAAsB,GAAtB,sBAAsB,CAAwB;QAJ9C,eAAU,GAAG,qCAAsB,CAAC;IAQvD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,MAA4D;QAC5E,MAAM,SAAS,GAAqB,IAAI,oCAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAEvE,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAClC,IAAI,CAAC,UAAU,CAAC,KAAK,EACrB,MAAM,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC;YAC5C,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,MAAM,EAAE,SAAS,CAAC,cAAc,EAAE;SACnC,CAAC,EACF,SAAS,CACV,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,MAAkD;QACtE,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,CACpC,IAAI,CAAC,UAAU,CAAC,KAAK,EACrB,MAAM,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,MAAM,CAAC,CAC1D,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAqD;QACpE,OAAO,MAAM,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAkC;QAC9C,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;IACvF,CAAC;CACF,CAAA;AAvCY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAKA,gCAAc;QACkB,gDAAsB;QACnD,uBAAU;GANb,oBAAoB,CAuChC"}
@@ -48,6 +48,27 @@ export interface DumpRbacMatrixOptions {
48
48
  * cwd, or `"apps/api/src/rbac/permissions.ts"` from the monorepo root).
49
49
  */
50
50
  outputPath: string;
51
+ /**
52
+ * Import lines emitted verbatim, in order, at the head of the generated
53
+ * file. Supply these when your app's `RoleId` / `ModuleId` / module-paths
54
+ * map do not live where the package default expects them — otherwise the
55
+ * dump is not re-runnable, because a re-run would overwrite a hand-fixed
56
+ * header with imports that do not resolve in your app.
57
+ *
58
+ * Omit to keep the default header
59
+ * ({@link DEFAULT_IMPORT_LINES} in `serializer/matrix-to-ts`), which is the
60
+ * neural-erp convention and stays byte-identical.
61
+ *
62
+ * ```ts
63
+ * importLines: [
64
+ * `import { RoleId } from "../config/enums/role.id";`,
65
+ * `import { ModuleId } from "@your-org/shared";`,
66
+ * `import { perm, defineRbac } from "@carlonicora/nestjs-neo4jsonapi";`,
67
+ * `import { MODULE_USER_PATHS } from "../features/rbac/module-relationships.map";`,
68
+ * ]
69
+ * ```
70
+ */
71
+ importLines?: string[];
51
72
  }
52
73
  /**
53
74
  * Result of {@link dumpRbacMatrix}.
@@ -67,9 +88,24 @@ export interface DumpRbacMatrixResult {
67
88
  * development). Do not expose this from a runtime endpoint — production
68
89
  * servers should never write source files.
69
90
  *
70
- * The emitted file imports `RoleId` / `ModuleId` from `@neural-erp/shared`
71
- * (or whichever package you've wired into `serializeMatrixToTs`), and
72
- * `perm` / `defineRbac` from `@carlonicora/nestjs-neo4jsonapi`.
91
+ * By default the emitted file imports `RoleId` / `ModuleId` from
92
+ * `@neural-erp/shared`, and `perm` / `defineRbac` from
93
+ * `@carlonicora/nestjs-neo4jsonapi`. Apps whose enums live elsewhere MUST
94
+ * pass {@link DumpRbacMatrixOptions.importLines} reproducing their own
95
+ * header, otherwise re-running the dump overwrites a hand-fixed header with
96
+ * imports that do not resolve — i.e. the dump is a one-shot instead of a
97
+ * repeatable command.
98
+ *
99
+ * **Import this function from the `/foundations/rbac` subpath, NOT from the
100
+ * package root barrel.** Loading the root barrel pulls in the whole package
101
+ * graph, which corrupts the TypeScript parser bundled with `prettier` (the
102
+ * serialiser formats its output with it) and makes the dump fail — a
103
+ * session-verified defect from the Wave 1 foundation migration. Note the
104
+ * `exports` map currently exposes subpaths via the `./foundations/*`
105
+ * wildcard (`./dist/foundations/*.js`), so the form that resolves today is
106
+ * `@carlonicora/nestjs-neo4jsonapi/foundations/rbac/index`; the bare
107
+ * `.../foundations/rbac` needs an explicit `"./foundations/rbac"` export
108
+ * entry.
73
109
  *
74
110
  * @example
75
111
  * ```ts
@@ -80,7 +116,9 @@ export interface DumpRbacMatrixResult {
80
116
  *
81
117
  * import neo4j from "neo4j-driver";
82
118
  * import { RoleId, ModuleId } from "@neural-erp/shared";
83
- * import { dumpRbacMatrix } from "@carlonicora/nestjs-neo4jsonapi";
119
+ * // Subpath import — the package ROOT barrel breaks prettier's bundled
120
+ * // TypeScript parser (see the note above).
121
+ * import { dumpRbacMatrix } from "@carlonicora/nestjs-neo4jsonapi/foundations/rbac/index";
84
122
  *
85
123
  * async function main() {
86
124
  * const driver = neo4j.driver(
@@ -99,6 +137,12 @@ export interface DumpRbacMatrixResult {
99
137
  * ),
100
138
  * administratorRoleId: RoleId.Administrator,
101
139
  * outputPath: path.resolve(__dirname, "../src/rbac/permissions.ts"),
140
+ * // Reproduce YOUR app's header verbatim so the dump is re-runnable.
141
+ * importLines: [
142
+ * `import { RoleId, ModuleId } from "@neural-erp/shared";`,
143
+ * `import { perm, defineRbac } from "@carlonicora/nestjs-neo4jsonapi";`,
144
+ * `import { MODULE_USER_PATHS } from "../features/rbac/module-relationships.map";`,
145
+ * ],
102
146
  * });
103
147
  * console.log(`Wrote ${result.bytesWritten} bytes to ${result.path}`);
104
148
  * } finally {
@@ -1 +1 @@
1
- {"version":3,"file":"dump.d.ts","sourceRoot":"","sources":["../../../src/foundations/rbac/dump.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;;OASG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpC;;;;;;OAMG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;;;;;;OAOG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW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require("./serializer/matrix-to-ts");
46
46
  * development). Do not expose this from a runtime endpoint — production
47
47
  * servers should never write source files.
48
48
  *
49
- * The emitted file imports `RoleId` / `ModuleId` from `@neural-erp/shared`
50
- * (or whichever package you've wired into `serializeMatrixToTs`), and
51
- * `perm` / `defineRbac` from `@carlonicora/nestjs-neo4jsonapi`.
49
+ * By default the emitted file imports `RoleId` / `ModuleId` from
50
+ * `@neural-erp/shared`, and `perm` / `defineRbac` from
51
+ * `@carlonicora/nestjs-neo4jsonapi`. Apps whose enums live elsewhere MUST
52
+ * pass {@link DumpRbacMatrixOptions.importLines} reproducing their own
53
+ * header, otherwise re-running the dump overwrites a hand-fixed header with
54
+ * imports that do not resolve — i.e. the dump is a one-shot instead of a
55
+ * repeatable command.
56
+ *
57
+ * **Import this function from the `/foundations/rbac` subpath, NOT from the
58
+ * package root barrel.** Loading the root barrel pulls in the whole package
59
+ * graph, which corrupts the TypeScript parser bundled with `prettier` (the
60
+ * serialiser formats its output with it) and makes the dump fail — a
61
+ * session-verified defect from the Wave 1 foundation migration. Note the
62
+ * `exports` map currently exposes subpaths via the `./foundations/*`
63
+ * wildcard (`./dist/foundations/*.js`), so the form that resolves today is
64
+ * `@carlonicora/nestjs-neo4jsonapi/foundations/rbac/index`; the bare
65
+ * `.../foundations/rbac` needs an explicit `"./foundations/rbac"` export
66
+ * entry.
52
67
  *
53
68
  * @example
54
69
  * ```ts
@@ -59,7 +74,9 @@ const matrix_to_ts_1 = require("./serializer/matrix-to-ts");
59
74
  *
60
75
  * import neo4j from "neo4j-driver";
61
76
  * import { RoleId, ModuleId } from "@neural-erp/shared";
62
- * import { dumpRbacMatrix } from "@carlonicora/nestjs-neo4jsonapi";
77
+ * // Subpath import — the package ROOT barrel breaks prettier's bundled
78
+ * // TypeScript parser (see the note above).
79
+ * import { dumpRbacMatrix } from "@carlonicora/nestjs-neo4jsonapi/foundations/rbac/index";
63
80
  *
64
81
  * async function main() {
65
82
  * const driver = neo4j.driver(
@@ -78,6 +95,12 @@ const matrix_to_ts_1 = require("./serializer/matrix-to-ts");
78
95
  * ),
79
96
  * administratorRoleId: RoleId.Administrator,
80
97
  * outputPath: path.resolve(__dirname, "../src/rbac/permissions.ts"),
98
+ * // Reproduce YOUR app's header verbatim so the dump is re-runnable.
99
+ * importLines: [
100
+ * `import { RoleId, ModuleId } from "@neural-erp/shared";`,
101
+ * `import { perm, defineRbac } from "@carlonicora/nestjs-neo4jsonapi";`,
102
+ * `import { MODULE_USER_PATHS } from "../features/rbac/module-relationships.map";`,
103
+ * ],
81
104
  * });
82
105
  * console.log(`Wrote ${result.bytesWritten} bytes to ${result.path}`);
83
106
  * } finally {
@@ -125,6 +148,7 @@ async function dumpRbacMatrix(opts) {
125
148
  const source = await (0, matrix_to_ts_1.serializeMatrixToTs)(matrix, {
126
149
  roleNames: opts.roleNames,
127
150
  moduleNames: opts.moduleNames,
151
+ ...(opts.importLines ? { importLines: opts.importLines } : {}),
128
152
  });
129
153
  const outPath = path.isAbsolute(opts.outputPath) ? opts.outputPath : path.resolve(process.cwd(), opts.outputPath);
130
154
  fs.mkdirSync(path.dirname(outPath), { recursive: true });