@venturialstd/user 0.0.4 → 0.0.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 (30) hide show
  1. package/README.md +1398 -1357
  2. package/dist/constants/notification.constant.d.ts +28 -0
  3. package/dist/constants/notification.constant.d.ts.map +1 -0
  4. package/dist/constants/notification.constant.js +35 -0
  5. package/dist/constants/notification.constant.js.map +1 -0
  6. package/dist/dtos/create-notification.dto.d.ts +14 -0
  7. package/dist/dtos/create-notification.dto.d.ts.map +1 -0
  8. package/dist/dtos/create-notification.dto.js +3 -0
  9. package/dist/dtos/create-notification.dto.js.map +1 -0
  10. package/dist/entities/user-notification-preferences.entity.d.ts +13 -0
  11. package/dist/entities/user-notification-preferences.entity.d.ts.map +1 -0
  12. package/dist/entities/user-notification-preferences.entity.js +65 -0
  13. package/dist/entities/user-notification-preferences.entity.js.map +1 -0
  14. package/dist/entities/user-notification.entity.d.ts +21 -0
  15. package/dist/entities/user-notification.entity.d.ts.map +1 -0
  16. package/dist/entities/user-notification.entity.js +109 -0
  17. package/dist/entities/user-notification.entity.js.map +1 -0
  18. package/dist/index.d.ts +5 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +5 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/services/user-notification.service.d.ts +54 -0
  23. package/dist/services/user-notification.service.d.ts.map +1 -0
  24. package/dist/services/user-notification.service.js +217 -0
  25. package/dist/services/user-notification.service.js.map +1 -0
  26. package/dist/user.module.d.ts +4 -0
  27. package/dist/user.module.d.ts.map +1 -1
  28. package/dist/user.module.js +17 -2
  29. package/dist/user.module.js.map +1 -1
  30. package/package.json +43 -42
