@open-mercato/core 0.6.4-develop.4217.1.c9aa050183 → 0.6.4-develop.4236.1.9fa6806b34
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 +37 -0
- package/dist/generated/entities/staff_time_entry/index.js.map +7 -0
- package/dist/generated/entities/staff_time_entry_segment/index.js +23 -0
- package/dist/generated/entities/staff_time_entry_segment/index.js.map +7 -0
- package/dist/generated/entities/staff_time_project/index.js +35 -0
- package/dist/generated/entities/staff_time_project/index.js.map +7 -0
- package/dist/generated/entities/staff_time_project_member/index.js +29 -0
- package/dist/generated/entities/staff_time_project_member/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +5 -1
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +64 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/helpers/integration/timesheetFixtures.js +50 -0
- package/dist/helpers/integration/timesheetFixtures.js.map +7 -0
- package/dist/modules/attachments/api/library/[id]/route.js +20 -16
- package/dist/modules/attachments/api/library/[id]/route.js.map +2 -2
- package/dist/modules/attachments/api/route.js +18 -14
- package/dist/modules/attachments/api/route.js.map +2 -2
- package/dist/modules/auth/api/roles/acl/route.js +10 -4
- package/dist/modules/auth/api/roles/acl/route.js.map +2 -2
- package/dist/modules/auth/api/sidebar/preferences/route.js +27 -20
- package/dist/modules/auth/api/sidebar/preferences/route.js.map +2 -2
- package/dist/modules/auth/api/users/acl/route.js +16 -11
- package/dist/modules/auth/api/users/acl/route.js.map +2 -2
- package/dist/modules/auth/commands/users.js +87 -71
- package/dist/modules/auth/commands/users.js.map +2 -2
- package/dist/modules/auth/services/sidebarPreferencesService.js +39 -30
- package/dist/modules/auth/services/sidebarPreferencesService.js.map +2 -2
- package/dist/modules/catalog/commands/categories.js +61 -12
- package/dist/modules/catalog/commands/categories.js.map +2 -2
- package/dist/modules/catalog/commands/products.js +79 -54
- package/dist/modules/catalog/commands/products.js.map +2 -2
- package/dist/modules/catalog/commands/variants.js +29 -16
- package/dist/modules/catalog/commands/variants.js.map +2 -2
- package/dist/modules/currencies/commands/currencies.js +15 -8
- package/dist/modules/currencies/commands/currencies.js.map +2 -2
- package/dist/modules/customer_accounts/api/admin/users.js +27 -26
- package/dist/modules/customer_accounts/api/admin/users.js.map +2 -2
- package/dist/modules/customer_accounts/api/password/reset-confirm.js +5 -5
- package/dist/modules/customer_accounts/api/password/reset-confirm.js.map +2 -2
- package/dist/modules/customer_accounts/api/portal/users/[id]/roles.js +11 -10
- package/dist/modules/customer_accounts/api/portal/users/[id]/roles.js.map +2 -2
- package/dist/modules/customers/commands/addresses.js +35 -21
- package/dist/modules/customers/commands/addresses.js.map +2 -2
- package/dist/modules/customers/commands/companies.js +163 -162
- package/dist/modules/customers/commands/companies.js.map +2 -2
- package/dist/modules/customers/commands/deals.js +3 -4
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/commands/interactions.js +19 -22
- package/dist/modules/customers/commands/interactions.js.map +2 -2
- package/dist/modules/customers/commands/people.js +18 -15
- package/dist/modules/customers/commands/people.js.map +2 -2
- package/dist/modules/customers/commands/personCompanyLinks.js +105 -94
- package/dist/modules/customers/commands/personCompanyLinks.js.map +2 -2
- package/dist/modules/customers/commands/pipeline-stages.js +30 -23
- package/dist/modules/customers/commands/pipeline-stages.js.map +2 -2
- package/dist/modules/customers/commands/pipelines.js +27 -20
- package/dist/modules/customers/commands/pipelines.js.map +2 -2
- package/dist/modules/customers/commands/tags.js +13 -5
- package/dist/modules/customers/commands/tags.js.map +2 -2
- package/dist/modules/dashboards/api/users/widgets/route.js +0 -1
- package/dist/modules/dashboards/api/users/widgets/route.js.map +2 -2
- package/dist/modules/dashboards/api/widgets/data/route.js +29 -1
- package/dist/modules/dashboards/api/widgets/data/route.js.map +2 -2
- package/dist/modules/data_sync/lib/sync-engine.js +4 -4
- package/dist/modules/data_sync/lib/sync-engine.js.map +2 -2
- package/dist/modules/data_sync/lib/sync-run-service.js +51 -27
- package/dist/modules/data_sync/lib/sync-run-service.js.map +2 -2
- package/dist/modules/directory/commands/organizations.js +192 -158
- package/dist/modules/directory/commands/organizations.js.map +3 -3
- package/dist/modules/inbox_ops/api/emails/[id]/reprocess/route.js +22 -16
- package/dist/modules/inbox_ops/api/emails/[id]/reprocess/route.js.map +2 -2
- package/dist/modules/messages/commands/messages.js +77 -75
- package/dist/modules/messages/commands/messages.js.map +2 -2
- package/dist/modules/messages/commands/shared.js +132 -132
- package/dist/modules/messages/commands/shared.js.map +2 -2
- package/dist/modules/perspectives/api/[tableId]/route.js +37 -26
- package/dist/modules/perspectives/api/[tableId]/route.js.map +2 -2
- package/dist/modules/resources/commands/resources.js +125 -117
- package/dist/modules/resources/commands/resources.js.map +2 -2
- package/dist/modules/resources/commands/tags.js +7 -3
- package/dist/modules/resources/commands/tags.js.map +2 -2
- package/dist/modules/sales/api/quotes/send/route.js +12 -11
- package/dist/modules/sales/api/quotes/send/route.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +629 -478
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/commands/payments.js +146 -146
- package/dist/modules/sales/commands/payments.js.map +2 -2
- package/dist/modules/sales/commands/returns.js +68 -60
- package/dist/modules/sales/commands/returns.js.map +2 -2
- package/dist/modules/staff/acl.js +10 -1
- package/dist/modules/staff/acl.js.map +2 -2
- package/dist/modules/staff/analytics.js +33 -0
- package/dist/modules/staff/analytics.js.map +7 -0
- package/dist/modules/staff/api/guards.js +31 -0
- package/dist/modules/staff/api/guards.js.map +7 -0
- package/dist/modules/staff/api/interceptors.js +96 -0
- package/dist/modules/staff/api/interceptors.js.map +7 -0
- package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js +170 -0
- package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/my-projects/route.js +103 -0
- package/dist/modules/staff/api/timesheets/my-projects/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/projects/kpis/route.js +147 -0
- package/dist/modules/staff/api/timesheets/projects/kpis/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js +171 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js +180 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js +155 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js +173 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js +260 -0
- package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/route.js +188 -0
- package/dist/modules/staff/api/timesheets/time-entries/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-projects/[id]/employees/route.js +159 -0
- package/dist/modules/staff/api/timesheets/time-projects/[id]/employees/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-projects/route.js +230 -0
- package/dist/modules/staff/api/timesheets/time-projects/route.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/page.js +710 -0
- package/dist/modules/staff/backend/staff/timesheets/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/page.meta.js +22 -0
- package/dist/modules/staff/backend/staff/timesheets/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.js +125 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.js +418 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.js +79 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/page.js +602 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/page.meta.js +25 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/projectFormConfig.js +123 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/projectFormConfig.js.map +7 -0
- package/dist/modules/staff/cli.js +38 -1
- package/dist/modules/staff/cli.js.map +2 -2
- package/dist/modules/staff/commands/index.js +2 -0
- package/dist/modules/staff/commands/index.js.map +2 -2
- package/dist/modules/staff/commands/leave-requests.js +30 -28
- package/dist/modules/staff/commands/leave-requests.js.map +3 -3
- package/dist/modules/staff/commands/team-members.js +21 -20
- package/dist/modules/staff/commands/team-members.js.map +2 -2
- package/dist/modules/staff/commands/timesheets-entries.js +409 -0
- package/dist/modules/staff/commands/timesheets-entries.js.map +7 -0
- package/dist/modules/staff/commands/timesheets-projects.js +618 -0
- package/dist/modules/staff/commands/timesheets-projects.js.map +7 -0
- package/dist/modules/staff/data/enrichers.js +104 -0
- package/dist/modules/staff/data/enrichers.js.map +7 -0
- package/dist/modules/staff/data/entities.js +226 -1
- package/dist/modules/staff/data/entities.js.map +2 -2
- package/dist/modules/staff/data/validators.js +113 -1
- package/dist/modules/staff/data/validators.js.map +2 -2
- package/dist/modules/staff/events.js +13 -1
- package/dist/modules/staff/events.js.map +2 -2
- package/dist/modules/staff/lib/crud.js +7 -1
- package/dist/modules/staff/lib/crud.js.map +2 -2
- package/dist/modules/staff/lib/staffMemberResolver.js +15 -0
- package/dist/modules/staff/lib/staffMemberResolver.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/computeProjectHoursTrend.js +60 -0
- package/dist/modules/staff/lib/timesheets-projects/computeProjectHoursTrend.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/computeProjectsKpis.js +260 -0
- package/dist/modules/staff/lib/timesheets-projects/computeProjectsKpis.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/dateBuckets.js +41 -0
- package/dist/modules/staff/lib/timesheets-projects/dateBuckets.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/initials.js +10 -0
- package/dist/modules/staff/lib/timesheets-projects/initials.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/kpiMath.js +12 -0
- package/dist/modules/staff/lib/timesheets-projects/kpiMath.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/listProjectMembersPreview.js +55 -0
- package/dist/modules/staff/lib/timesheets-projects/listProjectMembersPreview.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/HoursSparkline.js +66 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/HoursSparkline.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectCard.js +81 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectCard.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectMembersAvatarStack.js +58 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectMembersAvatarStack.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectsKpiStrip.js +152 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectsKpiStrip.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/SavedViewTabs.js +37 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/SavedViewTabs.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ViewModeToggle.js +57 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ViewModeToggle.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/useProjectsViewMode.js +50 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/useProjectsViewMode.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/AddRowDropdown.js +163 -0
- package/dist/modules/staff/lib/timesheets-ui/AddRowDropdown.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/CalendarPicker.js +209 -0
- package/dist/modules/staff/lib/timesheets-ui/CalendarPicker.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/ColorPicker.js +52 -0
- package/dist/modules/staff/lib/timesheets-ui/ColorPicker.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/CreateProjectDialog.js +77 -0
- package/dist/modules/staff/lib/timesheets-ui/CreateProjectDialog.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/ListView.js +173 -0
- package/dist/modules/staff/lib/timesheets-ui/ListView.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/ProjectColorDot.js +32 -0
- package/dist/modules/staff/lib/timesheets-ui/ProjectColorDot.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/TimerBar.js +270 -0
- package/dist/modules/staff/lib/timesheets-ui/TimerBar.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/ViewSwitcher.js +57 -0
- package/dist/modules/staff/lib/timesheets-ui/ViewSwitcher.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/colors.js +43 -0
- package/dist/modules/staff/lib/timesheets-ui/colors.js.map +7 -0
- package/dist/modules/staff/migrations/Migration20260326135612.js +24 -0
- package/dist/modules/staff/migrations/Migration20260326135612.js.map +7 -0
- package/dist/modules/staff/migrations/Migration20260413102715.js +23 -0
- package/dist/modules/staff/migrations/Migration20260413102715.js.map +7 -0
- package/dist/modules/staff/migrations/Migration20260413111602.js +13 -0
- package/dist/modules/staff/migrations/Migration20260413111602.js.map +7 -0
- package/dist/modules/staff/migrations/Migration20260511112759.js +19 -0
- package/dist/modules/staff/migrations/Migration20260511112759.js.map +7 -0
- package/dist/modules/staff/search.js +35 -0
- package/dist/modules/staff/search.js.map +2 -2
- package/dist/modules/staff/setup.js +15 -1
- package/dist/modules/staff/setup.js.map +2 -2
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/config.js +16 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/config.js.map +7 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.client.js +126 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.client.js.map +7 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.js +26 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.js.map +7 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/config.js +15 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/config.js.map +7 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.client.js +238 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.client.js.map +7 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.js +26 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.js.map +7 -0
- package/dist/modules/staff/widgets/injection/timer-sidebar-indicator/widget.js +145 -0
- package/dist/modules/staff/widgets/injection/timer-sidebar-indicator/widget.js.map +7 -0
- package/dist/modules/staff/widgets/injection-table.js +12 -0
- package/dist/modules/staff/widgets/injection-table.js.map +7 -0
- package/dist/modules/sync_excel/api/import/route.js +19 -17
- package/dist/modules/sync_excel/api/import/route.js.map +2 -2
- package/dist/modules/translations/commands/translations.js +22 -19
- package/dist/modules/translations/commands/translations.js.map +2 -2
- package/generated/entities/staff_time_entry/index.ts +17 -0
- package/generated/entities/staff_time_entry_segment/index.ts +10 -0
- package/generated/entities/staff_time_project/index.ts +16 -0
- package/generated/entities/staff_time_project_member/index.ts +13 -0
- package/generated/entities.ids.generated.ts +5 -1
- package/generated/entity-fields-registry.ts +64 -0
- package/package.json +7 -7
- package/src/helpers/integration/timesheetFixtures.ts +61 -0
- package/src/modules/attachments/api/library/[id]/route.ts +24 -17
- package/src/modules/attachments/api/route.ts +20 -14
- package/src/modules/auth/api/roles/acl/route.ts +11 -5
- package/src/modules/auth/api/sidebar/preferences/route.ts +33 -24
- package/src/modules/auth/api/users/acl/route.ts +17 -12
- package/src/modules/auth/commands/users.ts +96 -80
- package/src/modules/auth/services/sidebarPreferencesService.ts +40 -32
- package/src/modules/catalog/commands/categories.ts +61 -12
- package/src/modules/catalog/commands/products.ts +93 -60
- package/src/modules/catalog/commands/variants.ts +29 -16
- package/src/modules/currencies/commands/currencies.ts +27 -14
- package/src/modules/customer_accounts/api/admin/users.ts +31 -26
- package/src/modules/customer_accounts/api/password/reset-confirm.ts +5 -6
- package/src/modules/customer_accounts/api/portal/users/[id]/roles.ts +14 -13
- package/src/modules/customers/commands/addresses.ts +35 -23
- package/src/modules/customers/commands/companies.ts +166 -165
- package/src/modules/customers/commands/deals.ts +2 -4
- package/src/modules/customers/commands/interactions.ts +20 -26
- package/src/modules/customers/commands/people.ts +18 -15
- package/src/modules/customers/commands/personCompanyLinks.ts +109 -100
- package/src/modules/customers/commands/pipeline-stages.ts +31 -27
- package/src/modules/customers/commands/pipelines.ts +29 -23
- package/src/modules/customers/commands/tags.ts +13 -5
- package/src/modules/dashboards/api/users/widgets/route.ts +0 -1
- package/src/modules/dashboards/api/widgets/data/route.ts +36 -1
- package/src/modules/data_sync/lib/sync-engine.ts +4 -5
- package/src/modules/data_sync/lib/sync-run-service.ts +57 -28
- package/src/modules/directory/commands/organizations.ts +203 -166
- package/src/modules/inbox_ops/api/emails/[id]/reprocess/route.ts +26 -18
- package/src/modules/messages/commands/messages.ts +82 -80
- package/src/modules/messages/commands/shared.ts +138 -133
- package/src/modules/perspectives/api/[tableId]/route.ts +38 -27
- package/src/modules/resources/commands/resources.ts +127 -117
- package/src/modules/resources/commands/tags.ts +7 -3
- package/src/modules/sales/api/quotes/send/route.ts +17 -12
- package/src/modules/sales/commands/documents.ts +673 -481
- package/src/modules/sales/commands/payments.ts +158 -152
- package/src/modules/sales/commands/returns.ts +74 -63
- package/src/modules/staff/acl.ts +11 -0
- package/src/modules/staff/analytics.ts +30 -0
- package/src/modules/staff/api/guards.ts +59 -0
- package/src/modules/staff/api/interceptors.ts +122 -0
- package/src/modules/staff/api/timesheets/my-projects/[projectId]/route.ts +191 -0
- package/src/modules/staff/api/timesheets/my-projects/route.ts +115 -0
- package/src/modules/staff/api/timesheets/projects/kpis/route.ts +159 -0
- package/src/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.ts +187 -0
- package/src/modules/staff/api/timesheets/time-entries/[id]/segments/route.ts +191 -0
- package/src/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.ts +168 -0
- package/src/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.ts +191 -0
- package/src/modules/staff/api/timesheets/time-entries/bulk/route.ts +292 -0
- package/src/modules/staff/api/timesheets/time-entries/route.ts +193 -0
- package/src/modules/staff/api/timesheets/time-projects/[id]/employees/route.ts +167 -0
- package/src/modules/staff/api/timesheets/time-projects/route.ts +244 -0
- package/src/modules/staff/backend/staff/timesheets/page.meta.ts +20 -0
- package/src/modules/staff/backend/staff/timesheets/page.tsx +899 -0
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.tsx +141 -0
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/page.tsx +579 -0
- package/src/modules/staff/backend/staff/timesheets/projects/create/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/timesheets/projects/create/page.tsx +90 -0
- package/src/modules/staff/backend/staff/timesheets/projects/page.meta.ts +23 -0
- package/src/modules/staff/backend/staff/timesheets/projects/page.tsx +765 -0
- package/src/modules/staff/backend/staff/timesheets/projects/projectFormConfig.ts +138 -0
- package/src/modules/staff/cli.ts +40 -1
- package/src/modules/staff/commands/index.ts +2 -0
- package/src/modules/staff/commands/leave-requests.ts +37 -29
- package/src/modules/staff/commands/team-members.ts +25 -20
- package/src/modules/staff/commands/timesheets-entries.ts +504 -0
- package/src/modules/staff/commands/timesheets-projects.ts +699 -0
- package/src/modules/staff/data/enrichers.ts +134 -0
- package/src/modules/staff/data/entities.ts +198 -0
- package/src/modules/staff/data/validators.ts +129 -0
- package/src/modules/staff/events.ts +13 -0
- package/src/modules/staff/i18n/de.json +209 -1
- package/src/modules/staff/i18n/en.json +209 -1
- package/src/modules/staff/i18n/es.json +209 -1
- package/src/modules/staff/i18n/pl.json +209 -1
- package/src/modules/staff/lib/crud.ts +8 -0
- package/src/modules/staff/lib/staffMemberResolver.ts +22 -0
- package/src/modules/staff/lib/timesheets-projects/computeProjectHoursTrend.ts +89 -0
- package/src/modules/staff/lib/timesheets-projects/computeProjectsKpis.ts +311 -0
- package/src/modules/staff/lib/timesheets-projects/dateBuckets.ts +37 -0
- package/src/modules/staff/lib/timesheets-projects/initials.ts +6 -0
- package/src/modules/staff/lib/timesheets-projects/kpiMath.ts +8 -0
- package/src/modules/staff/lib/timesheets-projects/listProjectMembersPreview.ts +83 -0
- package/src/modules/staff/lib/timesheets-projects-ui/HoursSparkline.tsx +75 -0
- package/src/modules/staff/lib/timesheets-projects-ui/ProjectCard.tsx +110 -0
- package/src/modules/staff/lib/timesheets-projects-ui/ProjectMembersAvatarStack.tsx +73 -0
- package/src/modules/staff/lib/timesheets-projects-ui/ProjectsKpiStrip.tsx +185 -0
- package/src/modules/staff/lib/timesheets-projects-ui/SavedViewTabs.tsx +53 -0
- package/src/modules/staff/lib/timesheets-projects-ui/ViewModeToggle.tsx +63 -0
- package/src/modules/staff/lib/timesheets-projects-ui/useProjectsViewMode.ts +63 -0
- package/src/modules/staff/lib/timesheets-ui/AddRowDropdown.tsx +188 -0
- package/src/modules/staff/lib/timesheets-ui/CalendarPicker.tsx +229 -0
- package/src/modules/staff/lib/timesheets-ui/ColorPicker.tsx +65 -0
- package/src/modules/staff/lib/timesheets-ui/CreateProjectDialog.tsx +99 -0
- package/src/modules/staff/lib/timesheets-ui/ListView.tsx +230 -0
- package/src/modules/staff/lib/timesheets-ui/ProjectColorDot.tsx +40 -0
- package/src/modules/staff/lib/timesheets-ui/TimerBar.tsx +327 -0
- package/src/modules/staff/lib/timesheets-ui/ViewSwitcher.tsx +60 -0
- package/src/modules/staff/lib/timesheets-ui/colors.ts +58 -0
- package/src/modules/staff/migrations/.snapshot-open-mercato.json +1148 -0
- package/src/modules/staff/migrations/Migration20260326135612.ts +26 -0
- package/src/modules/staff/migrations/Migration20260413102715.ts +25 -0
- package/src/modules/staff/migrations/Migration20260413111602.ts +13 -0
- package/src/modules/staff/migrations/Migration20260511112759.ts +21 -0
- package/src/modules/staff/search.ts +35 -0
- package/src/modules/staff/setup.ts +15 -0
- package/src/modules/staff/widgets/dashboard/timesheets-hours-by-project/config.ts +17 -0
- package/src/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.client.tsx +158 -0
- package/src/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.ts +25 -0
- package/src/modules/staff/widgets/dashboard/timesheets-time-reporting/config.ts +15 -0
- package/src/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.client.tsx +297 -0
- package/src/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.ts +25 -0
- package/src/modules/staff/widgets/injection/timer-sidebar-indicator/widget.tsx +161 -0
- package/src/modules/staff/widgets/injection-table.ts +10 -0
- package/src/modules/sync_excel/api/import/route.ts +23 -18
- package/src/modules/translations/commands/translations.ts +49 -41
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
import { registerCommand, type CommandHandler } from '@open-mercato/shared/lib/commands'
|
|
4
|
+
import { withAtomicFlush } from '@open-mercato/shared/lib/commands/flush'
|
|
4
5
|
import { extractUndoPayload, type UndoPayload } from '@open-mercato/shared/lib/commands/undo'
|
|
5
6
|
import { findOneWithDecryption, findWithDecryption } from '@open-mercato/shared/lib/encryption/find'
|
|
6
7
|
import { Message, MessageObject, MessageRecipient, type MessageActionData } from '../data/entities'
|
|
@@ -432,94 +433,95 @@ const updateDraftCommand: CommandHandler<unknown, { ok: true; id: string }> = {
|
|
|
432
433
|
}
|
|
433
434
|
}
|
|
434
435
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
436
|
+
await withAtomicFlush(em, [async () => {
|
|
437
|
+
if (input.type !== undefined) message.type = input.type
|
|
438
|
+
if (input.visibility !== undefined) message.visibility = input.visibility
|
|
439
|
+
if (input.sourceEntityType !== undefined) message.sourceEntityType = input.sourceEntityType
|
|
440
|
+
if (input.sourceEntityId !== undefined) message.sourceEntityId = input.sourceEntityId
|
|
441
|
+
if (input.externalEmail !== undefined) message.externalEmail = input.externalEmail
|
|
442
|
+
if (input.externalName !== undefined) message.externalName = input.externalName
|
|
443
|
+
if (input.subject !== undefined) message.subject = input.subject
|
|
444
|
+
if (input.body !== undefined) message.body = input.body
|
|
445
|
+
if (input.bodyFormat !== undefined) message.bodyFormat = input.bodyFormat
|
|
446
|
+
if (input.priority !== undefined) message.priority = input.priority
|
|
447
|
+
if (input.actionData !== undefined) message.actionData = input.actionData
|
|
448
|
+
if (input.sendViaEmail !== undefined) message.sendViaEmail = input.sendViaEmail
|
|
449
|
+
|
|
450
|
+
if (input.recipients) {
|
|
451
|
+
await em.nativeDelete(MessageRecipient, { messageId: message.id })
|
|
452
|
+
for (const recipient of input.recipients) {
|
|
453
|
+
em.persist(em.create(MessageRecipient, {
|
|
454
|
+
messageId: message.id,
|
|
455
|
+
recipientUserId: recipient.userId,
|
|
456
|
+
recipientType: recipient.type,
|
|
457
|
+
status: 'unread',
|
|
458
|
+
}))
|
|
459
|
+
}
|
|
457
460
|
}
|
|
458
|
-
}
|
|
459
461
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
462
|
+
if (input.objects) {
|
|
463
|
+
await em.nativeDelete(MessageObject, { messageId: message.id })
|
|
464
|
+
for (const object of input.objects) {
|
|
465
|
+
em.persist(em.create(MessageObject, {
|
|
466
|
+
messageId: message.id,
|
|
467
|
+
entityModule: object.entityModule,
|
|
468
|
+
entityType: object.entityType,
|
|
469
|
+
entityId: object.entityId,
|
|
470
|
+
actionRequired: object.actionRequired,
|
|
471
|
+
actionType: object.actionType,
|
|
472
|
+
actionLabel: object.actionLabel,
|
|
473
|
+
}))
|
|
474
|
+
}
|
|
472
475
|
}
|
|
473
|
-
}
|
|
474
476
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
477
|
+
if (input.attachmentIds) {
|
|
478
|
+
const { Attachment } = await import('@open-mercato/core/modules/attachments/data/entities')
|
|
479
|
+
if (input.attachmentIds.length === 0) {
|
|
480
|
+
await em.nativeDelete(Attachment, {
|
|
481
|
+
entityId: MESSAGE_ATTACHMENT_ENTITY_ID,
|
|
482
|
+
recordId: message.id,
|
|
483
|
+
tenantId: input.tenantId,
|
|
484
|
+
organizationId: input.organizationId,
|
|
485
|
+
})
|
|
486
|
+
} else {
|
|
487
|
+
await em.nativeDelete(Attachment, {
|
|
488
|
+
entityId: MESSAGE_ATTACHMENT_ENTITY_ID,
|
|
489
|
+
recordId: message.id,
|
|
490
|
+
tenantId: input.tenantId,
|
|
491
|
+
organizationId: input.organizationId,
|
|
492
|
+
id: { $nin: input.attachmentIds },
|
|
493
|
+
})
|
|
494
|
+
}
|
|
495
|
+
await linkAttachmentsToMessage(
|
|
496
|
+
em,
|
|
497
|
+
message.id,
|
|
498
|
+
input.attachmentIds,
|
|
499
|
+
input.organizationId,
|
|
500
|
+
input.tenantId,
|
|
501
|
+
)
|
|
492
502
|
}
|
|
493
|
-
await linkAttachmentsToMessage(
|
|
494
|
-
em,
|
|
495
|
-
message.id,
|
|
496
|
-
input.attachmentIds,
|
|
497
|
-
input.organizationId,
|
|
498
|
-
input.tenantId,
|
|
499
|
-
)
|
|
500
|
-
}
|
|
501
503
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
if (finalVisibility !== 'public' && finalRecipientCount === 0) {
|
|
511
|
-
throw new Error('at least one recipient is required')
|
|
512
|
-
}
|
|
513
|
-
if (!finalSubject?.trim()) throw new Error('subject is required')
|
|
514
|
-
if (!finalBody?.trim()) throw new Error('body is required')
|
|
504
|
+
if (isSending) {
|
|
505
|
+
const finalVisibility = input.visibility ?? message.visibility
|
|
506
|
+
const finalSubject = input.subject ?? message.subject
|
|
507
|
+
const finalBody = input.body ?? message.body
|
|
508
|
+
const finalRecipientCount = input.recipients
|
|
509
|
+
? input.recipients.length
|
|
510
|
+
: (preloadedRecipients?.length ?? 0)
|
|
515
511
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
512
|
+
if (finalVisibility !== 'public' && finalRecipientCount === 0) {
|
|
513
|
+
throw new Error('at least one recipient is required')
|
|
514
|
+
}
|
|
515
|
+
if (!finalSubject?.trim()) throw new Error('subject is required')
|
|
516
|
+
if (!finalBody?.trim()) throw new Error('body is required')
|
|
517
|
+
|
|
518
|
+
message.isDraft = false
|
|
519
|
+
message.status = 'sent'
|
|
520
|
+
message.sentAt = new Date()
|
|
521
|
+
if (!message.threadId) message.threadId = message.id
|
|
522
|
+
}
|
|
523
|
+
}], { transaction: true })
|
|
521
524
|
|
|
522
|
-
await em.flush()
|
|
523
525
|
await emitMessageIndexUpsert(ctx.container, {
|
|
524
526
|
messageId: message.id,
|
|
525
527
|
tenantId: input.tenantId,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
2
|
+
import { withAtomicFlush } from '@open-mercato/shared/lib/commands/flush'
|
|
2
3
|
import { Message, MessageObject, MessageRecipient, type MessageActionData, type RecipientStatus } from '../data/entities'
|
|
3
4
|
import { MESSAGE_ATTACHMENT_ENTITY_ID } from '../lib/constants'
|
|
4
5
|
|
|
@@ -187,152 +188,156 @@ export async function restoreMessageAggregateSnapshot(
|
|
|
187
188
|
em: EntityManager,
|
|
188
189
|
snapshot: MessageAggregateSnapshot,
|
|
189
190
|
): Promise<void> {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
bodyFormat: snapshot.message.bodyFormat,
|
|
206
|
-
priority: snapshot.message.priority,
|
|
207
|
-
status: snapshot.message.status,
|
|
208
|
-
isDraft: snapshot.message.isDraft,
|
|
209
|
-
sentAt: toDate(snapshot.message.sentAt),
|
|
210
|
-
actionData: snapshot.message.actionData as MessageActionData,
|
|
211
|
-
actionResult: snapshot.message.actionResult,
|
|
212
|
-
actionTaken: snapshot.message.actionTaken,
|
|
213
|
-
actionTakenByUserId: snapshot.message.actionTakenByUserId,
|
|
214
|
-
actionTakenAt: toDate(snapshot.message.actionTakenAt),
|
|
215
|
-
sendViaEmail: snapshot.message.sendViaEmail,
|
|
216
|
-
tenantId: snapshot.message.tenantId,
|
|
217
|
-
organizationId: snapshot.message.organizationId,
|
|
218
|
-
deletedAt: toDate(snapshot.message.deletedAt),
|
|
219
|
-
})
|
|
220
|
-
em.persist(created)
|
|
221
|
-
} else {
|
|
222
|
-
existingMessage.type = snapshot.message.type
|
|
223
|
-
existingMessage.visibility = snapshot.message.visibility
|
|
224
|
-
existingMessage.sourceEntityType = snapshot.message.sourceEntityType
|
|
225
|
-
existingMessage.sourceEntityId = snapshot.message.sourceEntityId
|
|
226
|
-
existingMessage.externalEmail = snapshot.message.externalEmail
|
|
227
|
-
existingMessage.externalName = snapshot.message.externalName
|
|
228
|
-
existingMessage.threadId = snapshot.message.threadId
|
|
229
|
-
existingMessage.parentMessageId = snapshot.message.parentMessageId
|
|
230
|
-
existingMessage.senderUserId = snapshot.message.senderUserId
|
|
231
|
-
existingMessage.subject = snapshot.message.subject
|
|
232
|
-
existingMessage.body = snapshot.message.body
|
|
233
|
-
existingMessage.bodyFormat = snapshot.message.bodyFormat
|
|
234
|
-
existingMessage.priority = snapshot.message.priority
|
|
235
|
-
existingMessage.status = snapshot.message.status
|
|
236
|
-
existingMessage.isDraft = snapshot.message.isDraft
|
|
237
|
-
existingMessage.sentAt = toDate(snapshot.message.sentAt)
|
|
238
|
-
existingMessage.actionData = snapshot.message.actionData as MessageActionData
|
|
239
|
-
existingMessage.actionResult = snapshot.message.actionResult
|
|
240
|
-
existingMessage.actionTaken = snapshot.message.actionTaken
|
|
241
|
-
existingMessage.actionTakenByUserId = snapshot.message.actionTakenByUserId
|
|
242
|
-
existingMessage.actionTakenAt = toDate(snapshot.message.actionTakenAt)
|
|
243
|
-
existingMessage.sendViaEmail = snapshot.message.sendViaEmail
|
|
244
|
-
existingMessage.tenantId = snapshot.message.tenantId
|
|
245
|
-
existingMessage.organizationId = snapshot.message.organizationId
|
|
246
|
-
existingMessage.deletedAt = toDate(snapshot.message.deletedAt)
|
|
247
|
-
}
|
|
191
|
+
await withAtomicFlush(em, [async () => {
|
|
192
|
+
// Resolve every read before mutating: a query issued between a scalar
|
|
193
|
+
// mutation and the flush can silently reset the Unit of Work (SPEC-018
|
|
194
|
+
// Problem 1). withAtomicFlush flushes once at the end, so ordering is ours.
|
|
195
|
+
const { Attachment } = await import('@open-mercato/core/modules/attachments/data/entities')
|
|
196
|
+
const existingMessage = await em.findOne(Message, { id: snapshot.message.id })
|
|
197
|
+
const existingRecipients = await em.find(MessageRecipient, { messageId: snapshot.message.id })
|
|
198
|
+
const existingObjects = await em.find(MessageObject, { messageId: snapshot.message.id })
|
|
199
|
+
const attachmentsToRelink = snapshot.attachmentIds.length > 0
|
|
200
|
+
? await em.find(Attachment, {
|
|
201
|
+
id: { $in: snapshot.attachmentIds },
|
|
202
|
+
tenantId: snapshot.message.tenantId,
|
|
203
|
+
organizationId: snapshot.message.organizationId,
|
|
204
|
+
})
|
|
205
|
+
: []
|
|
248
206
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
207
|
+
if (!existingMessage) {
|
|
208
|
+
const created = em.create(Message, {
|
|
209
|
+
id: snapshot.message.id,
|
|
210
|
+
type: snapshot.message.type,
|
|
211
|
+
visibility: snapshot.message.visibility,
|
|
212
|
+
sourceEntityType: snapshot.message.sourceEntityType,
|
|
213
|
+
sourceEntityId: snapshot.message.sourceEntityId,
|
|
214
|
+
externalEmail: snapshot.message.externalEmail,
|
|
215
|
+
externalName: snapshot.message.externalName,
|
|
216
|
+
threadId: snapshot.message.threadId,
|
|
217
|
+
parentMessageId: snapshot.message.parentMessageId,
|
|
218
|
+
senderUserId: snapshot.message.senderUserId,
|
|
219
|
+
subject: snapshot.message.subject,
|
|
220
|
+
body: snapshot.message.body,
|
|
221
|
+
bodyFormat: snapshot.message.bodyFormat,
|
|
222
|
+
priority: snapshot.message.priority,
|
|
223
|
+
status: snapshot.message.status,
|
|
224
|
+
isDraft: snapshot.message.isDraft,
|
|
225
|
+
sentAt: toDate(snapshot.message.sentAt),
|
|
226
|
+
actionData: snapshot.message.actionData as MessageActionData,
|
|
227
|
+
actionResult: snapshot.message.actionResult,
|
|
228
|
+
actionTaken: snapshot.message.actionTaken,
|
|
229
|
+
actionTakenByUserId: snapshot.message.actionTakenByUserId,
|
|
230
|
+
actionTakenAt: toDate(snapshot.message.actionTakenAt),
|
|
231
|
+
sendViaEmail: snapshot.message.sendViaEmail,
|
|
232
|
+
tenantId: snapshot.message.tenantId,
|
|
233
|
+
organizationId: snapshot.message.organizationId,
|
|
234
|
+
deletedAt: toDate(snapshot.message.deletedAt),
|
|
235
|
+
})
|
|
236
|
+
em.persist(created)
|
|
237
|
+
} else {
|
|
238
|
+
existingMessage.type = snapshot.message.type
|
|
239
|
+
existingMessage.visibility = snapshot.message.visibility
|
|
240
|
+
existingMessage.sourceEntityType = snapshot.message.sourceEntityType
|
|
241
|
+
existingMessage.sourceEntityId = snapshot.message.sourceEntityId
|
|
242
|
+
existingMessage.externalEmail = snapshot.message.externalEmail
|
|
243
|
+
existingMessage.externalName = snapshot.message.externalName
|
|
244
|
+
existingMessage.threadId = snapshot.message.threadId
|
|
245
|
+
existingMessage.parentMessageId = snapshot.message.parentMessageId
|
|
246
|
+
existingMessage.senderUserId = snapshot.message.senderUserId
|
|
247
|
+
existingMessage.subject = snapshot.message.subject
|
|
248
|
+
existingMessage.body = snapshot.message.body
|
|
249
|
+
existingMessage.bodyFormat = snapshot.message.bodyFormat
|
|
250
|
+
existingMessage.priority = snapshot.message.priority
|
|
251
|
+
existingMessage.status = snapshot.message.status
|
|
252
|
+
existingMessage.isDraft = snapshot.message.isDraft
|
|
253
|
+
existingMessage.sentAt = toDate(snapshot.message.sentAt)
|
|
254
|
+
existingMessage.actionData = snapshot.message.actionData as MessageActionData
|
|
255
|
+
existingMessage.actionResult = snapshot.message.actionResult
|
|
256
|
+
existingMessage.actionTaken = snapshot.message.actionTaken
|
|
257
|
+
existingMessage.actionTakenByUserId = snapshot.message.actionTakenByUserId
|
|
258
|
+
existingMessage.actionTakenAt = toDate(snapshot.message.actionTakenAt)
|
|
259
|
+
existingMessage.sendViaEmail = snapshot.message.sendViaEmail
|
|
260
|
+
existingMessage.tenantId = snapshot.message.tenantId
|
|
261
|
+
existingMessage.organizationId = snapshot.message.organizationId
|
|
262
|
+
existingMessage.deletedAt = toDate(snapshot.message.deletedAt)
|
|
255
263
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
264
|
+
|
|
265
|
+
const recipientById = new Map(existingRecipients.map((item) => [item.id, item]))
|
|
266
|
+
const snapshotRecipientIds = new Set(snapshot.recipients.map((item) => item.id))
|
|
267
|
+
for (const current of existingRecipients) {
|
|
268
|
+
if (!snapshotRecipientIds.has(current.id)) {
|
|
269
|
+
em.remove(current)
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
for (const recipient of snapshot.recipients) {
|
|
273
|
+
const existing = recipientById.get(recipient.id)
|
|
274
|
+
if (!existing) {
|
|
275
|
+
em.persist(em.create(MessageRecipient, {
|
|
276
|
+
id: recipient.id,
|
|
277
|
+
messageId: recipient.messageId,
|
|
278
|
+
recipientUserId: recipient.recipientUserId,
|
|
279
|
+
recipientType: recipient.recipientType,
|
|
280
|
+
status: recipient.status,
|
|
281
|
+
readAt: toDate(recipient.readAt),
|
|
282
|
+
archivedAt: toDate(recipient.archivedAt),
|
|
283
|
+
deletedAt: toDate(recipient.deletedAt),
|
|
284
|
+
}))
|
|
285
|
+
continue
|
|
286
|
+
}
|
|
287
|
+
existing.messageId = recipient.messageId
|
|
288
|
+
existing.recipientUserId = recipient.recipientUserId
|
|
289
|
+
existing.recipientType = recipient.recipientType
|
|
290
|
+
existing.status = recipient.status
|
|
291
|
+
existing.readAt = toDate(recipient.readAt)
|
|
292
|
+
existing.archivedAt = toDate(recipient.archivedAt)
|
|
293
|
+
existing.deletedAt = toDate(recipient.deletedAt)
|
|
271
294
|
}
|
|
272
|
-
existing.messageId = recipient.messageId
|
|
273
|
-
existing.recipientUserId = recipient.recipientUserId
|
|
274
|
-
existing.recipientType = recipient.recipientType
|
|
275
|
-
existing.status = recipient.status
|
|
276
|
-
existing.readAt = toDate(recipient.readAt)
|
|
277
|
-
existing.archivedAt = toDate(recipient.archivedAt)
|
|
278
|
-
existing.deletedAt = toDate(recipient.deletedAt)
|
|
279
|
-
}
|
|
280
295
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
296
|
+
const objectById = new Map(existingObjects.map((item) => [item.id, item]))
|
|
297
|
+
const snapshotObjectIds = new Set(snapshot.objects.map((item) => item.id))
|
|
298
|
+
for (const current of existingObjects) {
|
|
299
|
+
if (!snapshotObjectIds.has(current.id)) {
|
|
300
|
+
em.remove(current)
|
|
301
|
+
}
|
|
287
302
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
303
|
+
for (const object of snapshot.objects) {
|
|
304
|
+
const existing = objectById.get(object.id)
|
|
305
|
+
if (!existing) {
|
|
306
|
+
em.persist(em.create(MessageObject, {
|
|
307
|
+
id: object.id,
|
|
308
|
+
messageId: object.messageId,
|
|
309
|
+
entityModule: object.entityModule,
|
|
310
|
+
entityType: object.entityType,
|
|
311
|
+
entityId: object.entityId,
|
|
312
|
+
actionRequired: object.actionRequired,
|
|
313
|
+
actionType: object.actionType,
|
|
314
|
+
actionLabel: object.actionLabel,
|
|
315
|
+
entitySnapshot: object.entitySnapshot,
|
|
316
|
+
}))
|
|
317
|
+
continue
|
|
318
|
+
}
|
|
319
|
+
existing.messageId = object.messageId
|
|
320
|
+
existing.entityModule = object.entityModule
|
|
321
|
+
existing.entityType = object.entityType
|
|
322
|
+
existing.entityId = object.entityId
|
|
323
|
+
existing.actionRequired = object.actionRequired
|
|
324
|
+
existing.actionType = object.actionType
|
|
325
|
+
existing.actionLabel = object.actionLabel
|
|
326
|
+
existing.entitySnapshot = object.entitySnapshot
|
|
304
327
|
}
|
|
305
|
-
existing.messageId = object.messageId
|
|
306
|
-
existing.entityModule = object.entityModule
|
|
307
|
-
existing.entityType = object.entityType
|
|
308
|
-
existing.entityId = object.entityId
|
|
309
|
-
existing.actionRequired = object.actionRequired
|
|
310
|
-
existing.actionType = object.actionType
|
|
311
|
-
existing.actionLabel = object.actionLabel
|
|
312
|
-
existing.entitySnapshot = object.entitySnapshot
|
|
313
|
-
}
|
|
314
328
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
recordId: snapshot.message.id,
|
|
319
|
-
tenantId: snapshot.message.tenantId,
|
|
320
|
-
organizationId: snapshot.message.organizationId,
|
|
321
|
-
id: { $nin: snapshot.attachmentIds.length > 0 ? snapshot.attachmentIds : ['00000000-0000-0000-0000-000000000000'] },
|
|
322
|
-
})
|
|
323
|
-
if (snapshot.attachmentIds.length > 0) {
|
|
324
|
-
const attachments = await em.find(Attachment, {
|
|
325
|
-
id: { $in: snapshot.attachmentIds },
|
|
329
|
+
await em.nativeDelete(Attachment, {
|
|
330
|
+
entityId: MESSAGE_ATTACHMENT_ENTITY_ID,
|
|
331
|
+
recordId: snapshot.message.id,
|
|
326
332
|
tenantId: snapshot.message.tenantId,
|
|
327
333
|
organizationId: snapshot.message.organizationId,
|
|
334
|
+
id: { $nin: snapshot.attachmentIds.length > 0 ? snapshot.attachmentIds : ['00000000-0000-0000-0000-000000000000'] },
|
|
328
335
|
})
|
|
329
|
-
for (const attachment of
|
|
336
|
+
for (const attachment of attachmentsToRelink) {
|
|
330
337
|
attachment.entityId = MESSAGE_ATTACHMENT_ENTITY_ID
|
|
331
338
|
attachment.recordId = snapshot.message.id
|
|
332
339
|
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
await em.flush()
|
|
340
|
+
}], { transaction: true })
|
|
336
341
|
}
|
|
337
342
|
|
|
338
343
|
export function buildCommandLogBase(
|
|
@@ -2,6 +2,7 @@ import { NextResponse } from 'next/server'
|
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
4
4
|
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
5
|
+
import { withAtomicFlush } from '@open-mercato/shared/lib/commands/flush'
|
|
5
6
|
import { perspectiveSaveSchema } from '@open-mercato/core/modules/perspectives/data/validators'
|
|
6
7
|
import {
|
|
7
8
|
loadPerspectivesState,
|
|
@@ -162,17 +163,12 @@ export async function POST(req: Request, ctx: { params: { tableId: string } }) {
|
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
const scope = buildScope(auth)
|
|
165
|
-
const saved = await saveUserPerspective(em, cache, {
|
|
166
|
-
scope,
|
|
167
|
-
tableId,
|
|
168
|
-
input: parsed.data,
|
|
169
|
-
})
|
|
170
166
|
|
|
171
167
|
const applyToRoles = Array.from(new Set(parsed.data.applyToRoles ?? [])).filter((id) => id.trim().length > 0)
|
|
172
168
|
const clearRoleIds = Array.from(new Set(parsed.data.clearRoleIds ?? [])).filter((id) => id.trim().length > 0)
|
|
173
|
-
|
|
169
|
+
const hasRoleOps = applyToRoles.length > 0 || clearRoleIds.length > 0
|
|
174
170
|
|
|
175
|
-
if (
|
|
171
|
+
if (hasRoleOps) {
|
|
176
172
|
const canApplyToRoles = await rbac.userHasAllFeatures?.(
|
|
177
173
|
auth.sub,
|
|
178
174
|
['perspectives.role_defaults'],
|
|
@@ -198,30 +194,45 @@ export async function POST(req: Request, ctx: { params: { tableId: string } }) {
|
|
|
198
194
|
if (missing.length) {
|
|
199
195
|
return NextResponse.json({ error: 'Invalid roles', missing }, { status: 400 })
|
|
200
196
|
}
|
|
197
|
+
}
|
|
201
198
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
tableId,
|
|
205
|
-
tenantId: auth.tenantId ?? null,
|
|
206
|
-
organizationId: auth.orgId ?? null,
|
|
207
|
-
input: {
|
|
208
|
-
roleIds: applyToRoles,
|
|
209
|
-
name: parsed.data.name,
|
|
210
|
-
settings: parsed.data.settings,
|
|
211
|
-
setDefault: parsed.data.setRoleDefault ?? false,
|
|
212
|
-
},
|
|
213
|
-
})
|
|
214
|
-
}
|
|
199
|
+
let saved: Awaited<ReturnType<typeof saveUserPerspective>> | null = null
|
|
200
|
+
let updatedRolePerspectives: Awaited<ReturnType<typeof saveRolePerspectives>> | null = null
|
|
215
201
|
|
|
216
|
-
|
|
217
|
-
|
|
202
|
+
await withAtomicFlush(em, [
|
|
203
|
+
async () => {
|
|
204
|
+
saved = await saveUserPerspective(em, cache, {
|
|
205
|
+
scope,
|
|
218
206
|
tableId,
|
|
219
|
-
|
|
220
|
-
organizationId: auth.orgId ?? null,
|
|
221
|
-
roleIds: clearRoleIds,
|
|
207
|
+
input: parsed.data,
|
|
222
208
|
})
|
|
223
|
-
}
|
|
224
|
-
|
|
209
|
+
},
|
|
210
|
+
async () => {
|
|
211
|
+
if (applyToRoles.length) {
|
|
212
|
+
updatedRolePerspectives = await saveRolePerspectives(em, cache, {
|
|
213
|
+
tableId,
|
|
214
|
+
tenantId: auth.tenantId ?? null,
|
|
215
|
+
organizationId: auth.orgId ?? null,
|
|
216
|
+
input: {
|
|
217
|
+
roleIds: applyToRoles,
|
|
218
|
+
name: parsed.data.name,
|
|
219
|
+
settings: parsed.data.settings,
|
|
220
|
+
setDefault: parsed.data.setRoleDefault ?? false,
|
|
221
|
+
},
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
async () => {
|
|
226
|
+
if (clearRoleIds.length) {
|
|
227
|
+
await clearRolePerspectives(em, cache, {
|
|
228
|
+
tableId,
|
|
229
|
+
tenantId: auth.tenantId ?? null,
|
|
230
|
+
organizationId: auth.orgId ?? null,
|
|
231
|
+
roleIds: clearRoleIds,
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
], { transaction: true })
|
|
225
236
|
|
|
226
237
|
return NextResponse.json({
|
|
227
238
|
perspective: saved,
|