@driveup/schema 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/lib/profile/company/course/appointment.entity.d.ts +87 -1
  2. package/lib/profile/company/course/appointment.entity.js +294 -0
  3. package/lib/profile/company/course/appointment.entity.js.map +1 -1
  4. package/lib/profile/company/course/course.entity.d.ts +1 -3
  5. package/lib/profile/company/course/course.entity.js +0 -18
  6. package/lib/profile/company/course/course.entity.js.map +1 -1
  7. package/lib/profile/company/instructor/activity.entity.d.ts +11 -1
  8. package/lib/profile/company/instructor/activity.entity.js +14 -0
  9. package/lib/profile/company/instructor/activity.entity.js.map +1 -1
  10. package/lib/profile/student/program/program.entity.js +4 -1
  11. package/lib/profile/student/program/program.entity.js.map +1 -1
  12. package/lib/profile/student/program/training/appointment.entity.d.ts +8 -1
  13. package/lib/profile/student/program/training/appointment.entity.js +17 -3
  14. package/lib/profile/student/program/training/appointment.entity.js.map +1 -1
  15. package/lib/profile/student/program/training/training.entity.d.ts +12 -0
  16. package/lib/profile/student/program/training/training.entity.js +21 -4
  17. package/lib/profile/student/program/training/training.entity.js.map +1 -1
  18. package/lib/profile/student/student.entity.d.ts +13 -0
  19. package/lib/profile/student/student.entity.js +36 -0
  20. package/lib/profile/student/student.entity.js.map +1 -1
  21. package/lib/tsconfig.tsbuildinfo +1 -1
  22. package/lib/user/user.entity.d.ts +0 -4
  23. package/lib/user/user.entity.js +0 -8
  24. package/lib/user/user.entity.js.map +1 -1
  25. package/package.json +2 -2
  26. package/lib/profile/student/program/medical/examination.model.d.ts +0 -63
  27. package/lib/profile/student/program/medical/examination.model.js +0 -158
  28. package/lib/profile/student/program/medical/examination.model.js.map +0 -1
  29. package/lib/system/campaigne/campaign.entity.d.ts +0 -69
  30. package/lib/system/campaigne/campaign.entity.js +0 -153
  31. package/lib/system/campaigne/campaign.entity.js.map +0 -1
  32. package/lib/system/campaigne/gifcode.entity.d.ts +0 -54
  33. package/lib/system/campaigne/gifcode.entity.js +0 -102
  34. package/lib/system/campaigne/gifcode.entity.js.map +0 -1
  35. package/lib/system/event/business.entity.d.ts +0 -75
  36. package/lib/system/event/business.entity.js +0 -128
  37. package/lib/system/event/business.entity.js.map +0 -1
  38. package/lib/utils/index.d.ts +0 -4
  39. package/lib/utils/index.js +0 -21
  40. package/lib/utils/index.js.map +0 -1
  41. package/lib/utils/json-metrics.transform.d.ts +0 -35
  42. package/lib/utils/json-metrics.transform.js +0 -83
  43. package/lib/utils/json-metrics.transform.js.map +0 -1
  44. package/lib/utils/trackable.entity.d.ts +0 -82
  45. package/lib/utils/trackable.entity.js +0 -69
  46. package/lib/utils/trackable.entity.js.map +0 -1
