@endora-commerce/mod-tasks 0.110.0 → 0.111.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 (308) hide show
  1. package/dist/admin/components/TaskCustomFields.js +2 -13
  2. package/dist/backend/email-templates/digest-defaults.d.ts +14 -7
  3. package/dist/backend/email-templates/digest-defaults.js +39 -19
  4. package/dist/backend/email-templates/reminder-defaults.d.ts +7 -3
  5. package/dist/backend/email-templates/reminder-defaults.js +11 -3
  6. package/dist/backend/entities/task-value-change.entity.d.ts +27 -0
  7. package/dist/backend/entities/task-value-change.entity.js +62 -0
  8. package/dist/backend/index.d.ts +2 -1
  9. package/dist/backend/index.js +27 -3
  10. package/dist/backend/services/attachment-service.d.ts +5 -4
  11. package/dist/backend/services/attachment-service.js +25 -9
  12. package/dist/backend/services/digest-service.js +1 -0
  13. package/dist/backend/services/owner-read-permissions.d.ts +3 -0
  14. package/dist/backend/services/owner-read-permissions.js +3 -0
  15. package/dist/backend/services/reference-service.js +1 -13
  16. package/dist/backend/services/reminder-schedule.d.ts +2 -1
  17. package/dist/backend/services/reminder-schedule.js +7 -3
  18. package/dist/backend/services/task-access.js +8 -0
  19. package/dist/backend/services/task-audit-state.d.ts +42 -0
  20. package/dist/backend/services/task-audit-state.js +98 -0
  21. package/dist/backend/services/task-commands.d.ts +38 -2
  22. package/dist/backend/services/task-commands.js +70 -7
  23. package/dist/backend/services/task-email.d.ts +8 -0
  24. package/dist/backend/services/task-email.js +18 -2
  25. package/dist/backend/services/task-history-service.d.ts +37 -0
  26. package/dist/backend/services/task-history-service.js +82 -7
  27. package/dist/backend/services/time-zone-rederive-service.d.ts +57 -0
  28. package/dist/backend/services/time-zone-rederive-service.js +105 -0
  29. package/dist/backend/workers/tasks-reminders-worker.d.ts +12 -6
  30. package/dist/backend/workers/tasks-reminders-worker.js +13 -6
  31. package/dist/manifest.d.ts +25 -1
  32. package/dist/manifest.js +35 -1
  33. package/dist/migrations/20261110T054810_tasks_value_changes.d.ts +23 -0
  34. package/dist/migrations/20261110T054810_tasks_value_changes.js +39 -0
  35. package/dist/migrations/index.d.ts +2 -1
  36. package/dist/migrations/index.js +7 -2
  37. package/docs/tasks.md +37 -8
  38. package/i18n/en.json +1 -0
  39. package/i18n/pl.json +1 -0
  40. package/package.json +11 -10
  41. package/dist/admin/api.d.ts.map +0 -1
  42. package/dist/admin/api.js.map +0 -1
  43. package/dist/admin/components/AssigneePicker.d.ts.map +0 -1
  44. package/dist/admin/components/AssigneePicker.js.map +0 -1
  45. package/dist/admin/components/BoardCardFieldsEditor.d.ts.map +0 -1
  46. package/dist/admin/components/BoardCardFieldsEditor.js.map +0 -1
  47. package/dist/admin/components/ContextLabel.d.ts.map +0 -1
  48. package/dist/admin/components/ContextLabel.js.map +0 -1
  49. package/dist/admin/components/ContextSection.d.ts.map +0 -1
  50. package/dist/admin/components/ContextSection.js.map +0 -1
  51. package/dist/admin/components/DigestControl.d.ts.map +0 -1
  52. package/dist/admin/components/DigestControl.js.map +0 -1
  53. package/dist/admin/components/LinkedRecordsSection.d.ts.map +0 -1
  54. package/dist/admin/components/LinkedRecordsSection.js.map +0 -1
  55. package/dist/admin/components/LookupPicker.d.ts.map +0 -1
  56. package/dist/admin/components/LookupPicker.js.map +0 -1
  57. package/dist/admin/components/RelatedTasksSection.d.ts.map +0 -1
  58. package/dist/admin/components/RelatedTasksSection.js.map +0 -1
  59. package/dist/admin/components/RemindersSection.d.ts.map +0 -1
  60. package/dist/admin/components/RemindersSection.js.map +0 -1
  61. package/dist/admin/components/StatusBadge.d.ts.map +0 -1
  62. package/dist/admin/components/StatusBadge.js.map +0 -1
  63. package/dist/admin/components/SubtasksSection.d.ts.map +0 -1
  64. package/dist/admin/components/SubtasksSection.js.map +0 -1
  65. package/dist/admin/components/TaskAttachments.d.ts.map +0 -1
  66. package/dist/admin/components/TaskAttachments.js.map +0 -1
  67. package/dist/admin/components/TaskBoard.d.ts.map +0 -1
  68. package/dist/admin/components/TaskBoard.js.map +0 -1
  69. package/dist/admin/components/TaskCard.d.ts.map +0 -1
  70. package/dist/admin/components/TaskCard.js.map +0 -1
  71. package/dist/admin/components/TaskComments.d.ts.map +0 -1
  72. package/dist/admin/components/TaskComments.js.map +0 -1
  73. package/dist/admin/components/TaskCustomFields.d.ts.map +0 -1
  74. package/dist/admin/components/TaskCustomFields.js.map +0 -1
  75. package/dist/admin/components/TaskFieldInputs.d.ts.map +0 -1
  76. package/dist/admin/components/TaskFieldInputs.js.map +0 -1
  77. package/dist/admin/components/TaskFilters.d.ts.map +0 -1
  78. package/dist/admin/components/TaskFilters.js.map +0 -1
  79. package/dist/admin/components/TaskMarkers.d.ts.map +0 -1
  80. package/dist/admin/components/TaskMarkers.js.map +0 -1
  81. package/dist/admin/components/TaskPicker.d.ts.map +0 -1
  82. package/dist/admin/components/TaskPicker.js.map +0 -1
  83. package/dist/admin/components/ViewModeToggle.d.ts.map +0 -1
  84. package/dist/admin/components/ViewModeToggle.js.map +0 -1
  85. package/dist/admin/components/priorities/TaskPriorityDeleteDialog.d.ts.map +0 -1
  86. package/dist/admin/components/priorities/TaskPriorityDeleteDialog.js.map +0 -1
  87. package/dist/admin/components/priorities/TaskPriorityDialog.d.ts.map +0 -1
  88. package/dist/admin/components/priorities/TaskPriorityDialog.js.map +0 -1
  89. package/dist/admin/components/tags/TaskTagDeleteDialog.d.ts.map +0 -1
  90. package/dist/admin/components/tags/TaskTagDeleteDialog.js.map +0 -1
  91. package/dist/admin/components/tags/TaskTagDialog.d.ts.map +0 -1
  92. package/dist/admin/components/tags/TaskTagDialog.js.map +0 -1
  93. package/dist/admin/components/task-columns.d.ts.map +0 -1
  94. package/dist/admin/components/task-columns.js.map +0 -1
  95. package/dist/admin/components/workflow/TaskStatusDeleteDialog.d.ts.map +0 -1
  96. package/dist/admin/components/workflow/TaskStatusDeleteDialog.js.map +0 -1
  97. package/dist/admin/components/workflow/TaskStatusDialog.d.ts.map +0 -1
  98. package/dist/admin/components/workflow/TaskStatusDialog.js.map +0 -1
  99. package/dist/admin/components/workflow/TaskStatusesTable.d.ts.map +0 -1
  100. package/dist/admin/components/workflow/TaskStatusesTable.js.map +0 -1
  101. package/dist/admin/index.d.ts.map +0 -1
  102. package/dist/admin/index.js.map +0 -1
  103. package/dist/admin/lib/current-admin.d.ts.map +0 -1
  104. package/dist/admin/lib/current-admin.js.map +0 -1
  105. package/dist/admin/lib/labels.d.ts.map +0 -1
  106. package/dist/admin/lib/labels.js.map +0 -1
  107. package/dist/admin/lib/references.d.ts.map +0 -1
  108. package/dist/admin/lib/references.js.map +0 -1
  109. package/dist/admin/lib/settings-paths.d.ts.map +0 -1
  110. package/dist/admin/lib/settings-paths.js.map +0 -1
  111. package/dist/admin/lib/task-filters.d.ts.map +0 -1
  112. package/dist/admin/lib/task-filters.js.map +0 -1
  113. package/dist/admin/lib/use-editor-focus.d.ts.map +0 -1
  114. package/dist/admin/lib/use-editor-focus.js.map +0 -1
  115. package/dist/admin/lib/use-task-vocabulary.d.ts.map +0 -1
  116. package/dist/admin/lib/use-task-vocabulary.js.map +0 -1
  117. package/dist/admin/pages/MyTasksPage.d.ts.map +0 -1
  118. package/dist/admin/pages/MyTasksPage.js.map +0 -1
  119. package/dist/admin/pages/TaskCreate.d.ts.map +0 -1
  120. package/dist/admin/pages/TaskCreate.js.map +0 -1
  121. package/dist/admin/pages/TaskDetail.d.ts.map +0 -1
  122. package/dist/admin/pages/TaskDetail.js.map +0 -1
  123. package/dist/admin/pages/TasksPage.d.ts.map +0 -1
  124. package/dist/admin/pages/TasksPage.js.map +0 -1
  125. package/dist/admin/pages/settings/TaskGeneralSettingsPage.d.ts.map +0 -1
  126. package/dist/admin/pages/settings/TaskGeneralSettingsPage.js.map +0 -1
  127. package/dist/admin/pages/settings/TaskPrioritiesPage.d.ts.map +0 -1
  128. package/dist/admin/pages/settings/TaskPrioritiesPage.js.map +0 -1
  129. package/dist/admin/pages/settings/TaskTagsPage.d.ts.map +0 -1
  130. package/dist/admin/pages/settings/TaskTagsPage.js.map +0 -1
  131. package/dist/admin/pages/settings/TaskWorkflowPage.d.ts.map +0 -1
  132. package/dist/admin/pages/settings/TaskWorkflowPage.js.map +0 -1
  133. package/dist/admin/zones/OpportunityTasksPanel.d.ts.map +0 -1
  134. package/dist/admin/zones/OpportunityTasksPanel.js.map +0 -1
  135. package/dist/admin/zones/OrderTasksPanel.d.ts.map +0 -1
  136. package/dist/admin/zones/OrderTasksPanel.js.map +0 -1
  137. package/dist/admin/zones/QuoteRequestTasksPanel.d.ts.map +0 -1
  138. package/dist/admin/zones/QuoteRequestTasksPanel.js.map +0 -1
  139. package/dist/admin/zones/TasksPanel.d.ts.map +0 -1
  140. package/dist/admin/zones/TasksPanel.js.map +0 -1
  141. package/dist/backend/admin-search-provider.d.ts.map +0 -1
  142. package/dist/backend/admin-search-provider.js.map +0 -1
  143. package/dist/backend/domain/board-card-fields.d.ts.map +0 -1
  144. package/dist/backend/domain/board-card-fields.js.map +0 -1
  145. package/dist/backend/domain/due-moment.d.ts.map +0 -1
  146. package/dist/backend/domain/due-moment.js.map +0 -1
  147. package/dist/backend/domain/hierarchy.d.ts.map +0 -1
  148. package/dist/backend/domain/hierarchy.js.map +0 -1
  149. package/dist/backend/domain/list-cursor.d.ts.map +0 -1
  150. package/dist/backend/domain/list-cursor.js.map +0 -1
  151. package/dist/backend/domain/task-status-graph.d.ts.map +0 -1
  152. package/dist/backend/domain/task-status-graph.js.map +0 -1
  153. package/dist/backend/email-templates/digest-defaults.d.ts.map +0 -1
  154. package/dist/backend/email-templates/digest-defaults.js.map +0 -1
  155. package/dist/backend/email-templates/reminder-defaults.d.ts.map +0 -1
  156. package/dist/backend/email-templates/reminder-defaults.js.map +0 -1
  157. package/dist/backend/entities/task-assignee.entity.d.ts.map +0 -1
  158. package/dist/backend/entities/task-assignee.entity.js.map +0 -1
  159. package/dist/backend/entities/task-attachment.entity.d.ts.map +0 -1
  160. package/dist/backend/entities/task-attachment.entity.js.map +0 -1
  161. package/dist/backend/entities/task-comment.entity.d.ts.map +0 -1
  162. package/dist/backend/entities/task-comment.entity.js.map +0 -1
  163. package/dist/backend/entities/task-digest-subscription.entity.d.ts.map +0 -1
  164. package/dist/backend/entities/task-digest-subscription.entity.js.map +0 -1
  165. package/dist/backend/entities/task-list-saved-view.entity.d.ts.map +0 -1
  166. package/dist/backend/entities/task-list-saved-view.entity.js.map +0 -1
  167. package/dist/backend/entities/task-priority.entity.d.ts.map +0 -1
  168. package/dist/backend/entities/task-priority.entity.js.map +0 -1
  169. package/dist/backend/entities/task-record-link.entity.d.ts.map +0 -1
  170. package/dist/backend/entities/task-record-link.entity.js.map +0 -1
  171. package/dist/backend/entities/task-reference.entity.d.ts.map +0 -1
  172. package/dist/backend/entities/task-reference.entity.js.map +0 -1
  173. package/dist/backend/entities/task-relation.entity.d.ts.map +0 -1
  174. package/dist/backend/entities/task-relation.entity.js.map +0 -1
  175. package/dist/backend/entities/task-reminder-delivery.entity.d.ts.map +0 -1
  176. package/dist/backend/entities/task-reminder-delivery.entity.js.map +0 -1
  177. package/dist/backend/entities/task-reminder.entity.d.ts.map +0 -1
  178. package/dist/backend/entities/task-reminder.entity.js.map +0 -1
  179. package/dist/backend/entities/task-status-transition.entity.d.ts.map +0 -1
  180. package/dist/backend/entities/task-status-transition.entity.js.map +0 -1
  181. package/dist/backend/entities/task-status.entity.d.ts.map +0 -1
  182. package/dist/backend/entities/task-status.entity.js.map +0 -1
  183. package/dist/backend/entities/task-tag-assignment.entity.d.ts.map +0 -1
  184. package/dist/backend/entities/task-tag-assignment.entity.js.map +0 -1
  185. package/dist/backend/entities/task-tag.entity.d.ts.map +0 -1
  186. package/dist/backend/entities/task-tag.entity.js.map +0 -1
  187. package/dist/backend/entities/task.entity.d.ts.map +0 -1
  188. package/dist/backend/entities/task.entity.js.map +0 -1
  189. package/dist/backend/index.d.ts.map +0 -1
  190. package/dist/backend/index.js.map +0 -1
  191. package/dist/backend/routes/routes.board.d.ts.map +0 -1
  192. package/dist/backend/routes/routes.board.js.map +0 -1
  193. package/dist/backend/routes/routes.collaboration.d.ts.map +0 -1
  194. package/dist/backend/routes/routes.collaboration.js.map +0 -1
  195. package/dist/backend/routes/routes.priorities.d.ts.map +0 -1
  196. package/dist/backend/routes/routes.priorities.js.map +0 -1
  197. package/dist/backend/routes/routes.reminders.d.ts.map +0 -1
  198. package/dist/backend/routes/routes.reminders.js.map +0 -1
  199. package/dist/backend/routes/routes.settings.d.ts.map +0 -1
  200. package/dist/backend/routes/routes.settings.js.map +0 -1
  201. package/dist/backend/routes/routes.tags.d.ts.map +0 -1
  202. package/dist/backend/routes/routes.tags.js.map +0 -1
  203. package/dist/backend/routes/routes.tasks.d.ts.map +0 -1
  204. package/dist/backend/routes/routes.tasks.js.map +0 -1
  205. package/dist/backend/routes/routes.views.d.ts.map +0 -1
  206. package/dist/backend/routes/routes.views.js.map +0 -1
  207. package/dist/backend/routes/routes.workflow.d.ts.map +0 -1
  208. package/dist/backend/routes/routes.workflow.js.map +0 -1
  209. package/dist/backend/saved-view-actor.d.ts.map +0 -1
  210. package/dist/backend/saved-view-actor.js.map +0 -1
  211. package/dist/backend/services/attachment-active-content.d.ts.map +0 -1
  212. package/dist/backend/services/attachment-active-content.js.map +0 -1
  213. package/dist/backend/services/attachment-service.d.ts.map +0 -1
  214. package/dist/backend/services/attachment-service.js.map +0 -1
  215. package/dist/backend/services/board-card-field-service.d.ts.map +0 -1
  216. package/dist/backend/services/board-card-field-service.js.map +0 -1
  217. package/dist/backend/services/board-service.d.ts.map +0 -1
  218. package/dist/backend/services/board-service.js.map +0 -1
  219. package/dist/backend/services/comment-service.d.ts.map +0 -1
  220. package/dist/backend/services/comment-service.js.map +0 -1
  221. package/dist/backend/services/context-lookup.d.ts.map +0 -1
  222. package/dist/backend/services/context-lookup.js.map +0 -1
  223. package/dist/backend/services/digest-service.d.ts.map +0 -1
  224. package/dist/backend/services/digest-service.js.map +0 -1
  225. package/dist/backend/services/document-lookup-service.d.ts.map +0 -1
  226. package/dist/backend/services/document-lookup-service.js.map +0 -1
  227. package/dist/backend/services/hierarchy-service.d.ts.map +0 -1
  228. package/dist/backend/services/hierarchy-service.js.map +0 -1
  229. package/dist/backend/services/maintenance-service.d.ts.map +0 -1
  230. package/dist/backend/services/maintenance-service.js.map +0 -1
  231. package/dist/backend/services/mention-service.d.ts.map +0 -1
  232. package/dist/backend/services/mention-service.js.map +0 -1
  233. package/dist/backend/services/owner-read-permissions.d.ts.map +0 -1
  234. package/dist/backend/services/owner-read-permissions.js.map +0 -1
  235. package/dist/backend/services/priority-service.d.ts.map +0 -1
  236. package/dist/backend/services/priority-service.js.map +0 -1
  237. package/dist/backend/services/record-link-service.d.ts.map +0 -1
  238. package/dist/backend/services/record-link-service.js.map +0 -1
  239. package/dist/backend/services/record-owners.d.ts.map +0 -1
  240. package/dist/backend/services/record-owners.js.map +0 -1
  241. package/dist/backend/services/reference-service.d.ts.map +0 -1
  242. package/dist/backend/services/reference-service.js.map +0 -1
  243. package/dist/backend/services/relation-service.d.ts.map +0 -1
  244. package/dist/backend/services/relation-service.js.map +0 -1
  245. package/dist/backend/services/reminder-schedule.d.ts.map +0 -1
  246. package/dist/backend/services/reminder-schedule.js.map +0 -1
  247. package/dist/backend/services/reminder-service.d.ts.map +0 -1
  248. package/dist/backend/services/reminder-service.js.map +0 -1
  249. package/dist/backend/services/saved-view-service.d.ts.map +0 -1
  250. package/dist/backend/services/saved-view-service.js.map +0 -1
  251. package/dist/backend/services/scheduled-work-probe.d.ts.map +0 -1
  252. package/dist/backend/services/scheduled-work-probe.js.map +0 -1
  253. package/dist/backend/services/tag-service.d.ts.map +0 -1
  254. package/dist/backend/services/tag-service.js.map +0 -1
  255. package/dist/backend/services/task-access.d.ts.map +0 -1
  256. package/dist/backend/services/task-access.js.map +0 -1
  257. package/dist/backend/services/task-asset-references.d.ts.map +0 -1
  258. package/dist/backend/services/task-asset-references.js.map +0 -1
  259. package/dist/backend/services/task-audit-references.d.ts.map +0 -1
  260. package/dist/backend/services/task-audit-references.js.map +0 -1
  261. package/dist/backend/services/task-checks.d.ts.map +0 -1
  262. package/dist/backend/services/task-checks.js.map +0 -1
  263. package/dist/backend/services/task-commands.d.ts.map +0 -1
  264. package/dist/backend/services/task-commands.js.map +0 -1
  265. package/dist/backend/services/task-context-registry.d.ts.map +0 -1
  266. package/dist/backend/services/task-context-registry.js.map +0 -1
  267. package/dist/backend/services/task-custom-fields.d.ts.map +0 -1
  268. package/dist/backend/services/task-custom-fields.js.map +0 -1
  269. package/dist/backend/services/task-email.d.ts.map +0 -1
  270. package/dist/backend/services/task-email.js.map +0 -1
  271. package/dist/backend/services/task-errors.d.ts.map +0 -1
  272. package/dist/backend/services/task-errors.js.map +0 -1
  273. package/dist/backend/services/task-history-service.d.ts.map +0 -1
  274. package/dist/backend/services/task-history-service.js.map +0 -1
  275. package/dist/backend/services/task-notifier.d.ts.map +0 -1
  276. package/dist/backend/services/task-notifier.js.map +0 -1
  277. package/dist/backend/services/task-number.d.ts.map +0 -1
  278. package/dist/backend/services/task-number.js.map +0 -1
  279. package/dist/backend/services/task-read-port.d.ts.map +0 -1
  280. package/dist/backend/services/task-read-port.js.map +0 -1
  281. package/dist/backend/services/task-reassignment.d.ts.map +0 -1
  282. package/dist/backend/services/task-reassignment.js.map +0 -1
  283. package/dist/backend/services/task-service.d.ts.map +0 -1
  284. package/dist/backend/services/task-service.js.map +0 -1
  285. package/dist/backend/services/task-settings-service.d.ts.map +0 -1
  286. package/dist/backend/services/task-settings-service.js.map +0 -1
  287. package/dist/backend/services/task-transition-service.d.ts.map +0 -1
  288. package/dist/backend/services/task-transition-service.js.map +0 -1
  289. package/dist/backend/services/task-visibility.d.ts.map +0 -1
  290. package/dist/backend/services/task-visibility.js.map +0 -1
  291. package/dist/backend/services/task-workflow-read.d.ts.map +0 -1
  292. package/dist/backend/services/task-workflow-read.js.map +0 -1
  293. package/dist/backend/services/task-write-port.d.ts.map +0 -1
  294. package/dist/backend/services/task-write-port.js.map +0 -1
  295. package/dist/backend/services/time-zone-validator.d.ts.map +0 -1
  296. package/dist/backend/services/time-zone-validator.js.map +0 -1
  297. package/dist/backend/services/workflow-config-service.d.ts.map +0 -1
  298. package/dist/backend/services/workflow-config-service.js.map +0 -1
  299. package/dist/backend/workers/tasks-reminders-worker.d.ts.map +0 -1
  300. package/dist/backend/workers/tasks-reminders-worker.js.map +0 -1
  301. package/dist/manifest.d.ts.map +0 -1
  302. package/dist/manifest.js.map +0 -1
  303. package/dist/migrations/20261026T133731_tasks_init.d.ts.map +0 -1
  304. package/dist/migrations/20261026T133731_tasks_init.js.map +0 -1
  305. package/dist/migrations/20261028T140002_tasks_task_management.d.ts.map +0 -1
  306. package/dist/migrations/20261028T140002_tasks_task_management.js.map +0 -1
  307. package/dist/migrations/index.d.ts.map +0 -1
  308. package/dist/migrations/index.js.map +0 -1
