@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,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GET /api/staff/portal/time-reports` — EP-50, the customer-facing half of the
|
|
3
|
+
* time-tracking suite.
|
|
4
|
+
*
|
|
5
|
+
* **The ownership check, spelled out, because it is the only thing standing
|
|
6
|
+
* between a client and another client's hours.** Every row this route can return
|
|
7
|
+
* satisfies all four of:
|
|
8
|
+
*
|
|
9
|
+
* `tenant_id = auth.tenantId` (from the customer JWT, never input)
|
|
10
|
+
* `organization_id= auth.orgId` (ditto; the portal shell already
|
|
11
|
+
* refuses a URL whose org slug does
|
|
12
|
+
* not resolve to this org)
|
|
13
|
+
* `customer_id = auth.customerEntityId` (the signed-in portal user's own
|
|
14
|
+
* customer entity — the same id
|
|
15
|
+
* `staff_time_reports.customer_id`
|
|
16
|
+
* holds, see `data/extensions.ts`)
|
|
17
|
+
* `status = 'closed' AND deleted_at IS NULL`
|
|
18
|
+
*
|
|
19
|
+
* A portal user with no `customerEntityId` is refused with `403` rather than
|
|
20
|
+
* being shown an unscoped list: an unlinked portal account is not a customer, and
|
|
21
|
+
* a null in that column would otherwise match nothing or — worse, in a future
|
|
22
|
+
* refactor — everything.
|
|
23
|
+
*
|
|
24
|
+
* **Money is absent, not blanked.** The response has no rate, cost, amount or
|
|
25
|
+
* currency field in its schema at all. `staff.timesheets.rates.view` is a *staff*
|
|
26
|
+
* feature resolved by `rbacService`; a portal identity is graded by
|
|
27
|
+
* `CustomerRbacService` against the disjoint `portal.*` namespace and can never
|
|
28
|
+
* hold it, so the module's own rule — money is added for a holder and absent for
|
|
29
|
+
* everyone else — resolves to "absent, always" here. Making that structural
|
|
30
|
+
* rather than conditional means no later edit can accidentally open it.
|
|
31
|
+
*
|
|
32
|
+
* Draft reports are invisible. A draft is working material whose entries are not
|
|
33
|
+
* frozen; only a closed report is a statement the business has stood behind.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import { NextResponse } from 'next/server'
|
|
37
|
+
import { z } from 'zod'
|
|
38
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
39
|
+
import type { CustomerAuthContext } from '@open-mercato/shared/modules/customer-auth'
|
|
40
|
+
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
41
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
42
|
+
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
43
|
+
import {
|
|
44
|
+
PORTAL_TIME_REPORTS_VIEW_FEATURE,
|
|
45
|
+
portalOwnedReportClause,
|
|
46
|
+
} from '../../../lib/time-tracking/portalReports'
|
|
47
|
+
|
|
48
|
+
const logger = createLogger('staff').child({ component: 'api/portal/time-reports' })
|
|
49
|
+
|
|
50
|
+
export const metadata: { path?: string; requireAuth?: boolean } = { requireAuth: false }
|
|
51
|
+
|
|
52
|
+
const listQuerySchema = z.object({
|
|
53
|
+
page: z.coerce.number().int().min(1).default(1),
|
|
54
|
+
pageSize: z.coerce.number().int().min(1).max(50).default(20),
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const reportItemSchema = z.object({
|
|
58
|
+
id: z.string().uuid(),
|
|
59
|
+
reference: z.string(),
|
|
60
|
+
title: z.string(),
|
|
61
|
+
periodFrom: z.string(),
|
|
62
|
+
periodTo: z.string(),
|
|
63
|
+
closedAt: z.string().nullable(),
|
|
64
|
+
totalBillableMinutes: z.number().int(),
|
|
65
|
+
totalNonbillableMinutes: z.number().int(),
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const errorResponseSchema = z.object({ ok: z.literal(false), error: z.string() })
|
|
69
|
+
|
|
70
|
+
const listResponseSchema = z.object({
|
|
71
|
+
items: z.array(reportItemSchema),
|
|
72
|
+
total: z.number().int(),
|
|
73
|
+
page: z.number().int(),
|
|
74
|
+
pageSize: z.number().int(),
|
|
75
|
+
totalPages: z.number().int(),
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
type PortalScope = {
|
|
79
|
+
auth: CustomerAuthContext
|
|
80
|
+
customerId: string
|
|
81
|
+
tenantId: string
|
|
82
|
+
organizationId: string
|
|
83
|
+
em: EntityManager
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type ReportRow = {
|
|
87
|
+
id: string
|
|
88
|
+
reference: string
|
|
89
|
+
title: string
|
|
90
|
+
period_from: Date | string
|
|
91
|
+
period_to: Date | string
|
|
92
|
+
closed_at: Date | string | null
|
|
93
|
+
total_billable_minutes: number | string | null
|
|
94
|
+
total_nonbillable_minutes: number | string | null
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function toIsoDate(value: Date | string | null | undefined): string | null {
|
|
98
|
+
if (value instanceof Date) {
|
|
99
|
+
if (Number.isNaN(value.getTime())) return null
|
|
100
|
+
return value.toISOString().slice(0, 10)
|
|
101
|
+
}
|
|
102
|
+
if (typeof value === 'string' && value.trim().length > 0) return value.trim().slice(0, 10)
|
|
103
|
+
return null
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function toIsoDateTime(value: Date | string | null | undefined): string | null {
|
|
107
|
+
if (value instanceof Date) {
|
|
108
|
+
if (Number.isNaN(value.getTime())) return null
|
|
109
|
+
return value.toISOString()
|
|
110
|
+
}
|
|
111
|
+
if (typeof value === 'string' && value.trim().length > 0) return value.trim()
|
|
112
|
+
return null
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function toMinutes(value: number | string | null | undefined): number {
|
|
116
|
+
const parsed = typeof value === 'number' ? value : Number(value ?? 0)
|
|
117
|
+
return Number.isFinite(parsed) ? Math.trunc(parsed) : 0
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Resolves the portal identity through `customer_accounts` with a dynamic import.
|
|
122
|
+
* Staff must stay extractable into its own package, so the module graph carries no
|
|
123
|
+
* static edge to `customer_accounts`; a deployment without the portal installed
|
|
124
|
+
* answers `401` here instead of failing to load.
|
|
125
|
+
*/
|
|
126
|
+
type CustomerFeatureGuard = (
|
|
127
|
+
auth: CustomerAuthContext,
|
|
128
|
+
features: string[],
|
|
129
|
+
rbac: unknown,
|
|
130
|
+
) => Promise<void>
|
|
131
|
+
|
|
132
|
+
export async function resolvePortalScope(req: Request): Promise<PortalScope | Response> {
|
|
133
|
+
let auth: CustomerAuthContext | null = null
|
|
134
|
+
let requireFeature: CustomerFeatureGuard | null = null
|
|
135
|
+
try {
|
|
136
|
+
const customerAuth = await import('@open-mercato/core/modules/customer_accounts/lib/customerAuth')
|
|
137
|
+
auth = await customerAuth.getCustomerAuthFromRequest(req)
|
|
138
|
+
const guard: unknown = (customerAuth as { requireCustomerFeature?: unknown }).requireCustomerFeature
|
|
139
|
+
requireFeature = typeof guard === 'function' ? (guard as CustomerFeatureGuard) : null
|
|
140
|
+
} catch (err) {
|
|
141
|
+
logger.warn('staff portal time-reports could not resolve customer auth', { err })
|
|
142
|
+
return NextResponse.json({ ok: false, error: 'staff.errors.unauthorized' }, { status: 401 })
|
|
143
|
+
}
|
|
144
|
+
if (!auth) {
|
|
145
|
+
return NextResponse.json({ ok: false, error: 'staff.errors.unauthorized' }, { status: 401 })
|
|
146
|
+
}
|
|
147
|
+
const customerId =
|
|
148
|
+
typeof auth.customerEntityId === 'string' && auth.customerEntityId.trim().length > 0
|
|
149
|
+
? auth.customerEntityId.trim()
|
|
150
|
+
: null
|
|
151
|
+
if (!customerId) {
|
|
152
|
+
return NextResponse.json({ ok: false, error: 'staff.errors.customerAccountNotLinked' }, { status: 403 })
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// A missing guard is a failed feature check, not an absent one: without it the
|
|
156
|
+
// tenant loses the ability to REVOKE `portal.time_reports.view`, since a customer
|
|
157
|
+
// role stripped of the grant would keep reading reports. (Not a disclosure —
|
|
158
|
+
// `portalOwnedReportClause` still pins tenant, organization, customer and
|
|
159
|
+
// `status = 'closed'` — but revocation has to keep working.)
|
|
160
|
+
if (!requireFeature) {
|
|
161
|
+
logger.error('staff portal time-reports could not resolve requireCustomerFeature; refusing the request', {
|
|
162
|
+
feature: PORTAL_TIME_REPORTS_VIEW_FEATURE,
|
|
163
|
+
})
|
|
164
|
+
return NextResponse.json({ ok: false, error: 'staff.errors.forbidden' }, { status: 403 })
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const container = await createRequestContainer()
|
|
168
|
+
try {
|
|
169
|
+
const rbac = container.resolve('customerRbacService')
|
|
170
|
+
await requireFeature(auth, [PORTAL_TIME_REPORTS_VIEW_FEATURE], rbac)
|
|
171
|
+
} catch (response) {
|
|
172
|
+
if (response instanceof Response) return response
|
|
173
|
+
logger.warn('staff portal time-reports feature check failed', { err: response })
|
|
174
|
+
return NextResponse.json({ ok: false, error: 'staff.errors.forbidden' }, { status: 403 })
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
auth,
|
|
179
|
+
customerId,
|
|
180
|
+
tenantId: auth.tenantId,
|
|
181
|
+
organizationId: auth.orgId,
|
|
182
|
+
em: (container.resolve('em') as EntityManager).fork(),
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export async function GET(req: Request) {
|
|
187
|
+
try {
|
|
188
|
+
const scopeOrResponse = await resolvePortalScope(req)
|
|
189
|
+
if (scopeOrResponse instanceof Response) return scopeOrResponse
|
|
190
|
+
const scope = scopeOrResponse
|
|
191
|
+
|
|
192
|
+
const url = new URL(req.url)
|
|
193
|
+
const parsedQuery = listQuerySchema.safeParse({
|
|
194
|
+
page: url.searchParams.get('page') ?? undefined,
|
|
195
|
+
pageSize: url.searchParams.get('pageSize') ?? undefined,
|
|
196
|
+
})
|
|
197
|
+
if (!parsedQuery.success) {
|
|
198
|
+
return NextResponse.json({ ok: false, error: 'staff.errors.invalidInput' }, { status: 400 })
|
|
199
|
+
}
|
|
200
|
+
const { page, pageSize } = parsedQuery.data
|
|
201
|
+
|
|
202
|
+
const connection = scope.em.getConnection()
|
|
203
|
+
const owned = portalOwnedReportClause(scope)
|
|
204
|
+
const countRows = (await connection.execute(
|
|
205
|
+
`SELECT COUNT(*)::bigint AS total FROM staff_time_reports WHERE ${owned.sql}`,
|
|
206
|
+
owned.params,
|
|
207
|
+
)) as Array<{ total: string | number | null }>
|
|
208
|
+
const total = toMinutes(countRows?.[0]?.total)
|
|
209
|
+
|
|
210
|
+
const rows = (await connection.execute(
|
|
211
|
+
`
|
|
212
|
+
SELECT id, reference, title, period_from, period_to, closed_at,
|
|
213
|
+
total_billable_minutes, total_nonbillable_minutes
|
|
214
|
+
FROM staff_time_reports
|
|
215
|
+
WHERE ${owned.sql}
|
|
216
|
+
ORDER BY period_from DESC, reference DESC
|
|
217
|
+
LIMIT ? OFFSET ?
|
|
218
|
+
`,
|
|
219
|
+
[...owned.params, pageSize, (page - 1) * pageSize],
|
|
220
|
+
)) as ReportRow[]
|
|
221
|
+
|
|
222
|
+
const items = rows
|
|
223
|
+
.map((row) => {
|
|
224
|
+
const periodFrom = toIsoDate(row.period_from)
|
|
225
|
+
const periodTo = toIsoDate(row.period_to)
|
|
226
|
+
if (!periodFrom || !periodTo) return null
|
|
227
|
+
return {
|
|
228
|
+
id: row.id,
|
|
229
|
+
reference: row.reference,
|
|
230
|
+
title: row.title,
|
|
231
|
+
periodFrom,
|
|
232
|
+
periodTo,
|
|
233
|
+
closedAt: toIsoDateTime(row.closed_at),
|
|
234
|
+
totalBillableMinutes: toMinutes(row.total_billable_minutes),
|
|
235
|
+
totalNonbillableMinutes: toMinutes(row.total_nonbillable_minutes),
|
|
236
|
+
}
|
|
237
|
+
})
|
|
238
|
+
.filter((item): item is z.infer<typeof reportItemSchema> => item !== null)
|
|
239
|
+
|
|
240
|
+
return NextResponse.json(
|
|
241
|
+
listResponseSchema.parse({
|
|
242
|
+
items,
|
|
243
|
+
total,
|
|
244
|
+
page,
|
|
245
|
+
pageSize,
|
|
246
|
+
totalPages: Math.max(1, Math.ceil(total / pageSize)),
|
|
247
|
+
}),
|
|
248
|
+
)
|
|
249
|
+
} catch (err) {
|
|
250
|
+
logger.error('staff portal time-reports list failed', { err })
|
|
251
|
+
return NextResponse.json({ ok: false, error: 'staff.errors.internal' }, { status: 500 })
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export const openApi: OpenApiRouteDoc = {
|
|
256
|
+
tag: 'Staff Portal',
|
|
257
|
+
methods: {
|
|
258
|
+
GET: {
|
|
259
|
+
summary: 'List the signed-in customer\u2019s closed time reports',
|
|
260
|
+
description:
|
|
261
|
+
'Returns the closed, non-deleted `staff_time_reports` rows whose `customer_id` matches the portal session\u2019s own customer entity, inside that session\u2019s tenant and organization. Draft reports are never listed. The response carries hours only \u2014 no rate, cost, amount or currency \u2014 because `staff.timesheets.rates.view` is a staff feature a portal identity cannot hold.',
|
|
262
|
+
query: listQuerySchema,
|
|
263
|
+
responses: [{ status: 200, description: 'Closed reports for the signed-in customer', schema: listResponseSchema }],
|
|
264
|
+
errors: [
|
|
265
|
+
{ status: 401, description: 'Not signed in to the portal', schema: errorResponseSchema },
|
|
266
|
+
{ status: 403, description: 'The portal account is not linked to a customer', schema: errorResponseSchema },
|
|
267
|
+
],
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
}
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
type StaffTeamMemberCreateInput,
|
|
18
18
|
} from '../../../data/validators'
|
|
19
19
|
import {
|
|
20
|
-
resolveUserFeatures,
|
|
21
20
|
runStaffMutationGuardAfterSuccess,
|
|
22
21
|
runStaffMutationGuards,
|
|
23
22
|
} from '../../guards'
|
|
@@ -126,7 +125,6 @@ export async function POST(req: Request) {
|
|
|
126
125
|
requestHeaders: req.headers,
|
|
127
126
|
mutationPayload: parsed,
|
|
128
127
|
},
|
|
129
|
-
resolveUserFeatures(auth),
|
|
130
128
|
)
|
|
131
129
|
if (!guardResult.ok) {
|
|
132
130
|
return NextResponse.json(
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
type StaffTeamMemberTagAssignmentInput,
|
|
15
15
|
} from '../../../../data/validators'
|
|
16
16
|
import {
|
|
17
|
-
resolveUserFeatures,
|
|
18
17
|
runStaffMutationGuardAfterSuccess,
|
|
19
18
|
runStaffMutationGuards,
|
|
20
19
|
} from '../../../guards'
|
|
@@ -68,7 +67,6 @@ export async function POST(req: Request) {
|
|
|
68
67
|
requestHeaders: req.headers,
|
|
69
68
|
mutationPayload: input,
|
|
70
69
|
},
|
|
71
|
-
resolveUserFeatures(auth),
|
|
72
70
|
)
|
|
73
71
|
if (!guardResult.ok) {
|
|
74
72
|
return NextResponse.json(
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
type StaffTeamMemberTagAssignmentInput,
|
|
15
15
|
} from '../../../../data/validators'
|
|
16
16
|
import {
|
|
17
|
-
resolveUserFeatures,
|
|
18
17
|
runStaffMutationGuardAfterSuccess,
|
|
19
18
|
runStaffMutationGuards,
|
|
20
19
|
} from '../../../guards'
|
|
@@ -68,7 +67,6 @@ export async function POST(req: Request) {
|
|
|
68
67
|
requestHeaders: req.headers,
|
|
69
68
|
mutationPayload: input,
|
|
70
69
|
},
|
|
71
|
-
resolveUserFeatures(auth),
|
|
72
70
|
)
|
|
73
71
|
if (!guardResult.ok) {
|
|
74
72
|
return NextResponse.json(
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API interceptors for the hand-rolled `/api/staff/timesheets/*` routes.
|
|
3
|
+
*
|
|
4
|
+
* The eight `makeCrudRoute` time-tracking resources run `runApiInterceptorsBefore`
|
|
5
|
+
* and `runApiInterceptorsAfter` through the CRUD factory. The ~23 routes written by
|
|
6
|
+
* hand beside them ran neither, so a third party could rewrite the body of a create
|
|
7
|
+
* on `/time-entries` but not on `/time-entries/bulk`, and could not shape the
|
|
8
|
+
* response of a single aggregate. This wraps the two shared runners in the one shape
|
|
9
|
+
* those routes need: one call before the work, one call around the response.
|
|
10
|
+
*
|
|
11
|
+
* `routePath` is derived from the request URL exactly as the factory derives it
|
|
12
|
+
* (`normalizeInterceptorRoutePath`) — the pathname with the leading `/api/` removed,
|
|
13
|
+
* so an interceptor targets `staff/timesheets/time-entries/bulk`. A route with a
|
|
14
|
+
* dynamic segment carries the CONCRETE id in that path
|
|
15
|
+
* (`staff/timesheets/time-entries/<uuid>/duplicate`), so an interceptor for one of
|
|
16
|
+
* those must use the registry's prefix wildcard — `staff/timesheets/time-entries/*`
|
|
17
|
+
* — rather than a literal with a placeholder in it.
|
|
18
|
+
*
|
|
19
|
+
* Scope: the interceptor context carries `tenantId` and `organizationId` and this
|
|
20
|
+
* helper fails closed with a 400 when either is missing, so no interceptor ever runs
|
|
21
|
+
* — and no route body is ever handed to one — outside a resolved tenant scope.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { NextResponse } from 'next/server'
|
|
25
|
+
import type { AwilixContainer } from 'awilix'
|
|
26
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
27
|
+
import type {
|
|
28
|
+
ApiInterceptorMethod,
|
|
29
|
+
InterceptorRequest,
|
|
30
|
+
} from '@open-mercato/shared/lib/crud/api-interceptor'
|
|
31
|
+
import { getApiInterceptorsForRoute } from '@open-mercato/shared/lib/crud/interceptor-registry'
|
|
32
|
+
import { runApiInterceptorsBefore } from '@open-mercato/shared/lib/crud/interceptor-runner'
|
|
33
|
+
import { runCustomRouteAfterInterceptors } from '@open-mercato/shared/lib/crud/custom-route-interceptor'
|
|
34
|
+
import { parseExtensionHeaders } from '@open-mercato/shared/lib/umes/extension-headers'
|
|
35
|
+
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
36
|
+
|
|
37
|
+
type RbacServiceLike = {
|
|
38
|
+
getGrantedFeatures?: (
|
|
39
|
+
userId: string,
|
|
40
|
+
scope: { tenantId: string | null; organizationId: string | null },
|
|
41
|
+
) => Promise<string[]>
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type TimesheetInterceptorScope = {
|
|
45
|
+
container: AwilixContainer
|
|
46
|
+
userId: string | null | undefined
|
|
47
|
+
tenantId: string | null | undefined
|
|
48
|
+
organizationId: string | null | undefined
|
|
49
|
+
/**
|
|
50
|
+
* The caller's granted features, when the route already resolved them — through
|
|
51
|
+
* `resolveFeatureAccess`, which always yields an array. Deliberately not
|
|
52
|
+
* nullable: a grant list that can be `null` cannot say whether an empty answer
|
|
53
|
+
* means "no grants" or "could not ask", and passing that ambiguity on is what
|
|
54
|
+
* this helper's own fallback exists to avoid.
|
|
55
|
+
*
|
|
56
|
+
* Omitted, the helper asks `rbacService.getGrantedFeatures` once — the same
|
|
57
|
+
* source the CRUD factory uses — so a feature-gated interceptor is evaluated
|
|
58
|
+
* against a real grant set rather than an empty one, and an unreadable set gates
|
|
59
|
+
* every feature-scoped interceptor off.
|
|
60
|
+
*/
|
|
61
|
+
userFeatures?: readonly string[]
|
|
62
|
+
/**
|
|
63
|
+
* Opt-in for the tenant-global routes (`/settings`, `/settings/reapply-rounding`),
|
|
64
|
+
* whose records have no organization at all. Without it a request that resolved no
|
|
65
|
+
* organization is refused rather than interceptor-scoped to an empty organization —
|
|
66
|
+
* the same fail-closed default every org-scoped route here keeps. With it, the
|
|
67
|
+
* context carries the empty organization id the CRUD factory also passes for a
|
|
68
|
+
* tenant-global caller.
|
|
69
|
+
*/
|
|
70
|
+
tenantGlobal?: boolean
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type TimesheetInterceptorSession = {
|
|
74
|
+
/** The request body after the before-pass, or `{}` for a route that sends none. */
|
|
75
|
+
body: Record<string, unknown>
|
|
76
|
+
/** The query after the before-pass. */
|
|
77
|
+
query: Record<string, unknown>
|
|
78
|
+
/** `query` as `URLSearchParams`, for routes that read their input that way. */
|
|
79
|
+
searchParams: URLSearchParams
|
|
80
|
+
/**
|
|
81
|
+
* Runs the after-pass over a successful JSON response and returns it. An
|
|
82
|
+
* interceptor that fails or times out replaces the response with its own error.
|
|
83
|
+
*/
|
|
84
|
+
respond(statusCode: number, body: Record<string, unknown>): Promise<NextResponse>
|
|
85
|
+
/**
|
|
86
|
+
* Runs the after-pass over a descriptor for a non-JSON response (a file export).
|
|
87
|
+
* The interceptors cannot rewrite the bytes, so the descriptor is what they shape;
|
|
88
|
+
* the caller applies whatever came back. A failed interceptor yields a JSON error
|
|
89
|
+
* response instead of the file.
|
|
90
|
+
*/
|
|
91
|
+
respondWithDescriptor(
|
|
92
|
+
descriptor: Record<string, unknown>,
|
|
93
|
+
): Promise<{ ok: true; descriptor: Record<string, unknown> } | { ok: false; response: NextResponse }>
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type TimesheetInterceptorRun =
|
|
97
|
+
| { ok: true; session: TimesheetInterceptorSession }
|
|
98
|
+
| { ok: false; response: NextResponse }
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Duplicates and repeated keys collapse to arrays so a rewritten query round-trips
|
|
102
|
+
* `?tagIds=a&tagIds=b` unchanged.
|
|
103
|
+
*/
|
|
104
|
+
export function readSearchParamsRecord(url: string): Record<string, unknown> {
|
|
105
|
+
const record: Record<string, unknown> = {}
|
|
106
|
+
let params: URLSearchParams
|
|
107
|
+
try {
|
|
108
|
+
params = new URL(url).searchParams
|
|
109
|
+
} catch {
|
|
110
|
+
return record
|
|
111
|
+
}
|
|
112
|
+
params.forEach((value, key) => {
|
|
113
|
+
const existing = record[key]
|
|
114
|
+
if (existing === undefined) {
|
|
115
|
+
record[key] = value
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
if (Array.isArray(existing)) {
|
|
119
|
+
existing.push(value)
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
record[key] = [existing, value]
|
|
123
|
+
})
|
|
124
|
+
return record
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function toSearchParams(query: Record<string, unknown>): URLSearchParams {
|
|
128
|
+
const params = new URLSearchParams()
|
|
129
|
+
for (const [key, value] of Object.entries(query)) {
|
|
130
|
+
if (value === null || value === undefined) continue
|
|
131
|
+
if (Array.isArray(value)) {
|
|
132
|
+
for (const item of value) {
|
|
133
|
+
if (item === null || item === undefined) continue
|
|
134
|
+
params.append(key, String(item))
|
|
135
|
+
}
|
|
136
|
+
continue
|
|
137
|
+
}
|
|
138
|
+
params.append(key, String(value))
|
|
139
|
+
}
|
|
140
|
+
return params
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function normalizeRoutePath(url: string): string {
|
|
144
|
+
try {
|
|
145
|
+
const pathname = new URL(url).pathname
|
|
146
|
+
if (pathname.startsWith('/api/')) return pathname.slice(5)
|
|
147
|
+
if (pathname === '/api') return ''
|
|
148
|
+
return pathname.replace(/^\/+/, '')
|
|
149
|
+
} catch {
|
|
150
|
+
return ''
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function toHeaderRecord(headers: Headers): Record<string, string> {
|
|
155
|
+
const output: Record<string, string> = {}
|
|
156
|
+
headers.forEach((value, key) => {
|
|
157
|
+
output[key] = value
|
|
158
|
+
})
|
|
159
|
+
return output
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function resolveUserFeatures(scope: TimesheetInterceptorScope): Promise<string[]> {
|
|
163
|
+
if (scope.userFeatures) return [...scope.userFeatures]
|
|
164
|
+
if (!scope.userId) return []
|
|
165
|
+
try {
|
|
166
|
+
const rbac = scope.container.resolve('rbacService') as RbacServiceLike | undefined
|
|
167
|
+
if (!rbac?.getGrantedFeatures) return []
|
|
168
|
+
return await rbac.getGrantedFeatures(scope.userId, {
|
|
169
|
+
tenantId: scope.tenantId ?? null,
|
|
170
|
+
organizationId: scope.organizationId ?? null,
|
|
171
|
+
})
|
|
172
|
+
} catch {
|
|
173
|
+
// An unreadable grant set gates every feature-scoped interceptor off rather
|
|
174
|
+
// than running it unauthorized.
|
|
175
|
+
return []
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export async function runTimesheetInterceptors(args: {
|
|
180
|
+
request: Request
|
|
181
|
+
method: ApiInterceptorMethod
|
|
182
|
+
scope: TimesheetInterceptorScope
|
|
183
|
+
/** `readJsonSafe` returns `null` for an unparseable body; that reaches here as `{}`. */
|
|
184
|
+
body?: Record<string, unknown> | null
|
|
185
|
+
query?: Record<string, unknown>
|
|
186
|
+
}): Promise<TimesheetInterceptorRun> {
|
|
187
|
+
const { request, method, scope } = args
|
|
188
|
+
const tenantId = scope.tenantId || null
|
|
189
|
+
const resolvedOrganizationId = scope.organizationId || null
|
|
190
|
+
const organizationId = resolvedOrganizationId ?? (scope.tenantGlobal ? '' : null)
|
|
191
|
+
if (!tenantId || organizationId === null) {
|
|
192
|
+
const { translate } = await resolveTranslations()
|
|
193
|
+
return {
|
|
194
|
+
ok: false,
|
|
195
|
+
response: NextResponse.json(
|
|
196
|
+
{ error: translate('staff.errors.missingScope', 'Missing tenant or organization scope.') },
|
|
197
|
+
{ status: 400 },
|
|
198
|
+
),
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const routePath = normalizeRoutePath(request.url)
|
|
203
|
+
const headers = toHeaderRecord(request.headers)
|
|
204
|
+
const requestPayload: InterceptorRequest = {
|
|
205
|
+
method,
|
|
206
|
+
url: request.url,
|
|
207
|
+
body: args.body ?? {},
|
|
208
|
+
query: args.query ?? {},
|
|
209
|
+
headers,
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// No interceptor targets this route and method, so neither pass can observe or
|
|
213
|
+
// change anything. Skipping here keeps the request off the RBAC grant read and the
|
|
214
|
+
// `em` resolve that assembling an interceptor context would otherwise cost on every
|
|
215
|
+
// call to every one of these routes.
|
|
216
|
+
if (getApiInterceptorsForRoute(routePath, method).length === 0) {
|
|
217
|
+
const query = requestPayload.query ?? {}
|
|
218
|
+
return {
|
|
219
|
+
ok: true,
|
|
220
|
+
session: {
|
|
221
|
+
body: requestPayload.body ?? {},
|
|
222
|
+
query,
|
|
223
|
+
searchParams: toSearchParams(query),
|
|
224
|
+
async respond(statusCode, body) {
|
|
225
|
+
return NextResponse.json(body, { status: statusCode })
|
|
226
|
+
},
|
|
227
|
+
async respondWithDescriptor(descriptor) {
|
|
228
|
+
return { ok: true, descriptor }
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const context = {
|
|
235
|
+
userId: scope.userId ?? '',
|
|
236
|
+
organizationId,
|
|
237
|
+
tenantId,
|
|
238
|
+
em: scope.container.resolve('em') as EntityManager,
|
|
239
|
+
container: scope.container,
|
|
240
|
+
userFeatures: await resolveUserFeatures(scope),
|
|
241
|
+
extensionHeaders: parseExtensionHeaders(headers),
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const before = await runApiInterceptorsBefore({
|
|
245
|
+
routePath,
|
|
246
|
+
method,
|
|
247
|
+
request: requestPayload,
|
|
248
|
+
context,
|
|
249
|
+
})
|
|
250
|
+
if (!before.ok) {
|
|
251
|
+
return { ok: false, response: NextResponse.json(before.body, { status: before.statusCode }) }
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const interceptedRequest = before.request
|
|
255
|
+
const query = interceptedRequest.query ?? {}
|
|
256
|
+
|
|
257
|
+
const runAfter = async (body: Record<string, unknown>, statusCode: number) =>
|
|
258
|
+
runCustomRouteAfterInterceptors({
|
|
259
|
+
routePath,
|
|
260
|
+
method,
|
|
261
|
+
request: interceptedRequest,
|
|
262
|
+
response: { statusCode, body, headers: {} },
|
|
263
|
+
context,
|
|
264
|
+
metadataByInterceptor: before.metadataByInterceptor,
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
return {
|
|
268
|
+
ok: true,
|
|
269
|
+
session: {
|
|
270
|
+
body: interceptedRequest.body ?? {},
|
|
271
|
+
query,
|
|
272
|
+
searchParams: toSearchParams(query),
|
|
273
|
+
async respond(statusCode, body) {
|
|
274
|
+
const after = await runAfter(body, statusCode)
|
|
275
|
+
return NextResponse.json(after.body, {
|
|
276
|
+
status: after.statusCode,
|
|
277
|
+
...(Object.keys(after.headers).length ? { headers: after.headers } : {}),
|
|
278
|
+
})
|
|
279
|
+
},
|
|
280
|
+
async respondWithDescriptor(descriptor) {
|
|
281
|
+
const after = await runAfter(descriptor, 200)
|
|
282
|
+
if (!after.ok) {
|
|
283
|
+
return {
|
|
284
|
+
ok: false,
|
|
285
|
+
response: NextResponse.json(after.body, { status: after.statusCode }),
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return { ok: true, descriptor: after.body }
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
}
|
|
292
|
+
}
|