@driveup/schema 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/README.md +174 -0
  2. package/lib/catalog/addon/addon.entity.d.ts +109 -0
  3. package/lib/catalog/addon/addon.entity.js +260 -0
  4. package/lib/catalog/addon/addon.entity.js.map +1 -0
  5. package/lib/catalog/addon/country.entity.d.ts +112 -0
  6. package/lib/catalog/addon/country.entity.js +246 -0
  7. package/lib/catalog/addon/country.entity.js.map +1 -0
  8. package/lib/catalog/driving/category.entity.d.ts +122 -0
  9. package/lib/catalog/driving/category.entity.js +217 -0
  10. package/lib/catalog/driving/category.entity.js.map +1 -0
  11. package/lib/catalog/driving/vehicle.entity.d.ts +49 -0
  12. package/lib/catalog/driving/vehicle.entity.js +97 -0
  13. package/lib/catalog/driving/vehicle.entity.js.map +1 -0
  14. package/lib/catalog/priceplan/priceplan.entity.d.ts +123 -0
  15. package/lib/catalog/priceplan/priceplan.entity.js +288 -0
  16. package/lib/catalog/priceplan/priceplan.entity.js.map +1 -0
  17. package/lib/catalog/product/country.entity.d.ts +109 -0
  18. package/lib/catalog/product/country.entity.js +233 -0
  19. package/lib/catalog/product/country.entity.js.map +1 -0
  20. package/lib/catalog/product/priceplan.entity.d.ts +113 -0
  21. package/lib/catalog/product/priceplan.entity.js +251 -0
  22. package/lib/catalog/product/priceplan.entity.js.map +1 -0
  23. package/lib/catalog/product/product.entity.d.ts +104 -0
  24. package/lib/catalog/product/product.entity.js +262 -0
  25. package/lib/catalog/product/product.entity.js.map +1 -0
  26. package/lib/catalog/program/program.entity.d.ts +107 -0
  27. package/lib/catalog/program/program.entity.js +247 -0
  28. package/lib/catalog/program/program.entity.js.map +1 -0
  29. package/lib/catalog/seed/assets/asset.entity.d.ts +68 -0
  30. package/lib/catalog/seed/assets/asset.entity.js +163 -0
  31. package/lib/catalog/seed/assets/asset.entity.js.map +1 -0
  32. package/lib/catalog/seed/courses/course.entity.d.ts +98 -0
  33. package/lib/catalog/seed/courses/course.entity.js +216 -0
  34. package/lib/catalog/seed/courses/course.entity.js.map +1 -0
  35. package/lib/catalog/seed/courses/lesson.entity.d.ts +90 -0
  36. package/lib/catalog/seed/courses/lesson.entity.js +214 -0
  37. package/lib/catalog/seed/courses/lesson.entity.js.map +1 -0
  38. package/lib/catalog/seed/courses/topic.entity.d.ts +77 -0
  39. package/lib/catalog/seed/courses/topic.entity.js +185 -0
  40. package/lib/catalog/seed/courses/topic.entity.js.map +1 -0
  41. package/lib/catalog/seed/expense/category.entity.d.ts +61 -0
  42. package/lib/catalog/seed/expense/category.entity.js +153 -0
  43. package/lib/catalog/seed/expense/category.entity.js.map +1 -0
  44. package/lib/index.d.ts +67 -0
  45. package/lib/index.js +89 -0
  46. package/lib/index.js.map +1 -0
  47. package/lib/profile/agent/agent.entity.d.ts +95 -0
  48. package/lib/profile/agent/agent.entity.js +223 -0
  49. package/lib/profile/agent/agent.entity.js.map +1 -0
  50. package/lib/profile/agent/payout.entity.d.ts +70 -0
  51. package/lib/profile/agent/payout.entity.js +160 -0
  52. package/lib/profile/agent/payout.entity.js.map +1 -0
  53. package/lib/profile/agent/promotion.entity.d.ts +82 -0
  54. package/lib/profile/agent/promotion.entity.js +174 -0
  55. package/lib/profile/agent/promotion.entity.js.map +1 -0
  56. package/lib/profile/company/company.entity.d.ts +234 -0
  57. package/lib/profile/company/company.entity.js +558 -0
  58. package/lib/profile/company/company.entity.js.map +1 -0
  59. package/lib/profile/company/course/appointment.entity.d.ts +111 -0
  60. package/lib/profile/company/course/appointment.entity.js +240 -0
  61. package/lib/profile/company/course/appointment.entity.js.map +1 -0
  62. package/lib/profile/company/course/course.entity.d.ts +156 -0
  63. package/lib/profile/company/course/course.entity.js +365 -0
  64. package/lib/profile/company/course/course.entity.js.map +1 -0
  65. package/lib/profile/company/course/lesson.entity.d.ts +123 -0
  66. package/lib/profile/company/course/lesson.entity.js +288 -0
  67. package/lib/profile/company/course/lesson.entity.js.map +1 -0
  68. package/lib/profile/company/course/topic.entity.d.ts +55 -0
  69. package/lib/profile/company/course/topic.entity.js +147 -0
  70. package/lib/profile/company/course/topic.entity.js.map +1 -0
  71. package/lib/profile/company/finances/billing/bill.entity.d.ts +145 -0
  72. package/lib/profile/company/finances/billing/bill.entity.js +338 -0
  73. package/lib/profile/company/finances/billing/bill.entity.js.map +1 -0
  74. package/lib/profile/company/finances/billing/item.entity.d.ts +75 -0
  75. package/lib/profile/company/finances/billing/item.entity.js +219 -0
  76. package/lib/profile/company/finances/billing/item.entity.js.map +1 -0
  77. package/lib/profile/company/finances/billing/transaction.entity.d.ts +44 -0
  78. package/lib/profile/company/finances/billing/transaction.entity.js +158 -0
  79. package/lib/profile/company/finances/billing/transaction.entity.js.map +1 -0
  80. package/lib/profile/company/finances/expense/category.entity.d.ts +55 -0
  81. package/lib/profile/company/finances/expense/category.entity.js +117 -0
  82. package/lib/profile/company/finances/expense/category.entity.js.map +1 -0
  83. package/lib/profile/company/finances/expense/expense.entity.d.ts +48 -0
  84. package/lib/profile/company/finances/expense/expense.entity.js +171 -0
  85. package/lib/profile/company/finances/expense/expense.entity.js.map +1 -0
  86. package/lib/profile/company/finances/handover/handover.entity.d.ts +44 -0
  87. package/lib/profile/company/finances/handover/handover.entity.js +202 -0
  88. package/lib/profile/company/finances/handover/handover.entity.js.map +1 -0
  89. package/lib/profile/company/finances/invoice/invoice.entity.d.ts +65 -0
  90. package/lib/profile/company/finances/invoice/invoice.entity.js +296 -0
  91. package/lib/profile/company/finances/invoice/invoice.entity.js.map +1 -0
  92. package/lib/profile/company/finances/invoice/item.entity.d.ts +25 -0
  93. package/lib/profile/company/finances/invoice/item.entity.js +148 -0
  94. package/lib/profile/company/finances/invoice/item.entity.js.map +1 -0
  95. package/lib/profile/company/finances/payment/method.entity.d.ts +35 -0
  96. package/lib/profile/company/finances/payment/method.entity.js +143 -0
  97. package/lib/profile/company/finances/payment/method.entity.js.map +1 -0
  98. package/lib/profile/company/finances/peyment/method.entity.d.ts +35 -0
  99. package/lib/profile/company/finances/peyment/method.entity.js +143 -0
  100. package/lib/profile/company/finances/peyment/method.entity.js.map +1 -0
  101. package/lib/profile/company/finances/peyment-method/payment-method.d.ts +34 -0
  102. package/lib/profile/company/finances/peyment-method/payment-method.js +118 -0
  103. package/lib/profile/company/finances/peyment-method/payment-method.js.map +1 -0
  104. package/lib/profile/company/instructor/instructor.entity.d.ts +85 -0
  105. package/lib/profile/company/instructor/instructor.entity.js +254 -0
  106. package/lib/profile/company/instructor/instructor.entity.js.map +1 -0
  107. package/lib/profile/company/instructor/task.entity.d.ts +60 -0
  108. package/lib/profile/company/instructor/task.entity.js +133 -0
  109. package/lib/profile/company/instructor/task.entity.js.map +1 -0
  110. package/lib/profile/company/medical/examination.entity.d.ts +59 -0
  111. package/lib/profile/company/medical/examination.entity.js +175 -0
  112. package/lib/profile/company/medical/examination.entity.js.map +1 -0
  113. package/lib/profile/company/medical/product.entity.d.ts +99 -0
  114. package/lib/profile/company/medical/product.entity.js +270 -0
  115. package/lib/profile/company/medical/product.entity.js.map +1 -0
  116. package/lib/profile/company/metrics/company.metric.d.ts +21 -0
  117. package/lib/profile/company/metrics/company.metric.js +122 -0
  118. package/lib/profile/company/metrics/company.metric.js.map +1 -0
  119. package/lib/profile/company/product/addon.entity.d.ts +93 -0
  120. package/lib/profile/company/product/addon.entity.js +234 -0
  121. package/lib/profile/company/product/addon.entity.js.map +1 -0
  122. package/lib/profile/company/product/priceplan.entity.d.ts +57 -0
  123. package/lib/profile/company/product/priceplan.entity.js +167 -0
  124. package/lib/profile/company/product/priceplan.entity.js.map +1 -0
  125. package/lib/profile/company/product/product.entity.d.ts +171 -0
  126. package/lib/profile/company/product/product.entity.js +383 -0
  127. package/lib/profile/company/product/product.entity.js.map +1 -0
  128. package/lib/profile/company/product/vehicle.entity.d.ts +46 -0
  129. package/lib/profile/company/product/vehicle.entity.js +144 -0
  130. package/lib/profile/company/product/vehicle.entity.js.map +1 -0
  131. package/lib/profile/instructor/instructor.entity.d.ts +80 -0
  132. package/lib/profile/instructor/instructor.entity.js +186 -0
  133. package/lib/profile/instructor/instructor.entity.js.map +1 -0
  134. package/lib/profile/student/program/licence/licence.entity.d.ts +66 -0
  135. package/lib/profile/student/program/licence/licence.entity.js +187 -0
  136. package/lib/profile/student/program/licence/licence.entity.js.map +1 -0
  137. package/lib/profile/student/program/medical/certificate.entity.d.ts +84 -0
  138. package/lib/profile/student/program/medical/certificate.entity.js +244 -0
  139. package/lib/profile/student/program/medical/certificate.entity.js.map +1 -0
  140. package/lib/profile/student/program/medical/examination.model.d.ts +65 -0
  141. package/lib/profile/student/program/medical/examination.model.js +209 -0
  142. package/lib/profile/student/program/medical/examination.model.js.map +1 -0
  143. package/lib/profile/student/program/program.entity.d.ts +78 -0
  144. package/lib/profile/student/program/program.entity.js +225 -0
  145. package/lib/profile/student/program/program.entity.js.map +1 -0
  146. package/lib/profile/student/program/training/appointment.entity.d.ts +151 -0
  147. package/lib/profile/student/program/training/appointment.entity.js +441 -0
  148. package/lib/profile/student/program/training/appointment.entity.js.map +1 -0
  149. package/lib/profile/student/program/training/exam.entity.d.ts +41 -0
  150. package/lib/profile/student/program/training/exam.entity.js +141 -0
  151. package/lib/profile/student/program/training/exam.entity.js.map +1 -0
  152. package/lib/profile/student/program/training/lesson.entity.d.ts +84 -0
  153. package/lib/profile/student/program/training/lesson.entity.js +221 -0
  154. package/lib/profile/student/program/training/lesson.entity.js.map +1 -0
  155. package/lib/profile/student/program/training/request.entity.d.ts +56 -0
  156. package/lib/profile/student/program/training/request.entity.js +159 -0
  157. package/lib/profile/student/program/training/request.entity.js.map +1 -0
  158. package/lib/profile/student/program/training/topic.entity.d.ts +109 -0
  159. package/lib/profile/student/program/training/topic.entity.js +255 -0
  160. package/lib/profile/student/program/training/topic.entity.js.map +1 -0
  161. package/lib/profile/student/program/training/training.entity.d.ts +167 -0
  162. package/lib/profile/student/program/training/training.entity.js +501 -0
  163. package/lib/profile/student/program/training/training.entity.js.map +1 -0
  164. package/lib/profile/student/program/training/transaction.entity.d.ts +111 -0
  165. package/lib/profile/student/program/training/transaction.entity.js +266 -0
  166. package/lib/profile/student/program/training/transaction.entity.js.map +1 -0
  167. package/lib/profile/student/student.entity.d.ts +89 -0
  168. package/lib/profile/student/student.entity.js +183 -0
  169. package/lib/profile/student/student.entity.js.map +1 -0
  170. package/lib/system/campaign/campaign.entity.d.ts +68 -0
  171. package/lib/system/campaign/campaign.entity.js +150 -0
  172. package/lib/system/campaign/campaign.entity.js.map +1 -0
  173. package/lib/system/campaign/gifcode.entity.d.ts +14 -0
  174. package/lib/system/campaign/gifcode.entity.js +77 -0
  175. package/lib/system/campaign/gifcode.entity.js.map +1 -0
  176. package/lib/system/campaigne/campaign.entity.d.ts +69 -0
  177. package/lib/system/campaigne/campaign.entity.js +179 -0
  178. package/lib/system/campaigne/campaign.entity.js.map +1 -0
  179. package/lib/system/campaigne/gifcode.entity.d.ts +54 -0
  180. package/lib/system/campaigne/gifcode.entity.js +126 -0
  181. package/lib/system/campaigne/gifcode.entity.js.map +1 -0
  182. package/lib/system/country/country.entity.d.ts +121 -0
  183. package/lib/system/country/country.entity.js +284 -0
  184. package/lib/system/country/country.entity.js.map +1 -0
  185. package/lib/system/country/country.metric.d.ts +12 -0
  186. package/lib/system/country/country.metric.js +68 -0
  187. package/lib/system/country/country.metric.js.map +1 -0
  188. package/lib/system/currency/currency.entity.d.ts +46 -0
  189. package/lib/system/currency/currency.entity.js +112 -0
  190. package/lib/system/currency/currency.entity.js.map +1 -0
  191. package/lib/system/driving/category.entity.d.ts +146 -0
  192. package/lib/system/driving/category.entity.js +321 -0
  193. package/lib/system/driving/category.entity.js.map +1 -0
  194. package/lib/system/driving/vehicle.entity.d.ts +54 -0
  195. package/lib/system/driving/vehicle.entity.js +130 -0
  196. package/lib/system/driving/vehicle.entity.js.map +1 -0
  197. package/lib/system/event/business.entity.d.ts +75 -0
  198. package/lib/system/event/business.entity.js +170 -0
  199. package/lib/system/event/business.entity.js.map +1 -0
  200. package/lib/system/event/log.entity.d.ts +103 -0
  201. package/lib/system/event/log.entity.js +202 -0
  202. package/lib/system/event/log.entity.js.map +1 -0
  203. package/lib/system/policy/policy.entity.d.ts +90 -0
  204. package/lib/system/policy/policy.entity.js +226 -0
  205. package/lib/system/policy/policy.entity.js.map +1 -0
  206. package/lib/system/staff/staff.entity.d.ts +72 -0
  207. package/lib/system/staff/staff.entity.js +186 -0
  208. package/lib/system/staff/staff.entity.js.map +1 -0
  209. package/lib/tsconfig.tsbuildinfo +1 -0
  210. package/lib/user/alert.entity.d.ts +95 -0
  211. package/lib/user/alert.entity.js +223 -0
  212. package/lib/user/alert.entity.js.map +1 -0
  213. package/lib/user/blocked.entity.d.ts +42 -0
  214. package/lib/user/blocked.entity.js +83 -0
  215. package/lib/user/blocked.entity.js.map +1 -0
  216. package/lib/user/device.entity.d.ts +72 -0
  217. package/lib/user/device.entity.js +182 -0
  218. package/lib/user/device.entity.js.map +1 -0
  219. package/lib/user/notification.entity.d.ts +87 -0
  220. package/lib/user/notification.entity.js +219 -0
  221. package/lib/user/notification.entity.js.map +1 -0
  222. package/lib/user/ticket.entity.d.ts +85 -0
  223. package/lib/user/ticket.entity.js +231 -0
  224. package/lib/user/ticket.entity.js.map +1 -0
  225. package/lib/user/user.entity.d.ts +235 -0
  226. package/lib/user/user.entity.js +573 -0
  227. package/lib/user/user.entity.js.map +1 -0
  228. package/lib/user/verification.entity.d.ts +75 -0
  229. package/lib/user/verification.entity.js +142 -0
  230. package/lib/user/verification.entity.js.map +1 -0
  231. package/lib/utils/activity.helper.d.ts +26 -0
  232. package/lib/utils/activity.helper.js +39 -0
  233. package/lib/utils/activity.helper.js.map +1 -0
  234. package/lib/utils/index.d.ts +4 -0
  235. package/lib/utils/index.js +21 -0
  236. package/lib/utils/index.js.map +1 -0
  237. package/lib/utils/json-metrics.transform.d.ts +35 -0
  238. package/lib/utils/json-metrics.transform.js +83 -0
  239. package/lib/utils/json-metrics.transform.js.map +1 -0
  240. package/lib/utils/numeric.transform.d.ts +38 -0
  241. package/lib/utils/numeric.transform.js +74 -0
  242. package/lib/utils/numeric.transform.js.map +1 -0
  243. package/lib/utils/trackable.entity.d.ts +82 -0
  244. package/lib/utils/trackable.entity.js +100 -0
  245. package/lib/utils/trackable.entity.js.map +1 -0
  246. package/package.json +49 -0
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.StudentTrainingTopicEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const typeorm_2 = require("typeorm");
15
+ const common_1 = require("@driveup/common");
16
+ const topic_entity_1 = require("../../../company/course/topic.entity");
17
+ const lesson_entity_1 = require("./lesson.entity");
18
+ const appointment_entity_1 = require("./appointment.entity");
19
+ const utils_1 = require("../../../../utils");
20
+ /**
21
+ * Student training topic entity representing topics within a training lesson.
22
+ * Topics are copied from company course topics and tracked individually per student.
23
+ * This allows tracking progress and maintaining data integrity even if company topics change.
24
+ * Extends TrackableEntity to track creation and update information.
25
+ */
26
+ let StudentTrainingTopicEntity = class StudentTrainingTopicEntity extends utils_1.TrackableEntity {
27
+ /**
28
+ * Student training lesson
29
+ */
30
+ lessonId;
31
+ /**
32
+ * Company lesson topic
33
+ * Keep reference to company topic
34
+ * in case by in progress training the topic is updated or deleted
35
+ */
36
+ topicId;
37
+ /**
38
+ * Topic title
39
+ * Keep copy of title in case company topic is updated or deleted
40
+ */
41
+ title;
42
+ /**
43
+ * Topic description
44
+ * Keep copy of description in case company topic is updated or deleted
45
+ */
46
+ description;
47
+ /**
48
+ * Topic image URL
49
+ * Keep copy of image URL in case company topic is updated or deleted
50
+ */
51
+ imageUrl;
52
+ /**
53
+ * Allow sorting of topics for each student seperately
54
+ */
55
+ sort;
56
+ /**
57
+ * Indicate if the topic has been completed by the student
58
+ */
59
+ done;
60
+ /**
61
+ * Skills associated with this topic and their assessment scores
62
+ */
63
+ skills;
64
+ /**
65
+ * ID of the user who marked this topic as completed
66
+ */
67
+ completedBy;
68
+ /**
69
+ * Timestamp when this topic was marked as completed
70
+ */
71
+ completedOn;
72
+ /**
73
+ * Student training lesson relation
74
+ */
75
+ lesson;
76
+ /**
77
+ * Company course lesson topic
78
+ * Keep relation to be able to fetch updates if needed
79
+ */
80
+ topic;
81
+ /**
82
+ * Creates a new StudentTrainingTopicEntity instance
83
+ * @param props - Partial properties to initialize the entity with
84
+ */
85
+ constructor(props) {
86
+ super();
87
+ Object.assign(this, props);
88
+ }
89
+ /**
90
+ * Converts the entity to a Topic model instance
91
+ * @returns Topic model with topic details and associated skills
92
+ */
93
+ toModel() {
94
+ return new common_1.Topic({
95
+ id: this.id,
96
+ title: this.title,
97
+ description: this.description,
98
+ imageUrl: this.imageUrl,
99
+ sort: this.sort,
100
+ done: this.done,
101
+ skills: this.skills?.map(common_1.Skill.toInstance) || []
102
+ });
103
+ }
104
+ /**
105
+ * Returns a summary representation of the topic
106
+ * @returns Topic model instance (same as toModel())
107
+ */
108
+ toSummary() {
109
+ return this.toModel();
110
+ }
111
+ /**
112
+ * Calculates the average score for this topic across all appointments
113
+ * @returns The average score or 0 if no scores are available
114
+ */
115
+ async getScore() {
116
+ const lesson = await this.lesson;
117
+ const training = await lesson.training;
118
+ const appointments = await training.appointments;
119
+ if (!appointments)
120
+ return 0;
121
+ const topics = appointments
122
+ .map(a => a.topics?.find(t => t && t.topicId === this.id))
123
+ .filter(t => t && t.score !== null && t.score !== undefined);
124
+ if (!topics?.length)
125
+ return 0;
126
+ let scores = 0;
127
+ for (const topic of topics) {
128
+ const score = typeof topic.score === 'string' ? parseFloat(topic.score) : topic.score;
129
+ scores += Number.isFinite(score) ? score : 0;
130
+ }
131
+ return scores / topics.length;
132
+ }
133
+ /**
134
+ * Checks if this topic has been included in any training appointments
135
+ * @returns True if the topic has been used in at least one appointment, false otherwise
136
+ */
137
+ async isTouched() {
138
+ const count = await appointment_entity_1.StudentTrainingAppointmentEntity
139
+ .createQueryBuilder('sda')
140
+ .where('JSON_CONTAINS(sda.topics, JSON_OBJECT("id", :topicId))', { topicId: this.id })
141
+ .getCount();
142
+ return count > 0;
143
+ }
144
+ /**
145
+ * Checks if this topic has been assessed in a specific training appointment
146
+ * @param session - The training appointment to check for assessment
147
+ * @returns True if the topic has been assessed in the given session, false otherwise
148
+ */
149
+ async hasAssessment(session) {
150
+ const count = await appointment_entity_1.StudentTrainingAppointmentEntity
151
+ .createQueryBuilder('sda')
152
+ .where('sda.id = :id', { id: session.id })
153
+ .andWhere('JSON_CONTAINS(sda.topics, JSON_OBJECT("id", :topicId))', { topicId: this.id })
154
+ .andWhere('EXISTS (SELECT 1 FROM JSON_TABLE(sda.skills, "$[*]" COLUMNS(score INT PATH "$.score")) AS skill WHERE skill.score != :noScore)', { noScore: common_1.Score.NoScoreSubmitted })
155
+ .getCount();
156
+ return count > 0;
157
+ }
158
+ /**
159
+ * Counts how many times this topic has been assessed across all appointments
160
+ * @returns The number of appointments where this topic received an assessment
161
+ */
162
+ async getRepetition() {
163
+ const count = await appointment_entity_1.StudentTrainingAppointmentEntity
164
+ .createQueryBuilder('sda')
165
+ .where('JSON_CONTAINS(sda.topics, JSON_OBJECT("id", :topicId))', { topicId: this.id })
166
+ .andWhere('EXISTS (SELECT 1 FROM JSON_TABLE(sda.skills, "$[*]" COLUMNS(score INT PATH "$.score")) AS skill WHERE skill.score != :noScore)', { noScore: common_1.Score.NoScoreSubmitted })
167
+ .getCount();
168
+ return count;
169
+ }
170
+ /**
171
+ * Retrieves all tracked activities for this topic
172
+ * Includes creation, update, and completion timestamps and associated users
173
+ * @returns Array of Activity objects filtered to exclude null values
174
+ */
175
+ async getActivities() {
176
+ const activities = [];
177
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
178
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
179
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
180
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
181
+ activities.push(await (0, utils_1.toActivity)(this.completedBy, common_1.ActivityType.completedBy));
182
+ activities.push(await (0, utils_1.toActivity)(this.completedOn, common_1.ActivityType.completedOn));
183
+ return activities.filter(a => a);
184
+ }
185
+ };
186
+ exports.StudentTrainingTopicEntity = StudentTrainingTopicEntity;
187
+ __decorate([
188
+ (0, typeorm_1.Column)(),
189
+ __metadata("design:type", Number)
190
+ ], StudentTrainingTopicEntity.prototype, "lessonId", void 0);
191
+ __decorate([
192
+ (0, typeorm_1.Column)(),
193
+ __metadata("design:type", Number)
194
+ ], StudentTrainingTopicEntity.prototype, "topicId", void 0);
195
+ __decorate([
196
+ (0, typeorm_1.Column)(),
197
+ __metadata("design:type", String)
198
+ ], StudentTrainingTopicEntity.prototype, "title", void 0);
199
+ __decorate([
200
+ (0, typeorm_1.Column)({
201
+ nullable: true,
202
+ default: null
203
+ }),
204
+ __metadata("design:type", String)
205
+ ], StudentTrainingTopicEntity.prototype, "description", void 0);
206
+ __decorate([
207
+ (0, typeorm_1.Column)({
208
+ nullable: true,
209
+ default: null
210
+ }),
211
+ __metadata("design:type", String)
212
+ ], StudentTrainingTopicEntity.prototype, "imageUrl", void 0);
213
+ __decorate([
214
+ (0, typeorm_1.Column)({
215
+ type: 'tinyint',
216
+ nullable: false
217
+ }),
218
+ __metadata("design:type", Number)
219
+ ], StudentTrainingTopicEntity.prototype, "sort", void 0);
220
+ __decorate([
221
+ (0, typeorm_1.Column)({
222
+ nullable: false,
223
+ default: false
224
+ }),
225
+ __metadata("design:type", Boolean)
226
+ ], StudentTrainingTopicEntity.prototype, "done", void 0);
227
+ __decorate([
228
+ (0, typeorm_1.Column)({
229
+ type: 'json',
230
+ nullable: true,
231
+ default: null
232
+ }),
233
+ __metadata("design:type", Array)
234
+ ], StudentTrainingTopicEntity.prototype, "skills", void 0);
235
+ __decorate([
236
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
237
+ __metadata("design:type", Number)
238
+ ], StudentTrainingTopicEntity.prototype, "completedBy", void 0);
239
+ __decorate([
240
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
241
+ __metadata("design:type", Date)
242
+ ], StudentTrainingTopicEntity.prototype, "completedOn", void 0);
243
+ __decorate([
244
+ (0, typeorm_2.ManyToOne)(() => lesson_entity_1.StudentTrainingLessonEntity, lesson => lesson.topics),
245
+ __metadata("design:type", Promise)
246
+ ], StudentTrainingTopicEntity.prototype, "lesson", void 0);
247
+ __decorate([
248
+ (0, typeorm_2.ManyToOne)(() => topic_entity_1.CompanyCourseTopicEntity, topic => topic.studentTopics),
249
+ __metadata("design:type", Promise)
250
+ ], StudentTrainingTopicEntity.prototype, "topic", void 0);
251
+ exports.StudentTrainingTopicEntity = StudentTrainingTopicEntity = __decorate([
252
+ (0, typeorm_1.Entity)('studentTrainingTopics'),
253
+ __metadata("design:paramtypes", [Object])
254
+ ], StudentTrainingTopicEntity);
255
+ //# sourceMappingURL=topic.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topic.entity.js","sourceRoot":"","sources":["../../../../../src/profile/student/program/training/topic.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA8C;AAC9C,qCAAoC;AACpC,4CAA8E;AAC9E,uEAAgF;AA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7B,IAAI;+DAAC;AAMlB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,2CAA2B,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;;0DACzB;AAO7C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uCAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC;;yDAC/B;qCA9F7B,0BAA0B;IADtC,IAAA,gBAAM,EAAC,uBAAuB,CAAC;;GACnB,0BAA0B,CA6NtC"}
@@ -0,0 +1,167 @@
1
+ import { Training, Rating, AddonUsage, Student, Person } from '@driveup/common';
2
+ import { Address, CarTransmission, Activity } from '@driveup/common';
3
+ import { StatusType } from '@driveup/common';
4
+ import { CompanyInvoiceEntity } from '../../../company/finances/invoice/invoice.entity';
5
+ import { StudentTrainingTransactionEntity } from './transaction.entity';
6
+ import { CompanyInstructorEntity } from '../../../company/instructor/instructor.entity';
7
+ import { CompanyCourseEntity } from '../../../company/course/course.entity';
8
+ import { StudentProgramEntity } from '../program.entity';
9
+ import { StudentTrainingLessonEntity } from './lesson.entity';
10
+ import { StudentTrainingAppointmentEntity } from './appointment.entity';
11
+ import { TrackableEntity } from '../../../../utils';
12
+ export declare class StudentTrainingEntity extends TrackableEntity<Training> {
13
+ /**
14
+ * Student program
15
+ */
16
+ programId: number;
17
+ /**
18
+ * Company course
19
+ */
20
+ courseId: number;
21
+ /**
22
+ * In-charge instructor
23
+ */
24
+ instructorId: number;
25
+ /**
26
+ * Training status
27
+ */
28
+ status: StatusType;
29
+ /**
30
+ * Title of the training session
31
+ */
32
+ title: string;
33
+ /**
34
+ * Detailed description of the training content and objectives
35
+ */
36
+ description: string;
37
+ /**
38
+ * Company training price
39
+ * Snapshot of the price at the time of training creation
40
+ * For driving training this price represents the driving session price
41
+ */
42
+ price: number;
43
+ /**
44
+ * Training session duration in minutes
45
+ * For driving training this represents the driving session duration
46
+ * For course training this represents the course lesson duration
47
+ */
48
+ sessionDuration: number;
49
+ /**
50
+ * Administration fee for this training
51
+ */
52
+ administrationFee: number;
53
+ /**
54
+ * Total Training cost
55
+ * All training related costs
56
+ */
57
+ cost: number;
58
+ /**
59
+ * Current training balance
60
+ */
61
+ balance: number;
62
+ /**
63
+ * The sum of the payments made by student for this training
64
+ */
65
+ paid: number;
66
+ /**
67
+ * The sum of the discounts applied to this training
68
+ */
69
+ discount: number;
70
+ /**
71
+ * The sum of the refunds applied to this training
72
+ */
73
+ refund: number;
74
+ /**
75
+ * Company training location
76
+ * This is a snapshot of the location at the time of training creation
77
+ * For driving tranings this represents the pickup location
78
+ */
79
+ location: Address;
80
+ /**
81
+ * The last viewed lesson by student
82
+ * Resume where they left off
83
+ */
84
+ resentLessonId: number;
85
+ /**
86
+ * The last viewed topic by student
87
+ * Resume where they left off
88
+ */
89
+ recentTopicId: number;
90
+ /**
91
+ * Transmission type for driving training
92
+ */
93
+ transmission: CarTransmission;
94
+ /**
95
+ * A student profile snapshot details at the time of training creation
96
+ * This data can be managed only by driving school
97
+ */
98
+ studentSnapshoot: Person;
99
+ /**
100
+ * Ratings and reviews given by the student for this training
101
+ */
102
+ ratings: Rating[];
103
+ /**
104
+ * List of addons used in the training
105
+ */
106
+ addons: AddonUsage[];
107
+ /**
108
+ * ID of the user who marked this training as completed
109
+ */
110
+ completedBy: number;
111
+ /**
112
+ * Timestamp when this training was marked as completed
113
+ */
114
+ completedOn: Date;
115
+ /**
116
+ * ID of the user who terminated this training
117
+ */
118
+ terminatedBy: number;
119
+ /**
120
+ * Timestamp when this training was terminated
121
+ */
122
+ terminatedOn: Date;
123
+ /**
124
+ * Student who is taking the training
125
+ */
126
+ program: Promise<StudentProgramEntity>;
127
+ /**
128
+ * Company course
129
+ * Example: Defensive driving course, First aid course, etc.
130
+ */
131
+ course: Promise<CompanyCourseEntity>;
132
+ /**
133
+ * Training in-charge instructor
134
+ */
135
+ instructor: Promise<CompanyInstructorEntity>;
136
+ /**
137
+ * Student training lessons
138
+ */
139
+ lessons: Promise<StudentTrainingLessonEntity[]>;
140
+ /**
141
+ * Student training appointments
142
+ */
143
+ appointments: Promise<StudentTrainingAppointmentEntity[]>;
144
+ /**
145
+ * Student training payments
146
+ */
147
+ transactions: Promise<StudentTrainingTransactionEntity[]>;
148
+ /**
149
+ * Invoices for this training
150
+ */
151
+ invoices: Promise<CompanyInvoiceEntity[]>;
152
+ constructor(props?: Partial<StudentTrainingEntity>);
153
+ toModel(): Promise<Training>;
154
+ toSummary(): Promise<Training>;
155
+ toModelWithDetails(): Promise<Training>;
156
+ getStudent(): Promise<import("../../student.entity").StudentEntity>;
157
+ getStudentSnapshot(): Student;
158
+ getProgram(): Promise<StudentProgramEntity>;
159
+ getCourse(): Promise<CompanyCourseEntity>;
160
+ getCompany(): Promise<import("../../../..").CompanyEntity>;
161
+ getPaymentTransactions(): Promise<number>;
162
+ getCashTransactions(): Promise<number>;
163
+ getDiscountTransactions(): Promise<number>;
164
+ getRefundTransactions(): Promise<number>;
165
+ getCanceledTransactions(): Promise<number>;
166
+ getActivities(): Promise<Activity[]>;
167
+ }