@@ -1,102 +0,0 @@
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.CampaigneGiftCodeEntity = 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 CampaigneGiftCodeEntity = class CampaigneGiftCodeEntity 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.CampaigneGiftCodeEntity = CampaigneGiftCodeEntity;
65
- __decorate([
66
- (0, typeorm_1.Column)(),
67
- __metadata("design:type", Number)
68
- ], CampaigneGiftCodeEntity.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
- ], CampaigneGiftCodeEntity.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
- ], CampaigneGiftCodeEntity.prototype, "profile", void 0);
86
- __decorate([
87
- (0, typeorm_1.Column)({ nullable: true, default: null }),
88
- __metadata("design:type", Number)
89
- ], CampaigneGiftCodeEntity.prototype, "registredBy", void 0);
90
- __decorate([
91
- (0, typeorm_1.Column)({ nullable: true, default: null }),
92
- __metadata("design:type", Date)
93
- ], CampaigneGiftCodeEntity.prototype, "registredOn", void 0);
94
- __decorate([
95
- (0, typeorm_1.ManyToMany)(() => campaign_entity_1.CampaigneEntity, campaign => campaign.giftCodes),
96
- __metadata("design:type", campaign_entity_1.CampaigneEntity)
97
- ], CampaigneGiftCodeEntity.prototype, "campaign", void 0);
98
- exports.CampaigneGiftCodeEntity = CampaigneGiftCodeEntity = __decorate([
99
- (0, typeorm_1.Entity)('systemCampaigneGiftCodes'),
100
- __metadata("design:paramtypes", [Object])
101
- ], CampaigneGiftCodeEntity);
102
- //# sourceMappingURL=gifcode.entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gifcode.entity.js","sourceRoot":"","sources":["../../../src/system/campaigne/gifcode.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAqD;AACrD,4CAAgF;AAChF,uDAAoD;AACpD,wDAAoD;AACpD,qDAAwD;AACxD,iEAAyD;AAEzD;;;GAGG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,2BAAyB;IA+CrE;;;OAGG;IACH,YAAY,KAAwC;QACnD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,OAAO;QACN,OAAO,IAAI,iBAAQ,CAAC;YACnB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,SAAS;QACR,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,aA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C;8BACxD,iCAAe;yDAAC;kCA7Cd,uBAAuB;IADnC,IAAA,gBAAM,EAAC,0BAA0B,CAAC;;GACtB,uBAAuB,CAyFnC"}
@@ -1,75 +0,0 @@
1
- import { Activity, ColorContext, Content, 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 BusinessEvent extends TrackableEntity<BusinessEvent> {
12
- /**
13
- * Profile type that this event applies to
14
- * @default ProfileType.Company
15
- */
16
- scope: 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
- * Translations for the notification content.
26
- * Exlain user what the notification is about in different languages.
27
- */
28
- translations: Content[];
29
- /**
30
- * Color context for the notification.
31
- * @type {Context}
32
- * @default Context.Info
33
- */
34
- color: ColorContext;
35
- /**
36
- * Notification channel
37
- * @type {NotificationChannel}
38
- * @default NotificationChannel.App
39
- */
40
- channel: NotificationChannel;
41
- /**
42
- * Indicates if the notification setting is enabled by default.
43
- * This is used to set the initial preference for users.
44
- * If true, users will have this notification setting enabled by default.
45
- * @default true
46
- */
47
- isPrefered: boolean;
48
- /**
49
- * Sort order for the notification setting.
50
- * This can be used to order the settings in the user interface.
51
- * Lower numbers appear first.
52
- * @default null
53
- */
54
- sort: number;
55
- /**
56
- * Creates a new BusinessEvent instance
57
- * @param props - Partial properties to initialize the entity
58
- */
59
- constructor(props?: Partial<BusinessEvent>);
60
- /**
61
- * Converts the entity to a BusinessEvent model instance
62
- * @returns BusinessEvent model with all business event properties
63
- */
64
- toModel(): BusinessEvent;
65
- /**
66
- * Returns a summary representation of the business event
67
- * @returns BusinessEvent model instance (same as toModel())
68
- */
69
- toSummary(): BusinessEvent;
70
- /**
71
- * Retrieves activity history for this business event
72
- * @returns Promise resolving to array of Activity instances tracking creation and updates
73
- */
74
- getActivities(): Promise<Activity[]>;
75
- }
@@ -1,128 +0,0 @@
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 BusinessEvent_1;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.BusinessEvent = void 0;
14
- const typeorm_1 = require("typeorm");
15
- const common_1 = require("@driveup/common");
16
- const trackable_1 = require("../../utils/trackable");
17
- const activity_helper_1 = require("../../utils/activity.helper");
18
- /**
19
- * Represents a business event configuration in the system.
20
- * Business events define system actions that can trigger notifications
21
- * (e.g., account created, appointment scheduled, payment received).
22
- * Each event can be configured with default preferences and notification channels.
23
- *
24
- * @extends TrackableEntity
25
- */
26
- let BusinessEvent = BusinessEvent_1 = class BusinessEvent extends trackable_1.TrackableEntity {
27
- /**
28
- * Creates a new BusinessEvent instance
29
- * @param props - Partial properties to initialize the entity
30
- */
31
- constructor(props) {
32
- super();
33
- Object.assign(this, props);
34
- }
35
- /**
36
- * Converts the entity to a BusinessEvent model instance
37
- * @returns BusinessEvent model with all business event properties
38
- */
39
- toModel() {
40
- return new BusinessEvent_1({
41
- id: this.id,
42
- scope: this.scope,
43
- event: this.event,
44
- translations: this.translations,
45
- color: this.color,
46
- channel: this.channel,
47
- isPrefered: this.isPrefered,
48
- sort: this.sort
49
- });
50
- }
51
- /**
52
- * Returns a summary representation of the business event
53
- * @returns BusinessEvent model instance (same as toModel())
54
- */
55
- toSummary() {
56
- return this.toModel();
57
- }
58
- /**
59
- * Retrieves activity history for this business event
60
- * @returns Promise resolving to array of Activity instances tracking creation and updates
61
- */
62
- async getActivities() {
63
- const activities = [];
64
- activities.push(await (0, activity_helper_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy));
65
- activities.push(await (0, activity_helper_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
66
- activities.push(await (0, activity_helper_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy));
67
- activities.push(await (0, activity_helper_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
68
- return activities.filter(a => a);
69
- }
70
- };
71
- exports.BusinessEvent = BusinessEvent;
72
- __decorate([
73
- (0, typeorm_1.Column)({
74
- type: 'enum',
75
- enum: common_1.ProfileType,
76
- default: common_1.ProfileType.Company,
77
- nullable: true
78
- }),
79
- __metadata("design:type", String)
80
- ], BusinessEvent.prototype, "scope", void 0);
81
- __decorate([
82
- (0, typeorm_1.Column)({ unique: true }),
83
- __metadata("design:type", String)
84
- ], BusinessEvent.prototype, "event", void 0);
85
- __decorate([
86
- (0, typeorm_1.Column)({
87
- type: 'simple-json',
88
- nullable: true,
89
- default: null
90
- }),
91
- __metadata("design:type", Array)
92
- ], BusinessEvent.prototype, "translations", void 0);
93
- __decorate([
94
- (0, typeorm_1.Column)({
95
- type: 'enum',
96
- enum: common_1.ColorContext,
97
- default: common_1.ColorContext.Info,
98
- nullable: true
99
- }),
100
- __metadata("design:type", String)
101
- ], BusinessEvent.prototype, "color", void 0);
102
- __decorate([
103
- (0, typeorm_1.Column)({
104
- type: 'enum',
105
- enum: common_1.NotificationChannel,
106
- default: common_1.NotificationChannel.App
107
- }),
108
- __metadata("design:type", String)
109
- ], BusinessEvent.prototype, "channel", void 0);
110
- __decorate([
111
- (0, typeorm_1.Column)({
112
- nullable: false,
113
- default: true
114
- }),
115
- __metadata("design:type", Boolean)
116
- ], BusinessEvent.prototype, "isPrefered", void 0);
117
- __decorate([
118
- (0, typeorm_1.Column)({
119
- nullable: true,
120
- default: null
121
- }),
122
- __metadata("design:type", Number)
123
- ], BusinessEvent.prototype, "sort", void 0);
124
- exports.BusinessEvent = BusinessEvent = BusinessEvent_1 = __decorate([
125
- (0, typeorm_1.Entity)('systemBusinessEvents'),
126
- __metadata("design:paramtypes", [Object])
127
- ], BusinessEvent);
128
- //# sourceMappingURL=business.entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"business.entity.js","sourceRoot":"","sources":["../../../src/system/event/business.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAAyC;AACzC,4CAAkH;AAClH,qDAAwD;AACxD,iEAAyD;AAEzD;;;;;;;GAOG;AAEI,IAAM,aAAa,qBAAnB,MAAM,aAAc,SAAQ,2BAA8B;IAmFhE;;;OAGG;IACH,YAAY,KAA8B;QACzC,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,OAAO;QACN,OAAO,IAAI,eAAa,CAAC;YACxB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;SACf,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,SAAS;QACR,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa;QAClB,MAA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BAAmB,CAAC,GAAG;KAChC,CAAC;;8CAC2B;AAY7B;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,IAAI;KACb,CAAC;;iDACkB;AAYpB;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;2CACW;wBAjFD,aAAa;IADzB,IAAA,gBAAM,EAAC,sBAAsB,CAAC;;GAClB,aAAa,CAiIzB"}
@@ -1,4 +0,0 @@
1
- export * from './activity.helper';
2
- export * from './json-metrics.transform';
3
- export * from './numeric.transform';
4
- export * from './trackable';
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./activity.helper"), exports);
18
- __exportStar(require("./json-metrics.transform"), exports);
19
- __exportStar(require("./numeric.transform"), exports);
20
- __exportStar(require("./trackable"), exports);
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,2DAAyC;AACzC,sDAAoC;AACpC,8CAA4B"}
@@ -1,35 +0,0 @@
1
- import { ValueTransformer } from 'typeorm';
2
- /**
3
- * TypeORM value transformer for JSON metrics columns.
4
- * Converts metric values in JSON objects to numeric types, ensuring all values
5
- * are valid numbers (defaulting to 0 for invalid or null values).
6
- * Useful for database columns that store metrics as JSON key-value pairs.
7
- *
8
- * @implements {ValueTransformer}
9
- * @example
10
- * ```typescript
11
- * @Column({
12
- * type: 'json',
13
- * transformer: new ColumnJsonMetricsTransformer()
14
- * })
15
- * metrics: Record<string, number>;
16
- * ```
17
- */
18
- export declare class ColumnJsonMetricsTransformer implements ValueTransformer {
19
- /**
20
- * Transforms a JSON object before persisting to the database.
21
- * Converts all values in the JSON object to numbers, defaulting to 0 for invalid values.
22
- *
23
- * @param json - The JSON object to transform
24
- * @returns Transformed JSON object with numeric values, or null if input is null/undefined
25
- */
26
- to(json?: Record<string, any> | null): Record<string, any> | null;
27
- /**
28
- * Transforms a JSON object when loading from the database.
29
- * Converts all values in the JSON object to numbers, defaulting to 0 for invalid values.
30
- *
31
- * @param json - The JSON object loaded from the database
32
- * @returns Transformed JSON object with numeric values, or null if input is null/undefined
33
- */
34
- from(json?: Record<string, any> | null): Record<string, any> | null;
35
- }
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ColumnJsonMetricsTransformer = void 0;
4
- /**
5
- * Type guard that checks if a value is null or undefined.
6
- *
7
- * @template T - The type of the value being checked
8
- * @param obj - The value to check
9
- * @returns True if the value is null or undefined, false otherwise
10
- */
11
- function isNullOrUndefined(obj) {
12
- return typeof obj === 'undefined' || obj === null;
13
- }
14
- /**
15
- * TypeORM value transformer for JSON metrics columns.
16
- * Converts metric values in JSON objects to numeric types, ensuring all values
17
- * are valid numbers (defaulting to 0 for invalid or null values).
18
- * Useful for database columns that store metrics as JSON key-value pairs.
19
- *
20
- * @implements {ValueTransformer}
21
- * @example
22
- * ```typescript
23
- * @Column({
24
- * type: 'json',
25
- * transformer: new ColumnJsonMetricsTransformer()
26
- * })
27
- * metrics: Record<string, number>;
28
- * ```
29
- */
30
- class ColumnJsonMetricsTransformer {
31
- /**
32
- * Transforms a JSON object before persisting to the database.
33
- * Converts all values in the JSON object to numbers, defaulting to 0 for invalid values.
34
- *
35
- * @param json - The JSON object to transform
36
- * @returns Transformed JSON object with numeric values, or null if input is null/undefined
37
- */
38
- to(json) {
39
- if (!isNullOrUndefined(json)) {
40
- for (const key in json) {
41
- if (Object.prototype.hasOwnProperty.call(json, key)) {
42
- const value = json[key];
43
- if (!isNullOrUndefined(value)) {
44
- const res = parseFloat(value);
45
- json[key] = isNaN(res) ? 0 : res;
46
- }
47
- else {
48
- json[key] = 0;
49
- }
50
- }
51
- }
52
- return json;
53
- }
54
- return null;
55
- }
56
- /**
57
- * Transforms a JSON object when loading from the database.
58
- * Converts all values in the JSON object to numbers, defaulting to 0 for invalid values.
59
- *
60
- * @param json - The JSON object loaded from the database
61
- * @returns Transformed JSON object with numeric values, or null if input is null/undefined
62
- */
63
- from(json) {
64
- if (!isNullOrUndefined(json)) {
65
- for (const key in json) {
66
- if (Object.prototype.hasOwnProperty.call(json, key)) {
67
- const value = json[key];
68
- if (!isNullOrUndefined(value)) {
69
- const res = parseFloat(value);
70
- json[key] = isNaN(res) ? 0 : res;
71
- }
72
- else {
73
- json[key] = 0;
74
- }
75
- }
76
- }
77
- return json;
78
- }
79
- return null;
80
- }
81
- }
82
- exports.ColumnJsonMetricsTransformer = ColumnJsonMetricsTransformer;
83
- //# sourceMappingURL=json-metrics.transform.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"json-metrics.transform.js","sourceRoot":"","sources":["../../src/utils/json-metrics.transform.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAI,GAAyB;IACtD,OAAO,OAAO,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,IAAI,CAAC;AACnD,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAa,4BAA4B;IACxC;;;;;;OAMG;IACH,EAAE,CAAC,IAAiC;QACnC,IAAI,CAA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AAC,GAAG,CAAC,CAAC;oBACf,CAAC;gBACF,CAAC;YACF,CAAC;YACD,OAAO,IAAW,CAAC;QACpB,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAlDD,oEAkDC"}
@@ -1,82 +0,0 @@
1
- import { Activity, Language } from '@driveup/common';
2
- import { BaseEntity } from 'typeorm';
3
- /**
4
- * Abstract base entity with comprehensive audit tracking properties.
5
- * Provides automatic tracking of creation, updates, and soft deletion with user attribution.
6
- * All entities requiring an audit trail should extend this class.
7
- *
8
- * @template T - The model type that the entity converts to
9
- * @extends BaseEntity
10
- *
11
- * @example
12
- * ```typescript
13
- * @Entity('users')
14
- * export class UserEntity extends TrackableEntity<User> {
15
- * // entity properties
16
- *
17
- * toModel() {
18
- * return new User({ id: this.id, ... });
19
- * }
20
- *
21
- * async getActivities() {
22
- * return [];
23
- * }
24
- * }
25
- * ```
26
- */
27
- export declare abstract class TrackableEntity<T = any> extends BaseEntity {
28
- /**
29
- * Primary key - auto-generated sequential ID
30
- */
31
- id: number;
32
- /**
33
- * ID of the user who created this entity
34
- */
35
- createdBy: number;
36
- /**
37
- * Timestamp when the entity was created
38
- * Automatically set by TypeORM
39
- */
40
- createdOn: Date;
41
- /**
42
- * ID of the user who last updated this entity
43
- */
44
- updatedBy: number;
45
- /**
46
- * Timestamp when the entity was last updated
47
- * Automatically updated by TypeORM
48
- */
49
- updatedOn: Date;
50
- /**
51
- * ID of the user who soft-deleted this entity
52
- */
53
- deletedBy: number;
54
- /**
55
- * Timestamp when the entity was soft-deleted
56
- * When set, the entity is excluded from normal queries
57
- */
58
- deletedOn: Date;
59
- /**
60
- * Converts the entity to its corresponding model instance.
61
- * Must be implemented by child classes to define transformation logic.
62
- *
63
- * @param lang - Optional language for localized content
64
- * @returns Model instance or Promise resolving to model instance
65
- */
66
- abstract toModel(lang?: Language): T | Promise<T>;
67
- /**
68
- * Converts the entity to a summary representation.
69
- * Must be implemented by child classes to define summary transformation logic.
70
- *
71
- * @param lang - Optional language for localized content
72
- * @returns Summary model instance or Promise resolving to summary model instance
73
- */
74
- abstract toSummary(lang?: Language): T | Promise<T>;
75
- /**
76
- * Retrieves all activity records associated with this entity.
77
- * Must be implemented by child classes to return their specific activity relations.
78
- *
79
- * @returns Promise resolving to array of Activity objects
80
- */
81
- abstract getActivities(): Promise<Activity[]>;
82
- }
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.TrackableEntity = void 0;
13
- const typeorm_1 = require("typeorm");
14
- /**
15
- * Abstract base entity with comprehensive audit tracking properties.
16
- * Provides automatic tracking of creation, updates, and soft deletion with user attribution.
17
- * All entities requiring an audit trail should extend this class.
18
- *
19
- * @template T - The model type that the entity converts to
20
- * @extends BaseEntity
21
- *
22
- * @example
23
- * ```typescript
24
- * @Entity('users')
25
- * export class UserEntity extends TrackableEntity<User> {
26
- * // entity properties
27
- *
28
- * toModel() {
29
- * return new User({ id: this.id, ... });
30
- * }
31
- *
32
- * async getActivities() {
33
- * return [];
34
- * }
35
- * }
36
- * ```
37
- */
38
- class TrackableEntity extends typeorm_1.BaseEntity {
39
- }
40
- exports.TrackableEntity = TrackableEntity;
41
- __decorate([
42
- (0, typeorm_1.PrimaryGeneratedColumn)(),
43
- __metadata("design:type", Number)
44
- ], TrackableEntity.prototype, "id", void 0);
45
- __decorate([
46
- (0, typeorm_1.Column)({ nullable: true, default: null }),
47
- __metadata("design:type", Number)
48
- ], TrackableEntity.prototype, "createdBy", void 0);
49
- __decorate([
50
- (0, typeorm_1.CreateDateColumn)({ nullable: true, default: null }),
51
- __metadata("design:type", Date)
52
- ], TrackableEntity.prototype, "createdOn", void 0);
53
- __decorate([
54
- (0, typeorm_1.Column)({ nullable: true, default: null }),
55
- __metadata("design:type", Number)
56
- ], TrackableEntity.prototype, "updatedBy", void 0);
57
- __decorate([
58
- (0, typeorm_1.UpdateDateColumn)({ nullable: true, default: null }),
59
- __metadata("design:type", Date)
60
- ], TrackableEntity.prototype, "updatedOn", void 0);
61
- __decorate([
62
- (0, typeorm_1.Column)({ nullable: true, default: null }),
63
- __metadata("design:type", Number)
64
- ], TrackableEntity.prototype, "deletedBy", void 0);
65
- __decorate([
66
- (0, typeorm_1.DeleteDateColumn)({ nullable: true, default: null }),
67
- __metadata("design:type", Date)
68
- ], TrackableEntity.prototype, "deletedOn", void 0);
69
- //# sourceMappingURL=trackable.entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trackable.entity.js","sourceRoot":"","sources":["../../src/utils/trackable.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAA2H;AAE3H;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAsB,eAAuB,SAAQ,oBAAU;CAyE9D;AAzED,0CAyEC;AAnEA;IADC,IAAA,gCAAsB,GAAE;;2CACd;AAMX;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;kDACxB;AAOlB;IADC,IAAA,0BAAgB,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BACzC,IAAI;kDAAC;AAMhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;kDACxB;AAOlB;IADC,IAAA,0BAAgB,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BACzC,IAAI;kDAAC;AAMhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;kDACxB;AAOlB;IADC,IAAA,0BAAgB,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BACzC,IAAI;kDAAC"}