@@ -24,18 +24,6 @@ function customFieldIssues(failure) {
24
24
  }
25
25
  return issues;
26
26
  }
27
- /**
28
- * The bag to send: a value that was stored and is now empty is sent as `null`
29
- * — "clear this" — because a key the request does not name keeps its value.
30
- */
31
- function withCleared(stored, edited) {
32
- const out = { ...edited };
33
- for (const key of new Set([...Object.keys(stored), ...Object.keys(edited)])) {
34
- if (out[key] === undefined)
35
- out[key] = null;
36
- }
37
- return out;
38
- }
39
27
  /**
40
28
  * A Task's custom fields (`specs/165-task-management/` FR-007, research R-8):
41
29
  * the kit's `CustomFieldValuesPanel` for the `task` host, saved through the
@@ -53,7 +41,8 @@ export function TaskCustomFields(props) {
53
41
  const save = async (values) => {
54
42
  setFieldErrors({});
55
43
  try {
56
- onChange(await tasksApi.updateTask(task.id, { customFieldValues: withCleared(task.customFieldValues, values) }));
44
+ // The panel's bag as it is: the changed keys only, a cleared one as `null` (issue #1007).
45
+ onChange(await tasksApi.updateTask(task.id, { customFieldValues: values }));
57
46
  }
58
47
  catch (failure) {
59
48
  setFieldErrors(customFieldIssues(failure) ?? {});
@@ -1,3 +1,4 @@
1
+ import type { PuckDataTree } from '@endora-commerce/email-components/schema/envelope';
1
2
  /**
2
3
  * The default subject and body of the daily Task digest
3
4
  * (`specs/165-task-management/` research R-18), in the two languages an Admin
@@ -6,15 +7,21 @@
6
7
  * **The list is a repeated block.** The directive engine of
7
8
  * `@endora-commerce/email-components` supports `{{for alias in path}} …
8
9
  * {{/for}}` (`directives/directive-engine.ts`), and the body uses it over
9
- * `digest.tasks` — each `{number, title, due, overdue, today}` — one line per
10
- * Task, so the HTML part breaks the lines as the text part does (a single
11
- * preformatted variable would be escaped into one HTML line), and the words
12
- * around them ("overdue since", "due today") are the template's, per
10
+ * `digest.tasks` — each `{number, title, due, overdue, today, adminUrl?}` — one
11
+ * line per Task, so the HTML part breaks the lines as the text part does, and
12
+ * the words around them ("overdue since", "due today") are the template's, per
13
13
  * language. `digest.taskList`, the number, title and due date of each joined
14
14
  * by line, is sent too: it is the variable the manifest declares, so an
15
15
  * operator editing the template sees a sample and may use it in a plain block.
16
16
  *
17
- * Never sent on a day with nothing due (FR-036). No link, as for the reminder.
17
+ * **Links, only when there is an address** (issue #185). On the platform's
18
+ * `ADMIN_BASE_URL` each line's number and title link to the Task
19
+ * (`task.adminUrl`) and a button opens *My tasks* (`digest.adminUrl`); the
20
+ * list is a rich-text block so a line can hold its anchor. Where the admin's
21
+ * address is not configured neither variable is sent: the lines are plain
22
+ * text and the button is dropped.
23
+ *
24
+ * Never sent on a day with nothing due (FR-036).
18
25
  */
