@driveup/schema 0.2.1 → 0.2.2
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/lib/index.d.ts +3 -3
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/profile/agent/agent.entity.d.ts +27 -0
- package/lib/profile/agent/agent.entity.js +59 -2
- package/lib/profile/agent/agent.entity.js.map +1 -1
- package/lib/profile/company/company.entity.d.ts +7 -0
- package/lib/profile/company/company.entity.js +16 -0
- package/lib/profile/company/company.entity.js.map +1 -1
- package/lib/profile/company/instructor/instructor.entity.d.ts +33 -1
- package/lib/profile/company/instructor/instructor.entity.js +66 -0
- package/lib/profile/company/instructor/instructor.entity.js.map +1 -1
- package/lib/profile/instructor/instructor.entity.d.ts +26 -4
- package/lib/profile/instructor/instructor.entity.js +57 -9
- package/lib/profile/instructor/instructor.entity.js.map +1 -1
- package/lib/profile/student/student.entity.d.ts +26 -0
- package/lib/profile/student/student.entity.js +57 -0
- package/lib/profile/student/student.entity.js.map +1 -1
- package/lib/system/campaign/campaign.entity.d.ts +69 -0
- package/lib/system/campaign/campaign.entity.js +153 -0
- package/lib/system/campaign/campaign.entity.js.map +1 -0
- package/lib/system/campaign/gifcode.entity.d.ts +54 -0
- package/lib/system/campaign/gifcode.entity.js +102 -0
- package/lib/system/campaign/gifcode.entity.js.map +1 -0
- package/lib/system/event/event.entity.d.ts +83 -0
- package/lib/system/event/event.entity.js +136 -0
- package/lib/system/event/event.entity.js.map +1 -0
- package/lib/system/event/log.entity.d.ts +27 -5
- package/lib/system/event/log.entity.js +43 -6
- package/lib/system/event/log.entity.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/user/device.entity.js +2 -1
- package/lib/user/device.entity.js.map +1 -1
- package/lib/user/user.entity.d.ts +16 -0
- package/lib/user/user.entity.js +48 -0
- package/lib/user/user.entity.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -48,13 +48,13 @@ export * from './profile/student/program/training/training.entity';
|
|
|
48
48
|
export * from './profile/student/program/training/transaction.entity';
|
|
49
49
|
export * from './profile/student/program/program.entity';
|
|
50
50
|
export * from './profile/student/student.entity';
|
|
51
|
-
export * from './system/
|
|
52
|
-
export * from './system/
|
|
51
|
+
export * from './system/campaign/campaign.entity';
|
|
52
|
+
export * from './system/campaign/gifcode.entity';
|
|
53
53
|
export * from './system/country/country.entity';
|
|
54
54
|
export * from './system/currency/currency.entity';
|
|
55
55
|
export * from './system/driving/category.entity';
|
|
56
56
|
export * from './system/driving/vehicle.entity';
|
|
57
|
-
export * from './system/event/
|
|
57
|
+
export * from './system/event/event.entity';
|
|
58
58
|
export * from './system/event/log.entity';
|
|
59
59
|
export * from './system/policy/policy.entity';
|
|
60
60
|
export * from './system/staff/staff.entity';
|
package/lib/index.js
CHANGED
|
@@ -70,13 +70,13 @@ __exportStar(require("./profile/student/program/training/transaction.entity"), e
|
|
|
70
70
|
__exportStar(require("./profile/student/program/program.entity"), exports);
|
|
71
71
|
__exportStar(require("./profile/student/student.entity"), exports);
|
|
72
72
|
// system
|
|
73
|
-
__exportStar(require("./system/
|
|
74
|
-
__exportStar(require("./system/
|
|
73
|
+
__exportStar(require("./system/campaign/campaign.entity"), exports);
|
|
74
|
+
__exportStar(require("./system/campaign/gifcode.entity"), exports);
|
|
75
75
|
__exportStar(require("./system/country/country.entity"), exports);
|
|
76
76
|
__exportStar(require("./system/currency/currency.entity"), exports);
|
|
77
77
|
__exportStar(require("./system/driving/category.entity"), exports);
|
|
78
78
|
__exportStar(require("./system/driving/vehicle.entity"), exports);
|
|
79
|
-
__exportStar(require("./system/event/
|
|
79
|
+
__exportStar(require("./system/event/event.entity"), exports);
|
|
80
80
|
__exportStar(require("./system/event/log.entity"), exports);
|
|
81
81
|
__exportStar(require("./system/policy/policy.entity"), exports);
|
|
82
82
|
__exportStar(require("./system/staff/staff.entity"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,+DAA6C;AAC7C,iEAA+C;AAC/C,uEAAqD;AACrD,mEAAiD;AACjD,qEAAmD;AACnD,mEAAiD;AACjD,mEAAiD;AACjD,qEAAmD;AACnD,uEAAqD;AACrD,uEAAqD;AACrD,sEAAoD;AACpD,yEAAuD;AACvD,iBAAiB;AACjB,+DAA6C;AAC7C,gEAA8C;AAC9C,mEAAiD;AACjD,mBAAmB;AACnB,8EAA4D;AAC5D,yEAAuD;AACvD,yEAAuD;AACvD,wEAAsD;AACtD,iFAA+D;AAC/D,iFAA+D;AAC/D,wFAAsE;AACtE,qFAAmE;AACnE,oFAAkE;AAClE,sFAAoE;AACpE,oFAAkE;AAClE,iFAA+D;AAC/D,mFAAiE;AACjE,iFAA+D;AAC/D,2EAAyD;AACzD,+EAA6D;AAC7D,2EAAyD;AACzD,yEAAuD;AACvD,6EAA2D;AAC3D,2EAAyD;AACzD,2EAAyD;AACzD,mEAAiD;AACjD,sBAAsB;AACtB,yEAAuD;AACvD,oBAAoB;AACpB,mFAAiE;AACjE,uFAAqE;AACrE,uFAAqE;AACrE,wFAAsE;AACtE,iFAA+D;AAC/D,mFAAiE;AACjE,oFAAkE;AAClE,kFAAgE;AAChE,qFAAmE;AACnE,wFAAsE;AACtE,2EAAyD;AACzD,mEAAiD;AACjD,SAAS;AACT,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,+DAA6C;AAC7C,iEAA+C;AAC/C,uEAAqD;AACrD,mEAAiD;AACjD,qEAAmD;AACnD,mEAAiD;AACjD,mEAAiD;AACjD,qEAAmD;AACnD,uEAAqD;AACrD,uEAAqD;AACrD,sEAAoD;AACpD,yEAAuD;AACvD,iBAAiB;AACjB,+DAA6C;AAC7C,gEAA8C;AAC9C,mEAAiD;AACjD,mBAAmB;AACnB,8EAA4D;AAC5D,yEAAuD;AACvD,yEAAuD;AACvD,wEAAsD;AACtD,iFAA+D;AAC/D,iFAA+D;AAC/D,wFAAsE;AACtE,qFAAmE;AACnE,oFAAkE;AAClE,sFAAoE;AACpE,oFAAkE;AAClE,iFAA+D;AAC/D,mFAAiE;AACjE,iFAA+D;AAC/D,2EAAyD;AACzD,+EAA6D;AAC7D,2EAAyD;AACzD,yEAAuD;AACvD,6EAA2D;AAC3D,2EAAyD;AACzD,2EAAyD;AACzD,mEAAiD;AACjD,sBAAsB;AACtB,yEAAuD;AACvD,oBAAoB;AACpB,mFAAiE;AACjE,uFAAqE;AACrE,uFAAqE;AACrE,wFAAsE;AACtE,iFAA+D;AAC/D,mFAAiE;AACjE,oFAAkE;AAClE,kFAAgE;AAChE,qFAAmE;AACnE,wFAAsE;AACtE,2EAAyD;AACzD,mEAAiD;AACjD,SAAS;AACT,oEAAkD;AAClD,mEAAiD;AACjD,kEAAgD;AAChD,oEAAkD;AAClD,mEAAiD;AACjD,kEAAgD;AAChD,8DAA4C;AAC5C,4DAA0C;AAC1C,gEAA8C;AAC9C,8DAA4C;AAC5C,sDAAoC;AACpC,wDAAsC;AACtC,uDAAqC;AACrC,6DAA2C;AAC3C,uDAAqC;AACrC,qDAAmC;AACnC,6DAA2C;AAC3C,QAAQ;AACR,0DAAwC;AACxC,4DAA0C;AAC1C,4DAA0C;AAC1C,oDAAkC"}
|
|
@@ -67,6 +67,12 @@ export declare class AgentEntity extends TrackableEntity<Agent> {
|
|
|
67
67
|
* @param props - Partial properties to initialize the entity
|
|
68
68
|
*/
|
|
69
69
|
constructor(props?: Partial<AgentEntity>);
|
|
70
|
+
/**
|
|
71
|
+
* Get agent by promotion code
|
|
72
|
+
* @param code Promotion code
|
|
73
|
+
* @returns AgentEntity or undefined if not found
|
|
74
|
+
*/
|
|
75
|
+
static getByCode(code: string): Promise<AgentEntity>;
|
|
70
76
|
/**
|
|
71
77
|
* Converts the entity to an Agent model instance
|
|
72
78
|
* @returns Agent model with basic information
|
|
@@ -87,9 +93,30 @@ export declare class AgentEntity extends TrackableEntity<Agent> {
|
|
|
87
93
|
* @returns Array of Preference objects or undefined if not set
|
|
88
94
|
*/
|
|
89
95
|
getPreferences(): Preference<boolean>[];
|
|
96
|
+
/**
|
|
97
|
+
* Checks if notifications are enabled for a specific event
|
|
98
|
+
* @param event Event name to check
|
|
99
|
+
* @returns True if notifications are enabled, false otherwise
|
|
100
|
+
*/
|
|
101
|
+
isNotificationEnabled(event: string): boolean;
|
|
90
102
|
/**
|
|
91
103
|
* Retrieves activity history for this agent
|
|
92
104
|
* @returns Promise resolving to array of Activity instances tracking creation and updates
|
|
93
105
|
*/
|
|
94
106
|
getActivities(): Promise<Activity[]>;
|
|
107
|
+
/**
|
|
108
|
+
* Log agent event
|
|
109
|
+
* @param event Event type
|
|
110
|
+
* @param metadata Content render data (in agent language)
|
|
111
|
+
* @param entityId Optional related entity ID
|
|
112
|
+
*/
|
|
113
|
+
log(event: string, metadata?: any, entityId?: number): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Log agent from author perspective
|
|
116
|
+
* Author logs are used to capture actions taken by the agent themselves
|
|
117
|
+
* @param event Event type
|
|
118
|
+
* @param metadata Content render data (in student language)
|
|
119
|
+
* @param entityId Optional related entity ID
|
|
120
|
+
*/
|
|
121
|
+
logAsAuthor(event: string, metadata?: any, entityId?: number): Promise<void>;
|
|
95
122
|
}
|
|
@@ -8,12 +8,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var AgentEntity_1;
|
|
11
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
13
|
exports.AgentEntity = void 0;
|
|
13
14
|
const typeorm_1 = require("typeorm");
|
|
14
15
|
const common_1 = require("@driveup/common");
|
|
15
16
|
const common_2 = require("@driveup/common");
|
|
16
17
|
const user_entity_1 = require("../../user/user.entity");
|
|
18
|
+
const log_entity_1 = require("../../system/event/log.entity");
|
|
17
19
|
const payout_entity_1 = require("./payout.entity");
|
|
18
20
|
const promotion_entity_1 = require("./promotion.entity");
|
|
19
21
|
const trackable_1 = require("../../utils/trackable");
|
|
@@ -26,7 +28,7 @@ const activity_helper_1 = require("../../utils/activity.helper");
|
|
|
26
28
|
*
|
|
27
29
|
* @extends TrackableEntity<Agent>
|
|
28
30
|
*/
|
|
29
|
-
let AgentEntity = class AgentEntity extends trackable_1.TrackableEntity {
|
|
31
|
+
let AgentEntity = AgentEntity_1 = class AgentEntity extends trackable_1.TrackableEntity {
|
|
30
32
|
/**
|
|
31
33
|
* Creates an instance of AgentEntity
|
|
32
34
|
* @param props - Partial properties to initialize the entity
|
|
@@ -35,6 +37,14 @@ let AgentEntity = class AgentEntity extends trackable_1.TrackableEntity {
|
|
|
35
37
|
super();
|
|
36
38
|
Object.assign(this, props);
|
|
37
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Get agent by promotion code
|
|
42
|
+
* @param code Promotion code
|
|
43
|
+
* @returns AgentEntity or undefined if not found
|
|
44
|
+
*/
|
|
45
|
+
static async getByCode(code) {
|
|
46
|
+
return AgentEntity_1.findOneBy({ code });
|
|
47
|
+
}
|
|
38
48
|
/**
|
|
39
49
|
* Converts the entity to an Agent model instance
|
|
40
50
|
* @returns Agent model with basic information
|
|
@@ -89,6 +99,18 @@ let AgentEntity = class AgentEntity extends trackable_1.TrackableEntity {
|
|
|
89
99
|
return;
|
|
90
100
|
return this.preferences.map(common_2.Preference.toInstance);
|
|
91
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Checks if notifications are enabled for a specific event
|
|
104
|
+
* @param event Event name to check
|
|
105
|
+
* @returns True if notifications are enabled, false otherwise
|
|
106
|
+
*/
|
|
107
|
+
isNotificationEnabled(event) {
|
|
108
|
+
const preferences = this.getPreferences();
|
|
109
|
+
if (!preferences)
|
|
110
|
+
return true;
|
|
111
|
+
const eventPref = preferences.find(p => p.name === event && p.scope === common_1.PreferenceScope.Notification);
|
|
112
|
+
return eventPref.value === true;
|
|
113
|
+
}
|
|
92
114
|
/**
|
|
93
115
|
* Retrieves activity history for this agent
|
|
94
116
|
* @returns Promise resolving to array of Activity instances tracking creation and updates
|
|
@@ -101,6 +123,41 @@ let AgentEntity = class AgentEntity extends trackable_1.TrackableEntity {
|
|
|
101
123
|
activities.push(await (0, activity_helper_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
|
|
102
124
|
return activities.filter(a => a);
|
|
103
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Log agent event
|
|
128
|
+
* @param event Event type
|
|
129
|
+
* @param metadata Content render data (in agent language)
|
|
130
|
+
* @param entityId Optional related entity ID
|
|
131
|
+
*/
|
|
132
|
+
async log(event, metadata, entityId) {
|
|
133
|
+
if (!this.id)
|
|
134
|
+
return;
|
|
135
|
+
await log_entity_1.LogEntity.from({
|
|
136
|
+
type: common_1.LogType.Agent,
|
|
137
|
+
event: event,
|
|
138
|
+
entityId: entityId,
|
|
139
|
+
profile: { type: common_1.ProfileType.Agent, id: this.id },
|
|
140
|
+
content: log_entity_1.LogEntity.toAgentContent(event, this.language, metadata)
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Log agent from author perspective
|
|
145
|
+
* Author logs are used to capture actions taken by the agent themselves
|
|
146
|
+
* @param event Event type
|
|
147
|
+
* @param metadata Content render data (in student language)
|
|
148
|
+
* @param entityId Optional related entity ID
|
|
149
|
+
*/
|
|
150
|
+
async logAsAuthor(event, metadata, entityId) {
|
|
151
|
+
if (!this.id)
|
|
152
|
+
return;
|
|
153
|
+
await log_entity_1.LogEntity.from({
|
|
154
|
+
type: common_1.LogType.Agent,
|
|
155
|
+
event: event,
|
|
156
|
+
entityId: entityId,
|
|
157
|
+
profile: { type: common_1.ProfileType.Agent, id: this.id },
|
|
158
|
+
content: log_entity_1.LogEntity.toAuthorContent(event, this.language, metadata)
|
|
159
|
+
});
|
|
160
|
+
}
|
|
104
161
|
};
|
|
105
162
|
exports.AgentEntity = AgentEntity;
|
|
106
163
|
__decorate([
|
|
@@ -168,7 +225,7 @@ __decorate([
|
|
|
168
225
|
(0, typeorm_1.OneToMany)(() => payout_entity_1.AgentPayoutEntity, payout => payout.agent),
|
|
169
226
|
__metadata("design:type", Promise)
|
|
170
227
|
], AgentEntity.prototype, "payouts", void 0);
|
|
171
|
-
exports.AgentEntity = AgentEntity = __decorate([
|
|
228
|
+
exports.AgentEntity = AgentEntity = AgentEntity_1 = __decorate([
|
|
172
229
|
(0, typeorm_1.Entity)('agents'),
|
|
173
230
|
__metadata("design:paramtypes", [Object])
|
|
174
231
|
], AgentEntity);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.entity.js","sourceRoot":"","sources":["../../../src/profile/agent/agent.entity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent.entity.js","sourceRoot":"","sources":["../../../src/profile/agent/agent.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAA+D;AAC/D,4CAAwI;AACxI,4CAA0D;AAC1D,wDAAoD;AACpD,8DAA0D;AAC1D,mDAAoD;AACpD,yDAA0D;AAC1D,qDAAwD;AACxD,iEAAyD;AAEzD;;;;;;;GAOG;AAEI,IAAM,WAAW,mBAAjB,MAAM,WAAY,SAAQ,2BAAsB;IA8FtD;;;OAGG;IACH,YAAY,KAA4B;QACvC,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,IAAY;QAClC,OAAO,aAAW,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC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AAM,EAAC;QACP,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,iBAAQ;QACd,OAAO,EAAE,iBAAQ,CAAC,EAAE;QACpB,QAAQ,EAAE,IAAI;KACd,CAAC;;6CACiB;AAOnB;IADC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;yCACZ;AAOb;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;+CACL;AAUnB;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;8BACW,oBAAW;gDAAC;AAUzB;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;gDACwB;AAO1B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAU,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC;;yCAC/B;AAMzB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uCAAoB,EAAE,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;;+CACxB;AAM5C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,iCAAiB,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;;4CACrB;sBA5F1B,WAAW;IADvB,IAAA,gBAAM,EAAC,QAAQ,CAAC;;GACJ,WAAW,CAoOvB"}
|
|
@@ -231,4 +231,11 @@ export declare class CompanyEntity extends TrackableEntity<Company> {
|
|
|
231
231
|
* @returns Promise resolving to array of Activity instances tracking creation, updates, and closure
|
|
232
232
|
*/
|
|
233
233
|
getActivities(): Promise<Activity[]>;
|
|
234
|
+
/**
|
|
235
|
+
* Log company event
|
|
236
|
+
* @param event Event type
|
|
237
|
+
* @param metadata Content render data (in company language)
|
|
238
|
+
* @param entityId Optional related entity ID
|
|
239
|
+
*/
|
|
240
|
+
log(event: string, metadata?: any, entityId?: number): Promise<void>;
|
|
234
241
|
}
|
|
@@ -15,6 +15,7 @@ const common_1 = require("@driveup/common");
|
|
|
15
15
|
const common_2 = require("@driveup/common");
|
|
16
16
|
const common_3 = require("@driveup/common");
|
|
17
17
|
const country_entity_1 = require("../../system/country/country.entity");
|
|
18
|
+
const log_entity_1 = require("../../system/event/log.entity");
|
|
18
19
|
const expense_entity_1 = require("./finances/expense/expense.entity");
|
|
19
20
|
const category_entity_1 = require("./finances/expense/category.entity");
|
|
20
21
|
const handover_entity_1 = require("./finances/handover/handover.entity");
|
|
@@ -181,6 +182,21 @@ let CompanyEntity = class CompanyEntity extends trackable_1.TrackableEntity {
|
|
|
181
182
|
activities.push(await (0, activity_helper_1.toActivity)(this.closedOn, common_1.ActivityType.closedOn));
|
|
182
183
|
return activities.filter(a => a);
|
|
183
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Log company event
|
|
187
|
+
* @param event Event type
|
|
188
|
+
* @param metadata Content render data (in company language)
|
|
189
|
+
* @param entityId Optional related entity ID
|
|
190
|
+
*/
|
|
191
|
+
async log(event, metadata, entityId) {
|
|
192
|
+
await log_entity_1.LogEntity.from({
|
|
193
|
+
type: common_1.LogType.Company,
|
|
194
|
+
event: event,
|
|
195
|
+
entityId: entityId,
|
|
196
|
+
profile: { type: common_1.ProfileType.Company, id: this.id },
|
|
197
|
+
content: log_entity_1.LogEntity.toCompanyContent(event, this.language, metadata)
|
|
198
|
+
});
|
|
199
|
+
}
|
|
184
200
|
};
|
|
185
201
|
exports.CompanyEntity = CompanyEntity;
|
|
186
202
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"company.entity.js","sourceRoot":"","sources":["../../../src/profile/company/company.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0E;AAC1E,
|
|
1
|
+
{"version":3,"file":"company.entity.js","sour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AI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;4CACrB;AAMpC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,0CAA0B,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;;qDAChB;AAMtD;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,2CAAuB,EAAE,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;;kDAC3B;AAMhD;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,qCAAoB,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;+CACxB;AAM1C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8CAA4B,EAAE,eAAe,CAAC,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC;;wDAC/B;AAM3D;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uCAAqB,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;;gDACzB;AAM5C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,qCAAoB,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;+CACxB;AAM1C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uCAAoB,EAAE,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;;sDACrB;wBA3SrC,aAAa;IADzB,IAAA,gBAAM,EAAC,WAAW,CAAC;;GACP,aAAa,CA0dzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountStatus, Activity, Instructor } from '@driveup/common';
|
|
1
|
+
import { AccountStatus, Activity, Instructor, Language } from '@driveup/common';
|
|
2
2
|
import { WorkingHours, Holiday, Preference, CompanyRole } from '@driveup/common';
|
|
3
3
|
import { CompanyEntity } from '../company.entity';
|
|
4
4
|
import { CompanyInstructorTaskEntity } from './task.entity';
|
|
@@ -16,6 +16,12 @@ export declare class CompanyInstructorEntity extends TrackableEntity<Instructor>
|
|
|
16
16
|
companyId: number;
|
|
17
17
|
status: AccountStatus;
|
|
18
18
|
role: CompanyRole;
|
|
19
|
+
/**
|
|
20
|
+
* Preferred language for the instructor interface
|
|
21
|
+
* Currently in sync with UserEntity.language not offered separately
|
|
22
|
+
* @default Language.En
|
|
23
|
+
*/
|
|
24
|
+
language: Language;
|
|
19
25
|
/**
|
|
20
26
|
* Instructor working hours definition
|
|
21
27
|
* @attention must get a default value of empty object array when creating the entity
|
|
@@ -82,4 +88,30 @@ export declare class CompanyInstructorEntity extends TrackableEntity<Instructor>
|
|
|
82
88
|
getInstructor(): Promise<InstructorEntity>;
|
|
83
89
|
canReinstate(): Promise<boolean>;
|
|
84
90
|
getActivities(): Promise<Activity[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Log instructor event
|
|
93
|
+
* @param event Event type
|
|
94
|
+
* @param metadata Content render data (in instructor language)
|
|
95
|
+
* @param entityId Optional related entity ID
|
|
96
|
+
*/
|
|
97
|
+
log(event: string, metadata?: any, entityId?: number): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Log event from authoring perspective.
|
|
100
|
+
* Author logs are used to capture actions taken by the instructor themselves
|
|
101
|
+
* @param event Event type
|
|
102
|
+
* @param metadata Content render data (in instructor language)
|
|
103
|
+
* @param entityId Optional related entity ID
|
|
104
|
+
*/
|
|
105
|
+
logAsAuthor(event: string, metadata?: any, entityId?: number): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Retrieves notification preferences as typed Preference instances
|
|
108
|
+
* @returns Array of Preference objects or undefined if not set
|
|
109
|
+
*/
|
|
110
|
+
getPreferences(): Preference<boolean>[];
|
|
111
|
+
/**
|
|
112
|
+
* Checks if notifications are enabled for a specific event
|
|
113
|
+
* @param event Event name to check
|
|
114
|
+
* @returns True if notifications are enabled, false otherwise
|
|
115
|
+
*/
|
|
116
|
+
isNotificationEnabled(event: string): boolean;
|
|
85
117
|
}
|
|
@@ -13,6 +13,7 @@ exports.CompanyInstructorEntity = void 0;
|
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const common_1 = require("@driveup/common");
|
|
15
15
|
const common_2 = require("@driveup/common");
|
|
16
|
+
const log_entity_1 = require("../../../system/event/log.entity");
|
|
16
17
|
const company_entity_1 = require("../company.entity");
|
|
17
18
|
const task_entity_1 = require("./task.entity");
|
|
18
19
|
const instructor_entity_1 = require("../../instructor/instructor.entity");
|
|
@@ -73,6 +74,62 @@ let CompanyInstructorEntity = class CompanyInstructorEntity extends trackable_1.
|
|
|
73
74
|
activities.push(await (0, activity_helper_1.toActivity)(this.invitedOn, common_1.ActivityType.invitedOn));
|
|
74
75
|
return activities.filter(a => a);
|
|
75
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Log instructor event
|
|
79
|
+
* @param event Event type
|
|
80
|
+
* @param metadata Content render data (in instructor language)
|
|
81
|
+
* @param entityId Optional related entity ID
|
|
82
|
+
*/
|
|
83
|
+
async log(event, metadata, entityId) {
|
|
84
|
+
if (!this.id)
|
|
85
|
+
return;
|
|
86
|
+
await log_entity_1.LogEntity.from({
|
|
87
|
+
type: common_1.LogType.Instructor,
|
|
88
|
+
event: event,
|
|
89
|
+
entityId: entityId,
|
|
90
|
+
profile: { type: common_1.ProfileType.Company, id: this.id },
|
|
91
|
+
content: log_entity_1.LogEntity.toInstructorContent(event, this.language, metadata)
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Log event from authoring perspective.
|
|
96
|
+
* Author logs are used to capture actions taken by the instructor themselves
|
|
97
|
+
* @param event Event type
|
|
98
|
+
* @param metadata Content render data (in instructor language)
|
|
99
|
+
* @param entityId Optional related entity ID
|
|
100
|
+
*/
|
|
101
|
+
async logAsAuthor(event, metadata, entityId) {
|
|
102
|
+
if (!this.id)
|
|
103
|
+
return;
|
|
104
|
+
await log_entity_1.LogEntity.from({
|
|
105
|
+
type: common_1.LogType.Instructor,
|
|
106
|
+
event: event,
|
|
107
|
+
entityId: entityId,
|
|
108
|
+
profile: { type: common_1.ProfileType.Company, id: this.id },
|
|
109
|
+
content: log_entity_1.LogEntity.toAuthorContent(event, this.language, metadata)
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Retrieves notification preferences as typed Preference instances
|
|
114
|
+
* @returns Array of Preference objects or undefined if not set
|
|
115
|
+
*/
|
|
116
|
+
getPreferences() {
|
|
117
|
+
if (!this.preferences)
|
|
118
|
+
return;
|
|
119
|
+
return this.preferences.map(common_2.Preference.toInstance);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Checks if notifications are enabled for a specific event
|
|
123
|
+
* @param event Event name to check
|
|
124
|
+
* @returns True if notifications are enabled, false otherwise
|
|
125
|
+
*/
|
|
126
|
+
isNotificationEnabled(event) {
|
|
127
|
+
const preferences = this.getPreferences();
|
|
128
|
+
if (!preferences)
|
|
129
|
+
return true;
|
|
130
|
+
const eventPref = preferences.find(p => p.name === event && p.scope === common_1.PreferenceScope.Notification);
|
|
131
|
+
return eventPref.value === true;
|
|
132
|
+
}
|
|
76
133
|
};
|
|
77
134
|
exports.CompanyInstructorEntity = CompanyInstructorEntity;
|
|
78
135
|
__decorate([
|
|
@@ -101,6 +158,15 @@ __decorate([
|
|
|
101
158
|
}),
|
|
102
159
|
__metadata("design:type", String)
|
|
103
160
|
], CompanyInstructorEntity.prototype, "role", void 0);
|
|
161
|
+
__decorate([
|
|
162
|
+
(0, typeorm_1.Column)({
|
|
163
|
+
type: 'enum',
|
|
164
|
+
enum: common_1.Language,
|
|
165
|
+
default: common_1.Language.En,
|
|
166
|
+
nullable: true
|
|
167
|
+
}),
|
|
168
|
+
__metadata("design:type", String)
|
|
169
|
+
], CompanyInstructorEntity.prototype, "language", void 0);
|
|
104
170
|
__decorate([
|
|
105
171
|
(0, typeorm_1.Column)({
|
|
106
172
|
type: 'simple-json',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructor.entity.js","sourceRoot":"","sources":["../../../../src/profile/company/instructor/instructor.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA+D;AAC/D,
|
|
1
|
+
{"version":3,"file":"instructor.entity.js","sourceRoot":"","sources":["../../../../src/profile/company/instructor/instructor.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA+D;AAC/D,4CAAqI;AACrI,4CAAiF;AACjF,iEAA6D;AAC7D,sDAAkD;AAClD,+CAA4D;AAC5D,0EAAsE;AACtE,0EAA6E;AAC7E,2DAA8D;AAC9D,2DAAoE;AACpE,oFAAuF;AACvF,0FAAqG;AACrG,qEAA8E;AAC9E,gFAA2F;AAC3F,wDAA2D;AAC3D,oEAA4D;AAGrD,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,2BAA2B;IAgJvE,YAAY,KAAwC;QACnD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;QACrC,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QAC1C,UAAU,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACxB,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAChC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAC5B,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACtC,UAAU,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,qBAAY,CAAC,UAAU,CAAC,CAAC;QAC1E,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,gBAAO,CAAC,UAAU,CAAC,CAAC;QAC7D,U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DACxB;kCA9IlC,uBAAuB;IADnC,IAAA,gBAAM,EAAC,oBAAoB,CAAC;;GAChB,uBAAuB,CA6PnC"}
|
|
@@ -22,6 +22,7 @@ export declare class InstructorEntity extends TrackableEntity<Instructor> {
|
|
|
22
22
|
status: AccountStatus;
|
|
23
23
|
/**
|
|
24
24
|
* Preferred language for the instructor interface
|
|
25
|
+
* Currently in sync with UserEntity.language not offered separately
|
|
25
26
|
* @default Language.En
|
|
26
27
|
*/
|
|
27
28
|
language: Language;
|
|
@@ -66,15 +67,36 @@ export declare class InstructorEntity extends TrackableEntity<Instructor> {
|
|
|
66
67
|
* @returns Promise resolving to Person model with basic contact information
|
|
67
68
|
*/
|
|
68
69
|
toPerson(): Promise<Person>;
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves all activity records for this instructor
|
|
72
|
+
* Includes creation and update actions
|
|
73
|
+
* @returns Array of Activity objects
|
|
74
|
+
*/
|
|
75
|
+
getActivities(): Promise<Activity[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Log instructor event
|
|
78
|
+
* @param event Event type
|
|
79
|
+
* @param metadata Content render data (in instructor language)
|
|
80
|
+
* @param entityId Optional related entity ID
|
|
81
|
+
*/
|
|
82
|
+
log(event: string, metadata?: any, entityId?: number): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Log event from authoring perspective.
|
|
85
|
+
* Author logs are used to capture actions taken by the instructor themselves
|
|
86
|
+
* @param event Event type
|
|
87
|
+
* @param metadata Content render data (in instructor language)
|
|
88
|
+
* @param entityId Optional related entity ID
|
|
89
|
+
*/
|
|
90
|
+
logAsAuthor(event: string, metadata?: any, entityId?: number): Promise<void>;
|
|
69
91
|
/**
|
|
70
92
|
* Retrieves notification preferences as typed Preference instances
|
|
71
93
|
* @returns Array of Preference objects or undefined if not set
|
|
72
94
|
*/
|
|
73
95
|
getPreferences(): Preference<boolean>[];
|
|
74
96
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @returns
|
|
97
|
+
* Checks if notifications are enabled for a specific event
|
|
98
|
+
* @param event Event name to check
|
|
99
|
+
* @returns True if notifications are enabled, false otherwise
|
|
78
100
|
*/
|
|
79
|
-
|
|
101
|
+
isNotificationEnabled(event: string): boolean;
|
|
80
102
|
}
|
|
@@ -14,6 +14,7 @@ const typeorm_1 = require("typeorm");
|
|
|
14
14
|
const common_1 = require("@driveup/common");
|
|
15
15
|
const common_2 = require("@driveup/common");
|
|
16
16
|
const user_entity_1 = require("../../user/user.entity");
|
|
17
|
+
const log_entity_1 = require("../../system/event/log.entity");
|
|
17
18
|
const instructor_entity_1 = require("../company/instructor/instructor.entity");
|
|
18
19
|
const trackable_1 = require("../../utils/trackable");
|
|
19
20
|
const activity_helper_1 = require("../../utils/activity.helper");
|
|
@@ -70,15 +71,6 @@ let InstructorEntity = class InstructorEntity extends trackable_1.TrackableEntit
|
|
|
70
71
|
email: user.email
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Retrieves notification preferences as typed Preference instances
|
|
75
|
-
* @returns Array of Preference objects or undefined if not set
|
|
76
|
-
*/
|
|
77
|
-
getPreferences() {
|
|
78
|
-
if (!this.preferences)
|
|
79
|
-
return;
|
|
80
|
-
return this.preferences.map(common_1.Preference.toInstance);
|
|
81
|
-
}
|
|
82
74
|
/**
|
|
83
75
|
* Retrieves all activity records for this instructor
|
|
84
76
|
* Includes creation and update actions
|
|
@@ -92,6 +84,62 @@ let InstructorEntity = class InstructorEntity extends trackable_1.TrackableEntit
|
|
|
92
84
|
activities.push(await (0, activity_helper_1.toActivity)(this.updatedOn, common_2.ActivityType.updatedOn));
|
|
93
85
|
return activities.filter(a => a);
|
|
94
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Log instructor event
|
|
89
|
+
* @param event Event type
|
|
90
|
+
* @param metadata Content render data (in instructor language)
|
|
91
|
+
* @param entityId Optional related entity ID
|
|
92
|
+
*/
|
|
93
|
+
async log(event, metadata, entityId) {
|
|
94
|
+
if (!this.id)
|
|
95
|
+
return;
|
|
96
|
+
await log_entity_1.LogEntity.from({
|
|
97
|
+
type: common_1.LogType.Instructor,
|
|
98
|
+
event: event,
|
|
99
|
+
entityId: entityId,
|
|
100
|
+
profile: { type: common_1.ProfileType.Company, id: this.id },
|
|
101
|
+
content: log_entity_1.LogEntity.toInstructorContent(event, this.language, metadata)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Log event from authoring perspective.
|
|
106
|
+
* Author logs are used to capture actions taken by the instructor themselves
|
|
107
|
+
* @param event Event type
|
|
108
|
+
* @param metadata Content render data (in instructor language)
|
|
109
|
+
* @param entityId Optional related entity ID
|
|
110
|
+
*/
|
|
111
|
+
async logAsAuthor(event, metadata, entityId) {
|
|
112
|
+
if (!this.id)
|
|
113
|
+
return;
|
|
114
|
+
await log_entity_1.LogEntity.from({
|
|
115
|
+
type: common_1.LogType.Instructor,
|
|
116
|
+
event: event,
|
|
117
|
+
entityId: entityId,
|
|
118
|
+
profile: { type: common_1.ProfileType.Company, id: this.id },
|
|
119
|
+
content: log_entity_1.LogEntity.toAuthorContent(event, this.language, metadata)
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Retrieves notification preferences as typed Preference instances
|
|
124
|
+
* @returns Array of Preference objects or undefined if not set
|
|
125
|
+
*/
|
|
126
|
+
getPreferences() {
|
|
127
|
+
if (!this.preferences)
|
|
128
|
+
return;
|
|
129
|
+
return this.preferences.map(common_1.Preference.toInstance);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Checks if notifications are enabled for a specific event
|
|
133
|
+
* @param event Event name to check
|
|
134
|
+
* @returns True if notifications are enabled, false otherwise
|
|
135
|
+
*/
|
|
136
|
+
isNotificationEnabled(event) {
|
|
137
|
+
const preferences = this.getPreferences();
|
|
138
|
+
if (!preferences)
|
|
139
|
+
return true;
|
|
140
|
+
const eventPref = preferences.find(p => p.name === event && p.scope === common_1.PreferenceScope.Notification);
|
|
141
|
+
return eventPref.value === true;
|
|
142
|
+
}
|
|
95
143
|
};
|
|
96
144
|
exports.InstructorEntity = InstructorEntity;
|
|
97
145
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructor.entity.js","sourceRoot":"","sources":["../../../src/profile/instructor/instructor.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA+D;AAC/D,
|
|
1
|
+
{"version":3,"file":"instructor.entity.js","sourceRoot":"","sources":["../../../src/profile/instructor/instructor.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA+D;AAC/D,4CAAiI;AACjI,4CAAyD;AACzD,wDAAoD;AACpD,8DAA0D;AAC1D,+EAAkF;AAClF,qDAAwD;AACxD,iEAAyD;AAEzD;;;;;;GAMG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,2BAA2B;IAyEhE;;;OAGG;IACH,YAAY,KAAiC;QAC5C,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO;QACZ,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;QAC7B,OAAO,mBAAU,CAAC,UAAU,CAAC;YAC5B,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI;YAC5B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ;YACxC,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ;YACxC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,SAAS;QACd,OAAO,MAAM,IAAI,CAAC,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