@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,441 @@
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
+ var StudentTrainingAppointmentEntity_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.StudentTrainingAppointmentEntity = void 0;
14
+ const typeorm_1 = require("typeorm");
15
+ const common_1 = require("@driveup/common");
16
+ const common_2 = require("@driveup/common");
17
+ const training_entity_1 = require("./training.entity");
18
+ const lesson_entity_1 = require("./lesson.entity");
19
+ const appointment_entity_1 = require("../../../company/course/appointment.entity");
20
+ const instructor_entity_1 = require("../../../company/instructor/instructor.entity");
21
+ const exam_entity_1 = require("./exam.entity");
22
+ const course_entity_1 = require("../../../company/course/course.entity");
23
+ const utils_1 = require("../../../../utils");
24
+ let StudentTrainingAppointmentEntity = StudentTrainingAppointmentEntity_1 = class StudentTrainingAppointmentEntity extends utils_1.TrackableEntity {
25
+ /**
26
+ * Reference to the training this appointment belongs to
27
+ */
28
+ trainingId;
29
+ /**
30
+ * Student training lesson relation
31
+ * Keep reference to lesson in case by in progress training the lesson is updated or deleted
32
+ * This reference is mandatory only by course training appointments
33
+ */
34
+ lessonId;
35
+ /**
36
+ * Only for company course trainings with flexible appointments
37
+ */
38
+ definitionId;
39
+ /**
40
+ * Only for student driving trainings
41
+ * Each session appointment can have a different instructor
42
+ */
43
+ instructorId;
44
+ /**
45
+ * Ensure consistency with Product.appointmentType
46
+ * Shortcut to avoid joins when fetching student appointments
47
+ */
48
+ type;
49
+ /**
50
+ * Current status of the appointment (Planned, Completed, or Canceled)
51
+ * @default StatusType.Planned
52
+ */
53
+ status;
54
+ /**
55
+ * Appointment date
56
+ */
57
+ startDate;
58
+ /**
59
+ * Appointment end date
60
+ * @description In Flexible courses, this field is set to null, and will be calculated each time based on the appointment duration
61
+ * @description In Fixed courses, this field must have a value, which is equal to the part.endDate
62
+ */
63
+ endDate;
64
+ /**
65
+ * Indicate if the student attended the appointment
66
+ */
67
+ attended;
68
+ /**
69
+ * Appointment price for the student
70
+ * Currently implemented oonly by driving trainings
71
+ */
72
+ price;
73
+ /**
74
+ * Appointment session duration in minutes
75
+ * Currently implemented oonly by driving trainings
76
+ */
77
+ duration;
78
+ /**
79
+ * Appointment location
80
+ * Currently implemented oonly by driving trainings
81
+ */
82
+ location;
83
+ /**
84
+ * Indicate if the appointment is an exam
85
+ * Currently implemented oonly by driving trainings
86
+ */
87
+ isExam;
88
+ /**
89
+ * Whether the student is charged for this appointment or not
90
+ * (used if the appointment is canceled)
91
+ */
92
+ charged;
93
+ /**
94
+ * Student signature image URL for the appointment
95
+ */
96
+ signatureUrl;
97
+ /**
98
+ * Lesson topics invloved in the appointment with scores
99
+ * Currently implemented oonly by driving trainings
100
+ */
101
+ topics;
102
+ /**
103
+ * Lesson skills involved in the appointment with scores
104
+ * Currently implemented oonly by driving trainings
105
+ */
106
+ skills;
107
+ /**
108
+ * Notes related to the appointment
109
+ */
110
+ note;
111
+ /**
112
+ * Timestamp when the student was reminded about this appointment
113
+ */
114
+ remindedOn;
115
+ /**
116
+ * Timestamp when the appointment was last rescheduled
117
+ */
118
+ rescheduledOn;
119
+ /**
120
+ * ID of the user who rescheduled the appointment
121
+ */
122
+ rescheduledBy;
123
+ /**
124
+ * Timestamp when the appointment was canceled
125
+ */
126
+ canceledOn;
127
+ /**
128
+ * ID of the user who canceled the appointment
129
+ */
130
+ canceledBy;
131
+ /**
132
+ * Student training this appointment belongs to
133
+ */
134
+ training;
135
+ /**
136
+ * Student training lesson relation
137
+ * Each student training lesson (only for course trainings) will be linked to its appointments
138
+ * For driving trainings this relation will be allways empty
139
+ */
140
+ lesson;
141
+ /**
142
+ * Company training appointment definition relation
143
+ * Each company training appointment definition (only for course trainings with flexible appointments) will be linked to its student appointments
144
+ * For driving trainings and fixed course trainings this relation will be allways empty
145
+ */
146
+ definition;
147
+ /**
148
+ * Company instructor relation
149
+ */
150
+ instructor;
151
+ /**
152
+ * Student training exam relation
153
+ */
154
+ exam;
155
+ constructor(props) {
156
+ super();
157
+ Object.assign(this, props);
158
+ }
159
+ async toModel() {
160
+ const training = await this.training;
161
+ return new common_1.Appointment({
162
+ id: this.id,
163
+ type: this.type,
164
+ status: this.status,
165
+ title: training.title,
166
+ description: training.description,
167
+ startDate: this.startDate,
168
+ endDate: this.endDate,
169
+ duration: this.duration,
170
+ location: this.location ? common_2.Address.toInstance(this.location) : null,
171
+ instructor: this.instructorId ? await (await this.instructor).toModel() : null,
172
+ isExam: this.isExam,
173
+ charged: this.charged,
174
+ });
175
+ }
176
+ toSummary() {
177
+ return new common_1.Appointment({
178
+ id: this.id,
179
+ type: this.type,
180
+ status: this.status,
181
+ startDate: this.startDate,
182
+ endDate: this.endDate,
183
+ duration: this.duration,
184
+ isExam: this.isExam,
185
+ charged: this.charged,
186
+ });
187
+ }
188
+ /**
189
+ * Student traning session
190
+ * Extended version of appointment with training session details
191
+ * @returns TrainingSession
192
+ */
193
+ async toSession() {
194
+ const session = new common_2.TrainingSession({ id: this.id });
195
+ session.appointment = await this.toModel();
196
+ session.price = this.price;
197
+ session.signatureUrl = this.signatureUrl;
198
+ const training = await this.training;
199
+ session.training = await training.toModel();
200
+ const companyCourse = await course_entity_1.CompanyCourseEntity.createQueryBuilder('cc')
201
+ .innerJoin(training_entity_1.StudentTrainingEntity, 'st', 'st.courseId = cc.id')
202
+ .where('st.id = :trainingId', { trainingId: this.trainingId })
203
+ .getOne();
204
+ session.course = await companyCourse.toModel();
205
+ // session lesson
206
+ const lesson = this.lessonId ? await this.lesson : null;
207
+ session.lesson = lesson ? await lesson.toModel() : null;
208
+ // session topics
209
+ const topics = lesson ? await lesson.topics : null;
210
+ session.topics = topics?.length ? await Promise.all(topics.map(t => t.toModel())) : null;
211
+ // get current session topic progress and scores
212
+ const topicProgress = this.topics?.map(common_1.TopicProgress.toInstance) || null;
213
+ const skillSores = this.skills?.map(common_1.SkillScore.toInstance) || null;
214
+ // assigne current session progress
215
+ session.topics = session.topics?.map(topic => {
216
+ const progress = topicProgress?.find(ts => ts.topicId === topic.id);
217
+ topic.score = progress?.score || topic.score;
218
+ topic.repetitions = progress?.repetitions || topic.repetitions;
219
+ topic.done = progress?.done || topic.done;
220
+ topic.skills = topic.skills?.map(skill => {
221
+ const score = skillSores?.find(ss => ss.skillId === skill.id);
222
+ skill.score = score?.score || skill.score;
223
+ return skill;
224
+ }) || [];
225
+ return topic;
226
+ });
227
+ // current session note
228
+ session.note = this.note ? common_1.Note.toInstance(this.note) : null;
229
+ // past session notes
230
+ const pastAppointmentNotes = await StudentTrainingAppointmentEntity_1.createQueryBuilder('sta')
231
+ .where('sta.trainingId = :trainingId', { trainingId: this.trainingId })
232
+ .andWhere('sta.id != :appointmentId', { appointmentId: this.id })
233
+ .andWhere('sta.note IS NOT NULL')
234
+ .getMany();
235
+ session.notes = pastAppointmentNotes?.map(a => a.note).map(common_1.Note.toInstance);
236
+ if (this.isExam) {
237
+ // exam information
238
+ const exam = await this.exam;
239
+ session.exam = exam ? await exam.toModel() : null;
240
+ }
241
+ // count past appointments (not canceled)
242
+ const pastAppointmentsCount = await StudentTrainingAppointmentEntity_1
243
+ .createQueryBuilder('sta')
244
+ .where('sta.trainingId = :trainingId', { trainingId: this.trainingId })
245
+ .andWhere('sta.startDate < :startDate', { startDate: this.startDate })
246
+ .andWhere('sta.status != :canceledStatus', { canceledStatus: common_1.StatusType.Canceled })
247
+ .getCount();
248
+ // index number: Session 1, Session 2, etc..
249
+ session.number = pastAppointmentsCount + 1;
250
+ return session;
251
+ }
252
+ async isFixed() {
253
+ const training = await this.training;
254
+ const companyTraining = await training.getCourse();
255
+ return companyTraining.isFixed;
256
+ }
257
+ async getActivities() {
258
+ const activities = [];
259
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_2.ActivityType.createdBy));
260
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_2.ActivityType.createdOn));
261
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_2.ActivityType.updatedBy));
262
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_2.ActivityType.updatedOn));
263
+ return activities.filter(a => a);
264
+ }
265
+ };
266
+ exports.StudentTrainingAppointmentEntity = StudentTrainingAppointmentEntity;
267
+ __decorate([
268
+ (0, typeorm_1.Column)(),
269
+ __metadata("design:type", Number)
270
+ ], StudentTrainingAppointmentEntity.prototype, "trainingId", void 0);
271
+ __decorate([
272
+ (0, typeorm_1.Column)({
273
+ nullable: true,
274
+ default: null
275
+ }),
276
+ __metadata("design:type", Number)
277
+ ], StudentTrainingAppointmentEntity.prototype, "lessonId", void 0);
278
+ __decorate([
279
+ (0, typeorm_1.Column)({
280
+ nullable: true,
281
+ default: null
282
+ }),
283
+ __metadata("design:type", Number)
284
+ ], StudentTrainingAppointmentEntity.prototype, "definitionId", void 0);
285
+ __decorate([
286
+ (0, typeorm_1.Column)({
287
+ nullable: true,
288
+ default: null
289
+ }),
290
+ __metadata("design:type", Number)
291
+ ], StudentTrainingAppointmentEntity.prototype, "instructorId", void 0);
292
+ __decorate([
293
+ (0, typeorm_1.Column)({
294
+ type: 'enum',
295
+ name: 'appointmentType',
296
+ nullable: false,
297
+ enum: common_1.AppointmentType,
298
+ default: common_1.AppointmentType.Driving
299
+ }),
300
+ __metadata("design:type", String)
301
+ ], StudentTrainingAppointmentEntity.prototype, "type", void 0);
302
+ __decorate([
303
+ (0, typeorm_1.Column)({
304
+ type: 'enum',
305
+ nullable: false,
306
+ enum: [
307
+ common_1.StatusType.Planned,
308
+ common_1.StatusType.Completed,
309
+ common_1.StatusType.Canceled
310
+ ],
311
+ default: common_1.StatusType.Planned
312
+ }),
313
+ __metadata("design:type", String)
314
+ ], StudentTrainingAppointmentEntity.prototype, "status", void 0);
315
+ __decorate([
316
+ (0, typeorm_1.Column)(),
317
+ __metadata("design:type", Date)
318
+ ], StudentTrainingAppointmentEntity.prototype, "startDate", void 0);
319
+ __decorate([
320
+ (0, typeorm_1.Column)({
321
+ nullable: true,
322
+ default: null
323
+ }),
324
+ __metadata("design:type", Date)
325
+ ], StudentTrainingAppointmentEntity.prototype, "endDate", void 0);
326
+ __decorate([
327
+ (0, typeorm_1.Column)({ default: false }),
328
+ __metadata("design:type", Boolean)
329
+ ], StudentTrainingAppointmentEntity.prototype, "attended", void 0);
330
+ __decorate([
331
+ (0, typeorm_1.Column)({
332
+ type: 'decimal',
333
+ precision: 8,
334
+ scale: 2,
335
+ nullable: false,
336
+ default: 0
337
+ }),
338
+ __metadata("design:type", Number)
339
+ ], StudentTrainingAppointmentEntity.prototype, "price", void 0);
340
+ __decorate([
341
+ (0, typeorm_1.Column)({
342
+ nullable: false,
343
+ default: 60
344
+ }),
345
+ __metadata("design:type", Number)
346
+ ], StudentTrainingAppointmentEntity.prototype, "duration", void 0);
347
+ __decorate([
348
+ (0, typeorm_1.Column)({
349
+ type: 'simple-json',
350
+ nullable: true,
351
+ default: null
352
+ }),
353
+ __metadata("design:type", common_2.Address)
354
+ ], StudentTrainingAppointmentEntity.prototype, "location", void 0);
355
+ __decorate([
356
+ (0, typeorm_1.Column)({
357
+ nullable: false,
358
+ default: false
359
+ }),
360
+ __metadata("design:type", Boolean)
361
+ ], StudentTrainingAppointmentEntity.prototype, "isExam", void 0);
362
+ __decorate([
363
+ (0, typeorm_1.Column)({ default: true }),
364
+ __metadata("design:type", Boolean)
365
+ ], StudentTrainingAppointmentEntity.prototype, "charged", void 0);
366
+ __decorate([
367
+ (0, typeorm_1.Column)({
368
+ nullable: true,
369
+ default: null
370
+ }),
371
+ __metadata("design:type", String)
372
+ ], StudentTrainingAppointmentEntity.prototype, "signatureUrl", void 0);
373
+ __decorate([
374
+ (0, typeorm_1.Column)({
375
+ type: 'simple-json',
376
+ nullable: true,
377
+ default: null
378
+ }),
379
+ __metadata("design:type", Array)
380
+ ], StudentTrainingAppointmentEntity.prototype, "topics", void 0);
381
+ __decorate([
382
+ (0, typeorm_1.Column)({
383
+ type: 'simple-json',
384
+ nullable: true,
385
+ default: null
386
+ }),
387
+ __metadata("design:type", Array)
388
+ ], StudentTrainingAppointmentEntity.prototype, "skills", void 0);
389
+ __decorate([
390
+ (0, typeorm_1.Column)({
391
+ type: 'simple-json',
392
+ nullable: true,
393
+ default: null
394
+ }),
395
+ __metadata("design:type", common_1.Note)
396
+ ], StudentTrainingAppointmentEntity.prototype, "note", void 0);
397
+ __decorate([
398
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
399
+ __metadata("design:type", Date)
400
+ ], StudentTrainingAppointmentEntity.prototype, "remindedOn", void 0);
401
+ __decorate([
402
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
403
+ __metadata("design:type", Date)
404
+ ], StudentTrainingAppointmentEntity.prototype, "rescheduledOn", void 0);
405
+ __decorate([
406
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
407
+ __metadata("design:type", Number)
408
+ ], StudentTrainingAppointmentEntity.prototype, "rescheduledBy", void 0);
409
+ __decorate([
410
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
411
+ __metadata("design:type", Date)
412
+ ], StudentTrainingAppointmentEntity.prototype, "canceledOn", void 0);
413
+ __decorate([
414
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
415
+ __metadata("design:type", Number)
416
+ ], StudentTrainingAppointmentEntity.prototype, "canceledBy", void 0);
417
+ __decorate([
418
+ (0, typeorm_1.ManyToOne)(() => training_entity_1.StudentTrainingEntity, training => training.appointments),
419
+ __metadata("design:type", Promise)
420
+ ], StudentTrainingAppointmentEntity.prototype, "training", void 0);
421
+ __decorate([
422
+ (0, typeorm_1.ManyToOne)(() => lesson_entity_1.StudentTrainingLessonEntity, lesson => lesson.appointments),
423
+ __metadata("design:type", Promise)
424
+ ], StudentTrainingAppointmentEntity.prototype, "lesson", void 0);
425
+ __decorate([
426
+ (0, typeorm_1.ManyToOne)(() => appointment_entity_1.CompanyCourseAppointmentEntity, definition => definition.studentAppointments),
427
+ __metadata("design:type", Promise)
428
+ ], StudentTrainingAppointmentEntity.prototype, "definition", void 0);
429
+ __decorate([
430
+ (0, typeorm_1.ManyToOne)(() => instructor_entity_1.CompanyInstructorEntity, instructor => instructor.studentTrainingAppointments),
431
+ __metadata("design:type", Promise)
432
+ ], StudentTrainingAppointmentEntity.prototype, "instructor", void 0);
433
+ __decorate([
434
+ (0, typeorm_1.OneToOne)(() => exam_entity_1.StudentTrainingExamEntity, exam => exam.appointment),
435
+ __metadata("design:type", Promise)
436
+ ], StudentTrainingAppointmentEntity.prototype, "exam", void 0);
437
+ exports.StudentTrainingAppointmentEntity = StudentTrainingAppointmentEntity = StudentTrainingAppointmentEntity_1 = __decorate([
438
+ (0, typeorm_1.Entity)('studentTrainingAppointments'),
439
+ __metadata("design:paramtypes", [Object])
440
+ ], StudentTrainingAppointmentEntity);
441
+ //# sourceMappingURL=appointment.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appointment.entity.js","sourceRoot":"","sources":["../../../../../src/profile/student/program/training/appointment.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,qCAA8D;AAC9D,4CAA4G;AAC5G,4CAAm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mB,CAAC;;oEAC1C;AAMpD;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,2CAAuB,EAAE,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,2BAA2B,CAAC;;oEAClD;AAM7C;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,uCAAyB,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;8DAC3B;2CApP7B,gCAAgC;IAD5C,IAAA,gBAAM,EAAC,6BAA6B,CAAC;;GACzB,gCAAgC,CAuX5C"}
@@ -0,0 +1,41 @@
1
+ import { Activity, Feedback } from '@driveup/common';
2
+ import { Note, Person, TrainingExam } from '@driveup/common';
3
+ import { StudentTrainingAppointmentEntity } from './appointment.entity';
4
+ import { TrackableEntity } from '../../../../utils';
5
+ export declare class StudentTrainingExamEntity extends TrackableEntity<TrainingExam> {
6
+ /**
7
+ * Reference to the appointment during which this exam took place
8
+ */
9
+ appointmentId: number;
10
+ /**
11
+ * Information about the examiner who conducted the exam
12
+ */
13
+ examiner: Person;
14
+ /**
15
+ * Detailed feedback provided by the examiner
16
+ */
17
+ feedback: Feedback;
18
+ /**
19
+ * Additional notes or comments about the exam
20
+ */
21
+ note: Note;
22
+ /**
23
+ * Whether the student passed the exam
24
+ * @default false
25
+ */
26
+ passed: boolean;
27
+ /**
28
+ * IDs of topics where the student failed to demonstrate competency
29
+ */
30
+ failedTopics: number[];
31
+ /**
32
+ * Student training exam appointment
33
+ * Student can have multiple exams in different appointments
34
+ * This relation offers more information for exam appointments
35
+ */
36
+ appointment: Promise<StudentTrainingAppointmentEntity>;
37
+ constructor(props?: Partial<StudentTrainingExamEntity>);
38
+ toModel(): Promise<TrainingExam>;
39
+ toSummary(): Promise<TrainingExam>;
40
+ getActivities(): Promise<Activity[]>;
41
+ }
@@ -0,0 +1,141 @@
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.StudentTrainingExamEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const common_2 = require("@driveup/common");
16
+ const appointment_entity_1 = require("./appointment.entity");
17
+ const utils_1 = require("../../../../utils");
18
+ const topic_entity_1 = require("./topic.entity");
19
+ let StudentTrainingExamEntity = class StudentTrainingExamEntity extends utils_1.TrackableEntity {
20
+ /**
21
+ * Reference to the appointment during which this exam took place
22
+ */
23
+ appointmentId;
24
+ /**
25
+ * Information about the examiner who conducted the exam
26
+ */
27
+ examiner;
28
+ /**
29
+ * Detailed feedback provided by the examiner
30
+ */
31
+ feedback;
32
+ /**
33
+ * Additional notes or comments about the exam
34
+ */
35
+ note;
36
+ /**
37
+ * Whether the student passed the exam
38
+ * @default false
39
+ */
40
+ passed;
41
+ /**
42
+ * IDs of topics where the student failed to demonstrate competency
43
+ */
44
+ failedTopics;
45
+ /**
46
+ * Student training exam appointment
47
+ * Student can have multiple exams in different appointments
48
+ * This relation offers more information for exam appointments
49
+ */
50
+ appointment;
51
+ constructor(props) {
52
+ super();
53
+ Object.assign(this, props);
54
+ }
55
+ async toModel() {
56
+ const exam = new common_2.TrainingExam({
57
+ id: this.id,
58
+ examiner: this.examiner ? common_2.Person.toInstance(this.examiner) : null,
59
+ feedback: this.feedback ? common_1.Feedback.toInstance(this.feedback) : null,
60
+ note: this.note ? common_2.Note.toInstance(this.note) : null,
61
+ passed: this.passed
62
+ });
63
+ if (this.failedTopics?.length) {
64
+ const failedTopics = await topic_entity_1.StudentTrainingTopicEntity
65
+ .createQueryBuilder('topic')
66
+ .whereInIds(this.failedTopics)
67
+ .getMany();
68
+ exam.failedTopics = await Promise.all(failedTopics?.map(async (t) => (await t.topic).toModel()) || []);
69
+ }
70
+ return exam;
71
+ }
72
+ async toSummary() {
73
+ return new common_2.TrainingExam({
74
+ id: this.id,
75
+ examiner: this.examiner ? common_2.Person.toInstance(this.examiner) : null,
76
+ passed: this.passed
77
+ });
78
+ }
79
+ async getActivities() {
80
+ const activities = [];
81
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
82
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
83
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
84
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
85
+ return activities.filter(a => a);
86
+ }
87
+ };
88
+ exports.StudentTrainingExamEntity = StudentTrainingExamEntity;
89
+ __decorate([
90
+ (0, typeorm_1.Column)(),
91
+ __metadata("design:type", Number)
92
+ ], StudentTrainingExamEntity.prototype, "appointmentId", void 0);
93
+ __decorate([
94
+ (0, typeorm_1.Column)({
95
+ type: 'simple-json',
96
+ nullable: true,
97
+ default: null
98
+ }),
99
+ __metadata("design:type", common_2.Person)
100
+ ], StudentTrainingExamEntity.prototype, "examiner", void 0);
101
+ __decorate([
102
+ (0, typeorm_1.Column)({
103
+ type: 'simple-json',
104
+ nullable: true,
105
+ default: null
106
+ }),
107
+ __metadata("design:type", common_1.Feedback)
108
+ ], StudentTrainingExamEntity.prototype, "feedback", void 0);
109
+ __decorate([
110
+ (0, typeorm_1.Column)({
111
+ type: 'simple-json',
112
+ nullable: true,
113
+ default: null
114
+ }),
115
+ __metadata("design:type", common_2.Note)
116
+ ], StudentTrainingExamEntity.prototype, "note", void 0);
117
+ __decorate([
118
+ (0, typeorm_1.Column)({
119
+ nullable: false,
120
+ default: false
121
+ }),
122
+ __metadata("design:type", Boolean)
123
+ ], StudentTrainingExamEntity.prototype, "passed", void 0);
124
+ __decorate([
125
+ (0, typeorm_1.Column)({
126
+ type: 'simple-json',
127
+ nullable: true,
128
+ default: null
129
+ }),
130
+ __metadata("design:type", Array)
131
+ ], StudentTrainingExamEntity.prototype, "failedTopics", void 0);
132
+ __decorate([
133
+ (0, typeorm_1.OneToOne)(() => appointment_entity_1.StudentTrainingAppointmentEntity, appointment => appointment.exam),
134
+ (0, typeorm_1.JoinColumn)(),
135
+ __metadata("design:type", Promise)
136
+ ], StudentTrainingExamEntity.prototype, "appointment", void 0);
137
+ exports.StudentTrainingExamEntity = StudentTrainingExamEntity = __decorate([
138
+ (0, typeorm_1.Entity)('studentTrainingExams'),
139
+ __metadata("design:paramtypes", [Object])
140
+ ], StudentTrainingExamEntity);
141
+ //# sourceMappingURL=exam.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exam.entity.js","sourceRoot":"","sources":["../../../../../src/profile/student/program/training/exam.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA+D;AAC/D,4CAAmE;AACnE,4CAA6D;AAC7D,6DAAwE;AACxE,6CAAgE;AAChE,iDAA4D;AAGrD,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,uBAA6B;IAE3E;;OAEG;IAEH,aAAa,CAAS;IAEtB;;OAEG;IAMH,QAAQ,CAAS;IAEjB;;OAEG;IAMH,QAAQ,CAAW;IAEnB;;OAEG;IAMH,IAAI,CAAO;IAEX;;;OAGG;IAKH,MAAM,CAAU;IAEhB;;OAEG;IAMH,YAAY,CAAW;IAEvB;;;;OAIG;IAGH,WAAW,CAA4C;IAEvD,YAAY,KAA0C;QACrD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAA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