@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.
- package/README.md +174 -0
- package/lib/catalog/addon/addon.entity.d.ts +109 -0
- package/lib/catalog/addon/addon.entity.js +260 -0
- package/lib/catalog/addon/addon.entity.js.map +1 -0
- package/lib/catalog/addon/country.entity.d.ts +112 -0
- package/lib/catalog/addon/country.entity.js +246 -0
- package/lib/catalog/addon/country.entity.js.map +1 -0
- package/lib/catalog/driving/category.entity.d.ts +122 -0
- package/lib/catalog/driving/category.entity.js +217 -0
- package/lib/catalog/driving/category.entity.js.map +1 -0
- package/lib/catalog/driving/vehicle.entity.d.ts +49 -0
- package/lib/catalog/driving/vehicle.entity.js +97 -0
- package/lib/catalog/driving/vehicle.entity.js.map +1 -0
- package/lib/catalog/priceplan/priceplan.entity.d.ts +123 -0
- package/lib/catalog/priceplan/priceplan.entity.js +288 -0
- package/lib/catalog/priceplan/priceplan.entity.js.map +1 -0
- package/lib/catalog/product/country.entity.d.ts +109 -0
- package/lib/catalog/product/country.entity.js +233 -0
- package/lib/catalog/product/country.entity.js.map +1 -0
- package/lib/catalog/product/priceplan.entity.d.ts +113 -0
- package/lib/catalog/product/priceplan.entity.js +251 -0
- package/lib/catalog/product/priceplan.entity.js.map +1 -0
- package/lib/catalog/product/product.entity.d.ts +104 -0
- package/lib/catalog/product/product.entity.js +262 -0
- package/lib/catalog/product/product.entity.js.map +1 -0
- package/lib/catalog/program/program.entity.d.ts +107 -0
- package/lib/catalog/program/program.entity.js +247 -0
- package/lib/catalog/program/program.entity.js.map +1 -0
- package/lib/catalog/seed/assets/asset.entity.d.ts +68 -0
- package/lib/catalog/seed/assets/asset.entity.js +163 -0
- package/lib/catalog/seed/assets/asset.entity.js.map +1 -0
- package/lib/catalog/seed/courses/course.entity.d.ts +98 -0
- package/lib/catalog/seed/courses/course.entity.js +216 -0
- package/lib/catalog/seed/courses/course.entity.js.map +1 -0
- package/lib/catalog/seed/courses/lesson.entity.d.ts +90 -0
- package/lib/catalog/seed/courses/lesson.entity.js +214 -0
- package/lib/catalog/seed/courses/lesson.entity.js.map +1 -0
- package/lib/catalog/seed/courses/topic.entity.d.ts +77 -0
- package/lib/catalog/seed/courses/topic.entity.js +185 -0
- package/lib/catalog/seed/courses/topic.entity.js.map +1 -0
- package/lib/catalog/seed/expense/category.entity.d.ts +61 -0
- package/lib/catalog/seed/expense/category.entity.js +153 -0
- package/lib/catalog/seed/expense/category.entity.js.map +1 -0
- package/lib/index.d.ts +67 -0
- package/lib/index.js +89 -0
- package/lib/index.js.map +1 -0
- package/lib/profile/agent/agent.entity.d.ts +95 -0
- package/lib/profile/agent/agent.entity.js +223 -0
- package/lib/profile/agent/agent.entity.js.map +1 -0
- package/lib/profile/agent/payout.entity.d.ts +70 -0
- package/lib/profile/agent/payout.entity.js +160 -0
- package/lib/profile/agent/payout.entity.js.map +1 -0
- package/lib/profile/agent/promotion.entity.d.ts +82 -0
- package/lib/profile/agent/promotion.entity.js +174 -0
- package/lib/profile/agent/promotion.entity.js.map +1 -0
- package/lib/profile/company/company.entity.d.ts +234 -0
- package/lib/profile/company/company.entity.js +558 -0
- package/lib/profile/company/company.entity.js.map +1 -0
- package/lib/profile/company/course/appointment.entity.d.ts +111 -0
- package/lib/profile/company/course/appointment.entity.js +240 -0
- package/lib/profile/company/course/appointment.entity.js.map +1 -0
- package/lib/profile/company/course/course.entity.d.ts +156 -0
- package/lib/profile/company/course/course.entity.js +365 -0
- package/lib/profile/company/course/course.entity.js.map +1 -0
- package/lib/profile/company/course/lesson.entity.d.ts +123 -0
- package/lib/profile/company/course/lesson.entity.js +288 -0
- package/lib/profile/company/course/lesson.entity.js.map +1 -0
- package/lib/profile/company/course/topic.entity.d.ts +55 -0
- package/lib/profile/company/course/topic.entity.js +147 -0
- package/lib/profile/company/course/topic.entity.js.map +1 -0
- package/lib/profile/company/finances/billing/bill.entity.d.ts +145 -0
- package/lib/profile/company/finances/billing/bill.entity.js +338 -0
- package/lib/profile/company/finances/billing/bill.entity.js.map +1 -0
- package/lib/profile/company/finances/billing/item.entity.d.ts +75 -0
- package/lib/profile/company/finances/billing/item.entity.js +219 -0
- package/lib/profile/company/finances/billing/item.entity.js.map +1 -0
- package/lib/profile/company/finances/billing/transaction.entity.d.ts +44 -0
- package/lib/profile/company/finances/billing/transaction.entity.js +158 -0
- package/lib/profile/company/finances/billing/transaction.entity.js.map +1 -0
- package/lib/profile/company/finances/expense/category.entity.d.ts +55 -0
- package/lib/profile/company/finances/expense/category.entity.js +117 -0
- package/lib/profile/company/finances/expense/category.entity.js.map +1 -0
- package/lib/profile/company/finances/expense/expense.entity.d.ts +48 -0
- package/lib/profile/company/finances/expense/expense.entity.js +171 -0
- package/lib/profile/company/finances/expense/expense.entity.js.map +1 -0
- package/lib/profile/company/finances/handover/handover.entity.d.ts +44 -0
- package/lib/profile/company/finances/handover/handover.entity.js +202 -0
- package/lib/profile/company/finances/handover/handover.entity.js.map +1 -0
- package/lib/profile/company/finances/invoice/invoice.entity.d.ts +65 -0
- package/lib/profile/company/finances/invoice/invoice.entity.js +296 -0
- package/lib/profile/company/finances/invoice/invoice.entity.js.map +1 -0
- package/lib/profile/company/finances/invoice/item.entity.d.ts +25 -0
- package/lib/profile/company/finances/invoice/item.entity.js +148 -0
- package/lib/profile/company/finances/invoice/item.entity.js.map +1 -0
- package/lib/profile/company/finances/payment/method.entity.d.ts +35 -0
- package/lib/profile/company/finances/payment/method.entity.js +143 -0
- package/lib/profile/company/finances/payment/method.entity.js.map +1 -0
- package/lib/profile/company/finances/peyment/method.entity.d.ts +35 -0
- package/lib/profile/company/finances/peyment/method.entity.js +143 -0
- package/lib/profile/company/finances/peyment/method.entity.js.map +1 -0
- package/lib/profile/company/finances/peyment-method/payment-method.d.ts +34 -0
- package/lib/profile/company/finances/peyment-method/payment-method.js +118 -0
- package/lib/profile/company/finances/peyment-method/payment-method.js.map +1 -0
- package/lib/profile/company/instructor/instructor.entity.d.ts +85 -0
- package/lib/profile/company/instructor/instructor.entity.js +254 -0
- package/lib/profile/company/instructor/instructor.entity.js.map +1 -0
- package/lib/profile/company/instructor/task.entity.d.ts +60 -0
- package/lib/profile/company/instructor/task.entity.js +133 -0
- package/lib/profile/company/instructor/task.entity.js.map +1 -0
- package/lib/profile/company/medical/examination.entity.d.ts +59 -0
- package/lib/profile/company/medical/examination.entity.js +175 -0
- package/lib/profile/company/medical/examination.entity.js.map +1 -0
- package/lib/profile/company/medical/product.entity.d.ts +99 -0
- package/lib/profile/company/medical/product.entity.js +270 -0
- package/lib/profile/company/medical/product.entity.js.map +1 -0
- package/lib/profile/company/metrics/company.metric.d.ts +21 -0
- package/lib/profile/company/metrics/company.metric.js +122 -0
- package/lib/profile/company/metrics/company.metric.js.map +1 -0
- package/lib/profile/company/product/addon.entity.d.ts +93 -0
- package/lib/profile/company/product/addon.entity.js +234 -0
- package/lib/profile/company/product/addon.entity.js.map +1 -0
- package/lib/profile/company/product/priceplan.entity.d.ts +57 -0
- package/lib/profile/company/product/priceplan.entity.js +167 -0
- package/lib/profile/company/product/priceplan.entity.js.map +1 -0
- package/lib/profile/company/product/product.entity.d.ts +171 -0
- package/lib/profile/company/product/product.entity.js +383 -0
- package/lib/profile/company/product/product.entity.js.map +1 -0
- package/lib/profile/company/product/vehicle.entity.d.ts +46 -0
- package/lib/profile/company/product/vehicle.entity.js +144 -0
- package/lib/profile/company/product/vehicle.entity.js.map +1 -0
- package/lib/profile/instructor/instructor.entity.d.ts +80 -0
- package/lib/profile/instructor/instructor.entity.js +186 -0
- package/lib/profile/instructor/instructor.entity.js.map +1 -0
- package/lib/profile/student/program/licence/licence.entity.d.ts +66 -0
- package/lib/profile/student/program/licence/licence.entity.js +187 -0
- package/lib/profile/student/program/licence/licence.entity.js.map +1 -0
- package/lib/profile/student/program/medical/certificate.entity.d.ts +84 -0
- package/lib/profile/student/program/medical/certificate.entity.js +244 -0
- package/lib/profile/student/program/medical/certificate.entity.js.map +1 -0
- package/lib/profile/student/program/medical/examination.model.d.ts +65 -0
- package/lib/profile/student/program/medical/examination.model.js +209 -0
- package/lib/profile/student/program/medical/examination.model.js.map +1 -0
- package/lib/profile/student/program/program.entity.d.ts +78 -0
- package/lib/profile/student/program/program.entity.js +225 -0
- package/lib/profile/student/program/program.entity.js.map +1 -0
- package/lib/profile/student/program/training/appointment.entity.d.ts +151 -0
- package/lib/profile/student/program/training/appointment.entity.js +441 -0
- package/lib/profile/student/program/training/appointment.entity.js.map +1 -0
- package/lib/profile/student/program/training/exam.entity.d.ts +41 -0
- package/lib/profile/student/program/training/exam.entity.js +141 -0
- package/lib/profile/student/program/training/exam.entity.js.map +1 -0
- package/lib/profile/student/program/training/lesson.entity.d.ts +84 -0
- package/lib/profile/student/program/training/lesson.entity.js +221 -0
- package/lib/profile/student/program/training/lesson.entity.js.map +1 -0
- package/lib/profile/student/program/training/request.entity.d.ts +56 -0
- package/lib/profile/student/program/training/request.entity.js +159 -0
- package/lib/profile/student/program/training/request.entity.js.map +1 -0
- package/lib/profile/student/program/training/topic.entity.d.ts +109 -0
- package/lib/profile/student/program/training/topic.entity.js +255 -0
- package/lib/profile/student/program/training/topic.entity.js.map +1 -0
- package/lib/profile/student/program/training/training.entity.d.ts +167 -0
- package/lib/profile/student/program/training/training.entity.js +501 -0
- package/lib/profile/student/program/training/training.entity.js.map +1 -0
- package/lib/profile/student/program/training/transaction.entity.d.ts +111 -0
- package/lib/profile/student/program/training/transaction.entity.js +266 -0
- package/lib/profile/student/program/training/transaction.entity.js.map +1 -0
- package/lib/profile/student/student.entity.d.ts +89 -0
- package/lib/profile/student/student.entity.js +183 -0
- package/lib/profile/student/student.entity.js.map +1 -0
- package/lib/system/campaign/campaign.entity.d.ts +68 -0
- package/lib/system/campaign/campaign.entity.js +150 -0
- package/lib/system/campaign/campaign.entity.js.map +1 -0
- package/lib/system/campaign/gifcode.entity.d.ts +14 -0
- package/lib/system/campaign/gifcode.entity.js +77 -0
- package/lib/system/campaign/gifcode.entity.js.map +1 -0
- package/lib/system/campaigne/campaign.entity.d.ts +69 -0
- package/lib/system/campaigne/campaign.entity.js +179 -0
- package/lib/system/campaigne/campaign.entity.js.map +1 -0
- package/lib/system/campaigne/gifcode.entity.d.ts +54 -0
- package/lib/system/campaigne/gifcode.entity.js +126 -0
- package/lib/system/campaigne/gifcode.entity.js.map +1 -0
- package/lib/system/country/country.entity.d.ts +121 -0
- package/lib/system/country/country.entity.js +284 -0
- package/lib/system/country/country.entity.js.map +1 -0
- package/lib/system/country/country.metric.d.ts +12 -0
- package/lib/system/country/country.metric.js +68 -0
- package/lib/system/country/country.metric.js.map +1 -0
- package/lib/system/currency/currency.entity.d.ts +46 -0
- package/lib/system/currency/currency.entity.js +112 -0
- package/lib/system/currency/currency.entity.js.map +1 -0
- package/lib/system/driving/category.entity.d.ts +146 -0
- package/lib/system/driving/category.entity.js +321 -0
- package/lib/system/driving/category.entity.js.map +1 -0
- package/lib/system/driving/vehicle.entity.d.ts +54 -0
- package/lib/system/driving/vehicle.entity.js +130 -0
- package/lib/system/driving/vehicle.entity.js.map +1 -0
- package/lib/system/event/business.entity.d.ts +75 -0
- package/lib/system/event/business.entity.js +170 -0
- package/lib/system/event/business.entity.js.map +1 -0
- package/lib/system/event/log.entity.d.ts +103 -0
- package/lib/system/event/log.entity.js +202 -0
- package/lib/system/event/log.entity.js.map +1 -0
- package/lib/system/policy/policy.entity.d.ts +90 -0
- package/lib/system/policy/policy.entity.js +226 -0
- package/lib/system/policy/policy.entity.js.map +1 -0
- package/lib/system/staff/staff.entity.d.ts +72 -0
- package/lib/system/staff/staff.entity.js +186 -0
- package/lib/system/staff/staff.entity.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/user/alert.entity.d.ts +95 -0
- package/lib/user/alert.entity.js +223 -0
- package/lib/user/alert.entity.js.map +1 -0
- package/lib/user/blocked.entity.d.ts +42 -0
- package/lib/user/blocked.entity.js +83 -0
- package/lib/user/blocked.entity.js.map +1 -0
- package/lib/user/device.entity.d.ts +72 -0
- package/lib/user/device.entity.js +182 -0
- package/lib/user/device.entity.js.map +1 -0
- package/lib/user/notification.entity.d.ts +87 -0
- package/lib/user/notification.entity.js +219 -0
- package/lib/user/notification.entity.js.map +1 -0
- package/lib/user/ticket.entity.d.ts +85 -0
- package/lib/user/ticket.entity.js +231 -0
- package/lib/user/ticket.entity.js.map +1 -0
- package/lib/user/user.entity.d.ts +235 -0
- package/lib/user/user.entity.js +573 -0
- package/lib/user/user.entity.js.map +1 -0
- package/lib/user/verification.entity.d.ts +75 -0
- package/lib/user/verification.entity.js +142 -0
- package/lib/user/verification.entity.js.map +1 -0
- package/lib/utils/activity.helper.d.ts +26 -0
- package/lib/utils/activity.helper.js +39 -0
- package/lib/utils/activity.helper.js.map +1 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +21 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/json-metrics.transform.d.ts +35 -0
- package/lib/utils/json-metrics.transform.js +83 -0
- package/lib/utils/json-metrics.transform.js.map +1 -0
- package/lib/utils/numeric.transform.d.ts +38 -0
- package/lib/utils/numeric.transform.js +74 -0
- package/lib/utils/numeric.transform.js.map +1 -0
- package/lib/utils/trackable.entity.d.ts +82 -0
- package/lib/utils/trackable.entity.js +100 -0
- package/lib/utils/trackable.entity.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var LogEntity_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.LogEntity = void 0;
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
16
|
+
const common_1 = require("@driveup/common");
|
|
17
|
+
const utils_1 = require("../../utils");
|
|
18
|
+
const DELIMITER = '.log.';
|
|
19
|
+
/**
|
|
20
|
+
* Represents a system log entry for tracking events and activities.
|
|
21
|
+
* Logs record important actions and changes across different entity types
|
|
22
|
+
* (users, companies, agents, etc.) and can be localized for display.
|
|
23
|
+
*
|
|
24
|
+
* @extends TrackableEntity
|
|
25
|
+
*/
|
|
26
|
+
let LogEntity = LogEntity_1 = class LogEntity extends utils_1.TrackableEntity {
|
|
27
|
+
/**
|
|
28
|
+
* The type of event that is being logged.
|
|
29
|
+
* This can be used to categorize the log entry.
|
|
30
|
+
* @type {LogType}
|
|
31
|
+
*/
|
|
32
|
+
scope;
|
|
33
|
+
/**
|
|
34
|
+
* The type of event that is being logged.
|
|
35
|
+
* This can be used to categorize the log entry.
|
|
36
|
+
* @type {string}
|
|
37
|
+
* @example 'user.identity.nameChanged'
|
|
38
|
+
*/
|
|
39
|
+
event;
|
|
40
|
+
/**
|
|
41
|
+
* The id of the entity associated with the log entry.
|
|
42
|
+
* In relation with logType, can be userId, companyId, agentId, studentId, etc.
|
|
43
|
+
* This is used to filter logs by entity.
|
|
44
|
+
* @type {number}
|
|
45
|
+
*/
|
|
46
|
+
entityId;
|
|
47
|
+
/**
|
|
48
|
+
* The content of the log entry.
|
|
49
|
+
* This should contain the details of the event being logged.
|
|
50
|
+
* @type {string}
|
|
51
|
+
*/
|
|
52
|
+
content;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a new LogEntity instance
|
|
55
|
+
* @param props - Partial properties to initialize the entity
|
|
56
|
+
*/
|
|
57
|
+
constructor(props) {
|
|
58
|
+
super();
|
|
59
|
+
Object.assign(this, props);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Converts the entity to a Log model instance
|
|
63
|
+
* @returns Log model with type, event, content, and creation date
|
|
64
|
+
*/
|
|
65
|
+
toModel() {
|
|
66
|
+
return new common_1.Log({
|
|
67
|
+
type: this.scope,
|
|
68
|
+
event: this.event,
|
|
69
|
+
content: this.content,
|
|
70
|
+
createdOn: this.createdOn
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Converts the entity to a Log model instance
|
|
75
|
+
* @returns Log model with type, event, content, and creation date
|
|
76
|
+
*/
|
|
77
|
+
toSummary() {
|
|
78
|
+
return this.toModel();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates and saves a new log entry
|
|
82
|
+
* @param props - Properties for the new log entry
|
|
83
|
+
* @returns Promise that resolves when the log is saved
|
|
84
|
+
*/
|
|
85
|
+
static async from(props) {
|
|
86
|
+
const entity = new LogEntity_1(props);
|
|
87
|
+
await entity.save();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Generates localized content for user log entries
|
|
91
|
+
* @param event - The event identifier
|
|
92
|
+
* @param lang - Language code for translation
|
|
93
|
+
* @param metadata - Optional metadata for i18n interpolation
|
|
94
|
+
* @returns Localized log content string, or empty string if translation not found
|
|
95
|
+
*/
|
|
96
|
+
static toUserContent(event, lang, metadata) {
|
|
97
|
+
const key = event + DELIMITER + common_1.LogType.User;
|
|
98
|
+
const content = nestjs_i18n_1.I18nContext.current().t(key, { args: metadata, lang });
|
|
99
|
+
return content === key ? '' : content;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Generates localized content for student log entries
|
|
103
|
+
* @param event - The event identifier
|
|
104
|
+
* @param lang - Language code for translation
|
|
105
|
+
* @param metadata - Optional metadata for i18n interpolation
|
|
106
|
+
* @returns Localized log content string, or empty string if translation not found
|
|
107
|
+
*/
|
|
108
|
+
static toStudentContent(event, lang, metadata) {
|
|
109
|
+
const key = event + `.log.author`;
|
|
110
|
+
const content = nestjs_i18n_1.I18nContext.current().t(key, { args: metadata, lang });
|
|
111
|
+
return content === key ? '' : content;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Generates localized content for agent log entries
|
|
115
|
+
* @param event - The event identifier
|
|
116
|
+
* @param lang - Language code for translation
|
|
117
|
+
* @param metadata - Optional metadata for i18n interpolation
|
|
118
|
+
* @returns Localized log content string, or empty string if translation not found
|
|
119
|
+
*/
|
|
120
|
+
static toAgentContent(event, lang, metadata) {
|
|
121
|
+
const key = event + DELIMITER + common_1.LogType.Agent;
|
|
122
|
+
const content = nestjs_i18n_1.I18nContext.current().t(key, { args: metadata, lang });
|
|
123
|
+
return content === key ? '' : content;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Generates localized content for instructor log entries
|
|
127
|
+
* @param event - The event identifier
|
|
128
|
+
* @param lang - Language code for translation
|
|
129
|
+
* @param metadata - Optional metadata for i18n interpolation
|
|
130
|
+
* @returns Localized log content string, or empty string if translation not found
|
|
131
|
+
*/
|
|
132
|
+
static toInstructorContent(event, lang, metadata) {
|
|
133
|
+
const key = event + DELIMITER + common_1.LogType.Instructor;
|
|
134
|
+
const content = nestjs_i18n_1.I18nContext.current().t(key, { args: metadata, lang });
|
|
135
|
+
return content === key ? '' : content;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Generates localized content for company log entries
|
|
139
|
+
* @param event - The event identifier
|
|
140
|
+
* @param lang - Language code for translation
|
|
141
|
+
* @param metadata - Optional metadata for i18n interpolation
|
|
142
|
+
* @returns Localized log content string, or empty string if translation not found
|
|
143
|
+
*/
|
|
144
|
+
static toCompanyContent(event, lang, metadata) {
|
|
145
|
+
const key = event + DELIMITER + common_1.LogType.Company;
|
|
146
|
+
const content = nestjs_i18n_1.I18nContext.current().t(key, { args: metadata, lang });
|
|
147
|
+
return content === key ? '' : content;
|
|
148
|
+
}
|
|
149
|
+
static toAuthorContent(event, lang, metadata) {
|
|
150
|
+
const key = event + DELIMITER + `author`;
|
|
151
|
+
const content = nestjs_i18n_1.I18nContext.current().t(key, { args: metadata, lang });
|
|
152
|
+
return content === key ? '' : content;
|
|
153
|
+
}
|
|
154
|
+
static toTargetContent(event, lang, metadata) {
|
|
155
|
+
const key = event + DELIMITER + `target`;
|
|
156
|
+
const content = nestjs_i18n_1.I18nContext.current().t(key, { args: metadata, lang });
|
|
157
|
+
return content === key ? '' : content;
|
|
158
|
+
}
|
|
159
|
+
static toSystemContent(event, metadata) {
|
|
160
|
+
const key = event + DELIMITER + common_1.LogType.System;
|
|
161
|
+
const content = nestjs_i18n_1.I18nContext.current().t(key, { args: metadata, lang: 'en' });
|
|
162
|
+
return content === key ? '' : content;
|
|
163
|
+
}
|
|
164
|
+
static toJobContent(event, metadata) {
|
|
165
|
+
const key = event + DELIMITER + common_1.LogType.Job;
|
|
166
|
+
const content = nestjs_i18n_1.I18nContext.current().t(key, { args: metadata, lang: 'en' });
|
|
167
|
+
return content === key ? '' : content;
|
|
168
|
+
}
|
|
169
|
+
async getActivities() {
|
|
170
|
+
const activities = [];
|
|
171
|
+
activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
|
|
172
|
+
activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
173
|
+
return activities.filter(a => a);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
exports.LogEntity = LogEntity;
|
|
177
|
+
__decorate([
|
|
178
|
+
(0, typeorm_1.Column)({
|
|
179
|
+
type: 'enum',
|
|
180
|
+
enum: common_1.LogType,
|
|
181
|
+
default: common_1.LogType.User,
|
|
182
|
+
nullable: true
|
|
183
|
+
}),
|
|
184
|
+
__metadata("design:type", String)
|
|
185
|
+
], LogEntity.prototype, "scope", void 0);
|
|
186
|
+
__decorate([
|
|
187
|
+
(0, typeorm_1.Column)(),
|
|
188
|
+
__metadata("design:type", String)
|
|
189
|
+
], LogEntity.prototype, "event", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
192
|
+
__metadata("design:type", Number)
|
|
193
|
+
], LogEntity.prototype, "entityId", void 0);
|
|
194
|
+
__decorate([
|
|
195
|
+
(0, typeorm_1.Column)(),
|
|
196
|
+
__metadata("design:type", String)
|
|
197
|
+
], LogEntity.prototype, "content", void 0);
|
|
198
|
+
exports.LogEntity = LogEntity = LogEntity_1 = __decorate([
|
|
199
|
+
(0, typeorm_1.Entity)('systemLogs'),
|
|
200
|
+
__metadata("design:paramtypes", [Object])
|
|
201
|
+
], LogEntity);
|
|
202
|
+
//# sourceMappingURL=log.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.entity.js","sourceRoot":"","sources":["../../../src/system/event/log.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAAyC;AACzC,6CAA0C;AAC1C,4CAAuE;AACvE,uCAA0D;AAE1D,MAAM,SAAS,GAAG,OAAO,CAAC;AAE1B;;;;;;GAMG;AAEI,IAAM,SAAS,iBAAf,MAAM,SAAU,SAAQ,uBAAoB;IAElD;;;;OAIG;IAOH,KAAK,CAAU;IAEf;;;;;OAKG;IAEH,KAAK,CAAS;IAEd;;;;;OAKG;IAEH,QAAQ,CAAS;IAEjB;;;;OAIG;IAEH,OAAO,CAAS;IAEhB;;;OAGG;IACH,YAAY,KAA0B;QACrC,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,OAAO;QACN,OAAO,IAAI,YAAG,CAAC;YACd,IAAI,EAAE,IAAI,CAAC,KAAK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AAC;IACvC,CAAC;IAED,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,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;CACD,CAAA;AAhLY,8BAAS;AAarB;IANC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,gBAAO;QACb,OAAO,EAAE,gBAAO,CAAC,IAAI;QACrB,QAAQ,EAAE,IAAI;KACd,CAAC;;wCACa;AASf;IADC,IAAA,gBAAM,GAAE;;wCACK;AASd;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;2CACzB;AAQjB;IADC,IAAA,gBAAM,GAAE;;0CACO;oBAvCJ,SAAS;IADrB,IAAA,gBAAM,EAAC,YAAY,CAAC;;GACR,SAAS,CAgLrB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ColorContext, Content, Language, Metadata } from '@driveup/common';
|
|
2
|
+
import { Policy, PolicyType, Activity } from '@driveup/common';
|
|
3
|
+
import { UserAlertEntity } from '../../user/alert.entity';
|
|
4
|
+
import { TrackableEntity } from '../../utils';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a system policy or compliance requirement.
|
|
7
|
+
* Policies define rules and requirements that users must follow or complete,
|
|
8
|
+
* such as adding recovery email, updating profile information, or accepting terms.
|
|
9
|
+
* When activated, policies can trigger user alerts.
|
|
10
|
+
*
|
|
11
|
+
* @extends TrackableEntity
|
|
12
|
+
*/
|
|
13
|
+
export declare class PolicyEntity extends TrackableEntity<Policy> {
|
|
14
|
+
/**
|
|
15
|
+
* Type of policy (e.g., MissingRecoveryEmail, ProfileIncomplete)
|
|
16
|
+
* @default PolicyType.MissingRecoveryEmail
|
|
17
|
+
*/
|
|
18
|
+
type: PolicyType;
|
|
19
|
+
/**
|
|
20
|
+
* UI color context for displaying the policy alert
|
|
21
|
+
* @default ColorContext.Info
|
|
22
|
+
*/
|
|
23
|
+
color: ColorContext;
|
|
24
|
+
/**
|
|
25
|
+
* URL to the policy's representative image or icon
|
|
26
|
+
*/
|
|
27
|
+
imageUrl: string;
|
|
28
|
+
/**
|
|
29
|
+
* Localized content for the policy (title, description, instructions)
|
|
30
|
+
*/
|
|
31
|
+
translations: Content[];
|
|
32
|
+
/**
|
|
33
|
+
* Additional metadata for policy configuration
|
|
34
|
+
*/
|
|
35
|
+
metadata: Metadata[];
|
|
36
|
+
/**
|
|
37
|
+
* Policy active status - controls whether new alerts are created
|
|
38
|
+
*/
|
|
39
|
+
active: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* ID of the staff member who enabled this policy
|
|
42
|
+
*/
|
|
43
|
+
enabledBy: number;
|
|
44
|
+
/**
|
|
45
|
+
* Date when the policy was enabled
|
|
46
|
+
*/
|
|
47
|
+
enabledOn: Date;
|
|
48
|
+
/**
|
|
49
|
+
* ID of the staff member who disabled this policy
|
|
50
|
+
*/
|
|
51
|
+
disabledBy: number;
|
|
52
|
+
/**
|
|
53
|
+
* Date when the policy was disabled
|
|
54
|
+
*/
|
|
55
|
+
disabledOn: Date;
|
|
56
|
+
/**
|
|
57
|
+
* User alerts generated from this policy
|
|
58
|
+
*/
|
|
59
|
+
alerts: Promise<UserAlertEntity[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new PolicyEntity instance
|
|
62
|
+
* @param props - Partial properties to initialize the entity
|
|
63
|
+
*/
|
|
64
|
+
constructor(props?: Partial<PolicyEntity>);
|
|
65
|
+
/**
|
|
66
|
+
* Converts the entity to a Policy model instance
|
|
67
|
+
* @param lang - Optional language for translations
|
|
68
|
+
* @returns Policy model with localized content
|
|
69
|
+
*/
|
|
70
|
+
toModel(lang?: Language): Policy;
|
|
71
|
+
/**
|
|
72
|
+
* Converts the entity to a Policy summary instance
|
|
73
|
+
* @param lang - Optional language for translations
|
|
74
|
+
* @returns Policy model with localized content
|
|
75
|
+
*/
|
|
76
|
+
toSummary(lang?: Language): Policy;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the localized translation for the policy
|
|
79
|
+
* @param lang - Optional language code; defaults to current i18n context or English
|
|
80
|
+
* @returns Content instance with translated title and description
|
|
81
|
+
*/
|
|
82
|
+
getTranslation(lang?: Language): Content;
|
|
83
|
+
/**
|
|
84
|
+
* Gets all available translations for the policy
|
|
85
|
+
* @returns Array of Content instances for all languages
|
|
86
|
+
*/
|
|
87
|
+
getTranslations(): Content[];
|
|
88
|
+
getMetadata(): Metadata<any>[];
|
|
89
|
+
getActivities(): Promise<Activity[]>;
|
|
90
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
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.PolicyEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
15
|
+
const common_1 = require("@driveup/common");
|
|
16
|
+
const common_2 = require("@driveup/common");
|
|
17
|
+
const alert_entity_1 = require("../../user/alert.entity");
|
|
18
|
+
const staff_entity_1 = require("../staff/staff.entity");
|
|
19
|
+
const utils_1 = require("../../utils");
|
|
20
|
+
/**
|
|
21
|
+
* Represents a system policy or compliance requirement.
|
|
22
|
+
* Policies define rules and requirements that users must follow or complete,
|
|
23
|
+
* such as adding recovery email, updating profile information, or accepting terms.
|
|
24
|
+
* When activated, policies can trigger user alerts.
|
|
25
|
+
*
|
|
26
|
+
* @extends TrackableEntity
|
|
27
|
+
*/
|
|
28
|
+
let PolicyEntity = class PolicyEntity extends utils_1.TrackableEntity {
|
|
29
|
+
/**
|
|
30
|
+
* Type of policy (e.g., MissingRecoveryEmail, ProfileIncomplete)
|
|
31
|
+
* @default PolicyType.MissingRecoveryEmail
|
|
32
|
+
*/
|
|
33
|
+
type;
|
|
34
|
+
/**
|
|
35
|
+
* UI color context for displaying the policy alert
|
|
36
|
+
* @default ColorContext.Info
|
|
37
|
+
*/
|
|
38
|
+
color;
|
|
39
|
+
/**
|
|
40
|
+
* URL to the policy's representative image or icon
|
|
41
|
+
*/
|
|
42
|
+
imageUrl;
|
|
43
|
+
/**
|
|
44
|
+
* Localized content for the policy (title, description, instructions)
|
|
45
|
+
*/
|
|
46
|
+
translations;
|
|
47
|
+
/**
|
|
48
|
+
* Additional metadata for policy configuration
|
|
49
|
+
*/
|
|
50
|
+
metadata;
|
|
51
|
+
/**
|
|
52
|
+
* Policy active status - controls whether new alerts are created
|
|
53
|
+
*/
|
|
54
|
+
active;
|
|
55
|
+
/**
|
|
56
|
+
* ID of the staff member who enabled this policy
|
|
57
|
+
*/
|
|
58
|
+
enabledBy;
|
|
59
|
+
/**
|
|
60
|
+
* Date when the policy was enabled
|
|
61
|
+
*/
|
|
62
|
+
enabledOn;
|
|
63
|
+
/**
|
|
64
|
+
* ID of the staff member who disabled this policy
|
|
65
|
+
*/
|
|
66
|
+
disabledBy;
|
|
67
|
+
/**
|
|
68
|
+
* Date when the policy was disabled
|
|
69
|
+
*/
|
|
70
|
+
disabledOn;
|
|
71
|
+
/**
|
|
72
|
+
* User alerts generated from this policy
|
|
73
|
+
*/
|
|
74
|
+
alerts;
|
|
75
|
+
/**
|
|
76
|
+
* Creates a new PolicyEntity instance
|
|
77
|
+
* @param props - Partial properties to initialize the entity
|
|
78
|
+
*/
|
|
79
|
+
constructor(props) {
|
|
80
|
+
super();
|
|
81
|
+
Object.assign(this, props);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Converts the entity to a Policy model instance
|
|
85
|
+
* @param lang - Optional language for translations
|
|
86
|
+
* @returns Policy model with localized content
|
|
87
|
+
*/
|
|
88
|
+
toModel(lang) {
|
|
89
|
+
const transaltion = this.getTranslation(lang);
|
|
90
|
+
return new common_2.Policy({
|
|
91
|
+
id: this.id,
|
|
92
|
+
type: this.type,
|
|
93
|
+
color: this.color,
|
|
94
|
+
active: this.active,
|
|
95
|
+
title: transaltion.title,
|
|
96
|
+
description: transaltion.description,
|
|
97
|
+
imageUrl: transaltion.imageUrl,
|
|
98
|
+
metadata: this.getMetadata(),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Converts the entity to a Policy summary instance
|
|
103
|
+
* @param lang - Optional language for translations
|
|
104
|
+
* @returns Policy model with localized content
|
|
105
|
+
*/
|
|
106
|
+
toSummary(lang) {
|
|
107
|
+
return this.toModel(lang);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Gets the localized translation for the policy
|
|
111
|
+
* @param lang - Optional language code; defaults to current i18n context or English
|
|
112
|
+
* @returns Content instance with translated title and description
|
|
113
|
+
*/
|
|
114
|
+
getTranslation(lang) {
|
|
115
|
+
const language = (lang || nestjs_i18n_1.I18nContext.current()?.lang) || common_1.Language.En;
|
|
116
|
+
const translation = this.translations?.find(t => t.language === language);
|
|
117
|
+
return new common_1.Content({
|
|
118
|
+
title: translation?.title,
|
|
119
|
+
description: translation?.description,
|
|
120
|
+
content: translation?.content,
|
|
121
|
+
imageUrl: translation?.imageUrl,
|
|
122
|
+
link: translation?.link,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Gets all available translations for the policy
|
|
127
|
+
* @returns Array of Content instances for all languages
|
|
128
|
+
*/
|
|
129
|
+
getTranslations() {
|
|
130
|
+
return this.translations?.map(t => new common_1.Content({
|
|
131
|
+
title: t.title,
|
|
132
|
+
description: t.description,
|
|
133
|
+
content: t.content,
|
|
134
|
+
imageUrl: t.imageUrl,
|
|
135
|
+
link: t.link,
|
|
136
|
+
language: t.language
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
getMetadata() {
|
|
140
|
+
return this.metadata?.map(m => common_1.Metadata.toInstance(m));
|
|
141
|
+
}
|
|
142
|
+
async getActivities() {
|
|
143
|
+
const activities = [];
|
|
144
|
+
activities.push(await (0, utils_1.toActivity)(this.createdBy, common_2.ActivityType.createdBy, staff_entity_1.StaffEntity));
|
|
145
|
+
activities.push(await (0, utils_1.toActivity)(this.createdOn, common_2.ActivityType.createdOn));
|
|
146
|
+
activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_2.ActivityType.updatedBy, staff_entity_1.StaffEntity));
|
|
147
|
+
activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_2.ActivityType.updatedOn));
|
|
148
|
+
activities.push(await (0, utils_1.toActivity)(this.enabledBy, common_2.ActivityType.enabledBy, staff_entity_1.StaffEntity));
|
|
149
|
+
activities.push(await (0, utils_1.toActivity)(this.enabledOn, common_2.ActivityType.createdOn));
|
|
150
|
+
activities.push(await (0, utils_1.toActivity)(this.disabledBy, common_2.ActivityType.disabledBy, staff_entity_1.StaffEntity));
|
|
151
|
+
activities.push(await (0, utils_1.toActivity)(this.disabledOn, common_2.ActivityType.disabledOn));
|
|
152
|
+
return activities.filter(a => a);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
exports.PolicyEntity = PolicyEntity;
|
|
156
|
+
__decorate([
|
|
157
|
+
(0, typeorm_1.Column)({
|
|
158
|
+
type: 'enum',
|
|
159
|
+
name: 'policyType',
|
|
160
|
+
enum: common_2.PolicyType,
|
|
161
|
+
default: common_2.PolicyType.MissingRecoveryEmail,
|
|
162
|
+
nullable: false
|
|
163
|
+
}),
|
|
164
|
+
__metadata("design:type", String)
|
|
165
|
+
], PolicyEntity.prototype, "type", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
(0, typeorm_1.Column)({
|
|
168
|
+
type: 'enum',
|
|
169
|
+
enum: common_1.ColorContext,
|
|
170
|
+
default: common_1.ColorContext.Info,
|
|
171
|
+
nullable: false
|
|
172
|
+
}),
|
|
173
|
+
__metadata("design:type", String)
|
|
174
|
+
], PolicyEntity.prototype, "color", void 0);
|
|
175
|
+
__decorate([
|
|
176
|
+
(0, typeorm_1.Column)({
|
|
177
|
+
nullable: true,
|
|
178
|
+
default: null
|
|
179
|
+
}),
|
|
180
|
+
__metadata("design:type", String)
|
|
181
|
+
], PolicyEntity.prototype, "imageUrl", void 0);
|
|
182
|
+
__decorate([
|
|
183
|
+
(0, typeorm_1.Column)({
|
|
184
|
+
type: 'simple-json',
|
|
185
|
+
nullable: true,
|
|
186
|
+
default: null
|
|
187
|
+
}),
|
|
188
|
+
__metadata("design:type", Array)
|
|
189
|
+
], PolicyEntity.prototype, "translations", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
(0, typeorm_1.Column)({
|
|
192
|
+
type: 'simple-json',
|
|
193
|
+
nullable: true,
|
|
194
|
+
default: null
|
|
195
|
+
}),
|
|
196
|
+
__metadata("design:type", Array)
|
|
197
|
+
], PolicyEntity.prototype, "metadata", void 0);
|
|
198
|
+
__decorate([
|
|
199
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
200
|
+
__metadata("design:type", Boolean)
|
|
201
|
+
], PolicyEntity.prototype, "active", void 0);
|
|
202
|
+
__decorate([
|
|
203
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
204
|
+
__metadata("design:type", Number)
|
|
205
|
+
], PolicyEntity.prototype, "enabledBy", void 0);
|
|
206
|
+
__decorate([
|
|
207
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
208
|
+
__metadata("design:type", Date)
|
|
209
|
+
], PolicyEntity.prototype, "enabledOn", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
212
|
+
__metadata("design:type", Number)
|
|
213
|
+
], PolicyEntity.prototype, "disabledBy", void 0);
|
|
214
|
+
__decorate([
|
|
215
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
216
|
+
__metadata("design:type", Date)
|
|
217
|
+
], PolicyEntity.prototype, "disabledOn", void 0);
|
|
218
|
+
__decorate([
|
|
219
|
+
(0, typeorm_1.OneToMany)(() => alert_entity_1.UserAlertEntity, alert => alert.policy),
|
|
220
|
+
__metadata("design:type", Promise)
|
|
221
|
+
], PolicyEntity.prototype, "alerts", void 0);
|
|
222
|
+
exports.PolicyEntity = PolicyEntity = __decorate([
|
|
223
|
+
(0, typeorm_1.Entity)('systemPolicies'),
|
|
224
|
+
__metadata("design:paramtypes", [Object])
|
|
225
|
+
], PolicyEntity);
|
|
226
|
+
//# sourceMappingURL=policy.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.entity.js","sourceRoot":"","sources":["../../../src/system/policy/policy.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAoD;AACpD,6CAA0C;AAC1C,4CAA6E;AAC7E,4CAA4E;AAC5E,0DAA0D;AAC1D,wDAAoD;AACpD,uCAA0D;AAE1D;;;;;;;GAOG;AAEI,IAAM,YAAY,GAAlB,MA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AAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;8CACe;AAUjB;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;kDACsB;AAUxB;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;8CACmB;AAMrB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;4CAC1B;AAMhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;+CACxB;AAMlB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BAC/B,IAAI;+CAAC;AAMhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;gDACvB;AAMnB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BAC9B,IAAI;gDAAC;AAMjB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;;4CACrB;uBA1FvB,YAAY;IADxB,IAAA,gBAAM,EAAC,gBAAgB,CAAC;;GACZ,YAAY,CAiLxB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { AccountStatus, Language, Person, StaffRole, Activity, Staff } from '@driveup/common';
|
|
2
|
+
import { TrackableEntity } from '../../utils';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a staff member in the system.
|
|
5
|
+
* Staff members are administrators or support personnel who manage
|
|
6
|
+
* the platform, assist customers, and perform system operations.
|
|
7
|
+
* Each staff member has a specific role and permissions.
|
|
8
|
+
*
|
|
9
|
+
* @extends TrackableEntity
|
|
10
|
+
*/
|
|
11
|
+
export declare class StaffEntity extends TrackableEntity<Staff> {
|
|
12
|
+
/**
|
|
13
|
+
* Current account status
|
|
14
|
+
* @default AccountStatus.Pending
|
|
15
|
+
*/
|
|
16
|
+
status: AccountStatus;
|
|
17
|
+
/**
|
|
18
|
+
* Staff role defining permissions and responsibilities
|
|
19
|
+
* @default StaffRole.CustomerSupportManager
|
|
20
|
+
*/
|
|
21
|
+
role: StaffRole;
|
|
22
|
+
/**
|
|
23
|
+
* Preferred language for the staff member
|
|
24
|
+
* @default Language.En
|
|
25
|
+
*/
|
|
26
|
+
language: Language;
|
|
27
|
+
/**
|
|
28
|
+
* Full name of the staff member
|
|
29
|
+
*/
|
|
30
|
+
name: string;
|
|
31
|
+
/**
|
|
32
|
+
* Phone number (unique identifier for authentication)
|
|
33
|
+
*/
|
|
34
|
+
phone: string;
|
|
35
|
+
/**
|
|
36
|
+
* Email address for notifications and communication
|
|
37
|
+
*/
|
|
38
|
+
email: string;
|
|
39
|
+
/**
|
|
40
|
+
* URL to the staff member's profile image
|
|
41
|
+
*/
|
|
42
|
+
imageUrl: string;
|
|
43
|
+
/**
|
|
44
|
+
* Unique identifier (UUID) for external references
|
|
45
|
+
*/
|
|
46
|
+
uid: string;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new StaffEntity instance
|
|
49
|
+
* @param props - Partial properties to initialize the entity
|
|
50
|
+
*/
|
|
51
|
+
constructor(props?: Partial<StaffEntity>);
|
|
52
|
+
/**
|
|
53
|
+
* Converts the entity to a Staff model instance
|
|
54
|
+
* @returns Staff model with core staff information
|
|
55
|
+
*/
|
|
56
|
+
toModel(): Staff;
|
|
57
|
+
/**
|
|
58
|
+
* Converts the entity to a Staff model instance
|
|
59
|
+
* @returns Staff model with core staff information
|
|
60
|
+
*/
|
|
61
|
+
toSummary(): Staff;
|
|
62
|
+
/**
|
|
63
|
+
* Converts the entity to a Person model instance
|
|
64
|
+
* @returns Person model with basic personal information
|
|
65
|
+
*/
|
|
66
|
+
toPerson(): Person;
|
|
67
|
+
/**
|
|
68
|
+
* Retrieves activity history for this staff member
|
|
69
|
+
* @returns Promise resolving to array of Activity instances tracking creation and updates
|
|
70
|
+
*/
|
|
71
|
+
getActivities(): Promise<Activity[]>;
|
|
72
|
+
}
|