19
26
  export declare const TASK_DIGEST_EMAIL_CODE = "tasks_daily_digest";
20
27
  export declare const TASK_DIGEST_DEFAULT: {
@@ -22,8 +29,8 @@ export declare const TASK_DIGEST_DEFAULT: {
22
29
  defaultContent: {
23
30
  schema_version: number;
24
31
  languages: {
25
- 'en-US': import("@endora-commerce/email-components/schema/envelope").PuckDataTree;
26
- 'pl-PL': import("@endora-commerce/email-components/schema/envelope").PuckDataTree;
32
+ 'en-US': PuckDataTree;
33
+ 'pl-PL': PuckDataTree;
27
34
  };
28
35
  };
29
36
  };
@@ -7,17 +7,41 @@ import { simpleEmailBodyTree } from '@endora-commerce/email-components/defaults/
7
7
  * **The list is a repeated block.** The directive engine of
8
8
  * `@endora-commerce/email-components` supports `{{for alias in path}} …
9
9
  * {{/for}}` (`directives/directive-engine.ts`), and the body uses it over
10
- * `digest.tasks` — each `{number, title, due, overdue, today}` — one line per
11
- * Task, so the HTML part breaks the lines as the text part does (a single
12
- * preformatted variable would be escaped into one HTML line), and the words
13
- * around them ("overdue since", "due today") are the template's, per
10
+ * `digest.tasks` — each `{number, title, due, overdue, today, adminUrl?}` — one
11
+ * line per Task, so the HTML part breaks the lines as the text part does, and
12
+ * the words around them ("overdue since", "due today") are the template's, per
14
13
  * language. `digest.taskList`, the number, title and due date of each joined
15
14
  * by line, is sent too: it is the variable the manifest declares, so an
16
15
  * operator editing the template sees a sample and may use it in a plain block.
17
16
  *
18
- * Never sent on a day with nothing due (FR-036). No link, as for the reminder.
17
+ * **Links, only when there is an address** (issue #185). On the platform's
18
+ * `ADMIN_BASE_URL` each line's number and title link to the Task
19
+ * (`task.adminUrl`) and a button opens *My tasks* (`digest.adminUrl`); the
20
+ * list is a rich-text block so a line can hold its anchor. Where the admin's
21
+ * address is not configured neither variable is sent: the lines are plain
22
+ * text and the button is dropped.
23
+ *
24
+ * Never sent on a day with nothing due (FR-036).
19
25
  */
20
26
  export const TASK_DIGEST_EMAIL_CODE = 'tasks_daily_digest';
27
+ const LINE = (overdue, today) => '{{for task in digest.tasks}}' +
28
+ '{{if task.adminUrl}}<a href="{{var task.adminUrl}}">{{/if}}{{var task.number}} {{var task.title}}{{if task.adminUrl}}</a>{{/if}}' +
29
+ ` — {{if task.overdue}}${overdue} {{var task.due}}{{/if}}{{if task.today}}${today}{{/if}}<br />` +
30
+ '{{/for}}';
31
+ /** The simple layout, with the rich-text list between its first text and its closing line. */
32
+ function digestTree(opts) {
33
+ const tree = simpleEmailBodyTree({
34
+ idPrefix: 'tasks-daily-digest',
35
+ heading: opts.heading,
36
+ text: opts.count,
37
+ ctaLabel: opts.ctaLabel,
38
+ ctaHref: '{{var digest.adminUrl}}',
39
+ });
40
+ const content = [...(tree.content ?? [])];
41
+ const at = content.findIndex((block) => block.type === 'transactional_emails.EmailText') + 1;
42
+ content.splice(at, 0, { type: 'transactional_emails.EmailRichText', props: { id: 'tasks-daily-digest-list', html: opts.list, align: 'left' } }, { type: 'transactional_emails.EmailText', props: { id: 'tasks-daily-digest-closing', text: opts.closing, align: 'left' } });
43
+ return { ...tree, content };
44
+ }
21
45
  export const TASK_DIGEST_DEFAULT = {
22
46
  defaultSubject: {
23
47
  'en-US': 'Your tasks for {{var digest.date}}: {{var digest.taskCount}} due or overdue',
@@ -26,23 +50,19 @@ export const TASK_DIGEST_DEFAULT = {
26
50
  defaultContent: {
27
51
  schema_version: 1,
28
52
  languages: {
29
- 'en-US': simpleEmailBodyTree({
30
- idPrefix: 'tasks-daily-digest',
53
+ 'en-US': digestTree({
31
54
  heading: 'Your tasks for today',
32
- text: [
33
- 'Due today or overdue: {{var digest.taskCount}}',
34
- '{{for task in digest.tasks}}{{var task.number}} {{var task.title}} — {{if task.overdue}}overdue since {{var task.due}}{{/if}}{{if task.today}}due today{{/if}}',
35
- '{{/for}}Open My tasks in the admin panel to see them.',
36
- ].join('\n'),
55
+ count: 'Due today or overdue: {{var digest.taskCount}}',
56
+ list: LINE('overdue since', 'due today'),
57
+ closing: 'Open My tasks in the admin panel to see them.',
58
+ ctaLabel: 'Open My tasks',
37
59
  }),
38
- 'pl-PL': simpleEmailBodyTree({
39
- idPrefix: 'tasks-daily-digest',
60
+ 'pl-PL': digestTree({
40
61
  heading: 'Twoje zadania na dziś',
41
- text: [
42
- 'Na dziś lub po terminie: {{var digest.taskCount}}',
43
- '{{for task in digest.tasks}}{{var task.number}} {{var task.title}} — {{if task.overdue}}po terminie od {{var task.due}}{{/if}}{{if task.today}}na dziś{{/if}}',
44
- '{{/for}}Otwórz Moje zadania w panelu administracyjnym, aby je zobaczyć.',
45
- ].join('\n'),
62
+ count: 'Na dziś lub po terminie: {{var digest.taskCount}}',
63
+ list: LINE('po terminie od', 'na dziś'),
64
+ closing: 'Otwórz Moje zadania w panelu administracyjnym, aby je zobaczyć.',
65
+ ctaLabel: 'Otwórz Moje zadania',
46
66
  }),
47
67
  },
48
68
  },
@@ -6,9 +6,13 @@
6
6
  * entry.
7
7
  *
8
8
  * Sent to one recipient who may see the Task at that moment, so it names the
9
- * Task by its number and its title, and says when it is due. **There is no
10
- * link**, for CRM's and Projects' reason: an absolute link needs the Admin
11
- * UI's address, which no module may read yet.
9
+ * Task by its number and its title, and says when it is due. **The link is a
10
+ * button, and only when there is an address**: `task.adminUrl` opens the Task
11
+ * on the platform's `ADMIN_BASE_URL` (`configuredAdminBaseUrl`, issue #185).
12
+ * Where that is not configured the variable is not sent and the button is
13
+ * dropped (`@endora-commerce/email-components` drops a button whose address is
14
+ * one empty variable); an operator's own template that does not name the
15
+ * variable renders as before.
12
16
  */
13
17
  export declare const TASK_REMINDER_EMAIL_CODE = "tasks_task_reminder";
14
18
  export declare const TASK_REMINDER_DEFAULT: {
@@ -7,9 +7,13 @@ import { simpleEmailBodyTree } from '@endora-commerce/email-components/defaults/
7
7
  * entry.
8
8
  *
9
9
  * Sent to one recipient who may see the Task at that moment, so it names the
10
- * Task by its number and its title, and says when it is due. **There is no
11
- * link**, for CRM's and Projects' reason: an absolute link needs the Admin
12
- * UI's address, which no module may read yet.
10
+ * Task by its number and its title, and says when it is due. **The link is a
11
+ * button, and only when there is an address**: `task.adminUrl` opens the Task
12
+ * on the platform's `ADMIN_BASE_URL` (`configuredAdminBaseUrl`, issue #185).
13
+ * Where that is not configured the variable is not sent and the button is
14
+ * dropped (`@endora-commerce/email-components` drops a button whose address is
15
+ * one empty variable); an operator's own template that does not name the
16
+ * variable renders as before.
13
17
  */
14
18
  export const TASK_REMINDER_EMAIL_CODE = 'tasks_task_reminder';
15
19
  export const TASK_REMINDER_DEFAULT = {
@@ -29,6 +33,8 @@ export const TASK_REMINDER_DEFAULT = {
29
33
  '{{if task.due}}Due: {{var task.due}}{{/if}}',
30
34
  'Open the task in the admin panel to see it.',
31
35
  ].join('\n'),
36
+ ctaLabel: 'Open the task',
37
+ ctaHref: '{{var task.adminUrl}}',
32
38
  }),
33
39
  'pl-PL': simpleEmailBodyTree({
34
40
  idPrefix: 'tasks-task-reminder',
@@ -39,6 +45,8 @@ export const TASK_REMINDER_DEFAULT = {
39
45
  '{{if task.due}}Termin: {{var task.due}}{{/if}}',
40
46
  'Otwórz zadanie w panelu administracyjnym, aby je zobaczyć.',
41
47
  ].join('\n'),
48
+ ctaLabel: 'Otwórz zadanie',
49
+ ctaHref: '{{var task.adminUrl}}',
42
50
  }),
43
51
  },
44
52
  },
@@ -0,0 +1,27 @@
1
+ import { OptionalProps } from '@mikro-orm/core';
2
+ /**
3
+ * What one Command changed among a Task's values, with the values (issue #470,
4
+ * D-288; `specs/conventions/audit-state.md` §3).
5
+ *
6
+ * The platform audit log is not tenant-scoped, so a `tasks.*` audit entry
7
+ * names the fields a write changed (`changedFields`, `changedCustomFields`)
8
+ * and carries this row's id as `valueChangeId`; the Task's history serves the
9
+ * values from here. Written in the Command of the change, so the row and the
10
+ * audit entry commit or roll back together. Classified like the Task, and read
11
+ * only by the id of a Task the reader may see.
12
+ *
13
+ * `before` is `null` for something that only arrived (a creation, an
14
+ * attachment), `after` for something that went. Each side holds only the keys
15
+ * that changed.
16
+ */
17
+ export declare class TaskValueChange {
18
+ [OptionalProps]?: 'id' | 'before' | 'after' | 'at';
19
+ id: string;
20
+ taskId: string;
21
+ before?: TaskValueState | null;
22
+ after?: TaskValueState | null;
23
+ at: Date;
24
+ }
25
+ /** The changed values of one side of a write — only the keys that changed. */
26
+ export type TaskValueState = Record<string, unknown>;
27
+ //# sourceMappingURL=task-value-change.entity.d.ts.map
@@ -0,0 +1,62 @@
1
+ var __decorate = (this && this.__decorate) || function (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
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Entity, Index, OptionalProps, PrimaryKey, Property } from '@mikro-orm/core';
11
+ import { RuleScoped } from '@endora-commerce/platform/tenancy';
12
+ import { randomUUID } from 'crypto';
13
+ /**
14
+ * What one Command changed among a Task's values, with the values (issue #470,
15
+ * D-288; `specs/conventions/audit-state.md` §3).
16
+ *
17
+ * The platform audit log is not tenant-scoped, so a `tasks.*` audit entry
18
+ * names the fields a write changed (`changedFields`, `changedCustomFields`)
19
+ * and carries this row's id as `valueChangeId`; the Task's history serves the
20
+ * values from here. Written in the Command of the change, so the row and the
21
+ * audit entry commit or roll back together. Classified like the Task, and read
22
+ * only by the id of a Task the reader may see.
23
+ *
24
+ * `before` is `null` for something that only arrived (a creation, an
25
+ * attachment), `after` for something that went. Each side holds only the keys
26
+ * that changed.
27
+ */
28
+ let TaskValueChange = class TaskValueChange {
29
+ [OptionalProps];
30
+ id = randomUUID();
31
+ taskId;
32
+ before = null;
33
+ after = null;
34
+ at = new Date();
35
+ };
36
+ __decorate([
37
+ PrimaryKey({ type: 'uuid' }),
38
+ __metadata("design:type", String)
39
+ ], TaskValueChange.prototype, "id", void 0);
40
+ __decorate([
41
+ Property({ type: 'uuid' }),
42
+ Index(),
43
+ __metadata("design:type", String)
44
+ ], TaskValueChange.prototype, "taskId", void 0);
45
+ __decorate([
46
+ Property({ type: 'json', nullable: true }),
47
+ __metadata("design:type", Object)
48
+ ], TaskValueChange.prototype, "before", void 0);
49
+ __decorate([
50
+ Property({ type: 'json', nullable: true }),
51
+ __metadata("design:type", Object)
52
+ ], TaskValueChange.prototype, "after", void 0);
53
+ __decorate([
54
+ Property({ type: 'datetime' }),
55
+ __metadata("design:type", Date)
56
+ ], TaskValueChange.prototype, "at", void 0);
57
+ TaskValueChange = __decorate([
58
+ RuleScoped(),
59
+ Entity({ tableName: 'task_value_changes' })
60
+ ], TaskValueChange);
61
+ export { TaskValueChange };
62
+ //# sourceMappingURL=task-value-change.entity.js.map
@@ -2,6 +2,7 @@ import { type ModuleContext } from '@endora-commerce/platform/kernel';
2
2
  import { Task } from './entities/task.entity.js';
3
3
  import { TaskAssignee } from './entities/task-assignee.entity.js';
4
4
  import { TaskAttachment } from './entities/task-attachment.entity.js';
5
+ import { TaskValueChange } from './entities/task-value-change.entity.js';
5
6
  import { TaskComment } from './entities/task-comment.entity.js';
6
7
  import { TaskDigestSubscription } from './entities/task-digest-subscription.entity.js';
7
8
  import { TaskListSavedView } from './entities/task-list-saved-view.entity.js';
@@ -28,7 +29,7 @@ export declare function registerModule(ctx: ModuleContext): void;
28
29
  * `@GlobalEntity` configuration; saved views and digest subscriptions are
29
30
  * `@GlobalEntity` per-administrator rows.
30
31
  */
31
- export declare const entities: (typeof Task | typeof TaskAssignee | typeof TaskAttachment | typeof TaskComment | typeof TaskDigestSubscription | typeof TaskListSavedView | typeof TaskPriority | typeof TaskRecordLink | typeof TaskReference | typeof TaskRelation | typeof TaskReminder | typeof TaskReminderDelivery | typeof TaskStatus | typeof TaskStatusTransition | typeof TaskTag | typeof TaskTagAssignment)[];
32
+ export declare const entities: (typeof Task | typeof TaskAssignee | typeof TaskAttachment | typeof TaskValueChange | typeof TaskComment | typeof TaskDigestSubscription | typeof TaskListSavedView | typeof TaskPriority | typeof TaskRecordLink | typeof TaskReference | typeof TaskRelation | typeof TaskReminder | typeof TaskReminderDelivery | typeof TaskStatus | typeof TaskStatusTransition | typeof TaskTag | typeof TaskTagAssignment)[];
32
33
  /**
33
34
  * The door to `tasks_number_seq`, published **by name** on `./backend`, as
34
35
  * CRM's `nextOpportunityNumber` is (`specs/143-crm-sales-opportunities/`
@@ -6,6 +6,7 @@ import { TASK_REMINDER_DEFAULT, TASK_REMINDER_EMAIL_CODE } from './email-templat
6
6
  import { Task } from './entities/task.entity.js';
7
7
  import { TaskAssignee } from './entities/task-assignee.entity.js';
8
8
  import { TaskAttachment } from './entities/task-attachment.entity.js';
9
+ import { TaskValueChange } from './entities/task-value-change.entity.js';
9
10
  import { TaskComment } from './entities/task-comment.entity.js';
10
11
  import { TaskDigestSubscription } from './entities/task-digest-subscription.entity.js';
11
12
  import { TaskListSavedView } from './entities/task-list-saved-view.entity.js';
@@ -52,6 +53,7 @@ import { TaskContextRegistry } from './services/task-context-registry.js';
52
53
  import { createTaskEmail } from './services/task-email.js';
53
54
  import { TaskHistoryService } from './services/task-history-service.js';
54
55
  import { TaskMaintenanceService } from './services/maintenance-service.js';
56
+ import { TaskTimeZoneRederiveService } from './services/time-zone-rederive-service.js';
55
57
  import { createTaskNotifier } from './services/task-notifier.js';
56
58
  import { TaskReadPortService } from './services/task-read-port.js';
57
59
  import { TaskService } from './services/task-service.js';
@@ -62,7 +64,7 @@ import { TaskWorkflowRead } from './services/task-workflow-read.js';
62
64
  import { TaskWritePortService } from './services/task-write-port.js';
63
65
  import { createTaskTimeZoneValidator } from './services/time-zone-validator.js';
64
66
  import { TaskWorkflowConfigService } from './services/workflow-config-service.js';
65
- import { createTasksRemindersJob, startTasksReminders, TASKS_DIGEST_SCOPE_REASON, TASKS_MAINTENANCE_SCOPE_REASON, TASKS_REMINDERS_SCOPE_REASON, } from './workers/tasks-reminders-worker.js';
67
+ import { createTasksRemindersJob, startTasksReminders, TASKS_DIGEST_SCOPE_REASON, TASKS_MAINTENANCE_SCOPE_REASON, TASKS_REDERIVE_SCOPE_REASON, TASKS_REMINDERS_SCOPE_REASON, } from './workers/tasks-reminders-worker.js';
66
68
  export function registerModule(ctx) {
67
69
  // --- Context (research R-1, R-9) -------------------------------------------
68
70
  // The Task contexts other modules own. A **contribution seam**: registered
@@ -246,12 +248,15 @@ export function registerModule(ctx) {
246
248
  // The audit log is the history (`task-history-service.ts`).
247
249
  // `auditLogService` is a platform service, not a module's port.
248
250
  tasksHistoryService: ctx
249
- .asFunction(({ tasksTaskService, auditLogService, tasksVisibility, tasksAccess }) => new TaskHistoryService({
251
+ .asFunction(({ emFactory, tasksTaskService, auditLogService, tasksVisibility, tasksAccess, tasksOwnerReadChecks }) => new TaskHistoryService({
252
+ emFactory,
250
253
  tasks: tasksTaskService,
251
254
  visibility: tasksVisibility,
252
255
  access: tasksAccess,
253
256
  auditLog: auditLogService,
254
257
  adminUsers: lazyPort(ctx, 'adminUserReadPort'),
258
+ // Custom-field values only for `custom_fields:read` (#470; feature 162 P2 = a).
259
+ mayReadCustomFields: tasksOwnerReadChecks.customFields,
255
260
  }))
256
261
  .singleton(),
257
262
  });
@@ -523,12 +528,29 @@ export function registerModule(ctx) {
523
528
  tasksMaintenanceService: ctx
524
529
  .asFunction(({ emFactory, commandBus, taskContextRegistry, auditLogService }) => new TaskMaintenanceService({ emFactory, commandBus, contexts: taskContextRegistry, auditLog: auditLogService }))
525
530
  .singleton(),
531
+ // Issue #505 — due dates and relative reminders re-derived once the zone has changed.
532
+ tasksTimeZoneRederiveService: ctx
533
+ .asFunction(({ emFactory, commandBus, auditLogService }) => {
534
+ const settings = lazyPort(ctx, 'settingsReadPort');
535
+ return new TaskTimeZoneRederiveService({
536
+ emFactory,
537
+ commandBus,
538
+ auditLog: auditLogService,
539
+ timeZone: () => settings.get('tasks.time_zone', null, TaskTimeZoneSchema.shape.timeZone),
540
+ });
541
+ })
542
+ .singleton(),
526
543
  // What one tick of the clock runs, and the slower passes' cadence. Registered, so that
527
544
  // what a test drives (`runTasksRemindersJob`) is what the consumer runs:
528
545
  // presence, then each pass's probe, then its scope.
529
546
  tasksRemindersJob: ctx
530
- .asFunction(({ tasksReminderService, tasksDigestService, tasksMaintenanceService }) => createTasksRemindersJob({
547
+ .asFunction(({ tasksReminderService, tasksDigestService, tasksMaintenanceService, tasksTimeZoneRederiveService }) => createTasksRemindersJob({
531
548
  isPresent: () => effectiveState.isPresent('tasks'),
549
+ rederive: {
550
+ scopeReason: TASKS_REDERIVE_SCOPE_REASON,
551
+ hasWork: () => tasksTimeZoneRederiveService.hasWork(),
552
+ run: () => tasksTimeZoneRederiveService.pass(),
553
+ },
532
554
  reminders: {
533
555
  scopeReason: TASKS_REMINDERS_SCOPE_REASON,
534
556
  hasWork: (now) => tasksReminderService.hasWork(now),
@@ -630,6 +652,8 @@ export const entities = [
630
652
  TaskTag,
631
653
  TaskListSavedView,
632
654
  TaskDigestSubscription,
655
+ // Issue #470 — the values the platform audit log no longer carries.
656
+ TaskValueChange,
633
657
  ];
634
658
  /**
635
659
  * The door to `tasks_number_seq`, published **by name** on `./backend`, as
@@ -26,10 +26,11 @@ export interface UploadedTaskFile {
26
26
  * refuses to delete a file a Task uses (`task-asset-references.ts`). **An
27
27
  * attachment is private, live and never active content.**
28
28
  *
29
- * **The download link is resolved here**, through `assetsLibraryPort`, because
30
- * the library's own admin API is behind the library's permissions; it is
31
- * handed out only under a Task the caller may see — and a file attached to a
32
- * Task the caller may not see cannot be attached elsewhere to obtain one.
29
+ * **The download link is resolved here**, through `assetReadPort.resolveUrls`
30
+ * in one batch per list (issue #545), because the library's own admin API is
31
+ * behind the library's permissions; it is handed out only under a Task the
32
+ * caller may see — and a file attached to a Task the caller may not see cannot
33
+ * be attached elsewhere to obtain one.
33
34
  *
34
35
  * **The upload stores first and attaches second**, two writes in two modules
35
36
  * that cannot share a transaction: when attaching fails the stored file is
@@ -3,6 +3,7 @@ import { ERROR_CODES, } from '@endora-commerce/contracts';
3
3
  import { HttpError } from '@endora-commerce/platform/http';
4
4
  import { rethrowIfModuleDisabled } from '@endora-commerce/platform/kernel';
5
5
  import { TaskAttachment } from '../entities/task-attachment.entity.js';
6
+ import { recordTaskValueChange } from './task-audit-state.js';
6
7
  import { asDownloadLink, refuseActiveContent } from './attachment-active-content.js';
7
8
  import { actingAdminUserId, isUuid } from './task-access.js';
8
9
  const UNKNOWN_MIME_TYPE = 'application/octet-stream';
@@ -29,10 +30,11 @@ function adminName(admin) {
29
30
  * refuses to delete a file a Task uses (`task-asset-references.ts`). **An
30
31
  * attachment is private, live and never active content.**
31
32
  *
32
- * **The download link is resolved here**, through `assetsLibraryPort`, because
33
- * the library's own admin API is behind the library's permissions; it is
34
- * handed out only under a Task the caller may see — and a file attached to a
35
- * Task the caller may not see cannot be attached elsewhere to obtain one.
33
+ * **The download link is resolved here**, through `assetReadPort.resolveUrls`
34
+ * in one batch per list (issue #545), because the library's own admin API is
35
+ * behind the library's permissions; it is handed out only under a Task the
36
+ * caller may see — and a file attached to a Task the caller may not see cannot
37
+ * be attached elsewhere to obtain one.
36
38
  *
37
39
  * **The upload stores first and attaches second**, two writes in two modules
38
40
  * that cannot share a transaction: when attaching fails the stored file is
@@ -79,7 +81,11 @@ export class TaskAttachmentService {
79
81
  throw fileUnavailable();
80
82
  await this.#refuseAFileHeldOutOfSight(em, assetId);
81
83
  if (asset.visibility !== 'private') {
82
- throw new HttpError(422, ERROR_CODES.VALIDATION_FAILED, 'An attachment must be a private file. Upload it to the media library as private.');
84
+ // The file's visibility refuses a well-formed request, so this is the
85
+ // module's attachment refusal, not `VALIDATION_FAILED` (issue #642).
86
+ // `code` is the refusal token that picks the sentence; `reason` is the
87
+ // member a screen reads, as the size and active-content refusals carry.
88
+ throw new HttpError(422, ERROR_CODES.TASK_ATTACHMENT_REFUSED, 'An attachment must be a private file. Upload it to the media library as private.', { code: 'not_private', reason: 'not_private', assetId, visibility: asset.visibility });
83
89
  }
84
90
  refuseActiveContent({ filename: asset.filename, mimeType: asset.mimeType });
85
91
  let row;
@@ -94,10 +100,15 @@ export class TaskAttachmentService {
94
100
  assetId,
95
101
  addedByAdminUserId: uploader,
96
102
  });
103
+ // A file's name is free text: it goes to the Task's own store (#470).
104
+ const values = recordTaskValueChange(tx, task.id, {
105
+ before: null,
106
+ after: { fileName: asset.filename },
107
+ });
97
108
  return {
98
109
  result: created,
99
110
  before: null,
100
- after: { attachmentId: created.id, assetId, fileName: asset.filename },
111
+ after: { attachmentId: created.id, assetId, ...values },
101
112
  };
102
113
  },
103
114
  });
@@ -213,10 +224,15 @@ export class TaskAttachmentService {
213
224
  ]);
214
225
  const assetById = new Map(assets.map((asset) => [asset.id, asset]));
215
226
  const names = new Map(uploaders.map((admin) => [admin.id, adminName(admin)]));
227
+ // One batched read for every file that is still there, and none for one
228
+ // that is gone. `resolveUrls` answers the URL the asset detail carries —
229
+ // signed and expiring for a private file — without the detail's "used by"
230
+ // list, which asked every reference descriptor about each file (#545).
231
+ const live = assets.map((asset) => asset.id);
232
+ const resolved = live.length > 0 ? await this.deps.assets.resolveUrls(live) : new Map();
216
233
  const urls = new Map();
217
- for (const asset of assets) {
218
- urls.set(asset.id, asDownloadLink((await this.deps.assetsLibrary.getAsset(asset.id)).url, asset.id));
219
- }
234
+ for (const [assetId, url] of resolved)
235
+ urls.set(assetId, asDownloadLink(url, assetId));
220
236
  return rows.map((row) => {
221
237
  const asset = assetById.get(row.assetId);
222
238
  const size = asset ? Number(asset.sizeBytes) : 0;
@@ -191,6 +191,7 @@ export class TaskDigestService {
191
191
  if (!(await this.deps.audience(adminUserId, facts)))
192
192
  continue;
193
193
  visible.push({
194
+ taskId: row.id,
194
195
  number: row.number,
195
196
  title: row.title,
196
197
  dueOn: row.due_on,
@@ -31,6 +31,8 @@ export declare const PROJECTS_READ_PERMISSION = "projects:read";
31
31
  * here: a reader without it sees no Task.
32
32
  */
33
33
  export declare const TASKS_READ_PERMISSION = "tasks:read";
34
+ /** `custom_fields`' read permission: a Task's custom-field values in its history (#470, feature 162 P2 = a). */
35
+ export declare const CUSTOM_FIELDS_READ_PERMISSION = "custom_fields:read";
34
36
  /** Whether whoever is behind the request may read what one other module owns. */
35
37
  export type OwnerReadCheck = () => Promise<boolean>;
36
38
  /** The checks a service that renders another module's data is handed. */
@@ -40,6 +42,7 @@ export interface OwnerReadChecks {
40
42
  quoteRequests: OwnerReadCheck;
41
43
  opportunities: OwnerReadCheck;
42
44
  projects: OwnerReadCheck;
45
+ customFields: OwnerReadCheck;
43
46
  }
44
47
  /**
45
48
  * One check. A function rather than a literal at the composition site:
@@ -33,6 +33,8 @@ export const PROJECTS_READ_PERMISSION = 'projects:read';
33
33
  * here: a reader without it sees no Task.
34
34
  */
35
35
  export const TASKS_READ_PERMISSION = 'tasks:read';
36
+ /** `custom_fields`' read permission: a Task's custom-field values in its history (#470, feature 162 P2 = a). */
37
+ export const CUSTOM_FIELDS_READ_PERMISSION = 'custom_fields:read';
36
38
  /**
37
39
  * One check. A function rather than a literal at the composition site:
38
40
  * `check:port-catches` follows the port through the value.
@@ -53,6 +55,7 @@ export function createOwnerReadChecks(permissions) {
53
55
  quoteRequests: createOwnerReadCheck(permissions, QUOTE_REQUESTS_READ_PERMISSION),
54
56
  opportunities: createOwnerReadCheck(permissions, CRM_READ_PERMISSION),
55
57
  projects: createOwnerReadCheck(permissions, PROJECTS_READ_PERMISSION),
58
+ customFields: createOwnerReadCheck(permissions, CUSTOM_FIELDS_READ_PERMISSION),
56
59
  };
57
60
  }
58
61
  //# sourceMappingURL=owner-read-permissions.js.map
@@ -1,5 +1,4 @@
1
1
  import { extractRecordReferenceTokens, } from '@endora-commerce/contracts';
2
- import { actingAdminUserId } from './task-access.js';
3
2
  /** The tokens of a text — none for a text that is not there. A malformed token is text. */
4
3
  export function referenceTokensOf(text) {
5
4
  return text ? extractRecordReferenceTokens(text) : [];
@@ -23,7 +22,6 @@ export function referenceRowsFor(source, text) {
23
22
  }
24
23
  return rows;
25
24
  }
26
- const FALLBACK_LANGUAGE = 'en';
27
25
  /** Where a chip leads. A person leads nowhere: an administrator's screen is `admin_users`'. */
28
26
  function adminUrl(token) {
29
27
  switch (token.type) {
@@ -43,7 +41,6 @@ function adminUrl(token) {
43
41
  return `/projects/${token.id}`;
44
42
  }
45
43
  }
46
- /** A Product's name in the reader's language, then any name of that language, then any name, then its SKU. */
47
44
  function isActive(person) {
48
45
  return person.status === 'active' && person.deletedAt === null;
49
46
  }
@@ -112,12 +109,11 @@ export class TaskReferenceService {
112
109
  productIds.length > 0 ? this.deps.mayRead.products() : Promise.resolve(false),
113
110
  orderIds.length > 0 ? this.deps.mayRead.orders() : Promise.resolve(false),
114
111
  ]);
115
- const [products, orders, people, tasks, _language, switchable] = await Promise.all([
112
+ const [products, orders, people, tasks, switchable] = await Promise.all([
116
113
  mayReadProducts ? this.deps.products.findByIds(productIds, { liveOnly: true }) : Promise.resolve([]),
117
114
  mayReadOrders ? this.deps.orders.findByIds(orderIds) : Promise.resolve([]),
118
115
  personIds.length > 0 ? this.deps.adminUsers.findByIds(personIds) : Promise.resolve([]),
119
116
  taskIds.length > 0 ? this.deps.tasks(taskIds) : Promise.resolve([]),
120
- mayReadProducts ? this.#viewerLanguage() : Promise.resolve(FALLBACK_LANGUAGE),
121
117
  Promise.all(Object.keys(SWITCHABLE).map(async (kind) => {
122
118
  const ids = idsOf(kind);
123
119
  // Presence first, then the reader's code, then the port.
@@ -167,13 +163,5 @@ export class TaskReferenceService {
167
163
  };
168
164
  }));
169
165
  }
170
- /** The reader's stored language — what the Admin UI renders in — or English. */
171
- async #viewerLanguage() {
172
- const reader = actingAdminUserId();
173
- if (reader === null)
174
- return FALLBACK_LANGUAGE;
175
- const admin = await this.deps.adminUsers.findById(reader);
176
- return admin?.preferredLanguage ?? FALLBACK_LANGUAGE;
177
- }
178
166
  }
179
167
  //# sourceMappingURL=reference-service.js.map
@@ -23,6 +23,7 @@ export declare function dueMomentOf(due: {
23
23
  * that is how the reminder's creator is told on the Task.
24
24
  *
25
25
  * Absolute reminders are the caller's chosen moments and are never touched.
26
+ * Answers how many relative reminders moved (none when they were removed).
26
27
  */
27
- export declare function followDueMoment(em: EntityManager, auditLog: AuditPort, taskId: string, moment: Date | null): Promise<void>;
28
+ export declare function followDueMoment(em: EntityManager, auditLog: AuditPort, taskId: string, moment: Date | null): Promise<number>;
28
29
  //# sourceMappingURL=reminder-schedule.d.ts.map
@@ -25,6 +25,7 @@ export function dueMomentOf(due, timeZone) {
25
25
  * that is how the reminder's creator is told on the Task.
26
26
  *
27
27
  * Absolute reminders are the caller's chosen moments and are never touched.
28
+ * Answers how many relative reminders moved (none when they were removed).
28
29
  */
29
30
  export async function followDueMoment(em, auditLog, taskId, moment) {
30
31
  if (moment === null) {
@@ -46,15 +47,18 @@ export async function followDueMoment(em, auditLog, taskId, moment) {
46
47
  stateAfter: null,
47
48
  });
48
49
  }
49
- return;
50
+ return 0;
50
51
  }
51
- await em.execute(`with "moved" as (
52
+ const moved = (await em.execute(`with "moved" as (
52
53
  update "task_reminders"
53
54
  set "remind_at" = ?::timestamptz - make_interval(mins => "offset_minutes")
54
55
  where "task_id" = ? and "mode" = 'relative'
55
56
  and "remind_at" <> ?::timestamptz - make_interval(mins => "offset_minutes")
56
57
  returning "id"
58
+ ), "rearmed" as (
59
+ delete from "task_reminder_deliveries" d using "moved" m where d."reminder_id" = m."id"
57
60
  )
58
- delete from "task_reminder_deliveries" d using "moved" m where d."reminder_id" = m."id"`, [moment, taskId, moment]);
61
+ select count(*)::int as "moved" from "moved"`, [moment, taskId, moment]));
62
+ return Number(moved[0]?.moved ?? 0);
59
63
  }
60
64
  //# sourceMappingURL=reminder-schedule.js.map