@flusys/nestjs-task-manager 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/README.md +245 -0
  2. package/cjs/config/index.js +19 -0
  3. package/cjs/config/message-keys.js +92 -0
  4. package/cjs/config/task-manager.constants.js +11 -0
  5. package/cjs/controllers/index.js +22 -0
  6. package/cjs/controllers/task-board.controller.js +219 -0
  7. package/cjs/controllers/task-comment.controller.js +103 -0
  8. package/cjs/controllers/task-label.controller.js +112 -0
  9. package/cjs/controllers/task-list.controller.js +158 -0
  10. package/cjs/controllers/task.controller.js +199 -0
  11. package/cjs/docs/index.js +18 -0
  12. package/cjs/docs/task-manager-swagger.config.js +43 -0
  13. package/cjs/dtos/index.js +22 -0
  14. package/cjs/dtos/task-board.dto.js +310 -0
  15. package/cjs/dtos/task-comment.dto.js +131 -0
  16. package/cjs/dtos/task-label.dto.js +120 -0
  17. package/cjs/dtos/task-list.dto.js +198 -0
  18. package/cjs/dtos/task.dto.js +367 -0
  19. package/cjs/entities/index.js +72 -0
  20. package/cjs/entities/task-activity.entity.js +98 -0
  21. package/cjs/entities/task-assignee.entity.js +67 -0
  22. package/cjs/entities/task-board-member.entity.js +94 -0
  23. package/cjs/entities/task-board-with-company.entity.js +57 -0
  24. package/cjs/entities/task-board.entity.js +88 -0
  25. package/cjs/entities/task-comment.entity.js +80 -0
  26. package/cjs/entities/task-label.entity.js +72 -0
  27. package/cjs/entities/task-list.entity.js +104 -0
  28. package/cjs/entities/task-task-label.entity.js +67 -0
  29. package/cjs/entities/task.entity.js +151 -0
  30. package/cjs/gateways/index.js +18 -0
  31. package/cjs/gateways/task-board.gateway.js +199 -0
  32. package/cjs/index.js +26 -0
  33. package/cjs/interfaces/index.js +19 -0
  34. package/cjs/interfaces/task-manager-module.interface.js +4 -0
  35. package/cjs/interfaces/task.interface.js +4 -0
  36. package/cjs/modules/index.js +18 -0
  37. package/cjs/modules/task-manager.module.js +131 -0
  38. package/cjs/services/index.js +25 -0
  39. package/cjs/services/task-activity.service.js +76 -0
  40. package/cjs/services/task-board.service.js +235 -0
  41. package/cjs/services/task-comment.service.js +103 -0
  42. package/cjs/services/task-label.service.js +97 -0
  43. package/cjs/services/task-list.service.js +115 -0
  44. package/cjs/services/task-manager-config.service.js +69 -0
  45. package/cjs/services/task-manager-datasource.provider.js +84 -0
  46. package/cjs/services/task.service.js +359 -0
  47. package/config/index.d.ts +2 -0
  48. package/config/message-keys.d.ts +65 -0
  49. package/config/task-manager.constants.d.ts +1 -0
  50. package/controllers/index.d.ts +5 -0
  51. package/controllers/task-board.controller.d.ts +27 -0
  52. package/controllers/task-comment.controller.d.ts +22 -0
  53. package/controllers/task-label.controller.d.ts +22 -0
  54. package/controllers/task-list.controller.d.ts +26 -0
  55. package/controllers/task.controller.d.ts +28 -0
  56. package/docs/index.d.ts +1 -0
  57. package/docs/task-manager-swagger.config.d.ts +2 -0
  58. package/dtos/index.d.ts +5 -0
  59. package/dtos/task-board.dto.d.ts +44 -0
  60. package/dtos/task-comment.dto.d.ts +16 -0
  61. package/dtos/task-label.dto.d.ts +16 -0
  62. package/dtos/task-list.dto.d.ts +26 -0
  63. package/dtos/task.dto.d.ts +48 -0
  64. package/entities/index.d.ts +22 -0
  65. package/entities/task-activity.entity.d.ts +9 -0
  66. package/entities/task-assignee.entity.d.ts +5 -0
  67. package/entities/task-board-member.entity.d.ts +12 -0
  68. package/entities/task-board-with-company.entity.d.ts +4 -0
  69. package/entities/task-board.entity.d.ts +8 -0
  70. package/entities/task-comment.entity.d.ts +7 -0
  71. package/entities/task-label.entity.d.ts +6 -0
  72. package/entities/task-list.entity.d.ts +9 -0
  73. package/entities/task-task-label.entity.d.ts +5 -0
  74. package/entities/task.entity.d.ts +23 -0
  75. package/fesm/config/index.js +2 -0
  76. package/fesm/config/message-keys.js +65 -0
  77. package/fesm/config/task-manager.constants.js +1 -0
  78. package/fesm/controllers/index.js +5 -0
  79. package/fesm/controllers/task-board.controller.js +209 -0
  80. package/fesm/controllers/task-comment.controller.js +93 -0
  81. package/fesm/controllers/task-label.controller.js +102 -0
  82. package/fesm/controllers/task-list.controller.js +148 -0
  83. package/fesm/controllers/task.controller.js +189 -0
  84. package/fesm/docs/index.js +1 -0
  85. package/fesm/docs/task-manager-swagger.config.js +33 -0
  86. package/fesm/dtos/index.js +5 -0
  87. package/fesm/dtos/task-board.dto.js +277 -0
  88. package/fesm/dtos/task-comment.dto.js +110 -0
  89. package/fesm/dtos/task-label.dto.js +99 -0
  90. package/fesm/dtos/task-list.dto.js +174 -0
  91. package/fesm/dtos/task.dto.js +337 -0
  92. package/fesm/entities/index.js +46 -0
  93. package/fesm/entities/task-activity.entity.js +88 -0
  94. package/fesm/entities/task-assignee.entity.js +57 -0
  95. package/fesm/entities/task-board-member.entity.js +76 -0
  96. package/fesm/entities/task-board-with-company.entity.js +47 -0
  97. package/fesm/entities/task-board.entity.js +78 -0
  98. package/fesm/entities/task-comment.entity.js +70 -0
  99. package/fesm/entities/task-label.entity.js +62 -0
  100. package/fesm/entities/task-list.entity.js +94 -0
  101. package/fesm/entities/task-task-label.entity.js +57 -0
  102. package/fesm/entities/task.entity.js +133 -0
  103. package/fesm/gateways/index.js +1 -0
  104. package/fesm/gateways/task-board.gateway.js +148 -0
  105. package/fesm/index.js +9 -0
  106. package/fesm/interfaces/index.js +2 -0
  107. package/fesm/interfaces/task-manager-module.interface.js +1 -0
  108. package/fesm/interfaces/task.interface.js +1 -0
  109. package/fesm/modules/index.js +1 -0
  110. package/fesm/modules/task-manager.module.js +121 -0
  111. package/fesm/services/index.js +8 -0
  112. package/fesm/services/task-activity.service.js +66 -0
  113. package/fesm/services/task-board.service.js +225 -0
  114. package/fesm/services/task-comment.service.js +93 -0
  115. package/fesm/services/task-label.service.js +87 -0
  116. package/fesm/services/task-list.service.js +105 -0
  117. package/fesm/services/task-manager-config.service.js +59 -0
  118. package/fesm/services/task-manager-datasource.provider.js +74 -0
  119. package/fesm/services/task.service.js +349 -0
  120. package/gateways/index.d.ts +1 -0
  121. package/gateways/task-board.gateway.d.ts +22 -0
  122. package/index.d.ts +9 -0
  123. package/interfaces/index.d.ts +2 -0
  124. package/interfaces/task-manager-module.interface.d.ts +19 -0
  125. package/interfaces/task.interface.d.ts +52 -0
  126. package/modules/index.d.ts +1 -0
  127. package/modules/task-manager.module.d.ts +8 -0
  128. package/package.json +91 -0
  129. package/services/index.d.ts +8 -0
  130. package/services/task-activity.service.d.ts +8 -0
  131. package/services/task-board.service.d.ts +32 -0
  132. package/services/task-comment.service.d.ts +18 -0
  133. package/services/task-label.service.d.ts +18 -0
  134. package/services/task-list.service.d.ts +19 -0
  135. package/services/task-manager-config.service.d.ts +12 -0
  136. package/services/task-manager-datasource.provider.d.ts +18 -0
  137. package/services/task.service.d.ts +44 -0
