@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.
Files changed (215) hide show
  1. package/LICENSE +675 -0
  2. package/README.md +791 -2
  3. package/dist/api/common/decorate.d.ts +21 -0
  4. package/dist/api/common/decorate.d.ts.map +1 -0
  5. package/dist/api/common/decorate.js +39 -0
  6. package/dist/api/common/decorate.js.map +1 -0
  7. package/dist/api/config/todos.config.d.ts +51 -0
  8. package/dist/api/config/todos.config.d.ts.map +1 -0
  9. package/dist/api/config/todos.config.js +7 -0
  10. package/dist/api/config/todos.config.js.map +1 -0
  11. package/dist/api/events/todos.event.payloads.d.ts +21 -0
  12. package/dist/api/events/todos.event.payloads.d.ts.map +1 -0
  13. package/dist/api/events/todos.event.payloads.js +3 -0
  14. package/dist/api/events/todos.event.payloads.js.map +1 -0
  15. package/dist/api/index.d.ts +22 -0
  16. package/dist/api/index.d.ts.map +1 -0
  17. package/dist/api/index.js +49 -0
  18. package/dist/api/index.js.map +1 -0
  19. package/dist/api/notifications/todos.notification.processor.d.ts +48 -0
  20. package/dist/api/notifications/todos.notification.processor.d.ts.map +1 -0
  21. package/dist/api/notifications/todos.notification.processor.js +251 -0
  22. package/dist/api/notifications/todos.notification.processor.js.map +1 -0
  23. package/dist/api/notifications/todos.queue.d.ts +41 -0
  24. package/dist/api/notifications/todos.queue.d.ts.map +1 -0
  25. package/dist/api/notifications/todos.queue.js +35 -0
  26. package/dist/api/notifications/todos.queue.js.map +1 -0
  27. package/dist/api/task/controllers/task.controller.factory.d.ts +38 -0
  28. package/dist/api/task/controllers/task.controller.factory.d.ts.map +1 -0
  29. package/dist/api/task/controllers/task.controller.factory.js +314 -0
  30. package/dist/api/task/controllers/task.controller.factory.js.map +1 -0
  31. package/dist/api/task/dtos/task.dtos.d.ts +15 -0
  32. package/dist/api/task/dtos/task.dtos.d.ts.map +1 -0
  33. package/dist/api/task/dtos/task.dtos.js +260 -0
  34. package/dist/api/task/dtos/task.dtos.js.map +1 -0
  35. package/dist/api/task/entities/task.d.ts +21 -0
  36. package/dist/api/task/entities/task.d.ts.map +1 -0
  37. package/dist/api/task/entities/task.js +95 -0
  38. package/dist/api/task/entities/task.js.map +1 -0
  39. package/dist/api/task/entities/task.meta.d.ts +3 -0
  40. package/dist/api/task/entities/task.meta.d.ts.map +1 -0
  41. package/dist/api/task/entities/task.meta.js +11 -0
  42. package/dist/api/task/entities/task.meta.js.map +1 -0
  43. package/dist/api/task/repositories/task.repository.d.ts +104 -0
  44. package/dist/api/task/repositories/task.repository.d.ts.map +1 -0
  45. package/dist/api/task/repositories/task.repository.js +328 -0
  46. package/dist/api/task/repositories/task.repository.js.map +1 -0
  47. package/dist/api/task/services/task.service.d.ts +149 -0
  48. package/dist/api/task/services/task.service.d.ts.map +1 -0
  49. package/dist/api/task/services/task.service.js +378 -0
  50. package/dist/api/task/services/task.service.js.map +1 -0
  51. package/dist/api/taskcomment/controllers/taskcomment.controller.factory.d.ts +44 -0
  52. package/dist/api/taskcomment/controllers/taskcomment.controller.factory.d.ts.map +1 -0
  53. package/dist/api/taskcomment/controllers/taskcomment.controller.factory.js +136 -0
  54. package/dist/api/taskcomment/controllers/taskcomment.controller.factory.js.map +1 -0
  55. package/dist/api/taskcomment/dtos/taskcomment.post.dto.d.ts +23 -0
  56. package/dist/api/taskcomment/dtos/taskcomment.post.dto.d.ts.map +1 -0
  57. package/dist/api/taskcomment/dtos/taskcomment.post.dto.js +87 -0
  58. package/dist/api/taskcomment/dtos/taskcomment.post.dto.js.map +1 -0
  59. package/dist/api/taskcomment/dtos/taskcomment.put.dto.d.ts +21 -0
  60. package/dist/api/taskcomment/dtos/taskcomment.put.dto.d.ts.map +1 -0
  61. package/dist/api/taskcomment/dtos/taskcomment.put.dto.js +71 -0
  62. package/dist/api/taskcomment/dtos/taskcomment.put.dto.js.map +1 -0
  63. package/dist/api/taskcomment/entities/taskcomment.d.ts +11 -0
  64. package/dist/api/taskcomment/entities/taskcomment.d.ts.map +1 -0
  65. package/dist/api/taskcomment/entities/taskcomment.js +44 -0
  66. package/dist/api/taskcomment/entities/taskcomment.js.map +1 -0
  67. package/dist/api/taskcomment/entities/taskcomment.meta.d.ts +5 -0
  68. package/dist/api/taskcomment/entities/taskcomment.meta.d.ts.map +1 -0
  69. package/dist/api/taskcomment/entities/taskcomment.meta.js +13 -0
  70. package/dist/api/taskcomment/entities/taskcomment.meta.js.map +1 -0
  71. package/dist/api/taskcomment/repositories/taskcomment.repository.d.ts +25 -0
  72. package/dist/api/taskcomment/repositories/taskcomment.repository.d.ts.map +1 -0
  73. package/dist/api/taskcomment/repositories/taskcomment.repository.js +73 -0
  74. package/dist/api/taskcomment/repositories/taskcomment.repository.js.map +1 -0
  75. package/dist/api/taskcomment/services/taskcomment.service.d.ts +78 -0
  76. package/dist/api/taskcomment/services/taskcomment.service.d.ts.map +1 -0
  77. package/dist/api/taskcomment/services/taskcomment.service.js +190 -0
  78. package/dist/api/taskcomment/services/taskcomment.service.js.map +1 -0
  79. package/dist/api/todos.module.d.ts +20 -0
  80. package/dist/api/todos.module.d.ts.map +1 -0
  81. package/dist/api/todos.module.js +143 -0
  82. package/dist/api/todos.module.js.map +1 -0
  83. package/dist/chunk-CO56HIPE.mjs +283 -0
  84. package/dist/chunk-CO56HIPE.mjs.map +1 -0
  85. package/dist/chunk-K6KLDGC2.js +283 -0
  86. package/dist/chunk-K6KLDGC2.js.map +1 -0
  87. package/dist/seed/index.d.ts +4 -0
  88. package/dist/seed/index.d.ts.map +1 -0
  89. package/dist/seed/index.js +9 -0
  90. package/dist/seed/index.js.map +1 -0
  91. package/dist/seed/todos.module.seed.d.ts +12 -0
  92. package/dist/seed/todos.module.seed.d.ts.map +1 -0
  93. package/dist/seed/todos.module.seed.js +54 -0
  94. package/dist/seed/todos.module.seed.js.map +1 -0
  95. package/dist/shared/index.d.ts +7 -0
  96. package/dist/shared/index.d.ts.map +1 -0
  97. package/dist/shared/index.js +23 -0
  98. package/dist/shared/index.js.map +1 -0
  99. package/dist/shared/task.completed.filter.d.ts +2 -0
  100. package/dist/shared/task.completed.filter.d.ts.map +1 -0
  101. package/dist/shared/task.completed.filter.js +3 -0
  102. package/dist/shared/task.completed.filter.js.map +1 -0
  103. package/dist/shared/task.priority.d.ts +6 -0
  104. package/dist/shared/task.priority.d.ts.map +1 -0
  105. package/dist/shared/task.priority.js +10 -0
  106. package/dist/shared/task.priority.js.map +1 -0
  107. package/dist/shared/todos.endpoints.d.ts +7 -0
  108. package/dist/shared/todos.endpoints.d.ts.map +1 -0
  109. package/dist/shared/todos.endpoints.js +10 -0
  110. package/dist/shared/todos.endpoints.js.map +1 -0
  111. package/dist/shared/todos.events.d.ts +13 -0
  112. package/dist/shared/todos.events.d.ts.map +1 -0
  113. package/dist/shared/todos.events.js +16 -0
  114. package/dist/shared/todos.events.js.map +1 -0
  115. package/dist/shared/todos.module.ids.d.ts +5 -0
  116. package/dist/shared/todos.module.ids.d.ts.map +1 -0
  117. package/dist/shared/todos.module.ids.js +8 -0
  118. package/dist/shared/todos.module.ids.js.map +1 -0
  119. package/dist/shared/todos.notification.types.d.ts +6 -0
  120. package/dist/shared/todos.notification.types.d.ts.map +1 -0
  121. package/dist/shared/todos.notification.types.js +9 -0
  122. package/dist/shared/todos.notification.types.js.map +1 -0
  123. package/dist/web/config/todos.config.d.ts +25 -0
  124. package/dist/web/config/todos.config.d.ts.map +1 -0
  125. package/dist/web/config/todos.ui.config.d.ts +28 -0
  126. package/dist/web/config/todos.ui.config.d.ts.map +1 -0
  127. package/dist/web/core.d.ts +18 -0
  128. package/dist/web/core.d.ts.map +1 -0
  129. package/dist/web/core.js +208 -0
  130. package/dist/web/core.js.map +1 -0
  131. package/dist/web/core.mjs +208 -0
  132. package/dist/web/core.mjs.map +1 -0
  133. package/dist/web/index.d.ts +22 -0
  134. package/dist/web/index.d.ts.map +1 -0
  135. package/dist/web/index.js +1959 -0
  136. package/dist/web/index.js.map +1 -0
  137. package/dist/web/index.mjs +1958 -0
  138. package/dist/web/index.mjs.map +1 -0
  139. package/dist/web/task/TaskModule.d.ts +6 -0
  140. package/dist/web/task/TaskModule.d.ts.map +1 -0
  141. package/dist/web/task/components/EisenhowerIcon.d.ts +9 -0
  142. package/dist/web/task/components/EisenhowerIcon.d.ts.map +1 -0
  143. package/dist/web/task/components/EisenhowerMatrixBoard.d.ts +21 -0
  144. package/dist/web/task/components/EisenhowerMatrixBoard.d.ts.map +1 -0
  145. package/dist/web/task/components/TaskMatrixCard.d.ts +11 -0
  146. package/dist/web/task/components/TaskMatrixCard.d.ts.map +1 -0
  147. package/dist/web/task/components/containers/TaskListContainer.d.ts +12 -0
  148. package/dist/web/task/components/containers/TaskListContainer.d.ts.map +1 -0
  149. package/dist/web/task/components/editors/TaskEditor.d.ts +12 -0
  150. package/dist/web/task/components/editors/TaskEditor.d.ts.map +1 -0
  151. package/dist/web/task/components/filters/TaskListFilters.d.ts +9 -0
  152. package/dist/web/task/components/filters/TaskListFilters.d.ts.map +1 -0
  153. package/dist/web/task/components/filters/TaskViewSwitcher.d.ts +9 -0
  154. package/dist/web/task/components/filters/TaskViewSwitcher.d.ts.map +1 -0
  155. package/dist/web/task/components/forms/TaskCreateButton.d.ts +5 -0
  156. package/dist/web/task/components/forms/TaskCreateButton.d.ts.map +1 -0
  157. package/dist/web/task/components/forms/TaskDeleter.d.ts +8 -0
  158. package/dist/web/task/components/forms/TaskDeleter.d.ts.map +1 -0
  159. package/dist/web/task/components/lists/TasksList.d.ts +20 -0
  160. package/dist/web/task/components/lists/TasksList.d.ts.map +1 -0
  161. package/dist/web/task/components/screens/UserTasksScreen.d.ts +5 -0
  162. package/dist/web/task/components/screens/UserTasksScreen.d.ts.map +1 -0
  163. package/dist/web/task/contexts/TaskContext.d.ts +29 -0
  164. package/dist/web/task/contexts/TaskContext.d.ts.map +1 -0
  165. package/dist/web/task/data/Task.d.ts +25 -0
  166. package/dist/web/task/data/Task.d.ts.map +1 -0
  167. package/dist/web/task/data/TaskFields.d.ts +12 -0
  168. package/dist/web/task/data/TaskFields.d.ts.map +1 -0
  169. package/dist/web/task/data/TaskInterface.d.ts +29 -0
  170. package/dist/web/task/data/TaskInterface.d.ts.map +1 -0
  171. package/dist/web/task/data/TaskService.d.ts +51 -0
  172. package/dist/web/task/data/TaskService.d.ts.map +1 -0
  173. package/dist/web/task/hooks/useTaskDeepLink.d.ts +12 -0
  174. package/dist/web/task/hooks/useTaskDeepLink.d.ts.map +1 -0
  175. package/dist/web/task/hooks/useTaskOverdueParam.d.ts +19 -0
  176. package/dist/web/task/hooks/useTaskOverdueParam.d.ts.map +1 -0
  177. package/dist/web/task/hooks/useTaskTableStructure.d.ts +8 -0
  178. package/dist/web/task/hooks/useTaskTableStructure.d.ts.map +1 -0
  179. package/dist/web/task/lib/task.priority.options.d.ts +5 -0
  180. package/dist/web/task/lib/task.priority.options.d.ts.map +1 -0
  181. package/dist/web/task/utils/dueDate.d.ts +11 -0
  182. package/dist/web/task/utils/dueDate.d.ts.map +1 -0
  183. package/dist/web/task/utils/getEisenhowerQuadrant.d.ts +4 -0
  184. package/dist/web/task/utils/getEisenhowerQuadrant.d.ts.map +1 -0
  185. package/dist/web/task/utils/isTaskOverdue.d.ts +12 -0
  186. package/dist/web/task/utils/isTaskOverdue.d.ts.map +1 -0
  187. package/dist/web/taskcomment/TaskCommentModule.d.ts +5 -0
  188. package/dist/web/taskcomment/TaskCommentModule.d.ts.map +1 -0
  189. package/dist/web/taskcomment/components/forms/TaskCommentEditor.d.ts +2 -0
  190. package/dist/web/taskcomment/components/forms/TaskCommentEditor.d.ts.map +1 -0
  191. package/dist/web/taskcomment/components/lists/TaskCommentList.d.ts +2 -0
  192. package/dist/web/taskcomment/components/lists/TaskCommentList.d.ts.map +1 -0
  193. package/dist/web/taskcomment/contexts/TaskCommentContext.d.ts +22 -0
  194. package/dist/web/taskcomment/contexts/TaskCommentContext.d.ts.map +1 -0
  195. package/dist/web/taskcomment/data/TaskComment.d.ts +11 -0
  196. package/dist/web/taskcomment/data/TaskComment.d.ts.map +1 -0
  197. package/dist/web/taskcomment/data/TaskCommentInterface.d.ts +12 -0
  198. package/dist/web/taskcomment/data/TaskCommentInterface.d.ts.map +1 -0
  199. package/dist/web/taskcomment/data/TaskCommentService.d.ts +16 -0
  200. package/dist/web/taskcomment/data/TaskCommentService.d.ts.map +1 -0
  201. package/dist/web/todos.modules.d.ts +10 -0
  202. package/dist/web/todos.modules.d.ts.map +1 -0
  203. package/dist/web/utils/isNotFoundError.d.ts +11 -0
  204. package/dist/web/utils/isNotFoundError.d.ts.map +1 -0
  205. package/i18n/en/todos.json +13 -0
  206. package/i18n/it/todos.json +13 -0
  207. package/messages/en.json +132 -0
  208. package/messages/it.json +132 -0
  209. package/package.json +214 -5
  210. package/templates/email/en/taskAssigned.hbs +31 -0
  211. package/templates/email/en/taskCommented.hbs +31 -0
  212. package/templates/email/en/taskCompleted.hbs +31 -0
  213. package/templates/email/it/taskAssigned.hbs +31 -0
  214. package/templates/email/it/taskCommented.hbs +31 -0
  215. package/templates/email/it/taskCompleted.hbs +31 -0
