@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.
- package/dist/admin/components/TaskCustomFields.js +2 -13
- package/dist/backend/email-templates/digest-defaults.d.ts +14 -7
- package/dist/backend/email-templates/digest-defaults.js +39 -19
- package/dist/backend/email-templates/reminder-defaults.d.ts +7 -3
- package/dist/backend/email-templates/reminder-defaults.js +11 -3
- package/dist/backend/entities/task-value-change.entity.d.ts +27 -0
- package/dist/backend/entities/task-value-change.entity.js +62 -0
- package/dist/backend/index.d.ts +2 -1
- package/dist/backend/index.js +27 -3
- package/dist/backend/services/attachment-service.d.ts +5 -4
- package/dist/backend/services/attachment-service.js +25 -9
- package/dist/backend/services/digest-service.js +1 -0
- package/dist/backend/services/owner-read-permissions.d.ts +3 -0
- package/dist/backend/services/owner-read-permissions.js +3 -0
- package/dist/backend/services/reference-service.js +1 -13
- package/dist/backend/services/reminder-schedule.d.ts +2 -1
- package/dist/backend/services/reminder-schedule.js +7 -3
- package/dist/backend/services/task-access.js +8 -0
- package/dist/backend/services/task-audit-state.d.ts +42 -0
- package/dist/backend/services/task-audit-state.js +98 -0
- package/dist/backend/services/task-commands.d.ts +38 -2
- package/dist/backend/services/task-commands.js +70 -7
- package/dist/backend/services/task-email.d.ts +8 -0
- package/dist/backend/services/task-email.js +18 -2
- package/dist/backend/services/task-history-service.d.ts +37 -0
- package/dist/backend/services/task-history-service.js +82 -7
- package/dist/backend/services/time-zone-rederive-service.d.ts +57 -0
- package/dist/backend/services/time-zone-rederive-service.js +105 -0
- package/dist/backend/workers/tasks-reminders-worker.d.ts +12 -6
- package/dist/backend/workers/tasks-reminders-worker.js +13 -6
- package/dist/manifest.d.ts +25 -1
- package/dist/manifest.js +35 -1
- package/dist/migrations/20261110T054810_tasks_value_changes.d.ts +23 -0
- package/dist/migrations/20261110T054810_tasks_value_changes.js +39 -0
- package/dist/migrations/index.d.ts +2 -1
- package/dist/migrations/index.js +7 -2
- package/docs/tasks.md +37 -8
- package/i18n/en.json +1 -0
- package/i18n/pl.json +1 -0
- package/package.json +11 -10
- package/dist/admin/api.d.ts.map +0 -1
- package/dist/admin/api.js.map +0 -1
- package/dist/admin/components/AssigneePicker.d.ts.map +0 -1
- package/dist/admin/components/AssigneePicker.js.map +0 -1
- package/dist/admin/components/BoardCardFieldsEditor.d.ts.map +0 -1
- package/dist/admin/components/BoardCardFieldsEditor.js.map +0 -1
- package/dist/admin/components/ContextLabel.d.ts.map +0 -1
- package/dist/admin/components/ContextLabel.js.map +0 -1
- package/dist/admin/components/ContextSection.d.ts.map +0 -1
- package/dist/admin/components/ContextSection.js.map +0 -1
- package/dist/admin/components/DigestControl.d.ts.map +0 -1
- package/dist/admin/components/DigestControl.js.map +0 -1
- package/dist/admin/components/LinkedRecordsSection.d.ts.map +0 -1
- package/dist/admin/components/LinkedRecordsSection.js.map +0 -1
- package/dist/admin/components/LookupPicker.d.ts.map +0 -1
- package/dist/admin/components/LookupPicker.js.map +0 -1
- package/dist/admin/components/RelatedTasksSection.d.ts.map +0 -1
- package/dist/admin/components/RelatedTasksSection.js.map +0 -1
- package/dist/admin/components/RemindersSection.d.ts.map +0 -1
- package/dist/admin/components/RemindersSection.js.map +0 -1
- package/dist/admin/components/StatusBadge.d.ts.map +0 -1
- package/dist/admin/components/StatusBadge.js.map +0 -1
- package/dist/admin/components/SubtasksSection.d.ts.map +0 -1
- package/dist/admin/components/SubtasksSection.js.map +0 -1
- package/dist/admin/components/TaskAttachments.d.ts.map +0 -1
- package/dist/admin/components/TaskAttachments.js.map +0 -1
- package/dist/admin/components/TaskBoard.d.ts.map +0 -1
- package/dist/admin/components/TaskBoard.js.map +0 -1
- package/dist/admin/components/TaskCard.d.ts.map +0 -1
- package/dist/admin/components/TaskCard.js.map +0 -1
- package/dist/admin/components/TaskComments.d.ts.map +0 -1
- package/dist/admin/components/TaskComments.js.map +0 -1
- package/dist/admin/components/TaskCustomFields.d.ts.map +0 -1
- package/dist/admin/components/TaskCustomFields.js.map +0 -1
- package/dist/admin/components/TaskFieldInputs.d.ts.map +0 -1
- package/dist/admin/components/TaskFieldInputs.js.map +0 -1
- package/dist/admin/components/TaskFilters.d.ts.map +0 -1
- package/dist/admin/components/TaskFilters.js.map +0 -1
- package/dist/admin/components/TaskMarkers.d.ts.map +0 -1
- package/dist/admin/components/TaskMarkers.js.map +0 -1
- package/dist/admin/components/TaskPicker.d.ts.map +0 -1
- package/dist/admin/components/TaskPicker.js.map +0 -1
- package/dist/admin/components/ViewModeToggle.d.ts.map +0 -1
- package/dist/admin/components/ViewModeToggle.js.map +0 -1
- package/dist/admin/components/priorities/TaskPriorityDeleteDialog.d.ts.map +0 -1
- package/dist/admin/components/priorities/TaskPriorityDeleteDialog.js.map +0 -1
- package/dist/admin/components/priorities/TaskPriorityDialog.d.ts.map +0 -1
- package/dist/admin/components/priorities/TaskPriorityDialog.js.map +0 -1
- package/dist/admin/components/tags/TaskTagDeleteDialog.d.ts.map +0 -1
- package/dist/admin/components/tags/TaskTagDeleteDialog.js.map +0 -1
- package/dist/admin/components/tags/TaskTagDialog.d.ts.map +0 -1
- package/dist/admin/components/tags/TaskTagDialog.js.map +0 -1
- package/dist/admin/components/task-columns.d.ts.map +0 -1
- package/dist/admin/components/task-columns.js.map +0 -1
- package/dist/admin/components/workflow/TaskStatusDeleteDialog.d.ts.map +0 -1
- package/dist/admin/components/workflow/TaskStatusDeleteDialog.js.map +0 -1
- package/dist/admin/components/workflow/TaskStatusDialog.d.ts.map +0 -1
- package/dist/admin/components/workflow/TaskStatusDialog.js.map +0 -1
- package/dist/admin/components/workflow/TaskStatusesTable.d.ts.map +0 -1
- package/dist/admin/components/workflow/TaskStatusesTable.js.map +0 -1
- package/dist/admin/index.d.ts.map +0 -1
- package/dist/admin/index.js.map +0 -1
- package/dist/admin/lib/current-admin.d.ts.map +0 -1
- package/dist/admin/lib/current-admin.js.map +0 -1
- package/dist/admin/lib/labels.d.ts.map +0 -1
- package/dist/admin/lib/labels.js.map +0 -1
- package/dist/admin/lib/references.d.ts.map +0 -1
- package/dist/admin/lib/references.js.map +0 -1
- package/dist/admin/lib/settings-paths.d.ts.map +0 -1
- package/dist/admin/lib/settings-paths.js.map +0 -1
- package/dist/admin/lib/task-filters.d.ts.map +0 -1
- package/dist/admin/lib/task-filters.js.map +0 -1
- package/dist/admin/lib/use-editor-focus.d.ts.map +0 -1
- package/dist/admin/lib/use-editor-focus.js.map +0 -1
- package/dist/admin/lib/use-task-vocabulary.d.ts.map +0 -1
- package/dist/admin/lib/use-task-vocabulary.js.map +0 -1
- package/dist/admin/pages/MyTasksPage.d.ts.map +0 -1
- package/dist/admin/pages/MyTasksPage.js.map +0 -1
- package/dist/admin/pages/TaskCreate.d.ts.map +0 -1
- package/dist/admin/pages/TaskCreate.js.map +0 -1
- package/dist/admin/pages/TaskDetail.d.ts.map +0 -1
- package/dist/admin/pages/TaskDetail.js.map +0 -1
- package/dist/admin/pages/TasksPage.d.ts.map +0 -1
- package/dist/admin/pages/TasksPage.js.map +0 -1
- package/dist/admin/pages/settings/TaskGeneralSettingsPage.d.ts.map +0 -1
- package/dist/admin/pages/settings/TaskGeneralSettingsPage.js.map +0 -1
- package/dist/admin/pages/settings/TaskPrioritiesPage.d.ts.map +0 -1
- package/dist/admin/pages/settings/TaskPrioritiesPage.js.map +0 -1
- package/dist/admin/pages/settings/TaskTagsPage.d.ts.map +0 -1
- package/dist/admin/pages/settings/TaskTagsPage.js.map +0 -1
- package/dist/admin/pages/settings/TaskWorkflowPage.d.ts.map +0 -1
- package/dist/admin/pages/settings/TaskWorkflowPage.js.map +0 -1
- package/dist/admin/zones/OpportunityTasksPanel.d.ts.map +0 -1
- package/dist/admin/zones/OpportunityTasksPanel.js.map +0 -1
- package/dist/admin/zones/OrderTasksPanel.d.ts.map +0 -1
- package/dist/admin/zones/OrderTasksPanel.js.map +0 -1
- package/dist/admin/zones/QuoteRequestTasksPanel.d.ts.map +0 -1
- package/dist/admin/zones/QuoteRequestTasksPanel.js.map +0 -1
- package/dist/admin/zones/TasksPanel.d.ts.map +0 -1
- package/dist/admin/zones/TasksPanel.js.map +0 -1
- package/dist/backend/admin-search-provider.d.ts.map +0 -1
- package/dist/backend/admin-search-provider.js.map +0 -1
- package/dist/backend/domain/board-card-fields.d.ts.map +0 -1
- package/dist/backend/domain/board-card-fields.js.map +0 -1
- package/dist/backend/domain/due-moment.d.ts.map +0 -1
- package/dist/backend/domain/due-moment.js.map +0 -1
- package/dist/backend/domain/hierarchy.d.ts.map +0 -1
- package/dist/backend/domain/hierarchy.js.map +0 -1
- package/dist/backend/domain/list-cursor.d.ts.map +0 -1
- package/dist/backend/domain/list-cursor.js.map +0 -1
- package/dist/backend/domain/task-status-graph.d.ts.map +0 -1
- package/dist/backend/domain/task-status-graph.js.map +0 -1
- package/dist/backend/email-templates/digest-defaults.d.ts.map +0 -1
- package/dist/backend/email-templates/digest-defaults.js.map +0 -1
- package/dist/backend/email-templates/reminder-defaults.d.ts.map +0 -1
- package/dist/backend/email-templates/reminder-defaults.js.map +0 -1
- package/dist/backend/entities/task-assignee.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-assignee.entity.js.map +0 -1
- package/dist/backend/entities/task-attachment.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-attachment.entity.js.map +0 -1
- package/dist/backend/entities/task-comment.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-comment.entity.js.map +0 -1
- package/dist/backend/entities/task-digest-subscription.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-digest-subscription.entity.js.map +0 -1
- package/dist/backend/entities/task-list-saved-view.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-list-saved-view.entity.js.map +0 -1
- package/dist/backend/entities/task-priority.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-priority.entity.js.map +0 -1
- package/dist/backend/entities/task-record-link.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-record-link.entity.js.map +0 -1
- package/dist/backend/entities/task-reference.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-reference.entity.js.map +0 -1
- package/dist/backend/entities/task-relation.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-relation.entity.js.map +0 -1
- package/dist/backend/entities/task-reminder-delivery.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-reminder-delivery.entity.js.map +0 -1
- package/dist/backend/entities/task-reminder.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-reminder.entity.js.map +0 -1
- package/dist/backend/entities/task-status-transition.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-status-transition.entity.js.map +0 -1
- package/dist/backend/entities/task-status.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-status.entity.js.map +0 -1
- package/dist/backend/entities/task-tag-assignment.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-tag-assignment.entity.js.map +0 -1
- package/dist/backend/entities/task-tag.entity.d.ts.map +0 -1
- package/dist/backend/entities/task-tag.entity.js.map +0 -1
- package/dist/backend/entities/task.entity.d.ts.map +0 -1
- package/dist/backend/entities/task.entity.js.map +0 -1
- package/dist/backend/index.d.ts.map +0 -1
- package/dist/backend/index.js.map +0 -1
- package/dist/backend/routes/routes.board.d.ts.map +0 -1
- package/dist/backend/routes/routes.board.js.map +0 -1
- package/dist/backend/routes/routes.collaboration.d.ts.map +0 -1
- package/dist/backend/routes/routes.collaboration.js.map +0 -1
- package/dist/backend/routes/routes.priorities.d.ts.map +0 -1
- package/dist/backend/routes/routes.priorities.js.map +0 -1
- package/dist/backend/routes/routes.reminders.d.ts.map +0 -1
- package/dist/backend/routes/routes.reminders.js.map +0 -1
- package/dist/backend/routes/routes.settings.d.ts.map +0 -1
- package/dist/backend/routes/routes.settings.js.map +0 -1
- package/dist/backend/routes/routes.tags.d.ts.map +0 -1
- package/dist/backend/routes/routes.tags.js.map +0 -1
- package/dist/backend/routes/routes.tasks.d.ts.map +0 -1
- package/dist/backend/routes/routes.tasks.js.map +0 -1
- package/dist/backend/routes/routes.views.d.ts.map +0 -1
- package/dist/backend/routes/routes.views.js.map +0 -1
- package/dist/backend/routes/routes.workflow.d.ts.map +0 -1
- package/dist/backend/routes/routes.workflow.js.map +0 -1
- package/dist/backend/saved-view-actor.d.ts.map +0 -1
- package/dist/backend/saved-view-actor.js.map +0 -1
- package/dist/backend/services/attachment-active-content.d.ts.map +0 -1
- package/dist/backend/services/attachment-active-content.js.map +0 -1
- package/dist/backend/services/attachment-service.d.ts.map +0 -1
- package/dist/backend/services/attachment-service.js.map +0 -1
- package/dist/backend/services/board-card-field-service.d.ts.map +0 -1
- package/dist/backend/services/board-card-field-service.js.map +0 -1
- package/dist/backend/services/board-service.d.ts.map +0 -1
- package/dist/backend/services/board-service.js.map +0 -1
- package/dist/backend/services/comment-service.d.ts.map +0 -1
- package/dist/backend/services/comment-service.js.map +0 -1
- package/dist/backend/services/context-lookup.d.ts.map +0 -1
- package/dist/backend/services/context-lookup.js.map +0 -1
- package/dist/backend/services/digest-service.d.ts.map +0 -1
- package/dist/backend/services/digest-service.js.map +0 -1
- package/dist/backend/services/document-lookup-service.d.ts.map +0 -1
- package/dist/backend/services/document-lookup-service.js.map +0 -1
- package/dist/backend/services/hierarchy-service.d.ts.map +0 -1
- package/dist/backend/services/hierarchy-service.js.map +0 -1
- package/dist/backend/services/maintenance-service.d.ts.map +0 -1
- package/dist/backend/services/maintenance-service.js.map +0 -1
- package/dist/backend/services/mention-service.d.ts.map +0 -1
- package/dist/backend/services/mention-service.js.map +0 -1
- package/dist/backend/services/owner-read-permissions.d.ts.map +0 -1
- package/dist/backend/services/owner-read-permissions.js.map +0 -1
- package/dist/backend/services/priority-service.d.ts.map +0 -1
- package/dist/backend/services/priority-service.js.map +0 -1
- package/dist/backend/services/record-link-service.d.ts.map +0 -1
- package/dist/backend/services/record-link-service.js.map +0 -1
- package/dist/backend/services/record-owners.d.ts.map +0 -1
- package/dist/backend/services/record-owners.js.map +0 -1
- package/dist/backend/services/reference-service.d.ts.map +0 -1
- package/dist/backend/services/reference-service.js.map +0 -1
- package/dist/backend/services/relation-service.d.ts.map +0 -1
- package/dist/backend/services/relation-service.js.map +0 -1
- package/dist/backend/services/reminder-schedule.d.ts.map +0 -1
- package/dist/backend/services/reminder-schedule.js.map +0 -1
- package/dist/backend/services/reminder-service.d.ts.map +0 -1
- package/dist/backend/services/reminder-service.js.map +0 -1
- package/dist/backend/services/saved-view-service.d.ts.map +0 -1
- package/dist/backend/services/saved-view-service.js.map +0 -1
- package/dist/backend/services/scheduled-work-probe.d.ts.map +0 -1
- package/dist/backend/services/scheduled-work-probe.js.map +0 -1
- package/dist/backend/services/tag-service.d.ts.map +0 -1
- package/dist/backend/services/tag-service.js.map +0 -1
- package/dist/backend/services/task-access.d.ts.map +0 -1
- package/dist/backend/services/task-access.js.map +0 -1
- package/dist/backend/services/task-asset-references.d.ts.map +0 -1
- package/dist/backend/services/task-asset-references.js.map +0 -1
- package/dist/backend/services/task-audit-references.d.ts.map +0 -1
- package/dist/backend/services/task-audit-references.js.map +0 -1
- package/dist/backend/services/task-checks.d.ts.map +0 -1
- package/dist/backend/services/task-checks.js.map +0 -1
- package/dist/backend/services/task-commands.d.ts.map +0 -1
- package/dist/backend/services/task-commands.js.map +0 -1
- package/dist/backend/services/task-context-registry.d.ts.map +0 -1
- package/dist/backend/services/task-context-registry.js.map +0 -1
- package/dist/backend/services/task-custom-fields.d.ts.map +0 -1
- package/dist/backend/services/task-custom-fields.js.map +0 -1
- package/dist/backend/services/task-email.d.ts.map +0 -1
- package/dist/backend/services/task-email.js.map +0 -1
- package/dist/backend/services/task-errors.d.ts.map +0 -1
- package/dist/backend/services/task-errors.js.map +0 -1
- package/dist/backend/services/task-history-service.d.ts.map +0 -1
- package/dist/backend/services/task-history-service.js.map +0 -1
- package/dist/backend/services/task-notifier.d.ts.map +0 -1
- package/dist/backend/services/task-notifier.js.map +0 -1
- package/dist/backend/services/task-number.d.ts.map +0 -1
- package/dist/backend/services/task-number.js.map +0 -1
- package/dist/backend/services/task-read-port.d.ts.map +0 -1
- package/dist/backend/services/task-read-port.js.map +0 -1
- package/dist/backend/services/task-reassignment.d.ts.map +0 -1
- package/dist/backend/services/task-reassignment.js.map +0 -1
- package/dist/backend/services/task-service.d.ts.map +0 -1
- package/dist/backend/services/task-service.js.map +0 -1
- package/dist/backend/services/task-settings-service.d.ts.map +0 -1
- package/dist/backend/services/task-settings-service.js.map +0 -1
- package/dist/backend/services/task-transition-service.d.ts.map +0 -1
- package/dist/backend/services/task-transition-service.js.map +0 -1
- package/dist/backend/services/task-visibility.d.ts.map +0 -1
- package/dist/backend/services/task-visibility.js.map +0 -1
- package/dist/backend/services/task-workflow-read.d.ts.map +0 -1
- package/dist/backend/services/task-workflow-read.js.map +0 -1
- package/dist/backend/services/task-write-port.d.ts.map +0 -1
- package/dist/backend/services/task-write-port.js.map +0 -1
- package/dist/backend/services/time-zone-validator.d.ts.map +0 -1
- package/dist/backend/services/time-zone-validator.js.map +0 -1
- package/dist/backend/services/workflow-config-service.d.ts.map +0 -1
- package/dist/backend/services/workflow-config-service.js.map +0 -1
- package/dist/backend/workers/tasks-reminders-worker.d.ts.map +0 -1
- package/dist/backend/workers/tasks-reminders-worker.js.map +0 -1
- package/dist/manifest.d.ts.map +0 -1
- package/dist/manifest.js.map +0 -1
- package/dist/migrations/20261026T133731_tasks_init.d.ts.map +0 -1
- package/dist/migrations/20261026T133731_tasks_init.js.map +0 -1
- package/dist/migrations/20261028T140002_tasks_task_management.d.ts.map +0 -1
- package/dist/migrations/20261028T140002_tasks_task_management.js.map +0 -1
- package/dist/migrations/index.d.ts.map +0 -1
- package/dist/migrations/index.js.map +0 -1
|
@@ -84,10 +84,18 @@ export const TASK_ACCESS_READERS = {
|
|
|
84
84
|
'walks the distinct context ids of each context type whose present owner can say which still exist, and reads ' +
|
|
85
85
|
'the ids of the Tasks of the contexts the owner says are gone, or whose group is — handing each to the delete or ' +
|
|
86
86
|
'ungroup Command, which re-reads it under the lock. Nothing read is shown or sent to anybody.',
|
|
87
|
+
'services/time-zone-rederive-service.ts': 'The #505 time-zone pass, run in the system scope its worker enters (its probe answers one bit, outside any ' +
|
|
88
|
+
'scope): it reads the ids and due moments of the Tasks whose `due_on` or relative reminders are out of step ' +
|
|
89
|
+
'with `tasks.time_zone`, platform-wide on purpose, and hands each to the re-derive Command, which re-reads it ' +
|
|
90
|
+
'under the lock. Nothing read is shown or sent to anybody.',
|
|
87
91
|
'services/task-write-port.ts': '`deleteInContext` lists the ids of one context for its owner — the module that registered the context type ' +
|
|
88
92
|
'and is deleting its own record — and hands each to the delete Command. `createMany` looks up which of the ' +
|
|
89
93
|
'source keys it was handed that one context already holds, for the same owner, and answers their ids in their ' +
|
|
90
94
|
'place: ids of Tasks that owner created in its own record (R-19).',
|
|
95
|
+
'services/task-history-service.ts': 'The Task\'s own value store (`task_value_changes`, issue #470) is read only after `findVisibleRow` handed ' +
|
|
96
|
+
'out the Task, keyed by that Task\'s id and the row ids its audit entries point at — a pointer to another ' +
|
|
97
|
+
'Task\'s row reads nothing — and what it holds is served through the same context and Task-id redaction as ' +
|
|
98
|
+
'the entries themselves.',
|
|
91
99
|
};
|
|
92
100
|
/** The columns of {@link TaskRow}, over `tasks` aliased `t`. */
|
|
93
101
|
export const TASK_COLUMNS = `t."id", t."number", t."title", t."description", t."status",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { EntityManager } from '@mikro-orm/postgresql';
|
|
2
|
+
import { type TaskValueState } from '../entities/task-value-change.entity.js';
|
|
3
|
+
/**
|
|
4
|
+
* What a `tasks.*` audit entry may say about a Task, and where the rest goes
|
|
5
|
+
* (issue #470, D-288; `specs/conventions/audit-state.md`).
|
|
6
|
+
*
|
|
7
|
+
* The platform audit log is one global table read under `audit_log:read`, so a
|
|
8
|
+
* Task's entry carries names and structure: its number, codes, dates, ids,
|
|
9
|
+
* booleans, lengths and the names of what changed. Its title (owner ruling O-1,
|
|
10
|
+
* 2026-11-10: a title is a value), its context note, its custom-field values
|
|
11
|
+
* and an attachment's file name go to `task_value_changes`, written in the same
|
|
12
|
+
* Command; the entry carries that row's id as `valueChangeId`, and the Task's
|
|
13
|
+
* history serves the values from there (`task-history-service.ts`).
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Every top-level key a Task's audit snapshot may hold. A new field of the
|
|
17
|
+
* snapshot is a value until somebody classifies it on purpose —
|
|
18
|
+
* `task-audit-sentinels.test.ts` holds the snapshot to this list.
|
|
19
|
+
*/
|
|
20
|
+
export declare const TASKS_AUDIT_KEYS: ReadonlySet<string>;
|
|
21
|
+
/** What an audit entry says of a value change: the names, and the store row. */
|
|
22
|
+
export interface TaskValueChangeKeys {
|
|
23
|
+
changedFields?: string[];
|
|
24
|
+
changedCustomFields?: string[];
|
|
25
|
+
valueChangeId?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Record what a write changed among the values the audit log may not hold:
|
|
29
|
+
* a {@link TaskValueChange} row in the Command's transaction, and the keys the
|
|
30
|
+
* entry carries instead (`changedFields`, `changedCustomFields`, sorted and
|
|
31
|
+
* each only when non-empty; `valueChangeId`). `before: null` is something that
|
|
32
|
+
* only arrived, `after: null` something that went; `customFieldValues` is
|
|
33
|
+
* compared key by key. Nothing changed writes no row and answers `{}`.
|
|
34
|
+
*
|
|
35
|
+
* Call it inside a Command, with that Command's EntityManager and a Task that
|
|
36
|
+
* was reached through `TaskAccess`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function recordTaskValueChange(em: EntityManager, taskId: string, change: {
|
|
39
|
+
before: TaskValueState | null;
|
|
40
|
+
after: TaskValueState | null;
|
|
41
|
+
}): TaskValueChangeKeys;
|
|
42
|
+
//# sourceMappingURL=task-audit-state.d.ts.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { TaskValueChange } from '../entities/task-value-change.entity.js';
|
|
3
|
+
/**
|
|
4
|
+
* What a `tasks.*` audit entry may say about a Task, and where the rest goes
|
|
5
|
+
* (issue #470, D-288; `specs/conventions/audit-state.md`).
|
|
6
|
+
*
|
|
7
|
+
* The platform audit log is one global table read under `audit_log:read`, so a
|
|
8
|
+
* Task's entry carries names and structure: its number, codes, dates, ids,
|
|
9
|
+
* booleans, lengths and the names of what changed. Its title (owner ruling O-1,
|
|
10
|
+
* 2026-11-10: a title is a value), its context note, its custom-field values
|
|
11
|
+
* and an attachment's file name go to `task_value_changes`, written in the same
|
|
12
|
+
* Command; the entry carries that row's id as `valueChangeId`, and the Task's
|
|
13
|
+
* history serves the values from there (`task-history-service.ts`).
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Every top-level key a Task's audit snapshot may hold. A new field of the
|
|
17
|
+
* snapshot is a value until somebody classifies it on purpose —
|
|
18
|
+
* `task-audit-sentinels.test.ts` holds the snapshot to this list.
|
|
19
|
+
*/
|
|
20
|
+
export const TASKS_AUDIT_KEYS = new Set([
|
|
21
|
+
'number',
|
|
22
|
+
'descriptionLength',
|
|
23
|
+
'status',
|
|
24
|
+
'dueOn',
|
|
25
|
+
'dueAt',
|
|
26
|
+
'startOn',
|
|
27
|
+
'completedAt',
|
|
28
|
+
'contextType',
|
|
29
|
+
'contextId',
|
|
30
|
+
'contextGroupId',
|
|
31
|
+
'changedFields',
|
|
32
|
+
'changedCustomFields',
|
|
33
|
+
'valueChangeId',
|
|
34
|
+
// Issue #505 — a code and a count on the entry of a changed time zone.
|
|
35
|
+
'reason',
|
|
36
|
+
'remindersMoved',
|
|
37
|
+
]);
|
|
38
|
+
function isEmpty(value) {
|
|
39
|
+
return value === null || value === undefined || (Array.isArray(value) && value.length === 0);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Record what a write changed among the values the audit log may not hold:
|
|
43
|
+
* a {@link TaskValueChange} row in the Command's transaction, and the keys the
|
|
44
|
+
* entry carries instead (`changedFields`, `changedCustomFields`, sorted and
|
|
45
|
+
* each only when non-empty; `valueChangeId`). `before: null` is something that
|
|
46
|
+
* only arrived, `after: null` something that went; `customFieldValues` is
|
|
47
|
+
* compared key by key. Nothing changed writes no row and answers `{}`.
|
|
48
|
+
*
|
|
49
|
+
* Call it inside a Command, with that Command's EntityManager and a Task that
|
|
50
|
+
* was reached through `TaskAccess`.
|
|
51
|
+
*/
|
|
52
|
+
export function recordTaskValueChange(em, taskId, change) {
|
|
53
|
+
const before = change.before ?? {};
|
|
54
|
+
const after = change.after ?? {};
|
|
55
|
+
const changedFields = [];
|
|
56
|
+
const changedCustomFields = [];
|
|
57
|
+
const storedBefore = {};
|
|
58
|
+
const storedAfter = {};
|
|
59
|
+
for (const field of [...new Set([...Object.keys(before), ...Object.keys(after)])]) {
|
|
60
|
+
if (field === 'customFieldValues')
|
|
61
|
+
continue;
|
|
62
|
+
const was = before[field] ?? null;
|
|
63
|
+
const is = after[field] ?? null;
|
|
64
|
+
const changed = change.before === null ? !isEmpty(is) : change.after === null ? !isEmpty(was) : !isDeepStrictEqual(was, is);
|
|
65
|
+
if (!changed)
|
|
66
|
+
continue;
|
|
67
|
+
changedFields.push(field);
|
|
68
|
+
storedBefore[field] = was;
|
|
69
|
+
storedAfter[field] = is;
|
|
70
|
+
}
|
|
71
|
+
const customBefore = (before.customFieldValues ?? {});
|
|
72
|
+
const customAfter = (after.customFieldValues ?? {});
|
|
73
|
+
for (const key of [...new Set([...Object.keys(customBefore), ...Object.keys(customAfter)])]) {
|
|
74
|
+
if (!isDeepStrictEqual(customBefore[key] ?? null, customAfter[key] ?? null))
|
|
75
|
+
changedCustomFields.push(key);
|
|
76
|
+
}
|
|
77
|
+
changedFields.sort();
|
|
78
|
+
changedCustomFields.sort();
|
|
79
|
+
if (changedCustomFields.length > 0) {
|
|
80
|
+
storedBefore.customFieldValues = Object.fromEntries(changedCustomFields.map((key) => [key, customBefore[key] ?? null]));
|
|
81
|
+
storedAfter.customFieldValues = Object.fromEntries(changedCustomFields.map((key) => [key, customAfter[key] ?? null]));
|
|
82
|
+
}
|
|
83
|
+
if (changedFields.length === 0 && changedCustomFields.length === 0)
|
|
84
|
+
return {};
|
|
85
|
+
// command-coverage-ignore: runs only inside a `tasks.*` Command's `run`, on the `em`
|
|
86
|
+
// the bus handed it — the row commits with that Command's one audit entry.
|
|
87
|
+
const row = em.create(TaskValueChange, {
|
|
88
|
+
taskId,
|
|
89
|
+
before: change.before === null ? null : storedBefore,
|
|
90
|
+
after: change.after === null ? null : storedAfter,
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
...(changedFields.length > 0 ? { changedFields } : {}),
|
|
94
|
+
...(changedCustomFields.length > 0 ? { changedCustomFields } : {}),
|
|
95
|
+
valueChangeId: row.id,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=task-audit-state.js.map
|
|
@@ -11,7 +11,7 @@ import { Task } from '../entities/task.entity.js';
|
|
|
11
11
|
* | Action | Event |
|
|
12
12
|
* | --- | --- |
|
|
13
13
|
* | `tasks.task.create` | `tasks.task.created.v1` |
|
|
14
|
-
* | `tasks.task.update` (title, description, due date and time, start date, context) | — |
|
|
14
|
+
* | `tasks.task.update` (title, description, due date and time, start date, context; a changed time zone) | — |
|
|
15
15
|
* | `tasks.task.priority_change` | — |
|
|
16
16
|
* | `tasks.task.tags_change` | — |
|
|
17
17
|
* | `tasks.task.custom_fields_change` | — |
|
|
@@ -89,7 +89,14 @@ export interface TaskFieldChanges {
|
|
|
89
89
|
startOn?: string | null;
|
|
90
90
|
context?: TaskContext | null;
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* The audit snapshot of a Task: names and structure only (#470,
|
|
94
|
+
* `TASKS_AUDIT_KEYS`). The title and the context note are values — they go to
|
|
95
|
+
* the Task's value store ({@link taskValues}).
|
|
96
|
+
*/
|
|
92
97
|
export declare function auditSnapshot(task: Task): Record<string, unknown>;
|
|
98
|
+
/** The values of a Task its history shows and the audit log may not hold (#470). */
|
|
99
|
+
export declare function taskValues(task: Task): Record<string, unknown>;
|
|
93
100
|
/** An event's `eventId` / `occurredAt` envelope. */
|
|
94
101
|
export declare function envelope(): {
|
|
95
102
|
eventId: string;
|
|
@@ -146,11 +153,40 @@ export declare function ungroupTaskCommand(id: string, from: {
|
|
|
146
153
|
contextId: string;
|
|
147
154
|
contextGroupId: string;
|
|
148
155
|
}): Command<boolean>;
|
|
156
|
+
/** What the time-zone pass derived for one Task, from the due moment it read (issue #505). */
|
|
157
|
+
export interface TaskDueRederivation {
|
|
158
|
+
/** The Task's `due_on` and `due_at` (ISO) when the pass read them; a Task that moved since is left. */
|
|
159
|
+
seen: {
|
|
160
|
+
dueOn: string | null;
|
|
161
|
+
dueAt: string | null;
|
|
162
|
+
};
|
|
163
|
+
/** With a due time: that time's date in the zone. */
|
|
164
|
+
dueOn: string | null;
|
|
165
|
+
/** Date only: 09:00 of the due date in the zone, the moment its relative reminders count from. */
|
|
166
|
+
moment: Date | null;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* `tasks.task.update`, `reason: 'time_zone_changed'` — what was counted in the
|
|
170
|
+
* old `tasks.time_zone` re-derived in the new one (issue #505; data-model §5,
|
|
171
|
+
* research R-17), one Command per Task, run as the system by the time-zone pass
|
|
172
|
+
* (`time-zone-rederive-service.ts`):
|
|
173
|
+
*
|
|
174
|
+
* - a Task with a due time gets that time's date in the zone as `due_on`;
|
|
175
|
+
* - a date-only Task's relative reminders follow 09:00 of its due date in the
|
|
176
|
+
* zone, as {@link followDueMoment} moves them for a changed due date — a
|
|
177
|
+
* reminder whose moment moved fires again.
|
|
178
|
+
*
|
|
179
|
+
* The Task is re-read under its lock and left as it is when its due moment is
|
|
180
|
+
* not the one the pass read: a write meanwhile derived its own. `false`, and
|
|
181
|
+
* nothing recorded, when nothing moved.
|
|
182
|
+
*/
|
|
183
|
+
export declare function rederiveTaskDueCommand(id: string, derived: TaskDueRederivation, auditLog: AuditPort): Command<boolean>;
|
|
149
184
|
/** `tasks.task.tags_change` — the whole set replaced; `false` when it did not change. */
|
|
150
185
|
export declare function changeTaskTagsCommand(id: string, tagIds: readonly string[]): Command<boolean>;
|
|
151
186
|
/**
|
|
152
187
|
* `tasks.task.custom_fields_change` — the bag `custom_fields` validated and
|
|
153
|
-
* merged; the audit row
|
|
188
|
+
* merged; the audit row names the keys that changed, and the Task's value
|
|
189
|
+
* store holds them before and after (#470).
|
|
154
190
|
* `false` when nothing changed.
|
|
155
191
|
*/
|
|
156
192
|
export declare function changeTaskCustomFieldsCommand(id: string, merged: Record<string, unknown>): Command<boolean>;
|
|
@@ -16,13 +16,18 @@ import { dueMomentOf, followDueMoment } from './reminder-schedule.js';
|
|
|
16
16
|
import { referenceRowsFor } from './reference-service.js';
|
|
17
17
|
import { taskAlreadyPublished, taskAssigneeInvalid, taskNotFound } from './task-errors.js';
|
|
18
18
|
import { nextTaskNumber } from './task-number.js';
|
|
19
|
+
import { recordTaskValueChange } from './task-audit-state.js';
|
|
19
20
|
function isoOrNull(value) {
|
|
20
21
|
return value ? new Date(value).toISOString() : null;
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* The audit snapshot of a Task: names and structure only (#470,
|
|
25
|
+
* `TASKS_AUDIT_KEYS`). The title and the context note are values — they go to
|
|
26
|
+
* the Task's value store ({@link taskValues}).
|
|
27
|
+
*/
|
|
22
28
|
export function auditSnapshot(task) {
|
|
23
29
|
return {
|
|
24
30
|
number: task.number,
|
|
25
|
-
title: task.title,
|
|
26
31
|
descriptionLength: task.description.length,
|
|
27
32
|
status: task.status,
|
|
28
33
|
dueOn: task.dueOn ?? null,
|
|
@@ -32,9 +37,12 @@ export function auditSnapshot(task) {
|
|
|
32
37
|
contextType: task.contextType ?? null,
|
|
33
38
|
contextId: task.contextId ?? null,
|
|
34
39
|
contextGroupId: task.contextGroupId ?? null,
|
|
35
|
-
contextNote: task.contextNote ?? null,
|
|
36
40
|
};
|
|
37
41
|
}
|
|
42
|
+
/** The values of a Task its history shows and the audit log may not hold (#470). */
|
|
43
|
+
export function taskValues(task) {
|
|
44
|
+
return { title: task.title, contextNote: task.contextNote ?? null };
|
|
45
|
+
}
|
|
38
46
|
/** An event's `eventId` / `occurredAt` envelope. */
|
|
39
47
|
export function envelope() {
|
|
40
48
|
return { eventId: randomUUID(), occurredAt: new Date().toISOString() };
|
|
@@ -147,6 +155,14 @@ export function createTaskCommand(context, input) {
|
|
|
147
155
|
}
|
|
148
156
|
}
|
|
149
157
|
created = task;
|
|
158
|
+
// The values go to the Task's own store; the entry names them (#470).
|
|
159
|
+
// The row names the Task by value, so the Task is written first, as
|
|
160
|
+
// for the other child rows above.
|
|
161
|
+
await scoped.flush();
|
|
162
|
+
const values = recordTaskValueChange(scoped, id, {
|
|
163
|
+
before: null,
|
|
164
|
+
after: { ...taskValues(task), customFieldValues: { ...task.customFieldValues } },
|
|
165
|
+
});
|
|
150
166
|
return {
|
|
151
167
|
result: id,
|
|
152
168
|
before: null,
|
|
@@ -159,7 +175,7 @@ export function createTaskCommand(context, input) {
|
|
|
159
175
|
tagIds,
|
|
160
176
|
...(parentTaskId !== null ? { parentTaskId } : {}),
|
|
161
177
|
...(links.length > 0 ? { links: links.map((link) => ({ kind: link.kind, recordId: link.id })) } : {}),
|
|
162
|
-
...
|
|
178
|
+
...values,
|
|
163
179
|
},
|
|
164
180
|
};
|
|
165
181
|
},
|
|
@@ -246,6 +262,7 @@ export function updateTaskCommand(id, changes, reminders) {
|
|
|
246
262
|
const scoped = em;
|
|
247
263
|
const task = await lockedTask(scoped, id);
|
|
248
264
|
const before = auditSnapshot(task);
|
|
265
|
+
const valuesBefore = taskValues(task);
|
|
249
266
|
let mentioned = [];
|
|
250
267
|
if (changes.title !== undefined)
|
|
251
268
|
task.title = changes.title;
|
|
@@ -270,7 +287,8 @@ export function updateTaskCommand(id, changes, reminders) {
|
|
|
270
287
|
task.contextId = changes.context?.contextId ?? null;
|
|
271
288
|
task.contextGroupId = changes.context?.contextGroupId ?? null;
|
|
272
289
|
}
|
|
273
|
-
|
|
290
|
+
const values = recordTaskValueChange(scoped, task.id, { before: valuesBefore, after: taskValues(task) });
|
|
291
|
+
return { result: { mentioned }, before, after: { ...auditSnapshot(task), ...values } };
|
|
274
292
|
},
|
|
275
293
|
};
|
|
276
294
|
}
|
|
@@ -325,6 +343,46 @@ export function ungroupTaskCommand(id, from) {
|
|
|
325
343
|
},
|
|
326
344
|
};
|
|
327
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* `tasks.task.update`, `reason: 'time_zone_changed'` — what was counted in the
|
|
348
|
+
* old `tasks.time_zone` re-derived in the new one (issue #505; data-model §5,
|
|
349
|
+
* research R-17), one Command per Task, run as the system by the time-zone pass
|
|
350
|
+
* (`time-zone-rederive-service.ts`):
|
|
351
|
+
*
|
|
352
|
+
* - a Task with a due time gets that time's date in the zone as `due_on`;
|
|
353
|
+
* - a date-only Task's relative reminders follow 09:00 of its due date in the
|
|
354
|
+
* zone, as {@link followDueMoment} moves them for a changed due date — a
|
|
355
|
+
* reminder whose moment moved fires again.
|
|
356
|
+
*
|
|
357
|
+
* The Task is re-read under its lock and left as it is when its due moment is
|
|
358
|
+
* not the one the pass read: a write meanwhile derived its own. `false`, and
|
|
359
|
+
* nothing recorded, when nothing moved.
|
|
360
|
+
*/
|
|
361
|
+
export function rederiveTaskDueCommand(id, derived, auditLog) {
|
|
362
|
+
return {
|
|
363
|
+
action: 'tasks.task.update',
|
|
364
|
+
objectType: 'task',
|
|
365
|
+
objectId: id,
|
|
366
|
+
run: async ({ em }) => {
|
|
367
|
+
const scoped = em;
|
|
368
|
+
const task = await scoped.findOne(Task, { id }, { lockMode: LockMode.PESSIMISTIC_WRITE });
|
|
369
|
+
if (!task || (task.dueOn ?? null) !== derived.seen.dueOn || isoOrNull(task.dueAt) !== derived.seen.dueAt) {
|
|
370
|
+
return { result: false, skipAudit: true };
|
|
371
|
+
}
|
|
372
|
+
const dueOn = task.dueOn ?? null;
|
|
373
|
+
if (task.dueAt && derived.dueOn !== null)
|
|
374
|
+
task.dueOn = derived.dueOn;
|
|
375
|
+
const remindersMoved = !task.dueAt && task.dueOn && derived.moment ? await followDueMoment(scoped, auditLog, task.id, derived.moment) : 0;
|
|
376
|
+
if ((task.dueOn ?? null) === dueOn && remindersMoved === 0)
|
|
377
|
+
return { result: false, skipAudit: true };
|
|
378
|
+
return {
|
|
379
|
+
result: true,
|
|
380
|
+
before: { dueOn },
|
|
381
|
+
after: { dueOn: task.dueOn ?? null, remindersMoved, reason: 'time_zone_changed' },
|
|
382
|
+
};
|
|
383
|
+
},
|
|
384
|
+
};
|
|
385
|
+
}
|
|
328
386
|
/** `tasks.task.tags_change` — the whole set replaced; `false` when it did not change. */
|
|
329
387
|
export function changeTaskTagsCommand(id, tagIds) {
|
|
330
388
|
return {
|
|
@@ -350,7 +408,8 @@ export function changeTaskTagsCommand(id, tagIds) {
|
|
|
350
408
|
}
|
|
351
409
|
/**
|
|
352
410
|
* `tasks.task.custom_fields_change` — the bag `custom_fields` validated and
|
|
353
|
-
* merged; the audit row
|
|
411
|
+
* merged; the audit row names the keys that changed, and the Task's value
|
|
412
|
+
* store holds them before and after (#470).
|
|
354
413
|
* `false` when nothing changed.
|
|
355
414
|
*/
|
|
356
415
|
export function changeTaskCustomFieldsCommand(id, merged) {
|
|
@@ -364,9 +423,13 @@ export function changeTaskCustomFieldsCommand(id, merged) {
|
|
|
364
423
|
const keys = [...new Set([...Object.keys(current), ...Object.keys(merged)])].filter((key) => !isDeepStrictEqual(current[key], merged[key]));
|
|
365
424
|
if (keys.length === 0)
|
|
366
425
|
return { result: false, skipAudit: true };
|
|
367
|
-
const side = (bag) => Object.fromEntries(keys.map((key) => [key, bag[key] ?? null]));
|
|
368
426
|
task.customFieldValues = merged;
|
|
369
|
-
|
|
427
|
+
// The values go to the Task's own store; the entry names the keys (#470).
|
|
428
|
+
const values = recordTaskValueChange(em, task.id, {
|
|
429
|
+
before: { customFieldValues: { ...current } },
|
|
430
|
+
after: { customFieldValues: { ...merged } },
|
|
431
|
+
});
|
|
432
|
+
return { result: true, before: null, after: { ...values } };
|
|
370
433
|
},
|
|
371
434
|
};
|
|
372
435
|
}
|
|
@@ -46,6 +46,8 @@ export interface TaskReminderEmailInput extends TaskEmailRecipient {
|
|
|
46
46
|
}
|
|
47
47
|
/** One line of a digest. */
|
|
48
48
|
export interface TaskDigestEntry {
|
|
49
|
+
/** The Task's id — what its link into the admin panel addresses. */
|
|
50
|
+
taskId: string;
|
|
49
51
|
number: string;
|
|
50
52
|
title: string;
|
|
51
53
|
/** `YYYY-MM-DD`. */
|
|
@@ -70,6 +72,12 @@ export interface TaskEmailDeps {
|
|
|
70
72
|
sender: () => TransactionalEmailSender | undefined;
|
|
71
73
|
/** Where a send that did not happen is reported. */
|
|
72
74
|
log: (message: string, context: Record<string, unknown>) => void;
|
|
75
|
+
/**
|
|
76
|
+
* The Admin UI's base address, read per send; `null` when it is not
|
|
77
|
+
* configured, and the e-mail then carries no link. The platform's
|
|
78
|
+
* `configuredAdminBaseUrl` unless a test injects one.
|
|
79
|
+
*/
|
|
80
|
+
adminBaseUrl?: () => string | null;
|
|
73
81
|
}
|
|
74
82
|
/**
|
|
75
83
|
* The language a Task e-mail is written in: the recipient's Admin UI language
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import { rethrowIfModuleDisabled } from '@endora-commerce/platform/kernel';
|
|
1
|
+
import { configuredAdminBaseUrl, rethrowIfModuleDisabled } from '@endora-commerce/platform/kernel';
|
|
2
2
|
import { TASK_DIGEST_EMAIL_CODE } from '../email-templates/digest-defaults.js';
|
|
3
3
|
import { TASK_REMINDER_EMAIL_CODE } from '../email-templates/reminder-defaults.js';
|
|
4
|
+
import { TASK_DIGEST_LINK_PATH, taskLinkPath } from './task-notifier.js';
|
|
5
|
+
/**
|
|
6
|
+
* `{ adminUrl }` — the bell entry's address made absolute on `base` — or
|
|
7
|
+
* nothing at all: a link is left out rather than relative, which opens nothing
|
|
8
|
+
* from a mail client, and the template drops what it would have shown.
|
|
9
|
+
*/
|
|
10
|
+
function adminLink(base, path) {
|
|
11
|
+
return base === null ? {} : { adminUrl: `${base}${path}` };
|
|
12
|
+
}
|
|
4
13
|
/**
|
|
5
14
|
* The language a Task e-mail is written in: the recipient's Admin UI language
|
|
6
15
|
* — Polish for a Polish preference, English for everything else, read by the
|
|
@@ -64,6 +73,7 @@ export function createTaskEmail(deps) {
|
|
|
64
73
|
});
|
|
65
74
|
return { sent: false, reason };
|
|
66
75
|
};
|
|
76
|
+
const adminBaseUrl = deps.adminBaseUrl ?? (() => configuredAdminBaseUrl());
|
|
67
77
|
const send = async (recipient, message) => {
|
|
68
78
|
if (!recipient.to)
|
|
69
79
|
return notSent(message.context, 'no_address');
|
|
@@ -100,6 +110,7 @@ export function createTaskEmail(deps) {
|
|
|
100
110
|
number: input.number,
|
|
101
111
|
title: input.title.replace(/\s+/g, ' ').trim(),
|
|
102
112
|
due: dueWords(input, language, input.timeZone) ?? '',
|
|
113
|
+
...adminLink(adminBaseUrl(), taskLinkPath(input.taskId)),
|
|
103
114
|
},
|
|
104
115
|
}),
|
|
105
116
|
context: { taskId: input.taskId, deliveryId: input.deliveryId },
|
|
@@ -110,9 +121,14 @@ export function createTaskEmail(deps) {
|
|
|
110
121
|
messageId: `${TASK_DIGEST_EMAIL_CODE}:${input.adminUserId}:${input.date}`,
|
|
111
122
|
document: null,
|
|
112
123
|
variables: (language) => {
|
|
113
|
-
const
|
|
124
|
+
const base = adminBaseUrl();
|
|
125
|
+
const tasks = input.tasks.map((entry) => ({
|
|
126
|
+
...digestItem(entry, input.date, language),
|
|
127
|
+
...adminLink(base, taskLinkPath(entry.taskId)),
|
|
128
|
+
}));
|
|
114
129
|
return {
|
|
115
130
|
digest: {
|
|
131
|
+
...adminLink(base, TASK_DIGEST_LINK_PATH),
|
|
116
132
|
date: dayWords(input.date, language),
|
|
117
133
|
taskCount: String(tasks.length),
|
|
118
134
|
// One Task a line — the number, the title and the due date, no words around them.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type AdminUserReadPort, type RecordHistoryPage, type RecordHistoryQuery } from '@endora-commerce/contracts';
|
|
2
|
+
import type { EntityManager } from '@mikro-orm/postgresql';
|
|
2
3
|
import type { AuditPort } from '@endora-commerce/platform/kernel';
|
|
3
4
|
import { type TaskAccess } from './task-access.js';
|
|
4
5
|
import type { TaskService } from './task-service.js';
|
|
@@ -12,6 +13,8 @@ export declare const TASK_AUDIT_OBJECT_TYPE = "task";
|
|
|
12
13
|
*/
|
|
13
14
|
export declare const TASK_HISTORY_REACH: number;
|
|
14
15
|
export interface TaskHistoryServiceDeps {
|
|
16
|
+
/** Reads the Task's own value store (#470), by the id of a Task the reader may see. */
|
|
17
|
+
emFactory: () => EntityManager;
|
|
15
18
|
tasks: Pick<TaskService, 'findVisibleRow'>;
|
|
16
19
|
/** Whether the reader may see a context an entry names — the Task may have left it since. */
|
|
17
20
|
visibility: Pick<TaskVisibility, 'canSeeContext'>;
|
|
@@ -21,12 +24,46 @@ export interface TaskHistoryServiceDeps {
|
|
|
21
24
|
auditLog: Pick<AuditPort, 'query'>;
|
|
22
25
|
/** `admin_users`' read port — lazy, resolved per call. */
|
|
23
26
|
adminUsers: AdminUserReadPort;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the reader holds `custom_fields:read` (owner ruling 2026-11-10,
|
|
29
|
+
* #470; feature 162 P2 = a, as CRM and Projects). Without it no entry serves
|
|
30
|
+
* a Task's custom-field values, nor the names of the changed ones.
|
|
31
|
+
*/
|
|
32
|
+
mayReadCustomFields: () => Promise<boolean>;
|
|
24
33
|
}
|
|
34
|
+
/** An audited state without its custom fields, for a reader who may not read them. */
|
|
35
|
+
export declare function withoutCustomFields(state: unknown): unknown;
|
|
25
36
|
/** The audited keys whose value is a Task's id (relation and hierarchy entries). */
|
|
26
37
|
export declare const TASK_ID_KEYS: readonly ["relatedTaskId", "parentTaskId"];
|
|
38
|
+
/** One row of `task_value_changes`: the changed values of one write, either side. */
|
|
39
|
+
export interface StoredTaskValueChange {
|
|
40
|
+
before: Record<string, unknown> | null;
|
|
41
|
+
after: Record<string, unknown> | null;
|
|
42
|
+
}
|
|
43
|
+
/** The `task_value_changes` row an entry points at — on the side that has one — or `null`. */
|
|
44
|
+
export declare function valueChangeIdOf(entry: {
|
|
45
|
+
before: unknown;
|
|
46
|
+
after: unknown;
|
|
47
|
+
}): string | null;
|
|
48
|
+
/**
|
|
49
|
+
* An entry with the values the Task's store kept for it (#470): the audit entry
|
|
50
|
+
* names what changed and points at the row by `valueChangeId`; the history
|
|
51
|
+
* serves the values in place of the names, in the shape entries written before
|
|
52
|
+
* #470 carried them. Without a row the names stay and only the pointer goes.
|
|
53
|
+
* Entries written before #470 carry their values and are served as stored
|
|
54
|
+
* (owner ruling O-4, 2026-11-10).
|
|
55
|
+
*/
|
|
56
|
+
export declare function withStoredValues(entry: {
|
|
57
|
+
before: unknown;
|
|
58
|
+
after: unknown;
|
|
59
|
+
}, change: StoredTaskValueChange | null): {
|
|
60
|
+
before: unknown;
|
|
61
|
+
after: unknown;
|
|
62
|
+
};
|
|
27
63
|
/** An audited state with its context blanked. */
|
|
28
64
|
export declare function withoutContext(state: Record<string, unknown>): Record<string, unknown>;
|
|
29
65
|
export declare class TaskHistoryService {
|
|
66
|
+
#private;
|
|
30
67
|
private readonly deps;
|
|
31
68
|
constructor(deps: TaskHistoryServiceDeps);
|
|
32
69
|
list(taskId: string, query: RecordHistoryQuery): Promise<RecordHistoryPage>;
|
|
@@ -28,6 +28,18 @@ function decodeCursor(cursor) {
|
|
|
28
28
|
}
|
|
29
29
|
throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, 'The cursor is not one this history issued.');
|
|
30
30
|
}
|
|
31
|
+
/** The keys of a state that belong to `custom_fields`: the values, and the names of the changed ones. */
|
|
32
|
+
const CUSTOM_FIELD_KEYS = ['customFieldValues', 'changedCustomFields'];
|
|
33
|
+
/** An audited state without its custom fields, for a reader who may not read them. */
|
|
34
|
+
export function withoutCustomFields(state) {
|
|
35
|
+
const record = asRecord(state);
|
|
36
|
+
if (!record || !CUSTOM_FIELD_KEYS.some((key) => Object.hasOwn(record, key)))
|
|
37
|
+
return state;
|
|
38
|
+
const out = { ...record };
|
|
39
|
+
for (const key of CUSTOM_FIELD_KEYS)
|
|
40
|
+
delete out[key];
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
31
43
|
/**
|
|
32
44
|
* `GET /tasks/:id/history` — **the audit log is the history**: every write of
|
|
33
45
|
* a Task is a Command recorded against `task` and its id. The Task is read
|
|
@@ -89,6 +101,47 @@ function showsReminder(entry, reader) {
|
|
|
89
101
|
return true;
|
|
90
102
|
return Array.isArray(state['recipientIds']) && state['recipientIds'].includes(reader);
|
|
91
103
|
}
|
|
104
|
+
/** The audit keys that stand in for the values the Task's own store keeps (#470). */
|
|
105
|
+
const VALUE_POINTER = 'valueChangeId';
|
|
106
|
+
const VALUE_NAMES = ['changedFields', 'changedCustomFields'];
|
|
107
|
+
const UUID_SHAPE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
108
|
+
/** The `task_value_changes` row an entry points at — on the side that has one — or `null`. */
|
|
109
|
+
export function valueChangeIdOf(entry) {
|
|
110
|
+
for (const state of [entry.after, entry.before]) {
|
|
111
|
+
const id = asRecord(state)?.[VALUE_POINTER];
|
|
112
|
+
if (typeof id === 'string' && UUID_SHAPE.test(id))
|
|
113
|
+
return id;
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* An entry with the values the Task's store kept for it (#470): the audit entry
|
|
119
|
+
* names what changed and points at the row by `valueChangeId`; the history
|
|
120
|
+
* serves the values in place of the names, in the shape entries written before
|
|
121
|
+
* #470 carried them. Without a row the names stay and only the pointer goes.
|
|
122
|
+
* Entries written before #470 carry their values and are served as stored
|
|
123
|
+
* (owner ruling O-4, 2026-11-10).
|
|
124
|
+
*/
|
|
125
|
+
export function withStoredValues(entry, change) {
|
|
126
|
+
const strip = (state) => {
|
|
127
|
+
const record = asRecord(state);
|
|
128
|
+
if (!record || !(VALUE_POINTER in record || (change && VALUE_NAMES.some((key) => key in record))))
|
|
129
|
+
return state;
|
|
130
|
+
const out = { ...record };
|
|
131
|
+
delete out[VALUE_POINTER];
|
|
132
|
+
if (change)
|
|
133
|
+
for (const key of VALUE_NAMES)
|
|
134
|
+
delete out[key];
|
|
135
|
+
return out;
|
|
136
|
+
};
|
|
137
|
+
const merge = (state, values) => {
|
|
138
|
+
const stripped = strip(state);
|
|
139
|
+
if (!values)
|
|
140
|
+
return stripped;
|
|
141
|
+
return { ...(asRecord(stripped) ?? {}), ...values };
|
|
142
|
+
};
|
|
143
|
+
return { before: merge(entry.before, change?.before ?? null), after: merge(entry.after, change?.after ?? null) };
|
|
144
|
+
}
|
|
92
145
|
/** An audited state with its context blanked. */
|
|
93
146
|
export function withoutContext(state) {
|
|
94
147
|
const out = { ...state };
|
|
@@ -126,13 +179,25 @@ export class TaskHistoryService {
|
|
|
126
179
|
const page = entries.slice(offset, offset + query.limit);
|
|
127
180
|
const hasMore = entries.length > offset + query.limit;
|
|
128
181
|
const truncated = !hasMore && read.length > TASK_HISTORY_REACH;
|
|
182
|
+
// The values the page's entries name, from the Task's own store — keyed by
|
|
183
|
+
// the Task `findVisibleRow` handed out, so a pointer to another Task's row
|
|
184
|
+
// reads nothing (#470).
|
|
185
|
+
const pointers = page
|
|
186
|
+
.map((entry) => valueChangeIdOf({ before: entry.stateBefore ?? null, after: entry.stateAfter ?? null }))
|
|
187
|
+
.filter((id) => id !== null);
|
|
188
|
+
const changes = await this.#valueChanges(task.id, pointers);
|
|
189
|
+
const states = page.map((entry) => {
|
|
190
|
+
const raw = { before: entry.stateBefore ?? null, after: entry.stateAfter ?? null };
|
|
191
|
+
const pointer = valueChangeIdOf(raw);
|
|
192
|
+
return withStoredValues(raw, pointer === null ? null : (changes.get(pointer) ?? null));
|
|
193
|
+
});
|
|
129
194
|
const actorIds = [...new Set(page.map((entry) => entry.actorAdminUserId).filter((id) => Boolean(id)))];
|
|
130
195
|
const actors = actorIds.length > 0 ? await this.deps.adminUsers.findByIds(actorIds) : [];
|
|
131
196
|
const names = new Map(actors.map((admin) => [admin.id, `${admin.firstName} ${admin.lastName}`.trim() || admin.email]));
|
|
132
197
|
// Each context the page names, asked once, under the reader's own context.
|
|
133
198
|
const seen = new Map();
|
|
134
|
-
for (const entry of
|
|
135
|
-
for (const state of [entry.
|
|
199
|
+
for (const entry of states) {
|
|
200
|
+
for (const state of [entry.before, entry.after]) {
|
|
136
201
|
const context = contextOf(state);
|
|
137
202
|
if (!context)
|
|
138
203
|
continue;
|
|
@@ -142,7 +207,7 @@ export class TaskHistoryService {
|
|
|
142
207
|
}
|
|
143
208
|
}
|
|
144
209
|
// Every Task the page names, asked once, in one read.
|
|
145
|
-
const named =
|
|
210
|
+
const named = states.flatMap((entry) => [...taskIdsOf(entry.before), ...taskIdsOf(entry.after)]);
|
|
146
211
|
const visibleTasks = named.length > 0 ? await this.deps.access.visibleIds(named) : new Set();
|
|
147
212
|
const withoutHiddenTasks = (state) => {
|
|
148
213
|
const record = asRecord(state);
|
|
@@ -156,14 +221,16 @@ export class TaskHistoryService {
|
|
|
156
221
|
}
|
|
157
222
|
return out;
|
|
158
223
|
};
|
|
159
|
-
const
|
|
224
|
+
const mayReadCustomFields = page.length > 0 ? await this.deps.mayReadCustomFields() : true;
|
|
225
|
+
const served = (raw) => {
|
|
226
|
+
const state = mayReadCustomFields ? raw : withoutCustomFields(raw);
|
|
160
227
|
const context = contextOf(state);
|
|
161
228
|
if (!context || seen.get(`${context.contextType}:${context.contextId}`))
|
|
162
229
|
return withoutHiddenTasks(state ?? null);
|
|
163
230
|
return withoutHiddenTasks(withoutContext(state));
|
|
164
231
|
};
|
|
165
232
|
return {
|
|
166
|
-
data: page.map((entry) => {
|
|
233
|
+
data: page.map((entry, index) => {
|
|
167
234
|
const actorId = entry.actorAdminUserId ?? null;
|
|
168
235
|
return {
|
|
169
236
|
id: entry.id,
|
|
@@ -172,8 +239,8 @@ export class TaskHistoryService {
|
|
|
172
239
|
actor: actorId === null
|
|
173
240
|
? { kind: 'system', id: null, name: null }
|
|
174
241
|
: { kind: 'admin', id: actorId, name: names.get(actorId) ?? null },
|
|
175
|
-
before: served(
|
|
176
|
-
after: served(
|
|
242
|
+
before: served(states[index]?.before ?? null),
|
|
243
|
+
after: served(states[index]?.after ?? null),
|
|
177
244
|
references: [],
|
|
178
245
|
};
|
|
179
246
|
}),
|
|
@@ -181,5 +248,13 @@ export class TaskHistoryService {
|
|
|
181
248
|
truncated,
|
|
182
249
|
};
|
|
183
250
|
}
|
|
251
|
+
/** The stored values of the page's entries, by row id — read by the Task's own id. */
|
|
252
|
+
async #valueChanges(taskId, ids) {
|
|
253
|
+
if (ids.length === 0)
|
|
254
|
+
return new Map();
|
|
255
|
+
const rows = (await this.deps.emFactory().execute(`select v."id", v."before", v."after" from "task_value_changes" v
|
|
256
|
+
where v."task_id" = ? and v."id" = any(?::uuid[])`, [taskId, `{${ids.join(',')}}`]));
|
|
257
|
+
return new Map(rows.map((row) => [row.id, { before: row.before, after: row.after }]));
|
|
258
|
+
}
|
|
184
259
|
}
|
|
185
260
|
//# sourceMappingURL=task-history-service.js.map
|