@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
|
@@ -86,4 +86,30 @@ export declare class StudentEntity extends TrackableEntity<Student> {
|
|
|
86
86
|
* @returns Array of Activity objects
|
|
87
87
|
*/
|
|
88
88
|
getActivities(): Promise<Activity[]>;
|
|
89
|
+
/**
|
|
90
|
+
* Log student event
|
|
91
|
+
* @param event Event type
|
|
92
|
+
* @param metadata Content render data (in student language)
|
|
93
|
+
* @param entityId Optional related entity ID
|
|
94
|
+
*/
|
|
95
|
+
log(event: string, metadata?: any, entityId?: number): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Log student from author perspective.
|
|
98
|
+
* Author logs are used to capture actions taken by the student themselves
|
|
99
|
+
* @param event Event type
|
|
100
|
+
* @param metadata Content render data (in student language)
|
|
101
|
+
* @param entityId Optional related entity ID
|
|
102
|
+
*/
|
|
103
|
+
logAsAuthor(event: string, metadata?: any, entityId?: number): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Retrieves notification preferences as typed Preference instances
|
|
106
|
+
* @returns Array of Preference objects or undefined if not set
|
|
107
|
+
*/
|
|
108
|
+
getPreferences(): Preference<boolean>[];
|
|
109
|
+
/**
|
|
110
|
+
* Checks if notifications are enabled for a specific event
|
|
111
|
+
* @param event Event name to check
|
|
112
|
+
* @returns True if notifications are enabled, false otherwise
|
|
113
|
+
*/
|
|
114
|
+
isNotificationEnabled(event: string): boolean;
|
|
89
115
|
}
|
|
@@ -13,6 +13,7 @@ exports.StudentEntity = void 0;
|
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const common_1 = require("@driveup/common");
|
|
15
15
|
const user_entity_1 = require("../../user/user.entity");
|
|
16
|
+
const log_entity_1 = require("../../system/event/log.entity");
|
|
16
17
|
const licence_entity_1 = require("./program/licence/licence.entity");
|
|
17
18
|
const examination_entity_1 = require("./program/medical/examination.entity");
|
|
18
19
|
const program_entity_1 = require("./program/program.entity");
|
|
@@ -63,6 +64,62 @@ let StudentEntity = class StudentEntity extends trackable_1.TrackableEntity {
|
|
|
63
64
|
activities.push(await (0, activity_helper_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
|
|
64
65
|
return activities.filter(a => a);
|
|
65
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Log student event
|
|
69
|
+
* @param event Event type
|
|
70
|
+
* @param metadata Content render data (in student language)
|
|
71
|
+
* @param entityId Optional related entity ID
|
|
72
|
+
*/
|
|
73
|
+
async log(event, metadata, entityId) {
|
|
74
|
+
if (!this.id)
|
|
75
|
+
return;
|
|
76
|
+
await log_entity_1.LogEntity.from({
|
|
77
|
+
type: common_1.LogType.Student,
|
|
78
|
+
event: event,
|
|
79
|
+
entityId: entityId,
|
|
80
|
+
profile: { type: common_1.ProfileType.Student, id: this.id },
|
|
81
|
+
content: log_entity_1.LogEntity.toStudentContent(event, this.language, metadata)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Log student from author perspective.
|
|
86
|
+
* Author logs are used to capture actions taken by the student themselves
|
|
87
|
+
* @param event Event type
|
|
88
|
+
* @param metadata Content render data (in student language)
|
|
89
|
+
* @param entityId Optional related entity ID
|
|
90
|
+
*/
|
|
91
|
+
async logAsAuthor(event, metadata, entityId) {
|
|
92
|
+
if (!this.id)
|
|
93
|
+
return;
|
|
94
|
+
await log_entity_1.LogEntity.from({
|
|
95
|
+
type: common_1.LogType.Student,
|
|
96
|
+
event: event,
|
|
97
|
+
entityId: entityId,
|
|
98
|
+
profile: { type: common_1.ProfileType.Student, id: this.id },
|
|
99
|
+
content: log_entity_1.LogEntity.toAuthorContent(event, this.language, metadata)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Retrieves notification preferences as typed Preference instances
|
|
104
|
+
* @returns Array of Preference objects or undefined if not set
|
|
105
|
+
*/
|
|
106
|
+
getPreferences() {
|
|
107
|
+
if (!this.preferences)
|
|
108
|
+
return;
|
|
109
|
+
return this.preferences.map(common_1.Preference.toInstance);
|
|
110
|
+
}
|
|
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) {
|
|
117
|
+
const preferences = this.getPreferences();
|
|
118
|
+
if (!preferences)
|
|
119
|
+
return true;
|
|
120
|
+
const eventPref = preferences.find(p => p.name === event && p.scope === common_1.PreferenceScope.Notification);
|
|
121
|
+
return eventPref ? eventPref.value : true;
|
|
122
|
+
}
|
|
66
123
|
};
|
|
67
124
|
exports.StudentEntity = StudentEntity;
|
|
68
125
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"student.entity.js","sourceRoot":"","sources":["../../../src/profile/student/student.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA+D;AAC/D,
|
|
1
|
+
{"version":3,"file":"student.entity.js","sourceRoot":"","sources":["../../../src/profile/student/student.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA+D;AAC/D,4CAA8I;AAC9I,wDAAoD;AACpD,8DAA0D;AAC1D,qEAAwE;AACxE,6EAAuF;AACvF,6DAAgE;AAChE,6EAAuF;AACvF,qDAAwD;AACxD,iEAAyD;AAGlD,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,2BAAwB;IA8F1D;;;OAGG;IACH,YAAY,KAA8B;QACzC,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,IAAI,gBAAO,CAAC;YAClB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI;YAC5B,QAAQ,EAAE,IAAI,CAAC,QAAQ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EAAC;QACP,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,iBAAQ;QACd,OAAO,EAAE,iBAAQ,CAAC,EAAE;QACpB,QAAQ,EAAE,IAAI;KACd,CAAC;;+CACiB;AAanB;IANC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,sBAAa;QACnB,OAAO,EAAE,sBAAa,CAAC,OAAO;QAC9B,QAAQ,EAAE,KAAK;KACf,CAAC;;6CACoB;AAWtB;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;kDACwB;AAQ1B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAU,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC;;2CAChC;AAQ1B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,oDAA+B,EAAE,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;;0DACrB;AAQhE;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,oDAA+B,EAAE,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;;0DACrB;AAShE;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,qCAAoB,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;+CACxB;AAQ1C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,qCAAoB,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;+CACxB;wBA5F9B,aAAa;IADzB,IAAA,gBAAM,EAAC,UAAU,CAAC;;GACN,aAAa,CAoMzB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Activity, Campaigne, Content, Language } from '@driveup/common';
|
|
2
|
+
import { ProductType } from '@driveup/common';
|
|
3
|
+
import { CampaignGiftCodeEntity } from './gifcode.entity';
|
|
4
|
+
import { TrackableEntity } from '../../utils/trackable';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a marketing campaign in the system.
|
|
7
|
+
* Campaigns offer promotional discounts through gift codes that users can redeem.
|
|
8
|
+
* Each campaign targets specific products and has an expiration date.
|
|
9
|
+
* Gift amounts are credited to the user's product wallet upon redemption.
|
|
10
|
+
*
|
|
11
|
+
* @extends TrackableEntity
|
|
12
|
+
*/
|
|
13
|
+
export declare class CampaignEntity extends TrackableEntity<Campaigne> {
|
|
14
|
+
/**
|
|
15
|
+
* Product types this campaign applies to
|
|
16
|
+
* @default []
|
|
17
|
+
*/
|
|
18
|
+
products: ProductType[];
|
|
19
|
+
/**
|
|
20
|
+
* Localized content for the campaign (title, description, etc.)
|
|
21
|
+
*/
|
|
22
|
+
translations: Content[];
|
|
23
|
+
/**
|
|
24
|
+
* URL to the campaign's promotional image
|
|
25
|
+
*/
|
|
26
|
+
imageUrl: string;
|
|
27
|
+
/**
|
|
28
|
+
* Campaign discount amount
|
|
29
|
+
* This amount will be stored on product credit
|
|
30
|
+
*/
|
|
31
|
+
giftAmount: number;
|
|
32
|
+
/**
|
|
33
|
+
* Campaign expiration date - after this date, codes cannot be redeemed
|
|
34
|
+
*/
|
|
35
|
+
exipryDate: Date;
|
|
36
|
+
/**
|
|
37
|
+
* Gift codes associated with this campaign
|
|
38
|
+
*/
|
|
39
|
+
giftCodes: Promise<CampaignGiftCodeEntity[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new CampaignEntity instance
|
|
42
|
+
* @param props - Partial properties to initialize the entity
|
|
43
|
+
*/
|
|
44
|
+
constructor(props?: Partial<CampaignEntity>);
|
|
45
|
+
/**
|
|
46
|
+
* Converts the entity to a Campaigne model instance
|
|
47
|
+
* @param lang - Optional language for translations
|
|
48
|
+
* @returns Campaigne model with localized content
|
|
49
|
+
*/
|
|
50
|
+
toModel(lang?: Language): Campaigne;
|
|
51
|
+
toSummary(lang?: Language): Campaigne;
|
|
52
|
+
/**
|
|
53
|
+
* Retrieves all gift codes for this campaign
|
|
54
|
+
* @returns Promise resolving to array of GiftCode models
|
|
55
|
+
*/
|
|
56
|
+
getCodes(): Promise<import("@driveup/common").GiftCode[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the localized translation for the campaign
|
|
59
|
+
* @param lang - Optional language code; defaults to current i18n context
|
|
60
|
+
* @returns Content instance with translated title and description
|
|
61
|
+
*/
|
|
62
|
+
getTranslation(lang?: Language): Content;
|
|
63
|
+
/**
|
|
64
|
+
* Gets all available translations for the campaign
|
|
65
|
+
* @returns Array of Content instances for all languages
|
|
66
|
+
*/
|
|
67
|
+
getTranslations(): Content[];
|
|
68
|
+
getActivities(): Promise<Activity[]>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
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.CampaignEntity = 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 gifcode_entity_1 = require("./gifcode.entity");
|
|
18
|
+
const staff_entity_1 = require("../staff/staff.entity");
|
|
19
|
+
const trackable_1 = require("../../utils/trackable");
|
|
20
|
+
const activity_helper_1 = require("../../utils/activity.helper");
|
|
21
|
+
/**
|
|
22
|
+
* Represents a marketing campaign in the system.
|
|
23
|
+
* Campaigns offer promotional discounts through gift codes that users can redeem.
|
|
24
|
+
* Each campaign targets specific products and has an expiration date.
|
|
25
|
+
* Gift amounts are credited to the user's product wallet upon redemption.
|
|
26
|
+
*
|
|
27
|
+
* @extends TrackableEntity
|
|
28
|
+
*/
|
|
29
|
+
let CampaignEntity = class CampaignEntity extends trackable_1.TrackableEntity {
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new CampaignEntity instance
|
|
32
|
+
* @param props - Partial properties to initialize the entity
|
|
33
|
+
*/
|
|
34
|
+
constructor(props) {
|
|
35
|
+
super();
|
|
36
|
+
Object.assign(this, props);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts the entity to a Campaigne model instance
|
|
40
|
+
* @param lang - Optional language for translations
|
|
41
|
+
* @returns Campaigne model with localized content
|
|
42
|
+
*/
|
|
43
|
+
toModel(lang) {
|
|
44
|
+
const transaltion = this.getTranslation(lang);
|
|
45
|
+
return new common_1.Campaigne({
|
|
46
|
+
id: this.id,
|
|
47
|
+
title: transaltion.title,
|
|
48
|
+
description: transaltion.description,
|
|
49
|
+
giftAmount: this.giftAmount,
|
|
50
|
+
imageUrl: transaltion.imageUrl || this.imageUrl,
|
|
51
|
+
exipryDate: this.exipryDate,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
toSummary(lang) {
|
|
55
|
+
return this.toModel(lang);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves all gift codes for this campaign
|
|
59
|
+
* @returns Promise resolving to array of GiftCode models
|
|
60
|
+
*/
|
|
61
|
+
async getCodes() {
|
|
62
|
+
return await Promise.all((await this.giftCodes).map(async (codeEntity) => codeEntity.toModel()));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets the localized translation for the campaign
|
|
66
|
+
* @param lang - Optional language code; defaults to current i18n context
|
|
67
|
+
* @returns Content instance with translated title and description
|
|
68
|
+
*/
|
|
69
|
+
getTranslation(lang) {
|
|
70
|
+
const language = lang || nestjs_i18n_1.I18nContext.current()?.lang;
|
|
71
|
+
const translation = this.translations?.find(t => t.language === language);
|
|
72
|
+
return new common_1.Content({
|
|
73
|
+
title: translation?.title,
|
|
74
|
+
description: translation?.description,
|
|
75
|
+
content: translation?.content,
|
|
76
|
+
imageUrl: translation?.imageUrl,
|
|
77
|
+
link: translation?.link,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Gets all available translations for the campaign
|
|
82
|
+
* @returns Array of Content instances for all languages
|
|
83
|
+
*/
|
|
84
|
+
getTranslations() {
|
|
85
|
+
return this.translations?.map(t => new common_1.Content({
|
|
86
|
+
title: t.title,
|
|
87
|
+
description: t.description,
|
|
88
|
+
content: t.content,
|
|
89
|
+
imageUrl: t.imageUrl,
|
|
90
|
+
link: t.link,
|
|
91
|
+
language: t.language
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
async getActivities() {
|
|
95
|
+
const activities = [];
|
|
96
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy, staff_entity_1.StaffEntity));
|
|
97
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
98
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy, staff_entity_1.StaffEntity));
|
|
99
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
|
|
100
|
+
return activities.filter(a => a);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
exports.CampaignEntity = CampaignEntity;
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, typeorm_1.Column)({
|
|
106
|
+
type: 'set',
|
|
107
|
+
enum: common_2.ProductType,
|
|
108
|
+
default: [],
|
|
109
|
+
nullable: false
|
|
110
|
+
}),
|
|
111
|
+
__metadata("design:type", Array)
|
|
112
|
+
], CampaignEntity.prototype, "products", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
(0, typeorm_1.Column)({
|
|
115
|
+
type: 'simple-json',
|
|
116
|
+
nullable: true,
|
|
117
|
+
default: null
|
|
118
|
+
}),
|
|
119
|
+
__metadata("design:type", Array)
|
|
120
|
+
], CampaignEntity.prototype, "translations", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
(0, typeorm_1.Column)({
|
|
123
|
+
nullable: true,
|
|
124
|
+
default: null
|
|
125
|
+
}),
|
|
126
|
+
__metadata("design:type", String)
|
|
127
|
+
], CampaignEntity.prototype, "imageUrl", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
(0, typeorm_1.Column)({
|
|
130
|
+
type: 'decimal',
|
|
131
|
+
precision: 10,
|
|
132
|
+
scale: 2,
|
|
133
|
+
nullable: false,
|
|
134
|
+
default: 0
|
|
135
|
+
}),
|
|
136
|
+
__metadata("design:type", Number)
|
|
137
|
+
], CampaignEntity.prototype, "giftAmount", void 0);
|
|
138
|
+
__decorate([
|
|
139
|
+
(0, typeorm_1.Column)({
|
|
140
|
+
nullable: true,
|
|
141
|
+
default: null
|
|
142
|
+
}),
|
|
143
|
+
__metadata("design:type", Date)
|
|
144
|
+
], CampaignEntity.prototype, "exipryDate", void 0);
|
|
145
|
+
__decorate([
|
|
146
|
+
(0, typeorm_1.OneToMany)(() => gifcode_entity_1.CampaignGiftCodeEntity, giftCode => giftCode.campaign),
|
|
147
|
+
__metadata("design:type", Promise)
|
|
148
|
+
], CampaignEntity.prototype, "giftCodes", void 0);
|
|
149
|
+
exports.CampaignEntity = CampaignEntity = __decorate([
|
|
150
|
+
(0, typeorm_1.Entity)('systemCampaigns'),
|
|
151
|
+
__metadata("design:paramtypes", [Object])
|
|
152
|
+
], CampaignEntity);
|
|
153
|
+
//# sourceMappingURL=campaign.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaign.entity.js","sourceRoot":"","sources":["../../../src/system/campaign/campaign.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAoD;AACpD,6CAA0C;AAC1C,4CAAuF;AACvF,4CAA8C;AAC9C,qDAA0D;AAC1D,wDAAoD;AACpD,qDAAwD;AACxD,iEAAyD;AAEzD;;;;;;;GAOG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,2BAA0B;IA6D7D;;;OAGG;IACH,YAAY,KAA+B;QAC1C,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,IAAe;QACtB,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,IAAI,kBAAS,CAAC;YACpB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,WAAW,EAAE,WAAW,CAAC,WAAW;YACpC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,QAAQ,EAAE,WAAW,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ;YAC/C,UAAU,EAAE,IAAI,CAAC,UAAU;SAC3B,CAAC,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,IAAe;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ;QACb,OAAO,MAAM,OAAO,CAAC,GAAG,CACvB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,KAAK,EAAC,UAAU,EAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE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, ProfileType } from '@driveup/common';
|
|
2
|
+
import { CampaignEntity } from './campaign.entity';
|
|
3
|
+
import { TrackableEntity } from '../../utils/trackable';
|
|
4
|
+
/**
|
|
5
|
+
* Campaign gift code entity representing promotional codes for campaigns.
|
|
6
|
+
* Extends TrackableEntity to track creation and update information.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CampaignGiftCodeEntity extends TrackableEntity<GiftCode> {
|
|
9
|
+
/**
|
|
10
|
+
* The ID of the campaign this gift code belongs to
|
|
11
|
+
*/
|
|
12
|
+
campaignId: number;
|
|
13
|
+
/**
|
|
14
|
+
* Unique 8-character gift code
|
|
15
|
+
*/
|
|
16
|
+
code: string;
|
|
17
|
+
/**
|
|
18
|
+
* Profile type that can use this gift code (Company, Student, Agent)
|
|
19
|
+
*/
|
|
20
|
+
profile: ProfileType;
|
|
21
|
+
/**
|
|
22
|
+
* ID of the user who registered/used this gift code
|
|
23
|
+
*/
|
|
24
|
+
registredBy: number;
|
|
25
|
+
/**
|
|
26
|
+
* Timestamp when this gift code was registered/used
|
|
27
|
+
*/
|
|
28
|
+
registredOn: Date;
|
|
29
|
+
/**
|
|
30
|
+
* The campaign associated with this gift code
|
|
31
|
+
*/
|
|
32
|
+
campaign: CampaignEntity;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new CampaigneGiftCodeEntity instance
|
|
35
|
+
* @param props - Partial properties to initialize the entity with
|
|
36
|
+
*/
|
|
37
|
+
constructor(props?: Partial<CampaignGiftCodeEntity>);
|
|
38
|
+
/**
|
|
39
|
+
* Converts the entity to a GiftCode model instance
|
|
40
|
+
* @returns GiftCode model with basic gift code information
|
|
41
|
+
*/
|
|
42
|
+
toModel(): GiftCode;
|
|
43
|
+
/**
|
|
44
|
+
* Returns a summary representation of the gift code
|
|
45
|
+
* @returns GiftCode model instance (same as toModel())
|
|
46
|
+
*/
|
|
47
|
+
toSummary(): GiftCode;
|
|
48
|
+
/**
|
|
49
|
+
* Retrieves all tracked activities for this gift code
|
|
50
|
+
* Includes creation, registration timestamps and associated staff members
|
|
51
|
+
* @returns Array of Activity objects
|
|
52
|
+
*/
|
|
53
|
+
getActivities(): Promise<Activity[]>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
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.CampaignGiftCodeEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const common_1 = require("@driveup/common");
|
|
15
|
+
const campaign_entity_1 = require("./campaign.entity");
|
|
16
|
+
const staff_entity_1 = require("../staff/staff.entity");
|
|
17
|
+
const trackable_1 = require("../../utils/trackable");
|
|
18
|
+
const activity_helper_1 = require("../../utils/activity.helper");
|
|
19
|
+
/**
|
|
20
|
+
* Campaign gift code entity representing promotional codes for campaigns.
|
|
21
|
+
* Extends TrackableEntity to track creation and update information.
|
|
22
|
+
*/
|
|
23
|
+
let CampaignGiftCodeEntity = class CampaignGiftCodeEntity extends trackable_1.TrackableEntity {
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new CampaigneGiftCodeEntity instance
|
|
26
|
+
* @param props - Partial properties to initialize the entity with
|
|
27
|
+
*/
|
|
28
|
+
constructor(props) {
|
|
29
|
+
super();
|
|
30
|
+
Object.assign(this, props);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Converts the entity to a GiftCode model instance
|
|
34
|
+
* @returns GiftCode model with basic gift code information
|
|
35
|
+
*/
|
|
36
|
+
toModel() {
|
|
37
|
+
return new common_1.GiftCode({
|
|
38
|
+
id: this.id,
|
|
39
|
+
code: this.code,
|
|
40
|
+
profile: this.profile
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns a summary representation of the gift code
|
|
45
|
+
* @returns GiftCode model instance (same as toModel())
|
|
46
|
+
*/
|
|
47
|
+
toSummary() {
|
|
48
|
+
return this.toModel();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves all tracked activities for this gift code
|
|
52
|
+
* Includes creation, registration timestamps and associated staff members
|
|
53
|
+
* @returns Array of Activity objects
|
|
54
|
+
*/
|
|
55
|
+
async getActivities() {
|
|
56
|
+
const activities = [];
|
|
57
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy, staff_entity_1.StaffEntity));
|
|
58
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
59
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.registredBy, common_1.ActivityType.registredBy));
|
|
60
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.registredOn, common_1.ActivityType.registredOn));
|
|
61
|
+
return activities;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.CampaignGiftCodeEntity = CampaignGiftCodeEntity;
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, typeorm_1.Column)(),
|
|
67
|
+
__metadata("design:type", Number)
|
|
68
|
+
], CampaignGiftCodeEntity.prototype, "campaignId", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, typeorm_1.Column)({
|
|
71
|
+
nullable: false,
|
|
72
|
+
unique: true,
|
|
73
|
+
length: 8
|
|
74
|
+
}),
|
|
75
|
+
__metadata("design:type", String)
|
|
76
|
+
], CampaignGiftCodeEntity.prototype, "code", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
(0, typeorm_1.Column)({
|
|
79
|
+
type: 'enum',
|
|
80
|
+
enum: common_1.ProfileType,
|
|
81
|
+
default: common_1.ProfileType.Company,
|
|
82
|
+
nullable: true,
|
|
83
|
+
}),
|
|
84
|
+
__metadata("design:type", String)
|
|
85
|
+
], CampaignGiftCodeEntity.prototype, "profile", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
88
|
+
__metadata("design:type", Number)
|
|
89
|
+
], CampaignGiftCodeEntity.prototype, "registredBy", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
92
|
+
__metadata("design:type", Date)
|
|
93
|
+
], CampaignGiftCodeEntity.prototype, "registredOn", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, typeorm_1.ManyToMany)(() => campaign_entity_1.CampaignEntity, campaign => campaign.giftCodes),
|
|
96
|
+
__metadata("design:type", campaign_entity_1.CampaignEntity)
|
|
97
|
+
], CampaignGiftCodeEntity.prototype, "campaign", void 0);
|
|
98
|
+
exports.CampaignGiftCodeEntity = CampaignGiftCodeEntity = __decorate([
|
|
99
|
+
(0, typeorm_1.Entity)('systemCampaignGiftCodes'),
|
|
100
|
+
__metadata("design:paramtypes", [Object])
|
|
101
|
+
], CampaignGiftCodeEntity);
|
|
102
|
+
//# sourceMappingURL=gifcode.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gifcode.entity.js","sourceRoot":"","sources":["../../../src/system/campaign/gifcode.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAqD;AACrD,4CAAgF;AAChF,uDAAmD;AACnD,wDAAoD;AACpD,qDAAwD;A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M,EAAE,CAAC;KACT,CAAC;;oDACW;AAWb;IANC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,oBAAW;QACjB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,QAAQ,EAAE,IAAI;KACd,CAAC;;uDACmB;AAMrB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;2DACtB;AAMpB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BAC7B,IAAI;2DAAC;AAMlB;IADC,IAAA,oBAAU,EAAC,GAAG,EAAE,CAAC,gCAAc,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;8BACvD,gCAAc;wDAAC;iCA7Cb,sBAAsB;IADlC,IAAA,gBAAM,EAAC,yBAAyB,CAAC;;GACrB,sBAAsB,CAyFlC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Activity, BusinessEvent, ColorContext, NotificationChannel, ProfileType } from '@driveup/common';
|
|
2
|
+
import { TrackableEntity } from '../../utils/trackable';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a business event configuration in the system.
|
|
5
|
+
* Business events define system actions that can trigger notifications
|
|
6
|
+
* (e.g., account created, appointment scheduled, payment received).
|
|
7
|
+
* Each event can be configured with default preferences and notification channels.
|
|
8
|
+
*
|
|
9
|
+
* @extends TrackableEntity
|
|
10
|
+
*/
|
|
11
|
+
export declare class EventEntity extends TrackableEntity<BusinessEvent> {
|
|
12
|
+
/**
|
|
13
|
+
* Profile type that this event applies to
|
|
14
|
+
* @default ProfileType.Company
|
|
15
|
+
*/
|
|
16
|
+
profile: ProfileType;
|
|
17
|
+
/**
|
|
18
|
+
* This name is used to identify the event setting in the system.
|
|
19
|
+
* @description The event name should be unique and descriptive.
|
|
20
|
+
* @example 'user.account.closed'
|
|
21
|
+
* @see @driveup/common for a list of predefined event names.
|
|
22
|
+
*/
|
|
23
|
+
event: string;
|
|
24
|
+
/**
|
|
25
|
+
* Color context for the notification.
|
|
26
|
+
* @type {Context}
|
|
27
|
+
* @default Context.Info
|
|
28
|
+
*/
|
|
29
|
+
color: ColorContext;
|
|
30
|
+
/**
|
|
31
|
+
* Notification channel
|
|
32
|
+
* @type {NotificationChannel}
|
|
33
|
+
* @default NotificationChannel.App
|
|
34
|
+
*/
|
|
35
|
+
channel: NotificationChannel;
|
|
36
|
+
/**
|
|
37
|
+
* Indicates if the notification setting is active.
|
|
38
|
+
* If false, the notification will not be sent.
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
active: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Indicates if the user can change the notification preference.
|
|
44
|
+
* If false, the user cannot disable or enable this notification.
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
canPrefered: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Indicates if the notification setting is enabled by default.
|
|
50
|
+
* This is used to set the initial preference for users.
|
|
51
|
+
* If true, users will have this notification setting enabled by default.
|
|
52
|
+
* @default true
|
|
53
|
+
*/
|
|
54
|
+
isPrefered: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Sort order for the notification setting.
|
|
57
|
+
* This can be used to order the settings in the user interface.
|
|
58
|
+
* Lower numbers appear first.
|
|
59
|
+
* @default null
|
|
60
|
+
*/
|
|
61
|
+
sort: number;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a new BusinessEvent instance
|
|
64
|
+
* @param props - Partial properties to initialize the entity
|
|
65
|
+
*/
|
|
66
|
+
constructor(props?: Partial<EventEntity>);
|
|
67
|
+
static getByEvent(event: string): Promise<EventEntity>;
|
|
68
|
+
/**
|
|
69
|
+
* Converts the entity to a BusinessEvent model instance
|
|
70
|
+
* @returns BusinessEvent model with all business event properties
|
|
71
|
+
*/
|
|
72
|
+
toModel(): BusinessEvent;
|
|
73
|
+
/**
|
|
74
|
+
* Returns a summary representation of the business event
|
|
75
|
+
* @returns BusinessEvent model instance (same as toModel())
|
|
76
|
+
*/
|
|
77
|
+
toSummary(): BusinessEvent;
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves activity history for this business event
|
|
80
|
+
* @returns Promise resolving to array of Activity instances tracking creation and updates
|
|
81
|
+
*/
|
|
82
|
+
getActivities(): Promise<Activity[]>;
|
|
83
|
+
}
|