@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,231 @@
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.UserTicketEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const common_2 = require("@driveup/common");
16
+ const user_entity_1 = require("./user.entity");
17
+ const utils_1 = require("../utils");
18
+ const staff_entity_1 = require("../system/staff/staff.entity");
19
+ const utils_2 = require("../utils");
20
+ /**
21
+ * Represents a support ticket created by or for a user.
22
+ * Tickets track customer support requests, account recovery, and other issues.
23
+ * Each ticket has a type, priority, status, and can include attachments.
24
+ *
25
+ * @extends TrackableEntity
26
+ */
27
+ let UserTicketEntity = class UserTicketEntity extends utils_2.TrackableEntity {
28
+ /**
29
+ * Reference to the user who created or is associated with this ticket
30
+ * Nullable for guest tickets
31
+ */
32
+ userId;
33
+ /**
34
+ * Type of ticket (Recovery, Support, Bug, etc.)
35
+ * @default TicketType.Recovery
36
+ */
37
+ type;
38
+ /**
39
+ * Priority level (Low, Medium, High, Urgent)
40
+ * @default PriorityType.Low
41
+ */
42
+ priority;
43
+ /**
44
+ * Current status of the ticket
45
+ * @default StatusType.Pending
46
+ */
47
+ status;
48
+ /**
49
+ * Ticket title or subject
50
+ */
51
+ title;
52
+ /**
53
+ * Detailed description of the issue or request
54
+ */
55
+ description;
56
+ /**
57
+ * Contact information for guest tickets (when userId is null)
58
+ */
59
+ person;
60
+ /**
61
+ * Files or images attached to the ticket
62
+ */
63
+ attachments;
64
+ /**
65
+ * ID of the staff member who completed the ticket
66
+ */
67
+ completedBy;
68
+ /**
69
+ * Timestamp when the ticket was completed
70
+ */
71
+ completedOn;
72
+ /**
73
+ * ID of the staff member who canceled the ticket
74
+ */
75
+ canceledBy;
76
+ /**
77
+ * Timestamp when the ticket was canceled
78
+ */
79
+ canceledOn;
80
+ /**
81
+ * Reference to the user (if not a guest ticket)
82
+ */
83
+ user;
84
+ /**
85
+ * Creates an instance of UserTicketEntity
86
+ * @param props - Partial properties to initialize the entity
87
+ */
88
+ constructor(props) {
89
+ super();
90
+ Object.assign(this, props);
91
+ }
92
+ /**
93
+ * Converts the entity to a Ticket model instance
94
+ * @returns Promise resolving to Ticket model
95
+ */
96
+ async toModel() {
97
+ const person = this.userId ? (await user_entity_1.UserEntity.findOneBy({ id: this.userId })).toPerson() : new common_1.Person(this.person);
98
+ const attachments = this.attachments ? this.attachments.map(common_1.Asset.toInstance) : [];
99
+ return new common_2.Ticket({
100
+ type: this.type,
101
+ status: this.status,
102
+ priority: this.priority,
103
+ title: this.title,
104
+ description: this.description,
105
+ person: person,
106
+ attachments: attachments
107
+ });
108
+ }
109
+ /**
110
+ * Converts the entity to a Ticket model instance
111
+ * @returns Promise resolving to Ticket model
112
+ */
113
+ async toSummary() {
114
+ const person = this.userId ? (await user_entity_1.UserEntity.findOneBy({ id: this.userId })).toPerson() : new common_1.Person(this.person);
115
+ return new common_2.Ticket({
116
+ type: this.type,
117
+ status: this.status,
118
+ priority: this.priority,
119
+ title: this.title,
120
+ person: person
121
+ });
122
+ }
123
+ async getActivities() {
124
+ const activities = [];
125
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_2.ActivityType.createdBy));
126
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_2.ActivityType.createdOn));
127
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_2.ActivityType.updatedBy, staff_entity_1.StaffEntity));
128
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_2.ActivityType.updatedOn));
129
+ activities.push(await (0, utils_1.toActivity)(this.completedBy, common_2.ActivityType.completedBy, staff_entity_1.StaffEntity));
130
+ activities.push(await (0, utils_1.toActivity)(this.completedOn, common_2.ActivityType.completedOn));
131
+ activities.push(await (0, utils_1.toActivity)(this.canceledBy, common_2.ActivityType.canceledBy, staff_entity_1.StaffEntity));
132
+ activities.push(await (0, utils_1.toActivity)(this.canceledOn, common_2.ActivityType.canceledOn));
133
+ return activities.filter(a => a);
134
+ }
135
+ };
136
+ exports.UserTicketEntity = UserTicketEntity;
137
+ __decorate([
138
+ (0, typeorm_1.Column)({
139
+ nullable: true,
140
+ default: null
141
+ }),
142
+ __metadata("design:type", Number)
143
+ ], UserTicketEntity.prototype, "userId", void 0);
144
+ __decorate([
145
+ (0, typeorm_1.Column)({
146
+ type: 'enum',
147
+ name: 'ticketType',
148
+ enum: common_2.TicketType,
149
+ default: common_2.TicketType.Recovery,
150
+ nullable: false
151
+ }),
152
+ __metadata("design:type", String)
153
+ ], UserTicketEntity.prototype, "type", void 0);
154
+ __decorate([
155
+ (0, typeorm_1.Column)({
156
+ type: 'enum',
157
+ enum: common_1.PriorityType,
158
+ default: common_1.PriorityType.Low,
159
+ nullable: false
160
+ }),
161
+ __metadata("design:type", String)
162
+ ], UserTicketEntity.prototype, "priority", void 0);
163
+ __decorate([
164
+ (0, typeorm_1.Column)({
165
+ type: 'enum',
166
+ enum: [
167
+ common_2.StatusType.Pending,
168
+ common_2.StatusType.Progress,
169
+ common_2.StatusType.Completed,
170
+ common_2.StatusType.Canceled,
171
+ ],
172
+ default: common_2.StatusType.Pending,
173
+ nullable: false
174
+ }),
175
+ __metadata("design:type", String)
176
+ ], UserTicketEntity.prototype, "status", void 0);
177
+ __decorate([
178
+ (0, typeorm_1.Column)({
179
+ nullable: true,
180
+ default: null
181
+ }),
182
+ __metadata("design:type", String)
183
+ ], UserTicketEntity.prototype, "title", void 0);
184
+ __decorate([
185
+ (0, typeorm_1.Column)({
186
+ nullable: true,
187
+ default: null
188
+ }),
189
+ __metadata("design:type", String)
190
+ ], UserTicketEntity.prototype, "description", void 0);
191
+ __decorate([
192
+ (0, typeorm_1.Column)({
193
+ type: 'simple-json',
194
+ nullable: true,
195
+ default: null
196
+ }),
197
+ __metadata("design:type", common_1.Person)
198
+ ], UserTicketEntity.prototype, "person", void 0);
199
+ __decorate([
200
+ (0, typeorm_1.Column)({
201
+ type: 'simple-json',
202
+ nullable: true,
203
+ default: null
204
+ }),
205
+ __metadata("design:type", Array)
206
+ ], UserTicketEntity.prototype, "attachments", void 0);
207
+ __decorate([
208
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
209
+ __metadata("design:type", Number)
210
+ ], UserTicketEntity.prototype, "completedBy", void 0);
211
+ __decorate([
212
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
213
+ __metadata("design:type", Date)
214
+ ], UserTicketEntity.prototype, "completedOn", void 0);
215
+ __decorate([
216
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
217
+ __metadata("design:type", Number)
218
+ ], UserTicketEntity.prototype, "canceledBy", void 0);
219
+ __decorate([
220
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
221
+ __metadata("design:type", Date)
222
+ ], UserTicketEntity.prototype, "canceledOn", void 0);
223
+ __decorate([
224
+ (0, typeorm_1.ManyToOne)(() => user_entity_1.UserEntity, user => user.tickets),
225
+ __metadata("design:type", Promise)
226
+ ], UserTicketEntity.prototype, "user", void 0);
227
+ exports.UserTicketEntity = UserTicketEntity = __decorate([
228
+ (0, typeorm_1.Entity)('userTickets'),
229
+ __metadata("design:paramtypes", [Object])
230
+ ], UserTicketEntity);
231
+ //# sourceMappingURL=ticket.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ticket.entity.js","sourceRoot":"","sources":["../../src/user/ticket.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAoD;AACpD,4CAA8D;AAC9D,4CAAyF;AACzF,+CAA2C;AAC3C,oCAAsC;AACtC,+DAA2D;AAC3D,oCAA2C;AAE3C;;;;;;GAMG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,uBAAuB;IAE5D;;;OAGG;IAKH,MAAM,CAAS;IAEf;;;OAGG;IAQH,IAAI,CAAa;IAEjB;;;OAGG;IAOH,QAAQ,CAAe;IAEvB;;;OAGG;IAYH,MAAM,CAAa;IAEnB;;OAEG;IAKH,KAAK,CAAS;IAEd;;OAEG;IAKH,WAAW,CAAS;IAEpB;;OAEG;IAMH,MAAM,CAAS;IAEf;;OAEG;IAMH,WAAW,CAAU;IAErB;;OAEG;IAEH,WAAW,CAAS;IAEpB;;OAEG;IAEH,WAAW,CAAO;IAElB;;OAEG;IAEH,UAAU,CAAS;IAEnB;;OAEG;IAEH,UAAU,CAAO;IAEjB;;OAEG;IAEH,IAAI,CAAsB;IAE1B;;;OAGG;IACH,YAAY,KAAiC;QAC5C,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,wBAAU,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,eAAM,CAAC,I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IAAI;oDAAC;AAMjB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAU,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;8CACxB;2BAxHd,gBAAgB;IAD5B,IAAA,gBAAM,EAAC,aAAa,CAAC;;GACT,gBAAgB,CAgL5B"}
@@ -0,0 +1,235 @@
1
+ import { AccountStatus, Language, ProfileType, User } from '@driveup/common';
2
+ import { Activity, Address, Person, SelectedProfile } from '@driveup/common';
3
+ import { CountryEntity } from '../system/country/country.entity';
4
+ import { CompanyEntity } from '../profile/company/company.entity';
5
+ import { InstructorEntity } from '../profile/instructor/instructor.entity';
6
+ import { CompanyInstructorEntity } from '../profile/company/instructor/instructor.entity';
7
+ import { AgentEntity } from '../profile/agent/agent.entity';
8
+ import { StudentEntity } from '../profile/student/student.entity';
9
+ import { UserNotificationEntity } from './notification.entity';
10
+ import { UserDeviceEntity } from './device.entity';
11
+ import { UserTicketEntity } from './ticket.entity';
12
+ import { UserAlertEntity } from './alert.entity';
13
+ import { TrackableEntity } from '../utils';
14
+ /**
15
+ * User entity representing a user in the system.
16
+ * Extends TrackableEntity to track creation and update information.
17
+ */
18
+ export declare class UserEntity extends TrackableEntity<User> {
19
+ /**
20
+ * The ID of the country the user belongs to
21
+ */
22
+ countryId: number;
23
+ /**
24
+ * Current account status of the user (Pending, Active, Suspended, Closed)
25
+ */
26
+ status: AccountStatus;
27
+ /**
28
+ * Preferred language of the user for the application interface
29
+ */
30
+ language: Language;
31
+ /**
32
+ * Full name of the user
33
+ */
34
+ name: string;
35
+ /**
36
+ * Unique phone number of the user (used for authentication)
37
+ */
38
+ phone: string;
39
+ /**
40
+ * URL to the user's profile image
41
+ */
42
+ imageUrl: string;
43
+ /**
44
+ * Email address of the user
45
+ */
46
+ email: string;
47
+ /**
48
+ * Date of birth of the user
49
+ */
50
+ birthday: Date;
51
+ /**
52
+ * Physical address of the user
53
+ */
54
+ address: Address;
55
+ /**
56
+ * The currently active/selected profile (Student, Agent, or Company)
57
+ */
58
+ selectedProfile: SelectedProfile;
59
+ /**
60
+ * Firebase Cloud Messaging tokens associated with the user's devices
61
+ * Used for sending push notifications to the user's devices
62
+ * @todo Consider using Device.signature instead and potentially remove this property
63
+ */
64
+ fcmTokens: string[];
65
+ /**
66
+ * Unique identifier (UUID) for the user
67
+ * Automatically generated on creation
68
+ */
69
+ uid: string;
70
+ /**
71
+ * Timezone of the user (default: 'Europe/Zurich')
72
+ */
73
+ timezone: string;
74
+ /**
75
+ * Timestamp of the user's last activity in the system
76
+ */
77
+ lastActivity: Date;
78
+ /**
79
+ * Student profiles associated with this user
80
+ */
81
+ studentProfiles: Promise<StudentEntity[]>;
82
+ /**
83
+ * Agent Profile
84
+ */
85
+ agentProfiles: Promise<AgentEntity[]>;
86
+ /**
87
+ * Instructor profiles
88
+ */
89
+ instructorProfiles: Promise<InstructorEntity[]>;
90
+ /**
91
+ * User country
92
+ */
93
+ country: Promise<CountryEntity>;
94
+ /**
95
+ * Registred devices
96
+ */
97
+ devices: Promise<UserDeviceEntity[]>;
98
+ /**
99
+ * Notifications
100
+ */
101
+ notifications: Promise<UserNotificationEntity[]>;
102
+ /**
103
+ * Alerts
104
+ */
105
+ alerts: Promise<UserAlertEntity[]>;
106
+ /**
107
+ * Support tickets
108
+ */
109
+ tickets: Promise<UserTicketEntity[]>;
110
+ /**
111
+ * Creates a new UserEntity instance
112
+ * @param props - Partial properties to initialize the entity with
113
+ */
114
+ constructor(props?: Partial<UserEntity>);
115
+ /**
116
+ * Converts the entity to a User model instance
117
+ * @returns User model with basic user information
118
+ */
119
+ toModel(): User;
120
+ /**
121
+ * Returns a summary representation of the user
122
+ * @returns User model instance (same as toModel())
123
+ */
124
+ toSummary(): User;
125
+ /**
126
+ * Converts the entity to a Person model instance
127
+ * @returns Person model with basic contact information
128
+ */
129
+ toPerson(): Person;
130
+ /**
131
+ * Updates the last activity timestamp of the user to the current date and saves it.
132
+ * Used to track when the user was last active in the system.
133
+ * @returns The updated user entity
134
+ */
135
+ updateActivity(): Promise<UserEntity>;
136
+ /**
137
+ * Retrieves the user's student profile if it exists, excluding closed profiles
138
+ * @returns The student profile or null if not found
139
+ */
140
+ getStudentProfile(): Promise<StudentEntity>;
141
+ /**
142
+ * Retrieves the user's active student profile
143
+ * @returns The active student profile or null if not found
144
+ */
145
+ getActiveStudentProfile(): Promise<StudentEntity>;
146
+ /**
147
+ * Retrieves the user's agent profile if it exists, excluding closed profiles
148
+ * @returns The agent profile or null if not found
149
+ */
150
+ getAgentProfile(): Promise<AgentEntity>;
151
+ /**
152
+ * Retrieves the user's active agent profile
153
+ * @returns The active agent profile or null if not found
154
+ */
155
+ getActiveAgentProfile(): Promise<AgentEntity>;
156
+ /**
157
+ * Checks if the user belongs to a specific company.
158
+ *
159
+ * @param companyId - The ID of the company to check against.
160
+ * @returns A promise that resolves to `true` if the user belongs to the specified company, otherwise `false`.
161
+ */
162
+ belongsToCompany(companyId: number): Promise<boolean>;
163
+ /**
164
+ * Checks if the user has at least one active profile (student, agent, or instructor)
165
+ * @returns True if the user has an active profile, false otherwise
166
+ */
167
+ hasActiveProfile(): Promise<boolean>;
168
+ /**
169
+ * Retrieves the next active profile based on priority (Company > Agent > Student)
170
+ * Used when the user removes their currently selected profile
171
+ * @returns Object containing profile type and ID, or null if no active profile exists
172
+ */
173
+ getNextProfile(): Promise<{
174
+ type: ProfileType;
175
+ id: number;
176
+ }>;
177
+ /**
178
+ * Retrieves the entity for the user's currently selected profile
179
+ * @returns The selected profile entity (Student, Agent, or CompanyInstructor) or null
180
+ */
181
+ getSelectedProfile(): Promise<StudentEntity | AgentEntity | CompanyInstructorEntity>;
182
+ /**
183
+ * Retrieves the selected student profile if currently selected
184
+ * @returns The student entity or null if not selected or not found
185
+ */
186
+ getSelectedStudent(): Promise<StudentEntity>;
187
+ /**
188
+ * Retrieves the selected agent profile if currently selected
189
+ * @returns The agent entity or null if not selected or not found
190
+ */
191
+ getSelectedAgent(): Promise<AgentEntity>;
192
+ /**
193
+ * Retrieves the selected company profile if currently selected
194
+ * @returns The company entity or null if not selected or not found
195
+ */
196
+ getSelectedCompany(): Promise<CompanyEntity>;
197
+ /**
198
+ * Retrieves the instructor profile for the user in the currently selected company
199
+ * @returns The company instructor entity or undefined if no company is selected
200
+ */
201
+ getSelectedInstructor(): Promise<CompanyInstructorEntity>;
202
+ /**
203
+ * Get the instructor profile for the user in the specified company, regardless of the profile status (pending, invited, etc...)
204
+ * @param company - The company to get the instructor profile for
205
+ * @returns The instructor profile for the user in the specified company
206
+ */
207
+ getInstructor(company: CompanyEntity): Promise<CompanyInstructorEntity>;
208
+ /**
209
+ * @returns The number of company user profiles
210
+ */
211
+ countInstructors(): Promise<number>;
212
+ /**
213
+ * Remove suffix from phone number if the account is closed
214
+ * @returns phone number that should be returned to ui
215
+ */
216
+ getPhone(): string;
217
+ /**
218
+ * Get the pending company profile for the user
219
+ */
220
+ getPendingCompany(): Promise<CompanyEntity>;
221
+ /**
222
+ * Get the pending student profile for the user
223
+ * @param manager EntityManager - optional transaction manager to use in a transaction
224
+ */
225
+ getPendingStudent(): Promise<StudentEntity>;
226
+ /**
227
+ * Get the pending agent profile for the user
228
+ */
229
+ getPendingAgent(): Promise<AgentEntity>;
230
+ /**
231
+ * Retrieves all tracked activities for this user (creation and update timestamps)
232
+ * @returns Array of Activity objects filtered to exclude null values
233
+ */
234
+ getActivities(): Promise<Activity[]>;
235
+ }