@open-mercato/core 0.6.4-develop.4210.1.d412061cfe → 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
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
diffCustomFieldChanges,
|
|
16
16
|
} from '@open-mercato/shared/lib/commands/customFieldSnapshots'
|
|
17
17
|
import { extractUndoPayload } from '@open-mercato/shared/lib/commands/undo'
|
|
18
|
+
import { withAtomicFlush } from '@open-mercato/shared/lib/commands/flush'
|
|
18
19
|
import {
|
|
19
20
|
parseWithCustomFields,
|
|
20
21
|
setCustomFieldsIfAny,
|
|
@@ -291,36 +292,43 @@ const createOrganizationCommand: CommandHandler<Record<string, unknown>, Organiz
|
|
|
291
292
|
const baseSlug = parsed.slug ? parsed.slug : slugify(parsed.name)
|
|
292
293
|
const slug = baseSlug ? await resolveUniqueSlug(em, tenantId, baseSlug) : null
|
|
293
294
|
const de = (ctx.container.resolve('dataEngine') as DataEngine)
|
|
294
|
-
const organization = await de.createOrmEntity({
|
|
295
|
-
entity: Organization,
|
|
296
|
-
data: {
|
|
297
|
-
tenant: tenantRef,
|
|
298
|
-
name: parsed.name,
|
|
299
|
-
slug,
|
|
300
|
-
isActive: parsed.isActive ?? true,
|
|
301
|
-
parentId,
|
|
302
|
-
},
|
|
303
|
-
})
|
|
304
|
-
setInternalTenantId(organization, tenantId)
|
|
305
|
-
const recordId = String(organization.id)
|
|
306
295
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
296
|
+
let organization!: Organization
|
|
297
|
+
await withAtomicFlush(em, [
|
|
298
|
+
async () => {
|
|
299
|
+
organization = await de.createOrmEntity({
|
|
300
|
+
entity: Organization,
|
|
301
|
+
data: {
|
|
302
|
+
tenant: tenantRef,
|
|
303
|
+
name: parsed.name,
|
|
304
|
+
slug,
|
|
305
|
+
isActive: parsed.isActive ?? true,
|
|
306
|
+
parentId,
|
|
307
|
+
},
|
|
308
|
+
})
|
|
309
|
+
setInternalTenantId(organization, tenantId)
|
|
310
|
+
const recordId = String(organization.id)
|
|
312
311
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
312
|
+
if (childIds.length) {
|
|
313
|
+
await assignChildren(em, tenantId, recordId, childIds)
|
|
314
|
+
}
|
|
315
|
+
const childParentsAfter = await loadChildParentSnapshots(em, tenantId, childIds)
|
|
316
|
+
setUndoMeta(organization, { childParentsBefore, childParentsAfter })
|
|
317
|
+
|
|
318
|
+
await setCustomFieldsIfAny({
|
|
319
|
+
dataEngine: de,
|
|
320
|
+
entityId: E.directory.organization,
|
|
321
|
+
recordId,
|
|
322
|
+
tenantId,
|
|
323
|
+
organizationId: recordId,
|
|
324
|
+
values: custom,
|
|
325
|
+
})
|
|
321
326
|
|
|
322
|
-
|
|
327
|
+
await rebuildHierarchyForTenant(em, tenantId)
|
|
328
|
+
},
|
|
329
|
+
], { transaction: true })
|
|
323
330
|
|
|
331
|
+
const recordId = String(organization.id)
|
|
324
332
|
const identifiers = { id: recordId, organizationId: recordId, tenantId }
|
|
325
333
|
await emitCrudSideEffects({
|
|
326
334
|
dataEngine: de,
|
|
@@ -379,27 +387,31 @@ const createOrganizationCommand: CommandHandler<Record<string, unknown>, Organiz
|
|
|
379
387
|
if (!tenantId) return
|
|
380
388
|
const em = (ctx.container.resolve('em') as EntityManager)
|
|
381
389
|
const de = (ctx.container.resolve('dataEngine') as DataEngine)
|
|
382
|
-
await
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
390
|
+
await withAtomicFlush(em, [
|
|
391
|
+
async () => {
|
|
392
|
+
await restoreChildParents(em, tenantId, childrenBefore)
|
|
393
|
+
if (after.custom && Object.keys(after.custom).length) {
|
|
394
|
+
const reset = buildCustomFieldResetMap(undefined, after.custom)
|
|
395
|
+
if (Object.keys(reset).length) {
|
|
396
|
+
const resetValues = reset as Parameters<DataEngine['setCustomFields']>[0]['values']
|
|
397
|
+
await de.setCustomFields({
|
|
398
|
+
entityId: E.directory.organization,
|
|
399
|
+
recordId: after.id,
|
|
400
|
+
tenantId,
|
|
401
|
+
organizationId: after.id,
|
|
402
|
+
values: resetValues,
|
|
403
|
+
notify: false,
|
|
404
|
+
})
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
await de.deleteOrmEntity({
|
|
408
|
+
entity: Organization,
|
|
409
|
+
where: { id: after.id, deletedAt: null } as FilterQuery<Organization>,
|
|
410
|
+
soft: false,
|
|
394
411
|
})
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
entity: Organization,
|
|
399
|
-
where: { id: after.id, deletedAt: null } as FilterQuery<Organization>,
|
|
400
|
-
soft: false,
|
|
401
|
-
})
|
|
402
|
-
await rebuildHierarchyForTenant(em, tenantId)
|
|
412
|
+
await rebuildHierarchyForTenant(em, tenantId)
|
|
413
|
+
},
|
|
414
|
+
], { transaction: true })
|
|
403
415
|
},
|
|
404
416
|
}
|
|
405
417
|
|
|
@@ -475,48 +487,56 @@ const updateOrganizationCommand: CommandHandler<Record<string, unknown>, Organiz
|
|
|
475
487
|
resolvedSlug = parsed.slug ? await resolveUniqueSlug(em, tenantId, parsed.slug, parsed.id) : parsed.slug
|
|
476
488
|
}
|
|
477
489
|
const de = (ctx.container.resolve('dataEngine') as DataEngine)
|
|
478
|
-
const organization = await de.updateOrmEntity({
|
|
479
|
-
entity: Organization,
|
|
480
|
-
where: { id: parsed.id, deletedAt: null } as FilterQuery<Organization>,
|
|
481
|
-
apply: (entity) => {
|
|
482
|
-
if (parsed.name !== undefined) entity.name = parsed.name
|
|
483
|
-
if (resolvedSlug !== undefined) entity.slug = resolvedSlug
|
|
484
|
-
if (parsed.isActive !== undefined) entity.isActive = parsed.isActive
|
|
485
|
-
entity.parentId = parentId
|
|
486
|
-
},
|
|
487
|
-
})
|
|
488
|
-
if (!organization) throw new CrudHttpError(404, { error: 'Not found' })
|
|
489
|
-
setInternalTenantId(organization, tenantId)
|
|
490
|
-
|
|
491
|
-
const recordId = String(organization.id)
|
|
492
|
-
const desiredChildIds = new Set(normalizedChildIds.filter((id) => id !== recordId))
|
|
493
|
-
await clearRemovedChildren(em, tenantId, recordId, desiredChildIds)
|
|
494
|
-
await assignChildren(em, tenantId, recordId, desiredChildIds)
|
|
495
|
-
const childParentsAfter = await loadChildParentSnapshots(em, tenantId, combinedChildIds)
|
|
496
|
-
setUndoMeta(organization, { childParentsBefore, childParentsAfter })
|
|
497
490
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
491
|
+
let resolvedOrganization!: Organization
|
|
492
|
+
await withAtomicFlush(em, [
|
|
493
|
+
async () => {
|
|
494
|
+
const organization = await de.updateOrmEntity({
|
|
495
|
+
entity: Organization,
|
|
496
|
+
where: { id: parsed.id, deletedAt: null } as FilterQuery<Organization>,
|
|
497
|
+
apply: (entity) => {
|
|
498
|
+
if (parsed.name !== undefined) entity.name = parsed.name
|
|
499
|
+
if (resolvedSlug !== undefined) entity.slug = resolvedSlug
|
|
500
|
+
if (parsed.isActive !== undefined) entity.isActive = parsed.isActive
|
|
501
|
+
entity.parentId = parentId
|
|
502
|
+
},
|
|
503
|
+
})
|
|
504
|
+
if (!organization) throw new CrudHttpError(404, { error: 'Not found' })
|
|
505
|
+
setInternalTenantId(organization, tenantId)
|
|
506
|
+
|
|
507
|
+
const recordId = String(organization.id)
|
|
508
|
+
const desiredChildIds = new Set(normalizedChildIds.filter((id) => id !== recordId))
|
|
509
|
+
await clearRemovedChildren(em, tenantId, recordId, desiredChildIds)
|
|
510
|
+
await assignChildren(em, tenantId, recordId, desiredChildIds)
|
|
511
|
+
const childParentsAfter = await loadChildParentSnapshots(em, tenantId, combinedChildIds)
|
|
512
|
+
setUndoMeta(organization, { childParentsBefore, childParentsAfter })
|
|
513
|
+
|
|
514
|
+
await setCustomFieldsIfAny({
|
|
515
|
+
dataEngine: de,
|
|
516
|
+
entityId: E.directory.organization,
|
|
517
|
+
recordId,
|
|
518
|
+
tenantId,
|
|
519
|
+
organizationId: recordId,
|
|
520
|
+
values: custom,
|
|
521
|
+
})
|
|
506
522
|
|
|
507
|
-
|
|
523
|
+
await rebuildHierarchyForTenant(em, tenantId)
|
|
524
|
+
resolvedOrganization = organization
|
|
525
|
+
},
|
|
526
|
+
], { transaction: true })
|
|
508
527
|
|
|
528
|
+
const recordId = String(resolvedOrganization.id)
|
|
509
529
|
const identifiers = { id: recordId, organizationId: recordId, tenantId }
|
|
510
530
|
await emitCrudSideEffects({
|
|
511
531
|
dataEngine: de,
|
|
512
532
|
action: 'updated',
|
|
513
|
-
entity:
|
|
533
|
+
entity: resolvedOrganization,
|
|
514
534
|
identifiers,
|
|
515
535
|
events: organizationCrudEvents,
|
|
516
536
|
indexer: organizationCrudIndexer,
|
|
517
537
|
})
|
|
518
538
|
|
|
519
|
-
return
|
|
539
|
+
return resolvedOrganization
|
|
520
540
|
},
|
|
521
541
|
captureAfter: async (_input, result, ctx) => {
|
|
522
542
|
const em = (ctx.container.resolve('em') as EntityManager).fork()
|
|
@@ -571,34 +591,39 @@ const updateOrganizationCommand: CommandHandler<Record<string, unknown>, Organiz
|
|
|
571
591
|
if (!tenantId) return
|
|
572
592
|
const em = (ctx.container.resolve('em') as EntityManager)
|
|
573
593
|
const de = (ctx.container.resolve('dataEngine') as DataEngine)
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
594
|
+
let updated: Organization | null = null
|
|
595
|
+
await withAtomicFlush(em, [
|
|
596
|
+
async () => {
|
|
597
|
+
updated = await de.updateOrmEntity({
|
|
598
|
+
entity: Organization,
|
|
599
|
+
where: { id: before.id } as FilterQuery<Organization>,
|
|
600
|
+
apply: (entity) => {
|
|
601
|
+
entity.name = before.name
|
|
602
|
+
if (before.slug !== undefined) entity.slug = before.slug
|
|
603
|
+
entity.isActive = before.isActive
|
|
604
|
+
entity.parentId = before.parentId
|
|
605
|
+
},
|
|
606
|
+
})
|
|
607
|
+
if (updated && tenantId) {
|
|
608
|
+
setInternalTenantId(updated, tenantId)
|
|
609
|
+
}
|
|
610
|
+
const reset = buildCustomFieldResetMap(before.custom, after?.custom)
|
|
611
|
+
if (Object.keys(reset).length) {
|
|
612
|
+
const resetValues = reset as Parameters<DataEngine['setCustomFields']>[0]['values']
|
|
613
|
+
await de.setCustomFields({
|
|
614
|
+
entityId: E.directory.organization,
|
|
615
|
+
recordId: before.id,
|
|
616
|
+
tenantId,
|
|
617
|
+
organizationId: before.id,
|
|
618
|
+
values: resetValues,
|
|
619
|
+
notify: false,
|
|
620
|
+
})
|
|
621
|
+
}
|
|
622
|
+
const childSnapshots = before.childParents
|
|
623
|
+
await restoreChildParents(em, tenantId, childSnapshots)
|
|
624
|
+
await rebuildHierarchyForTenant(em, tenantId)
|
|
582
625
|
},
|
|
583
|
-
})
|
|
584
|
-
if (updated && tenantId) {
|
|
585
|
-
setInternalTenantId(updated, tenantId)
|
|
586
|
-
}
|
|
587
|
-
const reset = buildCustomFieldResetMap(before.custom, after?.custom)
|
|
588
|
-
if (Object.keys(reset).length) {
|
|
589
|
-
const resetValues = reset as Parameters<DataEngine['setCustomFields']>[0]['values']
|
|
590
|
-
await de.setCustomFields({
|
|
591
|
-
entityId: E.directory.organization,
|
|
592
|
-
recordId: before.id,
|
|
593
|
-
tenantId,
|
|
594
|
-
organizationId: before.id,
|
|
595
|
-
values: resetValues,
|
|
596
|
-
notify: false,
|
|
597
|
-
})
|
|
598
|
-
}
|
|
599
|
-
const childSnapshots = before.childParents
|
|
600
|
-
await restoreChildParents(em, tenantId, childSnapshots)
|
|
601
|
-
await rebuildHierarchyForTenant(em, tenantId)
|
|
626
|
+
], { transaction: true })
|
|
602
627
|
await emitCrudUndoSideEffects({
|
|
603
628
|
dataEngine: de,
|
|
604
629
|
action: 'updated',
|
|
@@ -650,41 +675,48 @@ const deleteOrganizationCommand: CommandHandler<{ body: any; query: Record<strin
|
|
|
650
675
|
)
|
|
651
676
|
|
|
652
677
|
const de = (ctx.container.resolve('dataEngine') as DataEngine)
|
|
653
|
-
const deleted = await de.deleteOrmEntity({
|
|
654
|
-
entity: Organization,
|
|
655
|
-
where: { id, deletedAt: null } as FilterQuery<Organization>,
|
|
656
|
-
soft: true,
|
|
657
|
-
softDeleteField: 'deletedAt',
|
|
658
|
-
})
|
|
659
|
-
if (!deleted) throw new CrudHttpError(404, { error: 'Not found' })
|
|
660
|
-
setInternalTenantId(deleted, tenantId)
|
|
661
|
-
deleted.isActive = false
|
|
662
|
-
deleted.parentId = null
|
|
663
|
-
|
|
664
|
-
const childrenFilter: FilterQuery<Organization> = { tenant: tenantId, parentId: id, deletedAt: null }
|
|
665
|
-
const children = await em.find(Organization, childrenFilter)
|
|
666
|
-
const toPersist: Organization[] = []
|
|
667
|
-
for (const child of children) {
|
|
668
|
-
child.parentId = parentId
|
|
669
|
-
toPersist.push(child)
|
|
670
|
-
}
|
|
671
|
-
toPersist.push(deleted)
|
|
672
|
-
if (toPersist.length) await em.persist(toPersist).flush()
|
|
673
|
-
setUndoMeta(deleted, { childParentsBefore: childSnapshotsBefore })
|
|
674
678
|
|
|
675
|
-
|
|
679
|
+
let resolvedDeleted!: Organization
|
|
680
|
+
await withAtomicFlush(em, [
|
|
681
|
+
async () => {
|
|
682
|
+
const deleted = await de.deleteOrmEntity({
|
|
683
|
+
entity: Organization,
|
|
684
|
+
where: { id, deletedAt: null } as FilterQuery<Organization>,
|
|
685
|
+
soft: true,
|
|
686
|
+
softDeleteField: 'deletedAt',
|
|
687
|
+
})
|
|
688
|
+
if (!deleted) throw new CrudHttpError(404, { error: 'Not found' })
|
|
689
|
+
setInternalTenantId(deleted, tenantId)
|
|
690
|
+
deleted.isActive = false
|
|
691
|
+
deleted.parentId = null
|
|
692
|
+
|
|
693
|
+
const childrenFilter: FilterQuery<Organization> = { tenant: tenantId, parentId: id, deletedAt: null }
|
|
694
|
+
const children = await em.find(Organization, childrenFilter)
|
|
695
|
+
const toPersist: Organization[] = []
|
|
696
|
+
for (const child of children) {
|
|
697
|
+
child.parentId = parentId
|
|
698
|
+
toPersist.push(child)
|
|
699
|
+
}
|
|
700
|
+
toPersist.push(deleted)
|
|
701
|
+
if (toPersist.length) await em.persist(toPersist).flush()
|
|
702
|
+
setUndoMeta(deleted, { childParentsBefore: childSnapshotsBefore })
|
|
703
|
+
|
|
704
|
+
await rebuildHierarchyForTenant(em, tenantId)
|
|
705
|
+
resolvedDeleted = deleted
|
|
706
|
+
},
|
|
707
|
+
], { transaction: true })
|
|
676
708
|
|
|
677
709
|
const identifiers = { id, organizationId: id, tenantId }
|
|
678
710
|
await emitCrudSideEffects({
|
|
679
711
|
dataEngine: de,
|
|
680
712
|
action: 'deleted',
|
|
681
|
-
entity:
|
|
713
|
+
entity: resolvedDeleted,
|
|
682
714
|
identifiers,
|
|
683
715
|
events: organizationCrudEvents,
|
|
684
716
|
indexer: organizationCrudIndexer,
|
|
685
717
|
})
|
|
686
718
|
|
|
687
|
-
return
|
|
719
|
+
return resolvedDeleted
|
|
688
720
|
},
|
|
689
721
|
buildLog: async ({ snapshots, input, ctx }) => {
|
|
690
722
|
const { translate } = await resolveTranslations()
|
|
@@ -715,45 +747,50 @@ const deleteOrganizationCommand: CommandHandler<{ body: any; query: Record<strin
|
|
|
715
747
|
if (!tenantId) return
|
|
716
748
|
const em = (ctx.container.resolve('em') as EntityManager)
|
|
717
749
|
const de = (ctx.container.resolve('dataEngine') as DataEngine)
|
|
718
|
-
let organization
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
750
|
+
let organization: Organization | null = null
|
|
751
|
+
await withAtomicFlush(em, [
|
|
752
|
+
async () => {
|
|
753
|
+
organization = await em.findOne(Organization, { id: before.id })
|
|
754
|
+
if (organization) {
|
|
755
|
+
organization.deletedAt = null
|
|
756
|
+
organization.isActive = before.isActive
|
|
757
|
+
organization.name = before.name
|
|
758
|
+
if (before.slug !== undefined) organization.slug = before.slug
|
|
759
|
+
organization.parentId = before.parentId
|
|
760
|
+
await em.flush()
|
|
761
|
+
if (tenantId) setInternalTenantId(organization, tenantId)
|
|
762
|
+
} else {
|
|
763
|
+
organization = await de.createOrmEntity({
|
|
764
|
+
entity: Organization,
|
|
765
|
+
data: {
|
|
766
|
+
id: before.id,
|
|
767
|
+
name: before.name,
|
|
768
|
+
slug: before.slug ?? null,
|
|
769
|
+
tenant: tenantId ? em.getReference(Tenant, tenantId) : undefined,
|
|
770
|
+
isActive: before.isActive,
|
|
771
|
+
parentId: before.parentId,
|
|
772
|
+
},
|
|
773
|
+
})
|
|
774
|
+
if (tenantId) setInternalTenantId(organization, tenantId)
|
|
775
|
+
}
|
|
776
|
+
if (tenantId) {
|
|
777
|
+
const customValues = buildCustomFieldResetMap(before.custom, undefined)
|
|
778
|
+
if (Object.keys(customValues).length) {
|
|
779
|
+
const resetValues = customValues as Parameters<DataEngine['setCustomFields']>[0]['values']
|
|
780
|
+
await de.setCustomFields({
|
|
781
|
+
entityId: E.directory.organization,
|
|
782
|
+
recordId: before.id,
|
|
783
|
+
tenantId,
|
|
784
|
+
organizationId: before.id,
|
|
785
|
+
values: resetValues,
|
|
786
|
+
notify: false,
|
|
787
|
+
})
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
await restoreChildParents(em, tenantId, before.childParents)
|
|
791
|
+
await rebuildHierarchyForTenant(em, tenantId)
|
|
792
|
+
},
|
|
793
|
+
], { transaction: true })
|
|
757
794
|
await emitCrudUndoSideEffects({
|
|
758
795
|
dataEngine: de,
|
|
759
796
|
action: 'updated',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
3
3
|
import { findOneWithDecryption, findWithDecryption } from '@open-mercato/shared/lib/encryption/find'
|
|
4
|
+
import { withAtomicFlush } from '@open-mercato/shared/lib/commands/flush'
|
|
4
5
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
5
6
|
import { InboxDiscrepancy, InboxEmail, InboxProposal, InboxProposalAction } from '../../../../data/entities'
|
|
6
7
|
import { emitInboxOpsEvent } from '../../../../events'
|
|
@@ -48,11 +49,16 @@ export async function POST(req: Request) {
|
|
|
48
49
|
return NextResponse.json({ error: 'Email is already queued for processing' }, { status: 409 })
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
let retiredCounts = { retiredProposalCount: 0, retiredActionCount: 0 }
|
|
53
|
+
await withAtomicFlush(ctx.em, [
|
|
54
|
+
async () => {
|
|
55
|
+
retiredCounts = await retireActiveProposalsForEmail(ctx.em, email.id, ctx.userId, ctx.scope)
|
|
56
|
+
},
|
|
57
|
+
() => {
|
|
58
|
+
email.status = 'received'
|
|
59
|
+
email.processingError = null
|
|
60
|
+
},
|
|
61
|
+
], { transaction: true })
|
|
56
62
|
|
|
57
63
|
try {
|
|
58
64
|
await emitInboxOpsEvent('inbox_ops.email.reprocessed', {
|
|
@@ -123,6 +129,21 @@ async function retireActiveProposalsForEmail(
|
|
|
123
129
|
throw new ReprocessConflictError('Cannot reprocess after actions were already executed. Open the latest proposal instead.')
|
|
124
130
|
}
|
|
125
131
|
|
|
132
|
+
// Resolve every read before mutating: a query issued between a scalar
|
|
133
|
+
// mutation and the flush can silently reset the Unit of Work (SPEC-018
|
|
134
|
+
// Problem 1). withAtomicFlush flushes once at the end, so ordering is ours.
|
|
135
|
+
const discrepancies = await findWithDecryption(
|
|
136
|
+
em,
|
|
137
|
+
InboxDiscrepancy,
|
|
138
|
+
{
|
|
139
|
+
proposalId: { $in: proposalIds },
|
|
140
|
+
resolved: false,
|
|
141
|
+
deletedAt: null,
|
|
142
|
+
},
|
|
143
|
+
undefined,
|
|
144
|
+
scope,
|
|
145
|
+
)
|
|
146
|
+
|
|
126
147
|
const now = new Date()
|
|
127
148
|
const supersededAt = now.toISOString()
|
|
128
149
|
for (const proposal of proposals) {
|
|
@@ -153,23 +174,10 @@ async function retireActiveProposalsForEmail(
|
|
|
153
174
|
retiredActionCount += 1
|
|
154
175
|
}
|
|
155
176
|
|
|
156
|
-
const discrepancies = await findWithDecryption(
|
|
157
|
-
em,
|
|
158
|
-
InboxDiscrepancy,
|
|
159
|
-
{
|
|
160
|
-
proposalId: { $in: proposalIds },
|
|
161
|
-
resolved: false,
|
|
162
|
-
deletedAt: null,
|
|
163
|
-
},
|
|
164
|
-
undefined,
|
|
165
|
-
scope,
|
|
166
|
-
)
|
|
167
177
|
for (const discrepancy of discrepancies) {
|
|
168
178
|
discrepancy.resolved = true
|
|
169
179
|
}
|
|
170
180
|
|
|
171
|
-
await em.flush()
|
|
172
|
-
|
|
173
181
|
return {
|
|
174
182
|
retiredProposalCount: proposals.length,
|
|
175
183
|
retiredActionCount,
|