@open-mercato/core 0.4.5-develop-754ef4d2f0 → 0.4.5-develop-9f9549ebc8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generated/entities/message/index.js +65 -0
- package/dist/generated/entities/message/index.js.map +7 -0
- package/dist/generated/entities/message_access_token/index.js +19 -0
- package/dist/generated/entities/message_access_token/index.js.map +7 -0
- package/dist/generated/entities/message_confirmation/index.js +21 -0
- package/dist/generated/entities/message_confirmation/index.js.map +7 -0
- package/dist/generated/entities/message_object/index.js +23 -0
- package/dist/generated/entities/message_object/index.js.map +7 -0
- package/dist/generated/entities/message_recipient/index.js +31 -0
- package/dist/generated/entities/message_recipient/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +8 -0
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +10 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/auth/components/AclEditor.js +4 -2
- package/dist/modules/auth/components/AclEditor.js.map +2 -2
- package/dist/modules/auth/frontend/reset.js +3 -3
- package/dist/modules/auth/frontend/reset.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/[id]/page.js +27 -8
- package/dist/modules/customers/backend/customers/deals/[id]/page.js.map +2 -2
- package/dist/modules/customers/lib/messageObjectPreviews.js +131 -0
- package/dist/modules/customers/lib/messageObjectPreviews.js.map +7 -0
- package/dist/modules/customers/message-objects.js +71 -0
- package/dist/modules/customers/message-objects.js.map +7 -0
- package/dist/modules/customers/widgets/messages/CustomerMessageObjectDetail.js +51 -0
- package/dist/modules/customers/widgets/messages/CustomerMessageObjectDetail.js.map +7 -0
- package/dist/modules/customers/widgets/messages/CustomerMessageObjectPreview.js +35 -0
- package/dist/modules/customers/widgets/messages/CustomerMessageObjectPreview.js.map +7 -0
- package/dist/modules/customers/widgets/messages/index.js +7 -0
- package/dist/modules/customers/widgets/messages/index.js.map +7 -0
- package/dist/modules/dashboards/components/WidgetVisibilityEditor.js +35 -6
- package/dist/modules/dashboards/components/WidgetVisibilityEditor.js.map +2 -2
- package/dist/modules/messages/acl.js +15 -0
- package/dist/modules/messages/acl.js.map +7 -0
- package/dist/modules/messages/api/[id]/actions/[actionId]/route.js +92 -0
- package/dist/modules/messages/api/[id]/actions/[actionId]/route.js.map +7 -0
- package/dist/modules/messages/api/[id]/archive/route.js +120 -0
- package/dist/modules/messages/api/[id]/archive/route.js.map +7 -0
- package/dist/modules/messages/api/[id]/attachments/route.js +195 -0
- package/dist/modules/messages/api/[id]/attachments/route.js.map +7 -0
- package/dist/modules/messages/api/[id]/confirmation/route.js +67 -0
- package/dist/modules/messages/api/[id]/confirmation/route.js.map +7 -0
- package/dist/modules/messages/api/[id]/conversation/archive/route.js +68 -0
- package/dist/modules/messages/api/[id]/conversation/archive/route.js.map +7 -0
- package/dist/modules/messages/api/[id]/conversation/read/route.js +68 -0
- package/dist/modules/messages/api/[id]/conversation/read/route.js.map +7 -0
- package/dist/modules/messages/api/[id]/conversation/route.js +68 -0
- package/dist/modules/messages/api/[id]/conversation/route.js.map +7 -0
- package/dist/modules/messages/api/[id]/forward/route.js +85 -0
- package/dist/modules/messages/api/[id]/forward/route.js.map +7 -0
- package/dist/modules/messages/api/[id]/forward-preview/route.js +70 -0
- package/dist/modules/messages/api/[id]/forward-preview/route.js.map +7 -0
- package/dist/modules/messages/api/[id]/read/route.js +120 -0
- package/dist/modules/messages/api/[id]/read/route.js.map +7 -0
- package/dist/modules/messages/api/[id]/reply/route.js +87 -0
- package/dist/modules/messages/api/[id]/reply/route.js.map +7 -0
- package/dist/modules/messages/api/[id]/route.js +350 -0
- package/dist/modules/messages/api/[id]/route.js.map +7 -0
- package/dist/modules/messages/api/object-types/route.js +54 -0
- package/dist/modules/messages/api/object-types/route.js.map +7 -0
- package/dist/modules/messages/api/openapi.js +261 -0
- package/dist/modules/messages/api/openapi.js.map +7 -0
- package/dist/modules/messages/api/route.js +262 -0
- package/dist/modules/messages/api/route.js.map +7 -0
- package/dist/modules/messages/api/token/[token]/route.js +99 -0
- package/dist/modules/messages/api/token/[token]/route.js.map +7 -0
- package/dist/modules/messages/api/types/route.js +40 -0
- package/dist/modules/messages/api/types/route.js.map +7 -0
- package/dist/modules/messages/api/unread-count/route.js +43 -0
- package/dist/modules/messages/api/unread-count/route.js.map +7 -0
- package/dist/modules/messages/backend/messages/[id]/page.js +10 -0
- package/dist/modules/messages/backend/messages/[id]/page.js.map +7 -0
- package/dist/modules/messages/backend/messages/[id]/page.meta.js +16 -0
- package/dist/modules/messages/backend/messages/[id]/page.meta.js.map +7 -0
- package/dist/modules/messages/backend/messages/compose/page.js +10 -0
- package/dist/modules/messages/backend/messages/compose/page.js.map +7 -0
- package/dist/modules/messages/backend/messages/compose/page.meta.js +17 -0
- package/dist/modules/messages/backend/messages/compose/page.meta.js.map +7 -0
- package/dist/modules/messages/backend/page.js +10 -0
- package/dist/modules/messages/backend/page.js.map +7 -0
- package/dist/modules/messages/backend/page.meta.js +33 -0
- package/dist/modules/messages/backend/page.meta.js.map +7 -0
- package/dist/modules/messages/commands/actions.js +265 -0
- package/dist/modules/messages/commands/actions.js.map +7 -0
- package/dist/modules/messages/commands/attachments.js +217 -0
- package/dist/modules/messages/commands/attachments.js.map +7 -0
- package/dist/modules/messages/commands/confirmations.js +151 -0
- package/dist/modules/messages/commands/confirmations.js.map +7 -0
- package/dist/modules/messages/commands/conversation.js +240 -0
- package/dist/modules/messages/commands/conversation.js.map +7 -0
- package/dist/modules/messages/commands/messages.js +748 -0
- package/dist/modules/messages/commands/messages.js.map +7 -0
- package/dist/modules/messages/commands/recipients.js +259 -0
- package/dist/modules/messages/commands/recipients.js.map +7 -0
- package/dist/modules/messages/commands/shared.js +258 -0
- package/dist/modules/messages/commands/shared.js.map +7 -0
- package/dist/modules/messages/commands/tokens.js +69 -0
- package/dist/modules/messages/commands/tokens.js.map +7 -0
- package/dist/modules/messages/components/ComposeMessagePageClient.js +24 -0
- package/dist/modules/messages/components/ComposeMessagePageClient.js.map +7 -0
- package/dist/modules/messages/components/MessageDetailPageClient.js +261 -0
- package/dist/modules/messages/components/MessageDetailPageClient.js.map +7 -0
- package/dist/modules/messages/components/MessagesInboxPageClient.js +390 -0
- package/dist/modules/messages/components/MessagesInboxPageClient.js.map +7 -0
- package/dist/modules/messages/components/confirmation/MessageConfirmationActions.js +31 -0
- package/dist/modules/messages/components/confirmation/MessageConfirmationActions.js.map +7 -0
- package/dist/modules/messages/components/confirmation/MessageConfirmationContent.js +69 -0
- package/dist/modules/messages/components/confirmation/MessageConfirmationContent.js.map +7 -0
- package/dist/modules/messages/components/defaults/DefaultMessageActions.js +31 -0
- package/dist/modules/messages/components/defaults/DefaultMessageActions.js.map +7 -0
- package/dist/modules/messages/components/defaults/DefaultMessageContent.js +19 -0
- package/dist/modules/messages/components/defaults/DefaultMessageContent.js.map +7 -0
- package/dist/modules/messages/components/defaults/DefaultMessageListItem.js +90 -0
- package/dist/modules/messages/components/defaults/DefaultMessageListItem.js.map +7 -0
- package/dist/modules/messages/components/defaults/MessageRecordObjectDetail.js +86 -0
- package/dist/modules/messages/components/defaults/MessageRecordObjectDetail.js.map +7 -0
- package/dist/modules/messages/components/defaults/MessageRecordObjectPreview.js +61 -0
- package/dist/modules/messages/components/defaults/MessageRecordObjectPreview.js.map +7 -0
- package/dist/modules/messages/components/message-detail/detail-panels.js +27 -0
- package/dist/modules/messages/components/message-detail/detail-panels.js.map +7 -0
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetails.js +52 -0
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetails.js.map +7 -0
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsActions.js +289 -0
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsActions.js.map +7 -0
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsConversation.js +103 -0
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsConversation.js.map +7 -0
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsQueries.js +78 -0
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsQueries.js.map +7 -0
- package/dist/modules/messages/components/message-detail/panels/MainMessageHeader.js +94 -0
- package/dist/modules/messages/components/message-detail/panels/MainMessageHeader.js.map +7 -0
- package/dist/modules/messages/components/message-detail/panels/MessageHeader.js +110 -0
- package/dist/modules/messages/components/message-detail/panels/MessageHeader.js.map +7 -0
- package/dist/modules/messages/components/message-detail/panels/MessageListComponent.js +58 -0
- package/dist/modules/messages/components/message-detail/panels/MessageListComponent.js.map +7 -0
- package/dist/modules/messages/components/message-detail/panels/actions-panel.js +51 -0
- package/dist/modules/messages/components/message-detail/panels/actions-panel.js.map +7 -0
- package/dist/modules/messages/components/message-detail/panels/attachments-panel.js +66 -0
- package/dist/modules/messages/components/message-detail/panels/attachments-panel.js.map +7 -0
- package/dist/modules/messages/components/message-detail/panels/body-panel.js +20 -0
- package/dist/modules/messages/components/message-detail/panels/body-panel.js.map +7 -0
- package/dist/modules/messages/components/message-detail/panels/composer-dialogs.js +36 -0
- package/dist/modules/messages/components/message-detail/panels/composer-dialogs.js.map +7 -0
- package/dist/modules/messages/components/message-detail/panels/dialogs.js +96 -0
- package/dist/modules/messages/components/message-detail/panels/dialogs.js.map +7 -0
- package/dist/modules/messages/components/message-detail/panels/index.js +25 -0
- package/dist/modules/messages/components/message-detail/panels/index.js.map +7 -0
- package/dist/modules/messages/components/message-detail/panels/meta-panel.js +14 -0
- package/dist/modules/messages/components/message-detail/panels/meta-panel.js.map +7 -0
- package/dist/modules/messages/components/message-detail/panels/objects-panel.js +51 -0
- package/dist/modules/messages/components/message-detail/panels/objects-panel.js.map +7 -0
- package/dist/modules/messages/components/message-detail/panels/thread-panel.js +54 -0
- package/dist/modules/messages/components/message-detail/panels/thread-panel.js.map +7 -0
- package/dist/modules/messages/components/message-detail/types.js +1 -0
- package/dist/modules/messages/components/message-detail/types.js.map +7 -0
- package/dist/modules/messages/components/message-detail/utils.js +54 -0
- package/dist/modules/messages/components/message-detail/utils.js.map +7 -0
- package/dist/modules/messages/components/utils/PriorityBadge.js +52 -0
- package/dist/modules/messages/components/utils/PriorityBadge.js.map +7 -0
- package/dist/modules/messages/components/utils/typeUiRegistry.js +77 -0
- package/dist/modules/messages/components/utils/typeUiRegistry.js.map +7 -0
- package/dist/modules/messages/data/entities.js +309 -0
- package/dist/modules/messages/data/entities.js.map +7 -0
- package/dist/modules/messages/data/validators.js +272 -0
- package/dist/modules/messages/data/validators.js.map +7 -0
- package/dist/modules/messages/emails/MessageEmail.js +108 -0
- package/dist/modules/messages/emails/MessageEmail.js.map +7 -0
- package/dist/modules/messages/events.js +24 -0
- package/dist/modules/messages/events.js.map +7 -0
- package/dist/modules/messages/frontend/messages/view/[token]/page.js +247 -0
- package/dist/modules/messages/frontend/messages/view/[token]/page.js.map +7 -0
- package/dist/modules/messages/frontend/messages/view/[token]/page.meta.js +9 -0
- package/dist/modules/messages/frontend/messages/view/[token]/page.meta.js.map +7 -0
- package/dist/modules/messages/index.js +21 -0
- package/dist/modules/messages/index.js.map +7 -0
- package/dist/modules/messages/lib/actions.js +141 -0
- package/dist/modules/messages/lib/actions.js.map +7 -0
- package/dist/modules/messages/lib/attachments.js +131 -0
- package/dist/modules/messages/lib/attachments.js.map +7 -0
- package/dist/modules/messages/lib/constants.js +7 -0
- package/dist/modules/messages/lib/constants.js.map +7 -0
- package/dist/modules/messages/lib/email-sender.js +201 -0
- package/dist/modules/messages/lib/email-sender.js.map +7 -0
- package/dist/modules/messages/lib/forwarding.js +179 -0
- package/dist/modules/messages/lib/forwarding.js.map +7 -0
- package/dist/modules/messages/lib/message-objects-registry.js +49 -0
- package/dist/modules/messages/lib/message-objects-registry.js.map +7 -0
- package/dist/modules/messages/lib/message-types-registry.js +41 -0
- package/dist/modules/messages/lib/message-types-registry.js.map +7 -0
- package/dist/modules/messages/lib/object-validation.js +20 -0
- package/dist/modules/messages/lib/object-validation.js.map +7 -0
- package/dist/modules/messages/lib/operationMetadata.js +21 -0
- package/dist/modules/messages/lib/operationMetadata.js.map +7 -0
- package/dist/modules/messages/lib/priorityUtils.js +61 -0
- package/dist/modules/messages/lib/priorityUtils.js.map +7 -0
- package/dist/modules/messages/lib/routeHelpers.js +44 -0
- package/dist/modules/messages/lib/routeHelpers.js.map +7 -0
- package/dist/modules/messages/message-objects.js +7 -0
- package/dist/modules/messages/message-objects.js.map +7 -0
- package/dist/modules/messages/message-types.js +67 -0
- package/dist/modules/messages/message-types.js.map +7 -0
- package/dist/modules/messages/migrations/Migration20260213181243.js +31 -0
- package/dist/modules/messages/migrations/Migration20260213181243.js.map +7 -0
- package/dist/modules/messages/migrations/Migration20260215165126.js +16 -0
- package/dist/modules/messages/migrations/Migration20260215165126.js.map +7 -0
- package/dist/modules/messages/notifications.js +27 -0
- package/dist/modules/messages/notifications.js.map +7 -0
- package/dist/modules/messages/setup.js +21 -0
- package/dist/modules/messages/setup.js.map +7 -0
- package/dist/modules/messages/subscribers/message-notification.js +108 -0
- package/dist/modules/messages/subscribers/message-notification.js.map +7 -0
- package/dist/modules/messages/workers/send-email.worker.js +253 -0
- package/dist/modules/messages/workers/send-email.worker.js.map +7 -0
- package/dist/modules/sales/backend/sales/documents/[id]/page.js +30 -11
- package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
- package/dist/modules/sales/commands/payments.js +12 -6
- package/dist/modules/sales/commands/payments.js.map +2 -2
- package/dist/modules/sales/lib/messageObjectPreviews.js +114 -0
- package/dist/modules/sales/lib/messageObjectPreviews.js.map +7 -0
- package/dist/modules/sales/message-objects.js +57 -0
- package/dist/modules/sales/message-objects.js.map +7 -0
- package/dist/modules/sales/widgets/messages/SalesDocumentMessageDetail.js +51 -0
- package/dist/modules/sales/widgets/messages/SalesDocumentMessageDetail.js.map +7 -0
- package/dist/modules/sales/widgets/messages/SalesDocumentMessagePreview.js +36 -0
- package/dist/modules/sales/widgets/messages/SalesDocumentMessagePreview.js.map +7 -0
- package/dist/modules/sales/widgets/messages/index.js +7 -0
- package/dist/modules/sales/widgets/messages/index.js.map +7 -0
- package/dist/modules/staff/backend/staff/leave-requests/[id]/page.js +55 -1
- package/dist/modules/staff/backend/staff/leave-requests/[id]/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/my-leave-requests/[id]/page.js +60 -1
- package/dist/modules/staff/backend/staff/my-leave-requests/[id]/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/team-members/[id]/page.js +2 -19
- package/dist/modules/staff/backend/staff/team-members/[id]/page.js.map +2 -2
- package/dist/modules/staff/components/LeaveRequestDetail.js +112 -0
- package/dist/modules/staff/components/LeaveRequestDetail.js.map +7 -0
- package/dist/modules/staff/components/LeaveRequestForm.js +3 -1
- package/dist/modules/staff/components/LeaveRequestForm.js.map +2 -2
- package/dist/modules/staff/components/LeaveRequestPreview.js +43 -0
- package/dist/modules/staff/components/LeaveRequestPreview.js.map +7 -0
- package/dist/modules/staff/lib/messageObjectPreviews.js +148 -0
- package/dist/modules/staff/lib/messageObjectPreviews.js.map +7 -0
- package/dist/modules/staff/message-objects.js +104 -0
- package/dist/modules/staff/message-objects.js.map +7 -0
- package/dist/modules/staff/message-types.js +23 -0
- package/dist/modules/staff/message-types.js.map +7 -0
- package/dist/modules/staff/widgets/messages/StaffMessageObjectDetail.js +51 -0
- package/dist/modules/staff/widgets/messages/StaffMessageObjectDetail.js.map +7 -0
- package/dist/modules/staff/widgets/messages/StaffMessageObjectPreview.js +34 -0
- package/dist/modules/staff/widgets/messages/StaffMessageObjectPreview.js.map +7 -0
- package/dist/modules/staff/widgets/messages/index.js +7 -0
- package/dist/modules/staff/widgets/messages/index.js.map +7 -0
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js +6 -6
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js.map +2 -2
- package/generated/entities/message/index.ts +31 -0
- package/generated/entities/message_access_token/index.ts +8 -0
- package/generated/entities/message_confirmation/index.ts +9 -0
- package/generated/entities/message_object/index.ts +10 -0
- package/generated/entities/message_recipient/index.ts +14 -0
- package/generated/entities.ids.generated.ts +8 -0
- package/generated/entity-fields-registry.ts +10 -0
- package/jest.setup.ts +5 -0
- package/package.json +2 -2
- package/src/modules/attachments/i18n/de.json +4 -0
- package/src/modules/attachments/i18n/en.json +4 -0
- package/src/modules/attachments/i18n/es.json +4 -0
- package/src/modules/attachments/i18n/pl.json +4 -0
- package/src/modules/auth/components/AclEditor.tsx +4 -2
- package/src/modules/auth/frontend/reset.tsx +3 -3
- package/src/modules/auth/i18n/de.json +5 -0
- package/src/modules/auth/i18n/en.json +5 -0
- package/src/modules/auth/i18n/es.json +5 -0
- package/src/modules/auth/i18n/pl.json +5 -0
- package/src/modules/catalog/i18n/de.json +21 -0
- package/src/modules/catalog/i18n/en.json +21 -0
- package/src/modules/catalog/i18n/es.json +21 -0
- package/src/modules/catalog/i18n/pl.json +21 -0
- package/src/modules/currencies/i18n/de.json +6 -0
- package/src/modules/currencies/i18n/en.json +6 -0
- package/src/modules/currencies/i18n/es.json +6 -0
- package/src/modules/currencies/i18n/pl.json +6 -0
- package/src/modules/customers/backend/customers/deals/[id]/page.tsx +20 -4
- package/src/modules/customers/i18n/de.json +26 -1
- package/src/modules/customers/i18n/en.json +25 -0
- package/src/modules/customers/i18n/es.json +25 -0
- package/src/modules/customers/i18n/pl.json +25 -0
- package/src/modules/customers/lib/messageObjectPreviews.ts +154 -0
- package/src/modules/customers/message-objects.ts +70 -0
- package/src/modules/customers/widgets/messages/CustomerMessageObjectDetail.tsx +57 -0
- package/src/modules/customers/widgets/messages/CustomerMessageObjectPreview.tsx +49 -0
- package/src/modules/customers/widgets/messages/index.ts +2 -0
- package/src/modules/dashboards/components/WidgetVisibilityEditor.tsx +41 -5
- package/src/modules/dashboards/i18n/de.json +5 -1
- package/src/modules/dashboards/i18n/en.json +5 -1
- package/src/modules/dashboards/i18n/es.json +5 -1
- package/src/modules/dashboards/i18n/pl.json +5 -1
- package/src/modules/dictionaries/i18n/de.json +14 -1
- package/src/modules/dictionaries/i18n/en.json +14 -1
- package/src/modules/dictionaries/i18n/es.json +14 -1
- package/src/modules/dictionaries/i18n/pl.json +14 -1
- package/src/modules/feature_toggles/i18n/de.json +3 -0
- package/src/modules/feature_toggles/i18n/en.json +3 -0
- package/src/modules/feature_toggles/i18n/es.json +3 -0
- package/src/modules/feature_toggles/i18n/pl.json +3 -0
- package/src/modules/messages/acl.ts +11 -0
- package/src/modules/messages/api/[id]/actions/[actionId]/route.ts +103 -0
- package/src/modules/messages/api/[id]/archive/route.ts +138 -0
- package/src/modules/messages/api/[id]/attachments/route.ts +217 -0
- package/src/modules/messages/api/[id]/confirmation/route.ts +73 -0
- package/src/modules/messages/api/[id]/conversation/archive/route.ts +69 -0
- package/src/modules/messages/api/[id]/conversation/read/route.ts +69 -0
- package/src/modules/messages/api/[id]/conversation/route.ts +69 -0
- package/src/modules/messages/api/[id]/forward/route.ts +87 -0
- package/src/modules/messages/api/[id]/forward-preview/route.ts +75 -0
- package/src/modules/messages/api/[id]/read/route.ts +138 -0
- package/src/modules/messages/api/[id]/reply/route.ts +89 -0
- package/src/modules/messages/api/[id]/route.ts +401 -0
- package/src/modules/messages/api/object-types/route.ts +54 -0
- package/src/modules/messages/api/openapi.ts +261 -0
- package/src/modules/messages/api/route.ts +374 -0
- package/src/modules/messages/api/token/[token]/route.ts +103 -0
- package/src/modules/messages/api/types/route.ts +39 -0
- package/src/modules/messages/api/unread-count/route.ts +55 -0
- package/src/modules/messages/backend/messages/[id]/page.meta.ts +12 -0
- package/src/modules/messages/backend/messages/[id]/page.tsx +12 -0
- package/src/modules/messages/backend/messages/compose/page.meta.ts +13 -0
- package/src/modules/messages/backend/messages/compose/page.tsx +12 -0
- package/src/modules/messages/backend/page.meta.ts +31 -0
- package/src/modules/messages/backend/page.tsx +12 -0
- package/src/modules/messages/commands/actions.ts +307 -0
- package/src/modules/messages/commands/attachments.ts +227 -0
- package/src/modules/messages/commands/confirmations.ts +183 -0
- package/src/modules/messages/commands/conversation.ts +292 -0
- package/src/modules/messages/commands/messages.ts +845 -0
- package/src/modules/messages/commands/recipients.ts +281 -0
- package/src/modules/messages/commands/shared.ts +350 -0
- package/src/modules/messages/commands/tokens.ts +80 -0
- package/src/modules/messages/components/ComposeMessagePageClient.tsx +23 -0
- package/src/modules/messages/components/MessageDetailPageClient.tsx +287 -0
- package/src/modules/messages/components/MessagesInboxPageClient.tsx +469 -0
- package/src/modules/messages/components/confirmation/MessageConfirmationActions.tsx +35 -0
- package/src/modules/messages/components/confirmation/MessageConfirmationContent.tsx +88 -0
- package/src/modules/messages/components/defaults/DefaultMessageActions.tsx +37 -0
- package/src/modules/messages/components/defaults/DefaultMessageContent.tsx +21 -0
- package/src/modules/messages/components/defaults/DefaultMessageListItem.tsx +102 -0
- package/src/modules/messages/components/defaults/MessageRecordObjectDetail.tsx +114 -0
- package/src/modules/messages/components/defaults/MessageRecordObjectPreview.tsx +74 -0
- package/src/modules/messages/components/message-detail/detail-panels.ts +13 -0
- package/src/modules/messages/components/message-detail/hooks/useMessageDetails.ts +56 -0
- package/src/modules/messages/components/message-detail/hooks/useMessageDetailsActions.ts +367 -0
- package/src/modules/messages/components/message-detail/hooks/useMessageDetailsConversation.ts +134 -0
- package/src/modules/messages/components/message-detail/hooks/useMessageDetailsQueries.ts +102 -0
- package/src/modules/messages/components/message-detail/panels/MainMessageHeader.tsx +108 -0
- package/src/modules/messages/components/message-detail/panels/MessageHeader.tsx +144 -0
- package/src/modules/messages/components/message-detail/panels/MessageListComponent.tsx +63 -0
- package/src/modules/messages/components/message-detail/panels/actions-panel.tsx +66 -0
- package/src/modules/messages/components/message-detail/panels/attachments-panel.tsx +86 -0
- package/src/modules/messages/components/message-detail/panels/body-panel.tsx +32 -0
- package/src/modules/messages/components/message-detail/panels/composer-dialogs.tsx +42 -0
- package/src/modules/messages/components/message-detail/panels/dialogs.tsx +107 -0
- package/src/modules/messages/components/message-detail/panels/index.ts +11 -0
- package/src/modules/messages/components/message-detail/panels/meta-panel.tsx +19 -0
- package/src/modules/messages/components/message-detail/panels/objects-panel.tsx +65 -0
- package/src/modules/messages/components/message-detail/panels/thread-panel.tsx +65 -0
- package/src/modules/messages/components/message-detail/types.ts +114 -0
- package/src/modules/messages/components/message-detail/utils.ts +62 -0
- package/src/modules/messages/components/utils/PriorityBadge.tsx +63 -0
- package/src/modules/messages/components/utils/typeUiRegistry.ts +106 -0
- package/src/modules/messages/data/entities.ts +284 -0
- package/src/modules/messages/data/validators.ts +297 -0
- package/src/modules/messages/emails/MessageEmail.tsx +143 -0
- package/src/modules/messages/events.ts +24 -0
- package/src/modules/messages/frontend/messages/view/[token]/page.meta.ts +5 -0
- package/src/modules/messages/frontend/messages/view/[token]/page.tsx +389 -0
- package/src/modules/messages/i18n/de.json +240 -0
- package/src/modules/messages/i18n/en.json +240 -0
- package/src/modules/messages/i18n/es.json +240 -0
- package/src/modules/messages/i18n/pl.json +240 -0
- package/src/modules/messages/index.ts +19 -0
- package/src/modules/messages/lib/actions.ts +204 -0
- package/src/modules/messages/lib/attachments.ts +197 -0
- package/src/modules/messages/lib/constants.ts +2 -0
- package/src/modules/messages/lib/email-sender.ts +255 -0
- package/src/modules/messages/lib/forwarding.ts +240 -0
- package/src/modules/messages/lib/message-objects-registry.ts +60 -0
- package/src/modules/messages/lib/message-types-registry.ts +48 -0
- package/src/modules/messages/lib/object-validation.ts +26 -0
- package/src/modules/messages/lib/operationMetadata.ts +43 -0
- package/src/modules/messages/lib/priorityUtils.ts +76 -0
- package/src/modules/messages/lib/routeHelpers.ts +65 -0
- package/src/modules/messages/message-objects.ts +5 -0
- package/src/modules/messages/message-types.ts +65 -0
- package/src/modules/messages/migrations/.snapshot-open-mercato.json +957 -0
- package/src/modules/messages/migrations/Migration20260213181243.ts +34 -0
- package/src/modules/messages/migrations/Migration20260215165126.ts +16 -0
- package/src/modules/messages/notifications.ts +25 -0
- package/src/modules/messages/setup.ts +19 -0
- package/src/modules/messages/subscribers/message-notification.ts +138 -0
- package/src/modules/messages/workers/send-email.worker.ts +321 -0
- package/src/modules/query_index/i18n/es.json +2 -2
- package/src/modules/resources/i18n/de.json +57 -0
- package/src/modules/resources/i18n/en.json +57 -0
- package/src/modules/resources/i18n/es.json +57 -0
- package/src/modules/resources/i18n/pl.json +57 -0
- package/src/modules/sales/backend/sales/documents/[id]/page.tsx +23 -7
- package/src/modules/sales/commands/payments.ts +12 -6
- package/src/modules/sales/i18n/de.json +26 -0
- package/src/modules/sales/i18n/en.json +26 -0
- package/src/modules/sales/i18n/es.json +26 -0
- package/src/modules/sales/i18n/pl.json +26 -0
- package/src/modules/sales/lib/messageObjectPreviews.ts +150 -0
- package/src/modules/sales/message-objects.ts +56 -0
- package/src/modules/sales/widgets/messages/SalesDocumentMessageDetail.tsx +57 -0
- package/src/modules/sales/widgets/messages/SalesDocumentMessagePreview.tsx +46 -0
- package/src/modules/sales/widgets/messages/index.ts +2 -0
- package/src/modules/staff/backend/staff/leave-requests/[id]/page.tsx +54 -0
- package/src/modules/staff/backend/staff/my-leave-requests/[id]/page.tsx +58 -0
- package/src/modules/staff/backend/staff/team-members/[id]/page.tsx +2 -32
- package/src/modules/staff/components/LeaveRequestDetail.tsx +135 -0
- package/src/modules/staff/components/LeaveRequestForm.tsx +3 -0
- package/src/modules/staff/components/LeaveRequestPreview.tsx +74 -0
- package/src/modules/staff/i18n/de.json +22 -0
- package/src/modules/staff/i18n/en.json +22 -0
- package/src/modules/staff/i18n/es.json +22 -0
- package/src/modules/staff/i18n/pl.json +22 -0
- package/src/modules/staff/lib/messageObjectPreviews.ts +182 -0
- package/src/modules/staff/message-objects.ts +102 -0
- package/src/modules/staff/message-types.ts +21 -0
- package/src/modules/staff/widgets/messages/StaffMessageObjectDetail.tsx +57 -0
- package/src/modules/staff/widgets/messages/StaffMessageObjectPreview.tsx +44 -0
- package/src/modules/staff/widgets/messages/index.ts +2 -0
- package/src/modules/workflows/backend/definitions/visual-editor/page.tsx +6 -6
- package/src/modules/workflows/i18n/de.json +41 -0
- package/src/modules/workflows/i18n/en.json +41 -0
- package/src/modules/workflows/i18n/es.json +41 -0
- package/src/modules/workflows/i18n/pl.json +41 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { Entity, PrimaryKey, Property, Index, OptionalProps, Unique } from '@mikro-orm/core'
|
|
2
|
+
|
|
3
|
+
export type MessageStatus = 'draft' | 'sent'
|
|
4
|
+
export type MessagePriority = 'low' | 'normal' | 'high' | 'urgent'
|
|
5
|
+
export type MessageBodyFormat = 'text' | 'markdown'
|
|
6
|
+
|
|
7
|
+
export type MessageAction = {
|
|
8
|
+
id: string
|
|
9
|
+
label: string
|
|
10
|
+
labelKey?: string
|
|
11
|
+
variant?: 'default' | 'secondary' | 'destructive' | 'outline' | 'ghost'
|
|
12
|
+
icon?: string
|
|
13
|
+
commandId?: string
|
|
14
|
+
href?: string
|
|
15
|
+
isTerminal?: boolean
|
|
16
|
+
confirmRequired?: boolean
|
|
17
|
+
confirmMessage?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type MessageActionData = {
|
|
21
|
+
actions: MessageAction[]
|
|
22
|
+
primaryActionId?: string
|
|
23
|
+
expiresAt?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Entity({ tableName: 'messages' })
|
|
27
|
+
@Index({ name: 'messages_sender_idx', properties: ['senderUserId', 'sentAt'] })
|
|
28
|
+
@Index({ name: 'messages_thread_idx', properties: ['threadId'] })
|
|
29
|
+
@Index({ name: 'messages_type_idx', properties: ['type', 'tenantId'] })
|
|
30
|
+
@Index({ name: 'messages_tenant_idx', properties: ['tenantId', 'organizationId'] })
|
|
31
|
+
export class Message {
|
|
32
|
+
[OptionalProps]?: 'type' | 'status' | 'priority' | 'bodyFormat' | 'isDraft' | 'createdAt' | 'updatedAt'
|
|
33
|
+
|
|
34
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
35
|
+
id!: string
|
|
36
|
+
|
|
37
|
+
@Property({ name: 'type', type: 'text' })
|
|
38
|
+
type: string = 'default'
|
|
39
|
+
|
|
40
|
+
@Property({ name: 'thread_id', type: 'uuid', nullable: true })
|
|
41
|
+
threadId?: string | null
|
|
42
|
+
|
|
43
|
+
@Property({ name: 'parent_message_id', type: 'uuid', nullable: true })
|
|
44
|
+
parentMessageId?: string | null
|
|
45
|
+
|
|
46
|
+
@Property({ name: 'sender_user_id', type: 'uuid' })
|
|
47
|
+
senderUserId!: string
|
|
48
|
+
|
|
49
|
+
@Property({ name: 'subject', type: 'text' })
|
|
50
|
+
subject!: string
|
|
51
|
+
|
|
52
|
+
@Property({ name: 'body', type: 'text' })
|
|
53
|
+
body!: string
|
|
54
|
+
|
|
55
|
+
@Property({ name: 'body_format', type: 'text' })
|
|
56
|
+
bodyFormat: MessageBodyFormat = 'text'
|
|
57
|
+
|
|
58
|
+
@Property({ name: 'priority', type: 'text' })
|
|
59
|
+
priority: MessagePriority = 'normal'
|
|
60
|
+
|
|
61
|
+
@Property({ name: 'status', type: 'text' })
|
|
62
|
+
status: MessageStatus = 'draft'
|
|
63
|
+
|
|
64
|
+
@Property({ name: 'is_draft', type: 'boolean' })
|
|
65
|
+
isDraft: boolean = true
|
|
66
|
+
|
|
67
|
+
@Property({ name: 'sent_at', type: Date, nullable: true })
|
|
68
|
+
sentAt?: Date | null
|
|
69
|
+
|
|
70
|
+
@Property({ name: 'action_data', type: 'json', nullable: true })
|
|
71
|
+
actionData?: MessageActionData | null
|
|
72
|
+
|
|
73
|
+
@Property({ name: 'action_result', type: 'json', nullable: true })
|
|
74
|
+
actionResult?: Record<string, unknown> | null
|
|
75
|
+
|
|
76
|
+
@Property({ name: 'action_taken', type: 'text', nullable: true })
|
|
77
|
+
actionTaken?: string | null
|
|
78
|
+
|
|
79
|
+
@Property({ name: 'action_taken_by_user_id', type: 'uuid', nullable: true })
|
|
80
|
+
actionTakenByUserId?: string | null
|
|
81
|
+
|
|
82
|
+
@Property({ name: 'action_taken_at', type: Date, nullable: true })
|
|
83
|
+
actionTakenAt?: Date | null
|
|
84
|
+
|
|
85
|
+
@Property({ name: 'send_via_email', type: 'boolean', default: false })
|
|
86
|
+
sendViaEmail: boolean = false
|
|
87
|
+
|
|
88
|
+
@Property({ name: 'tenant_id', type: 'uuid' })
|
|
89
|
+
tenantId!: string
|
|
90
|
+
|
|
91
|
+
@Property({ name: 'organization_id', type: 'uuid', nullable: true })
|
|
92
|
+
organizationId?: string | null
|
|
93
|
+
|
|
94
|
+
@Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
|
|
95
|
+
createdAt: Date = new Date()
|
|
96
|
+
|
|
97
|
+
@Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
|
|
98
|
+
updatedAt: Date = new Date()
|
|
99
|
+
|
|
100
|
+
@Property({ name: 'deleted_at', type: Date, nullable: true })
|
|
101
|
+
deletedAt?: Date | null
|
|
102
|
+
|
|
103
|
+
@Property({ name: 'visibility', type: 'text', nullable: true })
|
|
104
|
+
visibility?: 'public' | 'internal' | null
|
|
105
|
+
|
|
106
|
+
@Property({ name: 'source_entity_type', type: 'text', nullable: true })
|
|
107
|
+
sourceEntityType?: string | null
|
|
108
|
+
|
|
109
|
+
@Property({ name: 'source_entity_id', type: 'uuid', nullable: true })
|
|
110
|
+
sourceEntityId?: string | null
|
|
111
|
+
|
|
112
|
+
@Property({ name: 'external_email', type: 'text', nullable: true })
|
|
113
|
+
externalEmail?: string | null
|
|
114
|
+
|
|
115
|
+
@Property({ name: 'external_name', type: 'text', nullable: true })
|
|
116
|
+
externalName?: string | null
|
|
117
|
+
|
|
118
|
+
@Property({ name: 'external_email_sent_at', type: Date, nullable: true })
|
|
119
|
+
externalEmailSentAt?: Date | null
|
|
120
|
+
|
|
121
|
+
@Property({ name: 'external_email_failed_at', type: Date, nullable: true })
|
|
122
|
+
externalEmailFailedAt?: Date | null
|
|
123
|
+
|
|
124
|
+
@Property({ name: 'external_email_error', type: 'text', nullable: true })
|
|
125
|
+
externalEmailError?: string | null
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export type RecipientType = 'to' | 'cc' | 'bcc'
|
|
129
|
+
export type RecipientStatus = 'unread' | 'read' | 'archived' | 'deleted'
|
|
130
|
+
|
|
131
|
+
@Entity({ tableName: 'message_recipients' })
|
|
132
|
+
@Index({ name: 'message_recipients_user_idx', properties: ['recipientUserId', 'status'] })
|
|
133
|
+
@Index({ name: 'message_recipients_message_idx', properties: ['messageId'] })
|
|
134
|
+
@Unique({ name: 'message_recipients_message_user_unique', properties: ['messageId', 'recipientUserId'] })
|
|
135
|
+
export class MessageRecipient {
|
|
136
|
+
[OptionalProps]?: 'recipientType' | 'status' | 'createdAt'
|
|
137
|
+
|
|
138
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
139
|
+
id!: string
|
|
140
|
+
|
|
141
|
+
@Property({ name: 'message_id', type: 'uuid' })
|
|
142
|
+
messageId!: string
|
|
143
|
+
|
|
144
|
+
@Property({ name: 'recipient_user_id', type: 'uuid' })
|
|
145
|
+
recipientUserId!: string
|
|
146
|
+
|
|
147
|
+
@Property({ name: 'recipient_type', type: 'text' })
|
|
148
|
+
recipientType: RecipientType = 'to'
|
|
149
|
+
|
|
150
|
+
@Property({ name: 'status', type: 'text' })
|
|
151
|
+
status: RecipientStatus = 'unread'
|
|
152
|
+
|
|
153
|
+
@Property({ name: 'read_at', type: Date, nullable: true })
|
|
154
|
+
readAt?: Date | null
|
|
155
|
+
|
|
156
|
+
@Property({ name: 'archived_at', type: Date, nullable: true })
|
|
157
|
+
archivedAt?: Date | null
|
|
158
|
+
|
|
159
|
+
@Property({ name: 'deleted_at', type: Date, nullable: true })
|
|
160
|
+
deletedAt?: Date | null
|
|
161
|
+
|
|
162
|
+
@Property({ name: 'email_sent_at', type: Date, nullable: true })
|
|
163
|
+
emailSentAt?: Date | null
|
|
164
|
+
|
|
165
|
+
@Property({ name: 'email_delivered_at', type: Date, nullable: true })
|
|
166
|
+
emailDeliveredAt?: Date | null
|
|
167
|
+
|
|
168
|
+
@Property({ name: 'email_opened_at', type: Date, nullable: true })
|
|
169
|
+
emailOpenedAt?: Date | null
|
|
170
|
+
|
|
171
|
+
@Property({ name: 'email_failed_at', type: Date, nullable: true })
|
|
172
|
+
emailFailedAt?: Date | null
|
|
173
|
+
|
|
174
|
+
@Property({ name: 'email_error', type: 'text', nullable: true })
|
|
175
|
+
emailError?: string | null
|
|
176
|
+
|
|
177
|
+
@Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
|
|
178
|
+
createdAt: Date = new Date()
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@Entity({ tableName: 'message_objects' })
|
|
182
|
+
@Index({ name: 'message_objects_message_idx', properties: ['messageId'] })
|
|
183
|
+
@Index({ name: 'message_objects_entity_idx', properties: ['entityType', 'entityId'] })
|
|
184
|
+
export class MessageObject {
|
|
185
|
+
[OptionalProps]?: 'actionRequired' | 'createdAt'
|
|
186
|
+
|
|
187
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
188
|
+
id!: string
|
|
189
|
+
|
|
190
|
+
@Property({ name: 'message_id', type: 'uuid' })
|
|
191
|
+
messageId!: string
|
|
192
|
+
|
|
193
|
+
@Property({ name: 'entity_module', type: 'text' })
|
|
194
|
+
entityModule!: string
|
|
195
|
+
|
|
196
|
+
@Property({ name: 'entity_type', type: 'text' })
|
|
197
|
+
entityType!: string
|
|
198
|
+
|
|
199
|
+
@Property({ name: 'entity_id', type: 'uuid' })
|
|
200
|
+
entityId!: string
|
|
201
|
+
|
|
202
|
+
@Property({ name: 'action_required', type: 'boolean' })
|
|
203
|
+
actionRequired: boolean = false
|
|
204
|
+
|
|
205
|
+
@Property({ name: 'action_type', type: 'text', nullable: true })
|
|
206
|
+
actionType?: string | null
|
|
207
|
+
|
|
208
|
+
@Property({ name: 'action_label', type: 'text', nullable: true })
|
|
209
|
+
actionLabel?: string | null
|
|
210
|
+
|
|
211
|
+
@Property({ name: 'entity_snapshot', type: 'json', nullable: true })
|
|
212
|
+
entitySnapshot?: Record<string, unknown> | null
|
|
213
|
+
|
|
214
|
+
@Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
|
|
215
|
+
createdAt: Date = new Date()
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@Entity({ tableName: 'message_access_tokens' })
|
|
219
|
+
@Index({ name: 'message_access_tokens_token_idx', properties: ['token'] })
|
|
220
|
+
@Index({ name: 'message_access_tokens_message_idx', properties: ['messageId'] })
|
|
221
|
+
export class MessageAccessToken {
|
|
222
|
+
[OptionalProps]?: 'createdAt'
|
|
223
|
+
|
|
224
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
225
|
+
id!: string
|
|
226
|
+
|
|
227
|
+
@Property({ name: 'message_id', type: 'uuid' })
|
|
228
|
+
messageId!: string
|
|
229
|
+
|
|
230
|
+
@Property({ name: 'recipient_user_id', type: 'uuid' })
|
|
231
|
+
recipientUserId!: string
|
|
232
|
+
|
|
233
|
+
@Property({ name: 'token', type: 'text', unique: true })
|
|
234
|
+
token!: string
|
|
235
|
+
|
|
236
|
+
@Property({ name: 'expires_at', type: Date })
|
|
237
|
+
expiresAt!: Date
|
|
238
|
+
|
|
239
|
+
@Property({ name: 'used_at', type: Date, nullable: true })
|
|
240
|
+
usedAt?: Date | null
|
|
241
|
+
|
|
242
|
+
@Property({ name: 'use_count', type: 'int', default: 0 })
|
|
243
|
+
useCount: number = 0
|
|
244
|
+
|
|
245
|
+
@Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
|
|
246
|
+
createdAt: Date = new Date()
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
@Entity({ tableName: 'message_confirmations' })
|
|
250
|
+
@Index({ name: 'message_confirmations_message_idx', properties: ['messageId'] })
|
|
251
|
+
@Index({ name: 'message_confirmations_scope_idx', properties: ['tenantId', 'organizationId'] })
|
|
252
|
+
@Unique({ name: 'message_confirmations_message_unique', properties: ['messageId'] })
|
|
253
|
+
export class MessageConfirmation {
|
|
254
|
+
[OptionalProps]?: 'confirmed' | 'createdAt' | 'updatedAt'
|
|
255
|
+
|
|
256
|
+
@PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
|
|
257
|
+
id!: string
|
|
258
|
+
|
|
259
|
+
@Property({ name: 'message_id', type: 'uuid' })
|
|
260
|
+
messageId!: string
|
|
261
|
+
|
|
262
|
+
@Property({ name: 'tenant_id', type: 'uuid' })
|
|
263
|
+
tenantId!: string
|
|
264
|
+
|
|
265
|
+
@Property({ name: 'organization_id', type: 'uuid', nullable: true })
|
|
266
|
+
organizationId?: string | null
|
|
267
|
+
|
|
268
|
+
@Property({ name: 'confirmed', type: 'boolean' })
|
|
269
|
+
confirmed: boolean = true
|
|
270
|
+
|
|
271
|
+
@Property({ name: 'confirmed_by_user_id', type: 'uuid', nullable: true })
|
|
272
|
+
confirmedByUserId?: string | null
|
|
273
|
+
|
|
274
|
+
@Property({ name: 'confirmed_at', type: Date, nullable: true })
|
|
275
|
+
confirmedAt?: Date | null
|
|
276
|
+
|
|
277
|
+
@Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
|
|
278
|
+
createdAt: Date = new Date()
|
|
279
|
+
|
|
280
|
+
@Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
|
|
281
|
+
updatedAt: Date = new Date()
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export default [Message, MessageRecipient, MessageObject, MessageAccessToken, MessageConfirmation]
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
function collectDuplicateRecipientIds(
|
|
4
|
+
recipients: Array<{ userId: string }>,
|
|
5
|
+
): string[] {
|
|
6
|
+
const seen = new Set<string>()
|
|
7
|
+
const duplicates = new Set<string>()
|
|
8
|
+
for (const recipient of recipients) {
|
|
9
|
+
if (seen.has(recipient.userId)) {
|
|
10
|
+
duplicates.add(recipient.userId)
|
|
11
|
+
continue
|
|
12
|
+
}
|
|
13
|
+
seen.add(recipient.userId)
|
|
14
|
+
}
|
|
15
|
+
return Array.from(duplicates)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function validateDefaultWithObjectsPayload(
|
|
19
|
+
value: {
|
|
20
|
+
type?: string
|
|
21
|
+
objects?: Array<{ actionRequired?: boolean; actionType?: string; actionLabel?: string }>
|
|
22
|
+
},
|
|
23
|
+
ctx: z.RefinementCtx,
|
|
24
|
+
): void {
|
|
25
|
+
if (value.type !== 'messages.defaultWithObjects') return
|
|
26
|
+
|
|
27
|
+
if (!Array.isArray(value.objects) || value.objects.length === 0) {
|
|
28
|
+
ctx.addIssue({
|
|
29
|
+
code: z.ZodIssueCode.custom,
|
|
30
|
+
path: ['objects'],
|
|
31
|
+
message: 'at least one object is required for messages.defaultWithObjects',
|
|
32
|
+
})
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
value.objects.forEach((object, index) => {
|
|
37
|
+
if (object.actionRequired === true) {
|
|
38
|
+
ctx.addIssue({
|
|
39
|
+
code: z.ZodIssueCode.custom,
|
|
40
|
+
path: ['objects', index, 'actionRequired'],
|
|
41
|
+
message: 'actionRequired must be false for messages.defaultWithObjects',
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
if (typeof object.actionType === 'string' && object.actionType.trim().length > 0) {
|
|
45
|
+
ctx.addIssue({
|
|
46
|
+
code: z.ZodIssueCode.custom,
|
|
47
|
+
path: ['objects', index, 'actionType'],
|
|
48
|
+
message: 'actionType is not allowed for messages.defaultWithObjects',
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
if (typeof object.actionLabel === 'string' && object.actionLabel.trim().length > 0) {
|
|
52
|
+
ctx.addIssue({
|
|
53
|
+
code: z.ZodIssueCode.custom,
|
|
54
|
+
path: ['objects', index, 'actionLabel'],
|
|
55
|
+
message: 'actionLabel is not allowed for messages.defaultWithObjects',
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const messageRecipientSchema = z.object({
|
|
62
|
+
userId: z.string().uuid(),
|
|
63
|
+
type: z.enum(['to', 'cc', 'bcc']).optional().default('to'),
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
export const messageObjectSchema = z.object({
|
|
67
|
+
entityModule: z.string().min(1),
|
|
68
|
+
entityType: z.string().min(1),
|
|
69
|
+
entityId: z.string().uuid(),
|
|
70
|
+
actionRequired: z.boolean().optional().default(false),
|
|
71
|
+
actionType: z.string().optional(),
|
|
72
|
+
actionLabel: z.string().optional(),
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
export const messageActionSchema = z.object({
|
|
76
|
+
id: z.string().min(1),
|
|
77
|
+
label: z.string().min(1),
|
|
78
|
+
labelKey: z.string().optional(),
|
|
79
|
+
variant: z.enum(['default', 'secondary', 'destructive', 'outline', 'ghost']).optional(),
|
|
80
|
+
icon: z.string().optional(),
|
|
81
|
+
commandId: z.string().optional(),
|
|
82
|
+
href: z.string().optional(),
|
|
83
|
+
isTerminal: z.boolean().optional(),
|
|
84
|
+
confirmRequired: z.boolean().optional(),
|
|
85
|
+
confirmMessage: z.string().optional(),
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
export const messageActionDataSchema = z.object({
|
|
89
|
+
actions: z.array(messageActionSchema),
|
|
90
|
+
primaryActionId: z.string().optional(),
|
|
91
|
+
expiresAt: z.string().datetime().optional(),
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
export const composeMessageSchema = z.object({
|
|
95
|
+
type: z.string().optional().default('default'),
|
|
96
|
+
visibility: z.enum(['public', 'internal']).nullable().optional(),
|
|
97
|
+
sourceEntityType: z.string().min(1).optional(),
|
|
98
|
+
sourceEntityId: z.string().uuid().optional(),
|
|
99
|
+
externalEmail: z.string().email().optional(),
|
|
100
|
+
externalName: z.string().min(1).max(255).optional(),
|
|
101
|
+
recipients: z.array(messageRecipientSchema).max(100).optional().default([]),
|
|
102
|
+
subject: z.string().max(500).optional().default(''),
|
|
103
|
+
body: z.string().max(50000).optional().default(''),
|
|
104
|
+
bodyFormat: z.enum(['text', 'markdown']).optional().default('text'),
|
|
105
|
+
priority: z.enum(['low', 'normal', 'high', 'urgent']).optional().default('normal'),
|
|
106
|
+
objects: z.array(messageObjectSchema).optional(),
|
|
107
|
+
attachmentIds: z.array(z.string().uuid()).optional(),
|
|
108
|
+
attachmentRecordId: z.string().min(1).max(255).optional(),
|
|
109
|
+
actionData: messageActionDataSchema.optional(),
|
|
110
|
+
sendViaEmail: z.boolean().optional().default(false),
|
|
111
|
+
parentMessageId: z.string().uuid().optional(),
|
|
112
|
+
isDraft: z.boolean().optional().default(false),
|
|
113
|
+
}).superRefine((value, ctx) => {
|
|
114
|
+
const isDraft = value.isDraft ?? false
|
|
115
|
+
const visibility = value.visibility ?? 'internal'
|
|
116
|
+
const recipientCount = value.recipients.length
|
|
117
|
+
const hasExternalEmail = Boolean(value.externalEmail?.trim())
|
|
118
|
+
const hasSubject = value.subject.trim().length > 0
|
|
119
|
+
const hasBody = value.body.trim().length > 0
|
|
120
|
+
|
|
121
|
+
if (!isDraft) {
|
|
122
|
+
if (visibility === 'public') {
|
|
123
|
+
if (!hasExternalEmail) {
|
|
124
|
+
ctx.addIssue({
|
|
125
|
+
code: z.ZodIssueCode.custom,
|
|
126
|
+
path: ['externalEmail'],
|
|
127
|
+
message: 'externalEmail is required when visibility is public',
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
if (recipientCount > 0) {
|
|
131
|
+
ctx.addIssue({
|
|
132
|
+
code: z.ZodIssueCode.custom,
|
|
133
|
+
path: ['recipients'],
|
|
134
|
+
message: 'recipients must be empty when visibility is public',
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
} else if (recipientCount === 0) {
|
|
138
|
+
ctx.addIssue({
|
|
139
|
+
code: z.ZodIssueCode.custom,
|
|
140
|
+
path: ['recipients'],
|
|
141
|
+
message: 'at least one recipient is required when visibility is internal',
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!hasSubject) {
|
|
146
|
+
ctx.addIssue({
|
|
147
|
+
code: z.ZodIssueCode.custom,
|
|
148
|
+
path: ['subject'],
|
|
149
|
+
message: 'subject is required',
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
if (!hasBody) {
|
|
153
|
+
ctx.addIssue({
|
|
154
|
+
code: z.ZodIssueCode.custom,
|
|
155
|
+
path: ['body'],
|
|
156
|
+
message: 'body is required',
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients)
|
|
162
|
+
if (duplicateRecipientIds.length > 0) {
|
|
163
|
+
ctx.addIssue({
|
|
164
|
+
code: z.ZodIssueCode.custom,
|
|
165
|
+
path: ['recipients'],
|
|
166
|
+
message: 'recipient user ids must be unique',
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
validateDefaultWithObjectsPayload(value, ctx)
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
export const updateDraftSchema = z.object({
|
|
174
|
+
type: z.string().optional(),
|
|
175
|
+
visibility: z.enum(['public', 'internal']).nullable().optional(),
|
|
176
|
+
sourceEntityType: z.string().min(1).optional(),
|
|
177
|
+
sourceEntityId: z.string().uuid().optional(),
|
|
178
|
+
externalEmail: z.string().email().optional(),
|
|
179
|
+
externalName: z.string().min(1).max(255).optional(),
|
|
180
|
+
recipients: z.array(messageRecipientSchema).optional(),
|
|
181
|
+
subject: z.string().min(1).max(500).optional(),
|
|
182
|
+
body: z.string().min(1).max(50000).optional(),
|
|
183
|
+
bodyFormat: z.enum(['text', 'markdown']).optional(),
|
|
184
|
+
priority: z.enum(['low', 'normal', 'high', 'urgent']).optional(),
|
|
185
|
+
objects: z.array(messageObjectSchema).optional(),
|
|
186
|
+
attachmentIds: z.array(z.string().uuid()).optional(),
|
|
187
|
+
actionData: messageActionDataSchema.optional(),
|
|
188
|
+
sendViaEmail: z.boolean().optional(),
|
|
189
|
+
}).superRefine((value, ctx) => {
|
|
190
|
+
if (value.recipients) {
|
|
191
|
+
const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients)
|
|
192
|
+
if (duplicateRecipientIds.length > 0) {
|
|
193
|
+
ctx.addIssue({
|
|
194
|
+
code: z.ZodIssueCode.custom,
|
|
195
|
+
path: ['recipients'],
|
|
196
|
+
message: 'recipient user ids must be unique',
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
validateDefaultWithObjectsPayload(value, ctx)
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
export const listMessagesSchema = z.object({
|
|
205
|
+
folder: z.enum(['inbox', 'sent', 'drafts', 'archived', 'all']).optional().default('inbox'),
|
|
206
|
+
status: z.enum(['unread', 'read', 'archived']).optional(),
|
|
207
|
+
type: z.string().optional(),
|
|
208
|
+
visibility: z.enum(['public', 'internal']).optional(),
|
|
209
|
+
sourceEntityType: z.string().optional(),
|
|
210
|
+
sourceEntityId: z.string().uuid().optional(),
|
|
211
|
+
externalEmail: z.string().email().optional(),
|
|
212
|
+
hasObjects: z.coerce.boolean().optional(),
|
|
213
|
+
hasAttachments: z.coerce.boolean().optional(),
|
|
214
|
+
hasActions: z.coerce.boolean().optional(),
|
|
215
|
+
senderId: z.string().uuid().optional(),
|
|
216
|
+
search: z.string().max(200).optional(),
|
|
217
|
+
since: z.string().datetime().optional(),
|
|
218
|
+
page: z.coerce.number().int().min(1).optional().default(1),
|
|
219
|
+
pageSize: z.coerce.number().int().min(1).max(100).optional().default(20),
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
export const forwardMessageSchema = z.object({
|
|
223
|
+
recipients: z.array(messageRecipientSchema).min(1).max(100),
|
|
224
|
+
body: z.string().max(50000).optional(),
|
|
225
|
+
additionalBody: z.string().max(10000).optional(),
|
|
226
|
+
includeAttachments: z.boolean().optional().default(true),
|
|
227
|
+
sendViaEmail: z.boolean().optional().default(false),
|
|
228
|
+
}).superRefine((value, ctx) => {
|
|
229
|
+
const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients)
|
|
230
|
+
if (duplicateRecipientIds.length > 0) {
|
|
231
|
+
ctx.addIssue({
|
|
232
|
+
code: z.ZodIssueCode.custom,
|
|
233
|
+
path: ['recipients'],
|
|
234
|
+
message: 'recipient user ids must be unique',
|
|
235
|
+
})
|
|
236
|
+
}
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
export const replyMessageSchema = z.object({
|
|
240
|
+
body: z.string().min(1).max(50000),
|
|
241
|
+
bodyFormat: z.enum(['text', 'markdown']).optional().default('text'),
|
|
242
|
+
recipients: z.array(messageRecipientSchema).max(100).optional(),
|
|
243
|
+
attachmentIds: z.array(z.string().uuid()).optional(),
|
|
244
|
+
attachmentRecordId: z.string().min(1).max(255).optional(),
|
|
245
|
+
replyAll: z.boolean().optional().default(false),
|
|
246
|
+
sendViaEmail: z.boolean().optional().default(false),
|
|
247
|
+
}).superRefine((value, ctx) => {
|
|
248
|
+
if (!value.recipients) return
|
|
249
|
+
const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients)
|
|
250
|
+
if (duplicateRecipientIds.length > 0) {
|
|
251
|
+
ctx.addIssue({
|
|
252
|
+
code: z.ZodIssueCode.custom,
|
|
253
|
+
path: ['recipients'],
|
|
254
|
+
message: 'recipient user ids must be unique',
|
|
255
|
+
})
|
|
256
|
+
}
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
export const executeActionSchema = z.object({
|
|
260
|
+
messageId: z.string().uuid(),
|
|
261
|
+
actionId: z.string().min(1),
|
|
262
|
+
payload: z.record(z.string(), z.unknown()).optional(),
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
export const confirmMessageSchema = z.object({
|
|
266
|
+
messageId: z.string().uuid(),
|
|
267
|
+
tenantId: z.string().uuid().optional(),
|
|
268
|
+
organizationId: z.string().uuid().nullable().optional(),
|
|
269
|
+
confirmed: z.boolean().optional().default(true),
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
export const messageObjectTypesQuerySchema = z.object({
|
|
273
|
+
messageType: z.string().min(1),
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
export const attachmentIdsPayloadSchema = z.object({
|
|
277
|
+
attachmentIds: z.array(z.string().uuid()).min(1).max(100),
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
export const unlinkAttachmentPayloadSchema = z.object({
|
|
281
|
+
attachmentId: z.string().uuid().optional(),
|
|
282
|
+
attachmentIds: z.array(z.string().uuid()).min(1).max(100).optional(),
|
|
283
|
+
}).refine(
|
|
284
|
+
(value) => Boolean(value.attachmentId || value.attachmentIds?.length),
|
|
285
|
+
{ message: 'attachmentId or attachmentIds is required' }
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
export type ComposeMessageInput = z.infer<typeof composeMessageSchema>
|
|
289
|
+
export type UpdateDraftInput = z.infer<typeof updateDraftSchema>
|
|
290
|
+
export type ListMessagesInput = z.infer<typeof listMessagesSchema>
|
|
291
|
+
export type ForwardMessageInput = z.infer<typeof forwardMessageSchema>
|
|
292
|
+
export type ReplyMessageInput = z.infer<typeof replyMessageSchema>
|
|
293
|
+
export type ExecuteActionInput = z.infer<typeof executeActionSchema>
|
|
294
|
+
export type ConfirmMessageInput = z.infer<typeof confirmMessageSchema>
|
|
295
|
+
export type MessageObjectTypesQueryInput = z.infer<typeof messageObjectTypesQuerySchema>
|
|
296
|
+
export type AttachmentIdsPayload = z.infer<typeof attachmentIdsPayloadSchema>
|
|
297
|
+
export type UnlinkAttachmentPayload = z.infer<typeof unlinkAttachmentPayloadSchema>
|