@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,95 @@
1
+ import { Activity, Alert, Language, SelectedProfile, StatusType } from '@driveup/common';
2
+ import { UserEntity } from './user.entity';
3
+ import { PolicyEntity } from '../system/policy/policy.entity';
4
+ import { TrackableEntity } from '../utils';
5
+ /**
6
+ * Represents a user alert or notification requiring action.
7
+ * Alerts can be system-generated (from policies) or manually created,
8
+ * and track completion, approval, or skip status.
9
+ * Each alert can be associated with a specific user profile and business event.
10
+ *
11
+ * @extends TrackableEntity
12
+ */
13
+ export declare class UserAlertEntity extends TrackableEntity<Alert> {
14
+ /**
15
+ * Reference to the user who receives this alert
16
+ */
17
+ userId: number;
18
+ /**
19
+ * Reference to the policy that generated this alert
20
+ * Null for manually created alerts
21
+ */
22
+ policyId: number;
23
+ /**
24
+ * Current status of the alert
25
+ * @default StatusType.Pending
26
+ */
27
+ status: StatusType;
28
+ /**
29
+ * Alert title
30
+ */
31
+ title: string;
32
+ /**
33
+ * Detailed alert message
34
+ */
35
+ message: string;
36
+ /**
37
+ * Business event associated with the alert.
38
+ */
39
+ event: string;
40
+ /**
41
+ * The profile type and company associated with the log entry.
42
+ * This is used to filter logs by profile and/or company.
43
+ */
44
+ profile: SelectedProfile;
45
+ /**
46
+ * Due date for completing the alert action
47
+ */
48
+ dueDate: Date;
49
+ /**
50
+ * Timestamp when the alert was completed
51
+ */
52
+ completedOn: Date;
53
+ /**
54
+ * Timestamp when the alert was skipped
55
+ */
56
+ skippedOn: Date;
57
+ /**
58
+ * Timestamp when the alert was approved
59
+ */
60
+ approvedOn: Date;
61
+ /**
62
+ * Reference to the user
63
+ */
64
+ user: Promise<UserEntity>;
65
+ /**
66
+ * Reference to the policy that generated this alert
67
+ */
68
+ policy: Promise<PolicyEntity>;
69
+ /**
70
+ * Creates an instance of UserAlertEntity
71
+ * @param props - Partial properties to initialize the entity
72
+ */
73
+ constructor(props?: Partial<UserAlertEntity>);
74
+ /**
75
+ * Converts the entity to an Alert model instance
76
+ * @returns Alert model with basic information
77
+ */
78
+ toModel(): Promise<Alert>;
79
+ /**
80
+ * Converts the entity to an Alert model instance
81
+ * @returns Alert model with basic information
82
+ */
83
+ toSummary(): Alert;
84
+ /**
85
+ * Retrieves the associated policy as a model
86
+ * @param lang - Language code for localization
87
+ * @returns Policy model or undefined if no policy is associated
88
+ */
89
+ toPolicy(lang: Language): Promise<import("@driveup/common").Policy>;
90
+ /**
91
+ * Retrieves all activity records for this alert
92
+ * @returns Array of Activity objects
93
+ */
94
+ getActivities(): Promise<Activity[]>;
95
+ }
@@ -0,0 +1,223 @@
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.UserAlertEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const user_entity_1 = require("./user.entity");
16
+ const policy_entity_1 = require("../system/policy/policy.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 user alert or notification requiring action.
22
+ * Alerts can be system-generated (from policies) or manually created,
23
+ * and track completion, approval, or skip status.
24
+ * Each alert can be associated with a specific user profile and business event.
25
+ *
26
+ * @extends TrackableEntity
27
+ */
28
+ let UserAlertEntity = class UserAlertEntity extends utils_2.TrackableEntity {
29
+ /**
30
+ * Reference to the user who receives this alert
31
+ */
32
+ userId;
33
+ /**
34
+ * Reference to the policy that generated this alert
35
+ * Null for manually created alerts
36
+ */
37
+ policyId;
38
+ /**
39
+ * Current status of the alert
40
+ * @default StatusType.Pending
41
+ */
42
+ status;
43
+ /**
44
+ * Alert title
45
+ */
46
+ title;
47
+ /**
48
+ * Detailed alert message
49
+ */
50
+ message;
51
+ /**
52
+ * Business event associated with the alert.
53
+ */
54
+ event;
55
+ /**
56
+ * The profile type and company associated with the log entry.
57
+ * This is used to filter logs by profile and/or company.
58
+ */
59
+ profile;
60
+ /**
61
+ * Due date for completing the alert action
62
+ */
63
+ dueDate;
64
+ /**
65
+ * Timestamp when the alert was completed
66
+ */
67
+ completedOn;
68
+ /**
69
+ * Timestamp when the alert was skipped
70
+ */
71
+ skippedOn;
72
+ /**
73
+ * Timestamp when the alert was approved
74
+ */
75
+ approvedOn;
76
+ /**
77
+ * Reference to the user
78
+ */
79
+ user;
80
+ /**
81
+ * Reference to the policy that generated this alert
82
+ */
83
+ policy;
84
+ /**
85
+ * Creates an instance of UserAlertEntity
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 an Alert model instance
94
+ * @returns Alert model with basic information
95
+ */
96
+ async toModel() {
97
+ const policy = this.policyId ? (await this.policy)?.toSummary() : undefined;
98
+ const activities = await this.getActivities();
99
+ return new common_1.Alert({
100
+ id: this.id,
101
+ policy: policy,
102
+ activities: activities,
103
+ event: this.event,
104
+ title: this.title,
105
+ message: this.message,
106
+ dueDate: this.dueDate
107
+ });
108
+ }
109
+ /**
110
+ * Converts the entity to an Alert model instance
111
+ * @returns Alert model with basic information
112
+ */
113
+ toSummary() {
114
+ return new common_1.Alert({
115
+ id: this.id,
116
+ title: this.title,
117
+ message: this.message,
118
+ dueDate: this.dueDate,
119
+ });
120
+ }
121
+ /**
122
+ * Retrieves the associated policy as a model
123
+ * @param lang - Language code for localization
124
+ * @returns Policy model or undefined if no policy is associated
125
+ */
126
+ async toPolicy(lang) {
127
+ if (!this.policyId)
128
+ return;
129
+ return (await this.policy).toModel(lang);
130
+ }
131
+ /**
132
+ * Retrieves all activity records for this alert
133
+ * @returns Array of Activity objects
134
+ */
135
+ async getActivities() {
136
+ const activities = [];
137
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy, staff_entity_1.StaffEntity));
138
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
139
+ activities.push(await (0, utils_1.toActivity)(this.completedOn, common_1.ActivityType.completedOn));
140
+ activities.push(await (0, utils_1.toActivity)(this.skippedOn, common_1.ActivityType.skippedOn));
141
+ activities.push(await (0, utils_1.toActivity)(this.approvedOn, common_1.ActivityType.approvedOn));
142
+ return activities.filter(a => a);
143
+ }
144
+ };
145
+ exports.UserAlertEntity = UserAlertEntity;
146
+ __decorate([
147
+ (0, typeorm_1.Column)(),
148
+ __metadata("design:type", Number)
149
+ ], UserAlertEntity.prototype, "userId", void 0);
150
+ __decorate([
151
+ (0, typeorm_1.Column)({
152
+ nullable: true,
153
+ default: null
154
+ }),
155
+ __metadata("design:type", Number)
156
+ ], UserAlertEntity.prototype, "policyId", void 0);
157
+ __decorate([
158
+ (0, typeorm_1.Column)({
159
+ type: 'enum',
160
+ enum: [
161
+ common_1.StatusType.Pending,
162
+ common_1.StatusType.Completed,
163
+ common_1.StatusType.Approved,
164
+ common_1.StatusType.Skipped,
165
+ common_1.StatusType.Overdate,
166
+ ],
167
+ default: common_1.StatusType.Pending,
168
+ nullable: false
169
+ }),
170
+ __metadata("design:type", String)
171
+ ], UserAlertEntity.prototype, "status", void 0);
172
+ __decorate([
173
+ (0, typeorm_1.Column)(),
174
+ __metadata("design:type", String)
175
+ ], UserAlertEntity.prototype, "title", void 0);
176
+ __decorate([
177
+ (0, typeorm_1.Column)(),
178
+ __metadata("design:type", String)
179
+ ], UserAlertEntity.prototype, "message", void 0);
180
+ __decorate([
181
+ (0, typeorm_1.Column)({
182
+ nullable: true,
183
+ default: null
184
+ }),
185
+ __metadata("design:type", String)
186
+ ], UserAlertEntity.prototype, "event", void 0);
187
+ __decorate([
188
+ (0, typeorm_1.Column)({
189
+ type: 'simple-json',
190
+ nullable: true,
191
+ default: null
192
+ }),
193
+ __metadata("design:type", Object)
194
+ ], UserAlertEntity.prototype, "profile", void 0);
195
+ __decorate([
196
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
197
+ __metadata("design:type", Date)
198
+ ], UserAlertEntity.prototype, "dueDate", void 0);
199
+ __decorate([
200
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
201
+ __metadata("design:type", Date)
202
+ ], UserAlertEntity.prototype, "completedOn", void 0);
203
+ __decorate([
204
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
205
+ __metadata("design:type", Date)
206
+ ], UserAlertEntity.prototype, "skippedOn", void 0);
207
+ __decorate([
208
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
209
+ __metadata("design:type", Date)
210
+ ], UserAlertEntity.prototype, "approvedOn", void 0);
211
+ __decorate([
212
+ (0, typeorm_1.ManyToOne)(() => user_entity_1.UserEntity, user => user.alerts),
213
+ __metadata("design:type", Promise)
214
+ ], UserAlertEntity.prototype, "user", void 0);
215
+ __decorate([
216
+ (0, typeorm_1.ManyToOne)(() => policy_entity_1.PolicyEntity, policy => policy.alerts),
217
+ __metadata("design:type", Promise)
218
+ ], UserAlertEntity.prototype, "policy", void 0);
219
+ exports.UserAlertEntity = UserAlertEntity = __decorate([
220
+ (0, typeorm_1.Entity)('userAlerts'),
221
+ __metadata("design:paramtypes", [Object])
222
+ ], UserAlertEntity);
223
+ //# sourceMappingURL=alert.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert.entity.js","sourceRoot":"","sources":["../../src/user/alert.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAoD;AACpD,4CAAuG;AACvG,+CAA2C;AAC3C,kEAA8D;AAC9D,oCAAsC;AACtC,+DAA2D;AAC3D,oCAA2C;AAE3C;;;;;;;GAOG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,uBAAsB;IAE1D;;OAEG;IAEH,MAAM,CAAS;IAEf;;;OAGG;IAKH,QAAQ,CAAS;IAEjB;;;OAGG;IAaH,MAAM,CAAa;IAEnB;;OAEG;IAEH,KAAK,CAAS;IAEd;;OAEG;IAEH,OAAO,CAAS;IAEhB;;OAEG;IAKH,KAAK,CAAS;IAEd;;;OAGG;IAMH,OAAO,CAAkB;IAEzB;;OAEG;IAEH,OAAO,CAAO;IAEd;;OAEG;IAEH,WAAW,CAAO;IAElB;;OAEG;IAEH,SAAS,CAAO;IAEhB;;OAEG;IAEH,UAAU,CAAO;IAEjB;;OAEG;IAEH,IAAI,CAAsB;IAE1B;;OAEG;IAEH,MAAM,CAAwB;IAE9B;;;OAGG;IACH,YAAY,KAAgC;QAC3C,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,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5E,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAC9C,OAAO,IAAI,cAAK,CAAC;YAChB,EAAE,EAAE,IAAI,CAAC,EAAE;YAC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AAC;8BAC/B,IAAI;kDAAC;AAMhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BAC9B,IAAI;mDAAC;AAMjB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAU,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;;6CACvB;AAM1B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,4BAAY,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;;+CACzB;0BAtGlB,eAAe;IAD3B,IAAA,gBAAM,EAAC,YAAY,CAAC;;GACR,eAAe,CAuK3B"}
@@ -0,0 +1,42 @@
1
+ import { Activity } from '@driveup/common';
2
+ import { TrackableEntity } from '../utils';
3
+ /**
4
+ * Represents a blocked phone number.
5
+ * Used to prevent accounts from being created with specific phone numbers.
6
+ * Blocks can be permanent or temporary (until a specific date).
7
+ *
8
+ * @extends TrackableEntity
9
+ */
10
+ export declare class UserBlockedPhoneNumberEntity extends TrackableEntity {
11
+ /**
12
+ * The blocked phone number
13
+ */
14
+ phone: string;
15
+ /**
16
+ * Date until which the phone number is blocked
17
+ * Null means permanent block
18
+ */
19
+ until: Date;
20
+ /**
21
+ * Creates an instance of UserBlockedPhoneNumberEntity
22
+ * @param props - Partial properties to initialize the entity
23
+ */
24
+ constructor(props?: Partial<UserBlockedPhoneNumberEntity>);
25
+ toModel(): {
26
+ phone: string;
27
+ until: Date;
28
+ };
29
+ /**
30
+ * Creates an instance of UserBlockedPhoneNumberEntity
31
+ * @param props - Partial properties to initialize the entity
32
+ */
33
+ toSummary(): {
34
+ phone: string;
35
+ until: Date;
36
+ };
37
+ /**
38
+ * Retrieves all activity records for this blocked number
39
+ * @returns Array of Activity objects
40
+ */
41
+ getActivities(): Promise<Activity[]>;
42
+ }
@@ -0,0 +1,83 @@
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.UserBlockedPhoneNumberEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const common_1 = require("@driveup/common");
15
+ const utils_1 = require("../utils");
16
+ /**
17
+ * Represents a blocked phone number.
18
+ * Used to prevent accounts from being created with specific phone numbers.
19
+ * Blocks can be permanent or temporary (until a specific date).
20
+ *
21
+ * @extends TrackableEntity
22
+ */
23
+ let UserBlockedPhoneNumberEntity = class UserBlockedPhoneNumberEntity extends utils_1.TrackableEntity {
24
+ /**
25
+ * The blocked phone number
26
+ */
27
+ phone;
28
+ /**
29
+ * Date until which the phone number is blocked
30
+ * Null means permanent block
31
+ */
32
+ until;
33
+ /**
34
+ * Creates an instance of UserBlockedPhoneNumberEntity
35
+ * @param props - Partial properties to initialize the entity
36
+ */
37
+ constructor(props) {
38
+ super();
39
+ Object.assign(this, props);
40
+ }
41
+ toModel() {
42
+ return {
43
+ phone: this.phone,
44
+ until: this.until
45
+ };
46
+ }
47
+ /**
48
+ * Creates an instance of UserBlockedPhoneNumberEntity
49
+ * @param props - Partial properties to initialize the entity
50
+ */
51
+ toSummary() {
52
+ return this.toModel();
53
+ }
54
+ /**
55
+ * Retrieves all activity records for this blocked number
56
+ * @returns Array of Activity objects
57
+ */
58
+ async getActivities() {
59
+ const activities = [];
60
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
61
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
62
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
63
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
64
+ return activities.filter(a => a);
65
+ }
66
+ };
67
+ exports.UserBlockedPhoneNumberEntity = UserBlockedPhoneNumberEntity;
68
+ __decorate([
69
+ (0, typeorm_1.Column)(),
70
+ __metadata("design:type", String)
71
+ ], UserBlockedPhoneNumberEntity.prototype, "phone", void 0);
72
+ __decorate([
73
+ (0, typeorm_1.Column)({
74
+ nullable: true,
75
+ default: null
76
+ }),
77
+ __metadata("design:type", Date)
78
+ ], UserBlockedPhoneNumberEntity.prototype, "until", void 0);
79
+ exports.UserBlockedPhoneNumberEntity = UserBlockedPhoneNumberEntity = __decorate([
80
+ (0, typeorm_1.Entity)('userBlockedPhoneNumbers'),
81
+ __metadata("design:paramtypes", [Object])
82
+ ], UserBlockedPhoneNumberEntity);
83
+ //# sourceMappingURL=blocked.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocked.entity.js","sourceRoot":"","sources":["../../src/user/blocked.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAyC;AACzC,4CAAyD;AACzD,oCAAuD;AAEvD;;;;;;GAMG;AAEI,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,uBAAe;IAEhE;;OAEG;IAEH,KAAK,CAAS;IAEd;;;OAGG;IAKH,KAAK,CAAO;IAEZ;;;OAGG;IACH,YAAY,KAA6C;QACxD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO;QACN,OAAO;YACN,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;SACjB,CAAA;IACF,CAAC;IAED;;;OAGG;IACH,SAAS;QACR,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa;QAClB,MAAM,UAAU,GAAe,EAAE,CAAC;QAClC,UAAU,CAAC,IAAI,CAAC,MAAM,IAAA,kBAAU,EAAC,IAAI,CAAC,SAAS,EAAE,qBAAY,CAAC,SAAS,CAAC,CAAC,CAAC;QAC1E,UAAU,CAAC,IAAI,CAAC,MAAM,IAAA,kBAAU,EAAC,IAAI,CAAC,SAAS,EAAE,qBAAY,CAAC,SAAS,CAAC,CAAC,CAAC;QAC1E,UAAU,CAAC,IAAI,CAAC,MAAM,IAAA,kBAAU,EAAC,IAAI,CAAC,SAAS,EAAE,qBAAY,CAAC,SAAS,CAAC,CAAC,CAAC;QAC1E,UAAU,CAAC,IAAI,CAAC,MAAM,IAAA,kBAAU,EAAC,IAAI,CAAC,SAAS,EAAE,qBAAY,CAAC,SAAS,CAAC,CAAC,CAAC;QAC1E,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;CACD,CAAA;AAtDY,oEAA4B;AAMxC;IADC,IAAA,gBAAM,GAAE;;2DACK;AAUd;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;8BACK,IAAI;2DAAC;uCAhBA,4BAA4B;IADxC,IAAA,gBAAM,EAAC,yBAAyB,CAAC;;GACrB,4BAA4B,CAsDxC"}
@@ -0,0 +1,72 @@
1
+ import { UserEntity } from './user.entity';
2
+ import { Activity, Device } from '@driveup/common';
3
+ import { TrackableEntity } from '../utils';
4
+ /**
5
+ * Represents a user's registered device for push notifications and authentication.
6
+ * Tracks device information including model, OS, and unique identifiers.
7
+ * Used for sending FCM notifications and device management.
8
+ *
9
+ * @extends TrackableEntity
10
+ */
11
+ export declare class UserDeviceEntity extends TrackableEntity<Device> {
12
+ /**
13
+ * Reference to the user who owns this device
14
+ */
15
+ userId: number;
16
+ /**
17
+ * Global unique identifier for the device
18
+ */
19
+ guid: string;
20
+ /**
21
+ * FCM token or device signature for push notifications
22
+ */
23
+ signature: string;
24
+ /**
25
+ * Device model (e.g., "iPhone 12", "Samsung Galaxy S21")
26
+ */
27
+ model: string;
28
+ /**
29
+ * Device name as set by the user
30
+ */
31
+ name: string;
32
+ /**
33
+ * Device manufacturer brand
34
+ */
35
+ brand: string;
36
+ /**
37
+ * Operating system (e.g., "iOS 15", "Android 12")
38
+ */
39
+ os: string;
40
+ /**
41
+ * Device language setting
42
+ */
43
+ language: string;
44
+ /**
45
+ * User custom description for the device
46
+ */
47
+ description: string;
48
+ /**
49
+ * Reference to the device owner
50
+ */
51
+ user: Promise<UserEntity>;
52
+ /**
53
+ * Creates an instance of UserDeviceEntity
54
+ * @param props - Partial properties to initialize the entity
55
+ */
56
+ constructor(props?: Partial<UserDeviceEntity>);
57
+ /**
58
+ * Converts the entity to a Device model instance
59
+ * @returns Device model with all device information
60
+ */
61
+ toModel(): Device;
62
+ /**
63
+ * Returns a summary representation of the device
64
+ * @returns Model instance (same as toModel())
65
+ */
66
+ toSummary(): Device;
67
+ /**
68
+ * Retrieves all activity records for this device
69
+ * @returns Array of Activity objects
70
+ */
71
+ getActivities(): Promise<Activity[]>;
72
+ }