@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.
- package/dist/bitcode-wallet/bitcode-wallet.service.d.ts +1 -0
- package/dist/bitcode-wallet/bitcode-wallet.service.d.ts.map +1 -1
- package/dist/bitcode-wallet/bitcode-wallet.service.js +22 -3
- package/dist/bitcode-wallet/bitcode-wallet.service.js.map +1 -1
- package/dist/class-group/class-group.controller.d.ts +1 -0
- package/dist/class-group/class-group.controller.d.ts.map +1 -1
- package/dist/class-group/class-group.service.d.ts +1 -0
- package/dist/class-group/class-group.service.d.ts.map +1 -1
- package/dist/course/course-export-scorm12-worker.service.d.ts +21 -0
- package/dist/course/course-export-scorm12-worker.service.d.ts.map +1 -0
- package/dist/course/course-export-scorm12-worker.service.js +109 -0
- package/dist/course/course-export-scorm12-worker.service.js.map +1 -0
- package/dist/course/course-export-scorm12.service.d.ts +42 -0
- package/dist/course/course-export-scorm12.service.d.ts.map +1 -0
- package/dist/course/course-export-scorm12.service.js +628 -0
- package/dist/course/course-export-scorm12.service.js.map +1 -0
- package/dist/course/course-export.service.d.ts +84 -0
- package/dist/course/course-export.service.d.ts.map +1 -0
- package/dist/course/course-export.service.js +237 -0
- package/dist/course/course-export.service.js.map +1 -0
- package/dist/course/course-structure.controller.d.ts +20 -10
- package/dist/course/course-structure.controller.d.ts.map +1 -1
- package/dist/course/course-structure.controller.js +20 -4
- package/dist/course/course-structure.controller.js.map +1 -1
- package/dist/course/course-structure.service.d.ts +12 -4
- package/dist/course/course-structure.service.d.ts.map +1 -1
- package/dist/course/course-structure.service.js +98 -23
- package/dist/course/course-structure.service.js.map +1 -1
- package/dist/course/course-video-agent-pipeline.service.d.ts +70 -0
- package/dist/course/course-video-agent-pipeline.service.d.ts.map +1 -0
- package/dist/course/course-video-agent-pipeline.service.js +398 -0
- package/dist/course/course-video-agent-pipeline.service.js.map +1 -0
- package/dist/course/course-video-hls.service.d.ts +71 -0
- package/dist/course/course-video-hls.service.d.ts.map +1 -0
- package/dist/course/course-video-hls.service.js +784 -0
- package/dist/course/course-video-hls.service.js.map +1 -0
- package/dist/course/course.controller.d.ts +47 -13
- package/dist/course/course.controller.d.ts.map +1 -1
- package/dist/course/course.controller.js +40 -26
- package/dist/course/course.controller.js.map +1 -1
- package/dist/course/course.mcp-tools.js +1 -1
- package/dist/course/course.mcp-tools.js.map +1 -1
- package/dist/course/course.module.d.ts.map +1 -1
- package/dist/course/course.module.js +16 -0
- package/dist/course/course.module.js.map +1 -1
- package/dist/course/course.service.d.ts +8 -9
- package/dist/course/course.service.d.ts.map +1 -1
- package/dist/course/course.service.js +93 -50
- package/dist/course/course.service.js.map +1 -1
- package/dist/course/dto/cleanup-course-storage.dto.d.ts +1 -1
- package/dist/course/dto/cleanup-course-storage.dto.d.ts.map +1 -1
- package/dist/course/dto/cleanup-course-storage.dto.js +1 -0
- package/dist/course/dto/cleanup-course-storage.dto.js.map +1 -1
- package/dist/course/dto/cleanup-upload-history.dto.d.ts +1 -1
- package/dist/course/dto/cleanup-upload-history.dto.d.ts.map +1 -1
- package/dist/course/dto/cleanup-upload-history.dto.js +1 -1
- package/dist/course/dto/cleanup-upload-history.dto.js.map +1 -1
- package/dist/course/dto/create-course-bulk-job.dto.d.ts +2 -1
- package/dist/course/dto/create-course-bulk-job.dto.d.ts.map +1 -1
- package/dist/course/dto/create-course-bulk-job.dto.js +6 -1
- package/dist/course/dto/create-course-bulk-job.dto.js.map +1 -1
- package/dist/course/dto/create-course-export.dto.d.ts +14 -0
- package/dist/course/dto/create-course-export.dto.d.ts.map +1 -0
- package/dist/course/dto/create-course-export.dto.js +71 -0
- package/dist/course/dto/create-course-export.dto.js.map +1 -0
- package/dist/course/dto/create-course-structure-lesson.dto.d.ts +2 -2
- package/dist/course/dto/create-course-structure-lesson.dto.d.ts.map +1 -1
- package/dist/course/dto/create-course-structure-lesson.dto.js +3 -2
- package/dist/course/dto/create-course-structure-lesson.dto.js.map +1 -1
- package/dist/course/ffmpeg.util.d.ts +10 -0
- package/dist/course/ffmpeg.util.d.ts.map +1 -0
- package/dist/course/ffmpeg.util.js +79 -0
- package/dist/course/ffmpeg.util.js.map +1 -0
- package/dist/course/lms-bulk-upload-automation.service.d.ts +18 -1
- package/dist/course/lms-bulk-upload-automation.service.d.ts.map +1 -1
- package/dist/course/lms-bulk-upload-automation.service.js +106 -8
- package/dist/course/lms-bulk-upload-automation.service.js.map +1 -1
- package/dist/course/lms-bulk-upload-infra.service.d.ts +1 -0
- package/dist/course/lms-bulk-upload-infra.service.d.ts.map +1 -1
- package/dist/course/lms-bulk-upload-infra.service.js +32 -8
- package/dist/course/lms-bulk-upload-infra.service.js.map +1 -1
- package/dist/course/lms-bulk-upload.controller.d.ts +30 -3
- package/dist/course/lms-bulk-upload.controller.d.ts.map +1 -1
- package/dist/course/lms-bulk-upload.controller.js +43 -2
- package/dist/course/lms-bulk-upload.controller.js.map +1 -1
- package/dist/course/lms-bulk-upload.service.d.ts +11 -0
- package/dist/course/lms-bulk-upload.service.d.ts.map +1 -1
- package/dist/course/lms-bulk-upload.service.js +59 -6
- package/dist/course/lms-bulk-upload.service.js.map +1 -1
- package/dist/course/lms-setting.controller.d.ts +2 -1
- package/dist/course/lms-setting.controller.d.ts.map +1 -1
- package/dist/course/lms-setting.controller.js +4 -2
- package/dist/course/lms-setting.controller.js.map +1 -1
- package/dist/course/scorm12-schemas.d.ts +4 -0
- package/dist/course/scorm12-schemas.d.ts.map +1 -0
- package/dist/course/scorm12-schemas.js +9 -0
- package/dist/course/scorm12-schemas.js.map +1 -0
- package/dist/enterprise/training/training-admin.controller.d.ts +2 -0
- package/dist/enterprise/training/training-admin.controller.d.ts.map +1 -1
- package/dist/enterprise/training/training-admin.service.d.ts +2 -0
- package/dist/enterprise/training/training-admin.service.d.ts.map +1 -1
- package/dist/enterprise/training/training-student.service.d.ts +51 -0
- package/dist/enterprise/training/training-student.service.d.ts.map +1 -1
- package/dist/enterprise/training/training-student.service.js +217 -4
- package/dist/enterprise/training/training-student.service.js.map +1 -1
- package/dist/evaluation/evaluation.service.d.ts +18 -0
- package/dist/evaluation/evaluation.service.d.ts.map +1 -1
- package/dist/evaluation/evaluation.service.js +125 -0
- package/dist/evaluation/evaluation.service.js.map +1 -1
- package/dist/exam/dto/create-standalone-question.dto.d.ts +12 -0
- package/dist/exam/dto/create-standalone-question.dto.d.ts.map +1 -0
- package/dist/exam/dto/create-standalone-question.dto.js +70 -0
- package/dist/exam/dto/create-standalone-question.dto.js.map +1 -0
- package/dist/exam/exam.module.d.ts.map +1 -1
- package/dist/exam/exam.module.js +2 -1
- package/dist/exam/exam.module.js.map +1 -1
- package/dist/exam/exam.service.d.ts +21 -0
- package/dist/exam/exam.service.d.ts.map +1 -1
- package/dist/exam/exam.service.js +80 -0
- package/dist/exam/exam.service.js.map +1 -1
- package/dist/exam/question.controller.d.ts +27 -0
- package/dist/exam/question.controller.d.ts.map +1 -0
- package/dist/exam/question.controller.js +53 -0
- package/dist/exam/question.controller.js.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.d.ts +4 -0
- package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.d.ts.map +1 -1
- package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.js +161 -25
- package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.js.map +1 -1
- package/dist/libraries/lms/tsconfig.tsbuildinfo +1 -1
- package/dist/lms-commerce-access.subscriber.d.ts +11 -0
- package/dist/lms-commerce-access.subscriber.d.ts.map +1 -0
- package/dist/lms-commerce-access.subscriber.js +74 -0
- package/dist/lms-commerce-access.subscriber.js.map +1 -0
- package/dist/lms.module.d.ts.map +1 -1
- package/dist/lms.module.js +16 -5
- package/dist/lms.module.js.map +1 -1
- package/dist/platforma/dto/heartbeat.dto.d.ts +9 -0
- package/dist/platforma/dto/heartbeat.dto.d.ts.map +1 -0
- package/dist/platforma/dto/heartbeat.dto.js +50 -0
- package/dist/platforma/dto/heartbeat.dto.js.map +1 -0
- package/dist/platforma/handlers/emit-certificate.handler.d.ts +27 -0
- package/dist/platforma/handlers/emit-certificate.handler.d.ts.map +1 -0
- package/dist/platforma/handlers/emit-certificate.handler.js +117 -0
- package/dist/platforma/handlers/emit-certificate.handler.js.map +1 -0
- package/dist/platforma/handlers/lesson-heartbeat.handler.d.ts +31 -0
- package/dist/platforma/handlers/lesson-heartbeat.handler.d.ts.map +1 -0
- package/dist/platforma/handlers/lesson-heartbeat.handler.js +281 -0
- package/dist/platforma/handlers/lesson-heartbeat.handler.js.map +1 -0
- package/dist/platforma/platforma-heartbeat.service.d.ts +10 -0
- package/dist/platforma/platforma-heartbeat.service.d.ts.map +1 -0
- package/dist/platforma/platforma-heartbeat.service.js +50 -0
- package/dist/platforma/platforma-heartbeat.service.js.map +1 -0
- package/dist/platforma/platforma-performance.service.d.ts +121 -0
- package/dist/platforma/platforma-performance.service.d.ts.map +1 -0
- package/dist/platforma/platforma-performance.service.js +500 -0
- package/dist/platforma/platforma-performance.service.js.map +1 -0
- package/dist/platforma/platforma-search.service.d.ts +21 -0
- package/dist/platforma/platforma-search.service.d.ts.map +1 -0
- package/dist/platforma/platforma-search.service.js +64 -0
- package/dist/platforma/platforma-search.service.js.map +1 -0
- package/dist/platforma/platforma-video.service.d.ts +39 -0
- package/dist/platforma/platforma-video.service.d.ts.map +1 -0
- package/dist/platforma/platforma-video.service.js +301 -0
- package/dist/platforma/platforma-video.service.js.map +1 -0
- package/dist/platforma/platforma.controller.d.ts +209 -1
- package/dist/platforma/platforma.controller.d.ts.map +1 -1
- package/dist/platforma/platforma.controller.js +208 -2
- package/dist/platforma/platforma.controller.js.map +1 -1
- package/dist/realtime/lms-realtime.controller.d.ts +2 -0
- package/dist/realtime/lms-realtime.controller.d.ts.map +1 -1
- package/dist/realtime/lms-realtime.controller.js +31 -0
- package/dist/realtime/lms-realtime.controller.js.map +1 -1
- package/dist/realtime/lms-realtime.service.d.ts +1 -1
- package/dist/realtime/lms-realtime.service.d.ts.map +1 -1
- package/dist/realtime/lms-realtime.service.js.map +1 -1
- package/dist/student-xp/dto/grant-skill-card-xp.dto.d.ts +5 -0
- package/dist/student-xp/dto/grant-skill-card-xp.dto.d.ts.map +1 -0
- package/dist/student-xp/dto/grant-skill-card-xp.dto.js +26 -0
- package/dist/student-xp/dto/grant-skill-card-xp.dto.js.map +1 -0
- package/dist/student-xp/student-xp.controller.d.ts +15 -0
- package/dist/student-xp/student-xp.controller.d.ts.map +1 -1
- package/dist/student-xp/student-xp.controller.js +24 -0
- package/dist/student-xp/student-xp.controller.js.map +1 -1
- package/dist/student-xp/student-xp.service.d.ts +16 -0
- package/dist/student-xp/student-xp.service.d.ts.map +1 -1
- package/dist/student-xp/student-xp.service.js +51 -1
- package/dist/student-xp/student-xp.service.js.map +1 -1
- package/hedhog/data/evaluation_topic.yaml +17 -0
- package/hedhog/data/menu.yaml +0 -17
- package/hedhog/data/queue_definition.yaml +48 -0
- package/hedhog/data/route.yaml +94 -124
- package/hedhog/data/setting_group.yaml +19 -19
- package/hedhog/frontend/app/bulk-upload-sessions/page.tsx.ejs +337 -41
- package/hedhog/frontend/app/certificates/models/page.tsx.ejs +182 -29
- package/hedhog/frontend/app/classes/_components/classes-calendar-view.tsx.ejs +277 -0
- package/hedhog/frontend/app/classes/page.tsx.ejs +127 -20
- package/hedhog/frontend/app/courses/[id]/page.tsx.ejs +69 -4
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-export-sheet.tsx.ejs +420 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-exports-tab.tsx.ejs +308 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-overview-tab.tsx.ejs +158 -45
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-xp-overview-tab.tsx.ejs +13 -13
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-lesson-xp-tab.tsx.ejs +11 -23
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-lesson.tsx.ejs +51 -63
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-panel.tsx.ejs +8 -3
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-session.tsx.ejs +31 -8
- package/hedhog/frontend/app/courses/[id]/structure/_components/drag-overlay.tsx.ejs +16 -9
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-course.tsx.ejs +201 -401
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-lesson.tsx.ejs +378 -690
- package/hedhog/frontend/app/courses/[id]/structure/_components/mock-data.ts.ejs +1 -2
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-row-lesson.tsx.ejs +3 -9
- package/hedhog/frontend/app/courses/[id]/structure/_components/types.ts.ejs +1 -1
- package/hedhog/frontend/app/courses/[id]/structure/_components/xp-premium-pills.tsx.ejs +1 -8
- package/hedhog/frontend/app/courses/[id]/structure/_data/adapters/course-structure.adapter.ts.ejs +6 -10
- package/hedhog/frontend/app/courses/[id]/structure/_data/services/course-structure.service.ts.ejs +49 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/types/api-course.types.ts.ejs +4 -3
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-content-overview.ts.ejs +2 -1
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-exports.ts.ejs +106 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-structure-mutations.ts.ejs +28 -1
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-lms-settings-query.ts.ejs +0 -2
- package/hedhog/frontend/app/courses/page.tsx.ejs +85 -9
- package/hedhog/frontend/app/enterprise/[id]/page.tsx.ejs +6 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-classes-calendar-tab.tsx.ejs +264 -0
- package/hedhog/frontend/app/enterprise/page.tsx.ejs +104 -47
- package/hedhog/frontend/app/exams/page.tsx.ejs +38 -4
- package/hedhog/frontend/app/instructors/page.tsx.ejs +87 -46
- package/hedhog/frontend/app/paths/page.tsx.ejs +38 -4
- package/hedhog/frontend/app/training/page.tsx.ejs +38 -4
- package/hedhog/frontend/messages/en.json +44 -28
- package/hedhog/frontend/messages/pt.json +47 -29
- package/hedhog/table/course_enrollment.yaml +3 -0
- package/hedhog/table/course_export.yaml +62 -0
- package/hedhog/table/lesson_view_event.yaml +66 -0
- package/package.json +14 -9
- package/src/bitcode-wallet/bitcode-wallet.service.ts +43 -4
- package/src/course/course-export-scorm12-worker.service.ts +124 -0
- package/src/course/course-export-scorm12.service.ts +668 -0
- package/src/course/course-export.service.ts +280 -0
- package/src/course/course-structure.controller.ts +16 -2
- package/src/course/course-structure.service.ts +100 -7
- package/src/course/course-video-agent-pipeline.service.ts +471 -0
- package/src/course/course-video-hls.service.ts +966 -0
- package/src/course/course.controller.ts +33 -19
- package/src/course/course.mcp-tools.ts +1 -1
- package/src/course/course.module.ts +16 -0
- package/src/course/course.service.ts +119 -61
- package/src/course/dto/cleanup-course-storage.dto.ts +1 -0
- package/src/course/dto/cleanup-upload-history.dto.ts +1 -1
- package/src/course/dto/create-course-bulk-job.dto.ts +7 -3
- package/src/course/dto/create-course-export.dto.ts +56 -0
- package/src/course/dto/create-course-structure-lesson.dto.ts +4 -3
- package/src/course/ffmpeg.util.ts +65 -0
- package/src/course/lms-bulk-upload-automation.service.ts +156 -6
- package/src/course/lms-bulk-upload-infra.service.ts +39 -6
- package/src/course/lms-bulk-upload.controller.ts +32 -2
- package/src/course/lms-bulk-upload.service.ts +70 -7
- package/src/course/lms-setting.controller.ts +4 -2
- package/src/course/scorm12-schemas.ts +9 -0
- package/src/enterprise/training/training-student.service.ts +221 -2
- package/src/evaluation/evaluation.service.ts +123 -0
- package/src/exam/dto/create-standalone-question.dto.ts +66 -0
- package/src/exam/exam.module.ts +2 -1
- package/src/exam/exam.service.ts +86 -0
- package/src/exam/question.controller.ts +28 -0
- package/src/lesson-xp-map/lesson-xp-ai-calculation.service.ts +205 -31
- package/src/lms-commerce-access.subscriber.ts +88 -0
- package/src/lms.module.ts +16 -5
- package/src/platforma/dto/heartbeat.dto.ts +30 -0
- package/src/platforma/handlers/emit-certificate.handler.ts +117 -0
- package/src/platforma/handlers/lesson-heartbeat.handler.ts +343 -0
- package/src/platforma/platforma-heartbeat.service.ts +33 -0
- package/src/platforma/platforma-performance.service.ts +606 -0
- package/src/platforma/platforma-search.service.ts +48 -0
- package/src/platforma/platforma-video.service.ts +346 -0
- package/src/platforma/platforma.controller.ts +137 -1
- package/src/platforma/platforma.service.ts +268 -268
- package/src/realtime/lms-realtime.controller.ts +27 -1
- package/src/realtime/lms-realtime.service.ts +2 -1
- package/src/student-xp/dto/grant-skill-card-xp.dto.ts +10 -0
- package/src/student-xp/student-xp.controller.ts +18 -2
- package/src/student-xp/student-xp.service.ts +84 -2
- package/hedhog/data/video_resolution_profile.yaml +0 -7
- package/hedhog/frontend/app/video-resolution-profiles/page.tsx.ejs +0 -607
- package/hedhog/table/course_video_resolution_profile.yaml +0 -22
- package/hedhog/table/video_resolution_profile.yaml +0 -18
- package/src/video-resolution-profile/dto/create-video-resolution-profile.dto.ts +0 -16
- package/src/video-resolution-profile/dto/update-video-resolution-profile.dto.ts +0 -16
- package/src/video-resolution-profile/video-resolution-profile.controller.ts +0 -62
- package/src/video-resolution-profile/video-resolution-profile.mcp-tools.ts +0 -128
- package/src/video-resolution-profile/video-resolution-profile.module.ts +0 -13
- 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
|
}
|
|
@@ -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
|
}
|