@@ -0,0 +1,133 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _ts_decorate(decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ 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;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ }
20
+ function _ts_metadata(k, v) {
21
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
+ }
23
+ import { Identity } from '@flusys/nestjs-shared/entities';
24
+ import { Column, Entity, Index } from 'typeorm';
25
+ export var TaskPriority = /*#__PURE__*/ function(TaskPriority) {
26
+ TaskPriority["LOW"] = "LOW";
27
+ TaskPriority["MEDIUM"] = "MEDIUM";
28
+ TaskPriority["HIGH"] = "HIGH";
29
+ TaskPriority["URGENT"] = "URGENT";
30
+ return TaskPriority;
31
+ }({});
32
+ export class Task extends Identity {
33
+ constructor(...args){
34
+ super(...args), _define_property(this, "boardId", void 0), _define_property(this, "listId", void 0), _define_property(this, "title", void 0), _define_property(this, "description", void 0), _define_property(this, "priority", void 0), _define_property(this, "dueDate", void 0), _define_property(this, "position", void 0), _define_property(this, "reporterId", void 0), _define_property(this, "parentTaskId", void 0), _define_property(this, "estimatedHours", void 0), _define_property(this, "assignees", []);
35
+ }
36
+ }
37
+ _ts_decorate([
38
+ Index(),
39
+ Column({
40
+ name: 'board_id',
41
+ type: 'uuid',
42
+ nullable: false
43
+ }),
44
+ _ts_metadata("design:type", String)
45
+ ], Task.prototype, "boardId", void 0);
46
+ _ts_decorate([
47
+ Index(),
48
+ Column({
49
+ name: 'list_id',
50
+ type: 'uuid',
51
+ nullable: false
52
+ }),
53
+ _ts_metadata("design:type", String)
54
+ ], Task.prototype, "listId", void 0);
55
+ _ts_decorate([
56
+ Column({
57
+ type: 'varchar',
58
+ length: 500,
59
+ nullable: false
60
+ }),
61
+ _ts_metadata("design:type", String)
62
+ ], Task.prototype, "title", void 0);
63
+ _ts_decorate([
64
+ Column({
65
+ type: 'text',
66
+ nullable: true
67
+ }),
68
+ _ts_metadata("design:type", Object)
69
+ ], Task.prototype, "description", void 0);
70
+ _ts_decorate([
71
+ Column({
72
+ type: 'varchar',
73
+ length: 20,
74
+ nullable: false,
75
+ default: "MEDIUM"
76
+ }),
77
+ _ts_metadata("design:type", String)
78
+ ], Task.prototype, "priority", void 0);
79
+ _ts_decorate([
80
+ Column({
81
+ name: 'due_date',
82
+ type: 'date',
83
+ nullable: true
84
+ }),
85
+ _ts_metadata("design:type", Object)
86
+ ], Task.prototype, "dueDate", void 0);
87
+ _ts_decorate([
88
+ Column({
89
+ type: 'int',
90
+ nullable: false,
91
+ default: 0
92
+ }),
93
+ _ts_metadata("design:type", Number)
94
+ ], Task.prototype, "position", void 0);
95
+ _ts_decorate([
96
+ Column({
97
+ name: 'reporter_id',
98
+ type: 'uuid',
99
+ nullable: true
100
+ }),
101
+ _ts_metadata("design:type", Object)
102
+ ], Task.prototype, "reporterId", void 0);
103
+ _ts_decorate([
104
+ Column({
105
+ name: 'parent_task_id',
106
+ type: 'uuid',
107
+ nullable: true
108
+ }),
109
+ _ts_metadata("design:type", Object)
110
+ ], Task.prototype, "parentTaskId", void 0);
111
+ _ts_decorate([
112
+ Column({
113
+ name: 'estimated_hours',
114
+ type: 'decimal',
115
+ precision: 5,
116
+ scale: 1,
117
+ nullable: true
118
+ }),
119
+ _ts_metadata("design:type", Object)
120
+ ], Task.prototype, "estimatedHours", void 0);
121
+ Task = _ts_decorate([
122
+ Entity({
123
+ name: 'task'
124
+ }),
125
+ Index([
126
+ 'boardId',
127
+ 'listId',
128
+ 'position'
129
+ ]),
130
+ Index([
131
+ 'dueDate'
132
+ ])
133
+ ], Task);
@@ -0,0 +1 @@
1
+ export * from './task-board.gateway';
@@ -0,0 +1,148 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _ts_decorate(decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ 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;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ }
20
+ function _ts_metadata(k, v) {
21
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
+ }
23
+ function _ts_param(paramIndex, decorator) {
24
+ return function(target, key) {
25
+ decorator(target, key, paramIndex);
26
+ };
27
+ }
28
+ import { Inject } from '@nestjs/common';
29
+ import { ConnectedSocket, MessageBody, SubscribeMessage, WebSocketGateway, WebSocketServer } from '@nestjs/websockets';
30
+ import * as jwt from 'jsonwebtoken';
31
+ import { Server, Socket } from 'socket.io';
32
+ import { TaskManagerConfigService } from '../services/task-manager-config.service';
33
+ export class TaskBoardGateway {
34
+ async handleConnection(client) {
35
+ try {
36
+ const token = this.extractToken(client);
37
+ if (!token) {
38
+ client.disconnect();
39
+ return;
40
+ }
41
+ const payload = this.verifyToken(token);
42
+ if (!payload) {
43
+ client.disconnect();
44
+ return;
45
+ }
46
+ client.data.userId = payload.id;
47
+ client.data.companyId = payload.companyId;
48
+ if (!this.connectedUsers.has(payload.id)) {
49
+ this.connectedUsers.set(payload.id, new Set());
50
+ }
51
+ this.connectedUsers.get(payload.id).add(client.id);
52
+ client.join(`user:${payload.id}`);
53
+ } catch {
54
+ client.disconnect();
55
+ }
56
+ }
57
+ handleDisconnect(client) {
58
+ const userId = client.data.userId;
59
+ if (userId) {
60
+ const sockets = this.connectedUsers.get(userId);
61
+ sockets?.delete(client.id);
62
+ if (sockets?.size === 0) {
63
+ this.connectedUsers.delete(userId);
64
+ }
65
+ }
66
+ }
67
+ handleJoinBoard(client, data) {
68
+ if (data?.boardId) {
69
+ client.join(`board:${data.boardId}`);
70
+ }
71
+ }
72
+ handleLeaveBoard(client, data) {
73
+ if (data?.boardId) {
74
+ client.leave(`board:${data.boardId}`);
75
+ }
76
+ }
77
+ emitToBoardRoom(boardId, event) {
78
+ this.server?.to(`board:${boardId}`).emit('board:event', event);
79
+ }
80
+ isUserOnline(userId) {
81
+ return this.connectedUsers.has(userId);
82
+ }
83
+ extractToken(client) {
84
+ const authToken = client.handshake.auth?.token;
85
+ if (authToken) return authToken;
86
+ const queryToken = client.handshake.query?.token;
87
+ if (typeof queryToken === 'string') return queryToken;
88
+ const authHeader = client.handshake.headers?.authorization;
89
+ if (authHeader?.startsWith('Bearer ')) return authHeader.substring(7);
90
+ return null;
91
+ }
92
+ verifyToken(token) {
93
+ try {
94
+ const secret = this.configService.getJwtSecret();
95
+ if (!secret) return null;
96
+ return jwt.verify(token, secret);
97
+ } catch {
98
+ return null;
99
+ }
100
+ }
101
+ constructor(configService){
102
+ _define_property(this, "configService", void 0);
103
+ _define_property(this, "connectedUsers", void 0);
104
+ _define_property(this, "server", void 0);
105
+ this.configService = configService;
106
+ this.connectedUsers = new Map();
107
+ }
108
+ }
109
+ _ts_decorate([
110
+ WebSocketServer(),
111
+ _ts_metadata("design:type", typeof Server === "undefined" ? Object : Server)
112
+ ], TaskBoardGateway.prototype, "server", void 0);
113
+ _ts_decorate([
114
+ SubscribeMessage('board:join'),
115
+ _ts_param(0, ConnectedSocket()),
116
+ _ts_param(1, MessageBody()),
117
+ _ts_metadata("design:type", Function),
118
+ _ts_metadata("design:paramtypes", [
119
+ typeof Socket === "undefined" ? Object : Socket,
120
+ Object
121
+ ]),
122
+ _ts_metadata("design:returntype", void 0)
123
+ ], TaskBoardGateway.prototype, "handleJoinBoard", null);
124
+ _ts_decorate([
125
+ SubscribeMessage('board:leave'),
126
+ _ts_param(0, ConnectedSocket()),
127
+ _ts_param(1, MessageBody()),
128
+ _ts_metadata("design:type", Function),
129
+ _ts_metadata("design:paramtypes", [
130
+ typeof Socket === "undefined" ? Object : Socket,
131
+ Object
132
+ ]),
133
+ _ts_metadata("design:returntype", void 0)
134
+ ], TaskBoardGateway.prototype, "handleLeaveBoard", null);
135
+ TaskBoardGateway = _ts_decorate([
136
+ WebSocketGateway({
137
+ namespace: '/task-boards',
138
+ cors: {
139
+ origin: '*',
140
+ credentials: true
141
+ }
142
+ }),
143
+ _ts_param(0, Inject(TaskManagerConfigService)),
144
+ _ts_metadata("design:type", Function),
145
+ _ts_metadata("design:paramtypes", [
146
+ typeof TaskManagerConfigService === "undefined" ? Object : TaskManagerConfigService
147
+ ])
148
+ ], TaskBoardGateway);
package/fesm/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export * from './config';
2
+ export * from './controllers';
3
+ export * from './docs';
4
+ export * from './dtos';
5
+ export * from './entities';
6
+ export * from './gateways';
7
+ export * from './interfaces';
8
+ export * from './modules';
9
+ export * from './services';
@@ -0,0 +1,2 @@
1
+ export * from './task-manager-module.interface';
2
+ export * from './task.interface';
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export * from './task-manager.module';
@@ -0,0 +1,121 @@
1
+ function _ts_decorate(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ }
7
+ import { CacheModule, UtilsModule } from '@flusys/nestjs-shared/modules';
8
+ import { Module } from '@nestjs/common';
9
+ import { TASK_MANAGER_MODULE_OPTIONS } from '../config/task-manager.constants';
10
+ import { TaskBoardController, TaskCommentController, TaskLabelController, TaskListController, TaskController } from '../controllers';
11
+ import { TaskBoardGateway } from '../gateways/task-board.gateway';
12
+ import { TaskActivityService, TaskBoardService, TaskCommentService, TaskLabelService, TaskListService, TaskManagerConfigService, TaskManagerDataSourceProvider, TaskService } from '../services';
13
+ const CONTROLLERS = [
14
+ TaskBoardController,
15
+ TaskListController,
16
+ TaskController,
17
+ TaskLabelController,
18
+ TaskCommentController
19
+ ];
20
+ const EXPORTED_SERVICES = [
21
+ TaskManagerConfigService,
22
+ TaskManagerDataSourceProvider,
23
+ TaskBoardService,
24
+ TaskListService,
25
+ TaskService,
26
+ TaskLabelService,
27
+ TaskCommentService,
28
+ TaskActivityService
29
+ ];
30
+ export class TaskManagerModule {
31
+ static forRoot(options) {
32
+ return {
33
+ module: TaskManagerModule,
34
+ global: options.global ?? false,
35
+ imports: [
36
+ CacheModule,
37
+ UtilsModule
38
+ ],
39
+ controllers: options.includeController !== false ? CONTROLLERS : [],
40
+ providers: [
41
+ ...this.buildProviders(options),
42
+ TaskBoardGateway
43
+ ],
44
+ exports: [
45
+ ...EXPORTED_SERVICES,
46
+ TaskBoardGateway
47
+ ]
48
+ };
49
+ }
50
+ static forRootAsync(options) {
51
+ return {
52
+ module: TaskManagerModule,
53
+ global: options.global ?? false,
54
+ imports: [
55
+ ...options.imports || [],
56
+ CacheModule,
57
+ UtilsModule
58
+ ],
59
+ controllers: options.includeController !== false ? CONTROLLERS : [],
60
+ providers: [
61
+ ...this.createAsyncProviders(options),
62
+ ...this.buildProviders(),
63
+ TaskBoardGateway
64
+ ],
65
+ exports: [
66
+ ...EXPORTED_SERVICES,
67
+ TaskBoardGateway
68
+ ]
69
+ };
70
+ }
71
+ static buildProviders(options) {
72
+ const providers = [
73
+ ...EXPORTED_SERVICES
74
+ ];
75
+ if (options) {
76
+ providers.unshift({
77
+ provide: TASK_MANAGER_MODULE_OPTIONS,
78
+ useValue: options
79
+ });
80
+ }
81
+ return providers;
82
+ }
83
+ static createAsyncProviders(options) {
84
+ if (options.useFactory) {
85
+ return [
86
+ {
87
+ provide: TASK_MANAGER_MODULE_OPTIONS,
88
+ useFactory: async (...args)=>({
89
+ ...options,
90
+ config: await options.useFactory(...args)
91
+ }),
92
+ inject: options.inject || []
93
+ }
94
+ ];
95
+ }
96
+ const factoryClass = options.useClass || options.useExisting;
97
+ if (!factoryClass) return [];
98
+ const providers = [
99
+ {
100
+ provide: TASK_MANAGER_MODULE_OPTIONS,
101
+ useFactory: async (factory)=>({
102
+ ...options,
103
+ config: await factory.createTaskManagerOptions()
104
+ }),
105
+ inject: [
106
+ factoryClass
107
+ ]
108
+ }
109
+ ];
110
+ if (options.useClass) {
111
+ providers.push({
112
+ provide: options.useClass,
113
+ useClass: options.useClass
114
+ });
115
+ }
116
+ return providers;
117
+ }
118
+ }
119
+ TaskManagerModule = _ts_decorate([
120
+ Module({})
121
+ ], TaskManagerModule);
@@ -0,0 +1,8 @@
1
+ export * from './task-manager-config.service';
2
+ export * from './task-manager-datasource.provider';
3
+ export * from './task-board.service';
4
+ export * from './task-list.service';
5
+ export * from './task-activity.service';
6
+ export * from './task-label.service';
7
+ export * from './task-comment.service';
8
+ export * from './task.service';
@@ -0,0 +1,66 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _ts_decorate(decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ 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;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ }
20
+ function _ts_metadata(k, v) {
21
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
+ }
23
+ function _ts_param(paramIndex, decorator) {
24
+ return function(target, key) {
25
+ decorator(target, key, paramIndex);
26
+ };
27
+ }
28
+ import { Inject, Injectable, Scope } from '@nestjs/common';
29
+ import { TaskActivity } from '../entities';
30
+ import { TaskManagerDataSourceProvider } from './task-manager-datasource.provider';
31
+ export class TaskActivityService {
32
+ async log(taskId, boardId, userId, action, oldValue, newValue) {
33
+ const repo = await this.ensureRepository();
34
+ const activity = repo.create({
35
+ taskId,
36
+ boardId,
37
+ userId,
38
+ action,
39
+ oldValue,
40
+ newValue
41
+ });
42
+ await repo.save(activity);
43
+ }
44
+ async ensureRepository() {
45
+ if (!this.repository) {
46
+ this.repository = await this.dataSourceProvider.getRepository(TaskActivity);
47
+ }
48
+ return this.repository;
49
+ }
50
+ constructor(dataSourceProvider){
51
+ _define_property(this, "dataSourceProvider", void 0);
52
+ _define_property(this, "repository", void 0);
53
+ this.dataSourceProvider = dataSourceProvider;
54
+ this.repository = null;
55
+ }
56
+ }
57
+ TaskActivityService = _ts_decorate([
58
+ Injectable({
59
+ scope: Scope.REQUEST
60
+ }),
61
+ _ts_param(0, Inject(TaskManagerDataSourceProvider)),
62
+ _ts_metadata("design:type", Function),
63
+ _ts_metadata("design:paramtypes", [
64
+ typeof TaskManagerDataSourceProvider === "undefined" ? Object : TaskManagerDataSourceProvider
65
+ ])
66
+ ], TaskActivityService);