@hed-hog/lms 0.0.364 → 0.0.366

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 (290) hide show
  1. package/dist/bitcode-wallet/bitcode-wallet.service.d.ts +1 -0
  2. package/dist/bitcode-wallet/bitcode-wallet.service.d.ts.map +1 -1
  3. package/dist/bitcode-wallet/bitcode-wallet.service.js +22 -3
  4. package/dist/bitcode-wallet/bitcode-wallet.service.js.map +1 -1
  5. package/dist/class-group/class-group.controller.d.ts +1 -0
  6. package/dist/class-group/class-group.controller.d.ts.map +1 -1
  7. package/dist/class-group/class-group.service.d.ts +1 -0
  8. package/dist/class-group/class-group.service.d.ts.map +1 -1
  9. package/dist/course/course-export-scorm12-worker.service.d.ts +21 -0
  10. package/dist/course/course-export-scorm12-worker.service.d.ts.map +1 -0
  11. package/dist/course/course-export-scorm12-worker.service.js +109 -0
  12. package/dist/course/course-export-scorm12-worker.service.js.map +1 -0
  13. package/dist/course/course-export-scorm12.service.d.ts +42 -0
  14. package/dist/course/course-export-scorm12.service.d.ts.map +1 -0
  15. package/dist/course/course-export-scorm12.service.js +628 -0
  16. package/dist/course/course-export-scorm12.service.js.map +1 -0
  17. package/dist/course/course-export.service.d.ts +84 -0
  18. package/dist/course/course-export.service.d.ts.map +1 -0
  19. package/dist/course/course-export.service.js +237 -0
  20. package/dist/course/course-export.service.js.map +1 -0
  21. package/dist/course/course-structure.controller.d.ts +20 -10
  22. package/dist/course/course-structure.controller.d.ts.map +1 -1
  23. package/dist/course/course-structure.controller.js +20 -4
  24. package/dist/course/course-structure.controller.js.map +1 -1
  25. package/dist/course/course-structure.service.d.ts +12 -4
  26. package/dist/course/course-structure.service.d.ts.map +1 -1
  27. package/dist/course/course-structure.service.js +98 -23
  28. package/dist/course/course-structure.service.js.map +1 -1
  29. package/dist/course/course-video-agent-pipeline.service.d.ts +70 -0
  30. package/dist/course/course-video-agent-pipeline.service.d.ts.map +1 -0
  31. package/dist/course/course-video-agent-pipeline.service.js +398 -0
  32. package/dist/course/course-video-agent-pipeline.service.js.map +1 -0
  33. package/dist/course/course-video-hls.service.d.ts +71 -0
  34. package/dist/course/course-video-hls.service.d.ts.map +1 -0
  35. package/dist/course/course-video-hls.service.js +784 -0
  36. package/dist/course/course-video-hls.service.js.map +1 -0
  37. package/dist/course/course.controller.d.ts +47 -13
  38. package/dist/course/course.controller.d.ts.map +1 -1
  39. package/dist/course/course.controller.js +40 -26
  40. package/dist/course/course.controller.js.map +1 -1
  41. package/dist/course/course.mcp-tools.js +1 -1
  42. package/dist/course/course.mcp-tools.js.map +1 -1
  43. package/dist/course/course.module.d.ts.map +1 -1
  44. package/dist/course/course.module.js +16 -0
  45. package/dist/course/course.module.js.map +1 -1
  46. package/dist/course/course.service.d.ts +8 -9
  47. package/dist/course/course.service.d.ts.map +1 -1
  48. package/dist/course/course.service.js +93 -50
  49. package/dist/course/course.service.js.map +1 -1
  50. package/dist/course/dto/cleanup-course-storage.dto.d.ts +1 -1
  51. package/dist/course/dto/cleanup-course-storage.dto.d.ts.map +1 -1
  52. package/dist/course/dto/cleanup-course-storage.dto.js +1 -0
  53. package/dist/course/dto/cleanup-course-storage.dto.js.map +1 -1
  54. package/dist/course/dto/cleanup-upload-history.dto.d.ts +1 -1
  55. package/dist/course/dto/cleanup-upload-history.dto.d.ts.map +1 -1
  56. package/dist/course/dto/cleanup-upload-history.dto.js +1 -1
  57. package/dist/course/dto/cleanup-upload-history.dto.js.map +1 -1
  58. package/dist/course/dto/create-course-bulk-job.dto.d.ts +2 -1
  59. package/dist/course/dto/create-course-bulk-job.dto.d.ts.map +1 -1
  60. package/dist/course/dto/create-course-bulk-job.dto.js +6 -1
  61. package/dist/course/dto/create-course-bulk-job.dto.js.map +1 -1
  62. package/dist/course/dto/create-course-export.dto.d.ts +14 -0
  63. package/dist/course/dto/create-course-export.dto.d.ts.map +1 -0
  64. package/dist/course/dto/create-course-export.dto.js +71 -0
  65. package/dist/course/dto/create-course-export.dto.js.map +1 -0
  66. package/dist/course/dto/create-course-structure-lesson.dto.d.ts +2 -2
  67. package/dist/course/dto/create-course-structure-lesson.dto.d.ts.map +1 -1
  68. package/dist/course/dto/create-course-structure-lesson.dto.js +3 -2
  69. package/dist/course/dto/create-course-structure-lesson.dto.js.map +1 -1
  70. package/dist/course/ffmpeg.util.d.ts +10 -0
  71. package/dist/course/ffmpeg.util.d.ts.map +1 -0
  72. package/dist/course/ffmpeg.util.js +79 -0
  73. package/dist/course/ffmpeg.util.js.map +1 -0
  74. package/dist/course/lms-bulk-upload-automation.service.d.ts +18 -1
  75. package/dist/course/lms-bulk-upload-automation.service.d.ts.map +1 -1
  76. package/dist/course/lms-bulk-upload-automation.service.js +106 -8
  77. package/dist/course/lms-bulk-upload-automation.service.js.map +1 -1
  78. package/dist/course/lms-bulk-upload-infra.service.d.ts +1 -0
  79. package/dist/course/lms-bulk-upload-infra.service.d.ts.map +1 -1
  80. package/dist/course/lms-bulk-upload-infra.service.js +32 -8
  81. package/dist/course/lms-bulk-upload-infra.service.js.map +1 -1
  82. package/dist/course/lms-bulk-upload.controller.d.ts +30 -3
  83. package/dist/course/lms-bulk-upload.controller.d.ts.map +1 -1
  84. package/dist/course/lms-bulk-upload.controller.js +43 -2
  85. package/dist/course/lms-bulk-upload.controller.js.map +1 -1
  86. package/dist/course/lms-bulk-upload.service.d.ts +11 -0
  87. package/dist/course/lms-bulk-upload.service.d.ts.map +1 -1
  88. package/dist/course/lms-bulk-upload.service.js +59 -6
  89. package/dist/course/lms-bulk-upload.service.js.map +1 -1
  90. package/dist/course/lms-setting.controller.d.ts +2 -1
  91. package/dist/course/lms-setting.controller.d.ts.map +1 -1
  92. package/dist/course/lms-setting.controller.js +4 -2
  93. package/dist/course/lms-setting.controller.js.map +1 -1
  94. package/dist/course/scorm12-schemas.d.ts +4 -0
  95. package/dist/course/scorm12-schemas.d.ts.map +1 -0
  96. package/dist/course/scorm12-schemas.js +9 -0
  97. package/dist/course/scorm12-schemas.js.map +1 -0
  98. package/dist/enterprise/training/training-admin.controller.d.ts +2 -0
  99. package/dist/enterprise/training/training-admin.controller.d.ts.map +1 -1
  100. package/dist/enterprise/training/training-admin.service.d.ts +2 -0
  101. package/dist/enterprise/training/training-admin.service.d.ts.map +1 -1
  102. package/dist/enterprise/training/training-student.service.d.ts +51 -0
  103. package/dist/enterprise/training/training-student.service.d.ts.map +1 -1
  104. package/dist/enterprise/training/training-student.service.js +217 -4
  105. package/dist/enterprise/training/training-student.service.js.map +1 -1
  106. package/dist/evaluation/evaluation.service.d.ts +18 -0
  107. package/dist/evaluation/evaluation.service.d.ts.map +1 -1
  108. package/dist/evaluation/evaluation.service.js +125 -0
  109. package/dist/evaluation/evaluation.service.js.map +1 -1
  110. package/dist/exam/dto/create-standalone-question.dto.d.ts +12 -0
  111. package/dist/exam/dto/create-standalone-question.dto.d.ts.map +1 -0
  112. package/dist/exam/dto/create-standalone-question.dto.js +70 -0
  113. package/dist/exam/dto/create-standalone-question.dto.js.map +1 -0
  114. package/dist/exam/exam.module.d.ts.map +1 -1
  115. package/dist/exam/exam.module.js +2 -1
  116. package/dist/exam/exam.module.js.map +1 -1
  117. package/dist/exam/exam.service.d.ts +21 -0
  118. package/dist/exam/exam.service.d.ts.map +1 -1
  119. package/dist/exam/exam.service.js +80 -0
  120. package/dist/exam/exam.service.js.map +1 -1
  121. package/dist/exam/question.controller.d.ts +27 -0
  122. package/dist/exam/question.controller.d.ts.map +1 -0
  123. package/dist/exam/question.controller.js +53 -0
  124. package/dist/exam/question.controller.js.map +1 -0
  125. package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.d.ts +4 -0
  126. package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.d.ts.map +1 -1
  127. package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.js +161 -25
  128. package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.js.map +1 -1
  129. package/dist/libraries/lms/tsconfig.tsbuildinfo +1 -1
  130. package/dist/lms-commerce-access.subscriber.d.ts +11 -0
  131. package/dist/lms-commerce-access.subscriber.d.ts.map +1 -0
  132. package/dist/lms-commerce-access.subscriber.js +74 -0
  133. package/dist/lms-commerce-access.subscriber.js.map +1 -0
  134. package/dist/lms.module.d.ts.map +1 -1
  135. package/dist/lms.module.js +16 -5
  136. package/dist/lms.module.js.map +1 -1
  137. package/dist/platforma/dto/heartbeat.dto.d.ts +9 -0
  138. package/dist/platforma/dto/heartbeat.dto.d.ts.map +1 -0
  139. package/dist/platforma/dto/heartbeat.dto.js +50 -0
  140. package/dist/platforma/dto/heartbeat.dto.js.map +1 -0
  141. package/dist/platforma/handlers/emit-certificate.handler.d.ts +27 -0
  142. package/dist/platforma/handlers/emit-certificate.handler.d.ts.map +1 -0
  143. package/dist/platforma/handlers/emit-certificate.handler.js +117 -0
  144. package/dist/platforma/handlers/emit-certificate.handler.js.map +1 -0
  145. package/dist/platforma/handlers/lesson-heartbeat.handler.d.ts +31 -0
  146. package/dist/platforma/handlers/lesson-heartbeat.handler.d.ts.map +1 -0
  147. package/dist/platforma/handlers/lesson-heartbeat.handler.js +281 -0
  148. package/dist/platforma/handlers/lesson-heartbeat.handler.js.map +1 -0
  149. package/dist/platforma/platforma-heartbeat.service.d.ts +10 -0
  150. package/dist/platforma/platforma-heartbeat.service.d.ts.map +1 -0
  151. package/dist/platforma/platforma-heartbeat.service.js +50 -0
  152. package/dist/platforma/platforma-heartbeat.service.js.map +1 -0
  153. package/dist/platforma/platforma-performance.service.d.ts +121 -0
  154. package/dist/platforma/platforma-performance.service.d.ts.map +1 -0
  155. package/dist/platforma/platforma-performance.service.js +500 -0
  156. package/dist/platforma/platforma-performance.service.js.map +1 -0
  157. package/dist/platforma/platforma-search.service.d.ts +21 -0
  158. package/dist/platforma/platforma-search.service.d.ts.map +1 -0
  159. package/dist/platforma/platforma-search.service.js +64 -0
  160. package/dist/platforma/platforma-search.service.js.map +1 -0
  161. package/dist/platforma/platforma-video.service.d.ts +39 -0
  162. package/dist/platforma/platforma-video.service.d.ts.map +1 -0
  163. package/dist/platforma/platforma-video.service.js +301 -0
  164. package/dist/platforma/platforma-video.service.js.map +1 -0
  165. package/dist/platforma/platforma.controller.d.ts +209 -1
  166. package/dist/platforma/platforma.controller.d.ts.map +1 -1
  167. package/dist/platforma/platforma.controller.js +208 -2
  168. package/dist/platforma/platforma.controller.js.map +1 -1
  169. package/dist/realtime/lms-realtime.controller.d.ts +2 -0
  170. package/dist/realtime/lms-realtime.controller.d.ts.map +1 -1
  171. package/dist/realtime/lms-realtime.controller.js +31 -0
  172. package/dist/realtime/lms-realtime.controller.js.map +1 -1
  173. package/dist/realtime/lms-realtime.service.d.ts +1 -1
  174. package/dist/realtime/lms-realtime.service.d.ts.map +1 -1
  175. package/dist/realtime/lms-realtime.service.js.map +1 -1
  176. package/dist/student-xp/dto/grant-skill-card-xp.dto.d.ts +5 -0
  177. package/dist/student-xp/dto/grant-skill-card-xp.dto.d.ts.map +1 -0
  178. package/dist/student-xp/dto/grant-skill-card-xp.dto.js +26 -0
  179. package/dist/student-xp/dto/grant-skill-card-xp.dto.js.map +1 -0
  180. package/dist/student-xp/student-xp.controller.d.ts +15 -0
  181. package/dist/student-xp/student-xp.controller.d.ts.map +1 -1
  182. package/dist/student-xp/student-xp.controller.js +24 -0
  183. package/dist/student-xp/student-xp.controller.js.map +1 -1
  184. package/dist/student-xp/student-xp.service.d.ts +16 -0
  185. package/dist/student-xp/student-xp.service.d.ts.map +1 -1
  186. package/dist/student-xp/student-xp.service.js +51 -1
  187. package/dist/student-xp/student-xp.service.js.map +1 -1
  188. package/hedhog/data/evaluation_topic.yaml +17 -0
  189. package/hedhog/data/menu.yaml +0 -17
  190. package/hedhog/data/queue_definition.yaml +48 -0
  191. package/hedhog/data/route.yaml +94 -124
  192. package/hedhog/data/setting_group.yaml +19 -19
  193. package/hedhog/frontend/app/bulk-upload-sessions/page.tsx.ejs +337 -41
  194. package/hedhog/frontend/app/certificates/models/page.tsx.ejs +182 -29
  195. package/hedhog/frontend/app/classes/_components/classes-calendar-view.tsx.ejs +277 -0
  196. package/hedhog/frontend/app/classes/page.tsx.ejs +127 -20
  197. package/hedhog/frontend/app/courses/[id]/page.tsx.ejs +69 -4
  198. package/hedhog/frontend/app/courses/[id]/structure/_components/course-export-sheet.tsx.ejs +420 -0
  199. package/hedhog/frontend/app/courses/[id]/structure/_components/course-exports-tab.tsx.ejs +308 -0
  200. package/hedhog/frontend/app/courses/[id]/structure/_components/course-overview-tab.tsx.ejs +158 -45
  201. package/hedhog/frontend/app/courses/[id]/structure/_components/course-xp-overview-tab.tsx.ejs +13 -13
  202. package/hedhog/frontend/app/courses/[id]/structure/_components/detail-lesson-xp-tab.tsx.ejs +11 -23
  203. package/hedhog/frontend/app/courses/[id]/structure/_components/detail-lesson.tsx.ejs +51 -63
  204. package/hedhog/frontend/app/courses/[id]/structure/_components/detail-panel.tsx.ejs +8 -3
  205. package/hedhog/frontend/app/courses/[id]/structure/_components/detail-session.tsx.ejs +31 -8
  206. package/hedhog/frontend/app/courses/[id]/structure/_components/drag-overlay.tsx.ejs +16 -9
  207. package/hedhog/frontend/app/courses/[id]/structure/_components/editor-course.tsx.ejs +201 -401
  208. package/hedhog/frontend/app/courses/[id]/structure/_components/editor-lesson.tsx.ejs +378 -690
  209. package/hedhog/frontend/app/courses/[id]/structure/_components/mock-data.ts.ejs +1 -2
  210. package/hedhog/frontend/app/courses/[id]/structure/_components/tree-row-lesson.tsx.ejs +3 -9
  211. package/hedhog/frontend/app/courses/[id]/structure/_components/types.ts.ejs +1 -1
  212. package/hedhog/frontend/app/courses/[id]/structure/_components/xp-premium-pills.tsx.ejs +1 -8
  213. package/hedhog/frontend/app/courses/[id]/structure/_data/adapters/course-structure.adapter.ts.ejs +6 -10
  214. package/hedhog/frontend/app/courses/[id]/structure/_data/services/course-structure.service.ts.ejs +49 -0
  215. package/hedhog/frontend/app/courses/[id]/structure/_data/types/api-course.types.ts.ejs +4 -3
  216. package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-content-overview.ts.ejs +2 -1
  217. package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-exports.ts.ejs +106 -0
  218. package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-structure-mutations.ts.ejs +28 -1
  219. package/hedhog/frontend/app/courses/[id]/structure/_data/use-lms-settings-query.ts.ejs +0 -2
  220. package/hedhog/frontend/app/courses/page.tsx.ejs +85 -9
  221. package/hedhog/frontend/app/enterprise/[id]/page.tsx.ejs +6 -0
  222. package/hedhog/frontend/app/enterprise/_components/enterprise-classes-calendar-tab.tsx.ejs +264 -0
  223. package/hedhog/frontend/app/enterprise/page.tsx.ejs +104 -47
  224. package/hedhog/frontend/app/exams/page.tsx.ejs +38 -4
  225. package/hedhog/frontend/app/instructors/page.tsx.ejs +87 -46
  226. package/hedhog/frontend/app/paths/page.tsx.ejs +38 -4
  227. package/hedhog/frontend/app/training/page.tsx.ejs +38 -4
  228. package/hedhog/frontend/messages/en.json +44 -28
  229. package/hedhog/frontend/messages/pt.json +47 -29
  230. package/hedhog/table/course_enrollment.yaml +3 -0
  231. package/hedhog/table/course_export.yaml +62 -0
  232. package/hedhog/table/lesson_view_event.yaml +66 -0
  233. package/package.json +14 -9
  234. package/src/bitcode-wallet/bitcode-wallet.service.ts +43 -4
  235. package/src/course/course-export-scorm12-worker.service.ts +124 -0
  236. package/src/course/course-export-scorm12.service.ts +668 -0
  237. package/src/course/course-export.service.ts +280 -0
  238. package/src/course/course-structure.controller.ts +16 -2
  239. package/src/course/course-structure.service.ts +100 -7
  240. package/src/course/course-video-agent-pipeline.service.ts +471 -0
  241. package/src/course/course-video-hls.service.ts +966 -0
  242. package/src/course/course.controller.ts +33 -19
  243. package/src/course/course.mcp-tools.ts +1 -1
  244. package/src/course/course.module.ts +16 -0
  245. package/src/course/course.service.ts +119 -61
  246. package/src/course/dto/cleanup-course-storage.dto.ts +1 -0
  247. package/src/course/dto/cleanup-upload-history.dto.ts +1 -1
  248. package/src/course/dto/create-course-bulk-job.dto.ts +7 -3
  249. package/src/course/dto/create-course-export.dto.ts +56 -0
  250. package/src/course/dto/create-course-structure-lesson.dto.ts +4 -3
  251. package/src/course/ffmpeg.util.ts +65 -0
  252. package/src/course/lms-bulk-upload-automation.service.ts +156 -6
  253. package/src/course/lms-bulk-upload-infra.service.ts +39 -6
  254. package/src/course/lms-bulk-upload.controller.ts +32 -2
  255. package/src/course/lms-bulk-upload.service.ts +70 -7
  256. package/src/course/lms-setting.controller.ts +4 -2
  257. package/src/course/scorm12-schemas.ts +9 -0
  258. package/src/enterprise/training/training-student.service.ts +221 -2
  259. package/src/evaluation/evaluation.service.ts +123 -0
  260. package/src/exam/dto/create-standalone-question.dto.ts +66 -0
  261. package/src/exam/exam.module.ts +2 -1
  262. package/src/exam/exam.service.ts +86 -0
  263. package/src/exam/question.controller.ts +28 -0
  264. package/src/lesson-xp-map/lesson-xp-ai-calculation.service.ts +205 -31
  265. package/src/lms-commerce-access.subscriber.ts +88 -0
  266. package/src/lms.module.ts +16 -5
  267. package/src/platforma/dto/heartbeat.dto.ts +30 -0
  268. package/src/platforma/handlers/emit-certificate.handler.ts +117 -0
  269. package/src/platforma/handlers/lesson-heartbeat.handler.ts +343 -0
  270. package/src/platforma/platforma-heartbeat.service.ts +33 -0
  271. package/src/platforma/platforma-performance.service.ts +606 -0
  272. package/src/platforma/platforma-search.service.ts +48 -0
  273. package/src/platforma/platforma-video.service.ts +346 -0
  274. package/src/platforma/platforma.controller.ts +137 -1
  275. package/src/platforma/platforma.service.ts +268 -268
  276. package/src/realtime/lms-realtime.controller.ts +27 -1
  277. package/src/realtime/lms-realtime.service.ts +2 -1
  278. package/src/student-xp/dto/grant-skill-card-xp.dto.ts +10 -0
  279. package/src/student-xp/student-xp.controller.ts +18 -2
  280. package/src/student-xp/student-xp.service.ts +84 -2
  281. package/hedhog/data/video_resolution_profile.yaml +0 -7
  282. package/hedhog/frontend/app/video-resolution-profiles/page.tsx.ejs +0 -607
  283. package/hedhog/table/course_video_resolution_profile.yaml +0 -22
  284. package/hedhog/table/video_resolution_profile.yaml +0 -18
  285. package/src/video-resolution-profile/dto/create-video-resolution-profile.dto.ts +0 -16
  286. package/src/video-resolution-profile/dto/update-video-resolution-profile.dto.ts +0 -16
  287. package/src/video-resolution-profile/video-resolution-profile.controller.ts +0 -62
  288. package/src/video-resolution-profile/video-resolution-profile.mcp-tools.ts +0 -128
  289. package/src/video-resolution-profile/video-resolution-profile.module.ts +0 -13
  290. package/src/video-resolution-profile/video-resolution-profile.service.ts +0 -117
