@open-mercato/core 0.6.6-develop.6465.1.019f0fb26f → 0.6.6-develop.6471.1.9ab5bdd79a
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/bootstrap.js +13 -11
- package/dist/bootstrap.js.map +2 -2
- package/dist/helpers/integration/queue-runner.js +4 -2
- package/dist/helpers/integration/queue-runner.js.map +2 -2
- package/dist/modules/api_keys/services/apiKeyService.js +5 -3
- package/dist/modules/api_keys/services/apiKeyService.js.map +2 -2
- package/dist/modules/attachments/api/image/[id]/[[...slug]]/route.js +4 -2
- package/dist/modules/attachments/api/image/[id]/[[...slug]]/route.js.map +2 -2
- package/dist/modules/attachments/api/library/[id]/route.js +3 -1
- package/dist/modules/attachments/api/library/[id]/route.js.map +2 -2
- package/dist/modules/attachments/api/route.js +8 -6
- package/dist/modules/attachments/api/route.js.map +2 -2
- package/dist/modules/attachments/components/AttachmentPartitionSettings.js +5 -3
- package/dist/modules/attachments/components/AttachmentPartitionSettings.js.map +2 -2
- package/dist/modules/attachments/lib/assignmentDetails.js +3 -1
- package/dist/modules/attachments/lib/assignmentDetails.js.map +2 -2
- package/dist/modules/attachments/lib/drivers/driverFactory.js +3 -1
- package/dist/modules/attachments/lib/drivers/driverFactory.js.map +2 -2
- package/dist/modules/attachments/lib/ocrQueue.js +10 -11
- package/dist/modules/attachments/lib/ocrQueue.js.map +2 -2
- package/dist/modules/attachments/lib/ocrService.js +6 -4
- package/dist/modules/attachments/lib/ocrService.js.map +2 -2
- package/dist/modules/audit_logs/api/audit-logs/actions/redo/route.js +3 -1
- package/dist/modules/audit_logs/api/audit-logs/actions/redo/route.js.map +2 -2
- package/dist/modules/audit_logs/api/audit-logs/actions/undo/route.js +3 -1
- package/dist/modules/audit_logs/api/audit-logs/actions/undo/route.js.map +2 -2
- package/dist/modules/audit_logs/backend/audit-logs/page.js +3 -1
- package/dist/modules/audit_logs/backend/audit-logs/page.js.map +2 -2
- package/dist/modules/audit_logs/components/AuditLogsActions.js +4 -2
- package/dist/modules/audit_logs/components/AuditLogsActions.js.map +2 -2
- package/dist/modules/audit_logs/services/accessLogService.js +4 -2
- package/dist/modules/audit_logs/services/accessLogService.js.map +2 -2
- package/dist/modules/audit_logs/services/actionLogService.js +7 -5
- package/dist/modules/audit_logs/services/actionLogService.js.map +3 -3
- package/dist/modules/auth/api/profile/route.js +4 -2
- package/dist/modules/auth/api/profile/route.js.map +2 -2
- package/dist/modules/auth/api/reset/confirm.js +3 -1
- package/dist/modules/auth/api/reset/confirm.js.map +2 -2
- package/dist/modules/auth/api/reset.js +4 -2
- package/dist/modules/auth/api/reset.js.map +2 -2
- package/dist/modules/auth/api/roles/route.js +3 -1
- package/dist/modules/auth/api/roles/route.js.map +2 -2
- package/dist/modules/auth/api/sidebar/variants/route.js +3 -1
- package/dist/modules/auth/api/sidebar/variants/route.js.map +2 -2
- package/dist/modules/auth/api/users/resend-invite/route.js +4 -2
- package/dist/modules/auth/api/users/resend-invite/route.js.map +2 -2
- package/dist/modules/auth/api/users/route.js +3 -1
- package/dist/modules/auth/api/users/route.js.map +2 -2
- package/dist/modules/auth/backend/auth/profile/page.js +3 -1
- package/dist/modules/auth/backend/auth/profile/page.js.map +2 -2
- package/dist/modules/auth/backend/profile/change-password/page.js +3 -1
- package/dist/modules/auth/backend/profile/change-password/page.js.map +2 -2
- package/dist/modules/auth/backend/users/[id]/edit/page.js +5 -3
- package/dist/modules/auth/backend/users/[id]/edit/page.js.map +2 -2
- package/dist/modules/auth/backend/users/create/page.js +4 -2
- package/dist/modules/auth/backend/users/create/page.js.map +2 -2
- package/dist/modules/auth/cli.js +10 -0
- package/dist/modules/auth/cli.js.map +2 -2
- package/dist/modules/auth/commands/users.js +4 -2
- package/dist/modules/auth/commands/users.js.map +2 -2
- package/dist/modules/auth/lib/consentIntegrity.js +3 -3
- package/dist/modules/auth/lib/consentIntegrity.js.map +2 -2
- package/dist/modules/auth/lib/setup-app.js +9 -10
- package/dist/modules/auth/lib/setup-app.js.map +2 -2
- package/dist/modules/auth/lib/tenantAccess.js +3 -1
- package/dist/modules/auth/lib/tenantAccess.js.map +2 -2
- package/dist/modules/auth/lib/tokenHash.js +3 -3
- package/dist/modules/auth/lib/tokenHash.js.map +2 -2
- package/dist/modules/business_rules/api/rules/route.js +4 -2
- package/dist/modules/business_rules/api/rules/route.js.map +2 -2
- package/dist/modules/business_rules/lib/expression-evaluator.js +7 -5
- package/dist/modules/business_rules/lib/expression-evaluator.js.map +2 -2
- package/dist/modules/business_rules/lib/rule-engine.js +5 -3
- package/dist/modules/business_rules/lib/rule-engine.js.map +2 -2
- package/dist/modules/business_rules/lib/rule-evaluator.js +11 -12
- package/dist/modules/business_rules/lib/rule-evaluator.js.map +2 -2
- package/dist/modules/business_rules/subscribers/crud-rule-trigger.js +3 -1
- package/dist/modules/business_rules/subscribers/crud-rule-trigger.js.map +2 -2
- package/dist/modules/business_rules/subscribers/rule-execution-failed-notification.js +3 -1
- package/dist/modules/business_rules/subscribers/rule-execution-failed-notification.js.map +2 -2
- package/dist/modules/catalog/ai-agents-context.js +4 -5
- package/dist/modules/catalog/ai-agents-context.js.map +2 -2
- package/dist/modules/catalog/ai-tools/_shared.js +3 -1
- package/dist/modules/catalog/ai-tools/_shared.js.map +2 -2
- package/dist/modules/catalog/ai-tools/authoring-pack.js +3 -1
- package/dist/modules/catalog/ai-tools/authoring-pack.js.map +2 -2
- package/dist/modules/catalog/ai-tools/merchandising-pack.js +3 -1
- package/dist/modules/catalog/ai-tools/merchandising-pack.js.map +2 -2
- package/dist/modules/catalog/api/dictionaries/[key]/route.js +3 -1
- package/dist/modules/catalog/api/dictionaries/[key]/route.js.map +2 -2
- package/dist/modules/catalog/api/prices/route.js +3 -1
- package/dist/modules/catalog/api/prices/route.js.map +2 -2
- package/dist/modules/catalog/api/products/route.js +5 -3
- package/dist/modules/catalog/api/products/route.js.map +2 -2
- package/dist/modules/catalog/api/settings/route.js +4 -2
- package/dist/modules/catalog/api/settings/route.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js +14 -12
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js +8 -6
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/create/page.js +5 -3
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/create/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/create/page.js +5 -6
- package/dist/modules/catalog/backend/catalog/products/create/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/optionSchemaClient.js +3 -1
- package/dist/modules/catalog/backend/catalog/products/optionSchemaClient.js.map +2 -2
- package/dist/modules/catalog/components/PriceKindSettings.js +5 -3
- package/dist/modules/catalog/components/PriceKindSettings.js.map +2 -2
- package/dist/modules/catalog/components/UnitPriceDisplaySettings.js +4 -2
- package/dist/modules/catalog/components/UnitPriceDisplaySettings.js.map +2 -2
- package/dist/modules/catalog/inbox-actions.js +4 -2
- package/dist/modules/catalog/inbox-actions.js.map +2 -2
- package/dist/modules/catalog/seed/examples.js +4 -5
- package/dist/modules/catalog/seed/examples.js.map +2 -2
- package/dist/modules/catalog/subscribers/low-stock-notification.js +3 -1
- package/dist/modules/catalog/subscribers/low-stock-notification.js.map +2 -2
- package/dist/modules/catalog/widgets/injection/product-seo/state.js +3 -1
- package/dist/modules/catalog/widgets/injection/product-seo/state.js.map +2 -2
- package/dist/modules/communication_channels/api/get/oauth/[provider]/callback/route.js +12 -11
- package/dist/modules/communication_channels/api/get/oauth/[provider]/callback/route.js.map +2 -2
- package/dist/modules/communication_channels/api/post/channels/[id]/import-history/route.js +3 -1
- package/dist/modules/communication_channels/api/post/channels/[id]/import-history/route.js.map +2 -2
- package/dist/modules/communication_channels/api/post/channels/[id]/push/register/route.js +3 -1
- package/dist/modules/communication_channels/api/post/channels/[id]/push/register/route.js.map +2 -2
- package/dist/modules/communication_channels/api/post/webhook/[provider]/route.js +5 -3
- package/dist/modules/communication_channels/api/post/webhook/[provider]/route.js.map +2 -2
- package/dist/modules/communication_channels/api/post/webhooks/gmail/route.js +6 -6
- package/dist/modules/communication_channels/api/post/webhooks/gmail/route.js.map +2 -2
- package/dist/modules/communication_channels/commands/connect-credential-channel.js +4 -6
- package/dist/modules/communication_channels/commands/connect-credential-channel.js.map +2 -2
- package/dist/modules/communication_channels/commands/delete-channel.js +3 -3
- package/dist/modules/communication_channels/commands/delete-channel.js.map +2 -2
- package/dist/modules/communication_channels/commands/deliver-outbound-message.js +4 -5
- package/dist/modules/communication_channels/commands/deliver-outbound-message.js.map +2 -2
- package/dist/modules/communication_channels/commands/disconnect-channel.js +3 -3
- package/dist/modules/communication_channels/commands/disconnect-channel.js.map +2 -2
- package/dist/modules/communication_channels/commands/ingest-inbound-message.js +5 -12
- package/dist/modules/communication_channels/commands/ingest-inbound-message.js.map +2 -2
- package/dist/modules/communication_channels/commands/push-unregister.js +3 -3
- package/dist/modules/communication_channels/commands/push-unregister.js.map +2 -2
- package/dist/modules/communication_channels/commands/reassign-conversation.js +5 -3
- package/dist/modules/communication_channels/commands/reassign-conversation.js.map +2 -2
- package/dist/modules/communication_channels/lib/dead-letter.js +3 -3
- package/dist/modules/communication_channels/lib/dead-letter.js.map +2 -2
- package/dist/modules/communication_channels/lib/email-mime.js +4 -6
- package/dist/modules/communication_channels/lib/email-mime.js.map +2 -2
- package/dist/modules/communication_channels/lib/oauth-client-config.js +5 -3
- package/dist/modules/communication_channels/lib/oauth-client-config.js.map +2 -2
- package/dist/modules/communication_channels/lib/send-as-user.js +3 -1
- package/dist/modules/communication_channels/lib/send-as-user.js.map +2 -2
- package/dist/modules/communication_channels/lib/thread-token.js +4 -2
- package/dist/modules/communication_channels/lib/thread-token.js.map +2 -2
- package/dist/modules/communication_channels/setup.js +3 -4
- package/dist/modules/communication_channels/setup.js.map +2 -2
- package/dist/modules/communication_channels/workers/channel-import-history.js +4 -6
- package/dist/modules/communication_channels/workers/channel-import-history.js.map +2 -2
- package/dist/modules/communication_channels/workers/gmail-history-sync.js +8 -16
- package/dist/modules/communication_channels/workers/gmail-history-sync.js.map +2 -2
- package/dist/modules/communication_channels/workers/gmail-renew-watch.js +5 -7
- package/dist/modules/communication_channels/workers/gmail-renew-watch.js.map +2 -2
- package/dist/modules/communication_channels/workers/outbound-delivery.js +6 -12
- package/dist/modules/communication_channels/workers/outbound-delivery.js.map +2 -2
- package/dist/modules/communication_channels/workers/poll-channel.js +7 -15
- package/dist/modules/communication_channels/workers/poll-channel.js.map +2 -2
- package/dist/modules/communication_channels/workers/poll-tick.js +5 -6
- package/dist/modules/communication_channels/workers/poll-tick.js.map +2 -2
- package/dist/modules/communication_channels/workers/reaction-processor.js +5 -9
- package/dist/modules/communication_channels/workers/reaction-processor.js.map +2 -2
- package/dist/modules/configs/api/cache/route.js +4 -2
- package/dist/modules/configs/api/cache/route.js.map +2 -2
- package/dist/modules/configs/api/system-status/route.js +4 -2
- package/dist/modules/configs/api/system-status/route.js.map +2 -2
- package/dist/modules/configs/api/upgrade-actions/route.js +4 -2
- package/dist/modules/configs/api/upgrade-actions/route.js.map +2 -2
- package/dist/modules/configs/components/ModuleTelemetryPanel.js +3 -1
- package/dist/modules/configs/components/ModuleTelemetryPanel.js.map +2 -2
- package/dist/modules/configs/lib/touchGeneratedBarrels.js +2 -1
- package/dist/modules/configs/lib/touchGeneratedBarrels.js.map +2 -2
- package/dist/modules/configs/services/upgradeActionsService.js +6 -3
- package/dist/modules/configs/services/upgradeActionsService.js.map +2 -2
- package/dist/modules/currencies/components/CurrencyFetchingConfig.js +3 -1
- package/dist/modules/currencies/components/CurrencyFetchingConfig.js.map +2 -2
- package/dist/modules/currencies/lib/exchangeRateFormConfig.js +3 -1
- package/dist/modules/currencies/lib/exchangeRateFormConfig.js.map +2 -2
- package/dist/modules/currencies/services/providers/nbp.js +6 -4
- package/dist/modules/currencies/services/providers/nbp.js.map +2 -2
- package/dist/modules/currencies/services/providers/raiffeisen.js +7 -7
- package/dist/modules/currencies/services/providers/raiffeisen.js.map +2 -2
- package/dist/modules/customer_accounts/api/domain-resolve/all.js +6 -5
- package/dist/modules/customer_accounts/api/domain-resolve/all.js.map +2 -2
- package/dist/modules/customer_accounts/api/signup.js +4 -2
- package/dist/modules/customer_accounts/api/signup.js.map +2 -2
- package/dist/modules/customer_accounts/lib/customerAuthServer.js +3 -1
- package/dist/modules/customer_accounts/lib/customerAuthServer.js.map +2 -2
- package/dist/modules/customer_accounts/subscribers/autoLinkCrm.js +3 -1
- package/dist/modules/customer_accounts/subscribers/autoLinkCrm.js.map +2 -2
- package/dist/modules/customer_accounts/subscribers/autoLinkCrmReverse.js +3 -1
- package/dist/modules/customer_accounts/subscribers/autoLinkCrmReverse.js.map +2 -2
- package/dist/modules/customer_accounts/subscribers/unlinkOnCompanyDelete.js +3 -1
- package/dist/modules/customer_accounts/subscribers/unlinkOnCompanyDelete.js.map +2 -2
- package/dist/modules/customer_accounts/subscribers/unlinkOnPersonDelete.js +3 -1
- package/dist/modules/customer_accounts/subscribers/unlinkOnPersonDelete.js.map +2 -2
- package/dist/modules/customers/ai-agents-context.js +4 -5
- package/dist/modules/customers/ai-agents-context.js.map +2 -2
- package/dist/modules/customers/api/activities/route.js +6 -4
- package/dist/modules/customers/api/activities/route.js.map +2 -2
- package/dist/modules/customers/api/comments/route.js +3 -1
- package/dist/modules/customers/api/comments/route.js.map +2 -2
- package/dist/modules/customers/api/companies/[id]/people/route.js +3 -1
- package/dist/modules/customers/api/companies/[id]/people/route.js.map +2 -2
- package/dist/modules/customers/api/companies/[id]/route.js +5 -3
- package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/companies/route.js +5 -3
- package/dist/modules/customers/api/companies/route.js.map +2 -2
- package/dist/modules/customers/api/dashboard/widgets/customer-todos/route.js +3 -1
- package/dist/modules/customers/api/dashboard/widgets/customer-todos/route.js.map +2 -2
- package/dist/modules/customers/api/dashboard/widgets/new-customers/route.js +3 -1
- package/dist/modules/customers/api/dashboard/widgets/new-customers/route.js.map +2 -2
- package/dist/modules/customers/api/dashboard/widgets/new-deals/route.js +3 -1
- package/dist/modules/customers/api/dashboard/widgets/new-deals/route.js.map +2 -2
- package/dist/modules/customers/api/dashboard/widgets/next-interactions/route.js +3 -1
- package/dist/modules/customers/api/dashboard/widgets/next-interactions/route.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/companies/route.js +3 -1
- package/dist/modules/customers/api/deals/[id]/companies/route.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/people/route.js +3 -1
- package/dist/modules/customers/api/deals/[id]/people/route.js.map +2 -2
- package/dist/modules/customers/api/deals/aggregate/route.js +3 -1
- package/dist/modules/customers/api/deals/aggregate/route.js.map +2 -2
- package/dist/modules/customers/api/deals/bulk-update-owner/route.js +7 -5
- package/dist/modules/customers/api/deals/bulk-update-owner/route.js.map +2 -2
- package/dist/modules/customers/api/deals/bulk-update-stage/route.js +7 -5
- package/dist/modules/customers/api/deals/bulk-update-stage/route.js.map +2 -2
- package/dist/modules/customers/api/deals/route.js +3 -1
- package/dist/modules/customers/api/deals/route.js.map +2 -2
- package/dist/modules/customers/api/deals/summary/route.js +3 -1
- package/dist/modules/customers/api/deals/summary/route.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js +4 -2
- package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/[kind]/route.js +5 -3
- package/dist/modules/customers/api/dictionaries/[kind]/route.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/cache.js +3 -1
- package/dist/modules/customers/api/dictionaries/cache.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/context.js +3 -1
- package/dist/modules/customers/api/dictionaries/context.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/currency/route.js +3 -1
- package/dist/modules/customers/api/dictionaries/currency/route.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/kind-settings/route.js +4 -2
- package/dist/modules/customers/api/dictionaries/kind-settings/route.js.map +2 -2
- package/dist/modules/customers/api/entity-roles-factory.js +7 -5
- package/dist/modules/customers/api/entity-roles-factory.js.map +2 -2
- package/dist/modules/customers/api/interactions/cancel/route.js +3 -1
- package/dist/modules/customers/api/interactions/cancel/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/complete/route.js +3 -1
- package/dist/modules/customers/api/interactions/complete/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/conflicts/route.js +3 -1
- package/dist/modules/customers/api/interactions/conflicts/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/counts/route.js +3 -1
- package/dist/modules/customers/api/interactions/counts/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/route.js +7 -4
- package/dist/modules/customers/api/interactions/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/tasks/route.js +3 -1
- package/dist/modules/customers/api/interactions/tasks/route.js.map +2 -2
- package/dist/modules/customers/api/labels/assign/route.js +3 -1
- package/dist/modules/customers/api/labels/assign/route.js.map +2 -2
- package/dist/modules/customers/api/labels/route.js +6 -3
- package/dist/modules/customers/api/labels/route.js.map +2 -2
- package/dist/modules/customers/api/labels/unassign/route.js +3 -1
- package/dist/modules/customers/api/labels/unassign/route.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/companies/enriched/route.js +3 -1
- package/dist/modules/customers/api/people/[id]/companies/enriched/route.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/route.js +5 -3
- package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/people/route.js +5 -3
- package/dist/modules/customers/api/people/route.js.map +2 -2
- package/dist/modules/customers/api/pipeline-stages/reorder/route.js +3 -1
- package/dist/modules/customers/api/pipeline-stages/reorder/route.js.map +2 -2
- package/dist/modules/customers/api/pipeline-stages/route.js +6 -4
- package/dist/modules/customers/api/pipeline-stages/route.js.map +2 -2
- package/dist/modules/customers/api/pipelines/route.js +6 -4
- package/dist/modules/customers/api/pipelines/route.js.map +2 -2
- package/dist/modules/customers/api/settings/address-format/route.js +4 -2
- package/dist/modules/customers/api/settings/address-format/route.js.map +2 -2
- package/dist/modules/customers/api/settings/dictionary-sort-modes/route.js +4 -2
- package/dist/modules/customers/api/settings/dictionary-sort-modes/route.js.map +2 -2
- package/dist/modules/customers/api/settings/stuck-threshold/route.js +4 -2
- package/dist/modules/customers/api/settings/stuck-threshold/route.js.map +2 -2
- package/dist/modules/customers/api/tags/assign/route.js +3 -1
- package/dist/modules/customers/api/tags/assign/route.js.map +2 -2
- package/dist/modules/customers/api/tags/unassign/route.js +3 -1
- package/dist/modules/customers/api/tags/unassign/route.js.map +2 -2
- package/dist/modules/customers/api/todos/route.js +6 -4
- package/dist/modules/customers/api/todos/route.js.map +2 -2
- package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js +5 -3
- package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealActivities.js +3 -1
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealActivities.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealClosure.js +3 -1
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealClosure.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/map/components/DealsMapCanvasImpl.js +4 -2
- package/dist/modules/customers/backend/customers/deals/map/components/DealsMapCanvasImpl.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/page.js +4 -2
- package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/people-v2/[id]/page.js +5 -3
- package/dist/modules/customers/backend/customers/people-v2/[id]/page.js.map +2 -2
- package/dist/modules/customers/commands/deals.js +3 -1
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/commands/dictionaries.js +3 -1
- package/dist/modules/customers/commands/dictionaries.js.map +2 -2
- package/dist/modules/customers/commands/interactions.js +4 -2
- package/dist/modules/customers/commands/interactions.js.map +2 -2
- package/dist/modules/customers/commands/shared.js +4 -2
- package/dist/modules/customers/commands/shared.js.map +2 -2
- package/dist/modules/customers/commands/todos.js +3 -1
- package/dist/modules/customers/commands/todos.js.map +2 -2
- package/dist/modules/customers/components/DictionarySettings.js +5 -3
- package/dist/modules/customers/components/DictionarySettings.js.map +2 -2
- package/dist/modules/customers/components/DictionarySortSettings.js +3 -1
- package/dist/modules/customers/components/DictionarySortSettings.js.map +2 -2
- package/dist/modules/customers/components/detail/ActivitiesCard.js +3 -1
- package/dist/modules/customers/components/detail/ActivitiesCard.js.map +2 -2
- package/dist/modules/customers/components/detail/ActivitiesDayStrip.js +3 -1
- package/dist/modules/customers/components/detail/ActivitiesDayStrip.js.map +2 -2
- package/dist/modules/customers/components/detail/ActivitiesSection.js +6 -4
- package/dist/modules/customers/components/detail/ActivitiesSection.js.map +2 -2
- package/dist/modules/customers/components/detail/ActivityCard.js +3 -1
- package/dist/modules/customers/components/detail/ActivityCard.js.map +2 -2
- package/dist/modules/customers/components/detail/ChangelogTab.js +3 -1
- package/dist/modules/customers/components/detail/ChangelogTab.js.map +2 -2
- package/dist/modules/customers/components/detail/CompanyCard.js +3 -1
- package/dist/modules/customers/components/detail/CompanyCard.js.map +2 -2
- package/dist/modules/customers/components/detail/ConfirmDealLostDialog.js +3 -1
- package/dist/modules/customers/components/detail/ConfirmDealLostDialog.js.map +2 -2
- package/dist/modules/customers/components/detail/EntityTagsDialog.js +3 -1
- package/dist/modules/customers/components/detail/EntityTagsDialog.js.map +2 -2
- package/dist/modules/customers/components/detail/InlineActivityComposer.js +3 -1
- package/dist/modules/customers/components/detail/InlineActivityComposer.js.map +2 -2
- package/dist/modules/customers/components/detail/ManageTagsDialog.js +3 -1
- package/dist/modules/customers/components/detail/ManageTagsDialog.js.map +2 -2
- package/dist/modules/customers/components/detail/RoleAssignmentRow.js +5 -3
- package/dist/modules/customers/components/detail/RoleAssignmentRow.js.map +2 -2
- package/dist/modules/customers/components/detail/RolesSection.js +4 -2
- package/dist/modules/customers/components/detail/RolesSection.js.map +2 -2
- package/dist/modules/customers/components/detail/hooks/useInteractionMutations.js +5 -3
- package/dist/modules/customers/components/detail/hooks/useInteractionMutations.js.map +2 -2
- package/dist/modules/customers/components/linking/LinkEntityDialog.js +4 -2
- package/dist/modules/customers/components/linking/LinkEntityDialog.js.map +2 -2
- package/dist/modules/customers/inbox-actions.js +3 -1
- package/dist/modules/customers/inbox-actions.js.map +2 -2
- package/dist/modules/customers/lib/bulkDeals.js +3 -1
- package/dist/modules/customers/lib/bulkDeals.js.map +2 -2
- package/dist/modules/customers/lib/dealClosureNotification.js +4 -2
- package/dist/modules/customers/lib/dealClosureNotification.js.map +2 -2
- package/dist/modules/customers/lib/dealStageTransitionTable.js +3 -1
- package/dist/modules/customers/lib/dealStageTransitionTable.js.map +2 -2
- package/dist/modules/customers/lib/interactionFeatureFlags.js +3 -1
- package/dist/modules/customers/lib/interactionFeatureFlags.js.map +2 -2
- package/dist/modules/customers/lib/todoCompatibility.js +3 -1
- package/dist/modules/customers/lib/todoCompatibility.js.map +2 -2
- package/dist/modules/customers/search.js +14 -7
- package/dist/modules/customers/search.js.map +2 -2
- package/dist/modules/customers/widgets/dashboard/customer-todos/widget.client.js +3 -1
- package/dist/modules/customers/widgets/dashboard/customer-todos/widget.client.js.map +2 -2
- package/dist/modules/customers/widgets/dashboard/new-customers/widget.client.js +3 -1
- package/dist/modules/customers/widgets/dashboard/new-customers/widget.client.js.map +2 -2
- package/dist/modules/customers/widgets/dashboard/new-deals/widget.client.js +3 -1
- package/dist/modules/customers/widgets/dashboard/new-deals/widget.client.js.map +2 -2
- package/dist/modules/customers/widgets/dashboard/next-interactions/widget.client.js +3 -1
- package/dist/modules/customers/widgets/dashboard/next-interactions/widget.client.js.map +2 -2
- package/dist/modules/dashboards/api/widgets/data/batch/route.js +3 -1
- package/dist/modules/dashboards/api/widgets/data/batch/route.js.map +2 -2
- package/dist/modules/dashboards/api/widgets/data/route.js +3 -1
- package/dist/modules/dashboards/api/widgets/data/route.js.map +2 -2
- package/dist/modules/dashboards/components/WidgetVisibilityEditor.js +5 -3
- package/dist/modules/dashboards/components/WidgetVisibilityEditor.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/aov-kpi/widget.client.js +3 -1
- package/dist/modules/dashboards/widgets/dashboard/aov-kpi/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/new-customers-kpi/widget.client.js +3 -1
- package/dist/modules/dashboards/widgets/dashboard/new-customers-kpi/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/orders-by-status/widget.client.js +3 -1
- package/dist/modules/dashboards/widgets/dashboard/orders-by-status/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/orders-kpi/widget.client.js +3 -1
- package/dist/modules/dashboards/widgets/dashboard/orders-kpi/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/pipeline-summary/widget.client.js +3 -1
- package/dist/modules/dashboards/widgets/dashboard/pipeline-summary/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/revenue-kpi/widget.client.js +3 -1
- package/dist/modules/dashboards/widgets/dashboard/revenue-kpi/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/revenue-trend/widget.client.js +3 -1
- package/dist/modules/dashboards/widgets/dashboard/revenue-trend/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/sales-by-region/widget.client.js +3 -1
- package/dist/modules/dashboards/widgets/dashboard/sales-by-region/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/top-customers/widget.client.js +3 -1
- package/dist/modules/dashboards/widgets/dashboard/top-customers/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/top-products/widget.client.js +3 -1
- package/dist/modules/dashboards/widgets/dashboard/top-products/widget.client.js.map +2 -2
- package/dist/modules/data_sync/api/run.js +3 -1
- package/dist/modules/data_sync/api/run.js.map +2 -2
- package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js +1 -1
- package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js.map +2 -2
- package/dist/modules/data_sync/lib/adapter-registry.js +11 -4
- package/dist/modules/data_sync/lib/adapter-registry.js.map +2 -2
- package/dist/modules/data_sync/lib/sync-engine.js +23 -2
- package/dist/modules/data_sync/lib/sync-engine.js.map +2 -2
- package/dist/modules/data_sync/workers/sync-export.js +3 -1
- package/dist/modules/data_sync/workers/sync-export.js.map +2 -2
- package/dist/modules/data_sync/workers/sync-import.js +3 -1
- package/dist/modules/data_sync/workers/sync-import.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js +4 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/reorder/route.js +3 -1
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/reorder/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js +4 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/set-default/route.js +3 -1
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/set-default/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/route.js +5 -3
- package/dist/modules/dictionaries/api/[dictionaryId]/route.js.map +2 -2
- package/dist/modules/dictionaries/api/context.js +3 -1
- package/dist/modules/dictionaries/api/context.js.map +2 -2
- package/dist/modules/dictionaries/api/route.js +4 -2
- package/dist/modules/dictionaries/api/route.js.map +2 -2
- package/dist/modules/dictionaries/components/DictionariesManager.js +5 -3
- package/dist/modules/dictionaries/components/DictionariesManager.js.map +2 -2
- package/dist/modules/dictionaries/components/DictionaryEntriesEditor.js +4 -2
- package/dist/modules/dictionaries/components/DictionaryEntriesEditor.js.map +2 -2
- package/dist/modules/dictionaries/components/DictionaryEntrySelect.js +4 -2
- package/dist/modules/dictionaries/components/DictionaryEntrySelect.js.map +2 -2
- package/dist/modules/dictionaries/components/DictionarySelectControl.js +3 -1
- package/dist/modules/dictionaries/components/DictionarySelectControl.js.map +2 -2
- package/dist/modules/dictionaries/fields/dictionary.js +3 -1
- package/dist/modules/dictionaries/fields/dictionary.js.map +2 -2
- package/dist/modules/directory/api/organization-branding/route.js +3 -1
- package/dist/modules/directory/api/organization-branding/route.js.map +2 -2
- package/dist/modules/directory/api/organization-switcher/route.js +3 -1
- package/dist/modules/directory/api/organization-switcher/route.js.map +2 -2
- package/dist/modules/directory/commands/tenants.js +5 -3
- package/dist/modules/directory/commands/tenants.js.map +2 -2
- package/dist/modules/directory/utils/organizationScope.js +6 -4
- package/dist/modules/directory/utils/organizationScope.js.map +2 -2
- package/dist/modules/entities/api/definitions.cache.js +3 -1
- package/dist/modules/entities/api/definitions.cache.js.map +2 -2
- package/dist/modules/entities/api/definitions.js +7 -5
- package/dist/modules/entities/api/definitions.js.map +2 -2
- package/dist/modules/entities/api/records.js +4 -8
- package/dist/modules/entities/api/records.js.map +2 -2
- package/dist/modules/entities/components/EncryptionManager.js +3 -1
- package/dist/modules/entities/components/EncryptionManager.js.map +2 -2
- package/dist/modules/entities/lib/makeActivityRoute.js +3 -1
- package/dist/modules/entities/lib/makeActivityRoute.js.map +2 -2
- package/dist/modules/feature_toggles/api/overrides/route.js +3 -1
- package/dist/modules/feature_toggles/api/overrides/route.js.map +2 -2
- package/dist/modules/feature_toggles/lib/feature-flag-check.js +5 -9
- package/dist/modules/feature_toggles/lib/feature-flag-check.js.map +2 -2
- package/dist/modules/inbox_ops/api/emails/[id]/reprocess/route.js +4 -2
- package/dist/modules/inbox_ops/api/emails/[id]/reprocess/route.js.map +2 -2
- package/dist/modules/inbox_ops/api/emails/[id]/route.js +4 -2
- package/dist/modules/inbox_ops/api/emails/[id]/route.js.map +2 -2
- package/dist/modules/inbox_ops/api/emails/route.js +3 -1
- package/dist/modules/inbox_ops/api/emails/route.js.map +2 -2
- package/dist/modules/inbox_ops/api/extract/route.js +3 -1
- package/dist/modules/inbox_ops/api/extract/route.js.map +2 -2
- package/dist/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/route.js +3 -1
- package/dist/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/route.js.map +2 -2
- package/dist/modules/inbox_ops/api/proposals/[id]/replies/[replyId]/send/route.js +4 -2
- package/dist/modules/inbox_ops/api/proposals/[id]/replies/[replyId]/send/route.js.map +2 -2
- package/dist/modules/inbox_ops/api/proposals/counts/route.js +4 -2
- package/dist/modules/inbox_ops/api/proposals/counts/route.js.map +2 -2
- package/dist/modules/inbox_ops/api/proposals/route.js +3 -1
- package/dist/modules/inbox_ops/api/proposals/route.js.map +2 -2
- package/dist/modules/inbox_ops/api/routeHelpers.js +3 -1
- package/dist/modules/inbox_ops/api/routeHelpers.js.map +2 -2
- package/dist/modules/inbox_ops/api/settings/route.js +3 -1
- package/dist/modules/inbox_ops/api/settings/route.js.map +2 -2
- package/dist/modules/inbox_ops/api/webhook/inbound.js +7 -5
- package/dist/modules/inbox_ops/api/webhook/inbound.js.map +2 -2
- package/dist/modules/inbox_ops/lib/cache.js +4 -2
- package/dist/modules/inbox_ops/lib/cache.js.map +2 -2
- package/dist/modules/inbox_ops/lib/catalogLookup.js +3 -1
- package/dist/modules/inbox_ops/lib/catalogLookup.js.map +2 -2
- package/dist/modules/inbox_ops/lib/eventBus.js +3 -4
- package/dist/modules/inbox_ops/lib/eventBus.js.map +2 -2
- package/dist/modules/inbox_ops/lib/messagesIntegration.js +4 -8
- package/dist/modules/inbox_ops/lib/messagesIntegration.js.map +2 -2
- package/dist/modules/inbox_ops/subscribers/executionAuditor.js +3 -1
- package/dist/modules/inbox_ops/subscribers/executionAuditor.js.map +2 -2
- package/dist/modules/inbox_ops/subscribers/extractionWorker.js +10 -8
- package/dist/modules/inbox_ops/subscribers/extractionWorker.js.map +2 -2
- package/dist/modules/inbox_ops/subscribers/proposalNotifier.js +3 -1
- package/dist/modules/inbox_ops/subscribers/proposalNotifier.js.map +2 -2
- package/dist/modules/messages/api/[id]/route.js +3 -4
- package/dist/modules/messages/api/[id]/route.js.map +2 -2
- package/dist/modules/messages/commands/actions.js +3 -1
- package/dist/modules/messages/commands/actions.js.map +2 -2
- package/dist/modules/messages/components/MessagesInboxPageClient.js +3 -1
- package/dist/modules/messages/components/MessagesInboxPageClient.js.map +2 -2
- package/dist/modules/messages/lib/email-sender.js +3 -7
- package/dist/modules/messages/lib/email-sender.js.map +2 -2
- package/dist/modules/messages/lib/message-objects-registry.js +3 -1
- package/dist/modules/messages/lib/message-objects-registry.js.map +2 -2
- package/dist/modules/messages/lib/message-types-registry.js +3 -1
- package/dist/modules/messages/lib/message-types-registry.js.map +2 -2
- package/dist/modules/messages/workers/send-email.worker.js +6 -4
- package/dist/modules/messages/workers/send-email.worker.js.map +2 -2
- package/dist/modules/notifications/lib/notificationMapper.js +3 -4
- package/dist/modules/notifications/lib/notificationMapper.js.map +2 -2
- package/dist/modules/notifications/lib/notificationService.js +4 -5
- package/dist/modules/notifications/lib/notificationService.js.map +2 -2
- package/dist/modules/notifications/subscribers/deliver-notification.js +8 -13
- package/dist/modules/notifications/subscribers/deliver-notification.js.map +2 -2
- package/dist/modules/payment_gateways/api/webhook/[provider]/route.js +3 -1
- package/dist/modules/payment_gateways/api/webhook/[provider]/route.js.map +2 -2
- package/dist/modules/perspectives/services/perspectiveService.js +3 -3
- package/dist/modules/perspectives/services/perspectiveService.js.map +2 -2
- package/dist/modules/planner/api/access.js +3 -3
- package/dist/modules/planner/api/access.js.map +2 -2
- package/dist/modules/planner/api/availability-date-specific.js +3 -1
- package/dist/modules/planner/api/availability-date-specific.js.map +2 -2
- package/dist/modules/planner/api/availability-weekly.js +3 -1
- package/dist/modules/planner/api/availability-weekly.js.map +2 -2
- package/dist/modules/planner/backend/planner/availability-rulesets/page.js +4 -2
- package/dist/modules/planner/backend/planner/availability-rulesets/page.js.map +2 -2
- package/dist/modules/planner/components/AvailabilityRulesEditor.js +3 -1
- package/dist/modules/planner/components/AvailabilityRulesEditor.js.map +2 -2
- package/dist/modules/progress/api/jobs/route.js +3 -1
- package/dist/modules/progress/api/jobs/route.js.map +2 -2
- package/dist/modules/query_index/components/QueryIndexesTable.js +5 -3
- package/dist/modules/query_index/components/QueryIndexesTable.js.map +2 -2
- package/dist/modules/query_index/lib/batch.js +4 -2
- package/dist/modules/query_index/lib/batch.js.map +2 -2
- package/dist/modules/query_index/lib/coverage.js +3 -1
- package/dist/modules/query_index/lib/coverage.js.map +2 -2
- package/dist/modules/query_index/lib/engine.js +13 -18
- package/dist/modules/query_index/lib/engine.js.map +2 -2
- package/dist/modules/query_index/lib/reindexer.js +8 -6
- package/dist/modules/query_index/lib/reindexer.js.map +2 -2
- package/dist/modules/query_index/lib/search-tokens.js +3 -1
- package/dist/modules/query_index/lib/search-tokens.js.map +2 -2
- package/dist/modules/query_index/subscribers/coverage_refresh.js +3 -1
- package/dist/modules/query_index/subscribers/coverage_refresh.js.map +2 -2
- package/dist/modules/resources/api/comments.js +3 -1
- package/dist/modules/resources/api/comments.js.map +2 -2
- package/dist/modules/resources/api/resources/tags/assign/route.js +3 -1
- package/dist/modules/resources/api/resources/tags/assign/route.js.map +2 -2
- package/dist/modules/resources/api/resources/tags/unassign/route.js +3 -1
- package/dist/modules/resources/api/resources/tags/unassign/route.js.map +2 -2
- package/dist/modules/resources/backend/resources/resource-types/[id]/edit/page.js +3 -1
- package/dist/modules/resources/backend/resources/resource-types/[id]/edit/page.js.map +2 -2
- package/dist/modules/resources/backend/resources/resource-types/page.js +4 -2
- package/dist/modules/resources/backend/resources/resource-types/page.js.map +2 -2
- package/dist/modules/resources/commands/activities.js +6 -5
- package/dist/modules/resources/commands/activities.js.map +2 -2
- package/dist/modules/resources/commands/comments.js +6 -4
- package/dist/modules/resources/commands/comments.js.map +2 -2
- package/dist/modules/resources/commands/shared.js +24 -1
- package/dist/modules/resources/commands/shared.js.map +2 -2
- package/dist/modules/sales/api/channels/route.js +3 -1
- package/dist/modules/sales/api/channels/route.js.map +2 -2
- package/dist/modules/sales/api/document-history/route.js +3 -1
- package/dist/modules/sales/api/document-history/route.js.map +2 -2
- package/dist/modules/sales/api/document-numbers/route.js +3 -1
- package/dist/modules/sales/api/document-numbers/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/accept/route.js +4 -2
- package/dist/modules/sales/api/quotes/accept/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/convert/route.js +3 -1
- package/dist/modules/sales/api/quotes/convert/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/public/[token]/route.js +3 -1
- package/dist/modules/sales/api/quotes/public/[token]/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/send/route.js +3 -1
- package/dist/modules/sales/api/quotes/send/route.js.map +2 -2
- package/dist/modules/sales/api/returns/[id]/route.js +3 -1
- package/dist/modules/sales/api/returns/[id]/route.js.map +2 -2
- package/dist/modules/sales/api/settings/document-numbers/route.js +4 -2
- package/dist/modules/sales/api/settings/document-numbers/route.js.map +2 -2
- package/dist/modules/sales/api/settings/order-editing/route.js +4 -2
- package/dist/modules/sales/api/settings/order-editing/route.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/[channelId]/edit/page.js +3 -1
- package/dist/modules/sales/backend/sales/channels/[channelId]/edit/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/offers/page.js +6 -4
- package/dist/modules/sales/backend/sales/channels/offers/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/page.js +4 -2
- package/dist/modules/sales/backend/sales/channels/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/documents/[id]/page.js +20 -18
- package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +4 -8
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/commands/payments.js +3 -1
- package/dist/modules/sales/commands/payments.js.map +2 -2
- package/dist/modules/sales/commands/shipments.js +3 -1
- package/dist/modules/sales/commands/shipments.js.map +2 -2
- package/dist/modules/sales/components/AdjustmentKindSettings.js +5 -3
- package/dist/modules/sales/components/AdjustmentKindSettings.js.map +2 -2
- package/dist/modules/sales/components/DocumentNumberSettings.js +4 -2
- package/dist/modules/sales/components/DocumentNumberSettings.js.map +2 -2
- package/dist/modules/sales/components/OrderEditingSettings.js +4 -2
- package/dist/modules/sales/components/OrderEditingSettings.js.map +2 -2
- package/dist/modules/sales/components/PaymentMethodsSettings.js +5 -3
- package/dist/modules/sales/components/PaymentMethodsSettings.js.map +2 -2
- package/dist/modules/sales/components/ShippingMethodsSettings.js +5 -3
- package/dist/modules/sales/components/ShippingMethodsSettings.js.map +2 -2
- package/dist/modules/sales/components/StatusSettings.js +5 -3
- package/dist/modules/sales/components/StatusSettings.js.map +2 -2
- package/dist/modules/sales/components/TaxRatesSettings.js +5 -3
- package/dist/modules/sales/components/TaxRatesSettings.js.map +2 -2
- package/dist/modules/sales/components/channels/ChannelOfferForm.js +16 -14
- package/dist/modules/sales/components/channels/ChannelOfferForm.js.map +2 -2
- package/dist/modules/sales/components/channels/SalesChannelOffersPanel.js +4 -2
- package/dist/modules/sales/components/channels/SalesChannelOffersPanel.js.map +2 -2
- package/dist/modules/sales/components/documents/AddressesSection.js +5 -3
- package/dist/modules/sales/components/documents/AddressesSection.js.map +2 -2
- package/dist/modules/sales/components/documents/AdjustmentDialog.js +3 -1
- package/dist/modules/sales/components/documents/AdjustmentDialog.js.map +2 -2
- package/dist/modules/sales/components/documents/AdjustmentsSection.js +5 -3
- package/dist/modules/sales/components/documents/AdjustmentsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/ItemsSection.js +6 -4
- package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/LineItemDialog.js +8 -6
- package/dist/modules/sales/components/documents/LineItemDialog.js.map +2 -2
- package/dist/modules/sales/components/documents/PaymentDialog.js +5 -3
- package/dist/modules/sales/components/documents/PaymentDialog.js.map +2 -2
- package/dist/modules/sales/components/documents/PaymentsSection.js +4 -2
- package/dist/modules/sales/components/documents/PaymentsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/SalesDocumentForm.js +14 -12
- package/dist/modules/sales/components/documents/SalesDocumentForm.js.map +2 -2
- package/dist/modules/sales/components/documents/SalesDocumentsTable.js +5 -3
- package/dist/modules/sales/components/documents/SalesDocumentsTable.js.map +2 -2
- package/dist/modules/sales/components/documents/ShipmentDialog.js +9 -7
- package/dist/modules/sales/components/documents/ShipmentDialog.js.map +2 -2
- package/dist/modules/sales/components/documents/ShipmentsSection.js +4 -2
- package/dist/modules/sales/components/documents/ShipmentsSection.js.map +2 -2
- package/dist/modules/sales/frontend/quote/[token]/page.js +4 -2
- package/dist/modules/sales/frontend/quote/[token]/page.js.map +2 -2
- package/dist/modules/sales/seed/examples.js +7 -9
- package/dist/modules/sales/seed/examples.js.map +2 -2
- package/dist/modules/sales/subscribers/quote-expiring-notification.js +3 -1
- package/dist/modules/sales/subscribers/quote-expiring-notification.js.map +2 -2
- package/dist/modules/sales/subscribers/reconcileOnAddressDelete.js +3 -1
- package/dist/modules/sales/subscribers/reconcileOnAddressDelete.js.map +2 -2
- package/dist/modules/sales/subscribers/reconcileOnCompanyDelete.js +3 -1
- package/dist/modules/sales/subscribers/reconcileOnCompanyDelete.js.map +2 -2
- package/dist/modules/sales/subscribers/reconcileOnCustomerDelete.js +3 -1
- package/dist/modules/sales/subscribers/reconcileOnCustomerDelete.js.map +2 -2
- package/dist/modules/sales/widgets/dashboard/makeDashboardWidgetRoute.js +5 -3
- package/dist/modules/sales/widgets/dashboard/makeDashboardWidgetRoute.js.map +2 -2
- package/dist/modules/sales/widgets/dashboard/new-orders/widget.client.js +3 -1
- package/dist/modules/sales/widgets/dashboard/new-orders/widget.client.js.map +2 -2
- package/dist/modules/sales/widgets/dashboard/new-quotes/widget.client.js +3 -1
- package/dist/modules/sales/widgets/dashboard/new-quotes/widget.client.js.map +2 -2
- package/dist/modules/shipping_carriers/api/tracking/route.js +5 -0
- package/dist/modules/shipping_carriers/api/tracking/route.js.map +2 -2
- package/dist/modules/shipping_carriers/api/webhook/[provider]/route.js +3 -1
- package/dist/modules/shipping_carriers/api/webhook/[provider]/route.js.map +2 -2
- package/dist/modules/shipping_carriers/lib/shipping-service.js +41 -19
- package/dist/modules/shipping_carriers/lib/shipping-service.js.map +2 -2
- package/dist/modules/shipping_carriers/lib/upstream-error-response.js +3 -1
- package/dist/modules/shipping_carriers/lib/upstream-error-response.js.map +2 -2
- package/dist/modules/shipping_carriers/workers/webhook-processor.js +3 -5
- package/dist/modules/shipping_carriers/workers/webhook-processor.js.map +2 -2
- package/dist/modules/staff/api/comments.js +3 -1
- package/dist/modules/staff/api/comments.js.map +2 -2
- package/dist/modules/staff/api/leave-requests/accept/route.js +3 -1
- package/dist/modules/staff/api/leave-requests/accept/route.js.map +2 -2
- package/dist/modules/staff/api/leave-requests/reject/route.js +3 -1
- package/dist/modules/staff/api/leave-requests/reject/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/assignable/route.js +3 -1
- package/dist/modules/staff/api/team-members/assignable/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/self/route.js +4 -2
- package/dist/modules/staff/api/team-members/self/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/tags/assign/route.js +3 -1
- package/dist/modules/staff/api/team-members/tags/assign/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/tags/unassign/route.js +3 -1
- package/dist/modules/staff/api/team-members/tags/unassign/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js +3 -1
- package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/my-projects/route.js +3 -1
- package/dist/modules/staff/api/timesheets/my-projects/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/projects/kpis/route.js +3 -1
- package/dist/modules/staff/api/timesheets/projects/kpis/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js +3 -1
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js +4 -2
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js +4 -2
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js +3 -1
- package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js.map +2 -2
- package/dist/modules/staff/api/timesheets/time-entries/start-timer/route.js +3 -1
- package/dist/modules/staff/api/timesheets/time-entries/start-timer/route.js.map +2 -2
- package/dist/modules/staff/backend/staff/team-members/page.js +4 -2
- package/dist/modules/staff/backend/staff/team-members/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/team-roles/page.js +4 -2
- package/dist/modules/staff/backend/staff/team-roles/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js +4 -2
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/teams/page.js +4 -2
- package/dist/modules/staff/backend/staff/teams/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/page.js +7 -5
- package/dist/modules/staff/backend/staff/timesheets/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.js +3 -1
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/page.js +4 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/page.js.map +2 -2
- package/dist/modules/staff/commands/timesheets-entries.js +3 -1
- package/dist/modules/staff/commands/timesheets-entries.js.map +2 -2
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.client.js +3 -1
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.client.js.map +2 -2
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.client.js +5 -3
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.client.js.map +2 -2
- package/dist/modules/sync_excel/api/import/route.js +3 -1
- package/dist/modules/sync_excel/api/import/route.js.map +2 -2
- package/dist/modules/translations/api/[entityType]/[entityId]/route.js +5 -3
- package/dist/modules/translations/api/[entityType]/[entityId]/route.js.map +2 -2
- package/dist/modules/translations/api/get/locales.js +3 -1
- package/dist/modules/translations/api/get/locales.js.map +2 -2
- package/dist/modules/translations/api/put/locales.js +3 -1
- package/dist/modules/translations/api/put/locales.js.map +2 -2
- package/dist/modules/translations/components/TranslationManager.js +3 -1
- package/dist/modules/translations/components/TranslationManager.js.map +2 -2
- package/dist/modules/translations/subscribers/cleanup.js +3 -1
- package/dist/modules/translations/subscribers/cleanup.js.map +2 -2
- package/dist/modules/workflows/api/definitions/[id]/customize/route.js +4 -2
- package/dist/modules/workflows/api/definitions/[id]/customize/route.js.map +2 -2
- package/dist/modules/workflows/api/definitions/[id]/reset-to-code/route.js +4 -2
- package/dist/modules/workflows/api/definitions/[id]/reset-to-code/route.js.map +2 -2
- package/dist/modules/workflows/api/definitions/[id]/route.js +6 -4
- package/dist/modules/workflows/api/definitions/[id]/route.js.map +2 -2
- package/dist/modules/workflows/api/definitions/route.js +4 -2
- package/dist/modules/workflows/api/definitions/route.js.map +2 -2
- package/dist/modules/workflows/api/events/[id]/route.js +3 -1
- package/dist/modules/workflows/api/events/[id]/route.js.map +2 -2
- package/dist/modules/workflows/api/events/route.js +3 -1
- package/dist/modules/workflows/api/events/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/[id]/advance/route.js +3 -1
- package/dist/modules/workflows/api/instances/[id]/advance/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/[id]/cancel/route.js +3 -1
- package/dist/modules/workflows/api/instances/[id]/cancel/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/[id]/events/route.js +3 -1
- package/dist/modules/workflows/api/instances/[id]/events/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/[id]/retry/route.js +3 -1
- package/dist/modules/workflows/api/instances/[id]/retry/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/[id]/route.js +3 -1
- package/dist/modules/workflows/api/instances/[id]/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/[id]/signal/route.js +5 -7
- package/dist/modules/workflows/api/instances/[id]/signal/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/route.js +5 -3
- package/dist/modules/workflows/api/instances/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/validate-start/route.js +3 -1
- package/dist/modules/workflows/api/instances/validate-start/route.js.map +2 -2
- package/dist/modules/workflows/api/signals/route.js +3 -1
- package/dist/modules/workflows/api/signals/route.js.map +2 -2
- package/dist/modules/workflows/api/tasks/[id]/claim/route.js +3 -1
- package/dist/modules/workflows/api/tasks/[id]/claim/route.js.map +2 -2
- package/dist/modules/workflows/api/tasks/[id]/complete/route.js +3 -1
- package/dist/modules/workflows/api/tasks/[id]/complete/route.js.map +2 -2
- package/dist/modules/workflows/api/tasks/[id]/route.js +3 -1
- package/dist/modules/workflows/api/tasks/[id]/route.js.map +2 -2
- package/dist/modules/workflows/api/tasks/route.js +3 -1
- package/dist/modules/workflows/api/tasks/route.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js +4 -2
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js.map +2 -2
- package/dist/modules/workflows/backend/instances/[id]/page.js +5 -3
- package/dist/modules/workflows/backend/instances/[id]/page.js.map +2 -2
- package/dist/modules/workflows/backend/tasks/[id]/page.js +3 -1
- package/dist/modules/workflows/backend/tasks/[id]/page.js.map +2 -2
- package/dist/modules/workflows/components/BusinessRulesSelector.js +5 -3
- package/dist/modules/workflows/components/BusinessRulesSelector.js.map +2 -2
- package/dist/modules/workflows/components/WorkflowSelector.js +5 -3
- package/dist/modules/workflows/components/WorkflowSelector.js.map +2 -2
- package/dist/modules/workflows/components/fields/BusinessRuleConditionsEditor.js +3 -1
- package/dist/modules/workflows/components/fields/BusinessRuleConditionsEditor.js.map +2 -2
- package/dist/modules/workflows/components/fields/StartPreConditionsEditor.js +3 -1
- package/dist/modules/workflows/components/fields/StartPreConditionsEditor.js.map +2 -2
- package/dist/modules/workflows/components/fields/WorkflowSelectorField.js +3 -1
- package/dist/modules/workflows/components/fields/WorkflowSelectorField.js.map +2 -2
- package/dist/modules/workflows/frontend/checkout-demo/page.js +8 -7
- package/dist/modules/workflows/frontend/checkout-demo/page.js.map +2 -2
- package/dist/modules/workflows/lib/activity-executor.js +25 -21
- package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
- package/dist/modules/workflows/lib/activity-worker-handler.js +8 -15
- package/dist/modules/workflows/lib/activity-worker-handler.js.map +2 -2
- package/dist/modules/workflows/lib/code-registry.js +7 -7
- package/dist/modules/workflows/lib/code-registry.js.map +2 -2
- package/dist/modules/workflows/lib/compensation-handler.js +4 -2
- package/dist/modules/workflows/lib/compensation-handler.js.map +2 -2
- package/dist/modules/workflows/lib/edgeFormTransforms.js +3 -1
- package/dist/modules/workflows/lib/edgeFormTransforms.js.map +2 -2
- package/dist/modules/workflows/lib/event-trigger-service.js +5 -3
- package/dist/modules/workflows/lib/event-trigger-service.js.map +2 -2
- package/dist/modules/workflows/lib/nodeFormTransforms.js +3 -1
- package/dist/modules/workflows/lib/nodeFormTransforms.js.map +2 -2
- package/dist/modules/workflows/lib/seeds.js +16 -2
- package/dist/modules/workflows/lib/seeds.js.map +2 -2
- package/dist/modules/workflows/lib/signal-handler.js +3 -1
- package/dist/modules/workflows/lib/signal-handler.js.map +2 -2
- package/dist/modules/workflows/lib/start-validator.js +9 -3
- package/dist/modules/workflows/lib/start-validator.js.map +2 -2
- package/dist/modules/workflows/lib/step-handler.js +3 -1
- package/dist/modules/workflows/lib/step-handler.js.map +2 -2
- package/dist/modules/workflows/lib/task-handler.js +3 -1
- package/dist/modules/workflows/lib/task-handler.js.map +2 -2
- package/dist/modules/workflows/lib/transition-handler.js +5 -3
- package/dist/modules/workflows/lib/transition-handler.js.map +2 -2
- package/dist/modules/workflows/lib/workflow-executor.js +27 -15
- package/dist/modules/workflows/lib/workflow-executor.js.map +2 -2
- package/dist/modules/workflows/subscribers/event-trigger.js +21 -18
- package/dist/modules/workflows/subscribers/event-trigger.js.map +2 -2
- package/dist/modules/workflows/subscribers/task-assigned-notification.js +3 -1
- package/dist/modules/workflows/subscribers/task-assigned-notification.js.map +2 -2
- package/dist/modules/workflows/workers/workflow-activities.worker.js +30 -20
- package/dist/modules/workflows/workers/workflow-activities.worker.js.map +2 -2
- package/package.json +7 -7
- package/src/bootstrap.ts +14 -11
- package/src/helpers/integration/queue-runner.ts +2 -2
- package/src/modules/api_keys/services/apiKeyService.ts +6 -3
- package/src/modules/attachments/api/image/[id]/[[...slug]]/route.ts +5 -2
- package/src/modules/attachments/api/library/[id]/route.ts +4 -1
- package/src/modules/attachments/api/route.ts +9 -6
- package/src/modules/attachments/components/AttachmentPartitionSettings.tsx +6 -3
- package/src/modules/attachments/lib/assignmentDetails.ts +4 -1
- package/src/modules/attachments/lib/drivers/driverFactory.ts +4 -1
- package/src/modules/attachments/lib/ocrQueue.ts +11 -11
- package/src/modules/attachments/lib/ocrService.ts +7 -4
- package/src/modules/audit_logs/api/audit-logs/actions/redo/route.ts +4 -1
- package/src/modules/audit_logs/api/audit-logs/actions/undo/route.ts +4 -1
- package/src/modules/audit_logs/backend/audit-logs/page.tsx +4 -1
- package/src/modules/audit_logs/components/AuditLogsActions.tsx +5 -2
- package/src/modules/audit_logs/services/accessLogService.ts +5 -4
- package/src/modules/audit_logs/services/actionLogService.ts +5 -2
- package/src/modules/auth/api/profile/route.ts +5 -2
- package/src/modules/auth/api/reset/confirm.ts +4 -1
- package/src/modules/auth/api/reset.ts +5 -2
- package/src/modules/auth/api/roles/route.ts +4 -1
- package/src/modules/auth/api/sidebar/variants/route.ts +4 -2
- package/src/modules/auth/api/users/resend-invite/route.ts +5 -2
- package/src/modules/auth/api/users/route.ts +4 -1
- package/src/modules/auth/backend/auth/profile/page.tsx +4 -1
- package/src/modules/auth/backend/profile/change-password/page.tsx +4 -1
- package/src/modules/auth/backend/users/[id]/edit/page.tsx +6 -3
- package/src/modules/auth/backend/users/create/page.tsx +5 -2
- package/src/modules/auth/cli.ts +10 -0
- package/src/modules/auth/commands/users.ts +5 -2
- package/src/modules/auth/lib/consentIntegrity.ts +4 -4
- package/src/modules/auth/lib/setup-app.ts +10 -10
- package/src/modules/auth/lib/tenantAccess.ts +4 -1
- package/src/modules/auth/lib/tokenHash.ts +4 -4
- package/src/modules/business_rules/api/rules/route.ts +5 -2
- package/src/modules/business_rules/lib/expression-evaluator.ts +8 -6
- package/src/modules/business_rules/lib/rule-engine.ts +6 -3
- package/src/modules/business_rules/lib/rule-evaluator.ts +11 -11
- package/src/modules/business_rules/subscribers/crud-rule-trigger.ts +4 -1
- package/src/modules/business_rules/subscribers/rule-execution-failed-notification.ts +4 -1
- package/src/modules/catalog/ai-agents-context.ts +5 -5
- package/src/modules/catalog/ai-tools/_shared.ts +4 -1
- package/src/modules/catalog/ai-tools/authoring-pack.ts +4 -1
- package/src/modules/catalog/ai-tools/merchandising-pack.ts +4 -1
- package/src/modules/catalog/api/dictionaries/[key]/route.ts +4 -1
- package/src/modules/catalog/api/prices/route.ts +4 -1
- package/src/modules/catalog/api/products/route.ts +6 -3
- package/src/modules/catalog/api/settings/route.ts +5 -2
- package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +15 -12
- package/src/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.tsx +9 -6
- package/src/modules/catalog/backend/catalog/products/[productId]/variants/create/page.tsx +6 -3
- package/src/modules/catalog/backend/catalog/products/create/page.tsx +6 -6
- package/src/modules/catalog/backend/catalog/products/optionSchemaClient.ts +4 -1
- package/src/modules/catalog/components/PriceKindSettings.tsx +6 -3
- package/src/modules/catalog/components/UnitPriceDisplaySettings.tsx +5 -2
- package/src/modules/catalog/inbox-actions.ts +5 -2
- package/src/modules/catalog/seed/examples.ts +5 -5
- package/src/modules/catalog/subscribers/low-stock-notification.ts +4 -1
- package/src/modules/catalog/widgets/injection/product-seo/state.ts +4 -1
- package/src/modules/communication_channels/api/get/oauth/[provider]/callback/route.ts +13 -13
- package/src/modules/communication_channels/api/post/channels/[id]/import-history/route.ts +4 -1
- package/src/modules/communication_channels/api/post/channels/[id]/push/register/route.ts +4 -1
- package/src/modules/communication_channels/api/post/webhook/[provider]/route.ts +6 -3
- package/src/modules/communication_channels/api/post/webhooks/gmail/route.ts +7 -6
- package/src/modules/communication_channels/commands/connect-credential-channel.ts +5 -10
- package/src/modules/communication_channels/commands/delete-channel.ts +4 -5
- package/src/modules/communication_channels/commands/deliver-outbound-message.ts +5 -5
- package/src/modules/communication_channels/commands/disconnect-channel.ts +4 -5
- package/src/modules/communication_channels/commands/ingest-inbound-message.ts +6 -12
- package/src/modules/communication_channels/commands/push-unregister.ts +4 -3
- package/src/modules/communication_channels/commands/reassign-conversation.ts +6 -3
- package/src/modules/communication_channels/lib/dead-letter.ts +4 -5
- package/src/modules/communication_channels/lib/email-mime.ts +5 -6
- package/src/modules/communication_channels/lib/oauth-client-config.ts +7 -3
- package/src/modules/communication_channels/lib/send-as-user.ts +4 -1
- package/src/modules/communication_channels/lib/thread-token.ts +5 -2
- package/src/modules/communication_channels/setup.ts +4 -4
- package/src/modules/communication_channels/workers/channel-import-history.ts +5 -8
- package/src/modules/communication_channels/workers/gmail-history-sync.ts +9 -18
- package/src/modules/communication_channels/workers/gmail-renew-watch.ts +6 -9
- package/src/modules/communication_channels/workers/outbound-delivery.ts +7 -12
- package/src/modules/communication_channels/workers/poll-channel.ts +8 -15
- package/src/modules/communication_channels/workers/poll-tick.ts +6 -6
- package/src/modules/communication_channels/workers/reaction-processor.ts +6 -9
- package/src/modules/configs/api/cache/route.ts +5 -2
- package/src/modules/configs/api/system-status/route.ts +5 -2
- package/src/modules/configs/api/upgrade-actions/route.ts +5 -2
- package/src/modules/configs/components/ModuleTelemetryPanel.tsx +4 -1
- package/src/modules/configs/lib/touchGeneratedBarrels.ts +1 -1
- package/src/modules/configs/services/upgradeActionsService.ts +7 -3
- package/src/modules/currencies/components/CurrencyFetchingConfig.tsx +4 -1
- package/src/modules/currencies/lib/exchangeRateFormConfig.ts +4 -1
- package/src/modules/currencies/services/providers/nbp.ts +7 -4
- package/src/modules/currencies/services/providers/raiffeisen.ts +8 -7
- package/src/modules/customer_accounts/api/domain-resolve/all.ts +7 -5
- package/src/modules/customer_accounts/api/signup.ts +5 -2
- package/src/modules/customer_accounts/lib/customerAuthServer.ts +4 -1
- package/src/modules/customer_accounts/subscribers/autoLinkCrm.ts +4 -1
- package/src/modules/customer_accounts/subscribers/autoLinkCrmReverse.ts +4 -1
- package/src/modules/customer_accounts/subscribers/unlinkOnCompanyDelete.ts +4 -1
- package/src/modules/customer_accounts/subscribers/unlinkOnPersonDelete.ts +4 -1
- package/src/modules/customers/ai-agents-context.ts +5 -5
- package/src/modules/customers/api/activities/route.ts +7 -4
- package/src/modules/customers/api/comments/route.ts +4 -1
- package/src/modules/customers/api/companies/[id]/people/route.ts +4 -1
- package/src/modules/customers/api/companies/[id]/route.ts +6 -3
- package/src/modules/customers/api/companies/route.ts +6 -3
- package/src/modules/customers/api/dashboard/widgets/customer-todos/route.ts +4 -1
- package/src/modules/customers/api/dashboard/widgets/new-customers/route.ts +4 -1
- package/src/modules/customers/api/dashboard/widgets/new-deals/route.ts +4 -1
- package/src/modules/customers/api/dashboard/widgets/next-interactions/route.ts +4 -1
- package/src/modules/customers/api/deals/[id]/companies/route.ts +4 -1
- package/src/modules/customers/api/deals/[id]/people/route.ts +4 -1
- package/src/modules/customers/api/deals/aggregate/route.ts +4 -1
- package/src/modules/customers/api/deals/bulk-update-owner/route.ts +8 -5
- package/src/modules/customers/api/deals/bulk-update-stage/route.ts +8 -5
- package/src/modules/customers/api/deals/route.ts +4 -1
- package/src/modules/customers/api/deals/summary/route.ts +4 -1
- package/src/modules/customers/api/dictionaries/[kind]/[id]/route.ts +5 -2
- package/src/modules/customers/api/dictionaries/[kind]/route.ts +6 -3
- package/src/modules/customers/api/dictionaries/cache.ts +4 -1
- package/src/modules/customers/api/dictionaries/context.ts +4 -1
- package/src/modules/customers/api/dictionaries/currency/route.ts +4 -1
- package/src/modules/customers/api/dictionaries/kind-settings/route.ts +5 -2
- package/src/modules/customers/api/entity-roles-factory.ts +8 -5
- package/src/modules/customers/api/interactions/cancel/route.ts +4 -1
- package/src/modules/customers/api/interactions/complete/route.ts +4 -1
- package/src/modules/customers/api/interactions/conflicts/route.ts +4 -1
- package/src/modules/customers/api/interactions/counts/route.ts +4 -1
- package/src/modules/customers/api/interactions/route.ts +8 -4
- package/src/modules/customers/api/interactions/tasks/route.ts +4 -1
- package/src/modules/customers/api/labels/assign/route.ts +4 -1
- package/src/modules/customers/api/labels/route.ts +7 -3
- package/src/modules/customers/api/labels/unassign/route.ts +4 -1
- package/src/modules/customers/api/people/[id]/companies/enriched/route.ts +4 -1
- package/src/modules/customers/api/people/[id]/route.ts +6 -3
- package/src/modules/customers/api/people/route.ts +6 -3
- package/src/modules/customers/api/pipeline-stages/reorder/route.ts +4 -1
- package/src/modules/customers/api/pipeline-stages/route.ts +7 -4
- package/src/modules/customers/api/pipelines/route.ts +7 -4
- package/src/modules/customers/api/settings/address-format/route.ts +5 -2
- package/src/modules/customers/api/settings/dictionary-sort-modes/route.ts +5 -2
- package/src/modules/customers/api/settings/stuck-threshold/route.ts +5 -2
- package/src/modules/customers/api/tags/assign/route.ts +4 -1
- package/src/modules/customers/api/tags/unassign/route.ts +4 -1
- package/src/modules/customers/api/todos/route.ts +7 -4
- package/src/modules/customers/backend/customers/companies-v2/[id]/page.tsx +6 -3
- package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealActivities.ts +4 -1
- package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealClosure.ts +4 -1
- package/src/modules/customers/backend/customers/deals/map/components/DealsMapCanvasImpl.tsx +5 -3
- package/src/modules/customers/backend/customers/deals/page.tsx +5 -2
- package/src/modules/customers/backend/customers/people-v2/[id]/page.tsx +6 -3
- package/src/modules/customers/commands/deals.ts +4 -1
- package/src/modules/customers/commands/dictionaries.ts +4 -1
- package/src/modules/customers/commands/interactions.ts +5 -2
- package/src/modules/customers/commands/shared.ts +5 -2
- package/src/modules/customers/commands/todos.ts +4 -1
- package/src/modules/customers/components/DictionarySettings.tsx +6 -3
- package/src/modules/customers/components/DictionarySortSettings.tsx +4 -1
- package/src/modules/customers/components/detail/ActivitiesCard.tsx +4 -1
- package/src/modules/customers/components/detail/ActivitiesDayStrip.tsx +4 -1
- package/src/modules/customers/components/detail/ActivitiesSection.tsx +7 -4
- package/src/modules/customers/components/detail/ActivityCard.tsx +4 -1
- package/src/modules/customers/components/detail/ChangelogTab.tsx +4 -1
- package/src/modules/customers/components/detail/CompanyCard.tsx +4 -1
- package/src/modules/customers/components/detail/ConfirmDealLostDialog.tsx +4 -1
- package/src/modules/customers/components/detail/EntityTagsDialog.tsx +4 -1
- package/src/modules/customers/components/detail/InlineActivityComposer.tsx +4 -1
- package/src/modules/customers/components/detail/ManageTagsDialog.tsx +4 -1
- package/src/modules/customers/components/detail/RoleAssignmentRow.tsx +6 -3
- package/src/modules/customers/components/detail/RolesSection.tsx +5 -2
- package/src/modules/customers/components/detail/hooks/useInteractionMutations.ts +6 -3
- package/src/modules/customers/components/linking/LinkEntityDialog.tsx +5 -2
- package/src/modules/customers/inbox-actions.ts +4 -1
- package/src/modules/customers/lib/bulkDeals.ts +4 -1
- package/src/modules/customers/lib/dealClosureNotification.ts +5 -2
- package/src/modules/customers/lib/dealStageTransitionTable.ts +4 -1
- package/src/modules/customers/lib/interactionFeatureFlags.ts +5 -1
- package/src/modules/customers/lib/todoCompatibility.ts +4 -1
- package/src/modules/customers/search.ts +15 -7
- package/src/modules/customers/widgets/dashboard/customer-todos/widget.client.tsx +4 -1
- package/src/modules/customers/widgets/dashboard/new-customers/widget.client.tsx +4 -1
- package/src/modules/customers/widgets/dashboard/new-deals/widget.client.tsx +4 -1
- package/src/modules/customers/widgets/dashboard/next-interactions/widget.client.tsx +4 -1
- package/src/modules/dashboards/api/widgets/data/batch/route.ts +4 -1
- package/src/modules/dashboards/api/widgets/data/route.ts +4 -1
- package/src/modules/dashboards/components/WidgetVisibilityEditor.tsx +6 -3
- package/src/modules/dashboards/widgets/dashboard/aov-kpi/widget.client.tsx +4 -1
- package/src/modules/dashboards/widgets/dashboard/new-customers-kpi/widget.client.tsx +4 -1
- package/src/modules/dashboards/widgets/dashboard/orders-by-status/widget.client.tsx +4 -1
- package/src/modules/dashboards/widgets/dashboard/orders-kpi/widget.client.tsx +4 -1
- package/src/modules/dashboards/widgets/dashboard/pipeline-summary/widget.client.tsx +4 -1
- package/src/modules/dashboards/widgets/dashboard/revenue-kpi/widget.client.tsx +4 -1
- package/src/modules/dashboards/widgets/dashboard/revenue-trend/widget.client.tsx +4 -1
- package/src/modules/dashboards/widgets/dashboard/sales-by-region/widget.client.tsx +4 -1
- package/src/modules/dashboards/widgets/dashboard/top-customers/widget.client.tsx +4 -1
- package/src/modules/dashboards/widgets/dashboard/top-products/widget.client.tsx +4 -1
- package/src/modules/data_sync/api/run.ts +4 -1
- package/src/modules/data_sync/backend/data-sync/runs/[id]/page.tsx +3 -1
- package/src/modules/data_sync/lib/adapter-registry.ts +16 -4
- package/src/modules/data_sync/lib/sync-engine.ts +31 -2
- package/src/modules/data_sync/workers/sync-export.ts +4 -1
- package/src/modules/data_sync/workers/sync-import.ts +4 -1
- package/src/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.ts +5 -2
- package/src/modules/dictionaries/api/[dictionaryId]/entries/reorder/route.ts +4 -1
- package/src/modules/dictionaries/api/[dictionaryId]/entries/route.ts +5 -2
- package/src/modules/dictionaries/api/[dictionaryId]/entries/set-default/route.ts +4 -1
- package/src/modules/dictionaries/api/[dictionaryId]/route.ts +6 -3
- package/src/modules/dictionaries/api/context.ts +4 -1
- package/src/modules/dictionaries/api/route.ts +5 -2
- package/src/modules/dictionaries/components/DictionariesManager.tsx +6 -3
- package/src/modules/dictionaries/components/DictionaryEntriesEditor.tsx +5 -2
- package/src/modules/dictionaries/components/DictionaryEntrySelect.tsx +5 -2
- package/src/modules/dictionaries/components/DictionarySelectControl.tsx +4 -1
- package/src/modules/dictionaries/fields/dictionary.tsx +4 -1
- package/src/modules/directory/api/organization-branding/route.ts +4 -1
- package/src/modules/directory/api/organization-switcher/route.ts +4 -1
- package/src/modules/directory/commands/tenants.ts +6 -3
- package/src/modules/directory/utils/organizationScope.ts +7 -4
- package/src/modules/entities/api/definitions.cache.ts +4 -1
- package/src/modules/entities/api/definitions.ts +8 -5
- package/src/modules/entities/api/records.ts +5 -2
- package/src/modules/entities/components/EncryptionManager.tsx +4 -1
- package/src/modules/entities/lib/makeActivityRoute.ts +4 -1
- package/src/modules/feature_toggles/api/overrides/route.ts +4 -1
- package/src/modules/feature_toggles/lib/feature-flag-check.ts +6 -9
- package/src/modules/inbox_ops/api/emails/[id]/reprocess/route.ts +5 -2
- package/src/modules/inbox_ops/api/emails/[id]/route.ts +5 -2
- package/src/modules/inbox_ops/api/emails/route.ts +4 -1
- package/src/modules/inbox_ops/api/extract/route.ts +4 -1
- package/src/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/route.ts +4 -1
- package/src/modules/inbox_ops/api/proposals/[id]/replies/[replyId]/send/route.ts +5 -2
- package/src/modules/inbox_ops/api/proposals/counts/route.ts +5 -2
- package/src/modules/inbox_ops/api/proposals/route.ts +4 -1
- package/src/modules/inbox_ops/api/routeHelpers.ts +4 -1
- package/src/modules/inbox_ops/api/settings/route.ts +4 -1
- package/src/modules/inbox_ops/api/webhook/inbound.ts +8 -5
- package/src/modules/inbox_ops/lib/cache.ts +5 -2
- package/src/modules/inbox_ops/lib/catalogLookup.ts +4 -1
- package/src/modules/inbox_ops/lib/eventBus.ts +4 -4
- package/src/modules/inbox_ops/lib/messagesIntegration.ts +5 -8
- package/src/modules/inbox_ops/subscribers/executionAuditor.ts +5 -1
- package/src/modules/inbox_ops/subscribers/extractionWorker.ts +11 -8
- package/src/modules/inbox_ops/subscribers/proposalNotifier.ts +4 -1
- package/src/modules/messages/api/[id]/route.ts +4 -4
- package/src/modules/messages/commands/actions.ts +4 -1
- package/src/modules/messages/components/MessagesInboxPageClient.tsx +4 -1
- package/src/modules/messages/lib/email-sender.ts +4 -7
- package/src/modules/messages/lib/message-objects-registry.ts +4 -1
- package/src/modules/messages/lib/message-types-registry.ts +4 -1
- package/src/modules/messages/workers/send-email.worker.ts +7 -4
- package/src/modules/notifications/lib/notificationMapper.ts +4 -4
- package/src/modules/notifications/lib/notificationService.ts +4 -5
- package/src/modules/notifications/subscribers/deliver-notification.ts +9 -14
- package/src/modules/payment_gateways/api/webhook/[provider]/route.ts +4 -1
- package/src/modules/perspectives/services/perspectiveService.ts +4 -3
- package/src/modules/planner/api/access.ts +4 -3
- package/src/modules/planner/api/availability-date-specific.ts +4 -1
- package/src/modules/planner/api/availability-weekly.ts +4 -1
- package/src/modules/planner/backend/planner/availability-rulesets/page.tsx +5 -2
- package/src/modules/planner/components/AvailabilityRulesEditor.tsx +4 -1
- package/src/modules/progress/api/jobs/route.ts +4 -1
- package/src/modules/query_index/components/QueryIndexesTable.tsx +6 -3
- package/src/modules/query_index/lib/batch.ts +5 -2
- package/src/modules/query_index/lib/coverage.ts +4 -1
- package/src/modules/query_index/lib/engine.ts +14 -17
- package/src/modules/query_index/lib/reindexer.ts +9 -6
- package/src/modules/query_index/lib/search-tokens.ts +4 -2
- package/src/modules/query_index/subscribers/coverage_refresh.ts +4 -1
- package/src/modules/resources/api/comments.ts +4 -1
- package/src/modules/resources/api/resources/tags/assign/route.ts +4 -1
- package/src/modules/resources/api/resources/tags/unassign/route.ts +4 -1
- package/src/modules/resources/backend/resources/resource-types/[id]/edit/page.tsx +4 -1
- package/src/modules/resources/backend/resources/resource-types/page.tsx +5 -2
- package/src/modules/resources/commands/activities.ts +5 -4
- package/src/modules/resources/commands/comments.ts +6 -4
- package/src/modules/resources/commands/shared.ts +36 -0
- package/src/modules/sales/api/channels/route.ts +4 -1
- package/src/modules/sales/api/document-history/route.ts +4 -1
- package/src/modules/sales/api/document-numbers/route.ts +4 -1
- package/src/modules/sales/api/quotes/accept/route.ts +5 -2
- package/src/modules/sales/api/quotes/convert/route.ts +4 -1
- package/src/modules/sales/api/quotes/public/[token]/route.ts +4 -1
- package/src/modules/sales/api/quotes/send/route.ts +4 -1
- package/src/modules/sales/api/returns/[id]/route.ts +4 -1
- package/src/modules/sales/api/settings/document-numbers/route.ts +5 -2
- package/src/modules/sales/api/settings/order-editing/route.ts +5 -2
- package/src/modules/sales/backend/sales/channels/[channelId]/edit/page.tsx +4 -1
- package/src/modules/sales/backend/sales/channels/offers/page.tsx +7 -4
- package/src/modules/sales/backend/sales/channels/page.tsx +5 -2
- package/src/modules/sales/backend/sales/documents/[id]/page.tsx +21 -18
- package/src/modules/sales/commands/documents.ts +5 -8
- package/src/modules/sales/commands/payments.ts +4 -1
- package/src/modules/sales/commands/shipments.ts +4 -2
- package/src/modules/sales/components/AdjustmentKindSettings.tsx +6 -3
- package/src/modules/sales/components/DocumentNumberSettings.tsx +5 -2
- package/src/modules/sales/components/OrderEditingSettings.tsx +5 -2
- package/src/modules/sales/components/PaymentMethodsSettings.tsx +6 -3
- package/src/modules/sales/components/ShippingMethodsSettings.tsx +6 -3
- package/src/modules/sales/components/StatusSettings.tsx +6 -3
- package/src/modules/sales/components/TaxRatesSettings.tsx +6 -3
- package/src/modules/sales/components/channels/ChannelOfferForm.tsx +17 -14
- package/src/modules/sales/components/channels/SalesChannelOffersPanel.tsx +5 -2
- package/src/modules/sales/components/documents/AddressesSection.tsx +6 -3
- package/src/modules/sales/components/documents/AdjustmentDialog.tsx +4 -1
- package/src/modules/sales/components/documents/AdjustmentsSection.tsx +6 -3
- package/src/modules/sales/components/documents/ItemsSection.tsx +7 -4
- package/src/modules/sales/components/documents/LineItemDialog.tsx +9 -6
- package/src/modules/sales/components/documents/PaymentDialog.tsx +6 -3
- package/src/modules/sales/components/documents/PaymentsSection.tsx +5 -2
- package/src/modules/sales/components/documents/SalesDocumentForm.tsx +15 -12
- package/src/modules/sales/components/documents/SalesDocumentsTable.tsx +6 -3
- package/src/modules/sales/components/documents/ShipmentDialog.tsx +10 -7
- package/src/modules/sales/components/documents/ShipmentsSection.tsx +5 -2
- package/src/modules/sales/frontend/quote/[token]/page.tsx +5 -2
- package/src/modules/sales/seed/examples.ts +8 -9
- package/src/modules/sales/subscribers/quote-expiring-notification.ts +4 -1
- package/src/modules/sales/subscribers/reconcileOnAddressDelete.ts +4 -1
- package/src/modules/sales/subscribers/reconcileOnCompanyDelete.ts +4 -1
- package/src/modules/sales/subscribers/reconcileOnCustomerDelete.ts +4 -1
- package/src/modules/sales/widgets/dashboard/makeDashboardWidgetRoute.ts +6 -3
- package/src/modules/sales/widgets/dashboard/new-orders/widget.client.tsx +274 -271
- package/src/modules/sales/widgets/dashboard/new-quotes/widget.client.tsx +280 -277
- package/src/modules/shipping_carriers/api/tracking/route.ts +5 -1
- package/src/modules/shipping_carriers/api/webhook/[provider]/route.ts +4 -1
- package/src/modules/shipping_carriers/lib/shipping-service.ts +47 -22
- package/src/modules/shipping_carriers/lib/upstream-error-response.ts +4 -1
- package/src/modules/shipping_carriers/workers/webhook-processor.ts +4 -5
- package/src/modules/staff/api/comments.ts +4 -1
- package/src/modules/staff/api/leave-requests/accept/route.ts +4 -1
- package/src/modules/staff/api/leave-requests/reject/route.ts +4 -1
- package/src/modules/staff/api/team-members/assignable/route.ts +4 -1
- package/src/modules/staff/api/team-members/self/route.ts +5 -2
- package/src/modules/staff/api/team-members/tags/assign/route.ts +4 -1
- package/src/modules/staff/api/team-members/tags/unassign/route.ts +4 -1
- package/src/modules/staff/api/timesheets/my-projects/[projectId]/route.ts +4 -1
- package/src/modules/staff/api/timesheets/my-projects/route.ts +4 -1
- package/src/modules/staff/api/timesheets/projects/kpis/route.ts +4 -1
- package/src/modules/staff/api/timesheets/time-entries/[id]/segments/route.ts +4 -1
- package/src/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.ts +5 -2
- package/src/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.ts +5 -2
- package/src/modules/staff/api/timesheets/time-entries/bulk/route.ts +4 -1
- package/src/modules/staff/api/timesheets/time-entries/start-timer/route.ts +4 -1
- package/src/modules/staff/backend/staff/team-members/page.tsx +5 -2
- package/src/modules/staff/backend/staff/team-roles/page.tsx +5 -2
- package/src/modules/staff/backend/staff/teams/[id]/edit/page.tsx +5 -2
- package/src/modules/staff/backend/staff/teams/page.tsx +5 -2
- package/src/modules/staff/backend/staff/timesheets/page.tsx +8 -5
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/page.tsx +4 -1
- package/src/modules/staff/backend/staff/timesheets/projects/page.tsx +5 -2
- package/src/modules/staff/commands/timesheets-entries.ts +4 -1
- package/src/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.client.tsx +4 -1
- package/src/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.client.tsx +6 -3
- package/src/modules/sync_excel/api/import/route.ts +4 -1
- package/src/modules/translations/api/[entityType]/[entityId]/route.ts +6 -3
- package/src/modules/translations/api/get/locales.ts +4 -1
- package/src/modules/translations/api/put/locales.ts +4 -1
- package/src/modules/translations/components/TranslationManager.tsx +4 -1
- package/src/modules/translations/subscribers/cleanup.ts +4 -1
- package/src/modules/workflows/api/definitions/[id]/customize/route.ts +5 -2
- package/src/modules/workflows/api/definitions/[id]/reset-to-code/route.ts +5 -2
- package/src/modules/workflows/api/definitions/[id]/route.ts +7 -4
- package/src/modules/workflows/api/definitions/route.ts +5 -2
- package/src/modules/workflows/api/events/[id]/route.ts +4 -1
- package/src/modules/workflows/api/events/route.ts +4 -1
- package/src/modules/workflows/api/instances/[id]/advance/route.ts +4 -1
- package/src/modules/workflows/api/instances/[id]/cancel/route.ts +4 -1
- package/src/modules/workflows/api/instances/[id]/events/route.ts +4 -1
- package/src/modules/workflows/api/instances/[id]/retry/route.ts +4 -1
- package/src/modules/workflows/api/instances/[id]/route.ts +4 -1
- package/src/modules/workflows/api/instances/[id]/signal/route.ts +6 -7
- package/src/modules/workflows/api/instances/route.ts +6 -3
- package/src/modules/workflows/api/instances/validate-start/route.ts +4 -1
- package/src/modules/workflows/api/signals/route.ts +4 -1
- package/src/modules/workflows/api/tasks/[id]/claim/route.ts +4 -1
- package/src/modules/workflows/api/tasks/[id]/complete/route.ts +4 -1
- package/src/modules/workflows/api/tasks/[id]/route.ts +4 -1
- package/src/modules/workflows/api/tasks/route.ts +4 -1
- package/src/modules/workflows/backend/definitions/visual-editor/page.tsx +5 -2
- package/src/modules/workflows/backend/instances/[id]/page.tsx +6 -3
- package/src/modules/workflows/backend/tasks/[id]/page.tsx +4 -1
- package/src/modules/workflows/components/BusinessRulesSelector.tsx +6 -3
- package/src/modules/workflows/components/WorkflowSelector.tsx +6 -3
- package/src/modules/workflows/components/fields/BusinessRuleConditionsEditor.tsx +4 -1
- package/src/modules/workflows/components/fields/StartPreConditionsEditor.tsx +4 -1
- package/src/modules/workflows/components/fields/WorkflowSelectorField.tsx +4 -1
- package/src/modules/workflows/frontend/checkout-demo/page.tsx +9 -7
- package/src/modules/workflows/lib/activity-executor.ts +26 -21
- package/src/modules/workflows/lib/activity-worker-handler.ts +9 -15
- package/src/modules/workflows/lib/code-registry.ts +8 -7
- package/src/modules/workflows/lib/compensation-handler.ts +5 -2
- package/src/modules/workflows/lib/edgeFormTransforms.ts +4 -1
- package/src/modules/workflows/lib/event-trigger-service.ts +6 -3
- package/src/modules/workflows/lib/nodeFormTransforms.ts +4 -1
- package/src/modules/workflows/lib/seeds.ts +17 -2
- package/src/modules/workflows/lib/signal-handler.ts +4 -1
- package/src/modules/workflows/lib/start-validator.ts +10 -3
- package/src/modules/workflows/lib/step-handler.ts +4 -1
- package/src/modules/workflows/lib/task-handler.ts +4 -1
- package/src/modules/workflows/lib/transition-handler.ts +6 -3
- package/src/modules/workflows/lib/workflow-executor.ts +28 -15
- package/src/modules/workflows/subscribers/event-trigger.ts +22 -24
- package/src/modules/workflows/subscribers/task-assigned-notification.ts +4 -1
- package/src/modules/workflows/workers/workflow-activities.worker.ts +31 -20
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { SalesOrder, SalesQuote } from "@open-mercato/core/modules/sales/data/entities";
|
|
2
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
3
|
+
const logger = createLogger("sales");
|
|
2
4
|
const metadata = {
|
|
3
5
|
event: "customers.person.deleted",
|
|
4
6
|
persistent: true,
|
|
@@ -24,7 +26,7 @@ async function handle(payload, ctx) {
|
|
|
24
26
|
)
|
|
25
27
|
]);
|
|
26
28
|
} catch (err) {
|
|
27
|
-
|
|
29
|
+
logger.error("sales.reconcile-on-person-delete Failed to null customerEntityId on sales documents", { err });
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/sales/subscribers/reconcileOnCustomerDelete.ts"],
|
|
4
|
-
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { SalesOrder, SalesQuote } from '@open-mercato/core/modules/sales/data/entities'\n\nexport const metadata = {\n event: 'customers.person.deleted',\n persistent: true,\n id: 'sales:reconcile-on-person-delete',\n}\n\nexport default async function handle(\n payload: unknown,\n ctx: { resolve: <T = unknown>(name: string) => T; eventName?: string },\n): Promise<void> {\n const data = payload as Record<string, unknown>\n const entityId = (data?.entityId as string | undefined) ?? (data?.id as string | undefined)\n const tenantId = data?.tenantId as string | undefined\n if (!entityId || !tenantId) return\n\n const em = ctx.resolve<EntityManager>('em')\n\n try {\n await Promise.all([\n em.nativeUpdate(\n SalesOrder,\n { customerEntityId: entityId, tenantId },\n { customerEntityId: null },\n ),\n em.nativeUpdate(\n SalesQuote,\n { customerEntityId: entityId, tenantId },\n { customerEntityId: null },\n ),\n ])\n } catch (err) {\n
|
|
5
|
-
"mappings": "AACA,SAAS,YAAY,kBAAkB;
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { SalesOrder, SalesQuote } from '@open-mercato/core/modules/sales/data/entities'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('sales')\n\nexport const metadata = {\n event: 'customers.person.deleted',\n persistent: true,\n id: 'sales:reconcile-on-person-delete',\n}\n\nexport default async function handle(\n payload: unknown,\n ctx: { resolve: <T = unknown>(name: string) => T; eventName?: string },\n): Promise<void> {\n const data = payload as Record<string, unknown>\n const entityId = (data?.entityId as string | undefined) ?? (data?.id as string | undefined)\n const tenantId = data?.tenantId as string | undefined\n if (!entityId || !tenantId) return\n\n const em = ctx.resolve<EntityManager>('em')\n\n try {\n await Promise.all([\n em.nativeUpdate(\n SalesOrder,\n { customerEntityId: entityId, tenantId },\n { customerEntityId: null },\n ),\n em.nativeUpdate(\n SalesQuote,\n { customerEntityId: entityId, tenantId },\n { customerEntityId: null },\n ),\n ])\n } catch (err) {\n logger.error('sales.reconcile-on-person-delete Failed to null customerEntityId on sales documents', { err })\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,YAAY,kBAAkB;AACvC,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,OAAO;AAE5B,MAAM,WAAW;AAAA,EACtB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,IAAI;AACN;AAEA,eAAO,OACL,SACA,KACe;AACf,QAAM,OAAO;AACb,QAAM,WAAY,MAAM,YAAoC,MAAM;AAClE,QAAM,WAAW,MAAM;AACvB,MAAI,CAAC,YAAY,CAAC,SAAU;AAE5B,QAAM,KAAK,IAAI,QAAuB,IAAI;AAE1C,MAAI;AACF,UAAM,QAAQ,IAAI;AAAA,MAChB,GAAG;AAAA,QACD;AAAA,QACA,EAAE,kBAAkB,UAAU,SAAS;AAAA,QACvC,EAAE,kBAAkB,KAAK;AAAA,MAC3B;AAAA,MACA,GAAG;AAAA,QACD;AAAA,QACA,EAAE,kBAAkB,UAAU,SAAS;AAAA,QACvC,EAAE,kBAAkB,KAAK;AAAA,MAC3B;AAAA,IACF,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,MAAM,uFAAuF,EAAE,IAAI,CAAC;AAAA,EAC7G;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,6 +7,8 @@ import { CrudHttpError, isCrudHttpError } from "@open-mercato/shared/lib/crud/er
|
|
|
7
7
|
import { findAndCountWithDecryption } from "@open-mercato/shared/lib/encryption/find";
|
|
8
8
|
import { resolveDateRange } from "@open-mercato/ui/backend/date-range";
|
|
9
9
|
import { resolveWidgetScope } from "@open-mercato/core/modules/dashboards/lib/widgetScope";
|
|
10
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
11
|
+
const logger = createLogger("sales");
|
|
10
12
|
const WIDGET_CACHE_TTL = 12e4;
|
|
11
13
|
const WIDGET_CACHE_SEGMENT_TTL = 864e5;
|
|
12
14
|
const WIDGET_CACHE_SEGMENT_KEY = "widget-data:__segment__";
|
|
@@ -94,7 +96,7 @@ function makeDashboardWidgetRoute(config) {
|
|
|
94
96
|
return NextResponse.json(cached);
|
|
95
97
|
}
|
|
96
98
|
} catch (err) {
|
|
97
|
-
|
|
99
|
+
logger.debug("widget-cache read failed", { err });
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
const where = {
|
|
@@ -129,7 +131,7 @@ function makeDashboardWidgetRoute(config) {
|
|
|
129
131
|
{ ttl: WIDGET_CACHE_SEGMENT_TTL, tags: ["widget-data"] }
|
|
130
132
|
));
|
|
131
133
|
} catch (err) {
|
|
132
|
-
|
|
134
|
+
logger.debug("widget-cache write failed", { err });
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
return NextResponse.json(response);
|
|
@@ -137,7 +139,7 @@ function makeDashboardWidgetRoute(config) {
|
|
|
137
139
|
if (isCrudHttpError(err)) {
|
|
138
140
|
return NextResponse.json(err.body, { status: err.status });
|
|
139
141
|
}
|
|
140
|
-
|
|
142
|
+
logger.error("dashboard widget route failed", { errorPrefix: config.errorPrefix, err });
|
|
141
143
|
return NextResponse.json(
|
|
142
144
|
{ error: translate(`${config.errorPrefix}.error`, config.openApi.errorFallback) },
|
|
143
145
|
{ status: 500 }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/sales/widgets/dashboard/makeDashboardWidgetRoute.ts"],
|
|
4
|
-
"sourcesContent": ["import { createHash } from 'node:crypto'\nimport { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport type { EntityName, FilterQuery, FindOptions } from '@mikro-orm/core'\nimport type { CacheStrategy } from '@open-mercato/cache'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { runWithCacheTenant } from '@open-mercato/cache'\nimport { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport { findAndCountWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { resolveDateRange } from '@open-mercato/ui/backend/date-range'\nimport type { DatePeriodOption } from '../../api/dashboard/widgets/helpers'\nimport { resolveWidgetScope, type WidgetScopeContext } from '@open-mercato/core/modules/dashboards/lib/widgetScope'\n\nconst WIDGET_CACHE_TTL = 120_000\nconst WIDGET_CACHE_SEGMENT_TTL = 86_400_000\nconst WIDGET_CACHE_SEGMENT_KEY = 'widget-data:__segment__'\n\nconst querySchema = z.object({\n limit: z.coerce.number().min(1).max(20).default(5),\n datePeriod: z.enum(['last24h', 'last7d', 'last30d', 'custom']).default('last24h'),\n customFrom: z.string().optional(),\n customTo: z.string().optional(),\n tenantId: z.string().uuid().optional(),\n organizationId: z.string().uuid().optional(),\n})\n\ntype WidgetContext = WidgetScopeContext & {\n limit: number\n datePeriod: DatePeriodOption\n customFrom?: string\n customTo?: string\n}\n\nfunction normalizeOrganizationIds(organizationIds: string[] | null): string[] | null {\n if (organizationIds === null) return null\n const set = new Set(organizationIds)\n return Array.from(set).sort((a, b) => a.localeCompare(b))\n}\n\nfunction buildCacheKey(\n cacheId: string,\n params: {\n tenantId: string\n organizationIds: string[] | null\n limit: number\n datePeriod: DatePeriodOption\n customFrom?: string\n customTo?: string\n }\n): string {\n const hash = createHash('sha256')\n hash.update(\n JSON.stringify({\n widget: cacheId,\n ...params,\n organizationIds: normalizeOrganizationIds(params.organizationIds),\n })\n )\n return `widget-data:${hash.digest('hex').slice(0, 16)}`\n}\n\nasync function resolveContext(req: Request, translate: (key: string, fallback?: string) => string): Promise<WidgetContext> {\n const url = new URL(req.url)\n const rawQuery: Record<string, string> = {}\n for (const [key, value] of url.searchParams.entries()) rawQuery[key] = value\n const parsed = querySchema.safeParse(rawQuery)\n if (!parsed.success) {\n throw new CrudHttpError(400, { error: translate('sales.errors.invalid_query', 'Invalid query parameters') })\n }\n\n const { container, em, tenantId, organizationIds } = await resolveWidgetScope(req, translate, {\n tenantId: parsed.data.tenantId ?? null,\n organizationId: parsed.data.organizationId ?? null,\n })\n\n return {\n container,\n em,\n tenantId,\n organizationIds,\n limit: parsed.data.limit,\n datePeriod: parsed.data.datePeriod,\n customFrom: parsed.data.customFrom,\n customTo: parsed.data.customTo,\n }\n}\n\nexport interface DashboardWidgetRouteConfig<TEntity extends object, TItem extends Record<string, unknown>> {\n entity: { new (...args: unknown[]): TEntity }\n cacheId: string\n cacheTags: string[]\n feature: string\n mapItem: (entity: Record<string, unknown>) => TItem\n itemSchema: z.ZodTypeAny\n openApi: {\n summary: string\n description: string\n getSummary: string\n itemDescription: string\n errorFallback: string\n }\n errorPrefix: string\n}\n\ntype WidgetResponse<TItem> = {\n items: TItem[]\n total: number\n dateRange: {\n from: string\n to: string\n }\n}\n\nconst widgetErrorSchema = z.object({ error: z.string() })\n\nexport function makeDashboardWidgetRoute<TEntity extends object, TItem extends Record<string, unknown>>(config: DashboardWidgetRouteConfig<TEntity, TItem>) {\n const cacheTags = ['widget-data', ...config.cacheTags]\n\n const metadata = {\n GET: { requireAuth: true, requireFeatures: ['dashboards.view', config.feature] },\n }\n\n async function GET(req: Request) {\n const { translate } = await resolveTranslations()\n try {\n const { container, em, tenantId, organizationIds, limit, datePeriod, customFrom, customTo } = await resolveContext(\n req,\n translate\n )\n const range = (() => {\n if (datePeriod === 'custom') {\n const from = customFrom ? new Date(customFrom) : new Date(0)\n const to = customTo ? new Date(customTo) : new Date()\n return { start: from, end: to }\n }\n const preset = datePeriod === 'last7d' ? 'last_7_days' : datePeriod === 'last30d' ? 'last_30_days' : 'today'\n return resolveDateRange(preset)\n })()\n\n let cache: CacheStrategy | null = null\n try {\n cache = container.resolve<CacheStrategy>('cache')\n } catch {\n cache = null\n }\n\n const cacheKey = buildCacheKey(config.cacheId, { tenantId, organizationIds, limit, datePeriod, customFrom, customTo })\n const tenantScope = tenantId ?? null\n\n if (cache) {\n try {\n const cached = await runWithCacheTenant(tenantScope, () => cache!.get(cacheKey))\n if (cached && typeof cached === 'object' && 'items' in (cached as object)) {\n return NextResponse.json(cached)\n }\n } catch (err) {\n
|
|
5
|
-
"mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAIlB,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,eAAe,uBAAuB;AAC/C,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB;AAEjC,SAAS,0BAAmD;
|
|
4
|
+
"sourcesContent": ["import { createHash } from 'node:crypto'\nimport { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport type { EntityName, FilterQuery, FindOptions } from '@mikro-orm/core'\nimport type { CacheStrategy } from '@open-mercato/cache'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { runWithCacheTenant } from '@open-mercato/cache'\nimport { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport { findAndCountWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { resolveDateRange } from '@open-mercato/ui/backend/date-range'\nimport type { DatePeriodOption } from '../../api/dashboard/widgets/helpers'\nimport { resolveWidgetScope, type WidgetScopeContext } from '@open-mercato/core/modules/dashboards/lib/widgetScope'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('sales')\n\nconst WIDGET_CACHE_TTL = 120_000\nconst WIDGET_CACHE_SEGMENT_TTL = 86_400_000\nconst WIDGET_CACHE_SEGMENT_KEY = 'widget-data:__segment__'\n\nconst querySchema = z.object({\n limit: z.coerce.number().min(1).max(20).default(5),\n datePeriod: z.enum(['last24h', 'last7d', 'last30d', 'custom']).default('last24h'),\n customFrom: z.string().optional(),\n customTo: z.string().optional(),\n tenantId: z.string().uuid().optional(),\n organizationId: z.string().uuid().optional(),\n})\n\ntype WidgetContext = WidgetScopeContext & {\n limit: number\n datePeriod: DatePeriodOption\n customFrom?: string\n customTo?: string\n}\n\nfunction normalizeOrganizationIds(organizationIds: string[] | null): string[] | null {\n if (organizationIds === null) return null\n const set = new Set(organizationIds)\n return Array.from(set).sort((a, b) => a.localeCompare(b))\n}\n\nfunction buildCacheKey(\n cacheId: string,\n params: {\n tenantId: string\n organizationIds: string[] | null\n limit: number\n datePeriod: DatePeriodOption\n customFrom?: string\n customTo?: string\n }\n): string {\n const hash = createHash('sha256')\n hash.update(\n JSON.stringify({\n widget: cacheId,\n ...params,\n organizationIds: normalizeOrganizationIds(params.organizationIds),\n })\n )\n return `widget-data:${hash.digest('hex').slice(0, 16)}`\n}\n\nasync function resolveContext(req: Request, translate: (key: string, fallback?: string) => string): Promise<WidgetContext> {\n const url = new URL(req.url)\n const rawQuery: Record<string, string> = {}\n for (const [key, value] of url.searchParams.entries()) rawQuery[key] = value\n const parsed = querySchema.safeParse(rawQuery)\n if (!parsed.success) {\n throw new CrudHttpError(400, { error: translate('sales.errors.invalid_query', 'Invalid query parameters') })\n }\n\n const { container, em, tenantId, organizationIds } = await resolveWidgetScope(req, translate, {\n tenantId: parsed.data.tenantId ?? null,\n organizationId: parsed.data.organizationId ?? null,\n })\n\n return {\n container,\n em,\n tenantId,\n organizationIds,\n limit: parsed.data.limit,\n datePeriod: parsed.data.datePeriod,\n customFrom: parsed.data.customFrom,\n customTo: parsed.data.customTo,\n }\n}\n\nexport interface DashboardWidgetRouteConfig<TEntity extends object, TItem extends Record<string, unknown>> {\n entity: { new (...args: unknown[]): TEntity }\n cacheId: string\n cacheTags: string[]\n feature: string\n mapItem: (entity: Record<string, unknown>) => TItem\n itemSchema: z.ZodTypeAny\n openApi: {\n summary: string\n description: string\n getSummary: string\n itemDescription: string\n errorFallback: string\n }\n errorPrefix: string\n}\n\ntype WidgetResponse<TItem> = {\n items: TItem[]\n total: number\n dateRange: {\n from: string\n to: string\n }\n}\n\nconst widgetErrorSchema = z.object({ error: z.string() })\n\nexport function makeDashboardWidgetRoute<TEntity extends object, TItem extends Record<string, unknown>>(config: DashboardWidgetRouteConfig<TEntity, TItem>) {\n const cacheTags = ['widget-data', ...config.cacheTags]\n\n const metadata = {\n GET: { requireAuth: true, requireFeatures: ['dashboards.view', config.feature] },\n }\n\n async function GET(req: Request) {\n const { translate } = await resolveTranslations()\n try {\n const { container, em, tenantId, organizationIds, limit, datePeriod, customFrom, customTo } = await resolveContext(\n req,\n translate\n )\n const range = (() => {\n if (datePeriod === 'custom') {\n const from = customFrom ? new Date(customFrom) : new Date(0)\n const to = customTo ? new Date(customTo) : new Date()\n return { start: from, end: to }\n }\n const preset = datePeriod === 'last7d' ? 'last_7_days' : datePeriod === 'last30d' ? 'last_30_days' : 'today'\n return resolveDateRange(preset)\n })()\n\n let cache: CacheStrategy | null = null\n try {\n cache = container.resolve<CacheStrategy>('cache')\n } catch {\n cache = null\n }\n\n const cacheKey = buildCacheKey(config.cacheId, { tenantId, organizationIds, limit, datePeriod, customFrom, customTo })\n const tenantScope = tenantId ?? null\n\n if (cache) {\n try {\n const cached = await runWithCacheTenant(tenantScope, () => cache!.get(cacheKey))\n if (cached && typeof cached === 'object' && 'items' in (cached as object)) {\n return NextResponse.json(cached)\n }\n } catch (err) {\n logger.debug('widget-cache read failed', { err })\n }\n }\n\n const where: FilterQuery<{ tenantId: string; deletedAt: Date | null; createdAt: Date; organizationId: string }> = {\n tenantId,\n deletedAt: null,\n createdAt: { $gte: range.start, $lte: range.end },\n }\n\n if (Array.isArray(organizationIds)) {\n const unique = Array.from(new Set(organizationIds))\n where.organizationId = unique.length === 1 ? unique[0] : { $in: unique }\n }\n\n const organizationIdScope = Array.isArray(organizationIds) && organizationIds.length === 1 ? organizationIds[0] : null\n // Generic boundary: config.entity is a class constructor from the factory caller,\n // so we cast to EntityName/FilterQuery at the call site (matching findAndCountWithDecryption's own internal casts)\n const [entities, total] = await findAndCountWithDecryption(\n em,\n config.entity as EntityName<TEntity>,\n where as FilterQuery<TEntity>,\n { limit, orderBy: { createdAt: 'desc' as const } } as FindOptions<TEntity>,\n { tenantId, organizationId: organizationIdScope },\n )\n\n const items = (entities as unknown as Record<string, unknown>[]).map(config.mapItem)\n\n const response: WidgetResponse<TItem> = {\n items,\n total,\n dateRange: { from: range.start.toISOString(), to: range.end.toISOString() },\n }\n\n if (cache) {\n try {\n await runWithCacheTenant(tenantScope, () => cache!.set(cacheKey, response, { ttl: WIDGET_CACHE_TTL, tags: cacheTags }))\n await runWithCacheTenant(tenantScope, () => cache!.set(\n WIDGET_CACHE_SEGMENT_KEY,\n { updatedAt: response.dateRange.to },\n { ttl: WIDGET_CACHE_SEGMENT_TTL, tags: ['widget-data'] },\n ))\n } catch (err) {\n logger.debug('widget-cache write failed', { err })\n }\n }\n\n return NextResponse.json(response)\n } catch (err) {\n if (isCrudHttpError(err)) {\n return NextResponse.json(err.body, { status: err.status })\n }\n logger.error('dashboard widget route failed', { errorPrefix: config.errorPrefix, err })\n return NextResponse.json(\n { error: translate(`${config.errorPrefix}.error`, config.openApi.errorFallback) },\n { status: 500 },\n )\n }\n }\n\n const responseSchema = z.object({\n items: z.array(config.itemSchema),\n total: z.number(),\n dateRange: z.object({\n from: z.string(),\n to: z.string(),\n }),\n })\n\n const openApi: OpenApiRouteDoc = {\n tag: 'Sales',\n summary: config.openApi.summary,\n description: config.openApi.description,\n methods: {\n GET: {\n summary: config.openApi.getSummary,\n query: querySchema,\n responses: [{ status: 200, description: config.openApi.itemDescription, schema: responseSchema }],\n errors: [\n { status: 400, description: 'Invalid query parameters', schema: widgetErrorSchema },\n { status: 401, description: 'Unauthorized', schema: widgetErrorSchema },\n { status: 403, description: 'Forbidden', schema: widgetErrorSchema },\n { status: 500, description: 'Widget failed to load', schema: widgetErrorSchema },\n ],\n },\n },\n }\n\n return { GET, metadata, openApi }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAIlB,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,eAAe,uBAAuB;AAC/C,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB;AAEjC,SAAS,0BAAmD;AAC5D,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,OAAO;AAEnC,MAAM,mBAAmB;AACzB,MAAM,2BAA2B;AACjC,MAAM,2BAA2B;AAEjC,MAAM,cAAc,EAAE,OAAO;AAAA,EAC3B,OAAO,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC;AAAA,EACjD,YAAY,EAAE,KAAK,CAAC,WAAW,UAAU,WAAW,QAAQ,CAAC,EAAE,QAAQ,SAAS;AAAA,EAChF,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,UAAU,EAAE,OAAO,EAAE,SAAS;AA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O,EAAE,KAAK,UAAU,QAAQ;AAClC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,6 +17,8 @@ import { formatRelativeTime } from "@open-mercato/shared/lib/time";
|
|
|
17
17
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
18
18
|
import { DEFAULT_SETTINGS, hydrateSalesNewOrdersSettings } from "./config.js";
|
|
19
19
|
import { readString, toDateInputValue, openNativeDatePicker, formatAmount } from "../shared.js";
|
|
20
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
21
|
+
const logger = createLogger("sales");
|
|
20
22
|
function parseNewOrderItems(payload) {
|
|
21
23
|
const rawItems = Array.isArray(payload?.items) ? payload?.items : [];
|
|
22
24
|
return rawItems.map((item) => {
|
|
@@ -84,7 +86,7 @@ const SalesNewOrdersWidget = ({
|
|
|
84
86
|
const data = await loadNewOrders(hydrated);
|
|
85
87
|
setItems(data);
|
|
86
88
|
} catch (err) {
|
|
87
|
-
|
|
89
|
+
logger.error("Failed to load new orders widget data", { err });
|
|
88
90
|
setError(translate("sales.widgets.newOrders.error", "Failed to load orders"));
|
|
89
91
|
} finally {
|
|
90
92
|
setLoading(false);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/sales/widgets/dashboard/new-orders/widget.client.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\r\n\r\nimport * as React from 'react'\r\nimport Link from 'next/link'\r\nimport type { DashboardWidgetComponentProps } from '@open-mercato/shared/modules/dashboard/widgets'\r\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\r\nimport { Input } from '@open-mercato/ui/primitives/input'\r\nimport {\r\n Select,\r\n SelectContent,\r\n SelectItem,\r\n SelectTrigger,\r\n SelectValue,\r\n} from '@open-mercato/ui/primitives/select'\r\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\r\nimport { Badge } from '@open-mercato/ui/primitives/badge'\r\nimport { formatRelativeTime } from '@open-mercato/shared/lib/time'\r\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\r\nimport { DEFAULT_SETTINGS, hydrateSalesNewOrdersSettings, type DatePeriodOption, type SalesNewOrdersSettings } from './config'\r\nimport { readString, toDateInputValue, openNativeDatePicker, formatAmount } from '../shared'\r\n\r\ntype NewOrderItem = {\r\n id: string\r\n orderNumber: string\r\n status: string | null\r\n customerName: string | null\r\n customerEntityId: string | null\r\n netAmount: string\r\n grossAmount: string\r\n currency: string | null\r\n createdAt: string\r\n}\r\n\r\ntype NewOrdersApiPayload = {\r\n items?: unknown[]\r\n error?: string\r\n}\r\n\r\nfunction parseNewOrderItems(payload: NewOrdersApiPayload | null): NewOrderItem[] {\r\n const rawItems = Array.isArray(payload?.items) ? payload?.items : []\r\n return rawItems\r\n .map((item) => {\r\n if (!item || typeof item !== 'object') return null\r\n const data = item as Record<string, unknown>\r\n const id = readString(data.id)\r\n const orderNumber = readString(data.orderNumber)\r\n const createdAt = readString(data.createdAt)\r\n if (!id || !orderNumber || !createdAt) return null\r\n return {\r\n id,\r\n orderNumber,\r\n status: readString(data.status),\r\n customerName: readString(data.customerName),\r\n customerEntityId: readString(data.customerEntityId),\r\n netAmount: readString(data.netAmount) ?? '0',\r\n grossAmount: readString(data.grossAmount) ?? '0',\r\n currency: readString(data.currency),\r\n createdAt,\r\n }\r\n })\r\n .filter((item): item is NewOrderItem => !!item)\r\n}\r\n\r\nasync function loadNewOrders(settings: SalesNewOrdersSettings): Promise<NewOrderItem[]> {\r\n const params = new URLSearchParams({\r\n limit: String(settings.pageSize),\r\n datePeriod: settings.datePeriod,\r\n })\r\n if (settings.datePeriod === 'custom') {\r\n if (settings.customFrom) params.set('customFrom', settings.customFrom)\r\n if (settings.customTo) params.set('customTo', settings.customTo)\r\n }\r\n\r\n const call = await apiCall<NewOrdersApiPayload>(`/api/sales/dashboard/widgets/new-orders?${params.toString()}`)\r\n if (!call.ok) {\r\n const message =\r\n typeof (call.result as Record<string, unknown> | null)?.error === 'string'\r\n ? ((call.result as Record<string, unknown>).error as string)\r\n : `Request failed with status ${call.status}`\r\n throw new Error(message)\r\n }\r\n return parseNewOrderItems(call.result ?? null)\r\n}\r\n\r\nfunction resolveDetailHref(item: NewOrderItem): string | null {\r\n return item.id ? `/backend/sales/orders/${encodeURIComponent(item.id)}` : null\r\n}\r\n\r\n\r\nconst SalesNewOrdersWidget: React.FC<DashboardWidgetComponentProps<SalesNewOrdersSettings>> = ({\r\n mode,\r\n settings = DEFAULT_SETTINGS,\r\n onSettingsChange,\r\n refreshToken,\r\n onRefreshStateChange,\r\n}) => {\r\n const translate = useT()\r\n const hydrated = React.useMemo(() => hydrateSalesNewOrdersSettings(settings), [settings])\r\n const [items, setItems] = React.useState<NewOrderItem[]>([])\r\n const [loading, setLoading] = React.useState(true)\r\n const [error, setError] = React.useState<string | null>(null)\r\n const [locale, setLocale] = React.useState<string | undefined>(undefined)\r\n\r\n React.useEffect(() => {\r\n if (typeof navigator !== 'undefined') {\r\n setLocale(navigator.language)\r\n }\r\n }, [])\r\n\r\n const refresh = React.useCallback(async () => {\r\n onRefreshStateChange?.(true)\r\n setLoading(true)\r\n setError(null)\r\n try {\r\n const data = await loadNewOrders(hydrated)\r\n setItems(data)\r\n } catch (err) {\r\n console.error('Failed to load new orders widget data', err)\r\n setError(translate('sales.widgets.newOrders.error', 'Failed to load orders'))\r\n } finally {\r\n setLoading(false)\r\n onRefreshStateChange?.(false)\r\n }\r\n }, [hydrated, onRefreshStateChange, translate])\r\n\r\n React.useEffect(() => {\r\n refresh().catch(() => {})\r\n }, [refresh, refreshToken])\r\n\r\n if (mode === 'settings') {\r\n return (\r\n <div className=\"space-y-4 text-sm\">\r\n <div className=\"space-y-1.5\">\r\n <label htmlFor=\"sales-new-orders-page-size\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\r\n {translate('sales.widgets.newOrders.settings.pageSize', 'Number of Orders')}\r\n </label>\r\n <Input\r\n id=\"sales-new-orders-page-size\"\r\n type=\"number\"\r\n min={1}\r\n max={20}\r\n className=\"w-24\"\r\n value={hydrated.pageSize}\r\n onChange={(event) => {\r\n const next = Number(event.target.value)\r\n if (!Number.isFinite(next)) return\r\n const clamped = Math.min(20, Math.max(1, Math.floor(next)))\r\n onSettingsChange?.({ ...hydrated, pageSize: clamped })\r\n }}\r\n />\r\n </div>\r\n\r\n <div className=\"space-y-1.5\">\r\n <label htmlFor=\"sales-new-orders-date-period\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\r\n {translate('sales.widgets.newOrders.settings.datePeriod', 'Date Period')}\r\n </label>\r\n <Select\r\n value={hydrated.datePeriod}\r\n onValueChange={(value) => {\r\n onSettingsChange?.({ ...hydrated, datePeriod: value as DatePeriodOption })\r\n }}\r\n >\r\n <SelectTrigger id=\"sales-new-orders-date-period\" size=\"sm\">\r\n <SelectValue />\r\n </SelectTrigger>\r\n <SelectContent>\r\n <SelectItem value=\"last24h\">{translate('sales.widgets.newOrders.settings.last24h', 'Last 24 hours')}</SelectItem>\r\n <SelectItem value=\"last7d\">{translate('sales.widgets.newOrders.settings.last7d', 'Last 7 days')}</SelectItem>\r\n <SelectItem value=\"last30d\">{translate('sales.widgets.newOrders.settings.last30d', 'Last 30 days')}</SelectItem>\r\n <SelectItem value=\"custom\">{translate('sales.widgets.newOrders.settings.custom', 'Custom range')}</SelectItem>\r\n </SelectContent>\r\n </Select>\r\n </div>\r\n\r\n {hydrated.datePeriod === 'custom' ? (\r\n <div className=\"grid gap-3\">\r\n <div className=\"space-y-1.5\">\r\n <label htmlFor=\"sales-new-orders-custom-from\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\r\n {translate('sales.widgets.newOrders.settings.customFrom', 'From')}\r\n </label>\r\n <input\r\n id=\"sales-new-orders-custom-from\"\r\n type=\"date\"\r\n value={toDateInputValue(hydrated.customFrom)}\r\n onChange={(event) => {\r\n onSettingsChange?.({ ...hydrated, customFrom: event.target.value })\r\n }}\r\n onFocus={openNativeDatePicker}\r\n onClick={openNativeDatePicker}\r\n className=\"w-full rounded-md border border-input bg-background px-2 py-1 text-sm text-foreground focus-visible:border-ring focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\r\n />\r\n </div>\r\n <div className=\"space-y-1.5\">\r\n <label htmlFor=\"sales-new-orders-custom-to\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\r\n {translate('sales.widgets.newOrders.settings.customTo', 'To')}\r\n </label>\r\n <input\r\n id=\"sales-new-orders-custom-to\"\r\n type=\"date\"\r\n value={toDateInputValue(hydrated.customTo)}\r\n onChange={(event) => {\r\n onSettingsChange?.({ ...hydrated, customTo: event.target.value })\r\n }}\r\n onFocus={openNativeDatePicker}\r\n onClick={openNativeDatePicker}\r\n className=\"w-full rounded-md border border-input bg-background px-2 py-1 text-sm text-foreground focus-visible:border-ring focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\r\n />\r\n </div>\r\n </div>\r\n ) : null}\r\n </div>\r\n )\r\n }\r\n\r\n if (error) {\r\n return <p className=\"text-sm text-destructive\">{error}</p>\r\n }\r\n\r\n if (loading) {\r\n return (\r\n <div className=\"flex h-32 items-center justify-center\">\r\n <Spinner className=\"h-6 w-6 text-muted-foreground\" />\r\n </div>\r\n )\r\n }\r\n\r\n if (!items.length) {\r\n return <p className=\"text-sm text-muted-foreground\">{translate('sales.widgets.newOrders.empty', 'No orders found')}</p>\r\n }\r\n\r\n return (\r\n <ul className=\"space-y-3\">\r\n {items.map((item) => {\r\n const detailHref = resolveDetailHref(item)\r\n const amountLabel = formatAmount(item.grossAmount, item.currency, locale)\r\n const createdLabel = formatRelativeTime(item.createdAt) ?? ''\r\n return (\r\n <li key={item.id} className=\"rounded-md border p-3\">\r\n <div className=\"flex items-start justify-between gap-3\">\r\n <div className=\"space-y-1\">\r\n <div className=\"flex items-center gap-2\">\r\n {detailHref ? (\r\n <Link href={detailHref} className=\"text-sm font-semibold text-foreground hover:underline\">\r\n {item.orderNumber}\r\n </Link>\r\n ) : (\r\n <span className=\"text-sm font-semibold text-foreground\">{item.orderNumber}</span>\r\n )}\r\n {item.status ? (\r\n <Badge variant=\"outline\" className=\"text-xs\">\r\n {item.status}\r\n </Badge>\r\n ) : null}\r\n </div>\r\n <p className=\"text-xs text-muted-foreground\">\r\n {item.customerName ?? translate('sales.widgets.newOrders.noCustomer', 'No customer')}\r\n </p>\r\n <p className=\"text-xs text-muted-foreground\">{createdLabel}</p>\r\n </div>\r\n <div className=\"text-right\">\r\n <p className=\"text-sm font-semibold\">{amountLabel}</p>\r\n </div>\r\n </div>\r\n </li>\r\n )\r\n })}\r\n </ul>\r\n )\r\n}\r\n\r\nexport default SalesNewOrdersWidget\r\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport type { DashboardWidgetComponentProps } from '@open-mercato/shared/modules/dashboard/widgets'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@open-mercato/ui/primitives/select'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { formatRelativeTime } from '@open-mercato/shared/lib/time'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { DEFAULT_SETTINGS, hydrateSalesNewOrdersSettings, type DatePeriodOption, type SalesNewOrdersSettings } from './config'\nimport { readString, toDateInputValue, openNativeDatePicker, formatAmount } from '../shared'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('sales')\n\ntype NewOrderItem = {\n id: string\n orderNumber: string\n status: string | null\n customerName: string | null\n customerEntityId: string | null\n netAmount: string\n grossAmount: string\n currency: string | null\n createdAt: string\n}\n\ntype NewOrdersApiPayload = {\n items?: unknown[]\n error?: string\n}\n\nfunction parseNewOrderItems(payload: NewOrdersApiPayload | null): NewOrderItem[] {\n const rawItems = Array.isArray(payload?.items) ? payload?.items : []\n return rawItems\n .map((item) => {\n if (!item || typeof item !== 'object') return null\n const data = item as Record<string, unknown>\n const id = readString(data.id)\n const orderNumber = readString(data.orderNumber)\n const createdAt = readString(data.createdAt)\n if (!id || !orderNumber || !createdAt) return null\n return {\n id,\n orderNumber,\n status: readString(data.status),\n customerName: readString(data.customerName),\n customerEntityId: readString(data.customerEntityId),\n netAmount: readString(data.netAmount) ?? '0',\n grossAmount: readString(data.grossAmount) ?? '0',\n currency: readString(data.currency),\n createdAt,\n }\n })\n .filter((item): item is NewOrderItem => !!item)\n}\n\nasync function loadNewOrders(settings: SalesNewOrdersSettings): Promise<NewOrderItem[]> {\n const params = new URLSearchParams({\n limit: String(settings.pageSize),\n datePeriod: settings.datePeriod,\n })\n if (settings.datePeriod === 'custom') {\n if (settings.customFrom) params.set('customFrom', settings.customFrom)\n if (settings.customTo) params.set('customTo', settings.customTo)\n }\n\n const call = await apiCall<NewOrdersApiPayload>(`/api/sales/dashboard/widgets/new-orders?${params.toString()}`)\n if (!call.ok) {\n const message =\n typeof (call.result as Record<string, unknown> | null)?.error === 'string'\n ? ((call.result as Record<string, unknown>).error as string)\n : `Request failed with status ${call.status}`\n throw new Error(message)\n }\n return parseNewOrderItems(call.result ?? null)\n}\n\nfunction resolveDetailHref(item: NewOrderItem): string | null {\n return item.id ? `/backend/sales/orders/${encodeURIComponent(item.id)}` : null\n}\n\n\nconst SalesNewOrdersWidget: React.FC<DashboardWidgetComponentProps<SalesNewOrdersSettings>> = ({\n mode,\n settings = DEFAULT_SETTINGS,\n onSettingsChange,\n refreshToken,\n onRefreshStateChange,\n}) => {\n const translate = useT()\n const hydrated = React.useMemo(() => hydrateSalesNewOrdersSettings(settings), [settings])\n const [items, setItems] = React.useState<NewOrderItem[]>([])\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n const [locale, setLocale] = React.useState<string | undefined>(undefined)\n\n React.useEffect(() => {\n if (typeof navigator !== 'undefined') {\n setLocale(navigator.language)\n }\n }, [])\n\n const refresh = React.useCallback(async () => {\n onRefreshStateChange?.(true)\n setLoading(true)\n setError(null)\n try {\n const data = await loadNewOrders(hydrated)\n setItems(data)\n } catch (err) {\n logger.error('Failed to load new orders widget data', { err })\n setError(translate('sales.widgets.newOrders.error', 'Failed to load orders'))\n } finally {\n setLoading(false)\n onRefreshStateChange?.(false)\n }\n }, [hydrated, onRefreshStateChange, translate])\n\n React.useEffect(() => {\n refresh().catch(() => {})\n }, [refresh, refreshToken])\n\n if (mode === 'settings') {\n return (\n <div className=\"space-y-4 text-sm\">\n <div className=\"space-y-1.5\">\n <label htmlFor=\"sales-new-orders-page-size\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\n {translate('sales.widgets.newOrders.settings.pageSize', 'Number of Orders')}\n </label>\n <Input\n id=\"sales-new-orders-page-size\"\n type=\"number\"\n min={1}\n max={20}\n className=\"w-24\"\n value={hydrated.pageSize}\n onChange={(event) => {\n const next = Number(event.target.value)\n if (!Number.isFinite(next)) return\n const clamped = Math.min(20, Math.max(1, Math.floor(next)))\n onSettingsChange?.({ ...hydrated, pageSize: clamped })\n }}\n />\n </div>\n\n <div className=\"space-y-1.5\">\n <label htmlFor=\"sales-new-orders-date-period\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\n {translate('sales.widgets.newOrders.settings.datePeriod', 'Date Period')}\n </label>\n <Select\n value={hydrated.datePeriod}\n onValueChange={(value) => {\n onSettingsChange?.({ ...hydrated, datePeriod: value as DatePeriodOption })\n }}\n >\n <SelectTrigger id=\"sales-new-orders-date-period\" size=\"sm\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"last24h\">{translate('sales.widgets.newOrders.settings.last24h', 'Last 24 hours')}</SelectItem>\n <SelectItem value=\"last7d\">{translate('sales.widgets.newOrders.settings.last7d', 'Last 7 days')}</SelectItem>\n <SelectItem value=\"last30d\">{translate('sales.widgets.newOrders.settings.last30d', 'Last 30 days')}</SelectItem>\n <SelectItem value=\"custom\">{translate('sales.widgets.newOrders.settings.custom', 'Custom range')}</SelectItem>\n </SelectContent>\n </Select>\n </div>\n\n {hydrated.datePeriod === 'custom' ? (\n <div className=\"grid gap-3\">\n <div className=\"space-y-1.5\">\n <label htmlFor=\"sales-new-orders-custom-from\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\n {translate('sales.widgets.newOrders.settings.customFrom', 'From')}\n </label>\n <input\n id=\"sales-new-orders-custom-from\"\n type=\"date\"\n value={toDateInputValue(hydrated.customFrom)}\n onChange={(event) => {\n onSettingsChange?.({ ...hydrated, customFrom: event.target.value })\n }}\n onFocus={openNativeDatePicker}\n onClick={openNativeDatePicker}\n className=\"w-full rounded-md border border-input bg-background px-2 py-1 text-sm text-foreground focus-visible:border-ring focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n />\n </div>\n <div className=\"space-y-1.5\">\n <label htmlFor=\"sales-new-orders-custom-to\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\n {translate('sales.widgets.newOrders.settings.customTo', 'To')}\n </label>\n <input\n id=\"sales-new-orders-custom-to\"\n type=\"date\"\n value={toDateInputValue(hydrated.customTo)}\n onChange={(event) => {\n onSettingsChange?.({ ...hydrated, customTo: event.target.value })\n }}\n onFocus={openNativeDatePicker}\n onClick={openNativeDatePicker}\n className=\"w-full rounded-md border border-input bg-background px-2 py-1 text-sm text-foreground focus-visible:border-ring focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n />\n </div>\n </div>\n ) : null}\n </div>\n )\n }\n\n if (error) {\n return <p className=\"text-sm text-destructive\">{error}</p>\n }\n\n if (loading) {\n return (\n <div className=\"flex h-32 items-center justify-center\">\n <Spinner className=\"h-6 w-6 text-muted-foreground\" />\n </div>\n )\n }\n\n if (!items.length) {\n return <p className=\"text-sm text-muted-foreground\">{translate('sales.widgets.newOrders.empty', 'No orders found')}</p>\n }\n\n return (\n <ul className=\"space-y-3\">\n {items.map((item) => {\n const detailHref = resolveDetailHref(item)\n const amountLabel = formatAmount(item.grossAmount, item.currency, locale)\n const createdLabel = formatRelativeTime(item.createdAt) ?? ''\n return (\n <li key={item.id} className=\"rounded-md border p-3\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n {detailHref ? (\n <Link href={detailHref} className=\"text-sm font-semibold text-foreground hover:underline\">\n {item.orderNumber}\n </Link>\n ) : (\n <span className=\"text-sm font-semibold text-foreground\">{item.orderNumber}</span>\n )}\n {item.status ? (\n <Badge variant=\"outline\" className=\"text-xs\">\n {item.status}\n </Badge>\n ) : null}\n </div>\n <p className=\"text-xs text-muted-foreground\">\n {item.customerName ?? translate('sales.widgets.newOrders.noCustomer', 'No customer')}\n </p>\n <p className=\"text-xs text-muted-foreground\">{createdLabel}</p>\n </div>\n <div className=\"text-right\">\n <p className=\"text-sm font-semibold\">{amountLabel}</p>\n </div>\n </div>\n </li>\n )\n })}\n </ul>\n )\n}\n\nexport default SalesNewOrdersWidget\n"],
|
|
5
|
+
"mappings": ";AAuIQ,SACE,KADF;AArIR,YAAY,WAAW;AACvB,OAAO,UAAU;AAEjB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,0BAA0B;AACnC,SAAS,YAAY;AACrB,SAAS,kBAAkB,qCAAyF;AACpH,SAAS,YAAY,kBAAkB,sBAAsB,oBAAoB;AACjF,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,OAAO;AAmBnC,SAAS,mBAAmB,SAAqD;AAC/E,QAAM,WAAW,MAAM,QAAQ,SAAS,KAAK,IAAI,SAAS,QAAQ,CAAC;AACnE,SAAO,SACJ,IAAI,CAAC,SAAS;AACb,QAAI,CAAC,QAAQ,OAAO,SAAS,SAAU,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,QAAiB,WAAU,yBAC1B,+BAAC,SAAI,WAAU,0CACb;AAAA,2BAAC,SAAI,WAAU,aACb;AAAA,6BAAC,SAAI,WAAU,2BACZ;AAAA,uBACC,oBAAC,QAAK,MAAM,YAAY,WAAU,yDAC/B,eAAK,aACR,IAEA,oBAAC,UAAK,WAAU,yCAAyC,eAAK,aAAY;AAAA,UAE3E,KAAK,SACJ,oBAAC,SAAM,SAAQ,WAAU,WAAU,WAChC,eAAK,QACR,IACE;AAAA,WACN;AAAA,QACA,oBAAC,OAAE,WAAU,iCACV,eAAK,gBAAgB,UAAU,sCAAsC,aAAa,GACrF;AAAA,QACA,oBAAC,OAAE,WAAU,iCAAiC,wBAAa;AAAA,SAC7D;AAAA,MACA,oBAAC,SAAI,WAAU,cACb,8BAAC,OAAE,WAAU,yBAAyB,uBAAY,GACpD;AAAA,OACF,KAzBO,KAAK,EA0Bd;AAAA,EAEJ,CAAC,GACH;AAEJ;AAEA,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,6 +17,8 @@ import { formatRelativeTime } from "@open-mercato/shared/lib/time";
|
|
|
17
17
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
18
18
|
import { DEFAULT_SETTINGS, hydrateSalesNewQuotesSettings } from "./config.js";
|
|
19
19
|
import { readString, toDateInputValue, openNativeDatePicker, formatAmount } from "../shared.js";
|
|
20
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
21
|
+
const logger = createLogger("sales");
|
|
20
22
|
function parseNewQuoteItems(payload) {
|
|
21
23
|
const rawItems = Array.isArray(payload?.items) ? payload?.items : [];
|
|
22
24
|
return rawItems.map((item) => {
|
|
@@ -87,7 +89,7 @@ const SalesNewQuotesWidget = ({
|
|
|
87
89
|
const data = await loadNewQuotes(hydrated);
|
|
88
90
|
setItems(data);
|
|
89
91
|
} catch (err) {
|
|
90
|
-
|
|
92
|
+
logger.error("Failed to load new quotes widget data", { err });
|
|
91
93
|
setError(translate("sales.widgets.newQuotes.error", "Failed to load quotes"));
|
|
92
94
|
} finally {
|
|
93
95
|
setLoading(false);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/sales/widgets/dashboard/new-quotes/widget.client.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\r\n\r\nimport * as React from 'react'\r\nimport Link from 'next/link'\r\nimport type { DashboardWidgetComponentProps } from '@open-mercato/shared/modules/dashboard/widgets'\r\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\r\nimport { Input } from '@open-mercato/ui/primitives/input'\r\nimport {\r\n Select,\r\n SelectContent,\r\n SelectItem,\r\n SelectTrigger,\r\n SelectValue,\r\n} from '@open-mercato/ui/primitives/select'\r\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\r\nimport { Badge } from '@open-mercato/ui/primitives/badge'\r\nimport { formatRelativeTime } from '@open-mercato/shared/lib/time'\r\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\r\nimport { DEFAULT_SETTINGS, hydrateSalesNewQuotesSettings, type DatePeriodOption, type SalesNewQuotesSettings } from './config'\r\nimport { readString, toDateInputValue, openNativeDatePicker, formatAmount } from '../shared'\r\n\r\ntype NewQuoteItem = {\r\n id: string\r\n quoteNumber: string\r\n status: string | null\r\n customerName: string | null\r\n customerEntityId: string | null\r\n netAmount: string\r\n grossAmount: string\r\n currency: string | null\r\n createdAt: string\r\n validFrom: string | null\r\n validUntil: string | null\r\n convertedOrderId: string | null\r\n}\r\n\r\ntype NewQuotesApiPayload = {\r\n items?: unknown[]\r\n error?: string\r\n}\r\n\r\nfunction parseNewQuoteItems(payload: NewQuotesApiPayload | null): NewQuoteItem[] {\r\n const rawItems = Array.isArray(payload?.items) ? payload?.items : []\r\n return rawItems\r\n .map((item) => {\r\n if (!item || typeof item !== 'object') return null\r\n const data = item as Record<string, unknown>\r\n const id = readString(data.id)\r\n const quoteNumber = readString(data.quoteNumber)\r\n const createdAt = readString(data.createdAt)\r\n if (!id || !quoteNumber || !createdAt) return null\r\n return {\r\n id,\r\n quoteNumber,\r\n status: readString(data.status),\r\n customerName: readString(data.customerName),\r\n customerEntityId: readString(data.customerEntityId),\r\n netAmount: readString(data.netAmount) ?? '0',\r\n grossAmount: readString(data.grossAmount) ?? '0',\r\n currency: readString(data.currency),\r\n createdAt,\r\n validFrom: readString(data.validFrom),\r\n validUntil: readString(data.validUntil),\r\n convertedOrderId: readString(data.convertedOrderId),\r\n }\r\n })\r\n .filter((item): item is NewQuoteItem => !!item)\r\n}\r\n\r\nasync function loadNewQuotes(settings: SalesNewQuotesSettings): Promise<NewQuoteItem[]> {\r\n const params = new URLSearchParams({\r\n limit: String(settings.pageSize),\r\n datePeriod: settings.datePeriod,\r\n })\r\n if (settings.datePeriod === 'custom') {\r\n if (settings.customFrom) params.set('customFrom', settings.customFrom)\r\n if (settings.customTo) params.set('customTo', settings.customTo)\r\n }\r\n\r\n const call = await apiCall<NewQuotesApiPayload>(`/api/sales/dashboard/widgets/new-quotes?${params.toString()}`)\r\n if (!call.ok) {\r\n const message =\r\n typeof (call.result as Record<string, unknown> | null)?.error === 'string'\r\n ? ((call.result as Record<string, unknown>).error as string)\r\n : `Request failed with status ${call.status}`\r\n throw new Error(message)\r\n }\r\n return parseNewQuoteItems(call.result ?? null)\r\n}\r\n\r\nfunction resolveDetailHref(item: NewQuoteItem): string | null {\r\n return item.id ? `/backend/sales/quotes/${encodeURIComponent(item.id)}` : null\r\n}\r\n\r\n\r\nconst SalesNewQuotesWidget: React.FC<DashboardWidgetComponentProps<SalesNewQuotesSettings>> = ({\r\n mode,\r\n settings = DEFAULT_SETTINGS,\r\n onSettingsChange,\r\n refreshToken,\r\n onRefreshStateChange,\r\n}) => {\r\n const translate = useT()\r\n const hydrated = React.useMemo(() => hydrateSalesNewQuotesSettings(settings), [settings])\r\n const [items, setItems] = React.useState<NewQuoteItem[]>([])\r\n const [loading, setLoading] = React.useState(true)\r\n const [error, setError] = React.useState<string | null>(null)\r\n const [locale, setLocale] = React.useState<string | undefined>(undefined)\r\n\r\n React.useEffect(() => {\r\n if (typeof navigator !== 'undefined') {\r\n setLocale(navigator.language)\r\n }\r\n }, [])\r\n\r\n const refresh = React.useCallback(async () => {\r\n onRefreshStateChange?.(true)\r\n setLoading(true)\r\n setError(null)\r\n try {\r\n const data = await loadNewQuotes(hydrated)\r\n setItems(data)\r\n } catch (err) {\r\n console.error('Failed to load new quotes widget data', err)\r\n setError(translate('sales.widgets.newQuotes.error', 'Failed to load quotes'))\r\n } finally {\r\n setLoading(false)\r\n onRefreshStateChange?.(false)\r\n }\r\n }, [hydrated, onRefreshStateChange, translate])\r\n\r\n React.useEffect(() => {\r\n refresh().catch(() => {})\r\n }, [refresh, refreshToken])\r\n\r\n if (mode === 'settings') {\r\n return (\r\n <div className=\"space-y-4 text-sm\">\r\n <div className=\"space-y-1.5\">\r\n <label htmlFor=\"sales-new-quotes-page-size\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\r\n {translate('sales.widgets.newQuotes.settings.pageSize', 'Number of Quotes')}\r\n </label>\r\n <Input\r\n id=\"sales-new-quotes-page-size\"\r\n type=\"number\"\r\n min={1}\r\n max={20}\r\n className=\"w-24\"\r\n value={hydrated.pageSize}\r\n onChange={(event) => {\r\n const next = Number(event.target.value)\r\n if (!Number.isFinite(next)) return\r\n const clamped = Math.min(20, Math.max(1, Math.floor(next)))\r\n onSettingsChange?.({ ...hydrated, pageSize: clamped })\r\n }}\r\n />\r\n </div>\r\n\r\n <div className=\"space-y-1.5\">\r\n <label htmlFor=\"sales-new-quotes-date-period\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\r\n {translate('sales.widgets.newQuotes.settings.datePeriod', 'Date Period')}\r\n </label>\r\n <Select\r\n value={hydrated.datePeriod}\r\n onValueChange={(value) => {\r\n onSettingsChange?.({ ...hydrated, datePeriod: value as DatePeriodOption })\r\n }}\r\n >\r\n <SelectTrigger id=\"sales-new-quotes-date-period\" size=\"sm\">\r\n <SelectValue />\r\n </SelectTrigger>\r\n <SelectContent>\r\n <SelectItem value=\"last24h\">{translate('sales.widgets.newQuotes.settings.last24h', 'Last 24 hours')}</SelectItem>\r\n <SelectItem value=\"last7d\">{translate('sales.widgets.newQuotes.settings.last7d', 'Last 7 days')}</SelectItem>\r\n <SelectItem value=\"last30d\">{translate('sales.widgets.newQuotes.settings.last30d', 'Last 30 days')}</SelectItem>\r\n <SelectItem value=\"custom\">{translate('sales.widgets.newQuotes.settings.custom', 'Custom range')}</SelectItem>\r\n </SelectContent>\r\n </Select>\r\n </div>\r\n\r\n {hydrated.datePeriod === 'custom' ? (\r\n <div className=\"grid gap-3\">\r\n <div className=\"space-y-1.5\">\r\n <label htmlFor=\"sales-new-quotes-custom-from\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\r\n {translate('sales.widgets.newQuotes.settings.customFrom', 'From')}\r\n </label>\r\n <input\r\n id=\"sales-new-quotes-custom-from\"\r\n type=\"date\"\r\n value={toDateInputValue(hydrated.customFrom)}\r\n onChange={(event) => {\r\n onSettingsChange?.({ ...hydrated, customFrom: event.target.value })\r\n }}\r\n onFocus={openNativeDatePicker}\r\n onClick={openNativeDatePicker}\r\n className=\"w-full rounded-md border border-input bg-background px-2 py-1 text-sm text-foreground focus-visible:border-ring focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\r\n />\r\n </div>\r\n <div className=\"space-y-1.5\">\r\n <label htmlFor=\"sales-new-quotes-custom-to\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\r\n {translate('sales.widgets.newQuotes.settings.customTo', 'To')}\r\n </label>\r\n <input\r\n id=\"sales-new-quotes-custom-to\"\r\n type=\"date\"\r\n value={toDateInputValue(hydrated.customTo)}\r\n onChange={(event) => {\r\n onSettingsChange?.({ ...hydrated, customTo: event.target.value })\r\n }}\r\n onFocus={openNativeDatePicker}\r\n onClick={openNativeDatePicker}\r\n className=\"w-full rounded-md border border-input bg-background px-2 py-1 text-sm text-foreground focus-visible:border-ring focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\r\n />\r\n </div>\r\n </div>\r\n ) : null}\r\n </div>\r\n )\r\n }\r\n\r\n if (error) {\r\n return <p className=\"text-sm text-destructive\">{error}</p>\r\n }\r\n\r\n if (loading) {\r\n return (\r\n <div className=\"flex h-32 items-center justify-center\">\r\n <Spinner className=\"h-6 w-6 text-muted-foreground\" />\r\n </div>\r\n )\r\n }\r\n\r\n if (!items.length) {\r\n return <p className=\"text-sm text-muted-foreground\">{translate('sales.widgets.newQuotes.empty', 'No quotes found')}</p>\r\n }\r\n\r\n return (\r\n <ul className=\"space-y-3\">\r\n {items.map((item) => {\r\n const detailHref = resolveDetailHref(item)\r\n const amountLabel = formatAmount(item.grossAmount, item.currency, locale)\r\n const createdLabel = formatRelativeTime(item.createdAt) ?? ''\r\n return (\r\n <li key={item.id} className=\"rounded-md border p-3\">\r\n <div className=\"flex items-start justify-between gap-3\">\r\n <div className=\"space-y-1\">\r\n <div className=\"flex items-center gap-2\">\r\n {detailHref ? (\r\n <Link href={detailHref} className=\"text-sm font-semibold text-foreground hover:underline\">\r\n {item.quoteNumber}\r\n </Link>\r\n ) : (\r\n <span className=\"text-sm font-semibold text-foreground\">{item.quoteNumber}</span>\r\n )}\r\n {item.status ? (\r\n <Badge variant=\"outline\" className=\"text-xs\">\r\n {item.status}\r\n </Badge>\r\n ) : null}\r\n </div>\r\n <p className=\"text-xs text-muted-foreground\">\r\n {item.customerName ?? translate('sales.widgets.newQuotes.noCustomer', 'No customer')}\r\n </p>\r\n <p className=\"text-xs text-muted-foreground\">{createdLabel}</p>\r\n </div>\r\n <div className=\"text-right\">\r\n <p className=\"text-sm font-semibold\">{amountLabel}</p>\r\n </div>\r\n </div>\r\n </li>\r\n )\r\n })}\r\n </ul>\r\n )\r\n}\r\n\r\nexport default SalesNewQuotesWidget\r\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport type { DashboardWidgetComponentProps } from '@open-mercato/shared/modules/dashboard/widgets'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@open-mercato/ui/primitives/select'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { formatRelativeTime } from '@open-mercato/shared/lib/time'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { DEFAULT_SETTINGS, hydrateSalesNewQuotesSettings, type DatePeriodOption, type SalesNewQuotesSettings } from './config'\nimport { readString, toDateInputValue, openNativeDatePicker, formatAmount } from '../shared'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('sales')\n\ntype NewQuoteItem = {\n id: string\n quoteNumber: string\n status: string | null\n customerName: string | null\n customerEntityId: string | null\n netAmount: string\n grossAmount: string\n currency: string | null\n createdAt: string\n validFrom: string | null\n validUntil: string | null\n convertedOrderId: string | null\n}\n\ntype NewQuotesApiPayload = {\n items?: unknown[]\n error?: string\n}\n\nfunction parseNewQuoteItems(payload: NewQuotesApiPayload | null): NewQuoteItem[] {\n const rawItems = Array.isArray(payload?.items) ? payload?.items : []\n return rawItems\n .map((item) => {\n if (!item || typeof item !== 'object') return null\n const data = item as Record<string, unknown>\n const id = readString(data.id)\n const quoteNumber = readString(data.quoteNumber)\n const createdAt = readString(data.createdAt)\n if (!id || !quoteNumber || !createdAt) return null\n return {\n id,\n quoteNumber,\n status: readString(data.status),\n customerName: readString(data.customerName),\n customerEntityId: readString(data.customerEntityId),\n netAmount: readString(data.netAmount) ?? '0',\n grossAmount: readString(data.grossAmount) ?? '0',\n currency: readString(data.currency),\n createdAt,\n validFrom: readString(data.validFrom),\n validUntil: readString(data.validUntil),\n convertedOrderId: readString(data.convertedOrderId),\n }\n })\n .filter((item): item is NewQuoteItem => !!item)\n}\n\nasync function loadNewQuotes(settings: SalesNewQuotesSettings): Promise<NewQuoteItem[]> {\n const params = new URLSearchParams({\n limit: String(settings.pageSize),\n datePeriod: settings.datePeriod,\n })\n if (settings.datePeriod === 'custom') {\n if (settings.customFrom) params.set('customFrom', settings.customFrom)\n if (settings.customTo) params.set('customTo', settings.customTo)\n }\n\n const call = await apiCall<NewQuotesApiPayload>(`/api/sales/dashboard/widgets/new-quotes?${params.toString()}`)\n if (!call.ok) {\n const message =\n typeof (call.result as Record<string, unknown> | null)?.error === 'string'\n ? ((call.result as Record<string, unknown>).error as string)\n : `Request failed with status ${call.status}`\n throw new Error(message)\n }\n return parseNewQuoteItems(call.result ?? null)\n}\n\nfunction resolveDetailHref(item: NewQuoteItem): string | null {\n return item.id ? `/backend/sales/quotes/${encodeURIComponent(item.id)}` : null\n}\n\n\nconst SalesNewQuotesWidget: React.FC<DashboardWidgetComponentProps<SalesNewQuotesSettings>> = ({\n mode,\n settings = DEFAULT_SETTINGS,\n onSettingsChange,\n refreshToken,\n onRefreshStateChange,\n}) => {\n const translate = useT()\n const hydrated = React.useMemo(() => hydrateSalesNewQuotesSettings(settings), [settings])\n const [items, setItems] = React.useState<NewQuoteItem[]>([])\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n const [locale, setLocale] = React.useState<string | undefined>(undefined)\n\n React.useEffect(() => {\n if (typeof navigator !== 'undefined') {\n setLocale(navigator.language)\n }\n }, [])\n\n const refresh = React.useCallback(async () => {\n onRefreshStateChange?.(true)\n setLoading(true)\n setError(null)\n try {\n const data = await loadNewQuotes(hydrated)\n setItems(data)\n } catch (err) {\n logger.error('Failed to load new quotes widget data', { err })\n setError(translate('sales.widgets.newQuotes.error', 'Failed to load quotes'))\n } finally {\n setLoading(false)\n onRefreshStateChange?.(false)\n }\n }, [hydrated, onRefreshStateChange, translate])\n\n React.useEffect(() => {\n refresh().catch(() => {})\n }, [refresh, refreshToken])\n\n if (mode === 'settings') {\n return (\n <div className=\"space-y-4 text-sm\">\n <div className=\"space-y-1.5\">\n <label htmlFor=\"sales-new-quotes-page-size\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\n {translate('sales.widgets.newQuotes.settings.pageSize', 'Number of Quotes')}\n </label>\n <Input\n id=\"sales-new-quotes-page-size\"\n type=\"number\"\n min={1}\n max={20}\n className=\"w-24\"\n value={hydrated.pageSize}\n onChange={(event) => {\n const next = Number(event.target.value)\n if (!Number.isFinite(next)) return\n const clamped = Math.min(20, Math.max(1, Math.floor(next)))\n onSettingsChange?.({ ...hydrated, pageSize: clamped })\n }}\n />\n </div>\n\n <div className=\"space-y-1.5\">\n <label htmlFor=\"sales-new-quotes-date-period\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\n {translate('sales.widgets.newQuotes.settings.datePeriod', 'Date Period')}\n </label>\n <Select\n value={hydrated.datePeriod}\n onValueChange={(value) => {\n onSettingsChange?.({ ...hydrated, datePeriod: value as DatePeriodOption })\n }}\n >\n <SelectTrigger id=\"sales-new-quotes-date-period\" size=\"sm\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"last24h\">{translate('sales.widgets.newQuotes.settings.last24h', 'Last 24 hours')}</SelectItem>\n <SelectItem value=\"last7d\">{translate('sales.widgets.newQuotes.settings.last7d', 'Last 7 days')}</SelectItem>\n <SelectItem value=\"last30d\">{translate('sales.widgets.newQuotes.settings.last30d', 'Last 30 days')}</SelectItem>\n <SelectItem value=\"custom\">{translate('sales.widgets.newQuotes.settings.custom', 'Custom range')}</SelectItem>\n </SelectContent>\n </Select>\n </div>\n\n {hydrated.datePeriod === 'custom' ? (\n <div className=\"grid gap-3\">\n <div className=\"space-y-1.5\">\n <label htmlFor=\"sales-new-quotes-custom-from\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\n {translate('sales.widgets.newQuotes.settings.customFrom', 'From')}\n </label>\n <input\n id=\"sales-new-quotes-custom-from\"\n type=\"date\"\n value={toDateInputValue(hydrated.customFrom)}\n onChange={(event) => {\n onSettingsChange?.({ ...hydrated, customFrom: event.target.value })\n }}\n onFocus={openNativeDatePicker}\n onClick={openNativeDatePicker}\n className=\"w-full rounded-md border border-input bg-background px-2 py-1 text-sm text-foreground focus-visible:border-ring focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n />\n </div>\n <div className=\"space-y-1.5\">\n <label htmlFor=\"sales-new-quotes-custom-to\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\n {translate('sales.widgets.newQuotes.settings.customTo', 'To')}\n </label>\n <input\n id=\"sales-new-quotes-custom-to\"\n type=\"date\"\n value={toDateInputValue(hydrated.customTo)}\n onChange={(event) => {\n onSettingsChange?.({ ...hydrated, customTo: event.target.value })\n }}\n onFocus={openNativeDatePicker}\n onClick={openNativeDatePicker}\n className=\"w-full rounded-md border border-input bg-background px-2 py-1 text-sm text-foreground focus-visible:border-ring focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n />\n </div>\n </div>\n ) : null}\n </div>\n )\n }\n\n if (error) {\n return <p className=\"text-sm text-destructive\">{error}</p>\n }\n\n if (loading) {\n return (\n <div className=\"flex h-32 items-center justify-center\">\n <Spinner className=\"h-6 w-6 text-muted-foreground\" />\n </div>\n )\n }\n\n if (!items.length) {\n return <p className=\"text-sm text-muted-foreground\">{translate('sales.widgets.newQuotes.empty', 'No quotes found')}</p>\n }\n\n return (\n <ul className=\"space-y-3\">\n {items.map((item) => {\n const detailHref = resolveDetailHref(item)\n const amountLabel = formatAmount(item.grossAmount, item.currency, locale)\n const createdLabel = formatRelativeTime(item.createdAt) ?? ''\n return (\n <li key={item.id} className=\"rounded-md border p-3\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n {detailHref ? (\n <Link href={detailHref} className=\"text-sm font-semibold text-foreground hover:underline\">\n {item.quoteNumber}\n </Link>\n ) : (\n <span className=\"text-sm font-semibold text-foreground\">{item.quoteNumber}</span>\n )}\n {item.status ? (\n <Badge variant=\"outline\" className=\"text-xs\">\n {item.status}\n </Badge>\n ) : null}\n </div>\n <p className=\"text-xs text-muted-foreground\">\n {item.customerName ?? translate('sales.widgets.newQuotes.noCustomer', 'No customer')}\n </p>\n <p className=\"text-xs text-muted-foreground\">{createdLabel}</p>\n </div>\n <div className=\"text-right\">\n <p className=\"text-sm font-semibold\">{amountLabel}</p>\n </div>\n </div>\n </li>\n )\n })}\n </ul>\n )\n}\n\nexport default SalesNewQuotesWidget\n"],
|
|
5
|
+
"mappings": ";AA6IQ,SACE,KADF;AA3IR,YAAY,WAAW;AACvB,OAAO,UAAU;AAEjB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,0BAA0B;AACnC,SAAS,YAAY;AACrB,SAAS,kBAAkB,qCAAyF;AACpH,SAAS,YAAY,kBAAkB,sBAAsB,oBAAoB;AACjF,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,OAAO;AAsBnC,SAAS,mBAAmB,SAAqD;AAC/E,QAAM,WAAW,MAAM,QAAQ,SAAS,KAAK,IAAI,SAAS,QAAQ,CAAC;AACnE,SAAO,SACJ,IAAI,CAAC,SAAS;AACb,QAAI,CAAC,QAAQ,OAAO,SAAS,SAAU,QAAO;AAC9C,UAAM,OAAO;AACb,UAAM,KAAK,WAAW,KAAK,EAAE;AAC7B,UAAM,cAAc,WAAW,KAAK,WAAW;AAC/C,UAAM,YAAY,WAAW,KAAK,SAAS;AAC3C,QAAI,CAAC,MAAM,CAAC,eAAe,CAAC,UAAW,QAAO;AAC9C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,QAAQ,WAAW,KAAK,MAAM;AAAA,MAC9B,cAAc,WAAW,KAAK,YAAY;AAAA,MAC1C,kBAAkB,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eAAK,aAAY;AAAA,UAE3E,KAAK,SACJ,oBAAC,SAAM,SAAQ,WAAU,WAAU,WAChC,eAAK,QACR,IACE;AAAA,WACN;AAAA,QACA,oBAAC,OAAE,WAAU,iCACV,eAAK,gBAAgB,UAAU,sCAAsC,aAAa,GACrF;AAAA,QACA,oBAAC,OAAE,WAAU,iCAAiC,wBAAa;AAAA,SAC7D;AAAA,MACA,oBAAC,SAAI,WAAU,cACb,8BAAC,OAAE,WAAU,yBAAyB,uBAAY,GACpD;AAAA,OACF,KAzBO,KAAK,EA0Bd;AAAA,EAEJ,CAAC,GACH;AAEJ;AAEA,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NextResponse } from "next/server";
|
|
2
2
|
import { getAuthFromRequest } from "@open-mercato/shared/lib/auth/server";
|
|
3
3
|
import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
|
|
4
|
+
import { CarrierShipmentNotFoundError } from "../../lib/shipping-service.js";
|
|
4
5
|
import { shippingCarrierUpstreamErrorResponse } from "../../lib/upstream-error-response.js";
|
|
5
6
|
import { trackingQuerySchema } from "../../data/validators.js";
|
|
6
7
|
import { shippingCarriersTag } from "../openapi.js";
|
|
@@ -32,6 +33,9 @@ async function GET(req) {
|
|
|
32
33
|
});
|
|
33
34
|
return NextResponse.json(tracking);
|
|
34
35
|
} catch (error) {
|
|
36
|
+
if (error instanceof CarrierShipmentNotFoundError) {
|
|
37
|
+
return NextResponse.json({ error: error.message }, { status: 404 });
|
|
38
|
+
}
|
|
35
39
|
return shippingCarrierUpstreamErrorResponse("tracking.get", error);
|
|
36
40
|
}
|
|
37
41
|
}
|
|
@@ -44,6 +48,7 @@ const openApi = {
|
|
|
44
48
|
tags: [shippingCarriersTag],
|
|
45
49
|
responses: [
|
|
46
50
|
{ status: 200, description: "Tracking returned" },
|
|
51
|
+
{ status: 404, description: "Shipment not found" },
|
|
47
52
|
{ status: 422, description: "Validation failed" },
|
|
48
53
|
{ status: 502, description: "Provider upstream error" }
|
|
49
54
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/shipping_carriers/api/tracking/route.ts"],
|
|
4
|
-
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport type
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,8BAA8B;
|
|
4
|
+
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { CarrierShipmentNotFoundError, type ShippingCarrierService } from '../../lib/shipping-service'\nimport { shippingCarrierUpstreamErrorResponse } from '../../lib/upstream-error-response'\nimport { trackingQuerySchema } from '../../data/validators'\nimport { shippingCarriersTag } from '../openapi'\n\nexport const metadata = {\n path: '/shipping-carriers/tracking',\n GET: { requireAuth: true, requireFeatures: ['shipping_carriers.view'] },\n}\n\nexport async function GET(req: Request) {\n const auth = await getAuthFromRequest(req)\n if (!auth?.tenantId || !auth.orgId) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n const url = new URL(req.url)\n const parsed = trackingQuerySchema.safeParse({\n providerKey: url.searchParams.get('providerKey'),\n shipmentId: url.searchParams.get('shipmentId') ?? undefined,\n trackingNumber: url.searchParams.get('trackingNumber') ?? undefined,\n })\n if (!parsed.success) {\n return NextResponse.json({ error: 'Invalid query', details: parsed.error.flatten() }, { status: 422 })\n }\n const container = await createRequestContainer()\n const service = container.resolve('shippingCarrierService') as ShippingCarrierService\n try {\n const tracking = await service.getTracking({\n ...parsed.data,\n organizationId: auth.orgId as string,\n tenantId: auth.tenantId,\n })\n return NextResponse.json(tracking)\n } catch (error: unknown) {\n if (error instanceof CarrierShipmentNotFoundError) {\n return NextResponse.json({ error: error.message }, { status: 404 })\n }\n return shippingCarrierUpstreamErrorResponse('tracking.get', error)\n }\n}\n\nexport const openApi = {\n tags: [shippingCarriersTag],\n summary: 'Get tracking',\n methods: {\n GET: {\n summary: 'Get tracking',\n tags: [shippingCarriersTag],\n responses: [\n { status: 200, description: 'Tracking returned' },\n { status: 404, description: 'Shipment not found' },\n { status: 422, description: 'Validation failed' },\n { status: 502, description: 'Provider upstream error' },\n ],\n },\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,8BAA8B;AACvC,SAAS,oCAAiE;AAC1E,SAAS,4CAA4C;AACrD,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AAE7B,MAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,KAAK,EAAE,aAAa,MAAM,iBAAiB,CAAC,wBAAwB,EAAE;AACxE;AAEA,eAAsB,IAAI,KAAc;AACtC,QAAM,OAAO,MAAM,mBAAmB,GAAG;AACzC,MAAI,CAAC,MAAM,YAAY,CAAC,KAAK,OAAO;AAClC,WAAO,aAAa,KAAK,EAAE,OAAO,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACrE;AACA,QAAM,MAAM,IAAI,IAAI,IAAI,GAAG;AAC3B,QAAM,SAAS,oBAAoB,UAAU;AAAA,IAC3C,aAAa,IAAI,aAAa,IAAI,aAAa;AAAA,IAC/C,YAAY,IAAI,aAAa,IAAI,YAAY,KAAK;AAAA,IAClD,gBAAgB,IAAI,aAAa,IAAI,gBAAgB,KAAK;AAAA,EAC5D,CAAC;AACD,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,aAAa,KAAK,EAAE,OAAO,iBAAiB,SAAS,OAAO,MAAM,QAAQ,EAAE,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACvG;AACA,QAAM,YAAY,MAAM,uBAAuB;AAC/C,QAAM,UAAU,UAAU,QAAQ,wBAAwB;AAC1D,MAAI;AACF,UAAM,WAAW,MAAM,QAAQ,YAAY;AAAA,MACzC,GAAG,OAAO;AAAA,MACV,gBAAgB,KAAK;AAAA,MACrB,UAAU,KAAK;AAAA,IACjB,CAAC;AACD,WAAO,aAAa,KAAK,QAAQ;AAAA,EACnC,SAAS,OAAgB;AACvB,QAAI,iBAAiB,8BAA8B;AACjD,aAAO,aAAa,KAAK,EAAE,OAAO,MAAM,QAAQ,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,IACpE;AACA,WAAO,qCAAqC,gBAAgB,KAAK;AAAA,EACnE;AACF;AAEO,MAAM,UAAU;AAAA,EACrB,MAAM,CAAC,mBAAmB;AAAA,EAC1B,SAAS;AAAA,EACT,SAAS;AAAA,IACP,KAAK;AAAA,MACH,SAAS;AAAA,MACT,MAAM,CAAC,mBAAmB;AAAA,MAC1B,WAAW;AAAA,QACT,EAAE,QAAQ,KAAK,aAAa,oBAAoB;AAAA,QAChD,EAAE,QAAQ,KAAK,aAAa,qBAAqB;AAAA,QACjD,EAAE,QAAQ,KAAK,aAAa,oBAAoB;AAAA,QAChD,EAAE,QAAQ,KAAK,aAAa,0BAA0B;AAAA,MACxD;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,6 +7,8 @@ import { CarrierShipment } from "../../../data/entities.js";
|
|
|
7
7
|
import { getShippingAdapter } from "../../../lib/adapter-registry.js";
|
|
8
8
|
import { getShippingCarrierQueue } from "../../../lib/queue.js";
|
|
9
9
|
import { shippingCarriersTag } from "../../openapi.js";
|
|
10
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
11
|
+
const logger = createLogger("shipping_carriers").child({ component: "webhook" });
|
|
10
12
|
const metadata = {
|
|
11
13
|
path: "/shipping-carriers/webhook/[provider]",
|
|
12
14
|
POST: { requireAuth: false }
|
|
@@ -89,7 +91,7 @@ async function POST(req, { params }) {
|
|
|
89
91
|
});
|
|
90
92
|
return NextResponse.json({ received: true, queued: true }, { status: 202 });
|
|
91
93
|
} catch (error) {
|
|
92
|
-
|
|
94
|
+
logger.warn("Webhook verification failed", { providerKey, err: error });
|
|
93
95
|
return NextResponse.json({ error: WEBHOOK_VERIFICATION_FAILED }, { status: 401 });
|
|
94
96
|
}
|
|
95
97
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/shipping_carriers/api/webhook/%5Bprovider%5D/route.ts"],
|
|
4
|
-
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { findWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'\nimport { checkRateLimit, getClientIp, RATE_LIMIT_ERROR_FALLBACK } from '@open-mercato/shared/lib/ratelimit/helpers'\nimport type { RateLimiterService } from '@open-mercato/shared/lib/ratelimit/service'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport type { CredentialsService } from '../../../../integrations/lib/credentials-service'\nimport { CarrierShipment } from '../../../data/entities'\nimport { getShippingAdapter } from '../../../lib/adapter-registry'\nimport { getShippingCarrierQueue } from '../../../lib/queue'\nimport { shippingCarriersTag } from '../../openapi'\n\nexport const metadata = {\n path: '/shipping-carriers/webhook/[provider]',\n POST: { requireAuth: false },\n}\n\nconst WEBHOOK_VERIFICATION_FAILED = 'Webhook verification failed'\n\nconst shippingCarrierWebhookRateLimitConfig = {\n points: 60,\n duration: 60,\n keyPrefix: 'shipping_carriers:webhook',\n}\n\nfunction readCarrierShipmentId(payload: Record<string, unknown> | null): string | null {\n if (!payload) return null\n const shipmentId = payload.shipmentId\n if (typeof shipmentId === 'string' && shipmentId.trim().length > 0) return shipmentId.trim()\n const data = payload.data\n if (data && typeof data === 'object') {\n const nested = (data as Record<string, unknown>).shipmentId\n if (typeof nested === 'string' && nested.trim().length > 0) return nested.trim()\n }\n return null\n}\n\nexport async function POST(req: Request, { params }: { params: Promise<{ provider: string }> | { provider: string } }) {\n const resolvedParams = await params\n const providerKey = resolvedParams.provider\n const adapter = getShippingAdapter(providerKey)\n if (!adapter) {\n return NextResponse.json({ error: `No shipping adapter for provider: ${providerKey}` }, { status: 404 })\n }\n\n const container = await createRequestContainer()\n const rateLimitResponse = await checkProviderWebhookRateLimit(container, req, providerKey)\n if (rateLimitResponse) return rateLimitResponse\n\n const rawBody = await req.text()\n const headers: Record<string, string> = {}\n req.headers.forEach((value, key) => {\n headers[key] = value\n })\n\n const em = container.resolve('em') as EntityManager\n const integrationCredentialsService = container.resolve('integrationCredentialsService') as CredentialsService\n const queue = getShippingCarrierQueue('shipping-carriers-webhook')\n const payload = await readJsonSafe<Record<string, unknown>>(rawBody)\n const carrierShipmentId = readCarrierShipmentId(payload)\n\n try {\n // The webhook endpoint is unauthenticated. Tenant/organization scope MUST come from a\n // CarrierShipment whose per-tenant credentials successfully verify the inbound\n // signature \u2014 NEVER from attacker-controlled payload metadata or an unsigned retry.\n // If no candidate shipment can be located by the provider-reported carrierShipmentId,\n // or no candidate's credentials can verify the signature, we fail closed with 401.\n // This mirrors the fix landed for payment_gateways in PR #1311.\n const candidates = carrierShipmentId\n ? await findWithDecryption(\n em,\n CarrierShipment,\n {\n providerKey,\n carrierShipmentId,\n deletedAt: null,\n },\n { limit: 10, orderBy: { createdAt: 'desc' } },\n )\n : []\n\n let shipment: CarrierShipment | null = null\n let matchedScope: { organizationId: string; tenantId: string } | null = null\n let event: Awaited<ReturnType<typeof adapter.verifyWebhook>> | null = null\n let lastVerificationError: unknown = null\n\n for (const candidate of candidates) {\n const candidateScope = { organizationId: candidate.organizationId, tenantId: candidate.tenantId }\n const credentials = await integrationCredentialsService.resolve(`carrier_${providerKey}`, candidateScope) ?? {}\n try {\n event = await adapter.verifyWebhook({ rawBody, headers, credentials })\n shipment = candidate\n matchedScope = candidateScope\n break\n } catch (error: unknown) {\n lastVerificationError = error\n }\n }\n\n if (!event || !shipment || !matchedScope) {\n throw lastVerificationError ?? new Error('Webhook verification failed: no matching shipment')\n }\n\n await queue.enqueue({\n name: 'shipping-carrier-webhook',\n payload: {\n providerKey,\n event,\n shipmentId: shipment.id,\n scope: matchedScope,\n },\n })\n\n return NextResponse.json({ received: true, queued: true }, { status: 202 })\n } catch (error: unknown) {\n
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB,aAAa,iCAAiC;AAIvE,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,+BAA+B;AACxC,SAAS,2BAA2B;AAE7B,MAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,MAAM,EAAE,aAAa,MAAM;AAC7B;AAEA,MAAM,8BAA8B;AAEpC,MAAM,wCAAwC;AAAA,EAC5C,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AACb;AAEA,SAAS,sBAAsB,SAAwD;AACrF,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,aAAa,QAAQ;AAC3B,MAAI,OAAO,eAAe,YAAY,WAAW,KAAK,EAAE,SAAS,EAAG,QAAO,WAAW,KAAK;AAC3F,QAAM,OAAO,QAAQ;AACrB,MAAI,QAAQ,OAAO,SAAS,UAAU;AACpC,UAAM,SAAU,KAAiC;AACjD,QAAI,OAAO,WAAW,YAAY,OAAO,KAAK,EAAE,SAAS,EAAG,QAAO,OAAO,KAAK;AAAA,EACjF;AACA,SAAO;AACT;AAEA,eAAsB,KAAK,KAAc,EAAE,OAAO,GAAqE;AACrH,QAAM,iBAAiB,MAAM;AAC7B,QAAM,cAAc,eAAe;AACnC,QAAM,UAAU,mBAAmB,WAAW;AAC9C,MAAI,CAAC,SAAS;AACZ,WAAO,aAAa,KAAK,EAAE,OAAO,qCAAqC,WAAW,G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AAM,MAAM,QAAQ;AAAA,MAClB,MAAM;AAAA,MACN,SAAS;AAAA,QACP;AAAA,QACA;AAAA,QACA,YAAY,SAAS;AAAA,QACrB,OAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,WAAO,aAAa,KAAK,EAAE,UAAU,MAAM,QAAQ,KAAK,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC5E,SAAS,OAAgB;AACvB,
|
|
4
|
+
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { findWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'\nimport { checkRateLimit, getClientIp, RATE_LIMIT_ERROR_FALLBACK } from '@open-mercato/shared/lib/ratelimit/helpers'\nimport type { RateLimiterService } from '@open-mercato/shared/lib/ratelimit/service'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport type { CredentialsService } from '../../../../integrations/lib/credentials-service'\nimport { CarrierShipment } from '../../../data/entities'\nimport { getShippingAdapter } from '../../../lib/adapter-registry'\nimport { getShippingCarrierQueue } from '../../../lib/queue'\nimport { shippingCarriersTag } from '../../openapi'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('shipping_carriers').child({ component: 'webhook' })\n\nexport const metadata = {\n path: '/shipping-carriers/webhook/[provider]',\n POST: { requireAuth: false },\n}\n\nconst WEBHOOK_VERIFICATION_FAILED = 'Webhook verification failed'\n\nconst shippingCarrierWebhookRateLimitConfig = {\n points: 60,\n duration: 60,\n keyPrefix: 'shipping_carriers:webhook',\n}\n\nfunction readCarrierShipmentId(payload: Record<string, unknown> | null): string | null {\n if (!payload) return null\n const shipmentId = payload.shipmentId\n if (typeof shipmentId === 'string' && shipmentId.trim().length > 0) return shipmentId.trim()\n const data = payload.data\n if (data && typeof data === 'object') {\n const nested = (data as Record<string, unknown>).shipmentId\n if (typeof nested === 'string' && nested.trim().length > 0) return nested.trim()\n }\n return null\n}\n\nexport async function POST(req: Request, { params }: { params: Promise<{ provider: string }> | { provider: string } }) {\n const resolvedParams = await params\n const providerKey = resolvedParams.provider\n const adapter = getShippingAdapter(providerKey)\n if (!adapter) {\n return NextResponse.json({ error: `No shipping adapter for provider: ${providerKey}` }, { status: 404 })\n }\n\n const container = await createRequestContainer()\n const rateLimitResponse = await checkProviderWebhookRateLimit(container, req, providerKey)\n if (rateLimitResponse) return rateLimitResponse\n\n const rawBody = await req.text()\n const headers: Record<string, string> = {}\n req.headers.forEach((value, key) => {\n headers[key] = value\n })\n\n const em = container.resolve('em') as EntityManager\n const integrationCredentialsService = container.resolve('integrationCredentialsService') as CredentialsService\n const queue = getShippingCarrierQueue('shipping-carriers-webhook')\n const payload = await readJsonSafe<Record<string, unknown>>(rawBody)\n const carrierShipmentId = readCarrierShipmentId(payload)\n\n try {\n // The webhook endpoint is unauthenticated. Tenant/organization scope MUST come from a\n // CarrierShipment whose per-tenant credentials successfully verify the inbound\n // signature \u2014 NEVER from attacker-controlled payload metadata or an unsigned retry.\n // If no candidate shipment can be located by the provider-reported carrierShipmentId,\n // or no candidate's credentials can verify the signature, we fail closed with 401.\n // This mirrors the fix landed for payment_gateways in PR #1311.\n const candidates = carrierShipmentId\n ? await findWithDecryption(\n em,\n CarrierShipment,\n {\n providerKey,\n carrierShipmentId,\n deletedAt: null,\n },\n { limit: 10, orderBy: { createdAt: 'desc' } },\n )\n : []\n\n let shipment: CarrierShipment | null = null\n let matchedScope: { organizationId: string; tenantId: string } | null = null\n let event: Awaited<ReturnType<typeof adapter.verifyWebhook>> | null = null\n let lastVerificationError: unknown = null\n\n for (const candidate of candidates) {\n const candidateScope = { organizationId: candidate.organizationId, tenantId: candidate.tenantId }\n const credentials = await integrationCredentialsService.resolve(`carrier_${providerKey}`, candidateScope) ?? {}\n try {\n event = await adapter.verifyWebhook({ rawBody, headers, credentials })\n shipment = candidate\n matchedScope = candidateScope\n break\n } catch (error: unknown) {\n lastVerificationError = error\n }\n }\n\n if (!event || !shipment || !matchedScope) {\n throw lastVerificationError ?? new Error('Webhook verification failed: no matching shipment')\n }\n\n await queue.enqueue({\n name: 'shipping-carrier-webhook',\n payload: {\n providerKey,\n event,\n shipmentId: shipment.id,\n scope: matchedScope,\n },\n })\n\n return NextResponse.json({ received: true, queued: true }, { status: 202 })\n } catch (error: unknown) {\n logger.warn('Webhook verification failed', { providerKey, err: error })\n return NextResponse.json({ error: WEBHOOK_VERIFICATION_FAILED }, { status: 401 })\n }\n}\n\nasync function checkProviderWebhookRateLimit(\n container: { resolve: (name: string) => unknown },\n req: Request,\n providerKey: string,\n): Promise<NextResponse | null> {\n const rateLimiterService = tryResolve<RateLimiterService>(container, 'rateLimiterService')\n if (!rateLimiterService) return null\n\n return checkRateLimit(\n rateLimiterService,\n shippingCarrierWebhookRateLimitConfig,\n `${providerKey}:${getClientIp(req, rateLimiterService.trustProxyDepth) ?? 'unknown'}`,\n RATE_LIMIT_ERROR_FALLBACK,\n )\n}\n\nfunction tryResolve<T>(container: { resolve: (name: string) => unknown }, name: string): T | null {\n try {\n return container.resolve(name) as T\n } catch {\n return null\n }\n}\n\nexport const openApi = {\n tags: [shippingCarriersTag],\n summary: 'Receive shipping carrier webhook',\n methods: {\n POST: {\n summary: 'Process inbound carrier webhook',\n tags: [shippingCarriersTag],\n responses: [\n { status: 202, description: 'Webhook accepted for async processing' },\n { status: 401, description: 'Signature verification failed' },\n { status: 404, description: 'Unknown provider' },\n ],\n },\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB,aAAa,iCAAiC;AAIvE,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,+BAA+B;AACxC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,mBAAmB,EAAE,MAAM,EAAE,WA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oBAAoB;AACzF,MAAI,CAAC,mBAAoB,QAAO;AAEhC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,GAAG,WAAW,IAAI,YAAY,KAAK,mBAAmB,eAAe,KAAK,SAAS;AAAA,IACnF;AAAA,EACF;AACF;AAEA,SAAS,WAAc,WAAmD,MAAwB;AAChG,MAAI;AACF,WAAO,UAAU,QAAQ,IAAI;AAAA,EAC/B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,MAAM,UAAU;AAAA,EACrB,MAAM,CAAC,mBAAmB;AAAA,EAC1B,SAAS;AAAA,EACT,SAAS;AAAA,IACP,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,MAAM,CAAC,mBAAmB;AAAA,MAC1B,WAAW;AAAA,QACT,EAAE,QAAQ,KAAK,aAAa,wCAAwC;AAAA,QACpE,EAAE,QAAQ,KAAK,aAAa,gCAAgC;AAAA,QAC5D,EAAE,QAAQ,KAAK,aAAa,mBAAmB;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,12 @@ import {
|
|
|
18
18
|
syncShipmentStatus,
|
|
19
19
|
TERMINAL_SHIPPING_STATUSES
|
|
20
20
|
} from "./status-sync.js";
|
|
21
|
+
class CarrierShipmentNotFoundError extends Error {
|
|
22
|
+
constructor() {
|
|
23
|
+
super("Shipment not found");
|
|
24
|
+
this.name = "CarrierShipmentNotFoundError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
21
27
|
function createShippingCarrierService(deps) {
|
|
22
28
|
const { em, integrationCredentialsService } = deps;
|
|
23
29
|
async function findShipmentOrThrow(shipmentId, scope) {
|
|
@@ -34,7 +40,26 @@ function createShippingCarrierService(deps) {
|
|
|
34
40
|
scope
|
|
35
41
|
);
|
|
36
42
|
if (!shipment) {
|
|
37
|
-
throw new
|
|
43
|
+
throw new CarrierShipmentNotFoundError();
|
|
44
|
+
}
|
|
45
|
+
return shipment;
|
|
46
|
+
}
|
|
47
|
+
async function findShipmentByTrackingNumberOrThrow(providerKey, trackingNumber, scope) {
|
|
48
|
+
const shipment = await findOneWithDecryption(
|
|
49
|
+
em,
|
|
50
|
+
CarrierShipment,
|
|
51
|
+
{
|
|
52
|
+
providerKey,
|
|
53
|
+
trackingNumber,
|
|
54
|
+
organizationId: scope.organizationId,
|
|
55
|
+
tenantId: scope.tenantId,
|
|
56
|
+
deletedAt: null
|
|
57
|
+
},
|
|
58
|
+
void 0,
|
|
59
|
+
scope
|
|
60
|
+
);
|
|
61
|
+
if (!shipment) {
|
|
62
|
+
throw new CarrierShipmentNotFoundError();
|
|
38
63
|
}
|
|
39
64
|
return shipment;
|
|
40
65
|
}
|
|
@@ -138,28 +163,24 @@ function createShippingCarrierService(deps) {
|
|
|
138
163
|
}
|
|
139
164
|
},
|
|
140
165
|
async getTracking(input) {
|
|
141
|
-
const
|
|
166
|
+
const scope = {
|
|
142
167
|
organizationId: input.organizationId,
|
|
143
168
|
tenantId: input.tenantId
|
|
144
|
-
}
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
},
|
|
154
|
-
void 0,
|
|
155
|
-
{
|
|
156
|
-
organizationId: input.organizationId,
|
|
157
|
-
tenantId: input.tenantId
|
|
169
|
+
};
|
|
170
|
+
const { adapter, credentials } = await resolveAdapter(input.providerKey, scope);
|
|
171
|
+
let shipment;
|
|
172
|
+
if (input.shipmentId) {
|
|
173
|
+
shipment = await findShipmentOrThrow(input.shipmentId, scope);
|
|
174
|
+
} else {
|
|
175
|
+
const trackingNumber = input.trackingNumber;
|
|
176
|
+
if (!trackingNumber) {
|
|
177
|
+
throw new CarrierShipmentNotFoundError();
|
|
158
178
|
}
|
|
159
|
-
|
|
179
|
+
shipment = await findShipmentByTrackingNumberOrThrow(input.providerKey, trackingNumber, scope);
|
|
180
|
+
}
|
|
160
181
|
return adapter.getTracking({
|
|
161
|
-
shipmentId: shipment
|
|
162
|
-
trackingNumber:
|
|
182
|
+
shipmentId: shipment.carrierShipmentId,
|
|
183
|
+
trackingNumber: shipment.trackingNumber,
|
|
163
184
|
credentials
|
|
164
185
|
});
|
|
165
186
|
},
|
|
@@ -252,6 +273,7 @@ function createShippingCarrierService(deps) {
|
|
|
252
273
|
};
|
|
253
274
|
}
|
|
254
275
|
export {
|
|
276
|
+
CarrierShipmentNotFoundError,
|
|
255
277
|
createShippingCarrierService
|
|
256
278
|
};
|
|
257
279
|
//# sourceMappingURL=shipping-service.js.map
|