@@ -0,0 +1,217 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.UserNotificationService = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const typeorm_1 = require("@nestjs/typeorm");
18
+ const typeorm_2 = require("typeorm");
19
+ const notification_constant_1 = require("../constants/notification.constant");
20
+ const user_notification_entity_1 = require("../entities/user-notification.entity");
21
+ const user_notification_preferences_entity_1 = require("../entities/user-notification-preferences.entity");
22
+ let UserNotificationService = class UserNotificationService {
23
+ notificationRepo;
24
+ preferencesRepo;
25
+ options;
26
+ allowedTypes;
27
+ allowedCategories;
28
+ allowedPriorities;
29
+ constructor(notificationRepo, preferencesRepo, options) {
30
+ this.notificationRepo = notificationRepo;
31
+ this.preferencesRepo = preferencesRepo;
32
+ this.options = options;
33
+ this.allowedTypes =
34
+ options.allowedNotificationTypes ?? notification_constant_1.DEFAULT_NOTIFICATION_TYPES;
35
+ this.allowedCategories =
36
+ options.allowedNotificationCategories ?? notification_constant_1.DEFAULT_NOTIFICATION_CATEGORIES;
37
+ this.allowedPriorities =
38
+ options.allowedNotificationPriorities ?? notification_constant_1.DEFAULT_NOTIFICATION_PRIORITIES;
39
+ }
40
+ getAllowedTypes() {
41
+ return [...this.allowedTypes];
42
+ }
43
+ getAllowedCategories() {
44
+ return [...this.allowedCategories];
45
+ }
46
+ getAllowedPriorities() {
47
+ return [...this.allowedPriorities];
48
+ }
49
+ validateType(type) {
50
+ if (!this.allowedTypes.includes(type)) {
51
+ throw new common_1.BadRequestException(`Invalid notification type. Allowed: ${this.allowedTypes.join(', ')}`);
52
+ }
53
+ }
54
+ validateCategory(category) {
55
+ if (!this.allowedCategories.includes(category)) {
56
+ throw new common_1.BadRequestException(`Invalid notification category. Allowed: ${this.allowedCategories.join(', ')}`);
57
+ }
58
+ }
59
+ validatePriority(priority) {
60
+ if (!this.allowedPriorities.includes(priority)) {
61
+ throw new common_1.BadRequestException(`Invalid notification priority. Allowed: ${this.allowedPriorities.join(', ')}`);
62
+ }
63
+ }
64
+ async createNotification(data) {
65
+ this.validateType(data.type);
66
+ this.validateCategory(data.category);
67
+ const priority = data.priority ?? 'medium';
68
+ this.validatePriority(priority);
69
+ const defaultChannels = this.options.defaultChannels ?? [
70
+ notification_constant_1.NotificationChannel.IN_APP,
71
+ notification_constant_1.NotificationChannel.EMAIL,
72
+ ];
73
+ const sentVia = data.sentVia ?? defaultChannels;
74
+ const partial = {
75
+ userId: data.userId,
76
+ type: data.type,
77
+ category: data.category,
78
+ title: data.title,
79
+ message: data.message,
80
+ metadata: data.metadata ?? undefined,
81
+ priority,
82
+ expiresAt: data.expiresAt ?? undefined,
83
+ groupKey: data.groupKey ?? undefined,
84
+ sentVia,
85
+ };
86
+ const notification = this.notificationRepo.create(partial);
87
+ const saved = await this.notificationRepo.save(notification);
88
+ return Array.isArray(saved) ? saved[0] : saved;
89
+ }
90
+ async findById(id) {
91
+ const notification = await this.notificationRepo.findOne({ where: { id } });
92
+ if (!notification) {
93
+ throw new common_1.NotFoundException(`Notification ${id} not found`);
94
+ }
95
+ return notification;
96
+ }
97
+ async findByUserId(userId, options) {
98
+ const qb = this.notificationRepo
99
+ .createQueryBuilder('n')
100
+ .where('n.userId = :userId', { userId });
101
+ if (options?.isRead !== undefined) {
102
+ qb.andWhere('n.isRead = :isRead', { isRead: options.isRead });
103
+ }
104
+ if (options?.type) {
105
+ this.validateType(options.type);
106
+ qb.andWhere('n.type = :type', { type: options.type });
107
+ }
108
+ if (options?.includeExpired === false) {
109
+ qb.andWhere('(n.expiresAt IS NULL OR n.expiresAt > :now)', {
110
+ now: new Date(),
111
+ });
112
+ }
113
+ const total = await qb.getCount();
114
+ qb.orderBy('n.createdAt', 'DESC');
115
+ if (options?.limit != null) {
116
+ qb.take(options.limit);
117
+ }
118
+ if (options?.offset != null) {
119
+ qb.skip(options.offset);
120
+ }
121
+ const data = await qb.getMany();
122
+ return { data, total };
123
+ }
124
+ async markAsRead(id, userId) {
125
+ const notification = await this.findById(id);
126
+ if (notification.userId !== userId) {
127
+ throw new common_1.NotFoundException(`Notification ${id} not found`);
128
+ }
129
+ notification.isRead = true;
130
+ notification.readAt = new Date();
131
+ return this.notificationRepo.save(notification);
132
+ }
133
+ async markAllAsRead(userId) {
134
+ const result = await this.notificationRepo.update({ userId, isRead: false }, { isRead: true, readAt: new Date() });
135
+ return { count: result.affected ?? 0 };
136
+ }
137
+ async archive(id, userId) {
138
+ const notification = await this.findById(id);
139
+ if (notification.userId !== userId) {
140
+ throw new common_1.NotFoundException(`Notification ${id} not found`);
141
+ }
142
+ notification.isArchived = true;
143
+ notification.archivedAt = new Date();
144
+ return this.notificationRepo.save(notification);
145
+ }
146
+ async getUnreadCount(userId) {
147
+ return this.notificationRepo.count({
148
+ where: { userId, isRead: false },
149
+ });
150
+ }
151
+ async getPreferences(userId) {
152
+ return this.preferencesRepo.findOne({ where: { userId } });
153
+ }
154
+ async upsertPreferences(userId, data) {
155
+ let prefs = await this.preferencesRepo.findOne({ where: { userId } });
156
+ if (!prefs) {
157
+ prefs = this.preferencesRepo.create({
158
+ userId,
159
+ enabledChannels: data.enabledChannels ?? [
160
+ notification_constant_1.NotificationChannel.IN_APP,
161
+ notification_constant_1.NotificationChannel.EMAIL,
162
+ ],
163
+ });
164
+ }
165
+ if (data.enabledChannels !== undefined)
166
+ prefs.enabledChannels = data.enabledChannels;
167
+ if (data.typePreferences !== undefined)
168
+ prefs.typePreferences = data.typePreferences;
169
+ if (data.quietHoursStart !== undefined)
170
+ prefs.quietHoursStart = data.quietHoursStart;
171
+ if (data.quietHoursEnd !== undefined)
172
+ prefs.quietHoursEnd = data.quietHoursEnd;
173
+ if (data.timezone !== undefined)
174
+ prefs.timezone = data.timezone;
175
+ return this.preferencesRepo.save(prefs);
176
+ }
177
+ async delete(id, userId) {
178
+ const notification = await this.findById(id);
179
+ if (notification.userId !== userId) {
180
+ throw new common_1.NotFoundException(`Notification ${id} not found`);
181
+ }
182
+ await this.notificationRepo.remove(notification);
183
+ }
184
+ async deleteExpired(olderThan) {
185
+ const cutoff = olderThan ?? new Date();
186
+ const result = await this.notificationRepo
187
+ .createQueryBuilder()
188
+ .delete()
189
+ .where('expiresAt IS NOT NULL')
190
+ .andWhere('expiresAt < :cutoff', { cutoff })
191
+ .execute();
192
+ return result.affected ?? 0;
193
+ }
194
+ async getUsersWithUnreadCount(includeExpired = false) {
195
+ const qb = this.notificationRepo
196
+ .createQueryBuilder('n')
197
+ .select('n.userId', 'userId')
198
+ .addSelect('COUNT(*)', 'count')
199
+ .where('n.isRead = :isRead', { isRead: false })
200
+ .groupBy('n.userId');
201
+ if (!includeExpired) {
202
+ qb.andWhere('(n.expiresAt IS NULL OR n.expiresAt > :now)', { now: new Date() });
203
+ }
204
+ const rows = await qb.getRawMany();
205
+ return rows.map((r) => ({ userId: r.userId, count: parseInt(r.count, 10) }));
206
+ }
207
+ };
208
+ exports.UserNotificationService = UserNotificationService;
209
+ exports.UserNotificationService = UserNotificationService = __decorate([
210
+ (0, common_1.Injectable)(),
211
+ __param(0, (0, typeorm_1.InjectRepository)(user_notification_entity_1.UserNotification)),
212
+ __param(1, (0, typeorm_1.InjectRepository)(user_notification_preferences_entity_1.UserNotificationPreferences)),
213
+ __param(2, (0, common_1.Inject)('USER_MODULE_OPTIONS')),
214
+ __metadata("design:paramtypes", [typeorm_2.Repository,
215
+ typeorm_2.Repository, Object])
216
+ ], UserNotificationService);
217
+ //# sourceMappingURL=user-notification.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-notification.service.js","sourceRoot":"","sources":["../../src/services/user-notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4F;AAC5F,6CAAmD;AACnD,qCAAqC;AAErC,8EAK4C;AAE5C,mFAAwE;AACxE,2GAA+F;AAIxF,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAOf;IAEA;IAEA;IAVF,YAAY,CAAW;IACvB,iBAAiB,CAAW;IAC5B,iBAAiB,CAAW;IAE7C,YAEmB,gBAA8C,EAE9C,eAAwD,EAExD,OAA0B;QAJ1B,qBAAgB,GAAhB,gBAAgB,CAA8B;QAE9C,oBAAe,GAAf,eAAe,CAAyC;QAExD,YAAO,GAAP,OAAO,CAAmB;QAE3C,IAAI,CAAC,YAAY;YACf,OAAO,CAAC,wBAAwB,IAAI,kDAA0B,CAAC;QACjE,IAAI,CAAC,iBAAiB;YACpB,OAAO,CAAC,6BAA6B,IAAI,uDAA+B,CAAC;QAC3E,IAAI,CAAC,iBAAiB;YACpB,OAAO,CAAC,6BAA6B,IAAI,uDAA+B,CAAC;IAC7E,CAAC;IAED,eAAe;QACb,OAAO,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;IAED,oBAAoB;QAClB,OAAO,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,oBAAoB;QAClB,OAAO,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAEO,YAAY,CAAC,IAAY;QAC/B,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,4BAAmB,CAC3B,uCAAuC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACtE,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,gBAAgB,CAAC,QAAgB;QACvC,IAAI,CAAC,IAAI,CAAC,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  settingsDefaults?: Record<string, unknown>;
6
6
  allowedStatuses?: string[];