@@ -1,268 +1,268 @@
1
- import { PrismaService } from '@hed-hog/api-prisma';
2
- import { Injectable } from '@nestjs/common';
3
- import { UpdatePlatformaProfileDto } from './dto/update-profile.dto';
4
-
5
- function mapGenderToDb(
6
- gender?: string | null,
7
- ): 'male' | 'female' | 'other' | null {
8
- if (!gender) return null;
9
- if (gender === 'Masculino') return 'male';
10
- if (gender === 'Feminino') return 'female';
11
- return 'other';
12
- }
13
-
14
- function mapGenderToDisplay(gender?: string | null): string | null {
15
- if (!gender) return null;
16
- if (gender === 'male') return 'Masculino';
17
- if (gender === 'female') return 'Feminino';
18
- return 'Prefiro nao dizer';
19
- }
20
-
21
- function buildLine1(street?: string | null, number?: string | null): string {
22
- if (!street && !number) return '';
23
- if (!number) return street ?? '';
24
- if (!street) return number;
25
- return `${street}, ${number}`;
26
- }
27
-
28
- function buildLine2(
29
- neighborhood?: string | null,
30
- complement?: string | null,
31
- ): string {
32
- const parts = [neighborhood, complement].filter(Boolean);
33
- return parts.join('; ');
34
- }
35
-
36
- function parseAddressLine1(line1?: string | null): [string, string] {
37
- if (!line1) return ['', ''];
38
- const idx = line1.lastIndexOf(', ');
39
- if (idx === -1) return [line1, ''];
40
- return [line1.slice(0, idx), line1.slice(idx + 2)];
41
- }
42
-
43
- function parseAddressLine2(line2?: string | null): [string, string] {
44
- if (!line2) return ['', ''];
45
- const idx = line2.indexOf('; ');
46
- if (idx === -1) return [line2, ''];
47
- return [line2.slice(0, idx), line2.slice(idx + 2)];
48
- }
49
-
50
- @Injectable()
51
- export class PlatformaService {
52
- constructor(private readonly prisma: PrismaService) {}
53
-
54
- async getProfile(userId: number) {
55
- const [user, personUser] = await Promise.all([
56
- this.prisma.user.findUnique({ where: { id: userId } }),
57
- this.prisma.person_user.findFirst({
58
- where: { user_id: userId },
59
- select: { person_id: true },
60
- }),
61
- ]);
62
-
63
- const personId = personUser?.person_id;
64
-
65
- const [individual, contacts, documents, personAddresses] =
66
- await Promise.all([
67
- personId
68
- ? this.prisma.person_individual.findUnique({
69
- where: { id: personId },
70
- })
71
- : Promise.resolve(null),
72
- personId
73
- ? this.prisma.contact.findMany({
74
- where: { person_id: personId },
75
- include: { contact_type: true },
76
- })
77
- : Promise.resolve([]),
78
- personId
79
- ? this.prisma.document.findMany({
80
- where: { person_id: personId },
81
- include: { document_type: true },
82
- })
83
- : Promise.resolve([]),
84
- personId
85
- ? this.prisma.person_address.findMany({
86
- where: { person_id: personId },
87
- include: { address: true },
88
- orderBy: { address: { is_primary: 'desc' } },
89
- })
90
- : Promise.resolve([]),
91
- ]);
92
-
93
- const phoneContact = contacts.find((c) => c.contact_type.code === 'PHONE');
94
- const cpfDoc = documents.find((d) => d.document_type.code === 'CPF');
95
- const primaryAddress =
96
- personAddresses.find((pa) => pa.address.is_primary)?.address ??
97
- personAddresses[0]?.address;
98
-
99
- const [street, number] = parseAddressLine1(primaryAddress?.line1);
100
- const [neighborhood, complement] = parseAddressLine2(primaryAddress?.line2);
101
-
102
- return {
103
- id: user?.id,
104
- name: user?.name ?? null,
105
- cpf: cpfDoc?.value ?? null,
106
- dob: individual?.birth_date
107
- ? individual.birth_date.toISOString().slice(0, 10)
108
- : null,
109
- gender: mapGenderToDisplay(individual?.gender as string | null),
110
- country: primaryAddress?.country_code ?? null,
111
- city: primaryAddress?.city ?? null,
112
- state: primaryAddress?.state ?? null,
113
- neighborhood,
114
- street,
115
- number,
116
- complement,
117
- zip: primaryAddress?.postal_code ?? null,
118
- phone: phoneContact?.value ?? null,
119
- profession: individual?.job_title ?? null,
120
- };
121
- }
122
-
123
- async updateProfile(userId: number, dto: UpdatePlatformaProfileDto) {
124
- await this.prisma.$transaction(async (tx) => {
125
- if (dto.name) {
126
- await tx.user.update({
127
- where: { id: userId },
128
- data: { name: dto.name },
129
- });
130
- }
131
-
132
- let personUser = await tx.person_user.findFirst({
133
- where: { user_id: userId },
134
- });
135
- let personId: number;
136
-
137
- if (!personUser) {
138
- const user = await tx.user.findUnique({ where: { id: userId } });
139
- const newPerson = await tx.person.create({
140
- data: {
141
- name: dto.name ?? user?.name ?? '',
142
- type: 'individual',
143
- status: 'active',
144
- } as any,
145
- });
146
- await tx.person_user.create({
147
- data: { person_id: newPerson.id, user_id: userId },
148
- });
149
- personId = newPerson.id;
150
- } else {
151
- personId = personUser.person_id;
152
- if (dto.name) {
153
- await tx.person.update({
154
- where: { id: personId },
155
- data: { name: dto.name },
156
- });
157
- }
158
- }
159
-
160
- const individualData: Record<string, unknown> = {};
161
- if (dto.dob !== undefined) {
162
- individualData.birth_date = dto.dob ? new Date(dto.dob) : null;
163
- }
164
- if (dto.gender !== undefined) {
165
- individualData.gender = mapGenderToDb(dto.gender);
166
- }
167
- if (dto.profession !== undefined) {
168
- individualData.job_title = dto.profession || null;
169
- }
170
-
171
- await (tx as any).person_individual.upsert({
172
- where: { id: personId },
173
- create: { id: personId, ...individualData },
174
- update: individualData,
175
- });
176
-
177
- const phoneType = await tx.contact_type.findFirst({
178
- where: { code: 'PHONE' },
179
- });
180
- if (phoneType && dto.phone !== undefined) {
181
- const existingPhone = await tx.contact.findFirst({
182
- where: { person_id: personId, contact_type_id: phoneType.id },
183
- });
184
- if (dto.phone) {
185
- if (existingPhone) {
186
- await tx.contact.update({
187
- where: { id: existingPhone.id },
188
- data: { value: dto.phone },
189
- });
190
- } else {
191
- await tx.contact.create({
192
- data: {
193
- person_id: personId,
194
- contact_type_id: phoneType.id,
195
- value: dto.phone,
196
- is_primary: true,
197
- },
198
- });
199
- }
200
- } else if (existingPhone) {
201
- await tx.contact.delete({ where: { id: existingPhone.id } });
202
- }
203
- }
204
-
205
- const cpfType = await tx.document_type.findFirst({
206
- where: { code: 'CPF' },
207
- });
208
- if (cpfType && dto.cpf !== undefined) {
209
- const existingCpf = await tx.document.findFirst({
210
- where: { person_id: personId, document_type_id: cpfType.id },
211
- });
212
- if (dto.cpf) {
213
- if (existingCpf) {
214
- await tx.document.update({
215
- where: { id: existingCpf.id },
216
- data: { value: dto.cpf },
217
- });
218
- } else {
219
- await tx.document.create({
220
- data: {
221
- person_id: personId,
222
- document_type_id: cpfType.id,
223
- value: dto.cpf,
224
- },
225
- });
226
- }
227
- } else if (existingCpf) {
228
- await tx.document.delete({ where: { id: existingCpf.id } });
229
- }
230
- }
231
-
232
- const hasAddressData =
233
- dto.street || dto.city || dto.state || dto.zip || dto.country;
234
- if (hasAddressData) {
235
- const existingPersonAddress = await tx.person_address.findFirst({
236
- where: { person_id: personId },
237
- include: { address: true },
238
- orderBy: { address: { is_primary: 'desc' } },
239
- });
240
-
241
- const addressData = {
242
- country_code: dto.country ?? '',
243
- state: dto.state ?? '',
244
- city: dto.city ?? '',
245
- postal_code: (dto.zip ?? '').replace(/\D/g, ''),
246
- line1: buildLine1(dto.street, dto.number),
247
- line2: buildLine2(dto.neighborhood, dto.complement),
248
- is_primary: true,
249
- address_type: 'residential' as const,
250
- };
251
-
252
- if (existingPersonAddress) {
253
- await tx.address.update({
254
- where: { id: existingPersonAddress.address_id },
255
- data: addressData,
256
- });
257
- } else {
258
- const newAddress = await tx.address.create({ data: addressData });
259
- await tx.person_address.create({
260
- data: { person_id: personId, address_id: newAddress.id },
261
- });
262
- }
263
- }
264
- });
265
-
266
- return { success: true };
267
- }
268
- }
1
+ import { PrismaService } from '@hed-hog/api-prisma';
2
+ import { Injectable } from '@nestjs/common';
3
+ import { UpdatePlatformaProfileDto } from './dto/update-profile.dto';
4
+
5
+ function mapGenderToDb(
6
+ gender?: string | null,
7
+ ): 'male' | 'female' | 'other' | null {
8
+ if (!gender) return null;
9
+ if (gender === 'Masculino') return 'male';
10
+ if (gender === 'Feminino') return 'female';
11
+ return 'other';
12
+ }
13
+
14
+ function mapGenderToDisplay(gender?: string | null): string | null {
15
+ if (!gender) return null;
16
+ if (gender === 'male') return 'Masculino';
17
+ if (gender === 'female') return 'Feminino';
18
+ return 'Prefiro nao dizer';
19
+ }
20
+
21
+ function buildLine1(street?: string | null, number?: string | null): string {
22
+ if (!street && !number) return '';
23
+ if (!number) return street ?? '';
24
+ if (!street) return number;
25
+ return `${street}, ${number}`;
26
+ }
27
+
28
+ function buildLine2(
29
+ neighborhood?: string | null,
30
+ complement?: string | null,
31
+ ): string {
32
+ const parts = [neighborhood, complement].filter(Boolean);
33
+ return parts.join('; ');
34
+ }
35
+
36
+ function parseAddressLine1(line1?: string | null): [string, string] {
37
+ if (!line1) return ['', ''];
38
+ const idx = line1.lastIndexOf(', ');
39
+ if (idx === -1) return [line1, ''];
40
+ return [line1.slice(0, idx), line1.slice(idx + 2)];
41
+ }
42
+
43
+ function parseAddressLine2(line2?: string | null): [string, string] {
44
+ if (!line2) return ['', ''];
45
+ const idx = line2.indexOf('; ');
46
+ if (idx === -1) return [line2, ''];
47
+ return [line2.slice(0, idx), line2.slice(idx + 2)];
48
+ }
49
+
50
+ @Injectable()
51
+ export class PlatformaService {
52
+ constructor(private readonly prisma: PrismaService) {}
53
+
54
+ async getProfile(userId: number) {
55
+ const [user, personUser] = await Promise.all([
56
+ this.prisma.user.findUnique({ where: { id: userId } }),
57
+ this.prisma.person_user.findFirst({
58
+ where: { user_id: userId },
59
+ select: { person_id: true },
60
+ }),
61
+ ]);
62
+
63
+ const personId = personUser?.person_id;
64
+
65
+ const [individual, contacts, documents, personAddresses] =
66
+ await Promise.all([
67
+ personId
68
+ ? this.prisma.person_individual.findUnique({
69
+ where: { id: personId },
70
+ })
71
+ : Promise.resolve(null),
72
+ personId
73
+ ? this.prisma.contact.findMany({
74
+ where: { person_id: personId },
75
+ include: { contact_type: true },
76
+ })
77
+ : Promise.resolve([]),
78
+ personId
79
+ ? this.prisma.document.findMany({
80
+ where: { person_id: personId },
81
+ include: { document_type: true },
82
+ })
83
+ : Promise.resolve([]),
84
+ personId
85
+ ? this.prisma.person_address.findMany({
86
+ where: { person_id: personId },
87
+ include: { address: true },
88
+ orderBy: { address: { is_primary: 'desc' } },
89
+ })
90
+ : Promise.resolve([]),
91
+ ]);
92
+
93
+ const phoneContact = contacts.find((c) => c.contact_type.code === 'PHONE');
94
+ const cpfDoc = documents.find((d) => d.document_type.code === 'CPF');
95
+ const primaryAddress =
96
+ personAddresses.find((pa) => pa.address.is_primary)?.address ??
97
+ personAddresses[0]?.address;
98
+
99
+ const [street, number] = parseAddressLine1(primaryAddress?.line1);
100
+ const [neighborhood, complement] = parseAddressLine2(primaryAddress?.line2);
101
+
102
+ return {
103
+ id: user?.id,
104
+ name: user?.name ?? null,
105
+ cpf: cpfDoc?.value ?? null,
106
+ dob: individual?.birth_date
107
+ ? individual.birth_date.toISOString().slice(0, 10)
108
+ : null,
109
+ gender: mapGenderToDisplay(individual?.gender as string | null),
110
+ country: primaryAddress?.country_code ?? null,
111
+ city: primaryAddress?.city ?? null,
112
+ state: primaryAddress?.state ?? null,
113
+ neighborhood,
114
+ street,
115
+ number,
116
+ complement,
117
+ zip: primaryAddress?.postal_code ?? null,
118
+ phone: phoneContact?.value ?? null,
119
+ profession: individual?.job_title ?? null,
120
+ };
121
+ }
122
+
123
+ async updateProfile(userId: number, dto: UpdatePlatformaProfileDto) {
124
+ await this.prisma.$transaction(async (tx) => {
125
+ if (dto.name) {
126
+ await tx.user.update({
127
+ where: { id: userId },
128
+ data: { name: dto.name },
129
+ });
130
+ }
131
+
132
+ let personUser = await tx.person_user.findFirst({
133
+ where: { user_id: userId },
134
+ });
135
+ let personId: number;
136
+
137
+ if (!personUser) {
138
+ const user = await tx.user.findUnique({ where: { id: userId } });
139
+ const newPerson = await tx.person.create({
140
+ data: {
141
+ name: dto.name ?? user?.name ?? '',
142
+ type: 'individual',
143
+ status: 'active',
144
+ } as any,
145
+ });
146
+ await tx.person_user.create({
147
+ data: { person_id: newPerson.id, user_id: userId },
148
+ });
149
+ personId = newPerson.id;
150
+ } else {
151
+ personId = personUser.person_id;
152
+ if (dto.name) {
153
+ await tx.person.update({
154
+ where: { id: personId },
155
+ data: { name: dto.name },
156
+ });
157
+ }
158
+ }
159
+
160
+ const individualData: Record<string, unknown> = {};
161
+ if (dto.dob !== undefined) {
162
+ individualData.birth_date = dto.dob ? new Date(dto.dob) : null;
163
+ }
164
+ if (dto.gender !== undefined) {
165
+ individualData.gender = mapGenderToDb(dto.gender);
166
+ }
167
+ if (dto.profession !== undefined) {
168
+ individualData.job_title = dto.profession || null;
169
+ }
170
+
171
+ await (tx as any).person_individual.upsert({
172
+ where: { id: personId },
173
+ create: { id: personId, ...individualData },
174
+ update: individualData,
175
+ });
176
+
177
+ const phoneType = await tx.contact_type.findFirst({
178
+ where: { code: 'PHONE' },
179
+ });
180
+ if (phoneType && dto.phone !== undefined) {
181
+ const existingPhone = await tx.contact.findFirst({
182
+ where: { person_id: personId, contact_type_id: phoneType.id },
183
+ });
184
+ if (dto.phone) {
185
+ if (existingPhone) {
186
+ await tx.contact.update({
187
+ where: { id: existingPhone.id },
188
+ data: { value: dto.phone },
189
+ });
190
+ } else {
191
+ await tx.contact.create({
192
+ data: {
193
+ person_id: personId,
194
+ contact_type_id: phoneType.id,
195
+ value: dto.phone,
196
+ is_primary: true,
197
+ },
198
+ });
199
+ }
200
+ } else if (existingPhone) {
201
+ await tx.contact.delete({ where: { id: existingPhone.id } });
202
+ }
203
+ }
204
+
205
+ const cpfType = await tx.document_type.findFirst({
206
+ where: { code: 'CPF' },
207
+ });
208
+ if (cpfType && dto.cpf !== undefined) {
209
+ const existingCpf = await tx.document.findFirst({
210
+ where: { person_id: personId, document_type_id: cpfType.id },
211
+ });
212
+ if (dto.cpf) {
213
+ if (existingCpf) {
214
+ await tx.document.update({
215
+ where: { id: existingCpf.id },
216
+ data: { value: dto.cpf },
217
+ });
218
+ } else {
219
+ await tx.document.create({
220
+ data: {
221
+ person_id: personId,
222
+ document_type_id: cpfType.id,
223
+ value: dto.cpf,
224
+ },
225
+ });
226
+ }
227
+ } else if (existingCpf) {
228
+ await tx.document.delete({ where: { id: existingCpf.id } });
229
+ }
230
+ }
231
+
232
+ const hasAddressData =
233
+ dto.street || dto.city || dto.state || dto.zip || dto.country;
234
+ if (hasAddressData) {
235
+ const existingPersonAddress = await tx.person_address.findFirst({
236
+ where: { person_id: personId },
237
+ include: { address: true },
238
+ orderBy: { address: { is_primary: 'desc' } },
239
+ });
240
+
241
+ const addressData = {
242
+ country_code: dto.country ?? '',
243
+ state: dto.state ?? '',
244
+ city: dto.city ?? '',
245
+ postal_code: (dto.zip ?? '').replace(/\D/g, ''),
246
+ line1: buildLine1(dto.street, dto.number),
247
+ line2: buildLine2(dto.neighborhood, dto.complement),
248
+ is_primary: true,
249
+ address_type: 'residential' as const,
250
+ };
251
+
252
+ if (existingPersonAddress) {
253
+ await tx.address.update({
254
+ where: { id: existingPersonAddress.address_id },
255
+ data: addressData,
256
+ });
257
+ } else {
258
+ const newAddress = await tx.address.create({ data: addressData });
259
+ await tx.person_address.create({
260
+ data: { person_id: personId, address_id: newAddress.id },
261
+ });
262
+ }
263
+ }
264
+ });
265
+
266
+ return { success: true };
267
+ }
268
+ }
@@ -1,4 +1,5 @@
1
- import { Controller, Get } from '@nestjs/common';
1
+ import { Controller, Get, Req, Res } from '@nestjs/common';
2
+ import type { Request, Response } from 'express';
2
3
  import { LmsRealtimeCursor, LmsRealtimeService } from './lms-realtime.service';