@@ -0,0 +1,260 @@
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.buildTaskDtos = buildTaskDtos;
13
+ const nestjs_neo4jsonapi_1 = require("@carlonicora/nestjs-neo4jsonapi");
14
+ const class_transformer_1 = require("class-transformer");
15
+ const class_validator_1 = require("class-validator");
16
+ const task_priority_1 = require("../../../shared/task.priority");
17
+ const task_meta_1 = require("../entities/task.meta");
18
+ /** Applies property decorators in code: the property names come from the app's configuration. */
19
+ function decorate(cls, property, decorators) {
20
+ for (const decorator of decorators)
21
+ decorator(cls.prototype, property);
22
+ }
23
+ function named(cls, name) {
24
+ Object.defineProperty(cls, "name", { value: name });
25
+ return cls;
26
+ }
27
+ /** Reference DTO of one linked entity (`{ type, id }`), as references/backend/02-dtos.md § "Reference DTO". */
28
+ function buildRefDto(endpoint) {
29
+ class RefDTO {
30
+ }
31
+ __decorate([
32
+ (0, class_validator_1.Equals)(endpoint),
33
+ __metadata("design:type", String)
34
+ ], RefDTO.prototype, "type", void 0);
35
+ __decorate([
36
+ (0, class_validator_1.IsUUID)(),
37
+ __metadata("design:type", String)
38
+ ], RefDTO.prototype, "id", void 0);
39
+ return RefDTO;
40
+ }
41
+ function buildOneDto(Ref) {
42
+ class OneDataDTO {
43
+ }
44
+ __decorate([
45
+ (0, class_validator_1.ValidateNested)(),
46
+ (0, class_validator_1.IsNotEmpty)(),
47
+ (0, class_transformer_1.Type)(() => Ref),
48
+ __metadata("design:type", Object)
49
+ ], OneDataDTO.prototype, "data", void 0);
50
+ return OneDataDTO;
51
+ }
52
+ function buildManyDto(Ref, nonEmpty) {
53
+ class ManyDataDTO {
54
+ }
55
+ __decorate([
56
+ (0, class_validator_1.IsArray)(),
57
+ (0, class_validator_1.ValidateNested)({ each: true }),
58
+ (0, class_transformer_1.Type)(() => Ref),
59
+ __metadata("design:type", Array)
60
+ ], ManyDataDTO.prototype, "data", void 0);
61
+ if (nonEmpty)
62
+ decorate(ManyDataDTO, "data", [(0, class_validator_1.ArrayNotEmpty)()]);
63
+ return ManyDataDTO;
64
+ }
65
+ function buildLinkWrapper(entry) {
66
+ const Ref = buildRefDto(entry.model.endpoint);
67
+ return entry.cardinality === "many" ? buildManyDto(Ref, !!entry.required) : buildOneDto(Ref);
68
+ }
69
+ class TaskPostAttributesDTO {
70
+ }
71
+ __decorate([
72
+ (0, class_validator_1.IsDefined)(),
73
+ (0, class_validator_1.IsString)(),
74
+ (0, class_validator_1.IsNotEmpty)(),
75
+ __metadata("design:type", String)
76
+ ], TaskPostAttributesDTO.prototype, "name", void 0);
77
+ __decorate([
78
+ (0, class_validator_1.IsOptional)(),
79
+ (0, class_validator_1.IsString)(),
80
+ __metadata("design:type", String)
81
+ ], TaskPostAttributesDTO.prototype, "content", void 0);
82
+ __decorate([
83
+ (0, class_validator_1.IsOptional)(),
84
+ (0, class_validator_1.IsEnum)(task_priority_1.TaskPriority),
85
+ __metadata("design:type", String)
86
+ ], TaskPostAttributesDTO.prototype, "priority", void 0);
87
+ __decorate([
88
+ (0, class_validator_1.IsOptional)(),
89
+ (0, class_validator_1.IsDateString)(),
90
+ __metadata("design:type", String)
91
+ ], TaskPostAttributesDTO.prototype, "dueDate", void 0);
92
+ __decorate([
93
+ (0, class_validator_1.IsOptional)(),
94
+ (0, class_validator_1.IsBoolean)(),
95
+ __metadata("design:type", Boolean)
96
+ ], TaskPostAttributesDTO.prototype, "completed", void 0);
97
+ class TaskPutAttributesDTO {
98
+ }
99
+ __decorate([
100
+ (0, class_validator_1.IsDefined)(),
101
+ (0, class_validator_1.IsString)(),
102
+ (0, class_validator_1.IsNotEmpty)(),
103
+ __metadata("design:type", String)
104
+ ], TaskPutAttributesDTO.prototype, "name", void 0);
105
+ __decorate([
106
+ (0, class_validator_1.IsOptional)(),
107
+ (0, class_validator_1.IsString)(),
108
+ __metadata("design:type", String)
109
+ ], TaskPutAttributesDTO.prototype, "content", void 0);
110
+ __decorate([
111
+ (0, class_validator_1.IsOptional)(),
112
+ (0, class_validator_1.IsEnum)(task_priority_1.TaskPriority),
113
+ __metadata("design:type", String)
114
+ ], TaskPutAttributesDTO.prototype, "priority", void 0);
115
+ __decorate([
116
+ (0, class_validator_1.IsOptional)(),
117
+ (0, class_validator_1.IsDateString)(),
118
+ __metadata("design:type", String)
119
+ ], TaskPutAttributesDTO.prototype, "dueDate", void 0);
120
+ __decorate([
121
+ (0, class_validator_1.IsOptional)(),
122
+ (0, class_validator_1.IsBoolean)(),
123
+ __metadata("design:type", Boolean)
124
+ ], TaskPutAttributesDTO.prototype, "completed", void 0);
125
+ class TaskPatchAttributesDTO {
126
+ }
127
+ __decorate([
128
+ (0, class_validator_1.IsOptional)(),
129
+ (0, class_validator_1.IsString)(),
130
+ (0, class_validator_1.IsNotEmpty)(),
131
+ __metadata("design:type", String)
132
+ ], TaskPatchAttributesDTO.prototype, "name", void 0);
133
+ __decorate([
134
+ (0, class_validator_1.IsOptional)(),
135
+ (0, class_validator_1.IsString)(),
136
+ __metadata("design:type", String)
137
+ ], TaskPatchAttributesDTO.prototype, "content", void 0);
138
+ __decorate([
139
+ (0, class_validator_1.IsOptional)(),
140
+ (0, class_validator_1.IsEnum)(task_priority_1.TaskPriority),
141
+ __metadata("design:type", String)
142
+ ], TaskPatchAttributesDTO.prototype, "priority", void 0);
143
+ __decorate([
144
+ (0, class_validator_1.IsOptional)(),
145
+ (0, class_validator_1.IsDateString)(),
146
+ __metadata("design:type", String)
147
+ ], TaskPatchAttributesDTO.prototype, "dueDate", void 0);
148
+ __decorate([
149
+ (0, class_validator_1.IsOptional)(),
150
+ (0, class_validator_1.IsBoolean)(),
151
+ __metadata("design:type", Boolean)
152
+ ], TaskPatchAttributesDTO.prototype, "completed", void 0);
153
+ /** PATCH attributes that may be left out but never cleared: `@IsOptional()` lets null through. */
154
+ const PATCH_NOT_NULL = ["name", "completed"];
155
+ /**
156
+ * Refuses `null` for the PATCH attributes that cannot be cleared (an emptied name is never
157
+ * saved). Sits on the data's `attributes` property, because `@IsOptional()` skips every validator
158
+ * of a null property.
159
+ */
160
+ function NoNullPatchAttributes() {
161
+ return (0, class_validator_1.ValidateBy)({
162
+ name: "noNullPatchAttributes",
163
+ validator: {
164
+ validate: (value) => !value ||
165
+ typeof value !== "object" ||
166
+ PATCH_NOT_NULL.every((field) => value[field] !== null),
167
+ defaultMessage: () => `${PATCH_NOT_NULL.join(" and ")} cannot be null`,
168
+ },
169
+ });
170
+ }
171
+ /**
172
+ * Builds the four task DTO classes from the app's relationship configuration. Called inside
173
+ * TodosModule.forRoot ("Decisions on record → Dynamic classes"); the configured relationship
174
+ * properties are decorated in code, everything else is a plain decorated class.
175
+ */
176
+ function buildTaskDtos(config) {
177
+ const writable = config.relationships.filter((entry) => !entry.readOnly);
178
+ const wrappers = new Map(writable.map((entry) => [entry.key, buildLinkWrapper(entry)]));
179
+ const propertyOf = (entry) => entry.dtoKey ?? entry.key;
180
+ const addLink = (cls, entry, mode) => {
181
+ const Wrapper = wrappers.get(entry.key);
182
+ decorate(cls, propertyOf(entry), [
183
+ // PATCH: every relationship optional (02-dtos.md Decision Matrix). TaskService refuses a
184
+ // body that leaves out a required changeable link; an absent immutable one keeps its value.
185
+ mode === "full" && entry.required ? (0, class_validator_1.IsDefined)() : (0, class_validator_1.IsOptional)(),
186
+ (0, class_validator_1.ValidateNested)(),
187
+ (0, class_transformer_1.Type)(() => Wrapper),
188
+ ]);
189
+ };
190
+ const addAssignee = (cls) => decorate(cls, "assignee", [(0, class_validator_1.IsOptional)(), (0, class_validator_1.ValidateNested)(), (0, class_transformer_1.Type)(() => nestjs_neo4jsonapi_1.UserDataDTO)]);
191
+ // Relationships
192
+ const TaskPostRelationshipsDTO = named(class {
193
+ }, "TaskPostRelationshipsDTO");
194
+ addAssignee(TaskPostRelationshipsDTO);
195
+ for (const entry of writable)
196
+ addLink(TaskPostRelationshipsDTO, entry, "full");
197
+ const TaskPutRelationshipsDTO = named(class {
198
+ }, "TaskPutRelationshipsDTO");
199
+ addAssignee(TaskPutRelationshipsDTO);
200
+ // PUT: same as POST (02-dtos.md Decision Matrix). An immutable link is validated here and
201
+ // TaskService.putFromDTO refuses a value that differs from the stored one.
202
+ for (const entry of writable)
203
+ addLink(TaskPutRelationshipsDTO, entry, "full");
204
+ const TaskRelationshipsPatchRelationshipsDTO = named(class {
205
+ }, "TaskRelationshipsPatchRelationshipsDTO");
206
+ for (const entry of writable)
207
+ addLink(TaskRelationshipsPatchRelationshipsDTO, entry, "patch");
208
+ // Data
209
+ const buildData = (name, attributes, relationships, relationshipsRequired, attributeChecks = []) => {
210
+ class DataDTO {
211
+ }
212
+ __decorate([
213
+ (0, class_validator_1.Equals)(task_meta_1.taskMeta.endpoint),
214
+ __metadata("design:type", String)
215
+ ], DataDTO.prototype, "type", void 0);
216
+ __decorate([
217
+ (0, class_validator_1.IsUUID)(),
218
+ __metadata("design:type", String)
219
+ ], DataDTO.prototype, "id", void 0);
220
+ if (attributes)
221
+ decorate(DataDTO, "attributes", [
222
+ (0, class_validator_1.ValidateNested)(),
223
+ (0, class_validator_1.IsNotEmpty)(),
224
+ ...attributeChecks,
225
+ (0, class_transformer_1.Type)(() => attributes),
226
+ ]);
227
+ if (relationships)
228
+ decorate(DataDTO, "relationships", [
229
+ (0, class_validator_1.ValidateNested)(),
230
+ relationshipsRequired ? (0, class_validator_1.IsDefined)() : (0, class_validator_1.IsOptional)(),
231
+ (0, class_transformer_1.Type)(() => relationships),
232
+ ]);
233
+ return named(DataDTO, name);
234
+ };
235
+ const TaskPostDataDTO = buildData("TaskPostDataDTO", TaskPostAttributesDTO, TaskPostRelationshipsDTO, writable.some((e) => e.required));
236
+ const TaskPutDataDTO = buildData("TaskPutDataDTO", TaskPutAttributesDTO, TaskPutRelationshipsDTO, writable.some((e) => e.required));
237
+ const TaskPatchDataDTO = buildData("TaskPatchDataDTO", TaskPatchAttributesDTO, undefined, false, [
238
+ NoNullPatchAttributes(),
239
+ ]);
240
+ const TaskRelationshipsPatchDataDTO = buildData("TaskRelationshipsPatchDataDTO", undefined, TaskRelationshipsPatchRelationshipsDTO, true);
241
+ // Top-level wrappers
242
+ const buildWrapper = (name, Data) => {
243
+ class WrapperDTO {
244
+ }
245
+ __decorate([
246
+ (0, class_validator_1.ValidateNested)(),
247
+ (0, class_validator_1.IsNotEmpty)(),
248
+ (0, class_transformer_1.Type)(() => Data),
249
+ __metadata("design:type", Object)
250
+ ], WrapperDTO.prototype, "data", void 0);
251
+ return named(WrapperDTO, name);
252
+ };
253
+ return {
254
+ TaskPostDTO: buildWrapper("TaskPostDTO", TaskPostDataDTO),
255
+ TaskPutDTO: buildWrapper("TaskPutDTO", TaskPutDataDTO),
256
+ TaskPatchDTO: buildWrapper("TaskPatchDTO", TaskPatchDataDTO),
257
+ TaskRelationshipsPatchDTO: buildWrapper("TaskRelationshipsPatchDTO", TaskRelationshipsPatchDataDTO),
258
+ };
259
+ }
260
+ //# sourceMappingURL=task.dtos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.dtos.js","sourceRoot":"","sources":["../../../../src/api/task/dtos/task.dtos.ts"],"names":[],"mappings":";;;;;;;;;;;AA8KA,sCAsGC;AApRD,wEAA8D;AAE9D,yDAA0D;AAC1D,qDAcyB;AAEzB,iEAA6D;AAC7D,qDAAiD;AAWjD,iGAAiG;AACjG,SAAS,QAAQ,CAAC,GAAkB,EAAE,QAAgB,EAAE,UAAuB;IAC7E,KAAK,MAAM,SAAS,IAAI,UAAU;QAAE,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,KAAK,CAA0B,GAAM,EAAE,IAAY;IAC1D,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,+GAA+G;AAC/G,SAAS,WAAW,CAAC,QAAgB;IACnC,MAAM,MAAM;KAMX;IAJC;QADC,IAAA,wBAAM,EAAC,QAAQ,CAAC;;wCACJ;IAGb;QADC,IAAA,wBAAM,GAAE;;sCACE;IAEb,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,GAA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AC;QAC5D,yBAAyB,EAAE,YAAY,CAAC,2BAA2B,EAAE,6BAA6B,CAAC;KACpG,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Entity, EntityDescriptor, RelationshipDef, User } from "@carlonicora/nestjs-neo4jsonapi";
2
+ import type { TodosModuleConfig } from "../../config/todos.config";
3
+ import { TaskPriority } from "../../../shared/task.priority";
4
+ export type Task = Entity & {
5
+ name: string;
6
+ content?: string;
7
+ priority?: TaskPriority;
8
+ dueDate?: string;
9
+ completed: boolean;
10
+ owner?: User;
11
+ assignee?: User;
12
+ /** Configured relationships, by key. */
13
+ [relationshipKey: string]: unknown;
14
+ };
15
+ /**
16
+ * Builds the Task descriptor from the app's configuration: the fixed fields, the fixed
17
+ * owner / assignee links and one relationship per configured entry. Called inside
18
+ * TodosModule.forRoot, never at import time.
19
+ */
20
+ export declare function buildTaskDescriptor(config: TodosModuleConfig): EntityDescriptor<Task, Record<string, RelationshipDef>>;
21
+ //# sourceMappingURL=task.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../../../src/api/task/entities/task.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EACN,gBAAgB,EAEhB,eAAe,EACf,IAAI,EAEL,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,wCAAwC;IACxC,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC,CAAC;AAkBF;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,iBAAiB,GACxB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAsEzD"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildTaskDescriptor = buildTaskDescriptor;
4
+ const nestjs_neo4jsonapi_1 = require("@carlonicora/nestjs-neo4jsonapi");
5
+ const task_meta_1 = require("./task.meta");
6
+ const RESERVED_KEYS = ["owner", "assignee", "company"];
7
+ function validateConfig(config) {
8
+ const seen = new Set();
9
+ for (const entry of config.relationships) {
10
+ if (RESERVED_KEYS.includes(entry.key))
11
+ throw new Error(`nja-todos: relationship key "${entry.key}" is reserved`);
12
+ if (seen.has(entry.key))
13
+ throw new Error(`nja-todos: relationship key "${entry.key}" is duplicated`);
14
+ seen.add(entry.key);
15
+ // GET users/:userId/tasks is the package's own route: a linked "users" list would collide with it.
16
+ if (entry.model.endpoint === nestjs_neo4jsonapi_1.userMeta.endpoint)
17
+ throw new Error(`nja-todos: relationship "${entry.key}" cannot link the users endpoint`);
18
+ if (entry.readOnly && entry.immutable)
19
+ throw new Error(`nja-todos: relationship "${entry.key}" cannot be both readOnly and immutable`);
20
+ }
21
+ }
22
+ /**
23
+ * Builds the Task descriptor from the app's configuration: the fixed fields, the fixed
24
+ * owner / assignee links and one relationship per configured entry. Called inside
25
+ * TodosModule.forRoot, never at import time.
26
+ */
27
+ function buildTaskDescriptor(config) {
28
+ validateConfig(config);
29
+ const relationships = {
30
+ owner: {
31
+ model: nestjs_neo4jsonapi_1.ownerMeta,
32
+ direction: "out",
33
+ relationship: "CREATED_BY",
34
+ cardinality: "one",
35
+ required: false,
36
+ contextKey: "userId",
37
+ immutable: true,
38
+ description: "The user who created the task.",
39
+ ...(config.catalogue
40
+ ? {
41
+ reverse: { name: "createdTasks", description: "Tasks created by this user.", cardinality: "many" },
42
+ }
43
+ : {}),
44
+ },
45
+ assignee: {
46
+ model: nestjs_neo4jsonapi_1.assigneeMeta,
47
+ direction: "out",
48
+ relationship: "ASSIGNED_TO",
49
+ cardinality: "one",
50
+ required: false,
51
+ dtoKey: "assignee",
52
+ description: "The user responsible for the task.",
53
+ ...(config.catalogue
54
+ ? {
55
+ reverse: {
56
+ name: "assignedTasks",
57
+ description: "Tasks assigned to this user.",
58
+ cardinality: "many",
59
+ },
60
+ }
61
+ : {}),
62
+ },
63
+ };
64
+ for (const entry of config.relationships) {
65
+ relationships[entry.key] = {
66
+ model: entry.model,
67
+ direction: entry.direction,
68
+ relationship: entry.relationship,
69
+ cardinality: entry.cardinality,
70
+ required: entry.required ?? false,
71
+ ...(entry.immutable ? { immutable: true } : {}),
72
+ ...(entry.readOnly ? { readOnly: true } : {}),
73
+ ...(entry.dtoKey ? { dtoKey: entry.dtoKey } : {}),
74
+ ...(entry.description ? { description: entry.description } : {}),
75
+ ...(entry.reverse ? { reverse: entry.reverse } : {}),
76
+ };
77
+ }
78
+ return (0, nestjs_neo4jsonapi_1.defineEntity)()({
79
+ ...task_meta_1.taskMeta,
80
+ ...(config.catalogue ? { description: config.catalogue.task } : {}),
81
+ fields: {
82
+ name: { type: "string", required: true, sortable: true, description: "The task's short title." },
83
+ content: { type: "string", kind: { type: "richtext" }, description: "Rich-text notes (BlockNote JSON)." },
84
+ priority: {
85
+ type: "string",
86
+ excludeFromSearch: true,
87
+ description: "Priority: high, medium or low; absent when none.",
88
+ },
89
+ dueDate: { type: "date", sortable: true, description: "Calendar date the task is due." },
90
+ completed: { type: "boolean", default: false, description: "Whether the task is done." },
91
+ },
92
+ relationships,
93
+ });
94
+ }
95
+ //# sourceMappingURL=task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.js","sourceRoot":"","sources":["../../../../src/api/task/entities/task.ts"],"names":[],"mappings":";;AA+CA,kDAwEC;AAv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map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.meta.d.ts","sourceRoot":"","sources":["../../../../src/api/task/entities/task.meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAGhE,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.taskMeta = void 0;
4
+ const todos_endpoints_1 = require("../../../shared/todos.endpoints");
5
+ exports.taskMeta = {
6
+ type: todos_endpoints_1.TASK_ENDPOINT,
7
+ endpoint: todos_endpoints_1.TASK_ENDPOINT,
8
+ nodeName: "task",
9
+ labelName: "Task",
10
+ };
11
+ //# sourceMappingURL=task.meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.meta.js","sourceRoot":"","sources":["../../../../src/api/task/entities/task.meta.ts"],"names":[],"mappings":";;;AACA,qEAAgE;AAEnD,QAAA,QAAQ,GAAa;IAChC,IAAI,EAAE,+BAAa;IACnB,QAAQ,EAAE,+BAAa;IACvB,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,MAAM;CAClB,CAAC"}
@@ -0,0 +1,104 @@
1
+ import { AbstractRepository, EntityDescriptor, JsonApiCursorInterface, Neo4jService, RelationshipDef, SecurityService, SortCriterion } from "@carlonicora/nestjs-neo4jsonapi";
2
+ import { ClsService } from "nestjs-cls";
3
+ import { type TodosModuleConfig } from "../../config/todos.config";
4
+ import type { TaskCompletedFilter } from "../../../shared/task.completed.filter";
5
+ import type { Task } from "../entities/task";
6
+ export type TaskListFilters = {
7
+ term?: string;
8
+ completedFilter?: TaskCompletedFilter | string;
9
+ filterPriority?: string[];
10
+ orderByFields?: SortCriterion[];
11
+ fetchAll?: boolean;
12
+ };
13
+ /**
14
+ * Tasks of the caller's company. The descriptor is built in TodosModule.forRoot from the app's
15
+ * configuration and injected (as ContentModule does with CONTENT_DESCRIPTOR).
16
+ *
17
+ * Every read applies the read rule (`buildUserHasAccess`); the hand-written writes are
18
+ * `setCompleted` (guarded transition), `deleteWithComments` and `setReadOnlyLink`. Links and the
19
+ * assignee are written through the generic `patch`, which runs the company check.
20
+ */
21
+ export declare class TaskRepository extends AbstractRepository<Task, Record<string, RelationshipDef>> {
22
+ protected readonly descriptor: EntityDescriptor<Task, Record<string, RelationshipDef>>;
23
+ private readonly config;
24
+ constructor(neo4j: Neo4jService, securityService: SecurityService, clsService: ClsService, descriptor: EntityDescriptor<Task, Record<string, RelationshipDef>>, config: TodosModuleConfig);
25
+ /**
26
+ * The read rule: a user sees a task they created, a task assigned to them, or a task linked
27
+ * through a relationship whose `access` admits them. Automated jobs bypass it; with no bound
28
+ * `currentUser` it fails closed (an unbound alias inside EXISTS would match any user).
29
+ * Continuation-safe: the base contract splices this AFTER segments that may end in a WHERE
30
+ * clause, so it opens with WITH, never WHERE. Overrides the base no-op hook.
31
+ *
32
+ * The edge types, labels and the access function's text are code from the app's configuration,
33
+ * never request data; the linked alias is built from the entry's index, never from its key.
34
+ */
35
+ /** The owner edge type, from the descriptor (both fixed user links point out of the task). */
36
+ private get ownerEdge();
37
+ /** The assignee edge type, from the descriptor. */
38
+ private get assigneeEdge();
39
+ protected buildUserHasAccess(): string;
40
+ onModuleInit(): Promise<void>;
41
+ /**
42
+ * The ORDER BY of a task list: the validated sort (`orderByFields`, from the service's
43
+ * `parseSort`), else `defaultOrderBy`. `priority` sorts by its rank, never alphabetically.
44
+ */
45
+ private listOrderBy;
46
+ private completedFilterClause;
47
+ findFiltered(params: TaskListFilters & {
48
+ cursor?: JsonApiCursorInterface;
49
+ }): Promise<Task[]>;
50
+ findByUser(params: TaskListFilters & {
51
+ userId: string;
52
+ creator?: boolean;
53
+ cursor?: JsonApiCursorInterface;
54
+ }): Promise<Task[]>;
55
+ findByLinked(params: TaskListFilters & {
56
+ key: string;
57
+ relatedId: string;
58
+ cursor?: JsonApiCursorInterface;
59
+ }): Promise<Task[]>;
60
+ /**
61
+ * One task by id. Not the inherited `findById`: that answers 403 for another company's id, and
62
+ * a task of another company, or one the read rule hides, must look exactly like a missing one.
63
+ */
64
+ findTask(params: {
65
+ taskId: string;
66
+ }): Promise<Task | null>;
67
+ /** Replaces the given links through the generic patch (company check, only the keys passed). */
68
+ replaceLinks(params: {
69
+ taskId: string;
70
+ links: Record<string, string[]>;
71
+ }): Promise<void>;
72
+ setAssignee(params: {
73
+ taskId: string;
74
+ assigneeId: string;
75
+ }): Promise<void>;
76
+ /** An empty list makes the generic patch delete the assignee edge. */
77
+ clearAssignee(params: {
78
+ taskId: string;
79
+ }): Promise<void>;
80
+ /**
81
+ * Guarded transition (references/backend/07-queue-workers.md § "The guarded state transition"):
82
+ * the first SET takes the node's write lock, then the stored value is checked. Of two
83
+ * simultaneous requests the second waits, reads the committed value and matches nothing.
84
+ * Returns true only when this call changed `completed`.
85
+ */
86
+ setCompleted(params: {
87
+ taskId: string;
88
+ completed: boolean;
89
+ }): Promise<boolean>;
90
+ deleteWithComments(params: {
91
+ taskId: string;
92
+ }): Promise<void>;
93
+ /**
94
+ * Writes a readOnly link (the generic writers skip those). Hand-written relationship Cypher, so
95
+ * the ids are checked against the company first (references/backend/01-entity-basics.md
96
+ * § "Relationship Writes: the Company Check"), and the link itself is company-scoped.
97
+ */
98
+ setReadOnlyLink(params: {
99
+ taskId: string;
100
+ key: string;
101
+ ids: string[];
102
+ }): Promise<void>;
103
+ }
104
+ //# sourceMappingURL=task.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.repository.d.ts","sourceRoot":"","sources":["../../../../src/api/task/repositories/task.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAIlB,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,aAAa,EAGd,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAiC,KAAK,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