7
+ allowedNotificationTypes?: string[];
8
+ allowedNotificationCategories?: string[];
9
+ allowedNotificationPriorities?: string[];
10
+ defaultChannels?: import('./constants/notification.constant').NotificationChannel[];
7
11
  }
8
12
  export declare class UserModule {
9
13
  static forRoot(options?: UserModuleOptions): DynamicModule;
@@ -1 +1 @@
1
- {"version":3,"file":"user.module.d.ts","sourceRoot":"","sources":["../src/user.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAY7D,MAAM,WAAW,iBAAiB;IAKhC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC;IAM5B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAM3C,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAS3C,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,qBACa,UAAU;IAKrB,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,iBAAsB,GAAG,aAAa;IAwB9D,MAAM,CAAC,UAAU,IAAI,aAAa;CAGnC"}
1
+ {"version":3,"file":"user.module.d.ts","sourceRoot":"","sources":["../src/user.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAe7D,MAAM,WAAW,iBAAiB;IAKhC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC;IAM5B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAM3C,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAS3C,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAM3B,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;IAKpC,6BAA6B,CAAC,EAAE,MAAM,EAAE,CAAC;IAKzC,6BAA6B,CAAC,EAAE,MAAM,EAAE,CAAC;IAKzC,eAAe,CAAC,EAAE,OAAO,mCAAmC,EAAE,mBAAmB,EAAE,CAAC;CACrF;AAED,qBACa,UAAU;IAKrB,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,iBAAsB,GAAG,aAAa;IAoC9D,MAAM,CAAC,UAAU,IAAI,aAAa;CAGnC"}
@@ -15,26 +15,41 @@ const permission_entity_1 = require("./entities/permission.entity");
15
15
  const role_entity_1 = require("./entities/role.entity");
16
16
  const role_permission_entity_1 = require("./entities/role-permission.entity");
17
17
  const user_entity_1 = require("./entities/user.entity");
18
+ const user_notification_entity_1 = require("./entities/user-notification.entity");
19
+ const user_notification_preferences_entity_1 = require("./entities/user-notification-preferences.entity");
18
20
  const user_role_entity_1 = require("./entities/user-role.entity");
19
21
  const acl_service_1 = require("./services/acl.service");
22
+ const user_notification_service_1 = require("./services/user-notification.service");
20
23
  const user_service_1 = require("./services/user.service");
21
24
  let UserModule = UserModule_1 = class UserModule {
22
25
  static forRoot(options = {}) {
23
26
  const aclEntities = [role_entity_1.Role, permission_entity_1.Permission, role_permission_entity_1.RolePermission, user_role_entity_1.UserRole];
24
- const entities = [user_entity_1.User, ...aclEntities, ...(options.additionalEntities || [])];
27
+ const notificationEntities = [user_notification_entity_1.UserNotification, user_notification_preferences_entity_1.UserNotificationPreferences];
28
+ const entities = [
29
+ user_entity_1.User,
30
+ ...aclEntities,
31
+ ...notificationEntities,
32
+ ...(options.additionalEntities || []),
33
+ ];
25
34
  return {
26
35
  module: UserModule_1,
27
36
  imports: [core_1.SharedModule, typeorm_1.TypeOrmModule.forFeature(entities)],
28
37
  providers: [
29
38
  user_service_1.UserService,
30
39
  acl_service_1.AclService,
40
+ user_notification_service_1.UserNotificationService,
31
41
  {
32
42
  provide: 'USER_MODULE_OPTIONS',
33
43
  useValue: options,
34
44
  },
35
45
  ],
36
46
  controllers: [],
37
- exports: [user_service_1.UserService, acl_service_1.AclService, 'USER_MODULE_OPTIONS'],
47
+ exports: [
48
+ user_service_1.UserService,
49
+ acl_service_1.AclService,
50
+ user_notification_service_1.UserNotificationService,
51
+ 'USER_MODULE_OPTIONS',
52
+ ],
38
53
  };
39
54
  }
40
55
  static forFeature() {
@@ -1 +1 @@
1
- {"version":3,"file":"user.module.js","sourceRoot":"","sources":["../src/user.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA6D;AAC7D,6CAAgD;AAChD,6CAAkD;AAElD,oEAA0D;AAC1D,wDAA8C;AAC9C,8EAAmE;AACnE,wDAA8C;AAC9C,kEAAuD;AACvD,wDAAoD;AACpD,0DAAsD;AAgC/C,IAAM,UAAU,kBAAhB,MAAM,UAAU;IAKrB,MAAM,CAAC,OAAO,CAAC,UAA6B,EAAE;QAC5C,MAAM,WAAW,GAAG,CAAC,kBAAI,EAAE,8BAAU,EAAE,uCAAc,EAAE,2BAAQ,CAAC,CAAC;QACjE,MAAM,QAAQ,GAAG,CAAC,kBAAI,EAAE,GAAG,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,CAAC;QAE/E,OAAO;YACL,MAAM,EAAE,YAAU;YAClB,OAAO,EAAE,CAAC,mBAAY,EAAE,uBAAa,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC3D,SAAS,EAAE;gBACT,0BAAW;gBACX,wBAAU;gBACV;oBACE,OAAO,EAAE,qBAAqB;oBAC9B,QAAQ,EAAE,OAAO;iBAClB;aACF;YACD,WAAW,EAAE,EAAE;YACf,OAAO,EAAE,CAAC,0BAAW,EAAE,wBAAU,EAAE,qBAAqB,CAAC;SAC1D,CAAC;IACJ,CAAC;IAMD,MAAM,CAAC,UAAU;QACf,OAAO,YAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;CACF,CAAA;AAhCY,gCAAU;qBAAV,UAAU;IADtB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,UAA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}
package/package.json CHANGED
@@ -1,42 +1,43 @@
1
- {
2
- "name": "@venturialstd/user",
3
- "version": "0.0.4",
4
- "description": "User Management Module for Venturial",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "type": "commonjs",
8
- "files": [
9
- "dist"
10
- ],
11
- "publishConfig": {
12
- "access": "public"
13
- },
14
- "scripts": {
15
- "build": "tsc -p tsconfig.json",
16
- "prepublishOnly": "npm run build",
17
- "release:patch": "npm run build && npm version patch --no-git-tag-version && npm publish",
18
- "test:dev": "ts-node -r tsconfig-paths/register test/main.ts",
19
- "test:watch": "nodemon --watch src --watch test --ext ts --exec npm run test:dev",
20
- "migration:generate": "ts-node node_modules/.bin/typeorm migration:generate -d test/data-source.ts test/migrations/$npm_config_name",
21
- "migration:run": "ts-node node_modules/.bin/typeorm migration:run -d test/data-source.ts",
22
- "migration:revert": "ts-node node_modules/.bin/typeorm migration:revert -d test/data-source.ts"
23
- },
24
- "devDependencies": {
25
- "@nestjs/config": "^3.0.0",
26
- "@types/node": "^20.0.0",
27
- "dotenv": "^17.2.3",
28
- "nodemon": "^3.0.0",
29
- "ts-node": "^10.9.0",
30
- "tsconfig-paths": "^4.2.0",
31
- "typescript": "^5.9.3"
32
- },
33
- "peerDependencies": {
34
- "@nestjs/common": "^11.0.11",
35
- "@nestjs/core": "^11.0.5",
36
- "@nestjs/typeorm": "^10.0.0",
37
- "@venturialstd/core": "^1.0.16",
38
- "class-transformer": "^0.5.1",
39
- "class-validator": "^0.14.1",
40
- "typeorm": "^0.3.20"
41
- }
42
- }
1
+ {
2
+ "name": "@venturialstd/user",
3
+ "version": "0.0.5",
4
+ "description": "User Management Module for Venturial",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "commonjs",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.json",
16
+ "prepublishOnly": "npm run build",
17
+ "release:patch": "npm run build && npm version patch --no-git-tag-version && npm publish",
18
+ "test:dev": "ts-node -r tsconfig-paths/register test/main.ts",
19
+ "test:watch": "nodemon --watch src --watch test --ext ts --exec npm run test:dev",
20
+ "migration:generate": "ts-node node_modules/.bin/typeorm migration:generate -d test/data-source.ts test/migrations/$npm_config_name",
21
+ "migration:run": "ts-node node_modules/.bin/typeorm migration:run -d test/data-source.ts",
22
+ "migration:revert": "ts-node node_modules/.bin/typeorm migration:revert -d test/data-source.ts",
23
+ "build:pack": "rimraf *.tgz && npm run build && npm pack"
24
+ },
25
+ "devDependencies": {
26
+ "@nestjs/config": "^3.0.0",
27
+ "@types/node": "^20.0.0",
28
+ "dotenv": "^17.2.3",
29
+ "nodemon": "^3.0.0",
30
+ "ts-node": "^10.9.0",
31
+ "tsconfig-paths": "^4.2.0",
32
+ "typescript": "^5.9.3"
33
+ },
34
+ "peerDependencies": {
35
+ "@nestjs/common": "^11.0.11",
36
+ "@nestjs/core": "^11.0.5",
37
+ "@nestjs/typeorm": "^10.0.0",
38
+ "@venturialstd/core": "^1.0.16",
39
+ "class-transformer": "^0.5.1",
40
+ "class-validator": "^0.14.1",
41
+ "typeorm": "^0.3.20"
42
+ }
43
+ }