3
4
 
4
5
  @Controller('lms/realtime')
@@ -9,4 +10,29 @@ export class LmsRealtimeController {
9
10
  getCursor(): LmsRealtimeCursor {
10
11
  return this.lmsRealtime.getCursor();
11
12
  }
13
+
14
+ @Get('activity/stream')
15
+ streamActivity(@Req() req: Request, @Res() res: Response) {
16
+ res.set({
17
+ 'Content-Type': 'text/event-stream',
18
+ 'Cache-Control': 'no-cache',
19
+ Connection: 'keep-alive',
20
+ 'X-Accel-Buffering': 'no',
21
+ });
22
+ res.flushHeaders();
23
+
24
+ const unsub = this.lmsRealtime.subscribe((event) => {
25
+ if (event.domain === 'lesson_view') {
26
+ res.write(`data: ${JSON.stringify(event)}\n\n`);
27
+ }
28
+ });
29
+
30
+ // Send a heartbeat every 25s to keep the connection alive through proxies
31
+ const heartbeat = setInterval(() => res.write(': ping\n\n'), 25_000);
32
+
33
+ req.on('close', () => {
34
+ clearInterval(heartbeat);
35
+ unsub();
36
+ });
37
+ }
12
38
  }
@@ -8,7 +8,8 @@ export type LmsRealtimeDomain =
8
8
  | 'exam_attempt'
