@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,573 @@
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 UserEntity_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.UserEntity = void 0;
14
+ const typeorm_1 = require("typeorm");
15
+ const common_1 = require("@driveup/common");
16
+ const common_2 = require("@driveup/common");
17
+ const country_entity_1 = require("../system/country/country.entity");
18
+ const company_entity_1 = require("../profile/company/company.entity");
19
+ const instructor_entity_1 = require("../profile/instructor/instructor.entity");
20
+ const instructor_entity_2 = require("../profile/company/instructor/instructor.entity");
21
+ const agent_entity_1 = require("../profile/agent/agent.entity");
22
+ const student_entity_1 = require("../profile/student/student.entity");
23
+ const notification_entity_1 = require("./notification.entity");
24
+ const device_entity_1 = require("./device.entity");
25
+ const ticket_entity_1 = require("./ticket.entity");
26
+ const alert_entity_1 = require("./alert.entity");
27
+ const utils_1 = require("../utils");
28
+ /**
29
+ * User entity representing a user in the system.
30
+ * Extends TrackableEntity to track creation and update information.
31
+ */
32
+ let UserEntity = UserEntity_1 = class UserEntity extends utils_1.TrackableEntity {
33
+ /**
34
+ * The ID of the country the user belongs to
35
+ */
36
+ countryId;
37
+ /**
38
+ * Current account status of the user (Pending, Active, Suspended, Closed)
39
+ */
40
+ status;
41
+ /**
42
+ * Preferred language of the user for the application interface
43
+ */
44
+ language;
45
+ /**
46
+ * Full name of the user
47
+ */
48
+ name;
49
+ /**
50
+ * Unique phone number of the user (used for authentication)
51
+ */
52
+ phone;
53
+ /**
54
+ * URL to the user's profile image
55
+ */
56
+ imageUrl;
57
+ /**
58
+ * Email address of the user
59
+ */
60
+ email;
61
+ /**
62
+ * Date of birth of the user
63
+ */
64
+ birthday;
65
+ /**
66
+ * Physical address of the user
67
+ */
68
+ address;
69
+ /**
70
+ * The currently active/selected profile (Student, Agent, or Company)
71
+ */
72
+ selectedProfile;
73
+ /**
74
+ * Firebase Cloud Messaging tokens associated with the user's devices
75
+ * Used for sending push notifications to the user's devices
76
+ * @todo Consider using Device.signature instead and potentially remove this property
77
+ */
78
+ fcmTokens;
79
+ /**
80
+ * Unique identifier (UUID) for the user
81
+ * Automatically generated on creation
82
+ */
83
+ uid;
84
+ /**
85
+ * Timezone of the user (default: 'Europe/Zurich')
86
+ */
87
+ timezone;
88
+ /**
89
+ * Timestamp of the user's last activity in the system
90
+ */
91
+ lastActivity;
92
+ /**
93
+ * Student profiles associated with this user
94
+ */
95
+ studentProfiles;
96
+ /**
97
+ * Agent Profile
98
+ */
99
+ agentProfiles;
100
+ /**
101
+ * Instructor profiles
102
+ */
103
+ instructorProfiles;
104
+ /**
105
+ * User country
106
+ */
107
+ country;
108
+ /**
109
+ * Registred devices
110
+ */
111
+ devices;
112
+ /**
113
+ * Notifications
114
+ */
115
+ notifications;
116
+ /**
117
+ * Alerts
118
+ */
119
+ alerts;
120
+ /**
121
+ * Support tickets
122
+ */
123
+ tickets;
124
+ /**
125
+ * Creates a new UserEntity instance
126
+ * @param props - Partial properties to initialize the entity with
127
+ */
128
+ constructor(props) {
129
+ super();
130
+ Object.assign(this, props);
131
+ }
132
+ /**
133
+ * Converts the entity to a User model instance
134
+ * @returns User model with basic user information
135
+ */
136
+ toModel() {
137
+ return new common_1.User({
138
+ id: this.id,
139
+ status: this.status,
140
+ name: this.name,
141
+ phone: this.phone,
142
+ email: this.email,
143
+ imageUrl: this.imageUrl,
144
+ });
145
+ }
146
+ /**
147
+ * Returns a summary representation of the user
148
+ * @returns User model instance (same as toModel())
149
+ */
150
+ toSummary() {
151
+ return this.toModel();
152
+ }
153
+ /**
154
+ * Converts the entity to a Person model instance
155
+ * @returns Person model with basic contact information
156
+ */
157
+ toPerson() {
158
+ return new common_2.Person({
159
+ id: this.id,
160
+ name: this.name,
161
+ phone: this.phone,
162
+ email: this.email,
163
+ imageUrl: this.imageUrl
164
+ });
165
+ }
166
+ /**
167
+ * Updates the last activity timestamp of the user to the current date and saves it.
168
+ * Used to track when the user was last active in the system.
169
+ * @returns The updated user entity
170
+ */
171
+ async updateActivity() {
172
+ this.lastActivity = new Date();
173
+ return await UserEntity_1.save(this);
174
+ }
175
+ /**
176
+ * Retrieves the user's student profile if it exists, excluding closed profiles
177
+ * @returns The student profile or null if not found
178
+ */
179
+ async getStudentProfile() {
180
+ const students = await this.studentProfiles;
181
+ return students?.length ? students.filter(i => i.status !== common_1.AccountStatus.Closed)[0] : null;
182
+ }
183
+ /**
184
+ * Retrieves the user's active student profile
185
+ * @returns The active student profile or null if not found
186
+ */
187
+ async getActiveStudentProfile() {
188
+ let students = await this.studentProfiles;
189
+ students = students?.filter(i => i.status === common_1.AccountStatus.Active);
190
+ return students?.length ? students[0] : null;
191
+ }
192
+ /**
193
+ * Retrieves the user's agent profile if it exists, excluding closed profiles
194
+ * @returns The agent profile or null if not found
195
+ */
196
+ async getAgentProfile() {
197
+ const agents = await this.agentProfiles;
198
+ return agents?.length ? agents.filter(i => i.status !== common_1.AccountStatus.Closed)[0] : null;
199
+ }
200
+ /**
201
+ * Retrieves the user's active agent profile
202
+ * @returns The active agent profile or null if not found
203
+ */
204
+ async getActiveAgentProfile() {
205
+ let agents = await this.agentProfiles;
206
+ agents = agents?.filter(i => i.status === common_1.AccountStatus.Active);
207
+ return agents?.length ? agents[0] : null;
208
+ }
209
+ /**
210
+ * Checks if the user belongs to a specific company.
211
+ *
212
+ * @param companyId - The ID of the company to check against.
213
+ * @returns A promise that resolves to `true` if the user belongs to the specified company, otherwise `false`.
214
+ */
215
+ async belongsToCompany(companyId) {
216
+ const exists = await instructor_entity_2.CompanyInstructorEntity
217
+ .createQueryBuilder('ci')
218
+ .innerJoin('ci.instructor', 'instructor')
219
+ .where('ci.companyId = :companyId', { companyId })
220
+ .andWhere('ci.status = :status', { status: common_1.AccountStatus.Active })
221
+ .andWhere('instructor.userId = :userId', { userId: this.id })
222
+ .getCount();
223
+ return exists > 0;
224
+ }
225
+ /**
226
+ * Checks if the user has at least one active profile (student, agent, or instructor)
227
+ * @returns True if the user has an active profile, false otherwise
228
+ */
229
+ async hasActiveProfile() {
230
+ const studentExists = await student_entity_1.StudentEntity.existsBy({
231
+ userId: this.id,
232
+ status: common_1.AccountStatus.Active
233
+ });
234
+ if (studentExists)
235
+ return true;
236
+ const agentExists = await agent_entity_1.AgentEntity.existsBy({
237
+ userId: this.id,
238
+ status: common_1.AccountStatus.Active
239
+ });
240
+ if (agentExists)
241
+ return true;
242
+ const instructorExists = await instructor_entity_1.InstructorEntity.existsBy({
243
+ userId: this.id,
244
+ status: common_1.AccountStatus.Active
245
+ });
246
+ if (instructorExists)
247
+ return true;
248
+ return;
249
+ }
250
+ /**
251
+ * Retrieves the next active profile based on priority (Company > Agent > Student)
252
+ * Used when the user removes their currently selected profile
253
+ * @returns Object containing profile type and ID, or null if no active profile exists
254
+ */
255
+ async getNextProfile() {
256
+ if (!(await this.hasActiveProfile())) {
257
+ return null;
258
+ }
259
+ const instructors = await instructor_entity_2.CompanyInstructorEntity
260
+ .createQueryBuilder('ci')
261
+ .innerJoin('ci.instructor', 'i')
262
+ .where('i.userId = :userId', { userId: this.id })
263
+ .andWhere('ci.status = :status', { status: common_1.AccountStatus.Active })
264
+ .getMany();
265
+ if (instructors?.length) {
266
+ return {
267
+ type: common_1.ProfileType.Company,
268
+ id: instructors[0].companyId
269
+ };
270
+ }
271
+ const agent = await agent_entity_1.AgentEntity.findOneBy({
272
+ userId: this.id,
273
+ status: common_1.AccountStatus.Active
274
+ });
275
+ if (agent) {
276
+ return {
277
+ type: common_1.ProfileType.Agent,
278
+ id: agent.id
279
+ };
280
+ }
281
+ const student = await student_entity_1.StudentEntity.findOneBy({
282
+ userId: this.id,
283
+ status: common_1.AccountStatus.Active
284
+ });
285
+ if (student) {
286
+ return {
287
+ type: common_1.ProfileType.Student,
288
+ id: student.id
289
+ };
290
+ }
291
+ return;
292
+ }
293
+ /**
294
+ * Retrieves the entity for the user's currently selected profile
295
+ * @returns The selected profile entity (Student, Agent, or CompanyInstructor) or null
296
+ */
297
+ async getSelectedProfile() {
298
+ switch (this.selectedProfile?.type) {
299
+ case common_1.ProfileType.Company:
300
+ return await this.getSelectedInstructor();
301
+ case common_1.ProfileType.Student:
302
+ return await this.getSelectedStudent();
303
+ case common_1.ProfileType.Agent:
304
+ return await this.getSelectedAgent();
305
+ default:
306
+ return null;
307
+ }
308
+ }
309
+ /**
310
+ * Retrieves the selected student profile if currently selected
311
+ * @returns The student entity or null if not selected or not found
312
+ */
313
+ async getSelectedStudent() {
314
+ if (this.selectedProfile?.type !== common_1.ProfileType.Student) {
315
+ return null;
316
+ }
317
+ return await student_entity_1.StudentEntity.findOneBy({
318
+ id: this.selectedProfile.id
319
+ });
320
+ }
321
+ /**
322
+ * Retrieves the selected agent profile if currently selected
323
+ * @returns The agent entity or null if not selected or not found
324
+ */
325
+ async getSelectedAgent() {
326
+ if (this.selectedProfile?.type !== common_1.ProfileType.Agent) {
327
+ return null;
328
+ }
329
+ return await agent_entity_1.AgentEntity.findOneBy({
330
+ id: this.selectedProfile.id
331
+ });
332
+ }
333
+ /**
334
+ * Retrieves the selected company profile if currently selected
335
+ * @returns The company entity or null if not selected or not found
336
+ */
337
+ async getSelectedCompany() {
338
+ if (this.selectedProfile?.type !== common_1.ProfileType.Company) {
339
+ return null;
340
+ }
341
+ return await company_entity_1.CompanyEntity.findOneBy({
342
+ id: this.selectedProfile.id
343
+ });
344
+ }
345
+ /**
346
+ * Retrieves the instructor profile for the user in the currently selected company
347
+ * @returns The company instructor entity or undefined if no company is selected
348
+ */
349
+ async getSelectedInstructor() {
350
+ const company = await this.getSelectedCompany();
351
+ if (!company)
352
+ return;
353
+ return await this.getInstructor(company);
354
+ }
355
+ /**
356
+ * Get the instructor profile for the user in the specified company, regardless of the profile status (pending, invited, etc...)
357
+ * @param company - The company to get the instructor profile for
358
+ * @returns The instructor profile for the user in the specified company
359
+ */
360
+ async getInstructor(company) {
361
+ return await instructor_entity_2.CompanyInstructorEntity
362
+ .createQueryBuilder('ci')
363
+ .innerJoin('ci.instructor', 'i')
364
+ .where('ci.companyId = :companyId', { companyId: company.id })
365
+ .andWhere('i.userId = :userId', { userId: this.id })
366
+ .getOne();
367
+ }
368
+ /**
369
+ * @returns The number of company user profiles
370
+ */
371
+ async countInstructors() {
372
+ return await instructor_entity_1.InstructorEntity.countBy({
373
+ userId: this.id
374
+ });
375
+ }
376
+ /**
377
+ * Remove suffix from phone number if the account is closed
378
+ * @returns phone number that should be returned to ui
379
+ */
380
+ getPhone() {
381
+ return (this.status === common_1.AccountStatus.Closed ?
382
+ this.phone.includes('-') ?
383
+ this.phone.split('-')[0]
384
+ : this.phone
385
+ : this.phone);
386
+ }
387
+ /**
388
+ * Get the pending company profile for the user
389
+ */
390
+ async getPendingCompany() {
391
+ return await company_entity_1.CompanyEntity
392
+ .createQueryBuilder('c')
393
+ .innerJoin('c.instructors', 'ci')
394
+ .innerJoin('ci.instructor', 'i')
395
+ .innerJoin('i.user', 'u')
396
+ .where('c.status = :status', { status: common_1.AccountStatus.Pending })
397
+ .andWhere('ci.role = :role', { role: common_1.CompanyRole.Owner })
398
+ .andWhere('u.id = :userId', { userId: this.id })
399
+ .getOne();
400
+ }
401
+ /**
402
+ * Get the pending student profile for the user
403
+ * @param manager EntityManager - optional transaction manager to use in a transaction
404
+ */
405
+ async getPendingStudent() {
406
+ return await student_entity_1.StudentEntity.findOneBy({
407
+ status: common_1.AccountStatus.Pending,
408
+ userId: this.id
409
+ });
410
+ }
411
+ /**
412
+ * Get the pending agent profile for the user
413
+ */
414
+ async getPendingAgent() {
415
+ return await agent_entity_1.AgentEntity.findOneBy({
416
+ status: common_1.AccountStatus.Pending,
417
+ userId: this.id
418
+ });
419
+ }
420
+ /**
421
+ * Retrieves all tracked activities for this user (creation and update timestamps)
422
+ * @returns Array of Activity objects filtered to exclude null values
423
+ */
424
+ async getActivities() {
425
+ const activities = [];
426
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_2.ActivityType.createdBy));
427
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_2.ActivityType.createdOn));
428
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_2.ActivityType.updatedBy));
429
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_2.ActivityType.updatedOn));
430
+ return activities.filter(a => a);
431
+ }
432
+ };
433
+ exports.UserEntity = UserEntity;
434
+ __decorate([
435
+ (0, typeorm_1.Column)(),
436
+ __metadata("design:type", Number)
437
+ ], UserEntity.prototype, "countryId", void 0);
438
+ __decorate([
439
+ (0, typeorm_1.Column)({
440
+ type: 'enum',
441
+ enum: common_1.AccountStatus,
442
+ default: common_1.AccountStatus.Pending,
443
+ nullable: false
444
+ }),
445
+ __metadata("design:type", String)
446
+ ], UserEntity.prototype, "status", void 0);
447
+ __decorate([
448
+ (0, typeorm_1.Column)({
449
+ type: 'enum',
450
+ enum: common_1.Language,
451
+ default: common_1.Language.En,
452
+ nullable: true
453
+ }),
454
+ __metadata("design:type", String)
455
+ ], UserEntity.prototype, "language", void 0);
456
+ __decorate([
457
+ (0, typeorm_1.Column)({
458
+ nullable: true,
459
+ default: null
460
+ }),
461
+ __metadata("design:type", String)
462
+ ], UserEntity.prototype, "name", void 0);
463
+ __decorate([
464
+ (0, typeorm_1.Column)({
465
+ nullable: false,
466
+ unique: true
467
+ }),
468
+ __metadata("design:type", String)
469
+ ], UserEntity.prototype, "phone", void 0);
470
+ __decorate([
471
+ (0, typeorm_1.Column)({
472
+ nullable: true,
473
+ default: null
474
+ }),
475
+ __metadata("design:type", String)
476
+ ], UserEntity.prototype, "imageUrl", void 0);
477
+ __decorate([
478
+ (0, typeorm_1.Column)({
479
+ nullable: true,
480
+ default: null
481
+ }),
482
+ __metadata("design:type", String)
483
+ ], UserEntity.prototype, "email", void 0);
484
+ __decorate([
485
+ (0, typeorm_1.Column)({
486
+ nullable: true,
487
+ default: null
488
+ }),
489
+ __metadata("design:type", Date)
490
+ ], UserEntity.prototype, "birthday", void 0);
491
+ __decorate([
492
+ (0, typeorm_1.Column)({
493
+ type: 'simple-json',
494
+ nullable: true,
495
+ default: null
496
+ }),
497
+ __metadata("design:type", common_2.Address)
498
+ ], UserEntity.prototype, "address", void 0);
499
+ __decorate([
500
+ (0, typeorm_1.Column)({
501
+ type: 'simple-json',
502
+ nullable: true,
503
+ default: null
504
+ }),
505
+ __metadata("design:type", Object)
506
+ ], UserEntity.prototype, "selectedProfile", void 0);
507
+ __decorate([
508
+ (0, typeorm_1.Column)({
509
+ type: 'simple-json',
510
+ nullable: true,
511
+ default: null
512
+ }),
513
+ __metadata("design:type", Array)
514
+ ], UserEntity.prototype, "fcmTokens", void 0);
515
+ __decorate([
516
+ (0, typeorm_1.Column)({
517
+ nullable: true,
518
+ unique: true
519
+ }),
520
+ (0, typeorm_1.Generated)('uuid'),
521
+ __metadata("design:type", String)
522
+ ], UserEntity.prototype, "uid", void 0);
523
+ __decorate([
524
+ (0, typeorm_1.Column)({
525
+ nullable: true,
526
+ default: 'Europe/Zurich'
527
+ }),
528
+ __metadata("design:type", String)
529
+ ], UserEntity.prototype, "timezone", void 0);
530
+ __decorate([
531
+ (0, typeorm_1.Column)({
532
+ nullable: true,
533
+ default: null
534
+ }),
535
+ __metadata("design:type", Date)
536
+ ], UserEntity.prototype, "lastActivity", void 0);
537
+ __decorate([
538
+ (0, typeorm_1.OneToMany)(() => student_entity_1.StudentEntity, student => student.user),
539
+ __metadata("design:type", Promise)
540
+ ], UserEntity.prototype, "studentProfiles", void 0);
541
+ __decorate([
542
+ (0, typeorm_1.OneToMany)(() => agent_entity_1.AgentEntity, agent => agent.user),
543
+ __metadata("design:type", Promise)
544
+ ], UserEntity.prototype, "agentProfiles", void 0);
545
+ __decorate([
546
+ (0, typeorm_1.OneToMany)(() => instructor_entity_1.InstructorEntity, instructor => instructor.user),
547
+ __metadata("design:type", Promise)
548
+ ], UserEntity.prototype, "instructorProfiles", void 0);
549
+ __decorate([
550
+ (0, typeorm_1.ManyToOne)(() => country_entity_1.CountryEntity, country => country.users),
551
+ __metadata("design:type", Promise)
552
+ ], UserEntity.prototype, "country", void 0);
553
+ __decorate([
554
+ (0, typeorm_1.OneToMany)(() => device_entity_1.UserDeviceEntity, device => device.user),
555
+ __metadata("design:type", Promise)
556
+ ], UserEntity.prototype, "devices", void 0);
557
+ __decorate([
558
+ (0, typeorm_1.OneToMany)(() => notification_entity_1.UserNotificationEntity, notification => notification.user),
559
+ __metadata("design:type", Promise)
560
+ ], UserEntity.prototype, "notifications", void 0);
561
+ __decorate([
562
+ (0, typeorm_1.OneToMany)(() => alert_entity_1.UserAlertEntity, alert => alert.user),
563
+ __metadata("design:type", Promise)
564
+ ], UserEntity.prototype, "alerts", void 0);
565
+ __decorate([
566
+ (0, typeorm_1.OneToMany)(() => ticket_entity_1.UserTicketEntity, ticket => ticket.user),
567
+ __metadata("design:type", Promise)
568
+ ], UserEntity.prototype, "tickets", void 0);
569
+ exports.UserEntity = UserEntity = UserEntity_1 = __decorate([
570
+ (0, typeorm_1.Entity)('users'),
571
+ __metadata("design:paramtypes", [Object])
572
+ ], UserEnt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BAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;;mDACd;AAM1C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,0BAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;;iDACZ;AAMtC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,oCAAgB,EAAE,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;;sDACjB;AAMhD;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;;2CACzB;AAMhC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,gCAAgB,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;;2CACpB;AAMrC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,4CAAsB,EAAE,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC;;iDAC1B;AAMjD;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;;0CACnB;AAMnC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,gCAAgB,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;;2CACpB;qBAtLzB,UAAU;IADtB,IAAA,gBAAM,EAAC,OAAO,CAAC;;GACH,UAAU,CAmhBtB"}
@@ -0,0 +1,75 @@
1
+ import { Activity } from '@driveup/common';
2
+ import { TrackableEntity } from '../utils';
3
+ /**
4
+ * Represents a verification token for phone or email verification.
5
+ * Used for account verification, password recovery, and other secure operations.
6
+ * Tokens have expiration dates and track confirmation attempts.
7
+ *
8
+ * @extends TrackableEntity
9
+ */
10
+ export declare class UserVerificationEntity extends TrackableEntity {
11
+ /**
12
+ * Phone number to be verified
13
+ */
14
+ phone: string;
15
+ /**
16
+ * Email address to be verified
17
+ */
18
+ email: string;
19
+ /**
20
+ * Verification token (OTP or UUID)
21
+ */
22
+ token: string;
23
+ /**
24
+ * Optional URL for email verification links
25
+ */
26
+ url: string;
27
+ /**
28
+ * Whether the verification has been confirmed
29
+ * @default false
30
+ */
31
+ confirmed: boolean;
32
+ /**
33
+ * Expiration date/time for the verification token
34
+ */
35
+ expiredOn: Date;
36
+ /**
37
+ * Number of verification attempts made
38
+ * @default 0
39
+ */
40
+ attempts: number;
41
+ /**
42
+ * Creates an instance of UserVerificationEntity
43
+ * @param props - Partial properties to initialize the entity
44
+ */
45
+ constructor(props?: Partial<UserVerificationEntity>);
46
+ toModel(): {
47
+ id: number;
48
+ phone: string;
49
+ email: string;
50
+ token: string;
51
+ url: string;
52
+ confirmed: boolean;
53
+ expiredOn: Date;
54
+ attempts: number;
55
+ };
56
+ /**
57
+ * Returns a summary representation of the user
58
+ * @returns Model instance (same as toModel())
59
+ */
60
+ toSummary(): {
61
+ id: number;
62
+ phone: string;
63
+ email: string;
64
+ token: string;
65
+ url: string;
66
+ confirmed: boolean;
67
+ expiredOn: Date;
68
+ attempts: number;
69
+ };
70
+ /**
71
+ * Retrieves all activity records for this verification
72
+ * @returns Array of Activity objects
73
+ */
74
+ getActivities(): Promise<Activity[]>;
75
+ }