@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,142 @@
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.UserVerificationEntity = 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 verification token for phone or email verification.
18
+ * Used for account verification, password recovery, and other secure operations.
19
+ * Tokens have expiration dates and track confirmation attempts.
20
+ *
21
+ * @extends TrackableEntity
22
+ */
23
+ let UserVerificationEntity = class UserVerificationEntity extends utils_1.TrackableEntity {
24
+ /**
25
+ * Phone number to be verified
26
+ */
27
+ phone;
28
+ /**
29
+ * Email address to be verified
30
+ */
31
+ email;
32
+ /**
33
+ * Verification token (OTP or UUID)
34
+ */
35
+ token;
36
+ /**
37
+ * Optional URL for email verification links
38
+ */
39
+ url;
40
+ /**
41
+ * Whether the verification has been confirmed
42
+ * @default false
43
+ */
44
+ confirmed;
45
+ /**
46
+ * Expiration date/time for the verification token
47
+ */
48
+ expiredOn;
49
+ /**
50
+ * Number of verification attempts made
51
+ * @default 0
52
+ */
53
+ attempts;
54
+ /**
55
+ * Creates an instance of UserVerificationEntity
56
+ * @param props - Partial properties to initialize the entity
57
+ */
58
+ constructor(props) {
59
+ super();
60
+ Object.assign(this, props);
61
+ }
62
+ toModel() {
63
+ return {
64
+ id: this.id,
65
+ phone: this.phone,
66
+ email: this.email,
67
+ token: this.token,
68
+ url: this.url,
69
+ confirmed: this.confirmed,
70
+ expiredOn: this.expiredOn,
71
+ attempts: this.attempts,
72
+ };
73
+ }
74
+ /**
75
+ * Returns a summary representation of the user
76
+ * @returns Model instance (same as toModel())
77
+ */
78
+ toSummary() {
79
+ return this.toModel();
80
+ }
81
+ /**
82
+ * Retrieves all activity records for this verification
83
+ * @returns Array of Activity objects
84
+ */
85
+ async getActivities() {
86
+ const activities = [];
87
+ activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
88
+ activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
89
+ activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
90
+ activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
91
+ return activities.filter(a => a);
92
+ }
93
+ };
94
+ exports.UserVerificationEntity = UserVerificationEntity;
95
+ __decorate([
96
+ (0, typeorm_1.Column)({
97
+ nullable: true,
98
+ default: null
99
+ }),
100
+ __metadata("design:type", String)
101
+ ], UserVerificationEntity.prototype, "phone", void 0);
102
+ __decorate([
103
+ (0, typeorm_1.Column)({
104
+ nullable: true,
105
+ default: null
106
+ }),
107
+ __metadata("design:type", String)
108
+ ], UserVerificationEntity.prototype, "email", void 0);
109
+ __decorate([
110
+ (0, typeorm_1.Column)(),
111
+ __metadata("design:type", String)
112
+ ], UserVerificationEntity.prototype, "token", void 0);
113
+ __decorate([
114
+ (0, typeorm_1.Column)({
115
+ nullable: true,
116
+ default: null
117
+ }),
118
+ __metadata("design:type", String)
119
+ ], UserVerificationEntity.prototype, "url", void 0);
120
+ __decorate([
121
+ (0, typeorm_1.Column)({
122
+ nullable: true,
123
+ default: false
124
+ }),
125
+ __metadata("design:type", Boolean)
126
+ ], UserVerificationEntity.prototype, "confirmed", void 0);
127
+ __decorate([
128
+ (0, typeorm_1.Column)({
129
+ nullable: true,
130
+ default: null
131
+ }),
132
+ __metadata("design:type", Date)
133
+ ], UserVerificationEntity.prototype, "expiredOn", void 0);
134
+ __decorate([
135
+ (0, typeorm_1.Column)({ default: 0 }),
136
+ __metadata("design:type", Number)
137
+ ], UserVerificationEntity.prototype, "attempts", void 0);
138
+ exports.UserVerificationEntity = UserVerificationEntity = __decorate([
139
+ (0, typeorm_1.Entity)('userVerifications'),
140
+ __metadata("design:paramtypes", [Object])
141
+ ], UserVerificationEntity);
142
+ //# sourceMappingURL=verification.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verification.entity.js","sourceRoot":"","sources":["../../src/user/verification.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAyC;AACzC,4CAAyD;AACzD,oCAAuD;AAEvD;;;;;;GAMG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,uBAAe;IAE1D;;OAEG;IAKH,KAAK,CAAS;IAEd;;OAEG;IAKH,KAAK,CAAS;IAEd;;OAEG;IAEH,KAAK,CAAS;IAEd;;OAEG;IAKH,GAAG,CAAS;IAEZ;;;OAGG;IAKH,SAAS,CAAU;IAEnB;;OAEG;IAKH,SAAS,CAAO;IAEhB;;;OAGG;IAEH,QAAQ,CAAS;IAEjB;;;OAGG;IACH,YAAY,KAAuC;QAClD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO;QACN,OAAO;YACN,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACvB,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;AAvGY,wDAAsB;AASlC;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;qDACY;AASd;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;qDACY;AAMd;IADC,IAAA,gBAAM,GAAE;;qDACK;AASd;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;mDACU;AAUZ;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,KAAK;KACd,CAAC;;yDACiB;AASnB;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;8BACS,IAAI;yDAAC;AAOhB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;wDACN;iCA3DL,sBAAsB;IADlC,IAAA,gBAAM,EAAC,mBAAmB,CAAC;;GACf,sBAAsB,CAuGlC"}
@@ -0,0 +1,26 @@
1
+ import { Activity, ActivityType, Person } from "@driveup/common";
2
+ import { BaseEntity } from "typeorm";
3
+ /**
4
+ * Creates an Activity instance from a value and activity type.
5
+ * Handles both user ID references (for 'by' activities) and Date values (for 'on' activities).
6
+ *
7
+ * This utility function is used to transform tracking fields (createdBy, updatedBy, etc.)
8
+ * into Activity objects with person or date information.
9
+ *
10
+ * @template T - Entity type that extends BaseEntity and has a toPerson method
11
+ * @param value - Either a user ID (number) or a Date
12
+ * @param type - The type of activity (e.g., createdBy, updatedBy, createdOn)
13
+ * @param entityClass - Entity class to fetch user data from (defaults to UserEntity)
14
+ * @returns Promise resolving to Activity instance or undefined if no value provided
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const createdActivity = await toActivity(this.createdBy, ActivityType.createdBy, StaffEntity);
19
+ * const createdOnActivity = await toActivity(this.createdOn, ActivityType.createdOn);
20
+ * ```
21
+ */
22
+ export declare function toActivity<T extends BaseEntity>(value: number | Date, type: ActivityType, entityClass?: {
23
+ findOneBy: (criteria: any) => Promise<T & {
24
+ toPerson: () => Person;
25
+ }>;
26
+ }): Promise<Activity | undefined>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toActivity = toActivity;
4
+ const common_1 = require("@driveup/common");
5
+ const user_entity_1 = require("../user/user.entity");
6
+ /**
7
+ * Creates an Activity instance from a value and activity type.
8
+ * Handles both user ID references (for 'by' activities) and Date values (for 'on' activities).
9
+ *
10
+ * This utility function is used to transform tracking fields (createdBy, updatedBy, etc.)
11
+ * into Activity objects with person or date information.
12
+ *
13
+ * @template T - Entity type that extends BaseEntity and has a toPerson method
14
+ * @param value - Either a user ID (number) or a Date
15
+ * @param type - The type of activity (e.g., createdBy, updatedBy, createdOn)
16
+ * @param entityClass - Entity class to fetch user data from (defaults to UserEntity)
17
+ * @returns Promise resolving to Activity instance or undefined if no value provided
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const createdActivity = await toActivity(this.createdBy, ActivityType.createdBy, StaffEntity);
22
+ * const createdOnActivity = await toActivity(this.createdOn, ActivityType.createdOn);
23
+ * ```
24
+ */
25
+ async function toActivity(value, type, entityClass = user_entity_1.UserEntity) {
26
+ if (!value)
27
+ return;
28
+ if (typeof value === 'number') {
29
+ const id = value;
30
+ const entity = await entityClass.findOneBy({ id });
31
+ const person = entity?.toPerson();
32
+ return new common_1.Activity({ type, person });
33
+ }
34
+ if (value instanceof Date) {
35
+ return new common_1.Activity({ type, date: value });
36
+ }
37
+ return;
38
+ }
39
+ //# sourceMappingURL=activity.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity.helper.js","sourceRoot":"","sources":["../../src/utils/activity.helper.ts"],"names":[],"mappings":";;AAuBA,gCAkBC;AAzCD,4CAAiE;AAEjE,qDAAiD;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACI,KAAK,UAAU,UAAU,CAC/B,KAAoB,EACpB,IAAkB,EAClB,cAEI,wBAAU;IAEd,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,EAAE,GAAG,KAAe,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CAAC,EAAC,EAAE,EAAC,CAAC,CAAA;QAChD,MAAM,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,CAAC;QAClC,OAAO,IAAI,iBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QAC3B,OAAO,IAAI,iBAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO;AACR,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './activity.helper';
2
+ export * from './json-metrics.transform';
3
+ export * from './numeric.transform';
4
+ export * from './trackable.entity';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./activity.helper"), exports);
18
+ __exportStar(require("./json-metrics.transform"), exports);
19
+ __exportStar(require("./numeric.transform"), exports);
20
+ __exportStar(require("./trackable.entity"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,2DAAyC;AACzC,sDAAoC;AACpC,qDAAmC"}
@@ -0,0 +1,35 @@
1
+ import { ValueTransformer } from 'typeorm';
2
+ /**
3
+ * TypeORM value transformer for JSON metrics columns.
4
+ * Converts metric values in JSON objects to numeric types, ensuring all values
5
+ * are valid numbers (defaulting to 0 for invalid or null values).
6
+ * Useful for database columns that store metrics as JSON key-value pairs.
7
+ *
8
+ * @implements {ValueTransformer}
9
+ * @example
10
+ * ```typescript
11
+ * @Column({
12
+ * type: 'json',
13
+ * transformer: new ColumnJsonMetricsTransformer()
14
+ * })
15
+ * metrics: Record<string, number>;
16
+ * ```
17
+ */
18
+ export declare class ColumnJsonMetricsTransformer implements ValueTransformer {
19
+ /**
20
+ * Transforms a JSON object before persisting to the database.
21
+ * Converts all values in the JSON object to numbers, defaulting to 0 for invalid values.
22
+ *
23
+ * @param json - The JSON object to transform
24
+ * @returns Transformed JSON object with numeric values, or null if input is null/undefined
25
+ */
26
+ to(json?: Record<string, any> | null): Record<string, any> | null;
27
+ /**
28
+ * Transforms a JSON object when loading from the database.
29
+ * Converts all values in the JSON object to numbers, defaulting to 0 for invalid values.
30
+ *
31
+ * @param json - The JSON object loaded from the database
32
+ * @returns Transformed JSON object with numeric values, or null if input is null/undefined
33
+ */
34
+ from(json?: Record<string, any> | null): Record<string, any> | null;
35
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColumnJsonMetricsTransformer = void 0;
4
+ /**
5
+ * Type guard that checks if a value is null or undefined.
6
+ *
7
+ * @template T - The type of the value being checked
8
+ * @param obj - The value to check
9
+ * @returns True if the value is null or undefined, false otherwise
10
+ */
11
+ function isNullOrUndefined(obj) {
12
+ return typeof obj === 'undefined' || obj === null;
13
+ }
14
+ /**
15
+ * TypeORM value transformer for JSON metrics columns.
16
+ * Converts metric values in JSON objects to numeric types, ensuring all values
17
+ * are valid numbers (defaulting to 0 for invalid or null values).
18
+ * Useful for database columns that store metrics as JSON key-value pairs.
19
+ *
20
+ * @implements {ValueTransformer}
21
+ * @example
22
+ * ```typescript
23
+ * @Column({
24
+ * type: 'json',
25
+ * transformer: new ColumnJsonMetricsTransformer()
26
+ * })
27
+ * metrics: Record<string, number>;
28
+ * ```
29
+ */
30
+ class ColumnJsonMetricsTransformer {
31
+ /**
32
+ * Transforms a JSON object before persisting to the database.
33
+ * Converts all values in the JSON object to numbers, defaulting to 0 for invalid values.
34
+ *
35
+ * @param json - The JSON object to transform
36
+ * @returns Transformed JSON object with numeric values, or null if input is null/undefined
37
+ */
38
+ to(json) {
39
+ if (!isNullOrUndefined(json)) {
40
+ for (const key in json) {
41
+ if (Object.prototype.hasOwnProperty.call(json, key)) {
42
+ const value = json[key];
43
+ if (!isNullOrUndefined(value)) {
44
+ const res = parseFloat(value);
45
+ json[key] = isNaN(res) ? 0 : res;
46
+ }
47
+ else {
48
+ json[key] = 0;
49
+ }
50
+ }
51
+ }
52
+ return json;
53
+ }
54
+ return null;
55
+ }
56
+ /**
57
+ * Transforms a JSON object when loading from the database.
58
+ * Converts all values in the JSON object to numbers, defaulting to 0 for invalid values.
59
+ *
60
+ * @param json - The JSON object loaded from the database
61
+ * @returns Transformed JSON object with numeric values, or null if input is null/undefined
62
+ */
63
+ from(json) {
64
+ if (!isNullOrUndefined(json)) {
65
+ for (const key in json) {
66
+ if (Object.prototype.hasOwnProperty.call(json, key)) {
67
+ const value = json[key];
68
+ if (!isNullOrUndefined(value)) {
69
+ const res = parseFloat(value);
70
+ json[key] = isNaN(res) ? 0 : res;
71
+ }
72
+ else {
73
+ json[key] = 0;
74
+ }
75
+ }
76
+ }
77
+ return json;
78
+ }
79
+ return null;
80
+ }
81
+ }
82
+ exports.ColumnJsonMetricsTransformer = ColumnJsonMetricsTransformer;
83
+ //# sourceMappingURL=json-metrics.transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-metrics.transform.js","sourceRoot":"","sources":["../../src/utils/json-metrics.transform.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAI,GAAyB;IACtD,OAAO,OAAO,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,IAAI,CAAC;AACnD,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAa,4BAA4B;IACxC;;;;;;OAMG;IACH,EAAE,CAAC,IAAiC;QACnC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACxB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;oBACrD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;oBACxB,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;wBAC/B,MAAM,GAAG,GAAG,UAAU,CAAC,KAAY,CAAC,CAAC;wBACrC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;oBAClC,CAAC;yBAAM,CAAC;wBACP,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBACf,CAAC;gBACF,CAAC;YACF,CAAC;YACD,OAAO,IAAW,CAAC;QACpB,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;;OAMG;IACH,IAAI,CAAC,IAAiC;QACrC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACxB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;oBACrD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;oBACxB,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;wBAC/B,MAAM,GAAG,GAAG,UAAU,CAAC,KAAY,CAAC,CAAC;wBACrC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;oBAClC,CAAC;yBAAM,CAAC;wBACP,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBACf,CAAC;gBACF,CAAC;YACF,CAAC;YACD,OAAO,IAAW,CAAC;QACpB,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAlDD,oEAkDC"}
@@ -0,0 +1,38 @@
1
+ import { ValueTransformer } from 'typeorm';
2
+ /**
3
+ * TypeORM value transformer for numeric columns.
4
+ * Handles conversion between JavaScript numbers and database numeric types,
5
+ * ensuring values are valid numbers (defaulting to 0 for invalid or null values).
6
+ * Particularly useful for DECIMAL columns that may return string values from the database.
7
+ *
8
+ * @implements {ValueTransformer}
9
+ * @example
10
+ * ```typescript
11
+ * @Column({
12
+ * type: 'decimal',
13
+ * precision: 8,
14
+ * scale: 2,
15
+ * transformer: new ColumnNumericTransformer()
16
+ * })
17
+ * price: number;
18
+ * ```
19
+ */
20
+ export declare class ColumnNumericTransformer implements ValueTransformer {
21
+ /**
22
+ * Transforms a number value before persisting to the database.
23
+ * Converts the value to a float, defaulting to 0 for invalid or null values.
24
+ *
25
+ * @param val - The number value to transform
26
+ * @returns Validated numeric value, or 0 if input is invalid or null/undefined
27
+ */
28
+ to(val?: number | null): number | null;
29
+ /**
30
+ * Transforms a string value when loading from the database.
31
+ * Converts the string to a float number, defaulting to 0 for invalid or null values.
32
+ * Database DECIMAL columns often return values as strings, so this conversion is necessary.
33
+ *
34
+ * @param val - The string value loaded from the database
35
+ * @returns Parsed numeric value, or 0 if input is invalid or null/undefined
36
+ */
37
+ from(val?: string | null): number | null;
38
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColumnNumericTransformer = void 0;
4
+ /**
5
+ * Type guard that checks if a value is null or undefined.
6
+ *
7
+ * @template T - The type of the value being checked
8
+ * @param obj - The value to check
9
+ * @returns True if the value is null or undefined, false otherwise
10
+ */
11
+ function isNullOrUndefined(obj) {
12
+ return typeof obj === 'undefined' || obj === null;
13
+ }
14
+ /**
15
+ * TypeORM value transformer for numeric columns.
16
+ * Handles conversion between JavaScript numbers and database numeric types,
17
+ * ensuring values are valid numbers (defaulting to 0 for invalid or null values).
18
+ * Particularly useful for DECIMAL columns that may return string values from the database.
19
+ *
20
+ * @implements {ValueTransformer}
21
+ * @example
22
+ * ```typescript
23
+ * @Column({
24
+ * type: 'decimal',
25
+ * precision: 8,
26
+ * scale: 2,
27
+ * transformer: new ColumnNumericTransformer()
28
+ * })
29
+ * price: number;
30
+ * ```
31
+ */
32
+ class ColumnNumericTransformer {
33
+ /**
34
+ * Transforms a number value before persisting to the database.
35
+ * Converts the value to a float, defaulting to 0 for invalid or null values.
36
+ *
37
+ * @param val - The number value to transform
38
+ * @returns Validated numeric value, or 0 if input is invalid or null/undefined
39
+ */
40
+ to(val) {
41
+ if (!isNullOrUndefined(val)) {
42
+ const res = parseFloat(val);
43
+ if (isNaN(res)) {
44
+ return 0;
45
+ }
46
+ else {
47
+ return res;
48
+ }
49
+ }
50
+ return 0;
51
+ }
52
+ /**
53
+ * Transforms a string value when loading from the database.
54
+ * Converts the string to a float number, defaulting to 0 for invalid or null values.
55
+ * Database DECIMAL columns often return values as strings, so this conversion is necessary.
56
+ *
57
+ * @param val - The string value loaded from the database
58
+ * @returns Parsed numeric value, or 0 if input is invalid or null/undefined
59
+ */
60
+ from(val) {
61
+ if (!isNullOrUndefined(val)) {
62
+ const res = parseFloat(val);
63
+ if (isNaN(res)) {
64
+ return 0;
65
+ }
66
+ else {
67
+ return res;
68
+ }
69
+ }
70
+ return 0;
71
+ }
72
+ }
73
+ exports.ColumnNumericTransformer = ColumnNumericTransformer;
74
+ //# sourceMappingURL=numeric.transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numeric.transform.js","sourceRoot":"","sources":["../../src/utils/numeric.transform.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAI,GAAyB;IACtD,OAAO,OAAO,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,IAAI,CAAC;AACnD,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,wBAAwB;IACpC;;;;;;OAMG;IACH,EAAE,CAAC,GAAmB;QACrB,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,GAAG,GAAG,UAAU,CAAC,GAAU,CAAC,CAAC;YACnC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChB,OAAO,CAAC,CAAC;YACV,CAAC;iBAAM,CAAC;gBACP,OAAO,GAAG,CAAC;YACZ,CAAC;QACF,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,CAAC,GAAmB;QACvB,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,GAAG,GAAG,UAAU,CAAC,GAAU,CAAC,CAAC;YACnC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChB,OAAO,CAAC,CAAC;YACV,CAAC;iBAAM,CAAC;gBACP,OAAO,GAAG,CAAC;YACZ,CAAC;QACF,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;CACD;AAvCD,4DAuCC"}
@@ -0,0 +1,82 @@
1
+ import { Activity, Language } from '@driveup/common';
2
+ import { BaseEntity } from 'typeorm';
3
+ /**
4
+ * Abstract base entity with comprehensive audit tracking properties.
5
+ * Provides automatic tracking of creation, updates, and soft deletion with user attribution.
6
+ * All entities requiring an audit trail should extend this class.
7
+ *
8
+ * @template T - The model type that the entity converts to
9
+ * @extends BaseEntity
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * @Entity('users')
14
+ * export class UserEntity extends TrackableEntity<User> {
15
+ * // entity properties
16
+ *
17
+ * toModel() {
18
+ * return new User({ id: this.id, ... });
19
+ * }
20
+ *
21
+ * async getActivities() {
22
+ * return [];
23
+ * }
24
+ * }
25
+ * ```
26
+ */
27
+ export declare abstract class TrackableEntity<T = any> extends BaseEntity {
28
+ /**
29
+ * Primary key - auto-generated sequential ID
30
+ */
31
+ id: number;
32
+ /**
33
+ * ID of the user who created this entity
34
+ */
35
+ createdBy: number;
36
+ /**
37
+ * Timestamp when the entity was created
38
+ * Automatically set by TypeORM
39
+ */
40
+ createdOn: Date;
41
+ /**
42
+ * ID of the user who last updated this entity
43
+ */
44
+ updatedBy: number;
45
+ /**
46
+ * Timestamp when the entity was last updated
47
+ * Automatically updated by TypeORM
48
+ */
49
+ updatedOn: Date;
50
+ /**
51
+ * ID of the user who soft-deleted this entity
52
+ */
53
+ deletedBy: number;
54
+ /**
55
+ * Timestamp when the entity was soft-deleted
56
+ * When set, the entity is excluded from normal queries
57
+ */
58
+ deletedOn: Date;
59
+ /**
60
+ * Converts the entity to its corresponding model instance.
61
+ * Must be implemented by child classes to define transformation logic.
62
+ *
63
+ * @param lang - Optional language for localized content
64
+ * @returns Model instance or Promise resolving to model instance
65
+ */
66
+ abstract toModel(lang?: Language): T | Promise<T>;
67
+ /**
68
+ * Converts the entity to a summary representation.
69
+ * Must be implemented by child classes to define summary transformation logic.
70
+ *
71
+ * @param lang - Optional language for localized content
72
+ * @returns Summary model instance or Promise resolving to summary model instance
73
+ */
74
+ abstract toSummary(lang?: Language): T | Promise<T>;
75
+ /**
76
+ * Retrieves all activity records associated with this entity.
77
+ * Must be implemented by child classes to return their specific activity relations.
78
+ *
79
+ * @returns Promise resolving to array of Activity objects
80
+ */
81
+ abstract getActivities(): Promise<Activity[]>;
82
+ }
@@ -0,0 +1,100 @@
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.TrackableEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ /**
15
+ * Abstract base entity with comprehensive audit tracking properties.
16
+ * Provides automatic tracking of creation, updates, and soft deletion with user attribution.
17
+ * All entities requiring an audit trail should extend this class.
18
+ *
19
+ * @template T - The model type that the entity converts to
20
+ * @extends BaseEntity
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * @Entity('users')
25
+ * export class UserEntity extends TrackableEntity<User> {
26
+ * // entity properties
27
+ *
28
+ * toModel() {
29
+ * return new User({ id: this.id, ... });
30
+ * }
31
+ *
32
+ * async getActivities() {
33
+ * return [];
34
+ * }
35
+ * }
36
+ * ```
37
+ */
38
+ class TrackableEntity extends typeorm_1.BaseEntity {
39
+ /**
40
+ * Primary key - auto-generated sequential ID
41
+ */
42
+ id;
43
+ /**
44
+ * ID of the user who created this entity
45
+ */
46
+ createdBy;
47
+ /**
48
+ * Timestamp when the entity was created
49
+ * Automatically set by TypeORM
50
+ */
51
+ createdOn;
52
+ /**
53
+ * ID of the user who last updated this entity
54
+ */
55
+ updatedBy;
56
+ /**
57
+ * Timestamp when the entity was last updated
58
+ * Automatically updated by TypeORM
59
+ */
60
+ updatedOn;
61
+ /**
62
+ * ID of the user who soft-deleted this entity
63
+ */
64
+ deletedBy;
65
+ /**
66
+ * Timestamp when the entity was soft-deleted
67
+ * When set, the entity is excluded from normal queries
68
+ */
69
+ deletedOn;
70
+ }
71
+ exports.TrackableEntity = TrackableEntity;
72
+ __decorate([
73
+ (0, typeorm_1.PrimaryGeneratedColumn)(),
74
+ __metadata("design:type", Number)
75
+ ], TrackableEntity.prototype, "id", void 0);
76
+ __decorate([
77
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
78
+ __metadata("design:type", Number)
79
+ ], TrackableEntity.prototype, "createdBy", void 0);
80
+ __decorate([
81
+ (0, typeorm_1.CreateDateColumn)({ nullable: true, default: null }),
82
+ __metadata("design:type", Date)
83
+ ], TrackableEntity.prototype, "createdOn", void 0);
84
+ __decorate([
85
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
86
+ __metadata("design:type", Number)
87
+ ], TrackableEntity.prototype, "updatedBy", void 0);
88
+ __decorate([
89
+ (0, typeorm_1.UpdateDateColumn)({ nullable: true, default: null }),
90
+ __metadata("design:type", Date)
91
+ ], TrackableEntity.prototype, "updatedOn", void 0);
92
+ __decorate([
93
+ (0, typeorm_1.Column)({ nullable: true, default: null }),
94
+ __metadata("design:type", Number)
95
+ ], TrackableEntity.prototype, "deletedBy", void 0);
96
+ __decorate([
97
+ (0, typeorm_1.DeleteDateColumn)({ nullable: true, default: null }),
98
+ __metadata("design:type", Date)
99
+ ], TrackableEntity.prototype, "deletedOn", void 0);
100
+ //# sourceMappingURL=trackable.entity.js.map