9
9
  | 'enterprise'
10
10
  | 'instructor'
11
- | 'achievement';
11
+ | 'achievement'
12
+ | 'lesson_view';
12
13
 
13
14
  export type LmsRealtimeEventType =
14
15
  | 'created'
@@ -0,0 +1,10 @@
1
+ import { IsInt, IsString, Min } from 'class-validator';
2
+
3
+ export class GrantSkillCardXpDto {
4
+ @IsString()
5
+ skillCardSlug: string;
6
+
7
+ @IsInt()
8
+ @Min(1)
9
+ xpEarned: number;
10
+ }
@@ -1,5 +1,6 @@
1
- import { Role } from '@hed-hog/api';
2
- import { Controller, Get, Param, ParseIntPipe, Query } from '@nestjs/common';
1
+ import { NoRole, Role, User } from '@hed-hog/api';
2
+ import { Body, Controller, Get, Param, ParseIntPipe, Post, Query } from '@nestjs/common';
3
+ import { GrantSkillCardXpDto } from './dto/grant-skill-card-xp.dto';
3
4
  import { StudentXpService } from './student-xp.service';
4
5
 
5
6
  @Role()
@@ -73,4 +74,19 @@ export class StudentXpController {
73
74
  getPersonBalanceSummary(@Param('personId', ParseIntPipe) personId: number) {
74
75
  return this.studentXpService.getPersonBalanceSummary(personId);
75
76
  }
77
+
78
+ @Get('my-balance')
79
+ @NoRole()
80
+ getMyBalance(@User('id') userId: number) {
81
+ return this.studentXpService.getMyBalance(userId);
82
+ }
83
+
84
+ @Post('skill-card')
85
+ @NoRole()
86
+ grantSkillCardXp(
87
+ @User('id') userId: number,
88
+ @Body() dto: GrantSkillCardXpDto,
89
+ ) {
90
+ return this.studentXpService.grantSkillCardXp(userId, dto);
91
+ }
76
92
  }