@open-mercato/core 0.7.1-develop.7178.1.ab93fbaf4e → 0.7.1-develop.7180.1.9717fbbb43
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/.turbo/turbo-build.log +2 -2
- package/dist/generated/entities/staff_time_entry/index.js +14 -0
- package/dist/generated/entities/staff_time_entry/index.js.map +2 -2
- package/dist/generated/entities/staff_time_entry_tag/index.js +15 -0
- package/dist/generated/entities/staff_time_entry_tag/index.js.map +7 -0
- package/dist/generated/entities/staff_time_project/index.js +16 -0
- package/dist/generated/entities/staff_time_project/index.js.map +2 -2
- package/dist/generated/entities/staff_time_report/index.js +57 -0
- package/dist/generated/entities/staff_time_report/index.js.map +7 -0
- package/dist/generated/entities/staff_time_report_entry/index.js +27 -0
- package/dist/generated/entities/staff_time_report_entry/index.js.map +7 -0
- package/dist/generated/entities/staff_time_report_event/index.js +21 -0
- package/dist/generated/entities/staff_time_report_event/index.js.map +7 -0
- package/dist/generated/entities/staff_time_report_project/index.js +15 -0
- package/dist/generated/entities/staff_time_report_project/index.js.map +7 -0
- package/dist/generated/entities/staff_time_tag/index.js +21 -0
- package/dist/generated/entities/staff_time_tag/index.js.map +7 -0
- package/dist/generated/entities/staff_time_task/index.js +37 -0
- package/dist/generated/entities/staff_time_task/index.js.map +7 -0
- package/dist/generated/entities/staff_time_task_comment/index.js +21 -0
- package/dist/generated/entities/staff_time_task_comment/index.js.map +7 -0
- package/dist/generated/entities/staff_time_task_status/index.js +29 -0
- package/dist/generated/entities/staff_time_task_status/index.js.map +7 -0
- package/dist/generated/entities/staff_time_task_tag/index.js +15 -0
- package/dist/generated/entities/staff_time_task_tag/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +11 -1
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +149 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/helpers/integration/timesheetFixtures.js +7 -0
- package/dist/helpers/integration/timesheetFixtures.js.map +2 -2
- package/dist/modules/auth/cli.js +16 -0
- package/dist/modules/auth/cli.js.map +2 -2
- package/dist/modules/auth/lib/backendChrome.js +1 -0
- package/dist/modules/auth/lib/backendChrome.js.map +2 -2
- package/dist/modules/customer_accounts/lib/customerRoleAcls.js +44 -0
- package/dist/modules/customer_accounts/lib/customerRoleAcls.js.map +7 -0
- package/dist/modules/customer_accounts/setup.js +1 -28
- package/dist/modules/customer_accounts/setup.js.map +2 -2
- package/dist/modules/data_sync/api/options.js +2 -0
- package/dist/modules/data_sync/api/options.js.map +2 -2
- package/dist/modules/data_sync/backend/data-sync/page.js +39 -17
- package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
- package/dist/modules/data_sync/lib/start-controls.js +42 -0
- package/dist/modules/data_sync/lib/start-controls.js.map +7 -0
- package/dist/modules/staff/acl.js +9 -1
- package/dist/modules/staff/acl.js.map +2 -2
- package/dist/modules/staff/ai-agents.js +142 -0
- package/dist/modules/staff/ai-agents.js.map +7 -0
- package/dist/modules/staff/ai-tools/time-tracking-pack.js +348 -0
- package/dist/modules/staff/ai-tools/time-tracking-pack.js.map +7 -0
- package/dist/modules/staff/ai-tools/types.js +54 -0
- package/dist/modules/staff/ai-tools/types.js.map +7 -0
- package/dist/modules/staff/ai-tools.js +8 -0
- package/dist/modules/staff/ai-tools.js.map +7 -0
- package/dist/modules/staff/analytics.js +84 -1
- package/dist/modules/staff/analytics.js.map +2 -2
- package/dist/modules/staff/api/guards.js +37 -3
- package/dist/modules/staff/api/guards.js.map +2 -2
- package/dist/modules/staff/api/leave-requests/accept/route.js +1 -3
- package/dist/modules/staff/api/leave-requests/accept/route.js.map +2 -2
- package/dist/modules/staff/api/leave-requests/reject/route.js +1 -3
- package/dist/modules/staff/api/leave-requests/reject/route.js.map +2 -2
- package/dist/modules/staff/api/portal/time-reports/[id]/route.js +131 -0
- package/dist/modules/staff/api/portal/time-reports/[id]/route.js.map +7 -0
- package/dist/modules/staff/api/portal/time-reports/route.js +179 -0
- package/dist/modules/staff/api/portal/time-reports/route.js.map +7 -0
- package/dist/modules/staff/api/team-members/self/route.js +1 -3
- package/dist/modules/staff/api/team-members/self/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/tags/assign/route.js +1 -3
- package/dist/modules/staff/api/team-members/tags/assign/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/tags/unassign/route.js +1 -3
- package/dist/modules/staff/api/team-members/tags/unassign/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.js +174 -0
- package/dist/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.js.map +7 -0
- package/dist/modules/staff/api/timesheets/access-requests/route.js +226 -0
- package/dist/modules/staff/api/timesheets/access-requests/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js +15 -8
- package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/my-projects/route.js +13 -1
- package/dist/modules/staff/api/timesheets/my-projects/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/my-work/myWorkAggregate.js +42 -0
- package/dist/modules/staff/api/timesheets/my-work/myWorkAggregate.js.map +7 -0
- package/dist/modules/staff/api/timesheets/my-work/route.js +383 -0
- package/dist/modules/staff/api/timesheets/my-work/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/projects/kpis/route.js +14 -2
- package/dist/modules/staff/api/timesheets/projects/kpis/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/reports/[id]/close/route.js +168 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/close/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/export/route.js +246 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/export/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/sheet/route.js +183 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/sheet/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/unlock/route.js +164 -0
- package/dist/modules/staff/api/timesheets/reports/[id]/unlock/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/reports/preview/route.js +360 -0
- package/dist/modules/staff/api/timesheets/reports/preview/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/reports/route.js +316 -0
- package/dist/modules/staff/api/timesheets/reports/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/reports/shared.js +63 -0
- package/dist/modules/staff/api/timesheets/reports/shared.js.map +7 -0
- package/dist/modules/staff/api/timesheets/settings/reapply-rounding/route.js +164 -0
- package/dist/modules/staff/api/timesheets/settings/reapply-rounding/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/settings/rounding-impact/route.js +168 -0
- package/dist/modules/staff/api/timesheets/settings/rounding-impact/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/settings/route.js +199 -0
- package/dist/modules/staff/api/timesheets/settings/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tags/access.js +76 -0
- package/dist/modules/staff/api/timesheets/tags/access.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tags/entry-assignments/route.js +235 -0
- package/dist/modules/staff/api/timesheets/tags/entry-assignments/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tags/route.js +160 -0
- package/dist/modules/staff/api/timesheets/tags/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tags/task-assignments/route.js +233 -0
- package/dist/modules/staff/api/timesheets/tags/task-assignments/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/task-statuses/route.js +188 -0
- package/dist/modules/staff/api/timesheets/task-statuses/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tasks/[id]/comments/route.js +399 -0
- package/dist/modules/staff/api/timesheets/tasks/[id]/comments/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tasks/[id]/status/route.js +210 -0
- package/dist/modules/staff/api/timesheets/tasks/[id]/status/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/tasks/route.js +333 -0
- package/dist/modules/staff/api/timesheets/tasks/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.js +228 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js +29 -10
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js +31 -18
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js +21 -7
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js +27 -7
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js +215 -32
- package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/copy-day/route.js +378 -0
- package/dist/modules/staff/api/timesheets/time-entries/copy-day/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/overlaps/route.js +340 -0
- package/dist/modules/staff/api/timesheets/time-entries/overlaps/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/route.js +238 -26
- package/dist/modules/staff/api/timesheets/time-entries/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/start-timer/route.js +23 -8
- package/dist/modules/staff/api/timesheets/time-entries/start-timer/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.js +209 -0
- package/dist/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-projects/[id]/employees/route.js +59 -2
- package/dist/modules/staff/api/timesheets/time-projects/[id]/employees/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-projects/route.js +264 -22
- package/dist/modules/staff/api/timesheets/time-projects/route.js.map +2 -2
- package/dist/modules/staff/backend/staff/time-tracking/board/page.js +110 -0
- package/dist/modules/staff/backend/staff/time-tracking/board/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/board/page.meta.js +18 -0
- package/dist/modules/staff/backend/staff/time-tracking/board/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/entries/page.js +981 -0
- package/dist/modules/staff/backend/staff/time-tracking/entries/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/entries/page.meta.js +18 -0
- package/dist/modules/staff/backend/staff/time-tracking/entries/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/page.js +583 -0
- package/dist/modules/staff/backend/staff/time-tracking/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/page.meta.js +15 -0
- package/dist/modules/staff/backend/staff/time-tracking/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/board/page.js +65 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/board/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/board/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/board/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/edit/page.js +229 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/edit/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/edit/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/edit/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/page.js +1014 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/create/page.js +97 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/create/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/create/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/create/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/page.js +1040 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/page.meta.js +19 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/projectFormConfig.js +353 -0
- package/dist/modules/staff/backend/staff/time-tracking/projects/projectFormConfig.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/[id]/page.js +457 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/[id]/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/[id]/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/[id]/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/create/page.js +697 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/create/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/create/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/create/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/page.js +174 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/page.meta.js +18 -0
- package/dist/modules/staff/backend/staff/time-tracking/reports/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/settings/page.js +546 -0
- package/dist/modules/staff/backend/staff/time-tracking/settings/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/settings/page.meta.js +18 -0
- package/dist/modules/staff/backend/staff/time-tracking/settings/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/timesheet/GridView.js +710 -0
- package/dist/modules/staff/backend/staff/time-tracking/timesheet/GridView.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/timesheet/page.js +646 -0
- package/dist/modules/staff/backend/staff/time-tracking/timesheet/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/time-tracking/timesheet/page.meta.js +18 -0
- package/dist/modules/staff/backend/staff/time-tracking/timesheet/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/page.js +4 -793
- package/dist/modules/staff/backend/staff/timesheets/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/page.meta.js +2 -7
- package/dist/modules/staff/backend/staff/timesheets/page.meta.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.js +5 -136
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.meta.js +1 -7
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.meta.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.js +5 -445
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.js.map +3 -3
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.meta.js +1 -7
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.meta.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.js +4 -76
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.meta.js +1 -7
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.meta.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/page.js +4 -613
- package/dist/modules/staff/backend/staff/timesheets/projects/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/page.meta.js +2 -17
- package/dist/modules/staff/backend/staff/timesheets/projects/page.meta.js.map +2 -2
- package/dist/modules/staff/ce.js +40 -0
- package/dist/modules/staff/ce.js.map +2 -2
- package/dist/modules/staff/cli.js +166 -1
- package/dist/modules/staff/cli.js.map +2 -2
- package/dist/modules/staff/commands/index.js +5 -0
- package/dist/modules/staff/commands/index.js.map +2 -2
- package/dist/modules/staff/commands/timesheets-entries.js +569 -21
- package/dist/modules/staff/commands/timesheets-entries.js.map +3 -3
- package/dist/modules/staff/commands/timesheets-projects.js +450 -7
- package/dist/modules/staff/commands/timesheets-projects.js.map +2 -2
- package/dist/modules/staff/commands/timesheets-reports.js +1036 -0
- package/dist/modules/staff/commands/timesheets-reports.js.map +7 -0
- package/dist/modules/staff/commands/timesheets-tags.js +1015 -0
- package/dist/modules/staff/commands/timesheets-tags.js.map +7 -0
- package/dist/modules/staff/commands/timesheets-task-comments.js +438 -0
- package/dist/modules/staff/commands/timesheets-task-comments.js.map +7 -0
- package/dist/modules/staff/commands/timesheets-task-statuses.js +723 -0
- package/dist/modules/staff/commands/timesheets-task-statuses.js.map +7 -0
- package/dist/modules/staff/commands/timesheets-tasks.js +834 -0
- package/dist/modules/staff/commands/timesheets-tasks.js.map +7 -0
- package/dist/modules/staff/data/enrichers.js +426 -12
- package/dist/modules/staff/data/enrichers.js.map +2 -2
- package/dist/modules/staff/data/entities.js +552 -3
- package/dist/modules/staff/data/entities.js.map +2 -2
- package/dist/modules/staff/data/extensions.js +41 -0
- package/dist/modules/staff/data/extensions.js.map +7 -0
- package/dist/modules/staff/data/validators.js +254 -9
- package/dist/modules/staff/data/validators.js.map +2 -2
- package/dist/modules/staff/di.js +42 -1
- package/dist/modules/staff/di.js.map +2 -2
- package/dist/modules/staff/events.js +84 -6
- package/dist/modules/staff/events.js.map +2 -2
- package/dist/modules/staff/events.payloads.js +158 -0
- package/dist/modules/staff/events.payloads.js.map +7 -0
- package/dist/modules/staff/extension-points.js +261 -0
- package/dist/modules/staff/extension-points.js.map +7 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/[id]/page.js +138 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/[id]/page.js.map +7 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/[id]/page.meta.js +12 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/[id]/page.meta.js.map +7 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/page.js +133 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/page.js.map +7 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/page.meta.js +19 -0
- package/dist/modules/staff/frontend/[orgSlug]/portal/time-reports/page.meta.js.map +7 -0
- package/dist/modules/staff/lib/crud.js +11 -1
- package/dist/modules/staff/lib/crud.js.map +2 -2
- package/dist/modules/staff/lib/time-tracking/access.js +92 -0
- package/dist/modules/staff/lib/time-tracking/access.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/billability.js +39 -0
- package/dist/modules/staff/lib/time-tracking/billability.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/capacity.js +68 -0
- package/dist/modules/staff/lib/time-tracking/capacity.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/componentContracts.js +15 -0
- package/dist/modules/staff/lib/time-tracking/componentContracts.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/cost.js +82 -0
- package/dist/modules/staff/lib/time-tracking/cost.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/duration.js +55 -0
- package/dist/modules/staff/lib/time-tracking/duration.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/featureAccess.js +41 -0
- package/dist/modules/staff/lib/time-tracking/featureAccess.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/interval.js +72 -0
- package/dist/modules/staff/lib/time-tracking/interval.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/migrateProjectCodes.js +88 -0
- package/dist/modules/staff/lib/time-tracking/migrateProjectCodes.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/moneyVisibility.js +10 -0
- package/dist/modules/staff/lib/time-tracking/moneyVisibility.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/overlap.js +87 -0
- package/dist/modules/staff/lib/time-tracking/overlap.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/portalRecipients.js +27 -0
- package/dist/modules/staff/lib/time-tracking/portalRecipients.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/portalReports.js +16 -0
- package/dist/modules/staff/lib/time-tracking/portalReports.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/projectCode.js +135 -0
- package/dist/modules/staff/lib/time-tracking/projectCode.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/reapplyRounding.js +187 -0
- package/dist/modules/staff/lib/time-tracking/reapplyRounding.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/recalculationRunner.js +80 -0
- package/dist/modules/staff/lib/time-tracking/recalculationRunner.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/recalculations.js +56 -0
- package/dist/modules/staff/lib/time-tracking/recalculations.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/registries/invoke.js +63 -0
- package/dist/modules/staff/lib/time-tracking/registries/invoke.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/registries/registry.js +62 -0
- package/dist/modules/staff/lib/time-tracking/registries/registry.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/registries/scope.js +21 -0
- package/dist/modules/staff/lib/time-tracking/registries/scope.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/rollup.js +34 -0
- package/dist/modules/staff/lib/time-tracking/rollup.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/rounding.js +66 -0
- package/dist/modules/staff/lib/time-tracking/rounding.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/roundingImpact.js +39 -0
- package/dist/modules/staff/lib/time-tracking/roundingImpact.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/settingKeys.js +214 -0
- package/dist/modules/staff/lib/time-tracking/settingKeys.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/settings.js +87 -0
- package/dist/modules/staff/lib/time-tracking/settings.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/sqlInClause.js +9 -0
- package/dist/modules/staff/lib/time-tracking/sqlInClause.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking/timeEntrySources.js +48 -0
- package/dist/modules/staff/lib/time-tracking/timeEntrySources.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/BoardFilterChips.js +283 -0
- package/dist/modules/staff/lib/time-tracking-ui/BoardFilterChips.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/CustomerPicker.js +324 -0
- package/dist/modules/staff/lib/time-tracking-ui/CustomerPicker.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/DurationInput.js +121 -0
- package/dist/modules/staff/lib/time-tracking-ui/DurationInput.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/EntryDetailsFields.js +188 -0
- package/dist/modules/staff/lib/time-tracking-ui/EntryDetailsFields.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/EntryFilterBar.js +89 -0
- package/dist/modules/staff/lib/time-tracking-ui/EntryFilterBar.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/KanbanBoard.js +855 -0
- package/dist/modules/staff/lib/time-tracking-ui/KanbanBoard.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/KanbanCard.js +360 -0
- package/dist/modules/staff/lib/time-tracking-ui/KanbanCard.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/KanbanColumn.js +259 -0
- package/dist/modules/staff/lib/time-tracking-ui/KanbanColumn.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/NewTaskDialog.js +238 -0
- package/dist/modules/staff/lib/time-tracking-ui/NewTaskDialog.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/NoProjectAccess.js +130 -0
- package/dist/modules/staff/lib/time-tracking-ui/NoProjectAccess.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/PeriodSelector.js +98 -0
- package/dist/modules/staff/lib/time-tracking-ui/PeriodSelector.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/PhasePlaceholder.js +27 -0
- package/dist/modules/staff/lib/time-tracking-ui/PhasePlaceholder.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectCodeField.js +166 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectCodeField.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectCurrencyField.js +295 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectCurrencyField.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectFormSections.js +212 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectFormSections.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectTeamDrawer.js +729 -0
- package/dist/modules/staff/lib/time-tracking-ui/ProjectTeamDrawer.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/ReportSheet.js +217 -0
- package/dist/modules/staff/lib/time-tracking-ui/ReportSheet.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TagPicker.js +158 -0
- package/dist/modules/staff/lib/time-tracking-ui/TagPicker.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskBoardScreen.js +224 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskBoardScreen.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskCommentThread.js +93 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskCommentThread.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskDrawer.js +1196 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskDrawer.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskListView.js +176 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskListView.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskPicker.js +307 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskPicker.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskQuickLog.js +284 -0
- package/dist/modules/staff/lib/time-tracking-ui/TaskQuickLog.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimeEntriesSummaryFooter.js +73 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimeEntriesSummaryFooter.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimeEntryDialog.js +1499 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimeEntryDialog.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimeEntryDurationCell.js +95 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimeEntryDurationCell.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimesheetCalendar.js +188 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimesheetCalendar.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimesheetPeriodFooter.js +61 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimesheetPeriodFooter.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimesheetViewSwitch.js +45 -0
- package/dist/modules/staff/lib/time-tracking-ui/TimesheetViewSwitch.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/boardDirectory.js +176 -0
- package/dist/modules/staff/lib/time-tracking-ui/boardDirectory.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/boardFilters.js +82 -0
- package/dist/modules/staff/lib/time-tracking-ui/boardFilters.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/boardSummary.js +5 -0
- package/dist/modules/staff/lib/time-tracking-ui/boardSummary.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/kanbanBoardData.js +152 -0
- package/dist/modules/staff/lib/time-tracking-ui/kanbanBoardData.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/projectTeamAssignment.js +92 -0
- package/dist/modules/staff/lib/time-tracking-ui/projectTeamAssignment.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/taskDrawerData.js +111 -0
- package/dist/modules/staff/lib/time-tracking-ui/taskDrawerData.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/timeEntryDialogState.js +243 -0
- package/dist/modules/staff/lib/time-tracking-ui/timeEntryDialogState.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/timeEntryListData.js +151 -0
- package/dist/modules/staff/lib/time-tracking-ui/timeEntryListData.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/timeTrackingSettingsForm.js +105 -0
- package/dist/modules/staff/lib/time-tracking-ui/timeTrackingSettingsForm.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/timesheetData.js +132 -0
- package/dist/modules/staff/lib/time-tracking-ui/timesheetData.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/timesheetPeriod.js +205 -0
- package/dist/modules/staff/lib/time-tracking-ui/timesheetPeriod.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/timesheetTargets.js +53 -0
- package/dist/modules/staff/lib/time-tracking-ui/timesheetTargets.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/useBoardFilters.js +77 -0
- package/dist/modules/staff/lib/time-tracking-ui/useBoardFilters.js.map +7 -0
- package/dist/modules/staff/lib/time-tracking-ui/useTimesheetPreferences.js +151 -0
- package/dist/modules/staff/lib/time-tracking-ui/useTimesheetPreferences.js.map +7 -0
- package/dist/modules/staff/lib/timeTrackingSeeds.js +809 -0
- package/dist/modules/staff/lib/timeTrackingSeeds.js.map +7 -0
- package/dist/modules/staff/lib/timesheets/timeEntryCacheInvalidation.js +2 -3
- package/dist/modules/staff/lib/timesheets/timeEntryCacheInvalidation.js.map +2 -2
- package/dist/modules/staff/lib/timesheets/timeEntryDecoration.js +152 -0
- package/dist/modules/staff/lib/timesheets/timeEntryDecoration.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/budgetBurn.js +36 -0
- package/dist/modules/staff/lib/timesheets-projects/budgetBurn.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/budgetThreshold.js +66 -0
- package/dist/modules/staff/lib/timesheets-projects/budgetThreshold.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/budgetThresholdState.js +78 -0
- package/dist/modules/staff/lib/timesheets-projects/budgetThresholdState.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/computeProjectFinancials.js +81 -0
- package/dist/modules/staff/lib/timesheets-projects/computeProjectFinancials.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/reportSelection.js +44 -0
- package/dist/modules/staff/lib/timesheets-projects/reportSelection.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/AssignMembersDialog.js +169 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/AssignMembersDialog.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectBudgetCell.js +22 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectBudgetCell.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectCard.js +51 -1
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectCard.js.map +2 -2
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectsBulkActionsBar.js +70 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectsBulkActionsBar.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/buildReportSheet.js +63 -0
- package/dist/modules/staff/lib/timesheets-reports/buildReportSheet.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/loadReportData.js +170 -0
- package/dist/modules/staff/lib/timesheets-reports/loadReportData.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/pdf.js +205 -0
- package/dist/modules/staff/lib/timesheets-reports/pdf.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportApprovalPolicies.js +68 -0
- package/dist/modules/staff/lib/timesheets-reports/reportApprovalPolicies.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportConfigData.js +135 -0
- package/dist/modules/staff/lib/timesheets-reports/reportConfigData.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportConfigState.js +48 -0
- package/dist/modules/staff/lib/timesheets-reports/reportConfigState.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportExport.js +262 -0
- package/dist/modules/staff/lib/timesheets-reports/reportExport.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportExportFormats.js +34 -0
- package/dist/modules/staff/lib/timesheets-reports/reportExportFormats.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportGroupings.js +79 -0
- package/dist/modules/staff/lib/timesheets-reports/reportGroupings.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportLabels.js +11 -0
- package/dist/modules/staff/lib/timesheets-reports/reportLabels.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportReference.js +83 -0
- package/dist/modules/staff/lib/timesheets-reports/reportReference.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportRows.js +42 -0
- package/dist/modules/staff/lib/timesheets-reports/reportRows.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportSheetData.js +107 -0
- package/dist/modules/staff/lib/timesheets-reports/reportSheetData.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/reportTotals.js +289 -0
- package/dist/modules/staff/lib/timesheets-reports/reportTotals.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-reports/xlsx.js +145 -0
- package/dist/modules/staff/lib/timesheets-reports/xlsx.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/computeTaskRollups.js +116 -0
- package/dist/modules/staff/lib/timesheets-tasks/computeTaskRollups.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/defaultStatusTemplate.js +50 -0
- package/dist/modules/staff/lib/timesheets-tasks/defaultStatusTemplate.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/seedProjectStatuses.js +27 -0
- package/dist/modules/staff/lib/timesheets-tasks/seedProjectStatuses.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/statusPositions.js +65 -0
- package/dist/modules/staff/lib/timesheets-tasks/statusPositions.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/statusSlug.js +31 -0
- package/dist/modules/staff/lib/timesheets-tasks/statusSlug.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/taskHierarchy.js +31 -0
- package/dist/modules/staff/lib/timesheets-tasks/taskHierarchy.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/taskHoursTotals.js +17 -0
- package/dist/modules/staff/lib/timesheets-tasks/taskHoursTotals.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-tasks/taskReference.js +51 -0
- package/dist/modules/staff/lib/timesheets-tasks/taskReference.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/CreateProjectDialog.js +11 -4
- package/dist/modules/staff/lib/timesheets-ui/CreateProjectDialog.js.map +2 -2
- package/dist/modules/staff/lib/timesheets-ui/ListView.js +369 -111
- package/dist/modules/staff/lib/timesheets-ui/ListView.js.map +2 -2
- package/dist/modules/staff/lib/timesheets-ui/TimerBar.js +47 -2
- package/dist/modules/staff/lib/timesheets-ui/TimerBar.js.map +2 -2
- package/dist/modules/staff/migrations/Migration20260813073131_staff.js +79 -0
- package/dist/modules/staff/migrations/Migration20260813073131_staff.js.map +7 -0
- package/dist/modules/staff/migrations/Migration20260824143357_staff.js +15 -0
- package/dist/modules/staff/migrations/Migration20260824143357_staff.js.map +7 -0
- package/dist/modules/staff/notifications.client.js +16 -0
- package/dist/modules/staff/notifications.client.js.map +7 -0
- package/dist/modules/staff/notifications.handlers.js +80 -0
- package/dist/modules/staff/notifications.handlers.js.map +7 -0
- package/dist/modules/staff/notifications.js +168 -0
- package/dist/modules/staff/notifications.js.map +2 -2
- package/dist/modules/staff/search.js +159 -1
- package/dist/modules/staff/search.js.map +2 -2
- package/dist/modules/staff/setup.js +20 -1
- package/dist/modules/staff/setup.js.map +2 -2
- package/dist/modules/staff/subscribers/time-project-access-requested-notification.js +68 -0
- package/dist/modules/staff/subscribers/time-project-access-requested-notification.js.map +7 -0
- package/dist/modules/staff/subscribers/time-project-budget-threshold-notification.js +149 -0
- package/dist/modules/staff/subscribers/time-project-budget-threshold-notification.js.map +7 -0
- package/dist/modules/staff/subscribers/time-report-approved-notification.js +78 -0
- package/dist/modules/staff/subscribers/time-report-approved-notification.js.map +7 -0
- package/dist/modules/staff/subscribers/time-report-portal-broadcast.js +78 -0
- package/dist/modules/staff/subscribers/time-report-portal-broadcast.js.map +7 -0
- package/dist/modules/staff/translations.js +4 -1
- package/dist/modules/staff/translations.js.map +2 -2
- package/dist/modules/staff/widgets/components.js +7 -0
- package/dist/modules/staff/widgets/components.js.map +7 -0
- package/dist/modules/staff/widgets/injection/timer-sidebar-indicator/widget.js +5 -4
- package/dist/modules/staff/widgets/injection/timer-sidebar-indicator/widget.js.map +2 -2
- package/dist/modules/staff/widgets/notifications/TimeProjectAccessRequestedRenderer.js +135 -0
- package/dist/modules/staff/widgets/notifications/TimeProjectAccessRequestedRenderer.js.map +7 -0
- package/dist/modules/staff/widgets/notifications/index.js +5 -0
- package/dist/modules/staff/widgets/notifications/index.js.map +7 -0
- package/dist/modules/staff/workers/timesheets-reapply-rounding.js +43 -0
- package/dist/modules/staff/workers/timesheets-reapply-rounding.js.map +7 -0
- package/generated/entities/staff_time_entry/index.ts +7 -0
- package/generated/entities/staff_time_entry_tag/index.ts +6 -0
- package/generated/entities/staff_time_project/index.ts +8 -0
- package/generated/entities/staff_time_report/index.ts +27 -0
- package/generated/entities/staff_time_report_entry/index.ts +12 -0
- package/generated/entities/staff_time_report_event/index.ts +9 -0
- package/generated/entities/staff_time_report_project/index.ts +6 -0
- package/generated/entities/staff_time_tag/index.ts +9 -0
- package/generated/entities/staff_time_task/index.ts +17 -0
- package/generated/entities/staff_time_task_comment/index.ts +9 -0
- package/generated/entities/staff_time_task_status/index.ts +13 -0
- package/generated/entities/staff_time_task_tag/index.ts +6 -0
- package/generated/entities.ids.generated.ts +11 -1
- package/generated/entity-fields-registry.ts +149 -0
- package/package.json +7 -7
- package/src/helpers/integration/timesheetFixtures.ts +31 -1
- package/src/modules/auth/README.md +1 -1
- package/src/modules/auth/cli.ts +35 -1
- package/src/modules/auth/i18n/de.json +7 -0
- package/src/modules/auth/i18n/en.json +7 -0
- package/src/modules/auth/i18n/es.json +7 -0
- package/src/modules/auth/i18n/ko.json +7 -0
- package/src/modules/auth/i18n/pl.json +7 -0
- package/src/modules/auth/lib/backendChrome.tsx +1 -0
- package/src/modules/customer_accounts/lib/customerRoleAcls.ts +79 -0
- package/src/modules/customer_accounts/setup.ts +1 -45
- package/src/modules/data_sync/AGENTS.md +34 -0
- package/src/modules/data_sync/api/options.ts +2 -0
- package/src/modules/data_sync/backend/data-sync/page.tsx +82 -33
- package/src/modules/data_sync/i18n/de.json +1 -0
- package/src/modules/data_sync/i18n/en.json +1 -0
- package/src/modules/data_sync/i18n/es.json +1 -0
- package/src/modules/data_sync/i18n/ko.json +1 -0
- package/src/modules/data_sync/i18n/pl.json +1 -0
- package/src/modules/data_sync/lib/adapter.ts +45 -0
- package/src/modules/data_sync/lib/start-controls.ts +89 -0
- package/src/modules/staff/AGENTS.md +769 -1
- package/src/modules/staff/acl.ts +9 -0
- package/src/modules/staff/ai-agents.ts +189 -0
- package/src/modules/staff/ai-tools/time-tracking-pack.ts +494 -0
- package/src/modules/staff/ai-tools/types.ts +82 -0
- package/src/modules/staff/ai-tools.ts +13 -0
- package/src/modules/staff/analytics.ts +113 -0
- package/src/modules/staff/api/guards.ts +85 -3
- package/src/modules/staff/api/leave-requests/accept/route.ts +0 -2
- package/src/modules/staff/api/leave-requests/reject/route.ts +0 -2
- package/src/modules/staff/api/portal/time-reports/[id]/route.ts +182 -0
- package/src/modules/staff/api/portal/time-reports/route.ts +270 -0
- package/src/modules/staff/api/team-members/self/route.ts +0 -2
- package/src/modules/staff/api/team-members/tags/assign/route.ts +0 -2
- package/src/modules/staff/api/team-members/tags/unassign/route.ts +0 -2
- package/src/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.ts +292 -0
- package/src/modules/staff/api/timesheets/access-requests/route.ts +299 -0
- package/src/modules/staff/api/timesheets/my-projects/[projectId]/route.ts +15 -7
- package/src/modules/staff/api/timesheets/my-projects/route.ts +14 -1
- package/src/modules/staff/api/timesheets/my-work/myWorkAggregate.ts +90 -0
- package/src/modules/staff/api/timesheets/my-work/route.ts +475 -0
- package/src/modules/staff/api/timesheets/projects/kpis/route.ts +15 -2
- package/src/modules/staff/api/timesheets/reports/[id]/close/route.ts +203 -0
- package/src/modules/staff/api/timesheets/reports/[id]/export/route.ts +315 -0
- package/src/modules/staff/api/timesheets/reports/[id]/sheet/route.ts +220 -0
- package/src/modules/staff/api/timesheets/reports/[id]/unlock/route.ts +208 -0
- package/src/modules/staff/api/timesheets/reports/preview/route.ts +449 -0
- package/src/modules/staff/api/timesheets/reports/route.ts +386 -0
- package/src/modules/staff/api/timesheets/reports/shared.ts +121 -0
- package/src/modules/staff/api/timesheets/settings/reapply-rounding/route.ts +205 -0
- package/src/modules/staff/api/timesheets/settings/rounding-impact/route.ts +226 -0
- package/src/modules/staff/api/timesheets/settings/route.ts +242 -0
- package/src/modules/staff/api/timesheets/tags/access.ts +134 -0
- package/src/modules/staff/api/timesheets/tags/entry-assignments/route.ts +290 -0
- package/src/modules/staff/api/timesheets/tags/route.ts +177 -0
- package/src/modules/staff/api/timesheets/tags/task-assignments/route.ts +294 -0
- package/src/modules/staff/api/timesheets/task-statuses/route.ts +232 -0
- package/src/modules/staff/api/timesheets/tasks/[id]/comments/route.ts +532 -0
- package/src/modules/staff/api/timesheets/tasks/[id]/status/route.ts +271 -0
- package/src/modules/staff/api/timesheets/tasks/route.ts +443 -0
- package/src/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.ts +306 -0
- package/src/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.ts +32 -10
- package/src/modules/staff/api/timesheets/time-entries/[id]/segments/route.ts +32 -17
- package/src/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.ts +27 -6
- package/src/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.ts +36 -6
- package/src/modules/staff/api/timesheets/time-entries/bulk/route.ts +331 -34
- package/src/modules/staff/api/timesheets/time-entries/copy-day/route.ts +533 -0
- package/src/modules/staff/api/timesheets/time-entries/overlaps/route.ts +457 -0
- package/src/modules/staff/api/timesheets/time-entries/route.ts +378 -24
- package/src/modules/staff/api/timesheets/time-entries/start-timer/route.ts +31 -9
- package/src/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.ts +246 -0
- package/src/modules/staff/api/timesheets/time-projects/[id]/employees/route.ts +62 -2
- package/src/modules/staff/api/timesheets/time-projects/route.ts +397 -22
- package/src/modules/staff/backend/staff/time-tracking/board/page.meta.ts +14 -0
- package/src/modules/staff/backend/staff/time-tracking/board/page.tsx +151 -0
- package/src/modules/staff/backend/staff/time-tracking/entries/page.meta.ts +14 -0
- package/src/modules/staff/backend/staff/time-tracking/entries/page.tsx +1229 -0
- package/src/modules/staff/backend/staff/time-tracking/page.meta.ts +11 -0
- package/src/modules/staff/backend/staff/time-tracking/page.tsx +823 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/[id]/board/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/[id]/board/page.tsx +81 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/[id]/edit/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/[id]/edit/page.tsx +275 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/[id]/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/[id]/page.tsx +1420 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/create/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/create/page.tsx +109 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/page.meta.ts +15 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/page.tsx +1254 -0
- package/src/modules/staff/backend/staff/time-tracking/projects/projectFormConfig.ts +466 -0
- package/src/modules/staff/backend/staff/time-tracking/reports/[id]/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/time-tracking/reports/[id]/page.tsx +632 -0
- package/src/modules/staff/backend/staff/time-tracking/reports/create/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/time-tracking/reports/create/page.tsx +867 -0
- package/src/modules/staff/backend/staff/time-tracking/reports/page.meta.ts +14 -0
- package/src/modules/staff/backend/staff/time-tracking/reports/page.tsx +246 -0
- package/src/modules/staff/backend/staff/time-tracking/settings/page.meta.ts +14 -0
- package/src/modules/staff/backend/staff/time-tracking/settings/page.tsx +701 -0
- package/src/modules/staff/backend/staff/time-tracking/timesheet/GridView.tsx +953 -0
- package/src/modules/staff/backend/staff/time-tracking/timesheet/page.meta.ts +14 -0
- package/src/modules/staff/backend/staff/time-tracking/timesheet/page.tsx +800 -0
- package/src/modules/staff/backend/staff/timesheets/page.meta.ts +6 -6
- package/src/modules/staff/backend/staff/timesheets/page.tsx +12 -1010
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.meta.ts +0 -6
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.tsx +4 -158
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/page.meta.ts +0 -6
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/page.tsx +4 -609
- package/src/modules/staff/backend/staff/timesheets/projects/create/page.meta.ts +0 -6
- package/src/modules/staff/backend/staff/timesheets/projects/create/page.tsx +3 -89
- package/src/modules/staff/backend/staff/timesheets/projects/page.meta.ts +2 -19
- package/src/modules/staff/backend/staff/timesheets/projects/page.tsx +3 -778
- package/src/modules/staff/ce.ts +63 -0
- package/src/modules/staff/cli.ts +207 -1
- package/src/modules/staff/commands/index.ts +5 -0
- package/src/modules/staff/commands/timesheets-entries.ts +1006 -28
- package/src/modules/staff/commands/timesheets-projects.ts +593 -7
- package/src/modules/staff/commands/timesheets-reports.ts +1329 -0
- package/src/modules/staff/commands/timesheets-tags.ts +1315 -0
- package/src/modules/staff/commands/timesheets-task-comments.ts +583 -0
- package/src/modules/staff/commands/timesheets-task-statuses.ts +889 -0
- package/src/modules/staff/commands/timesheets-tasks.ts +1121 -0
- package/src/modules/staff/data/enrichers.ts +675 -10
- package/src/modules/staff/data/entities.ts +494 -2
- package/src/modules/staff/data/extensions.ts +68 -0
- package/src/modules/staff/data/validators.ts +348 -3
- package/src/modules/staff/di.ts +96 -0
- package/src/modules/staff/events.payloads.ts +268 -0
- package/src/modules/staff/events.ts +87 -5
- package/src/modules/staff/extension-points.ts +308 -0
- package/src/modules/staff/frontend/[orgSlug]/portal/time-reports/[id]/page.meta.ts +10 -0
- package/src/modules/staff/frontend/[orgSlug]/portal/time-reports/[id]/page.tsx +225 -0
- package/src/modules/staff/frontend/[orgSlug]/portal/time-reports/page.meta.ts +17 -0
- package/src/modules/staff/frontend/[orgSlug]/portal/time-reports/page.tsx +182 -0
- package/src/modules/staff/i18n/de.json +899 -0
- package/src/modules/staff/i18n/en.json +899 -0
- package/src/modules/staff/i18n/es.json +899 -0
- package/src/modules/staff/i18n/ko.json +899 -0
- package/src/modules/staff/i18n/pl.json +899 -0
- package/src/modules/staff/lib/crud.ts +14 -3
- package/src/modules/staff/lib/time-tracking/access.ts +155 -0
- package/src/modules/staff/lib/time-tracking/billability.ts +68 -0
- package/src/modules/staff/lib/time-tracking/capacity.ts +124 -0
- package/src/modules/staff/lib/time-tracking/componentContracts.ts +26 -0
- package/src/modules/staff/lib/time-tracking/cost.ts +144 -0
- package/src/modules/staff/lib/time-tracking/duration.ts +68 -0
- package/src/modules/staff/lib/time-tracking/featureAccess.ts +115 -0
- package/src/modules/staff/lib/time-tracking/interval.ts +90 -0
- package/src/modules/staff/lib/time-tracking/migrateProjectCodes.ts +161 -0
- package/src/modules/staff/lib/time-tracking/moneyVisibility.ts +37 -0
- package/src/modules/staff/lib/time-tracking/overlap.ts +159 -0
- package/src/modules/staff/lib/time-tracking/portalRecipients.ts +76 -0
- package/src/modules/staff/lib/time-tracking/portalReports.ts +31 -0
- package/src/modules/staff/lib/time-tracking/projectCode.ts +221 -0
- package/src/modules/staff/lib/time-tracking/reapplyRounding.ts +313 -0
- package/src/modules/staff/lib/time-tracking/recalculationRunner.ts +118 -0
- package/src/modules/staff/lib/time-tracking/recalculations.ts +135 -0
- package/src/modules/staff/lib/time-tracking/registries/invoke.ts +122 -0
- package/src/modules/staff/lib/time-tracking/registries/registry.ts +124 -0
- package/src/modules/staff/lib/time-tracking/registries/scope.ts +56 -0
- package/src/modules/staff/lib/time-tracking/rollup.ts +59 -0
- package/src/modules/staff/lib/time-tracking/rounding.ts +126 -0
- package/src/modules/staff/lib/time-tracking/roundingImpact.ts +75 -0
- package/src/modules/staff/lib/time-tracking/settingKeys.ts +274 -0
- package/src/modules/staff/lib/time-tracking/settings.ts +168 -0
- package/src/modules/staff/lib/time-tracking/sqlInClause.ts +22 -0
- package/src/modules/staff/lib/time-tracking/timeEntrySources.ts +85 -0
- package/src/modules/staff/lib/time-tracking-ui/BoardFilterChips.tsx +360 -0
- package/src/modules/staff/lib/time-tracking-ui/CustomerPicker.tsx +427 -0
- package/src/modules/staff/lib/time-tracking-ui/DurationInput.tsx +192 -0
- package/src/modules/staff/lib/time-tracking-ui/EntryDetailsFields.tsx +224 -0
- package/src/modules/staff/lib/time-tracking-ui/EntryFilterBar.tsx +144 -0
- package/src/modules/staff/lib/time-tracking-ui/KanbanBoard.tsx +1065 -0
- package/src/modules/staff/lib/time-tracking-ui/KanbanCard.tsx +435 -0
- package/src/modules/staff/lib/time-tracking-ui/KanbanColumn.tsx +316 -0
- package/src/modules/staff/lib/time-tracking-ui/NewTaskDialog.tsx +291 -0
- package/src/modules/staff/lib/time-tracking-ui/NoProjectAccess.tsx +162 -0
- package/src/modules/staff/lib/time-tracking-ui/PeriodSelector.tsx +149 -0
- package/src/modules/staff/lib/time-tracking-ui/PhasePlaceholder.tsx +31 -0
- package/src/modules/staff/lib/time-tracking-ui/ProjectCodeField.tsx +230 -0
- package/src/modules/staff/lib/time-tracking-ui/ProjectCurrencyField.tsx +432 -0
- package/src/modules/staff/lib/time-tracking-ui/ProjectFormSections.tsx +323 -0
- package/src/modules/staff/lib/time-tracking-ui/ProjectTeamDrawer.tsx +930 -0
- package/src/modules/staff/lib/time-tracking-ui/ReportSheet.tsx +357 -0
- package/src/modules/staff/lib/time-tracking-ui/TagPicker.tsx +195 -0
- package/src/modules/staff/lib/time-tracking-ui/TaskBoardScreen.tsx +243 -0
- package/src/modules/staff/lib/time-tracking-ui/TaskCommentThread.tsx +137 -0
- package/src/modules/staff/lib/time-tracking-ui/TaskDrawer.tsx +1405 -0
- package/src/modules/staff/lib/time-tracking-ui/TaskListView.tsx +260 -0
- package/src/modules/staff/lib/time-tracking-ui/TaskPicker.tsx +435 -0
- package/src/modules/staff/lib/time-tracking-ui/TaskQuickLog.tsx +296 -0
- package/src/modules/staff/lib/time-tracking-ui/TimeEntriesSummaryFooter.tsx +97 -0
- package/src/modules/staff/lib/time-tracking-ui/TimeEntryDialog.tsx +1929 -0
- package/src/modules/staff/lib/time-tracking-ui/TimeEntryDurationCell.tsx +126 -0
- package/src/modules/staff/lib/time-tracking-ui/TimesheetCalendar.tsx +265 -0
- package/src/modules/staff/lib/time-tracking-ui/TimesheetPeriodFooter.tsx +78 -0
- package/src/modules/staff/lib/time-tracking-ui/TimesheetViewSwitch.tsx +70 -0
- package/src/modules/staff/lib/time-tracking-ui/boardDirectory.ts +231 -0
- package/src/modules/staff/lib/time-tracking-ui/boardFilters.ts +128 -0
- package/src/modules/staff/lib/time-tracking-ui/boardSummary.ts +20 -0
- package/src/modules/staff/lib/time-tracking-ui/kanbanBoardData.ts +228 -0
- package/src/modules/staff/lib/time-tracking-ui/projectTeamAssignment.ts +143 -0
- package/src/modules/staff/lib/time-tracking-ui/taskDrawerData.ts +194 -0
- package/src/modules/staff/lib/time-tracking-ui/timeEntryDialogState.ts +400 -0
- package/src/modules/staff/lib/time-tracking-ui/timeEntryListData.ts +271 -0
- package/src/modules/staff/lib/time-tracking-ui/timeTrackingSettingsForm.ts +168 -0
- package/src/modules/staff/lib/time-tracking-ui/timesheetData.ts +225 -0
- package/src/modules/staff/lib/time-tracking-ui/timesheetPeriod.ts +278 -0
- package/src/modules/staff/lib/time-tracking-ui/timesheetTargets.ts +93 -0
- package/src/modules/staff/lib/time-tracking-ui/useBoardFilters.ts +107 -0
- package/src/modules/staff/lib/time-tracking-ui/useTimesheetPreferences.ts +245 -0
- package/src/modules/staff/lib/timeTrackingSeeds.ts +1037 -0
- package/src/modules/staff/lib/timesheets/timeEntryCacheInvalidation.ts +11 -10
- package/src/modules/staff/lib/timesheets/timeEntryDecoration.ts +256 -0
- package/src/modules/staff/lib/timesheets-projects/budgetBurn.ts +60 -0
- package/src/modules/staff/lib/timesheets-projects/budgetThreshold.ts +135 -0
- package/src/modules/staff/lib/timesheets-projects/budgetThresholdState.ts +137 -0
- package/src/modules/staff/lib/timesheets-projects/computeProjectFinancials.ts +142 -0
- package/src/modules/staff/lib/timesheets-projects/reportSelection.ts +82 -0
- package/src/modules/staff/lib/timesheets-projects-ui/AssignMembersDialog.tsx +237 -0
- package/src/modules/staff/lib/timesheets-projects-ui/ProjectBudgetCell.tsx +33 -0
- package/src/modules/staff/lib/timesheets-projects-ui/ProjectCard.tsx +56 -1
- package/src/modules/staff/lib/timesheets-projects-ui/ProjectsBulkActionsBar.tsx +90 -0
- package/src/modules/staff/lib/timesheets-reports/buildReportSheet.ts +125 -0
- package/src/modules/staff/lib/timesheets-reports/loadReportData.ts +251 -0
- package/src/modules/staff/lib/timesheets-reports/pdf.ts +263 -0
- package/src/modules/staff/lib/timesheets-reports/reportApprovalPolicies.ts +137 -0
- package/src/modules/staff/lib/timesheets-reports/reportConfigData.ts +247 -0
- package/src/modules/staff/lib/timesheets-reports/reportConfigState.ts +89 -0
- package/src/modules/staff/lib/timesheets-reports/reportExport.ts +373 -0
- package/src/modules/staff/lib/timesheets-reports/reportExportFormats.ts +71 -0
- package/src/modules/staff/lib/timesheets-reports/reportGroupings.ts +153 -0
- package/src/modules/staff/lib/timesheets-reports/reportLabels.ts +23 -0
- package/src/modules/staff/lib/timesheets-reports/reportReference.ts +146 -0
- package/src/modules/staff/lib/timesheets-reports/reportRows.ts +89 -0
- package/src/modules/staff/lib/timesheets-reports/reportSheetData.ts +196 -0
- package/src/modules/staff/lib/timesheets-reports/reportTotals.ts +544 -0
- package/src/modules/staff/lib/timesheets-reports/xlsx.ts +207 -0
- package/src/modules/staff/lib/timesheets-tasks/computeTaskRollups.ts +238 -0
- package/src/modules/staff/lib/timesheets-tasks/defaultStatusTemplate.ts +90 -0
- package/src/modules/staff/lib/timesheets-tasks/seedProjectStatuses.ts +43 -0
- package/src/modules/staff/lib/timesheets-tasks/statusPositions.ts +132 -0
- package/src/modules/staff/lib/timesheets-tasks/statusSlug.ts +43 -0
- package/src/modules/staff/lib/timesheets-tasks/taskHierarchy.ts +99 -0
- package/src/modules/staff/lib/timesheets-tasks/taskHoursTotals.ts +42 -0
- package/src/modules/staff/lib/timesheets-tasks/taskReference.ts +108 -0
- package/src/modules/staff/lib/timesheets-ui/CreateProjectDialog.tsx +18 -4
- package/src/modules/staff/lib/timesheets-ui/ListView.tsx +504 -149
- package/src/modules/staff/lib/timesheets-ui/TimerBar.tsx +50 -2
- package/src/modules/staff/migrations/.snapshot-open-mercato.json +3244 -228
- package/src/modules/staff/migrations/Migration20260813073131_staff.ts +94 -0
- package/src/modules/staff/migrations/Migration20260824143357_staff.ts +17 -0
- package/src/modules/staff/notifications.client.ts +16 -0
- package/src/modules/staff/notifications.handlers.ts +88 -0
- package/src/modules/staff/notifications.ts +163 -0
- package/src/modules/staff/search.ts +191 -1
- package/src/modules/staff/setup.ts +22 -0
- package/src/modules/staff/subscribers/time-project-access-requested-notification.ts +95 -0
- package/src/modules/staff/subscribers/time-project-budget-threshold-notification.ts +226 -0
- package/src/modules/staff/subscribers/time-report-approved-notification.ts +116 -0
- package/src/modules/staff/subscribers/time-report-portal-broadcast.ts +120 -0
- package/src/modules/staff/translations.ts +17 -0
- package/src/modules/staff/widgets/components.ts +34 -0
- package/src/modules/staff/widgets/injection/timer-sidebar-indicator/widget.tsx +6 -5
- package/src/modules/staff/widgets/notifications/TimeProjectAccessRequestedRenderer.tsx +138 -0
- package/src/modules/staff/widgets/notifications/index.ts +1 -0
- package/src/modules/staff/workers/timesheets-reapply-rounding.ts +59 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/projectFormConfig.js +0 -123
- package/dist/modules/staff/backend/staff/timesheets/projects/projectFormConfig.js.map +0 -7
- package/src/modules/staff/backend/staff/timesheets/projects/projectFormConfig.ts +0 -138
|
@@ -0,0 +1,889 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kanban column commands for the per-project boards of screen 6 (D-1).
|
|
3
|
+
*
|
|
4
|
+
* Columns are project configuration rather than task data, which is why every
|
|
5
|
+
* write here is guarded by `staff.timesheets.projects.manage` at the route while
|
|
6
|
+
* the board itself only needs `…tasks.view` to read them.
|
|
7
|
+
*
|
|
8
|
+
* The board carries three invariants no caller is trusted with:
|
|
9
|
+
*
|
|
10
|
+
* 1. A project always has at least one column. Deleting the last one is refused
|
|
11
|
+
* — a project with an empty board cannot accept a task and no screen exists
|
|
12
|
+
* that would put a column back.
|
|
13
|
+
* 2. Exactly one column is `is_default` and at least one is `is_done`. New tasks
|
|
14
|
+
* land on the default; the drawer's subtask tick sends the first done column.
|
|
15
|
+
* Both are repaired here, never taken on faith from the request.
|
|
16
|
+
* 3. A column that still holds tasks is not deleted. The refusal names the count
|
|
17
|
+
* and stops there: it does NOT accept a move-target and does NOT relocate the
|
|
18
|
+
* cards itself, because moving them belongs to the task status endpoint that
|
|
19
|
+
* owns the task's `closed_at`, its index document and its status_changed
|
|
20
|
+
* event. Emptying the column first is the caller's job.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { z } from 'zod'
|
|
24
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
25
|
+
import type { CommandHandler } from '@open-mercato/shared/lib/commands'
|
|
26
|
+
import { registerCommand } from '@open-mercato/shared/lib/commands'
|
|
27
|
+
import { CrudHttpError, isUniqueViolation } from '@open-mercato/shared/lib/crud/errors'
|
|
28
|
+
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
29
|
+
import { buildChanges, emitCrudSideEffects, emitCrudUndoSideEffects } from '@open-mercato/shared/lib/commands/helpers'
|
|
30
|
+
import { withAtomicFlush } from '@open-mercato/shared/lib/commands/flush'
|
|
31
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
32
|
+
import type { CrudIndexerConfig } from '@open-mercato/shared/lib/crud/types'
|
|
33
|
+
import type { DataEngine } from '@open-mercato/shared/lib/data/engine'
|
|
34
|
+
import { StaffTimeProject, StaffTimeTask, StaffTimeTaskStatus } from '../data/entities'
|
|
35
|
+
import {
|
|
36
|
+
staffTimeTaskStatusCreateSchema,
|
|
37
|
+
staffTimeTaskStatusUpdateSchema,
|
|
38
|
+
staffTimeTaskStatusReorderSchema,
|
|
39
|
+
type StaffTimeTaskStatusCreateInput,
|
|
40
|
+
type StaffTimeTaskStatusUpdateInput,
|
|
41
|
+
} from '../data/validators'
|
|
42
|
+
import { deriveTaskStatusSlug } from '../lib/timesheets-tasks/statusSlug'
|
|
43
|
+
import { nextStatusPosition, planStatusReorder } from '../lib/timesheets-tasks/statusPositions'
|
|
44
|
+
import {
|
|
45
|
+
applyScopeToWhere,
|
|
46
|
+
commandActorScope,
|
|
47
|
+
commandInputScope,
|
|
48
|
+
ensureOrganizationScope,
|
|
49
|
+
ensureTenantScope,
|
|
50
|
+
extractUndoPayload,
|
|
51
|
+
scopedStaffSnapshotWhere,
|
|
52
|
+
staffSnapshotScopeFromContext,
|
|
53
|
+
staffSnapshotScopeFromSnapshot,
|
|
54
|
+
type StaffCommandScope,
|
|
55
|
+
type StaffSnapshotScope,
|
|
56
|
+
} from './shared'
|
|
57
|
+
|
|
58
|
+
const logger = createLogger('staff').child({ component: 'timesheets-task-statuses' })
|
|
59
|
+
|
|
60
|
+
export const staffTimeTaskStatusCommandIds = {
|
|
61
|
+
create: 'staff.timesheets.task_statuses.create',
|
|
62
|
+
update: 'staff.timesheets.task_statuses.update',
|
|
63
|
+
delete: 'staff.timesheets.task_statuses.delete',
|
|
64
|
+
reorder: 'staff.timesheets.task_statuses.reorder',
|
|
65
|
+
} as const
|
|
66
|
+
|
|
67
|
+
export const TASK_STATUS_LAST_COLUMN_CODE = 'task_status_last_column'
|
|
68
|
+
export const TASK_STATUS_HAS_TASKS_CODE = 'task_status_has_tasks'
|
|
69
|
+
export const TASK_STATUS_DEFAULT_REQUIRED_CODE = 'task_status_default_required'
|
|
70
|
+
export const TASK_STATUS_DONE_REQUIRED_CODE = 'task_status_done_required'
|
|
71
|
+
export const TASK_STATUS_SLUG_DUPLICATE_CODE = 'task_status_slug_duplicate'
|
|
72
|
+
export const TASK_STATUS_UNKNOWN_IDS_CODE = 'task_status_unknown_ids'
|
|
73
|
+
|
|
74
|
+
const taskStatusCrudIndexer: CrudIndexerConfig<StaffTimeTaskStatus> = {
|
|
75
|
+
entityType: 'staff:staff_time_task_status',
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// The board declares no CRUD event ids of its own in `events.ts`: a column write is
|
|
79
|
+
// a configuration change the board re-reads, so these commands queue index and
|
|
80
|
+
// cache side effects only. Task movement keeps its own `time_task.status_changed`.
|
|
81
|
+
|
|
82
|
+
type Translate = (key: string, fallback: string) => string
|
|
83
|
+
|
|
84
|
+
type TaskStatusSnapshot = {
|
|
85
|
+
id: string
|
|
86
|
+
tenantId: string
|
|
87
|
+
organizationId: string
|
|
88
|
+
timeProjectId: string
|
|
89
|
+
name: string
|
|
90
|
+
slug: string
|
|
91
|
+
color: string | null
|
|
92
|
+
position: number
|
|
93
|
+
isDefault: boolean
|
|
94
|
+
isDone: boolean
|
|
95
|
+
deletedAt: string | null
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The sibling columns' ordering flags as they stood before the write. Every one of
|
|
100
|
+
* these commands can move a neighbour — promoting a new default, re-spacing the
|
|
101
|
+
* board after a compaction, handing `is_done` to a survivor — so undo has to be
|
|
102
|
+
* able to put the whole board back, not just the row that was addressed.
|
|
103
|
+
*/
|
|
104
|
+
type TaskStatusBoardRow = {
|
|
105
|
+
id: string
|
|
106
|
+
position: number
|
|
107
|
+
isDefault: boolean
|
|
108
|
+
isDone: boolean
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
type TaskStatusUndoPayload = {
|
|
112
|
+
before?: TaskStatusSnapshot | null
|
|
113
|
+
after?: TaskStatusSnapshot | null
|
|
114
|
+
boardBefore?: TaskStatusBoardRow[] | null
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function toSnapshot(status: StaffTimeTaskStatus): TaskStatusSnapshot {
|
|
118
|
+
return {
|
|
119
|
+
id: status.id,
|
|
120
|
+
tenantId: status.tenantId,
|
|
121
|
+
organizationId: status.organizationId,
|
|
122
|
+
timeProjectId: status.timeProjectId,
|
|
123
|
+
name: status.name,
|
|
124
|
+
slug: status.slug,
|
|
125
|
+
color: status.color ?? null,
|
|
126
|
+
position: status.position,
|
|
127
|
+
isDefault: status.isDefault,
|
|
128
|
+
isDone: status.isDone,
|
|
129
|
+
deletedAt: status.deletedAt ? status.deletedAt.toISOString() : null,
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function toBoardRow(status: StaffTimeTaskStatus): TaskStatusBoardRow {
|
|
134
|
+
return {
|
|
135
|
+
id: status.id,
|
|
136
|
+
position: status.position,
|
|
137
|
+
isDefault: status.isDefault,
|
|
138
|
+
isDone: status.isDone,
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function loadTaskStatusSnapshot(
|
|
143
|
+
em: EntityManager,
|
|
144
|
+
id: string,
|
|
145
|
+
scope?: StaffSnapshotScope | null,
|
|
146
|
+
): Promise<TaskStatusSnapshot | null> {
|
|
147
|
+
const status = await em.findOne(StaffTimeTaskStatus, scopedStaffSnapshotWhere(id, scope))
|
|
148
|
+
return status ? toSnapshot(status) : null
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function boardWhere(timeProjectId: string, scope: StaffCommandScope) {
|
|
152
|
+
return applyScopeToWhere<StaffTimeTaskStatus>({ timeProjectId, deletedAt: null }, scope)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async function loadBoard(
|
|
156
|
+
em: EntityManager,
|
|
157
|
+
timeProjectId: string,
|
|
158
|
+
scope: StaffCommandScope,
|
|
159
|
+
): Promise<StaffTimeTaskStatus[]> {
|
|
160
|
+
const statuses = await em.find(StaffTimeTaskStatus, boardWhere(timeProjectId, scope))
|
|
161
|
+
return statuses.sort((left, right) => left.position - right.position || (left.id < right.id ? -1 : 1))
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async function loadBoardSnapshot(
|
|
165
|
+
em: EntityManager,
|
|
166
|
+
timeProjectId: string,
|
|
167
|
+
scope?: StaffSnapshotScope | null,
|
|
168
|
+
): Promise<TaskStatusBoardRow[]> {
|
|
169
|
+
const statuses = await em.find(StaffTimeTaskStatus, {
|
|
170
|
+
timeProjectId,
|
|
171
|
+
deletedAt: null,
|
|
172
|
+
...snapshotScopeWhere(scope),
|
|
173
|
+
})
|
|
174
|
+
return statuses.map(toBoardRow)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function snapshotScopeWhere(scope?: StaffSnapshotScope | null): { tenantId?: string; organizationId?: string } {
|
|
178
|
+
const where: { tenantId?: string; organizationId?: string } = {}
|
|
179
|
+
if (scope?.tenantId) where.tenantId = scope.tenantId
|
|
180
|
+
if (scope?.organizationId) where.organizationId = scope.organizationId
|
|
181
|
+
return where
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function slugDuplicateError(translate: Translate, slug: string): CrudHttpError {
|
|
185
|
+
const message = translate(
|
|
186
|
+
'staff.time_tracking.taskStatuses.errors.slugDuplicate',
|
|
187
|
+
'A column with this slug already exists on this project.',
|
|
188
|
+
)
|
|
189
|
+
return new CrudHttpError(409, {
|
|
190
|
+
code: TASK_STATUS_SLUG_DUPLICATE_CODE,
|
|
191
|
+
error: message,
|
|
192
|
+
slug,
|
|
193
|
+
fieldErrors: { slug: message },
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function notFoundError(translate: Translate): CrudHttpError {
|
|
198
|
+
return new CrudHttpError(404, {
|
|
199
|
+
error: translate(
|
|
200
|
+
'staff.time_tracking.taskStatuses.errors.notFound',
|
|
201
|
+
'Task status not found or not accessible.',
|
|
202
|
+
),
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function projectNotFoundError(translate: Translate): CrudHttpError {
|
|
207
|
+
const message = translate('staff.timesheets.errors.projectNotFound', 'Time project not found or not accessible.')
|
|
208
|
+
return new CrudHttpError(422, {
|
|
209
|
+
error: message,
|
|
210
|
+
fieldErrors: { timeProjectId: message },
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Applies invariant 2 to a board that is about to be written: the caller's wish is
|
|
216
|
+
* honoured where it can be, and repaired where it cannot. A board can never end up
|
|
217
|
+
* with two defaults or with nothing terminal.
|
|
218
|
+
*/
|
|
219
|
+
function normalizeBoardFlags(board: StaffTimeTaskStatus[], preferredDefaultId: string | null): void {
|
|
220
|
+
if (board.length === 0) return
|
|
221
|
+
const defaults = board.filter((status) => status.isDefault)
|
|
222
|
+
const preferred = preferredDefaultId ? board.find((status) => status.id === preferredDefaultId) ?? null : null
|
|
223
|
+
const winner = preferred ?? defaults[0] ?? board[0]
|
|
224
|
+
for (const status of board) status.isDefault = status.id === winner.id
|
|
225
|
+
if (!board.some((status) => status.isDone)) {
|
|
226
|
+
board[board.length - 1].isDone = true
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async function requireProject(
|
|
231
|
+
em: EntityManager,
|
|
232
|
+
timeProjectId: string,
|
|
233
|
+
scope: StaffCommandScope,
|
|
234
|
+
translate: Translate,
|
|
235
|
+
): Promise<void> {
|
|
236
|
+
const project = await em.findOne(
|
|
237
|
+
StaffTimeProject,
|
|
238
|
+
applyScopeToWhere<StaffTimeProject>({ id: timeProjectId, deletedAt: null }, scope),
|
|
239
|
+
{ fields: ['id'] },
|
|
240
|
+
)
|
|
241
|
+
if (!project) throw projectNotFoundError(translate)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
async function restoreBoard(
|
|
245
|
+
em: EntityManager,
|
|
246
|
+
boardBefore: TaskStatusBoardRow[] | null | undefined,
|
|
247
|
+
scope: StaffSnapshotScope | null,
|
|
248
|
+
): Promise<StaffTimeTaskStatus[]> {
|
|
249
|
+
if (!boardBefore || boardBefore.length === 0) return []
|
|
250
|
+
const ids = boardBefore.map((row) => row.id)
|
|
251
|
+
const statuses = await em.find(StaffTimeTaskStatus, {
|
|
252
|
+
id: { $in: ids },
|
|
253
|
+
...snapshotScopeWhere(scope),
|
|
254
|
+
})
|
|
255
|
+
const byId = new Map(statuses.map((status) => [status.id, status]))
|
|
256
|
+
const restored: StaffTimeTaskStatus[] = []
|
|
257
|
+
for (const row of boardBefore) {
|
|
258
|
+
const status = byId.get(row.id)
|
|
259
|
+
if (!status) continue
|
|
260
|
+
status.position = row.position
|
|
261
|
+
status.isDefault = row.isDefault
|
|
262
|
+
status.isDone = row.isDone
|
|
263
|
+
status.updatedAt = new Date()
|
|
264
|
+
restored.push(status)
|
|
265
|
+
}
|
|
266
|
+
return restored
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const createTaskStatusCommand: CommandHandler<StaffTimeTaskStatusCreateInput, { taskStatusId: string }> = {
|
|
270
|
+
id: staffTimeTaskStatusCommandIds.create,
|
|
271
|
+
async prepare(rawInput, ctx) {
|
|
272
|
+
const parsed = staffTimeTaskStatusCreateSchema.safeParse(rawInput)
|
|
273
|
+
if (!parsed.success) return {}
|
|
274
|
+
const em = ctx.container.resolve('em') as EntityManager
|
|
275
|
+
const boardBefore = await loadBoardSnapshot(em, parsed.data.timeProjectId, staffSnapshotScopeFromContext(ctx))
|
|
276
|
+
return { before: { boardBefore } }
|
|
277
|
+
},
|
|
278
|
+
async execute(rawInput, ctx) {
|
|
279
|
+
const parsed = staffTimeTaskStatusCreateSchema.parse(rawInput)
|
|
280
|
+
ensureTenantScope(ctx, parsed.tenantId)
|
|
281
|
+
ensureOrganizationScope(ctx, parsed.organizationId)
|
|
282
|
+
const scope = commandInputScope(ctx, parsed.tenantId, parsed.organizationId)
|
|
283
|
+
const { translate } = await resolveTranslations()
|
|
284
|
+
|
|
285
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
286
|
+
let board: StaffTimeTaskStatus[] = []
|
|
287
|
+
let created: StaffTimeTaskStatus | null = null
|
|
288
|
+
|
|
289
|
+
try {
|
|
290
|
+
// The board is read inside the transaction that writes the new column, so a
|
|
291
|
+
// concurrent create cannot slip a second default past the repair below.
|
|
292
|
+
await withAtomicFlush(
|
|
293
|
+
em,
|
|
294
|
+
[
|
|
295
|
+
async () => {
|
|
296
|
+
await requireProject(em, parsed.timeProjectId, scope, translate)
|
|
297
|
+
board = await loadBoard(em, parsed.timeProjectId, scope)
|
|
298
|
+
},
|
|
299
|
+
() => {
|
|
300
|
+
const takenSlugs = board.map((status) => status.slug.toLowerCase())
|
|
301
|
+
const slug = parsed.slug ? parsed.slug.toLowerCase() : deriveTaskStatusSlug(parsed.name, takenSlugs)
|
|
302
|
+
if (takenSlugs.includes(slug)) throw slugDuplicateError(translate, slug)
|
|
303
|
+
|
|
304
|
+
const isFirstColumn = board.length === 0
|
|
305
|
+
created = em.create(StaffTimeTaskStatus, {
|
|
306
|
+
tenantId: parsed.tenantId,
|
|
307
|
+
organizationId: parsed.organizationId,
|
|
308
|
+
timeProjectId: parsed.timeProjectId,
|
|
309
|
+
name: parsed.name,
|
|
310
|
+
slug,
|
|
311
|
+
color: parsed.color ?? null,
|
|
312
|
+
position: parsed.position ?? nextStatusPosition(board.map((status) => status.position)),
|
|
313
|
+
// The first column of a board is necessarily both the landing column
|
|
314
|
+
// and the terminal one, whatever the request asked for.
|
|
315
|
+
isDefault: isFirstColumn ? true : parsed.isDefault ?? false,
|
|
316
|
+
isDone: isFirstColumn ? true : parsed.isDone ?? false,
|
|
317
|
+
createdAt: new Date(),
|
|
318
|
+
updatedAt: new Date(),
|
|
319
|
+
deletedAt: null,
|
|
320
|
+
})
|
|
321
|
+
em.persist(created)
|
|
322
|
+
normalizeBoardFlags([...board, created], created.isDefault ? created.id : null)
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
{ transaction: true, label: staffTimeTaskStatusCommandIds.create },
|
|
326
|
+
)
|
|
327
|
+
} catch (err) {
|
|
328
|
+
if (isUniqueViolation(err)) throw slugDuplicateError(translate, parsed.slug ?? parsed.name)
|
|
329
|
+
throw err
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const record = created as StaffTimeTaskStatus | null
|
|
333
|
+
if (!record) throw notFoundError(translate)
|
|
334
|
+
|
|
335
|
+
await emitCrudSideEffects({
|
|
336
|
+
dataEngine: ctx.container.resolve('dataEngine'),
|
|
337
|
+
action: 'created',
|
|
338
|
+
entity: record,
|
|
339
|
+
identifiers: { id: record.id, organizationId: record.organizationId, tenantId: record.tenantId },
|
|
340
|
+
indexer: taskStatusCrudIndexer,
|
|
341
|
+
})
|
|
342
|
+
|
|
343
|
+
return { taskStatusId: record.id }
|
|
344
|
+
},
|
|
345
|
+
captureAfter: async (_input, result, ctx) => {
|
|
346
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
347
|
+
const snapshot = await loadTaskStatusSnapshot(em, result.taskStatusId, staffSnapshotScopeFromContext(ctx))
|
|
348
|
+
if (!snapshot) return null
|
|
349
|
+
return { snapshot }
|
|
350
|
+
},
|
|
351
|
+
buildLog: async ({ result, snapshots, ctx }) => {
|
|
352
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
353
|
+
const snapshot = await loadTaskStatusSnapshot(em, result.taskStatusId, staffSnapshotScopeFromContext(ctx))
|
|
354
|
+
if (!snapshot) return null
|
|
355
|
+
const boardBefore = (snapshots.before as { boardBefore?: TaskStatusBoardRow[] } | undefined)?.boardBefore ?? null
|
|
356
|
+
const { translate } = await resolveTranslations()
|
|
357
|
+
return {
|
|
358
|
+
actionLabel: translate('staff.audit.timesheets.task_statuses.create', 'Create task status'),
|
|
359
|
+
resourceKind: 'staff.timesheets.task_status',
|
|
360
|
+
resourceId: snapshot.id,
|
|
361
|
+
tenantId: snapshot.tenantId,
|
|
362
|
+
organizationId: snapshot.organizationId,
|
|
363
|
+
snapshotAfter: snapshot,
|
|
364
|
+
payload: {
|
|
365
|
+
undo: {
|
|
366
|
+
after: snapshot,
|
|
367
|
+
boardBefore,
|
|
368
|
+
} satisfies TaskStatusUndoPayload,
|
|
369
|
+
},
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
undo: async ({ logEntry, ctx }) => {
|
|
373
|
+
const payload = extractUndoPayload<TaskStatusUndoPayload>(logEntry)
|
|
374
|
+
const after = payload?.after
|
|
375
|
+
if (!after) return
|
|
376
|
+
const snapshotScope = staffSnapshotScopeFromSnapshot(after)
|
|
377
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
378
|
+
const status = await em.findOne(StaffTimeTaskStatus, scopedStaffSnapshotWhere(after.id, snapshotScope))
|
|
379
|
+
if (!status) return
|
|
380
|
+
|
|
381
|
+
await withAtomicFlush(
|
|
382
|
+
em,
|
|
383
|
+
[
|
|
384
|
+
() => {
|
|
385
|
+
status.deletedAt = new Date()
|
|
386
|
+
status.updatedAt = new Date()
|
|
387
|
+
},
|
|
388
|
+
// The board is re-read here, so it has to be its own phase.
|
|
389
|
+
() => restoreBoard(em, payload?.boardBefore, snapshotScope),
|
|
390
|
+
],
|
|
391
|
+
{ transaction: true, label: `${staffTimeTaskStatusCommandIds.create}.undo` },
|
|
392
|
+
)
|
|
393
|
+
|
|
394
|
+
await emitCrudUndoSideEffects({
|
|
395
|
+
dataEngine: ctx.container.resolve('dataEngine'),
|
|
396
|
+
action: 'deleted',
|
|
397
|
+
entity: status,
|
|
398
|
+
identifiers: { id: status.id, organizationId: status.organizationId, tenantId: status.tenantId },
|
|
399
|
+
indexer: taskStatusCrudIndexer,
|
|
400
|
+
})
|
|
401
|
+
},
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const updateTaskStatusCommand: CommandHandler<StaffTimeTaskStatusUpdateInput, { taskStatusId: string }> = {
|
|
405
|
+
id: staffTimeTaskStatusCommandIds.update,
|
|
406
|
+
async prepare(rawInput, ctx) {
|
|
407
|
+
const parsed = staffTimeTaskStatusUpdateSchema.safeParse(rawInput)
|
|
408
|
+
if (!parsed.success) return {}
|
|
409
|
+
const em = ctx.container.resolve('em') as EntityManager
|
|
410
|
+
const scope = staffSnapshotScopeFromContext(ctx)
|
|
411
|
+
const before = await loadTaskStatusSnapshot(em, parsed.data.id, scope)
|
|
412
|
+
if (!before) return {}
|
|
413
|
+
const boardBefore = await loadBoardSnapshot(em, before.timeProjectId, scope)
|
|
414
|
+
return { before: { snapshot: before, boardBefore } }
|
|
415
|
+
},
|
|
416
|
+
async execute(rawInput, ctx) {
|
|
417
|
+
const parsed = staffTimeTaskStatusUpdateSchema.parse(rawInput)
|
|
418
|
+
const { translate } = await resolveTranslations()
|
|
419
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
420
|
+
const scope = commandActorScope(ctx)
|
|
421
|
+
|
|
422
|
+
const status = await em.findOne(
|
|
423
|
+
StaffTimeTaskStatus,
|
|
424
|
+
applyScopeToWhere<StaffTimeTaskStatus>({ id: parsed.id, deletedAt: null }, scope),
|
|
425
|
+
)
|
|
426
|
+
if (!status) throw notFoundError(translate)
|
|
427
|
+
ensureTenantScope(ctx, status.tenantId)
|
|
428
|
+
ensureOrganizationScope(ctx, status.organizationId)
|
|
429
|
+
|
|
430
|
+
let board: StaffTimeTaskStatus[] = []
|
|
431
|
+
|
|
432
|
+
try {
|
|
433
|
+
await withAtomicFlush(
|
|
434
|
+
em,
|
|
435
|
+
[
|
|
436
|
+
async () => {
|
|
437
|
+
board = await loadBoard(em, status.timeProjectId, scope)
|
|
438
|
+
},
|
|
439
|
+
() => {
|
|
440
|
+
if (parsed.name !== undefined) status.name = parsed.name
|
|
441
|
+
if (parsed.color !== undefined) status.color = parsed.color ?? null
|
|
442
|
+
|
|
443
|
+
if (parsed.isDefault === false && status.isDefault) {
|
|
444
|
+
// Unsetting the only default would leave new tasks with nowhere to
|
|
445
|
+
// land; promoting another column is the caller's move to make.
|
|
446
|
+
throw new CrudHttpError(409, {
|
|
447
|
+
code: TASK_STATUS_DEFAULT_REQUIRED_CODE,
|
|
448
|
+
error: translate(
|
|
449
|
+
'staff.time_tracking.taskStatuses.errors.defaultRequired',
|
|
450
|
+
'A project needs one default column. Mark another column as the default instead.',
|
|
451
|
+
),
|
|
452
|
+
})
|
|
453
|
+
}
|
|
454
|
+
if (parsed.isDone === false && status.isDone && board.filter((row) => row.isDone).length <= 1) {
|
|
455
|
+
throw new CrudHttpError(409, {
|
|
456
|
+
code: TASK_STATUS_DONE_REQUIRED_CODE,
|
|
457
|
+
error: translate(
|
|
458
|
+
'staff.time_tracking.taskStatuses.errors.doneRequired',
|
|
459
|
+
'A project needs at least one done column. Mark another column as done first.',
|
|
460
|
+
),
|
|
461
|
+
})
|
|
462
|
+
}
|
|
463
|
+
if (parsed.isDone !== undefined) status.isDone = parsed.isDone
|
|
464
|
+
if (parsed.isDefault === true) status.isDefault = true
|
|
465
|
+
|
|
466
|
+
if (parsed.position !== undefined) {
|
|
467
|
+
// A single-column drag is expressed as a one-row reorder, so the rare
|
|
468
|
+
// "no integer fits here" drop compacts the board instead of writing a
|
|
469
|
+
// position that collides with its neighbour.
|
|
470
|
+
const plan = planStatusReorder(
|
|
471
|
+
board.map((row) => ({ id: row.id, position: row.position })),
|
|
472
|
+
[{ id: status.id, position: parsed.position }],
|
|
473
|
+
)
|
|
474
|
+
const byId = new Map(board.map((row) => [row.id, row]))
|
|
475
|
+
for (const update of plan.updates) {
|
|
476
|
+
const target = byId.get(update.id)
|
|
477
|
+
if (!target) continue
|
|
478
|
+
target.position = update.position
|
|
479
|
+
target.updatedAt = new Date()
|
|
480
|
+
}
|
|
481
|
+
if (plan.compacted) {
|
|
482
|
+
logger.debug('Compacted task status board', {
|
|
483
|
+
timeProjectId: status.timeProjectId,
|
|
484
|
+
updates: plan.updates.length,
|
|
485
|
+
})
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
normalizeBoardFlags(board, parsed.isDefault === true ? status.id : null)
|
|
490
|
+
status.updatedAt = new Date()
|
|
491
|
+
},
|
|
492
|
+
],
|
|
493
|
+
{ transaction: true, label: staffTimeTaskStatusCommandIds.update },
|
|
494
|
+
)
|
|
495
|
+
} catch (err) {
|
|
496
|
+
if (isUniqueViolation(err)) throw slugDuplicateError(translate, status.slug)
|
|
497
|
+
throw err
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
await emitCrudSideEffects({
|
|
501
|
+
dataEngine: ctx.container.resolve('dataEngine'),
|
|
502
|
+
action: 'updated',
|
|
503
|
+
entity: status,
|
|
504
|
+
identifiers: { id: status.id, organizationId: status.organizationId, tenantId: status.tenantId },
|
|
505
|
+
indexer: taskStatusCrudIndexer,
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
return { taskStatusId: status.id }
|
|
509
|
+
},
|
|
510
|
+
buildLog: async ({ snapshots, ctx }) => {
|
|
511
|
+
const prepared = snapshots.before as
|
|
512
|
+
| { snapshot?: TaskStatusSnapshot; boardBefore?: TaskStatusBoardRow[] }
|
|
513
|
+
| undefined
|
|
514
|
+
const before = prepared?.snapshot
|
|
515
|
+
if (!before) return null
|
|
516
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
517
|
+
const after = await loadTaskStatusSnapshot(em, before.id, staffSnapshotScopeFromSnapshot(before))
|
|
518
|
+
if (!after) return null
|
|
519
|
+
const changes = buildChanges(
|
|
520
|
+
before as unknown as Record<string, unknown>,
|
|
521
|
+
after as unknown as Record<string, unknown>,
|
|
522
|
+
['name', 'color', 'position', 'isDefault', 'isDone'],
|
|
523
|
+
)
|
|
524
|
+
const { translate } = await resolveTranslations()
|
|
525
|
+
return {
|
|
526
|
+
actionLabel: translate('staff.audit.timesheets.task_statuses.update', 'Update task status'),
|
|
527
|
+
resourceKind: 'staff.timesheets.task_status',
|
|
528
|
+
resourceId: before.id,
|
|
529
|
+
tenantId: before.tenantId,
|
|
530
|
+
organizationId: before.organizationId,
|
|
531
|
+
snapshotBefore: before,
|
|
532
|
+
snapshotAfter: after,
|
|
533
|
+
changes,
|
|
534
|
+
payload: {
|
|
535
|
+
undo: {
|
|
536
|
+
before,
|
|
537
|
+
after,
|
|
538
|
+
boardBefore: prepared?.boardBefore ?? null,
|
|
539
|
+
} satisfies TaskStatusUndoPayload,
|
|
540
|
+
},
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
undo: async ({ logEntry, ctx }) => {
|
|
544
|
+
const payload = extractUndoPayload<TaskStatusUndoPayload>(logEntry)
|
|
545
|
+
const before = payload?.before
|
|
546
|
+
if (!before) return
|
|
547
|
+
const snapshotScope = staffSnapshotScopeFromSnapshot(before)
|
|
548
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
549
|
+
const status = await em.findOne(StaffTimeTaskStatus, scopedStaffSnapshotWhere(before.id, snapshotScope))
|
|
550
|
+
if (!status) return
|
|
551
|
+
|
|
552
|
+
await withAtomicFlush(
|
|
553
|
+
em,
|
|
554
|
+
[
|
|
555
|
+
() => {
|
|
556
|
+
status.name = before.name
|
|
557
|
+
status.color = before.color ?? null
|
|
558
|
+
status.updatedAt = new Date()
|
|
559
|
+
},
|
|
560
|
+
// Positions and flags belong to the whole board, and restoring them
|
|
561
|
+
// re-reads the sibling rows.
|
|
562
|
+
() => restoreBoard(em, payload?.boardBefore, snapshotScope),
|
|
563
|
+
],
|
|
564
|
+
{ transaction: true, label: `${staffTimeTaskStatusCommandIds.update}.undo` },
|
|
565
|
+
)
|
|
566
|
+
|
|
567
|
+
await emitCrudUndoSideEffects({
|
|
568
|
+
dataEngine: ctx.container.resolve('dataEngine'),
|
|
569
|
+
action: 'updated',
|
|
570
|
+
entity: status,
|
|
571
|
+
identifiers: { id: status.id, organizationId: status.organizationId, tenantId: status.tenantId },
|
|
572
|
+
indexer: taskStatusCrudIndexer,
|
|
573
|
+
})
|
|
574
|
+
},
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
const deleteTaskStatusCommand: CommandHandler<{ id?: string }, { taskStatusId: string }> = {
|
|
578
|
+
id: staffTimeTaskStatusCommandIds.delete,
|
|
579
|
+
async prepare(input, ctx) {
|
|
580
|
+
const id = input?.id
|
|
581
|
+
if (!id) return {}
|
|
582
|
+
const em = ctx.container.resolve('em') as EntityManager
|
|
583
|
+
const scope = staffSnapshotScopeFromContext(ctx)
|
|
584
|
+
const before = await loadTaskStatusSnapshot(em, id, scope)
|
|
585
|
+
if (!before) return {}
|
|
586
|
+
const boardBefore = await loadBoardSnapshot(em, before.timeProjectId, scope)
|
|
587
|
+
return { before: { snapshot: before, boardBefore } }
|
|
588
|
+
},
|
|
589
|
+
async execute(input, ctx) {
|
|
590
|
+
const { translate } = await resolveTranslations()
|
|
591
|
+
const id = input?.id
|
|
592
|
+
if (!id) {
|
|
593
|
+
throw new CrudHttpError(400, {
|
|
594
|
+
error: translate('staff.time_tracking.taskStatuses.errors.idRequired', 'Task status id is required.'),
|
|
595
|
+
})
|
|
596
|
+
}
|
|
597
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
598
|
+
const scope = commandActorScope(ctx)
|
|
599
|
+
const status = await em.findOne(
|
|
600
|
+
StaffTimeTaskStatus,
|
|
601
|
+
applyScopeToWhere<StaffTimeTaskStatus>({ id, deletedAt: null }, scope),
|
|
602
|
+
)
|
|
603
|
+
if (!status) throw notFoundError(translate)
|
|
604
|
+
ensureTenantScope(ctx, status.tenantId)
|
|
605
|
+
ensureOrganizationScope(ctx, status.organizationId)
|
|
606
|
+
|
|
607
|
+
let survivors: StaffTimeTaskStatus[] = []
|
|
608
|
+
|
|
609
|
+
await withAtomicFlush(
|
|
610
|
+
em,
|
|
611
|
+
[
|
|
612
|
+
async () => {
|
|
613
|
+
const board = await loadBoard(em, status.timeProjectId, scope)
|
|
614
|
+
survivors = board.filter((row) => row.id !== status.id)
|
|
615
|
+
if (survivors.length === 0) {
|
|
616
|
+
throw new CrudHttpError(409, {
|
|
617
|
+
code: TASK_STATUS_LAST_COLUMN_CODE,
|
|
618
|
+
error: translate(
|
|
619
|
+
'staff.time_tracking.taskStatuses.errors.lastColumn',
|
|
620
|
+
'A project needs at least one column. Add another column before removing this one.',
|
|
621
|
+
),
|
|
622
|
+
})
|
|
623
|
+
}
|
|
624
|
+
const taskCount = await em.count(
|
|
625
|
+
StaffTimeTask,
|
|
626
|
+
applyScopeToWhere<StaffTimeTask>({ taskStatusId: status.id, deletedAt: null }, scope),
|
|
627
|
+
)
|
|
628
|
+
if (taskCount > 0) {
|
|
629
|
+
throw new CrudHttpError(409, {
|
|
630
|
+
code: TASK_STATUS_HAS_TASKS_CODE,
|
|
631
|
+
error: translate(
|
|
632
|
+
'staff.time_tracking.taskStatuses.errors.hasTasks',
|
|
633
|
+
'This column still holds tasks. Move them to another column before removing it.',
|
|
634
|
+
),
|
|
635
|
+
taskCount,
|
|
636
|
+
})
|
|
637
|
+
}
|
|
638
|
+
},
|
|
639
|
+
() => {
|
|
640
|
+
status.deletedAt = new Date()
|
|
641
|
+
status.updatedAt = new Date()
|
|
642
|
+
// Removing the landing or the terminal column hands the role to a
|
|
643
|
+
// survivor rather than refusing the delete — an empty column should
|
|
644
|
+
// always be removable.
|
|
645
|
+
normalizeBoardFlags(survivors, null)
|
|
646
|
+
},
|
|
647
|
+
],
|
|
648
|
+
{ transaction: true, label: staffTimeTaskStatusCommandIds.delete },
|
|
649
|
+
)
|
|
650
|
+
|
|
651
|
+
await emitCrudSideEffects({
|
|
652
|
+
dataEngine: ctx.container.resolve('dataEngine'),
|
|
653
|
+
action: 'deleted',
|
|
654
|
+
entity: status,
|
|
655
|
+
identifiers: { id: status.id, organizationId: status.organizationId, tenantId: status.tenantId },
|
|
656
|
+
indexer: taskStatusCrudIndexer,
|
|
657
|
+
})
|
|
658
|
+
|
|
659
|
+
return { taskStatusId: status.id }
|
|
660
|
+
},
|
|
661
|
+
buildLog: async ({ snapshots }) => {
|
|
662
|
+
const prepared = snapshots.before as
|
|
663
|
+
| { snapshot?: TaskStatusSnapshot; boardBefore?: TaskStatusBoardRow[] }
|
|
664
|
+
| undefined
|
|
665
|
+
const before = prepared?.snapshot
|
|
666
|
+
if (!before) return null
|
|
667
|
+
const { translate } = await resolveTranslations()
|
|
668
|
+
return {
|
|
669
|
+
actionLabel: translate('staff.audit.timesheets.task_statuses.delete', 'Delete task status'),
|
|
670
|
+
resourceKind: 'staff.timesheets.task_status',
|
|
671
|
+
resourceId: before.id,
|
|
672
|
+
tenantId: before.tenantId,
|
|
673
|
+
organizationId: before.organizationId,
|
|
674
|
+
snapshotBefore: before,
|
|
675
|
+
payload: {
|
|
676
|
+
undo: {
|
|
677
|
+
before,
|
|
678
|
+
boardBefore: prepared?.boardBefore ?? null,
|
|
679
|
+
} satisfies TaskStatusUndoPayload,
|
|
680
|
+
},
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
undo: async ({ logEntry, ctx }) => {
|
|
684
|
+
const payload = extractUndoPayload<TaskStatusUndoPayload>(logEntry)
|
|
685
|
+
const before = payload?.before
|
|
686
|
+
if (!before) return
|
|
687
|
+
const snapshotScope = staffSnapshotScopeFromSnapshot(before)
|
|
688
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
689
|
+
let status = await em.findOne(StaffTimeTaskStatus, scopedStaffSnapshotWhere(before.id, snapshotScope))
|
|
690
|
+
|
|
691
|
+
await withAtomicFlush(
|
|
692
|
+
em,
|
|
693
|
+
[
|
|
694
|
+
() => {
|
|
695
|
+
if (!status) {
|
|
696
|
+
status = em.create(StaffTimeTaskStatus, {
|
|
697
|
+
id: before.id,
|
|
698
|
+
tenantId: before.tenantId,
|
|
699
|
+
organizationId: before.organizationId,
|
|
700
|
+
timeProjectId: before.timeProjectId,
|
|
701
|
+
name: before.name,
|
|
702
|
+
slug: before.slug,
|
|
703
|
+
color: before.color ?? null,
|
|
704
|
+
position: before.position,
|
|
705
|
+
isDefault: before.isDefault,
|
|
706
|
+
isDone: before.isDone,
|
|
707
|
+
createdAt: new Date(),
|
|
708
|
+
updatedAt: new Date(),
|
|
709
|
+
deletedAt: null,
|
|
710
|
+
})
|
|
711
|
+
em.persist(status)
|
|
712
|
+
return
|
|
713
|
+
}
|
|
714
|
+
status.name = before.name
|
|
715
|
+
status.slug = before.slug
|
|
716
|
+
status.color = before.color ?? null
|
|
717
|
+
status.position = before.position
|
|
718
|
+
status.isDefault = before.isDefault
|
|
719
|
+
status.isDone = before.isDone
|
|
720
|
+
status.deletedAt = null
|
|
721
|
+
status.updatedAt = new Date()
|
|
722
|
+
},
|
|
723
|
+
() => restoreBoard(em, payload?.boardBefore, snapshotScope),
|
|
724
|
+
],
|
|
725
|
+
{ transaction: true, label: `${staffTimeTaskStatusCommandIds.delete}.undo` },
|
|
726
|
+
)
|
|
727
|
+
|
|
728
|
+
await emitCrudUndoSideEffects({
|
|
729
|
+
dataEngine: ctx.container.resolve('dataEngine'),
|
|
730
|
+
action: 'created',
|
|
731
|
+
entity: status,
|
|
732
|
+
identifiers: {
|
|
733
|
+
id: before.id,
|
|
734
|
+
organizationId: before.organizationId,
|
|
735
|
+
tenantId: before.tenantId,
|
|
736
|
+
},
|
|
737
|
+
indexer: taskStatusCrudIndexer,
|
|
738
|
+
})
|
|
739
|
+
},
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Batch reorder for a whole-board drag. The single-column case travels through
|
|
744
|
+
* `update` (the PUT the spec's contract table describes); this one exists for the
|
|
745
|
+
* board that restates several columns at once and for the compaction that follows
|
|
746
|
+
* a drop with no room left between neighbours.
|
|
747
|
+
*/
|
|
748
|
+
const reorderTaskStatusCommandSchema = staffTimeTaskStatusReorderSchema.extend({
|
|
749
|
+
timeProjectId: z.string().uuid(),
|
|
750
|
+
})
|
|
751
|
+
|
|
752
|
+
export type StaffTimeTaskStatusReorderCommandInput = z.infer<typeof reorderTaskStatusCommandSchema>
|
|
753
|
+
|
|
754
|
+
const reorderTaskStatusesCommand: CommandHandler<
|
|
755
|
+
StaffTimeTaskStatusReorderCommandInput,
|
|
756
|
+
{ timeProjectId: string; updatedIds: string[]; compacted: boolean }
|
|
757
|
+
> = {
|
|
758
|
+
id: staffTimeTaskStatusCommandIds.reorder,
|
|
759
|
+
async prepare(rawInput, ctx) {
|
|
760
|
+
const parsed = reorderTaskStatusCommandSchema.safeParse(rawInput)
|
|
761
|
+
if (!parsed.success) return {}
|
|
762
|
+
const em = ctx.container.resolve('em') as EntityManager
|
|
763
|
+
const boardBefore = await loadBoardSnapshot(em, parsed.data.timeProjectId, staffSnapshotScopeFromContext(ctx))
|
|
764
|
+
return { before: { timeProjectId: parsed.data.timeProjectId, boardBefore } }
|
|
765
|
+
},
|
|
766
|
+
async execute(rawInput, ctx) {
|
|
767
|
+
const parsed = reorderTaskStatusCommandSchema.parse(rawInput)
|
|
768
|
+
const { translate } = await resolveTranslations()
|
|
769
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
770
|
+
const scope = commandActorScope(ctx)
|
|
771
|
+
|
|
772
|
+
let board: StaffTimeTaskStatus[] = []
|
|
773
|
+
let updatedIds: string[] = []
|
|
774
|
+
let compacted = false
|
|
775
|
+
|
|
776
|
+
await withAtomicFlush(
|
|
777
|
+
em,
|
|
778
|
+
[
|
|
779
|
+
async () => {
|
|
780
|
+
await requireProject(em, parsed.timeProjectId, scope, translate)
|
|
781
|
+
board = await loadBoard(em, parsed.timeProjectId, scope)
|
|
782
|
+
},
|
|
783
|
+
() => {
|
|
784
|
+
const plan = planStatusReorder(
|
|
785
|
+
board.map((row) => ({ id: row.id, position: row.position })),
|
|
786
|
+
parsed.statuses,
|
|
787
|
+
)
|
|
788
|
+
if (plan.unknownIds.length > 0) {
|
|
789
|
+
// Ids from another project (or already deleted) must never be written
|
|
790
|
+
// through this project's reorder.
|
|
791
|
+
throw new CrudHttpError(422, {
|
|
792
|
+
code: TASK_STATUS_UNKNOWN_IDS_CODE,
|
|
793
|
+
error: translate(
|
|
794
|
+
'staff.time_tracking.taskStatuses.errors.unknownIds',
|
|
795
|
+
'Some columns do not belong to this project.',
|
|
796
|
+
),
|
|
797
|
+
unknownIds: plan.unknownIds,
|
|
798
|
+
})
|
|
799
|
+
}
|
|
800
|
+
const byId = new Map(board.map((row) => [row.id, row]))
|
|
801
|
+
for (const update of plan.updates) {
|
|
802
|
+
const target = byId.get(update.id)
|
|
803
|
+
if (!target) continue
|
|
804
|
+
target.position = update.position
|
|
805
|
+
target.updatedAt = new Date()
|
|
806
|
+
}
|
|
807
|
+
updatedIds = plan.updates.map((update) => update.id)
|
|
808
|
+
compacted = plan.compacted
|
|
809
|
+
},
|
|
810
|
+
],
|
|
811
|
+
{ transaction: true, label: staffTimeTaskStatusCommandIds.reorder },
|
|
812
|
+
)
|
|
813
|
+
|
|
814
|
+
const dataEngine = ctx.container.resolve('dataEngine') as DataEngine
|
|
815
|
+
for (const status of board) {
|
|
816
|
+
if (!updatedIds.includes(status.id)) continue
|
|
817
|
+
await emitCrudSideEffects({
|
|
818
|
+
dataEngine,
|
|
819
|
+
action: 'updated',
|
|
820
|
+
entity: status,
|
|
821
|
+
identifiers: { id: status.id, organizationId: status.organizationId, tenantId: status.tenantId },
|
|
822
|
+
indexer: taskStatusCrudIndexer,
|
|
823
|
+
})
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
return { timeProjectId: parsed.timeProjectId, updatedIds, compacted }
|
|
827
|
+
},
|
|
828
|
+
buildLog: async ({ result, snapshots, ctx }) => {
|
|
829
|
+
const prepared = snapshots.before as
|
|
830
|
+
| { timeProjectId?: string; boardBefore?: TaskStatusBoardRow[] }
|
|
831
|
+
| undefined
|
|
832
|
+
const boardBefore = prepared?.boardBefore ?? null
|
|
833
|
+
if (!boardBefore || boardBefore.length === 0) return null
|
|
834
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
835
|
+
const scope = staffSnapshotScopeFromContext(ctx)
|
|
836
|
+
const boardAfter = await loadBoardSnapshot(em, result.timeProjectId, scope)
|
|
837
|
+
const { translate } = await resolveTranslations()
|
|
838
|
+
return {
|
|
839
|
+
actionLabel: translate('staff.audit.timesheets.task_statuses.reorder', 'Reorder task statuses'),
|
|
840
|
+
resourceKind: 'staff.timesheets.task_status',
|
|
841
|
+
resourceId: result.timeProjectId,
|
|
842
|
+
tenantId: scope?.tenantId ?? null,
|
|
843
|
+
organizationId: ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null,
|
|
844
|
+
snapshotBefore: { statuses: boardBefore },
|
|
845
|
+
snapshotAfter: { statuses: boardAfter },
|
|
846
|
+
payload: {
|
|
847
|
+
undo: {
|
|
848
|
+
boardBefore,
|
|
849
|
+
} satisfies TaskStatusUndoPayload,
|
|
850
|
+
},
|
|
851
|
+
}
|
|
852
|
+
},
|
|
853
|
+
undo: async ({ logEntry, ctx }) => {
|
|
854
|
+
const payload = extractUndoPayload<TaskStatusUndoPayload>(logEntry)
|
|
855
|
+
const boardBefore = payload?.boardBefore
|
|
856
|
+
if (!boardBefore || boardBefore.length === 0) return
|
|
857
|
+
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
858
|
+
const snapshotScope = staffSnapshotScopeFromContext(ctx)
|
|
859
|
+
let restored: StaffTimeTaskStatus[] = []
|
|
860
|
+
await withAtomicFlush(
|
|
861
|
+
em,
|
|
862
|
+
[
|
|
863
|
+
async () => {
|
|
864
|
+
restored = await restoreBoard(em, boardBefore, snapshotScope)
|
|
865
|
+
},
|
|
866
|
+
],
|
|
867
|
+
{
|
|
868
|
+
transaction: true,
|
|
869
|
+
label: `${staffTimeTaskStatusCommandIds.reorder}.undo`,
|
|
870
|
+
},
|
|
871
|
+
)
|
|
872
|
+
|
|
873
|
+
const dataEngine = ctx.container.resolve('dataEngine') as DataEngine
|
|
874
|
+
for (const status of restored) {
|
|
875
|
+
await emitCrudUndoSideEffects({
|
|
876
|
+
dataEngine,
|
|
877
|
+
action: 'updated',
|
|
878
|
+
entity: status,
|
|
879
|
+
identifiers: { id: status.id, organizationId: status.organizationId, tenantId: status.tenantId },
|
|
880
|
+
indexer: taskStatusCrudIndexer,
|
|
881
|
+
})
|
|
882
|
+
}
|
|
883
|
+
},
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
registerCommand(createTaskStatusCommand)
|
|
887
|
+
registerCommand(updateTaskStatusCommand)
|
|
888
|
+
registerCommand(deleteTaskStatusCommand)
|
|
889
|
+
registerCommand(reorderTaskStatusesCommand)
|