@carlonicora/nja-todos 0.0.1 → 1.0.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.
- package/LICENSE +675 -0
- package/README.md +791 -2
- package/dist/api/common/decorate.d.ts +21 -0
- package/dist/api/common/decorate.d.ts.map +1 -0
- package/dist/api/common/decorate.js +39 -0
- package/dist/api/common/decorate.js.map +1 -0
- package/dist/api/config/todos.config.d.ts +51 -0
- package/dist/api/config/todos.config.d.ts.map +1 -0
- package/dist/api/config/todos.config.js +7 -0
- package/dist/api/config/todos.config.js.map +1 -0
- package/dist/api/events/todos.event.payloads.d.ts +21 -0
- package/dist/api/events/todos.event.payloads.d.ts.map +1 -0
- package/dist/api/events/todos.event.payloads.js +3 -0
- package/dist/api/events/todos.event.payloads.js.map +1 -0
- package/dist/api/index.d.ts +22 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +49 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/notifications/todos.notification.processor.d.ts +48 -0
- package/dist/api/notifications/todos.notification.processor.d.ts.map +1 -0
- package/dist/api/notifications/todos.notification.processor.js +251 -0
- package/dist/api/notifications/todos.notification.processor.js.map +1 -0
- package/dist/api/notifications/todos.queue.d.ts +41 -0
- package/dist/api/notifications/todos.queue.d.ts.map +1 -0
- package/dist/api/notifications/todos.queue.js +35 -0
- package/dist/api/notifications/todos.queue.js.map +1 -0
- package/dist/api/task/controllers/task.controller.factory.d.ts +38 -0
- package/dist/api/task/controllers/task.controller.factory.d.ts.map +1 -0
- package/dist/api/task/controllers/task.controller.factory.js +314 -0
- package/dist/api/task/controllers/task.controller.factory.js.map +1 -0
- package/dist/api/task/dtos/task.dtos.d.ts +15 -0
- package/dist/api/task/dtos/task.dtos.d.ts.map +1 -0
- package/dist/api/task/dtos/task.dtos.js +260 -0
- package/dist/api/task/dtos/task.dtos.js.map +1 -0
- package/dist/api/task/entities/task.d.ts +21 -0
- package/dist/api/task/entities/task.d.ts.map +1 -0
- package/dist/api/task/entities/task.js +95 -0
- package/dist/api/task/entities/task.js.map +1 -0
- package/dist/api/task/entities/task.meta.d.ts +3 -0
- package/dist/api/task/entities/task.meta.d.ts.map +1 -0
- package/dist/api/task/entities/task.meta.js +11 -0
- package/dist/api/task/entities/task.meta.js.map +1 -0
- package/dist/api/task/repositories/task.repository.d.ts +104 -0
- package/dist/api/task/repositories/task.repository.d.ts.map +1 -0
- package/dist/api/task/repositories/task.repository.js +328 -0
- package/dist/api/task/repositories/task.repository.js.map +1 -0
- package/dist/api/task/services/task.service.d.ts +149 -0
- package/dist/api/task/services/task.service.d.ts.map +1 -0
- package/dist/api/task/services/task.service.js +378 -0
- package/dist/api/task/services/task.service.js.map +1 -0
- package/dist/api/taskcomment/controllers/taskcomment.controller.factory.d.ts +44 -0
- package/dist/api/taskcomment/controllers/taskcomment.controller.factory.d.ts.map +1 -0
- package/dist/api/taskcomment/controllers/taskcomment.controller.factory.js +136 -0
- package/dist/api/taskcomment/controllers/taskcomment.controller.factory.js.map +1 -0
- package/dist/api/taskcomment/dtos/taskcomment.post.dto.d.ts +23 -0
- package/dist/api/taskcomment/dtos/taskcomment.post.dto.d.ts.map +1 -0
- package/dist/api/taskcomment/dtos/taskcomment.post.dto.js +87 -0
- package/dist/api/taskcomment/dtos/taskcomment.post.dto.js.map +1 -0
- package/dist/api/taskcomment/dtos/taskcomment.put.dto.d.ts +21 -0
- package/dist/api/taskcomment/dtos/taskcomment.put.dto.d.ts.map +1 -0
- package/dist/api/taskcomment/dtos/taskcomment.put.dto.js +71 -0
- package/dist/api/taskcomment/dtos/taskcomment.put.dto.js.map +1 -0
- package/dist/api/taskcomment/entities/taskcomment.d.ts +11 -0
- package/dist/api/taskcomment/entities/taskcomment.d.ts.map +1 -0
- package/dist/api/taskcomment/entities/taskcomment.js +44 -0
- package/dist/api/taskcomment/entities/taskcomment.js.map +1 -0
- package/dist/api/taskcomment/entities/taskcomment.meta.d.ts +5 -0
- package/dist/api/taskcomment/entities/taskcomment.meta.d.ts.map +1 -0
- package/dist/api/taskcomment/entities/taskcomment.meta.js +13 -0
- package/dist/api/taskcomment/entities/taskcomment.meta.js.map +1 -0
- package/dist/api/taskcomment/repositories/taskcomment.repository.d.ts +25 -0
- package/dist/api/taskcomment/repositories/taskcomment.repository.d.ts.map +1 -0
- package/dist/api/taskcomment/repositories/taskcomment.repository.js +73 -0
- package/dist/api/taskcomment/repositories/taskcomment.repository.js.map +1 -0
- package/dist/api/taskcomment/services/taskcomment.service.d.ts +78 -0
- package/dist/api/taskcomment/services/taskcomment.service.d.ts.map +1 -0
- package/dist/api/taskcomment/services/taskcomment.service.js +190 -0
- package/dist/api/taskcomment/services/taskcomment.service.js.map +1 -0
- package/dist/api/todos.module.d.ts +20 -0
- package/dist/api/todos.module.d.ts.map +1 -0
- package/dist/api/todos.module.js +143 -0
- package/dist/api/todos.module.js.map +1 -0
- package/dist/chunk-CO56HIPE.mjs +283 -0
- package/dist/chunk-CO56HIPE.mjs.map +1 -0
- package/dist/chunk-K6KLDGC2.js +283 -0
- package/dist/chunk-K6KLDGC2.js.map +1 -0
- package/dist/seed/index.d.ts +4 -0
- package/dist/seed/index.d.ts.map +1 -0
- package/dist/seed/index.js +9 -0
- package/dist/seed/index.js.map +1 -0
- package/dist/seed/todos.module.seed.d.ts +12 -0
- package/dist/seed/todos.module.seed.d.ts.map +1 -0
- package/dist/seed/todos.module.seed.js +54 -0
- package/dist/seed/todos.module.seed.js.map +1 -0
- package/dist/shared/index.d.ts +7 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +23 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/task.completed.filter.d.ts +2 -0
- package/dist/shared/task.completed.filter.d.ts.map +1 -0
- package/dist/shared/task.completed.filter.js +3 -0
- package/dist/shared/task.completed.filter.js.map +1 -0
- package/dist/shared/task.priority.d.ts +6 -0
- package/dist/shared/task.priority.d.ts.map +1 -0
- package/dist/shared/task.priority.js +10 -0
- package/dist/shared/task.priority.js.map +1 -0
- package/dist/shared/todos.endpoints.d.ts +7 -0
- package/dist/shared/todos.endpoints.d.ts.map +1 -0
- package/dist/shared/todos.endpoints.js +10 -0
- package/dist/shared/todos.endpoints.js.map +1 -0
- package/dist/shared/todos.events.d.ts +13 -0
- package/dist/shared/todos.events.d.ts.map +1 -0
- package/dist/shared/todos.events.js +16 -0
- package/dist/shared/todos.events.js.map +1 -0
- package/dist/shared/todos.module.ids.d.ts +5 -0
- package/dist/shared/todos.module.ids.d.ts.map +1 -0
- package/dist/shared/todos.module.ids.js +8 -0
- package/dist/shared/todos.module.ids.js.map +1 -0
- package/dist/shared/todos.notification.types.d.ts +6 -0
- package/dist/shared/todos.notification.types.d.ts.map +1 -0
- package/dist/shared/todos.notification.types.js +9 -0
- package/dist/shared/todos.notification.types.js.map +1 -0
- package/dist/web/config/todos.config.d.ts +25 -0
- package/dist/web/config/todos.config.d.ts.map +1 -0
- package/dist/web/config/todos.ui.config.d.ts +28 -0
- package/dist/web/config/todos.ui.config.d.ts.map +1 -0
- package/dist/web/core.d.ts +18 -0
- package/dist/web/core.d.ts.map +1 -0
- package/dist/web/core.js +208 -0
- package/dist/web/core.js.map +1 -0
- package/dist/web/core.mjs +208 -0
- package/dist/web/core.mjs.map +1 -0
- package/dist/web/index.d.ts +22 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +1959 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/index.mjs +1958 -0
- package/dist/web/index.mjs.map +1 -0
- package/dist/web/task/TaskModule.d.ts +6 -0
- package/dist/web/task/TaskModule.d.ts.map +1 -0
- package/dist/web/task/components/EisenhowerIcon.d.ts +9 -0
- package/dist/web/task/components/EisenhowerIcon.d.ts.map +1 -0
- package/dist/web/task/components/EisenhowerMatrixBoard.d.ts +21 -0
- package/dist/web/task/components/EisenhowerMatrixBoard.d.ts.map +1 -0
- package/dist/web/task/components/TaskMatrixCard.d.ts +11 -0
- package/dist/web/task/components/TaskMatrixCard.d.ts.map +1 -0
- package/dist/web/task/components/containers/TaskListContainer.d.ts +12 -0
- package/dist/web/task/components/containers/TaskListContainer.d.ts.map +1 -0
- package/dist/web/task/components/editors/TaskEditor.d.ts +12 -0
- package/dist/web/task/components/editors/TaskEditor.d.ts.map +1 -0
- package/dist/web/task/components/filters/TaskListFilters.d.ts +9 -0
- package/dist/web/task/components/filters/TaskListFilters.d.ts.map +1 -0
- package/dist/web/task/components/filters/TaskViewSwitcher.d.ts +9 -0
- package/dist/web/task/components/filters/TaskViewSwitcher.d.ts.map +1 -0
- package/dist/web/task/components/forms/TaskCreateButton.d.ts +5 -0
- package/dist/web/task/components/forms/TaskCreateButton.d.ts.map +1 -0
- package/dist/web/task/components/forms/TaskDeleter.d.ts +8 -0
- package/dist/web/task/components/forms/TaskDeleter.d.ts.map +1 -0
- package/dist/web/task/components/lists/TasksList.d.ts +20 -0
- package/dist/web/task/components/lists/TasksList.d.ts.map +1 -0
- package/dist/web/task/components/screens/UserTasksScreen.d.ts +5 -0
- package/dist/web/task/components/screens/UserTasksScreen.d.ts.map +1 -0
- package/dist/web/task/contexts/TaskContext.d.ts +29 -0
- package/dist/web/task/contexts/TaskContext.d.ts.map +1 -0
- package/dist/web/task/data/Task.d.ts +25 -0
- package/dist/web/task/data/Task.d.ts.map +1 -0
- package/dist/web/task/data/TaskFields.d.ts +12 -0
- package/dist/web/task/data/TaskFields.d.ts.map +1 -0
- package/dist/web/task/data/TaskInterface.d.ts +29 -0
- package/dist/web/task/data/TaskInterface.d.ts.map +1 -0
- package/dist/web/task/data/TaskService.d.ts +51 -0
- package/dist/web/task/data/TaskService.d.ts.map +1 -0
- package/dist/web/task/hooks/useTaskDeepLink.d.ts +12 -0
- package/dist/web/task/hooks/useTaskDeepLink.d.ts.map +1 -0
- package/dist/web/task/hooks/useTaskOverdueParam.d.ts +19 -0
- package/dist/web/task/hooks/useTaskOverdueParam.d.ts.map +1 -0
- package/dist/web/task/hooks/useTaskTableStructure.d.ts +8 -0
- package/dist/web/task/hooks/useTaskTableStructure.d.ts.map +1 -0
- package/dist/web/task/lib/task.priority.options.d.ts +5 -0
- package/dist/web/task/lib/task.priority.options.d.ts.map +1 -0
- package/dist/web/task/utils/dueDate.d.ts +11 -0
- package/dist/web/task/utils/dueDate.d.ts.map +1 -0
- package/dist/web/task/utils/getEisenhowerQuadrant.d.ts +4 -0
- package/dist/web/task/utils/getEisenhowerQuadrant.d.ts.map +1 -0
- package/dist/web/task/utils/isTaskOverdue.d.ts +12 -0
- package/dist/web/task/utils/isTaskOverdue.d.ts.map +1 -0
- package/dist/web/taskcomment/TaskCommentModule.d.ts +5 -0
- package/dist/web/taskcomment/TaskCommentModule.d.ts.map +1 -0
- package/dist/web/taskcomment/components/forms/TaskCommentEditor.d.ts +2 -0
- package/dist/web/taskcomment/components/forms/TaskCommentEditor.d.ts.map +1 -0
- package/dist/web/taskcomment/components/lists/TaskCommentList.d.ts +2 -0
- package/dist/web/taskcomment/components/lists/TaskCommentList.d.ts.map +1 -0
- package/dist/web/taskcomment/contexts/TaskCommentContext.d.ts +22 -0
- package/dist/web/taskcomment/contexts/TaskCommentContext.d.ts.map +1 -0
- package/dist/web/taskcomment/data/TaskComment.d.ts +11 -0
- package/dist/web/taskcomment/data/TaskComment.d.ts.map +1 -0
- package/dist/web/taskcomment/data/TaskCommentInterface.d.ts +12 -0
- package/dist/web/taskcomment/data/TaskCommentInterface.d.ts.map +1 -0
- package/dist/web/taskcomment/data/TaskCommentService.d.ts +16 -0
- package/dist/web/taskcomment/data/TaskCommentService.d.ts.map +1 -0
- package/dist/web/todos.modules.d.ts +10 -0
- package/dist/web/todos.modules.d.ts.map +1 -0
- package/dist/web/utils/isNotFoundError.d.ts +11 -0
- package/dist/web/utils/isNotFoundError.d.ts.map +1 -0
- package/i18n/en/todos.json +13 -0
- package/i18n/it/todos.json +13 -0
- package/messages/en.json +132 -0
- package/messages/it.json +132 -0
- package/package.json +214 -5
- package/templates/email/en/taskAssigned.hbs +31 -0
- package/templates/email/en/taskCommented.hbs +31 -0
- package/templates/email/en/taskCompleted.hbs +31 -0
- package/templates/email/it/taskAssigned.hbs +31 -0
- package/templates/email/it/taskCommented.hbs +31 -0
- package/templates/email/it/taskCompleted.hbs +31 -0
|
@@ -0,0 +1,190 @@
|
|
|
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.TaskCommentService = void 0;
|
|
16
|
+
const nestjs_neo4jsonapi_1 = require("@carlonicora/nestjs-neo4jsonapi");
|
|
17
|
+
const bullmq_1 = require("@nestjs/bullmq");
|
|
18
|
+
const common_1 = require("@nestjs/common");
|
|
19
|
+
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
20
|
+
const bullmq_2 = require("bullmq");
|
|
21
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
22
|
+
const todos_events_1 = require("../../../shared/todos.events");
|
|
23
|
+
const todos_config_1 = require("../../config/todos.config");
|
|
24
|
+
const todos_queue_1 = require("../../notifications/todos.queue");
|
|
25
|
+
const task_meta_1 = require("../../task/entities/task.meta");
|
|
26
|
+
const task_repository_1 = require("../../task/repositories/task.repository");
|
|
27
|
+
const taskcomment_repository_1 = require("../repositories/taskcomment.repository");
|
|
28
|
+
/** Neo4j's error code for a broken uniqueness constraint (an existing id). */
|
|
29
|
+
const CONSTRAINT_VALIDATION_FAILED = "Neo.ClientError.Schema.ConstraintValidationFailed";
|
|
30
|
+
/**
|
|
31
|
+
* Task comments. Every method first loads the comment's task with TaskRepository.findTask, which
|
|
32
|
+
* applies the task read rule: a task the user cannot see (or a missing one, or one of another
|
|
33
|
+
* company) answers 404 before any comment is read or written. Only the author changes or deletes
|
|
34
|
+
* a comment.
|
|
35
|
+
*/
|
|
36
|
+
let TaskCommentService = class TaskCommentService extends nestjs_neo4jsonapi_1.AbstractService {
|
|
37
|
+
constructor(jsonApiService, taskCommentRepository, taskRepository, queue, clsService, eventEmitter, descriptor) {
|
|
38
|
+
super(jsonApiService, taskCommentRepository, clsService, descriptor.model);
|
|
39
|
+
this.taskCommentRepository = taskCommentRepository;
|
|
40
|
+
this.taskRepository = taskRepository;
|
|
41
|
+
this.queue = queue;
|
|
42
|
+
this.clsService = clsService;
|
|
43
|
+
this.eventEmitter = eventEmitter;
|
|
44
|
+
this.descriptor = descriptor;
|
|
45
|
+
}
|
|
46
|
+
async findByTask(params) {
|
|
47
|
+
await this.requireVisibleTask(params.taskId);
|
|
48
|
+
const paginator = new nestjs_neo4jsonapi_1.JsonApiPaginator(params.query);
|
|
49
|
+
const rows = await this.taskCommentRepository.findByTask({
|
|
50
|
+
taskId: params.taskId,
|
|
51
|
+
fetchAll: params.fetchAll,
|
|
52
|
+
cursor: paginator.generateCursor(),
|
|
53
|
+
});
|
|
54
|
+
return this.jsonApiService.buildList(this.descriptor.model, rows, paginator);
|
|
55
|
+
}
|
|
56
|
+
async createFromDTO(params) {
|
|
57
|
+
const relationship = params.data.relationships?.task?.data;
|
|
58
|
+
const taskId = Array.isArray(relationship) ? undefined : relationship?.id;
|
|
59
|
+
const task = await this.requireVisibleTask(taskId);
|
|
60
|
+
const repoParams = this.mapDTOToParams(params.data, "create");
|
|
61
|
+
try {
|
|
62
|
+
await this.taskCommentRepository.create(repoParams);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (error?.code === CONSTRAINT_VALIDATION_FAILED)
|
|
66
|
+
throw new common_1.ConflictException("A comment with this id already exists");
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
const comment = await this.requireComment(repoParams.id);
|
|
70
|
+
await this.enqueueCommented({ taskId: task.id, commentId: comment.id });
|
|
71
|
+
this.emit(todos_events_1.TodosEvent.CommentCreated, { comment, taskId: task.id, changes: [] });
|
|
72
|
+
return this.jsonApiService.buildSingle(this.descriptor.model, comment);
|
|
73
|
+
}
|
|
74
|
+
/** PUT taskcomments/:id (through createCrudHandlers): the author edits the text. */
|
|
75
|
+
async putFromDTO(params) {
|
|
76
|
+
return this.updateContent(params.data);
|
|
77
|
+
}
|
|
78
|
+
/** The same edit under the inherited PATCH name, so it cannot skip the author check. */
|
|
79
|
+
async patchFromDTO(params) {
|
|
80
|
+
return this.updateContent(params.data);
|
|
81
|
+
}
|
|
82
|
+
async delete(params) {
|
|
83
|
+
const { comment, task } = await this.requireOwnComment(params.id);
|
|
84
|
+
await this.taskCommentRepository.delete({ id: comment.id });
|
|
85
|
+
this.emit(todos_events_1.TodosEvent.CommentDeleted, { comment, taskId: task.id, changes: [] });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* One comment, after its task's read rule (a hidden task answers 404). No route calls it, but
|
|
89
|
+
* it stays: without it the inherited AbstractService.findById (company filter only, no task
|
|
90
|
+
* read rule) would be the public method of this exported service, and the inherited
|
|
91
|
+
* create/put/patch/addToRelationshipFromDTO read their result back through this.findById.
|
|
92
|
+
*/
|
|
93
|
+
async findById(params) {
|
|
94
|
+
const comment = await this.requireComment(params.id);
|
|
95
|
+
await this.requireVisibleTask(comment.task?.id);
|
|
96
|
+
return this.jsonApiService.buildSingle(this.descriptor.model, comment);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The task a comment belongs to, as a cache element (`@CacheInvalidate`'s `elements` on the
|
|
100
|
+
* comment PUT and DELETE routes): the task's cached comment list changes with the write.
|
|
101
|
+
* [] when the comment is gone.
|
|
102
|
+
*/
|
|
103
|
+
async findTaskElement(params) {
|
|
104
|
+
const taskId = (await this.taskCommentRepository.findComment({ id: params.commentId }))?.task?.id;
|
|
105
|
+
return taskId ? [{ type: task_meta_1.taskMeta.endpoint, id: taskId }] : [];
|
|
106
|
+
}
|
|
107
|
+
/** Comments are listed only through their task, which applies the read rule. */
|
|
108
|
+
async find() {
|
|
109
|
+
throw new common_1.BadRequestException("Comments are listed through their task");
|
|
110
|
+
}
|
|
111
|
+
/** The inherited relationship list: only `task`, routed through findByTask (read rule). */
|
|
112
|
+
async findByRelated(params) {
|
|
113
|
+
if (params.relationship !== "task" || typeof params.id !== "string")
|
|
114
|
+
throw new common_1.BadRequestException("Comments are listed through their task");
|
|
115
|
+
return this.findByTask({ taskId: params.id, query: params.query, fetchAll: params.fetchAll });
|
|
116
|
+
}
|
|
117
|
+
async updateContent(data) {
|
|
118
|
+
const { comment, task } = await this.requireOwnComment(data.id);
|
|
119
|
+
// The task link is immutable: it may be sent (PUT must send it) only with the comment's own task.
|
|
120
|
+
const sent = data.relationships?.task?.data;
|
|
121
|
+
if (sent !== undefined && (Array.isArray(sent) || sent?.id !== task.id))
|
|
122
|
+
throw new common_1.BadRequestException("A comment cannot move to another task");
|
|
123
|
+
await this.taskCommentRepository.patch({ id: comment.id, content: data.attributes?.content });
|
|
124
|
+
const updated = await this.requireComment(comment.id);
|
|
125
|
+
this.emit(todos_events_1.TodosEvent.CommentUpdated, {
|
|
126
|
+
comment: updated,
|
|
127
|
+
previous: comment,
|
|
128
|
+
taskId: task.id,
|
|
129
|
+
changes: comment.content === updated.content ? [] : ["content"],
|
|
130
|
+
});
|
|
131
|
+
return this.jsonApiService.buildSingle(this.descriptor.model, updated);
|
|
132
|
+
}
|
|
133
|
+
async requireVisibleTask(taskId) {
|
|
134
|
+
const task = taskId ? await this.taskRepository.findTask({ taskId }) : null;
|
|
135
|
+
if (!task)
|
|
136
|
+
throw new common_1.NotFoundException("Task not found");
|
|
137
|
+
return task;
|
|
138
|
+
}
|
|
139
|
+
async requireComment(id) {
|
|
140
|
+
const comment = await this.taskCommentRepository.findComment({ id });
|
|
141
|
+
if (!comment)
|
|
142
|
+
throw new common_1.NotFoundException("Comment not found");
|
|
143
|
+
return comment;
|
|
144
|
+
}
|
|
145
|
+
/** The comment (404), its visible task (404) and the caller as its author (403). */
|
|
146
|
+
async requireOwnComment(id) {
|
|
147
|
+
const comment = await this.requireComment(id);
|
|
148
|
+
const task = await this.requireVisibleTask(comment.task?.id);
|
|
149
|
+
if (!comment.owner?.id || comment.owner.id !== this.clsService.get("userId"))
|
|
150
|
+
throw new common_1.ForbiddenException("Only the author can change this comment");
|
|
151
|
+
return { comment, task };
|
|
152
|
+
}
|
|
153
|
+
emit(event, payload) {
|
|
154
|
+
const full = {
|
|
155
|
+
comment: payload.comment,
|
|
156
|
+
...(payload.previous ? { previous: payload.previous } : {}),
|
|
157
|
+
taskId: payload.taskId,
|
|
158
|
+
actorId: this.clsService.get("userId"),
|
|
159
|
+
companyId: this.clsService.get("companyId"),
|
|
160
|
+
changes: payload.changes,
|
|
161
|
+
};
|
|
162
|
+
this.eventEmitter.emit(event, full);
|
|
163
|
+
}
|
|
164
|
+
async enqueueCommented(params) {
|
|
165
|
+
const job = {
|
|
166
|
+
taskId: params.taskId,
|
|
167
|
+
actorId: this.clsService.get("userId"),
|
|
168
|
+
companyId: this.clsService.get("companyId"),
|
|
169
|
+
commentId: params.commentId,
|
|
170
|
+
};
|
|
171
|
+
// The request's language, so the processor can set it in CLS.
|
|
172
|
+
const language = this.clsService.get("language");
|
|
173
|
+
if (typeof language === "string" && language)
|
|
174
|
+
job.language = language;
|
|
175
|
+
await this.queue.add(todos_queue_1.TodosJobName.TaskCommentedOn, job, { jobId: (0, todos_queue_1.todosJobId)(todos_queue_1.TodosJobName.TaskCommentedOn) });
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
exports.TaskCommentService = TaskCommentService;
|
|
179
|
+
exports.TaskCommentService = TaskCommentService = __decorate([
|
|
180
|
+
(0, common_1.Injectable)(),
|
|
181
|
+
__param(3, (0, bullmq_1.InjectQueue)(todos_queue_1.TODOS_QUEUE)),
|
|
182
|
+
__param(6, (0, common_1.Inject)(todos_config_1.TASK_COMMENT_DESCRIPTOR)),
|
|
183
|
+
__metadata("design:paramtypes", [nestjs_neo4jsonapi_1.JsonApiService,
|
|
184
|
+
taskcomment_repository_1.TaskCommentRepository,
|
|
185
|
+
task_repository_1.TaskRepository,
|
|
186
|
+
bullmq_2.Queue,
|
|
187
|
+
nestjs_cls_1.ClsService,
|
|
188
|
+
event_emitter_1.EventEmitter2, Object])
|
|
189
|
+
], TaskCommentService);
|
|
190
|
+
//# sourceMappingURL=taskcomment.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskcomment.service.js","sourceRoot":"","sources":["../../../../src/api/taskcomment/services/taskcomment.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wEASyC;AACzC,2CAA6C;AAC7C,2CAOwB;AACxB,yDAAsD;AACtD,mCAA+B;AAC/B,2CAAwC;AACxC,+DAA0D;AAC1D,4DAAoE;AAEpE,iEAAuH;AAEvH,6DAAyD;AACzD,6EAAyE;AAEzE,mFAA+E;AAE/E,8EAA8E;AAC9E,MAAM,4BAA4B,GAAG,mDAAmD,CAAC;AAEzF;;;;;GAKG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,oCAA6D;IACnG,YACE,cAA8B,EACb,qBAA4C,EAC5C,cAA8B,EACJ,KAAY,EACpC,UAAsB,EACxB,YAA2B,EAEzB,UAA0E;QAE7F,KAAK,CA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from "@carlonicora/nestjs-neo4jsonapi";
|
|
2
|
+
import { DynamicModule, OnModuleInit } from "@nestjs/common";
|
|
3
|
+
import { ModuleRef } from "@nestjs/core";
|
|
4
|
+
import { TodosModuleConfig } from "./config/todos.config";
|
|
5
|
+
import { Task } from "./task/entities/task";
|
|
6
|
+
import { TaskComment } from "./taskcomment/entities/taskcomment";
|
|
7
|
+
/**
|
|
8
|
+
* Tasks and task comments, configured per app. Descriptors, DTO classes and controller classes
|
|
9
|
+
* are built here, in `forRoot`, never at import time.
|
|
10
|
+
*/
|
|
11
|
+
export declare class TodosModule implements OnModuleInit {
|
|
12
|
+
private readonly taskDescriptor;
|
|
13
|
+
private readonly commentDescriptor;
|
|
14
|
+
private readonly config;
|
|
15
|
+
private readonly moduleRef;
|
|
16
|
+
constructor(taskDescriptor: EntityDescriptor<Task, Record<string, RelationshipDef>>, commentDescriptor: EntityDescriptor<TaskComment, Record<string, RelationshipDef>>, config: TodosModuleConfig, moduleRef: ModuleRef);
|
|
17
|
+
static forRoot(config: TodosModuleConfig): DynamicModule;
|
|
18
|
+
onModuleInit(): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=todos.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todos.module.d.ts","sourceRoot":"","sources":["../../src/api/todos.module.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEzF,OAAO,EAAE,aAAa,EAAkB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAA0D,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAKlH,OAAO,EAAuB,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAIjE,OAAO,EAA8B,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAI7F;;;GAGG;AACH,qBACa,WAAY,YAAW,YAAY;IAEnB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAExD,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM;IAC7C,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAJgB,cAAc,EAAE,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,EAEhG,iBAAiB,EAAE,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,EAC3D,MAAM,EAAE,iBAAiB,EAC/C,SAAS,EAAE,SAAS;IAGvC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa;IAgDxD,YAAY,IAAI,IAAI;CAUrB"}
|
|
@@ -0,0 +1,143 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
var TodosModule_1;
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.TodosModule = void 0;
|
|
50
|
+
const nestjs_neo4jsonapi_1 = require("@carlonicora/nestjs-neo4jsonapi");
|
|
51
|
+
const bullmq_1 = require("@nestjs/bullmq");
|
|
52
|
+
const common_1 = require("@nestjs/common");
|
|
53
|
+
const core_1 = require("@nestjs/core");
|
|
54
|
+
const path = __importStar(require("path"));
|
|
55
|
+
const todos_module_ids_1 = require("../shared/todos.module.ids");
|
|
56
|
+
const todos_config_1 = require("./config/todos.config");
|
|
57
|
+
const todos_notification_processor_1 = require("./notifications/todos.notification.processor");
|
|
58
|
+
const todos_queue_1 = require("./notifications/todos.queue");
|
|
59
|
+
const task_controller_factory_1 = require("./task/controllers/task.controller.factory");
|
|
60
|
+
const task_dtos_1 = require("./task/dtos/task.dtos");
|
|
61
|
+
const task_1 = require("./task/entities/task");
|
|
62
|
+
const task_repository_1 = require("./task/repositories/task.repository");
|
|
63
|
+
const task_service_1 = require("./task/services/task.service");
|
|
64
|
+
const taskcomment_controller_factory_1 = require("./taskcomment/controllers/taskcomment.controller.factory");
|
|
65
|
+
const taskcomment_1 = require("./taskcomment/entities/taskcomment");
|
|
66
|
+
const taskcomment_repository_1 = require("./taskcomment/repositories/taskcomment.repository");
|
|
67
|
+
const taskcomment_service_1 = require("./taskcomment/services/taskcomment.service");
|
|
68
|
+
/**
|
|
69
|
+
* Tasks and task comments, configured per app. Descriptors, DTO classes and controller classes
|
|
70
|
+
* are built here, in `forRoot`, never at import time.
|
|
71
|
+
*/
|
|
72
|
+
let TodosModule = TodosModule_1 = class TodosModule {
|
|
73
|
+
constructor(taskDescriptor, commentDescriptor, config, moduleRef) {
|
|
74
|
+
this.taskDescriptor = taskDescriptor;
|
|
75
|
+
this.commentDescriptor = commentDescriptor;
|
|
76
|
+
this.config = config;
|
|
77
|
+
this.moduleRef = moduleRef;
|
|
78
|
+
}
|
|
79
|
+
static forRoot(config) {
|
|
80
|
+
const taskDescriptor = (0, task_1.buildTaskDescriptor)(config); // validates the configuration
|
|
81
|
+
const commentDescriptor = (0, taskcomment_1.buildTaskCommentDescriptor)(config);
|
|
82
|
+
const dtos = (0, task_dtos_1.buildTaskDtos)(config);
|
|
83
|
+
// `__dirname` is src/api under vitest and dist/api after tsc: `../../` is the package root in both.
|
|
84
|
+
(0, nestjs_neo4jsonapi_1.registerEmailTemplateDirectory)(path.resolve(__dirname, "../../templates/email"));
|
|
85
|
+
(0, nestjs_neo4jsonapi_1.registerI18nDirectory)(path.resolve(__dirname, "../../i18n"));
|
|
86
|
+
return {
|
|
87
|
+
module: TodosModule_1,
|
|
88
|
+
global: true, // any app module can inject TaskService (README: setting a read-only link from app code)
|
|
89
|
+
controllers: [(0, task_controller_factory_1.buildTaskController)(config, dtos), (0, taskcomment_controller_factory_1.buildTaskCommentController)(config)],
|
|
90
|
+
providers: [
|
|
91
|
+
{ provide: todos_config_1.TODOS_CONFIG, useValue: config },
|
|
92
|
+
{ provide: todos_config_1.TASK_DESCRIPTOR, useValue: taskDescriptor },
|
|
93
|
+
{ provide: todos_config_1.TASK_COMMENT_DESCRIPTOR, useValue: commentDescriptor },
|
|
94
|
+
taskDescriptor.model.serialiser,
|
|
95
|
+
commentDescriptor.model.serialiser,
|
|
96
|
+
task_repository_1.TaskRepository,
|
|
97
|
+
taskcomment_repository_1.TaskCommentRepository,
|
|
98
|
+
task_service_1.TaskService,
|
|
99
|
+
taskcomment_service_1.TaskCommentService,
|
|
100
|
+
(0, nestjs_neo4jsonapi_1.createWorkerProvider)(todos_notification_processor_1.TodosNotificationProcessor),
|
|
101
|
+
],
|
|
102
|
+
imports: [
|
|
103
|
+
bullmq_1.BullModule.registerQueue({ name: todos_queue_1.TODOS_QUEUE, ...todos_queue_1.TODOS_QUEUE_OPTIONS }),
|
|
104
|
+
nestjs_neo4jsonapi_1.AuditModule,
|
|
105
|
+
nestjs_neo4jsonapi_1.NotificationModule,
|
|
106
|
+
nestjs_neo4jsonapi_1.PushModule,
|
|
107
|
+
// No library UserModule here: an app that replaces it with an extended user module
|
|
108
|
+
// would mount the library user controller twice. The app passes the module that
|
|
109
|
+
// exports UserService (the library's UserModule or its own) in `config.imports`.
|
|
110
|
+
...(config.catalogue ? [nestjs_neo4jsonapi_1.GraphModule] : []),
|
|
111
|
+
...(config.imports ?? []),
|
|
112
|
+
],
|
|
113
|
+
exports: [
|
|
114
|
+
task_service_1.TaskService,
|
|
115
|
+
taskcomment_service_1.TaskCommentService,
|
|
116
|
+
// The repositories stay private: app code goes through the services, which apply the
|
|
117
|
+
// task read rule and the comment-author check.
|
|
118
|
+
todos_config_1.TODOS_CONFIG,
|
|
119
|
+
todos_config_1.TASK_DESCRIPTOR,
|
|
120
|
+
todos_config_1.TASK_COMMENT_DESCRIPTOR,
|
|
121
|
+
],
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
onModuleInit() {
|
|
125
|
+
nestjs_neo4jsonapi_1.modelRegistry.register(this.taskDescriptor.model);
|
|
126
|
+
nestjs_neo4jsonapi_1.modelRegistry.register(this.commentDescriptor.model);
|
|
127
|
+
if (this.config.catalogue) {
|
|
128
|
+
// Resolved here, never in the constructor (moduleRef.get there returns Nest's placeholder).
|
|
129
|
+
const graph = this.moduleRef.get(nestjs_neo4jsonapi_1.GraphDescriptorRegistry, { strict: false });
|
|
130
|
+
graph.register({ descriptor: this.taskDescriptor, moduleId: todos_module_ids_1.TODOS_MODULE_IDS.Task });
|
|
131
|
+
graph.register({ descriptor: this.commentDescriptor, moduleId: todos_module_ids_1.TODOS_MODULE_IDS.TaskComment });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
exports.TodosModule = TodosModule;
|
|
136
|
+
exports.TodosModule = TodosModule = TodosModule_1 = __decorate([
|
|
137
|
+
(0, common_1.Module)({}),
|
|
138
|
+
__param(0, (0, common_1.Inject)(todos_config_1.TASK_DESCRIPTOR)),
|
|
139
|
+
__param(1, (0, common_1.Inject)(todos_config_1.TASK_COMMENT_DESCRIPTOR)),
|
|
140
|
+
__param(2, (0, common_1.Inject)(todos_config_1.TODOS_CONFIG)),
|
|
141
|
+
__metadata("design:paramtypes", [Object, Object, Object, core_1.ModuleRef])
|
|
142
|
+
], TodosModule);
|
|
143
|
+
//# sourceMappingURL=todos.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tod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AG,CAAC,4CAAuB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;YAC7E,KAAK,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,EAAE,mCAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YACrF,KAAK,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,EAAE,mCAAgB,CAAC,WAAW,EAAE,CAAC,CAAC;QACjG,CAAC;IACH,CAAC;CACF,CAAA;AAnEY,kCAAW;sBAAX,WAAW;IADvB,IAAA,eAAM,EAAC,EAAE,CAAC;IAGN,WAAA,IAAA,eAAM,EAAC,8BAAe,CAAC,CAAA;IACvB,WAAA,IAAA,eAAM,EAAC,sCAAuB,CAAC,CAAA;IAE/B,WAAA,IAAA,eAAM,EAAC,2BAAY,CAAC,CAAA;6DACO,gBAAS;GAN5B,WAAW,CAmEvB"}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/web/config/todos.config.ts
|
|
5
|
+
var KEY = /* @__PURE__ */ Symbol.for("nja-todos.config");
|
|
6
|
+
function configureTodos(config) {
|
|
7
|
+
globalThis[KEY] = config;
|
|
8
|
+
}
|
|
9
|
+
__name(configureTodos, "configureTodos");
|
|
10
|
+
function getTodosConfig() {
|
|
11
|
+
const config = globalThis[KEY];
|
|
12
|
+
if (!config) throw new Error("nja-todos: configureTodos() was not called");
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
15
|
+
__name(getTodosConfig, "getTodosConfig");
|
|
16
|
+
|
|
17
|
+
// src/web/task/data/TaskFields.ts
|
|
18
|
+
var TaskFields = /* @__PURE__ */ ((TaskFields2) => {
|
|
19
|
+
TaskFields2["taskId"] = "taskId";
|
|
20
|
+
TaskFields2["name"] = "name";
|
|
21
|
+
TaskFields2["assignee"] = "assignee";
|
|
22
|
+
TaskFields2["owner"] = "owner";
|
|
23
|
+
TaskFields2["priority"] = "priority";
|
|
24
|
+
TaskFields2["dueDate"] = "dueDate";
|
|
25
|
+
TaskFields2["relationships"] = "relationships";
|
|
26
|
+
TaskFields2["createdAt"] = "createdAt";
|
|
27
|
+
TaskFields2["updatedAt"] = "updatedAt";
|
|
28
|
+
return TaskFields2;
|
|
29
|
+
})(TaskFields || {});
|
|
30
|
+
|
|
31
|
+
// src/shared/todos.endpoints.ts
|
|
32
|
+
var TASK_ENDPOINT = "tasks";
|
|
33
|
+
var TASK_COMMENT_ENDPOINT = "taskcomments";
|
|
34
|
+
var TASK_RELATIONSHIPS_PATH = "relationships";
|
|
35
|
+
var TASK_TOGGLE_COMPLETE_PATH = "toggle-complete";
|
|
36
|
+
var TASK_ASSIGNEE_PATH = "assignee";
|
|
37
|
+
|
|
38
|
+
// src/web/task/data/TaskService.ts
|
|
39
|
+
import {
|
|
40
|
+
AbstractService,
|
|
41
|
+
EndpointCreator,
|
|
42
|
+
HttpMethod,
|
|
43
|
+
Modules as Modules2
|
|
44
|
+
} from "@carlonicora/nextjs-jsonapi/core";
|
|
45
|
+
|
|
46
|
+
// src/web/todos.modules.ts
|
|
47
|
+
import { Modules } from "@carlonicora/nextjs-jsonapi/core";
|
|
48
|
+
var TodosModules = Modules;
|
|
49
|
+
|
|
50
|
+
// src/web/task/data/TaskService.ts
|
|
51
|
+
var TaskService = class extends AbstractService {
|
|
52
|
+
static {
|
|
53
|
+
__name(this, "TaskService");
|
|
54
|
+
}
|
|
55
|
+
static addListParams(endpoint, params) {
|
|
56
|
+
if (params.filterPriority) endpoint.addAdditionalParam("filterPriority", params.filterPriority);
|
|
57
|
+
if (params.completedFilter) endpoint.addAdditionalParam("completedFilter", params.completedFilter);
|
|
58
|
+
if (params.search) endpoint.addAdditionalParam("search", params.search);
|
|
59
|
+
if (params.fetchAll) endpoint.addAdditionalParam("fetchAll", "true");
|
|
60
|
+
if (params.pageSize) endpoint.addAdditionalParam("page[size]", String(params.pageSize));
|
|
61
|
+
if (params.sort) endpoint.addAdditionalParam("sort", params.sort);
|
|
62
|
+
return endpoint;
|
|
63
|
+
}
|
|
64
|
+
static async findOne(params) {
|
|
65
|
+
return this.callApi({
|
|
66
|
+
type: TodosModules.Task,
|
|
67
|
+
method: HttpMethod.GET,
|
|
68
|
+
endpoint: new EndpointCreator({ endpoint: TodosModules.Task, id: params.id }).generate(),
|
|
69
|
+
suppressGlobalError: true
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
static async findMany(params) {
|
|
73
|
+
const endpoint = this.addListParams(new EndpointCreator({ endpoint: TodosModules.Task }), params);
|
|
74
|
+
return this.callApi({
|
|
75
|
+
type: TodosModules.Task,
|
|
76
|
+
method: HttpMethod.GET,
|
|
77
|
+
endpoint: endpoint.generate(),
|
|
78
|
+
next: params.next,
|
|
79
|
+
previous: params.prev,
|
|
80
|
+
suppressGlobalError: true
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
static async findManyByRelated(params) {
|
|
84
|
+
const relationship = getTodosConfig().relationships.find((r) => r.key === params.key);
|
|
85
|
+
if (!relationship) throw new Error(`nja-todos: no relationship "${params.key}" is configured`);
|
|
86
|
+
const endpoint = this.addListParams(
|
|
87
|
+
new EndpointCreator({ endpoint: relationship.module(), id: params.id, childEndpoint: TodosModules.Task }),
|
|
88
|
+
params
|
|
89
|
+
);
|
|
90
|
+
return this.callApi({
|
|
91
|
+
type: TodosModules.Task,
|
|
92
|
+
method: HttpMethod.GET,
|
|
93
|
+
endpoint: endpoint.generate(),
|
|
94
|
+
next: params.next,
|
|
95
|
+
previous: params.prev,
|
|
96
|
+
suppressGlobalError: true
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
static async findManyByUser(params) {
|
|
100
|
+
const endpoint = new EndpointCreator({
|
|
101
|
+
endpoint: Modules2.User,
|
|
102
|
+
id: params.userId,
|
|
103
|
+
childEndpoint: TodosModules.Task
|
|
104
|
+
});
|
|
105
|
+
if (params.creator) endpoint.addAdditionalParam("creator", "true");
|
|
106
|
+
this.addListParams(endpoint, params);
|
|
107
|
+
return this.callApi({
|
|
108
|
+
type: TodosModules.Task,
|
|
109
|
+
method: HttpMethod.GET,
|
|
110
|
+
endpoint: endpoint.generate(),
|
|
111
|
+
next: params.next,
|
|
112
|
+
previous: params.prev,
|
|
113
|
+
suppressGlobalError: true
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
static async create(params) {
|
|
117
|
+
return this.callApi({
|
|
118
|
+
type: TodosModules.Task,
|
|
119
|
+
method: HttpMethod.POST,
|
|
120
|
+
endpoint: new EndpointCreator({ endpoint: TodosModules.Task }).generate(),
|
|
121
|
+
input: params,
|
|
122
|
+
suppressGlobalError: true
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
static async update(params) {
|
|
126
|
+
return this.callApi({
|
|
127
|
+
type: TodosModules.Task,
|
|
128
|
+
method: HttpMethod.PUT,
|
|
129
|
+
endpoint: new EndpointCreator({ endpoint: TodosModules.Task, id: params.id }).generate(),
|
|
130
|
+
input: params,
|
|
131
|
+
suppressGlobalError: true
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
static async patch(params) {
|
|
135
|
+
return this.callApi({
|
|
136
|
+
type: TodosModules.Task,
|
|
137
|
+
method: HttpMethod.PATCH,
|
|
138
|
+
endpoint: new EndpointCreator({ endpoint: TodosModules.Task, id: params.id }).generate(),
|
|
139
|
+
input: params,
|
|
140
|
+
suppressGlobalError: true
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
static async patchRelationships(params) {
|
|
144
|
+
const input = { id: params.id, related: params.related };
|
|
145
|
+
return this.callApi({
|
|
146
|
+
type: TodosModules.Task,
|
|
147
|
+
method: HttpMethod.PATCH,
|
|
148
|
+
endpoint: new EndpointCreator({
|
|
149
|
+
endpoint: TodosModules.Task,
|
|
150
|
+
id: params.id,
|
|
151
|
+
childEndpoint: TASK_RELATIONSHIPS_PATH
|
|
152
|
+
}).generate(),
|
|
153
|
+
input,
|
|
154
|
+
suppressGlobalError: true
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
static async toggleComplete(params) {
|
|
158
|
+
const input = { id: params.taskId, completed: params.completed };
|
|
159
|
+
return this.callApi({
|
|
160
|
+
type: TodosModules.Task,
|
|
161
|
+
method: HttpMethod.PATCH,
|
|
162
|
+
endpoint: new EndpointCreator({
|
|
163
|
+
endpoint: TodosModules.Task,
|
|
164
|
+
id: params.taskId,
|
|
165
|
+
childEndpoint: TASK_TOGGLE_COMPLETE_PATH
|
|
166
|
+
}).generate(),
|
|
167
|
+
input,
|
|
168
|
+
suppressGlobalError: true
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
static async changeAssignee(params) {
|
|
172
|
+
return this.callApi({
|
|
173
|
+
type: TodosModules.Task,
|
|
174
|
+
method: HttpMethod.PATCH,
|
|
175
|
+
endpoint: new EndpointCreator({
|
|
176
|
+
endpoint: TodosModules.Task,
|
|
177
|
+
id: params.taskId,
|
|
178
|
+
childEndpoint: TASK_ASSIGNEE_PATH,
|
|
179
|
+
childId: params.assigneeId
|
|
180
|
+
}).generate(),
|
|
181
|
+
suppressGlobalError: true
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
static async clearAssignee(params) {
|
|
185
|
+
await this.callApi({
|
|
186
|
+
type: TodosModules.Task,
|
|
187
|
+
method: HttpMethod.DELETE,
|
|
188
|
+
endpoint: new EndpointCreator({
|
|
189
|
+
endpoint: TodosModules.Task,
|
|
190
|
+
id: params.taskId,
|
|
191
|
+
childEndpoint: TASK_ASSIGNEE_PATH
|
|
192
|
+
}).generate(),
|
|
193
|
+
suppressGlobalError: true
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
static async delete(params) {
|
|
197
|
+
await this.callApi({
|
|
198
|
+
type: TodosModules.Task,
|
|
199
|
+
method: HttpMethod.DELETE,
|
|
200
|
+
endpoint: new EndpointCreator({ endpoint: TodosModules.Task, id: params.id }).generate(),
|
|
201
|
+
suppressGlobalError: true
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// src/web/taskcomment/data/TaskCommentService.ts
|
|
207
|
+
import {
|
|
208
|
+
AbstractService as AbstractService2,
|
|
209
|
+
EndpointCreator as EndpointCreator2,
|
|
210
|
+
HttpMethod as HttpMethod2
|
|
211
|
+
} from "@carlonicora/nextjs-jsonapi/core";
|
|
212
|
+
var TaskCommentService = class extends AbstractService2 {
|
|
213
|
+
static {
|
|
214
|
+
__name(this, "TaskCommentService");
|
|
215
|
+
}
|
|
216
|
+
static async findMany(params) {
|
|
217
|
+
const endpoint = new EndpointCreator2({
|
|
218
|
+
endpoint: TodosModules.Task,
|
|
219
|
+
id: params.taskId,
|
|
220
|
+
childEndpoint: TodosModules.TaskComment
|
|
221
|
+
});
|
|
222
|
+
if (params.fetchAll) endpoint.addAdditionalParam("fetchAll", "true");
|
|
223
|
+
return this.callApi({
|
|
224
|
+
type: TodosModules.TaskComment,
|
|
225
|
+
method: HttpMethod2.GET,
|
|
226
|
+
endpoint: endpoint.generate(),
|
|
227
|
+
next: params.next,
|
|
228
|
+
previous: params.prev,
|
|
229
|
+
suppressGlobalError: true
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
static async create(params) {
|
|
233
|
+
return this.callApi({
|
|
234
|
+
type: TodosModules.TaskComment,
|
|
235
|
+
method: HttpMethod2.POST,
|
|
236
|
+
endpoint: new EndpointCreator2({ endpoint: TodosModules.TaskComment }).generate(),
|
|
237
|
+
input: params,
|
|
238
|
+
suppressGlobalError: true
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
static async update(params) {
|
|
242
|
+
return this.callApi({
|
|
243
|
+
type: TodosModules.TaskComment,
|
|
244
|
+
method: HttpMethod2.PUT,
|
|
245
|
+
endpoint: new EndpointCreator2({ endpoint: TodosModules.TaskComment, id: params.id }).generate(),
|
|
246
|
+
input: params,
|
|
247
|
+
suppressGlobalError: true
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
static async delete(params) {
|
|
251
|
+
await this.callApi({
|
|
252
|
+
type: TodosModules.TaskComment,
|
|
253
|
+
method: HttpMethod2.DELETE,
|
|
254
|
+
endpoint: new EndpointCreator2({ endpoint: TodosModules.TaskComment, id: params.id }).generate(),
|
|
255
|
+
suppressGlobalError: true
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// src/shared/task.priority.ts
|
|
261
|
+
var TaskPriority = /* @__PURE__ */ ((TaskPriority2) => {
|
|
262
|
+
TaskPriority2["High"] = "high";
|
|
263
|
+
TaskPriority2["Medium"] = "medium";
|
|
264
|
+
TaskPriority2["Low"] = "low";
|
|
265
|
+
return TaskPriority2;
|
|
266
|
+
})(TaskPriority || {});
|
|
267
|
+
|
|
268
|
+
export {
|
|
269
|
+
__name,
|
|
270
|
+
configureTodos,
|
|
271
|
+
getTodosConfig,
|
|
272
|
+
TodosModules,
|
|
273
|
+
TaskFields,
|
|
274
|
+
TASK_ENDPOINT,
|
|
275
|
+
TASK_COMMENT_ENDPOINT,
|
|
276
|
+
TASK_RELATIONSHIPS_PATH,
|
|
277
|
+
TASK_TOGGLE_COMPLETE_PATH,
|
|
278
|
+
TASK_ASSIGNEE_PATH,
|
|
279
|
+
TaskService,
|
|
280
|
+
TaskCommentService,
|
|
281
|
+
TaskPriority
|
|
282
|
+
};
|
|
283
|
+
//# sourceMappingURL=chunk-CO56HIPE.mjs.map
|