@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,144 @@
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.CompanyProductVehicleEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const product_entity_1 = require("./product.entity");
16
+ const utils_1 = require("../../../utils");
17
+ let CompanyProductVehicleEntity = class CompanyProductVehicleEntity extends utils_1.TrackableEntity {
18
+ /**
19
+ * Reference to the company product this vehicle belongs to
20
+ */
21
+ productId;
22
+ /**
23
+ * Vehicle license plate
24
+ */
25
+ licensePlate;
26
+ /**
27
+ * Vehicle number used in driving school
28
+ */
29
+ number;
30
+ /**
31
+ * Vehicle make (e.g. Toyota, Ford)
32
+ */
33
+ make;
34
+ /**
35
+ * Vehicle model (e.g. Corolla, Focus)
36
+ */
37
+ model;
38
+ /**
39
+ * Vehicle manufacturing year
40
+ */
41
+ year;
42
+ /**
43
+ * URL to an image of the vehicle
44
+ */
45
+ imageUrl;
46
+ /**
47
+ * Type of transmission (Automatic or Manual)
48
+ * @default CarTransmission.Automatic
49
+ */
50
+ transmission;
51
+ /**
52
+ * Reference to the company product this vehicle is used for
53
+ */
54
+ product;
55
+ constructor(props) {
56
+ super();
57
+ Object.assign(this, props);
58
+ }
59
+ toModel() {
60
+ return new common_1.Vehicle({
61
+ id: this.id,
62
+ licensePlate: this.licensePlate,
63
+ number: this.number,
64
+ make: this.make,
65
+ model: this.model,
66
+ year: this.year,
67
+ imageUrl: this.imageUrl,
68
+ transmission: this.transmission
69
+ });
70
+ }
71
+ toSummary() {
72
+ return this.toModel();
73
+ }
74
+ async getActivities() {
75
+ const activities = [];
76
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
77
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
78
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
79
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
80
+ return activities.filter(a => a);
81
+ }
82
+ };
83
+ exports.CompanyProductVehicleEntity = CompanyProductVehicleEntity;
84
+ __decorate([
85
+ (0, typeorm_1.Column)(),
86
+ __metadata("design:type", String)
87
+ ], CompanyProductVehicleEntity.prototype, "productId", void 0);
88
+ __decorate([
89
+ (0, typeorm_1.Column)(),
90
+ __metadata("design:type", String)
91
+ ], CompanyProductVehicleEntity.prototype, "licensePlate", void 0);
92
+ __decorate([
93
+ (0, typeorm_1.Column)({
94
+ nullable: true,
95
+ default: null
96
+ }),
97
+ __metadata("design:type", String)
98
+ ], CompanyProductVehicleEntity.prototype, "number", void 0);
99
+ __decorate([
100
+ (0, typeorm_1.Column)({
101
+ nullable: true,
102
+ default: null
103
+ }),
104
+ __metadata("design:type", String)
105
+ ], CompanyProductVehicleEntity.prototype, "make", void 0);
106
+ __decorate([
107
+ (0, typeorm_1.Column)({
108
+ nullable: true,
109
+ default: null
110
+ }),
111
+ __metadata("design:type", String)
112
+ ], CompanyProductVehicleEntity.prototype, "model", void 0);
113
+ __decorate([
114
+ (0, typeorm_1.Column)({
115
+ nullable: true,
116
+ default: null
117
+ }),
118
+ __metadata("design:type", Number)
119
+ ], CompanyProductVehicleEntity.prototype, "year", void 0);
120
+ __decorate([
121
+ (0, typeorm_1.Column)({
122
+ nullable: true,
123
+ default: null
124
+ }),
125
+ __metadata("design:type", String)
126
+ ], CompanyProductVehicleEntity.prototype, "imageUrl", void 0);
127
+ __decorate([
128
+ (0, typeorm_1.Column)({
129
+ type: 'enum',
130
+ enum: common_1.CarTransmission,
131
+ default: common_1.CarTransmission.Automatic,
132
+ nullable: false
133
+ }),
134
+ __metadata("design:type", String)
135
+ ], CompanyProductVehicleEntity.prototype, "transmission", void 0);
136
+ __decorate([
137
+ (0, typeorm_1.ManyToOne)(() => product_entity_1.CompanyProductEntity, product => product.vehicles),
138
+ __metadata("design:type", Promise)
139
+ ], CompanyProductVehicleEntity.prototype, "product", void 0);
140
+ exports.CompanyProductVehicleEntity = CompanyProductVehicleEntity = __decorate([
141
+ (0, typeorm_1.Entity)('companyProductVehicles'),
142
+ __metadata("design:paramtypes", [Object])
143
+ ], CompanyProductVehicleEntity);
144
+ //# sourceMappingURL=vehicle.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vehicle.entity.js","sourceRoot":"","sources":["../../../../src/profile/company/product/vehicle.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAoD;AACpD,4CAAmF;AACnF,qDAAwD;AACxD,0CAA6D;AAGtD,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,uBAAwB;IAExE;;OAEG;IAEH,SAAS,CAAS;IAElB;;OAEG;IAEH,YAAY,CAAS;IAErB;;OAEG;IAKH,MAAM,CAAS;IAEf;;OAEG;IAKH,IAAI,CAAS;IAEb;;OAEG;IAKH,KAAK,CAAS;IAEd;;OAEG;IAKH,IAAI,CAA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C,CAAC,CAAC,CAAC;IAClC,CAAC;CACD,CAAA;AA3GY,kEAA2B;AAMvC;IADC,IAAA,gBAAM,GAAE;;8DACS;AAMlB;IADC,IAAA,gBAAM,GAAE;;iEACY;AASrB;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;2DACa;AASf;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;yDACW;AASb;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;0DACY;AASd;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;yDACW;AASb;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;6DACe;AAYjB;IANC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,wBAAe;QACrB,OAAO,EAAE,wBAAe,CAAC,SAAS;QAClC,QAAQ,EAAE,KAAK;KACf,CAAC;;iEACsC;AAMxC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,qCAAoB,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;;4DAC5B;sCA3E3B,2BAA2B;IADvC,IAAA,gBAAM,EAAC,wBAAwB,CAAC;;GACpB,2BAA2B,CA2GvC"}
@@ -0,0 +1,80 @@
1
+ import { AccountStatus, Instructor, Language, Person, Preference } from '@driveup/common';
2
+ import { Activity } from '@driveup/common';
3
+ import { UserEntity } from '../../user/user.entity';
4
+ import { CompanyInstructorEntity } from '../company/instructor/instructor.entity';
5
+ import { TrackableEntity } from '../../utils';
6
+ /**
7
+ * Represents an instructor profile in the system.
8
+ * Instructors can be associated with multiple companies and provide
9
+ * training services. Each instructor has their own preferences and settings.
10
+ *
11
+ * @extends TrackableEntity<Instructor>
12
+ */
13
+ export declare class InstructorEntity extends TrackableEntity<Instructor> {
14
+ /**
15
+ * Reference to the user account
16
+ */
17
+ userId: number;
18
+ /**
19
+ * Account status of the instructor profile
20
+ * @default AccountStatus.Invited
21
+ */
22
+ status: AccountStatus;
23
+ /**
24
+ * Preferred language for the instructor interface
25
+ * @default Language.En
26
+ */
27
+ language: Language;
28
+ /**
29
+ * Instructor's display name
30
+ */
31
+ name: string;
32
+ /**
33
+ * URL to the instructor's profile picture
34
+ */
35
+ imageUrl: string;
36
+ /**
37
+ * Notification preferences stored as JSON
38
+ */
39
+ preferences: Preference[];
40
+ /**
41
+ * Reference to the user account
42
+ */
43
+ user: Promise<UserEntity>;
44
+ /**
45
+ * Companies this instructor is associated with
46
+ */
47
+ companies: Promise<CompanyInstructorEntity[]>;
48
+ /**
49
+ * Creates an instance of InstructorEntity
50
+ * @param props - Partial properties to initialize the entity
51
+ */
52
+ constructor(props?: Partial<InstructorEntity>);
53
+ /**
54
+ * Converts the entity to an Instructor model instance
55
+ * Falls back to user data if instructor-specific data is not set
56
+ * @returns Promise resolving to Instructor model
57
+ */
58
+ toModel(): Promise<Instructor>;
59
+ /**
60
+ * Converts the entity to an Instructor model instance
61
+ * @returns Promise resolving to Instructor model
62
+ */
63
+ toSummary(): Promise<Instructor>;
64
+ /**
65
+ * Converts the entity to a Person model
66
+ * @returns Promise resolving to Person model with basic contact information
67
+ */
68
+ toPerson(): Promise<Person>;
69
+ /**
70
+ * Retrieves notification preferences as typed Preference instances
71
+ * @returns Array of Preference objects or undefined if not set
72
+ */
73
+ getPreferences(): Preference<boolean>[];
74
+ /**
75
+ * Retrieves all activity records for this instructor
76
+ * Includes creation and update actions
77
+ * @returns Array of Activity objects
78
+ */
79
+ getActivities(): Promise<Activity[]>;
80
+ }
@@ -0,0 +1,186 @@
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.InstructorEntity = 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/user.entity");
17
+ const instructor_entity_1 = require("../company/instructor/instructor.entity");
18
+ const utils_1 = require("../../utils");
19
+ /**
20
+ * Represents an instructor profile in the system.
21
+ * Instructors can be associated with multiple companies and provide
22
+ * training services. Each instructor has their own preferences and settings.
23
+ *
24
+ * @extends TrackableEntity<Instructor>
25
+ */
26
+ let InstructorEntity = class InstructorEntity extends utils_1.TrackableEntity {
27
+ /**
28
+ * Reference to the user account
29
+ */
30
+ userId;
31
+ /**
32
+ * Account status of the instructor profile
33
+ * @default AccountStatus.Invited
34
+ */
35
+ status;
36
+ /**
37
+ * Preferred language for the instructor interface
38
+ * @default Language.En
39
+ */
40
+ language;
41
+ /**
42
+ * Instructor's display name
43
+ */
44
+ name;
45
+ /**
46
+ * URL to the instructor's profile picture
47
+ */
48
+ imageUrl;
49
+ /**
50
+ * Notification preferences stored as JSON
51
+ */
52
+ preferences;
53
+ /**
54
+ * Reference to the user account
55
+ */
56
+ user;
57
+ /**
58
+ * Companies this instructor is associated with
59
+ */
60
+ companies;
61
+ /**
62
+ * Creates an instance of InstructorEntity
63
+ * @param props - Partial properties to initialize the entity
64
+ */
65
+ constructor(props) {
66
+ super();
67
+ Object.assign(this, props);
68
+ }
69
+ /**
70
+ * Converts the entity to an Instructor model instance
71
+ * Falls back to user data if instructor-specific data is not set
72
+ * @returns Promise resolving to Instructor model
73
+ */
74
+ async toModel() {
75
+ const user = await this.user;
76
+ return common_1.Instructor.toInstance({
77
+ id: this.id,
78
+ name: this.name || user.name,
79
+ language: this.language || user.language,
80
+ imageUrl: this.imageUrl || user.imageUrl,
81
+ phone: user.phone,
82
+ status: this.status
83
+ });
84
+ }
85
+ /**
86
+ * Converts the entity to an Instructor model instance
87
+ * @returns Promise resolving to Instructor model
88
+ */
89
+ async toSummary() {
90
+ return await this.toModel();
91
+ }
92
+ /**
93
+ * Converts the entity to a Person model
94
+ * @returns Promise resolving to Person model with basic contact information
95
+ */
96
+ async toPerson() {
97
+ const user = await this.user;
98
+ return new common_1.Person({
99
+ id: this.id,
100
+ name: this.name,
101
+ imageUrl: this.imageUrl || user.imageUrl,
102
+ phone: user.phone,
103
+ email: user.email
104
+ });
105
+ }
106
+ /**
107
+ * Retrieves notification preferences as typed Preference instances
108
+ * @returns Array of Preference objects or undefined if not set
109
+ */
110
+ getPreferences() {
111
+ if (!this.preferences)
112
+ return;
113
+ return this.preferences.map(common_1.Preference.toInstance);
114
+ }
115
+ /**
116
+ * Retrieves all activity records for this instructor
117
+ * Includes creation and update actions
118
+ * @returns Array of Activity objects
119
+ */
120
+ async getActivities() {
121
+ const activities = [];
122
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_2.ActivityType.createdBy));
123
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_2.ActivityType.createdOn));
124
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_2.ActivityType.updatedBy));
125
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_2.ActivityType.updatedOn));
126
+ return activities.filter(a => a);
127
+ }
128
+ };
129
+ exports.InstructorEntity = InstructorEntity;
130
+ __decorate([
131
+ (0, typeorm_1.Column)(),
132
+ __metadata("design:type", Number)
133
+ ], InstructorEntity.prototype, "userId", void 0);
134
+ __decorate([
135
+ (0, typeorm_1.Column)({
136
+ type: 'enum',
137
+ enum: common_1.AccountStatus,
138
+ default: common_1.AccountStatus.Invited,
139
+ nullable: false
140
+ }),
141
+ __metadata("design:type", String)
142
+ ], InstructorEntity.prototype, "status", void 0);
143
+ __decorate([
144
+ (0, typeorm_1.Column)({
145
+ type: 'enum',
146
+ enum: common_1.Language,
147
+ default: common_1.Language.En,
148
+ nullable: true
149
+ }),
150
+ __metadata("design:type", String)
151
+ ], InstructorEntity.prototype, "language", void 0);
152
+ __decorate([
153
+ (0, typeorm_1.Column)({
154
+ nullable: true,
155
+ default: null
156
+ }),
157
+ __metadata("design:type", String)
158
+ ], InstructorEntity.prototype, "name", void 0);
159
+ __decorate([
160
+ (0, typeorm_1.Column)({
161
+ nullable: true,
162
+ default: null
163
+ }),
164
+ __metadata("design:type", String)
165
+ ], InstructorEntity.prototype, "imageUrl", void 0);
166
+ __decorate([
167
+ (0, typeorm_1.Column)({
168
+ type: 'simple-json',
169
+ nullable: true,
170
+ default: null
171
+ }),
172
+ __metadata("design:type", Array)
173
+ ], InstructorEntity.prototype, "preferences", void 0);
174
+ __decorate([
175
+ (0, typeorm_1.ManyToOne)(() => user_entity_1.UserEntity, user => user.instructorProfiles),
176
+ __metadata("design:type", Promise)
177
+ ], InstructorEntity.prototype, "user", void 0);
178
+ __decorate([
179
+ (0, typeorm_1.OneToMany)(() => instructor_entity_1.CompanyInstructorEntity, company => company.instructor),
180
+ __metadata("design:type", Promise)
181
+ ], InstructorEntity.prototype, "companies", void 0);
182
+ exports.InstructorEntity = InstructorEntity = __decorate([
183
+ (0, typeorm_1.Entity)('instructors'),
184
+ __metadata("design:paramtypes", [Object])
185
+ ], InstructorEntity);
186
+ //# sourceMappingURL=instructor.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructor.entity.js","sourceRoot":"","sources":["../../../src/profile/instructor/instructor.ent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AE,sBAAa,CAAC,OAAO;QAC9B,QAAQ,EAAE,KAAK;KACf,CAAC;;gDACoB;AAYtB;IANC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,iBAAQ;QACd,OAAO,EAAE,iBAAQ,CAAC,EAAE;QACpB,QAAQ,EAAE,IAAI;KACd,CAAC;;kDACiB;AASnB;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;8CACW;AASb;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;kDACe;AAUjB;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;qDACwB;AAM1B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAU,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC;;8CACnC;AAM1B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,2CAAuB,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;;mDAC1B;2BAtElC,gBAAgB;IAD5B,IAAA,gBAAM,EAAC,aAAa,CAAC;;GACT,gBAAgB,CA+I5B"}
@@ -0,0 +1,66 @@
1
+ import { ProductType, Activity, Licence, Authority } from '@driveup/common';
2
+ import { StudentEntity } from '../../student.entity';
3
+ import { DrivingCategoryEntity } from '../../../../system/driving/category.entity';
4
+ import { StudentProgramEntity } from '../program.entity';
5
+ import { TrackableEntity } from '../../../../utils';
6
+ export declare class StudentLicenceEntity extends TrackableEntity<Licence> {
7
+ /**
8
+ * Reference to the student who owns this license
9
+ */
10
+ studentId: number;
11
+ /**
12
+ * Reference to the driving category this license is valid for
13
+ */
14
+ categoryId: string;
15
+ /**
16
+ * Type of license (Student, Probationary, or Permanent)
17
+ * @default ProductType.DrivingCar
18
+ */
19
+ type: ProductType;
20
+ /**
21
+ * Name of the medical document
22
+ * (only for student reference)
23
+ */
24
+ name: string;
25
+ /**
26
+ * Licence number
27
+ */
28
+ number: string;
29
+ /**
30
+ * Document issued date
31
+ */
32
+ issuedAt: Date;
33
+ /**
34
+ * Date from which the license becomes valid
35
+ */
36
+ validFrom: Date;
37
+ /**
38
+ * Document expiry date
39
+ */
40
+ validUntil: Date;
41
+ /**
42
+ * Document url
43
+ */
44
+ documentUrl: string;
45
+ /**
46
+ * Information about the authority that issued the license
47
+ */
48
+ issuer: Authority;
49
+ /**
50
+ * Reference to the student who owns this license
51
+ */
52
+ student: Promise<StudentEntity>;
53
+ /**
54
+ * Reference to the driving category associated with this license
55
+ */
56
+ category: Promise<DrivingCategoryEntity>;
57
+ /**
58
+ * Student programs linked to this licence
59
+ * (pivot table relation)
60
+ */
61
+ programs: Promise<StudentProgramEntity[]>;
62
+ constructor(props?: Partial<StudentLicenceEntity>);
63
+ toModel(): Licence;
64
+ toSummary(): Licence;
65
+ getActivities(): Promise<Activity[]>;
66
+ }
@@ -0,0 +1,187 @@
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.StudentLicenceEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const student_entity_1 = require("../../student.entity");
16
+ const category_entity_1 = require("../../../../system/driving/category.entity");
17
+ const program_entity_1 = require("../program.entity");
18
+ const utils_1 = require("../../../../utils");
19
+ let StudentLicenceEntity = class StudentLicenceEntity extends utils_1.TrackableEntity {
20
+ /**
21
+ * Reference to the student who owns this license
22
+ */
23
+ studentId;
24
+ /**
25
+ * Reference to the driving category this license is valid for
26
+ */
27
+ categoryId;
28
+ /**
29
+ * Type of license (Student, Probationary, or Permanent)
30
+ * @default ProductType.DrivingCar
31
+ */
32
+ type;
33
+ /**
34
+ * Name of the medical document
35
+ * (only for student reference)
36
+ */
37
+ name;
38
+ /**
39
+ * Licence number
40
+ */
41
+ number;
42
+ /**
43
+ * Document issued date
44
+ */
45
+ issuedAt;
46
+ /**
47
+ * Date from which the license becomes valid
48
+ */
49
+ validFrom;
50
+ /**
51
+ * Document expiry date
52
+ */
53
+ validUntil;
54
+ /**
55
+ * Document url
56
+ */
57
+ documentUrl;
58
+ /**
59
+ * Information about the authority that issued the license
60
+ */
61
+ issuer;
62
+ /**
63
+ * Reference to the student who owns this license
64
+ */
65
+ student;
66
+ /**
67
+ * Reference to the driving category associated with this license
68
+ */
69
+ category;
70
+ /**
71
+ * Student programs linked to this licence
72
+ * (pivot table relation)
73
+ */
74
+ programs;
75
+ constructor(props) {
76
+ super();
77
+ Object.assign(this, props);
78
+ }
79
+ toModel() {
80
+ return new common_1.Licence({
81
+ id: this.id,
82
+ number: this.number,
83
+ type: this.type,
84
+ name: this.name,
85
+ issuedAt: this.issuedAt,
86
+ validFrom: this.validFrom,
87
+ validUntil: this.validUntil,
88
+ documentUrl: this.documentUrl,
89
+ issuer: this.issuer ? common_1.Authority.toInstance(this.issuer) : null,
90
+ });
91
+ }
92
+ toSummary() {
93
+ return this.toModel();
94
+ }
95
+ async getActivities() {
96
+ const activities = [];
97
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
98
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
99
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
100
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
101
+ return activities.filter(a => a);
102
+ }
103
+ };
104
+ exports.StudentLicenceEntity = StudentLicenceEntity;
105
+ __decorate([
106
+ (0, typeorm_1.Column)(),
107
+ __metadata("design:type", Number)
108
+ ], StudentLicenceEntity.prototype, "studentId", void 0);
109
+ __decorate([
110
+ (0, typeorm_1.Column)(),
111
+ __metadata("design:type", String)
112
+ ], StudentLicenceEntity.prototype, "categoryId", void 0);
113
+ __decorate([
114
+ (0, typeorm_1.Column)({
115
+ type: 'enum',
116
+ name: 'licenceType',
117
+ enum: [
118
+ common_1.ProductType.LicenceStudent,
119
+ common_1.ProductType.LicenceProbationary,
120
+ common_1.ProductType.LicencePermanent
121
+ ],
122
+ default: common_1.ProductType.DrivingCar,
123
+ nullable: false
124
+ }),
125
+ __metadata("design:type", String)
126
+ ], StudentLicenceEntity.prototype, "type", void 0);
127
+ __decorate([
128
+ (0, typeorm_1.Column)({
129
+ nullable: true,
130
+ default: null
131
+ }),
132
+ __metadata("design:type", String)
133
+ ], StudentLicenceEntity.prototype, "name", void 0);
134
+ __decorate([
135
+ (0, typeorm_1.Column)(),
136
+ __metadata("design:type", String)
137
+ ], StudentLicenceEntity.prototype, "number", void 0);
138
+ __decorate([
139
+ (0, typeorm_1.Column)({
140
+ nullable: true,
141
+ default: null
142
+ }),
143
+ __metadata("design:type", Date)
144
+ ], StudentLicenceEntity.prototype, "issuedAt", void 0);
145
+ __decorate([
146
+ (0, typeorm_1.Column)({
147
+ nullable: true,
148
+ default: null
149
+ }),
150
+ __metadata("design:type", Date)
151
+ ], StudentLicenceEntity.prototype, "validFrom", void 0);
152
+ __decorate([
153
+ (0, typeorm_1.Column)(),
154
+ __metadata("design:type", Date)
155
+ ], StudentLicenceEntity.prototype, "validUntil", void 0);
156
+ __decorate([
157
+ (0, typeorm_1.Column)({
158
+ nullable: true,
159
+ default: null
160
+ }),
161
+ __metadata("design:type", String)
162
+ ], StudentLicenceEntity.prototype, "documentUrl", void 0);
163
+ __decorate([
164
+ (0, typeorm_1.Column)({
165
+ type: 'simple-json',
166
+ nullable: true,
167
+ default: null
168
+ }),
169
+ __metadata("design:type", common_1.Authority)
170
+ ], StudentLicenceEntity.prototype, "issuer", void 0);
171
+ __decorate([
172
+ (0, typeorm_1.ManyToOne)(() => student_entity_1.StudentEntity, student => student.licences),
173
+ __metadata("design:type", Promise)
174
+ ], StudentLicenceEntity.prototype, "student", void 0);
175
+ __decorate([
176
+ (0, typeorm_1.ManyToOne)(() => category_entity_1.DrivingCategoryEntity, category => category.studentLicences),
177
+ __metadata("design:type", Promise)
178
+ ], StudentLicenceEntity.prototype, "category", void 0);
179
+ __decorate([
180
+ (0, typeorm_1.ManyToMany)(() => program_entity_1.StudentProgramEntity, program => program.licences),
181
+ __metadata("design:type", Promise)
182
+ ], StudentLicenceEntity.prototype, "programs", void 0);
183
+ exports.StudentLicenceEntity = StudentLicenceEntity = __decorate([
184
+ (0, typeorm_1.Entity)('studentLicences'),
185
+ __metadata("design:paramtypes", [Object])
186
+ ], StudentLicenceEntity);
187
+ //# sourceMappingURL=licence.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"licence.entity.js","sourceRoot":"","sources":["../../../../../src/profile/student/program/licence/licence.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgE;AAChE,4CAA0F;AAC1F,yDAAqD;AACrD,gFAAmF;AACnF,sDAAyD;AACzD,6CAAgE;AAGzD,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,uBAAwB;IAEjE;;OAEG;IAEH,SAAS,CAAS;IAElB;;OAEG;IAEH,UAAU,CAAS;IAEnB;;;OAGG;IAYH,IAAI,CAAc;IAElB;;;OAGG;IAKH,IAAI,CAAS;I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