@open-mercato/core 0.5.1-develop.2691.d8a0934b37 → 0.5.1-develop.2699.f8b50c8046
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/modules/api_keys/data/entities.js +1 -1
- package/dist/modules/api_keys/data/entities.js.map +1 -1
- package/dist/modules/api_keys/services/apiKeyService.js +5 -5
- package/dist/modules/api_keys/services/apiKeyService.js.map +2 -2
- package/dist/modules/attachments/api/library/[id]/route.js +1 -1
- package/dist/modules/attachments/api/library/[id]/route.js.map +2 -2
- package/dist/modules/attachments/api/library/route.js +7 -9
- package/dist/modules/attachments/api/library/route.js.map +2 -2
- package/dist/modules/attachments/api/partitions/route.js +3 -3
- package/dist/modules/attachments/api/partitions/route.js.map +2 -2
- package/dist/modules/attachments/api/route.js +6 -5
- package/dist/modules/attachments/api/route.js.map +2 -2
- package/dist/modules/attachments/api/transfer/route.js +1 -1
- package/dist/modules/attachments/api/transfer/route.js.map +2 -2
- package/dist/modules/attachments/data/entities.js +2 -1
- package/dist/modules/attachments/data/entities.js.map +2 -2
- package/dist/modules/attachments/lib/ocrQueue.js +1 -1
- package/dist/modules/attachments/lib/ocrQueue.js.map +2 -2
- package/dist/modules/audit_logs/api/audit-logs/actions/export/route.js.map +2 -2
- package/dist/modules/audit_logs/api/audit-logs/actions/route.js.map +2 -2
- package/dist/modules/audit_logs/data/entities.js +1 -1
- package/dist/modules/audit_logs/data/entities.js.map +1 -1
- package/dist/modules/audit_logs/services/actionLogService.js +77 -70
- package/dist/modules/audit_logs/services/actionLogService.js.map +2 -2
- package/dist/modules/auth/api/roles/acl/route.js +1 -1
- package/dist/modules/auth/api/roles/acl/route.js.map +2 -2
- package/dist/modules/auth/api/users/acl/route.js +2 -2
- package/dist/modules/auth/api/users/acl/route.js.map +2 -2
- package/dist/modules/auth/api/users/resend-invite/route.js +1 -1
- package/dist/modules/auth/api/users/resend-invite/route.js.map +2 -2
- package/dist/modules/auth/cli.js +12 -6
- package/dist/modules/auth/cli.js.map +2 -2
- package/dist/modules/auth/commands/users.js +1 -1
- package/dist/modules/auth/commands/users.js.map +2 -2
- package/dist/modules/auth/data/entities.js +1 -1
- package/dist/modules/auth/data/entities.js.map +2 -2
- package/dist/modules/auth/lib/setup-app.js +3 -3
- package/dist/modules/auth/lib/setup-app.js.map +2 -2
- package/dist/modules/auth/services/authService.js +2 -2
- package/dist/modules/auth/services/authService.js.map +2 -2
- package/dist/modules/business_rules/api/rules/route.js +3 -3
- package/dist/modules/business_rules/api/rules/route.js.map +2 -2
- package/dist/modules/business_rules/api/sets/[id]/members/route.js +7 -4
- package/dist/modules/business_rules/api/sets/[id]/members/route.js.map +2 -2
- package/dist/modules/business_rules/api/sets/route.js +3 -3
- package/dist/modules/business_rules/api/sets/route.js.map +2 -2
- package/dist/modules/business_rules/cli.js +1 -1
- package/dist/modules/business_rules/cli.js.map +2 -2
- package/dist/modules/business_rules/data/entities.js +2 -9
- package/dist/modules/business_rules/data/entities.js.map +2 -2
- package/dist/modules/business_rules/lib/rule-engine.js +1 -1
- package/dist/modules/business_rules/lib/rule-engine.js.map +2 -2
- package/dist/modules/catalog/api/option-schemas/route.js +0 -1
- package/dist/modules/catalog/api/option-schemas/route.js.map +2 -2
- package/dist/modules/catalog/data/entities.js +2 -11
- package/dist/modules/catalog/data/entities.js.map +2 -2
- package/dist/modules/configs/data/entities.js +2 -1
- package/dist/modules/configs/data/entities.js.map +2 -2
- package/dist/modules/currencies/commands/fetch-configs.js +3 -3
- package/dist/modules/currencies/commands/fetch-configs.js.map +2 -2
- package/dist/modules/currencies/data/entities.js +1 -1
- package/dist/modules/currencies/data/entities.js.map +2 -2
- package/dist/modules/customer_accounts/api/signup.js +1 -1
- package/dist/modules/customer_accounts/api/signup.js.map +2 -2
- package/dist/modules/customer_accounts/data/entities.js +1 -1
- package/dist/modules/customer_accounts/data/entities.js.map +2 -2
- package/dist/modules/customer_accounts/services/customerInvitationService.js +1 -1
- package/dist/modules/customer_accounts/services/customerInvitationService.js.map +2 -2
- package/dist/modules/customer_accounts/services/customerSessionService.js +1 -1
- package/dist/modules/customer_accounts/services/customerSessionService.js.map +2 -2
- package/dist/modules/customer_accounts/services/customerTokenService.js +12 -7
- package/dist/modules/customer_accounts/services/customerTokenService.js.map +2 -2
- package/dist/modules/customers/api/interactions/conflicts/route.js +19 -17
- package/dist/modules/customers/api/interactions/conflicts/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/counts/route.js +7 -6
- package/dist/modules/customers/api/interactions/counts/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/route.js +28 -42
- package/dist/modules/customers/api/interactions/route.js.map +2 -2
- package/dist/modules/customers/api/utils.js +29 -24
- package/dist/modules/customers/api/utils.js.map +2 -2
- package/dist/modules/customers/cli.js +45 -40
- package/dist/modules/customers/cli.js.map +2 -2
- package/dist/modules/customers/commands/dictionaries.js +1 -1
- package/dist/modules/customers/commands/dictionaries.js.map +2 -2
- package/dist/modules/customers/commands/tags.js +1 -1
- package/dist/modules/customers/commands/tags.js.map +2 -2
- package/dist/modules/customers/data/entities.js +2 -12
- package/dist/modules/customers/data/entities.js.map +2 -2
- package/dist/modules/customers/lib/interactionProjection.js +18 -15
- package/dist/modules/customers/lib/interactionProjection.js.map +2 -2
- package/dist/modules/customers/lib/personCompanyLinkTable.js +6 -8
- package/dist/modules/customers/lib/personCompanyLinkTable.js.map +2 -2
- package/dist/modules/dashboards/api/roles/widgets/route.js +1 -1
- package/dist/modules/dashboards/api/roles/widgets/route.js.map +2 -2
- package/dist/modules/dashboards/api/users/widgets/route.js +1 -1
- package/dist/modules/dashboards/api/users/widgets/route.js.map +2 -2
- package/dist/modules/dashboards/data/entities.js +1 -1
- package/dist/modules/dashboards/data/entities.js.map +1 -1
- package/dist/modules/data_sync/api/mappings/route.js +1 -1
- package/dist/modules/data_sync/api/mappings/route.js.map +2 -2
- package/dist/modules/data_sync/data/entities.js +2 -1
- package/dist/modules/data_sync/data/entities.js.map +2 -2
- package/dist/modules/data_sync/lib/id-mapping.js +1 -1
- package/dist/modules/data_sync/lib/id-mapping.js.map +2 -2
- package/dist/modules/data_sync/lib/sync-run-service.js +1 -1
- package/dist/modules/data_sync/lib/sync-run-service.js.map +2 -2
- package/dist/modules/dictionaries/commands/factory.js +1 -1
- package/dist/modules/dictionaries/commands/factory.js.map +2 -2
- package/dist/modules/dictionaries/data/entities.js +2 -9
- package/dist/modules/dictionaries/data/entities.js.map +2 -2
- package/dist/modules/directory/commands/organizations.js +4 -4
- package/dist/modules/directory/commands/organizations.js.map +2 -2
- package/dist/modules/directory/data/entities.js +2 -1
- package/dist/modules/directory/data/entities.js.map +2 -2
- package/dist/modules/entities/api/definitions.js +2 -2
- package/dist/modules/entities/api/definitions.js.map +2 -2
- package/dist/modules/entities/api/encryption.js +2 -2
- package/dist/modules/entities/api/encryption.js.map +2 -2
- package/dist/modules/entities/api/relations/options.js +2 -2
- package/dist/modules/entities/api/relations/options.js.map +2 -2
- package/dist/modules/entities/cli.js +4 -4
- package/dist/modules/entities/cli.js.map +2 -2
- package/dist/modules/entities/data/entities.js +1 -1
- package/dist/modules/entities/data/entities.js.map +2 -2
- package/dist/modules/entities/lib/field-definitions.js +2 -2
- package/dist/modules/entities/lib/field-definitions.js.map +2 -2
- package/dist/modules/entities/lib/register.js +1 -1
- package/dist/modules/entities/lib/register.js.map +2 -2
- package/dist/modules/feature_toggles/data/entities.js +2 -9
- package/dist/modules/feature_toggles/data/entities.js.map +2 -2
- package/dist/modules/inbox_ops/api/proposals/counts/route.js +3 -6
- package/dist/modules/inbox_ops/api/proposals/counts/route.js.map +2 -2
- package/dist/modules/inbox_ops/data/entities.js +2 -8
- package/dist/modules/inbox_ops/data/entities.js.map +2 -2
- package/dist/modules/inbox_ops/lib/messagesIntegration.js +6 -6
- package/dist/modules/inbox_ops/lib/messagesIntegration.js.map +2 -2
- package/dist/modules/integrations/data/entities.js +2 -1
- package/dist/modules/integrations/data/entities.js.map +2 -2
- package/dist/modules/integrations/lib/credentials-service.js +1 -1
- package/dist/modules/integrations/lib/credentials-service.js.map +2 -2
- package/dist/modules/integrations/lib/log-service.js +1 -1
- package/dist/modules/integrations/lib/log-service.js.map +2 -2
- package/dist/modules/integrations/lib/state-service.js +1 -1
- package/dist/modules/integrations/lib/state-service.js.map +2 -2
- package/dist/modules/messages/api/route.js +90 -93
- package/dist/modules/messages/api/route.js.map +2 -2
- package/dist/modules/messages/api/unread-count/route.js +8 -7
- package/dist/modules/messages/api/unread-count/route.js.map +2 -2
- package/dist/modules/messages/commands/confirmations.js +1 -1
- package/dist/modules/messages/commands/confirmations.js.map +2 -2
- package/dist/modules/messages/commands/messages.js +3 -3
- package/dist/modules/messages/commands/messages.js.map +2 -2
- package/dist/modules/messages/data/entities.js +2 -1
- package/dist/modules/messages/data/entities.js.map +2 -2
- package/dist/modules/messages/lib/email-sender.js +1 -1
- package/dist/modules/messages/lib/email-sender.js.map +2 -2
- package/dist/modules/messages/lib/searchLookup.js +8 -8
- package/dist/modules/messages/lib/searchLookup.js.map +2 -2
- package/dist/modules/messages/lib/tokenConsumption.js +9 -4
- package/dist/modules/messages/lib/tokenConsumption.js.map +2 -2
- package/dist/modules/notifications/data/entities.js +2 -1
- package/dist/modules/notifications/data/entities.js.map +2 -2
- package/dist/modules/notifications/lib/notificationRecipients.js +15 -5
- package/dist/modules/notifications/lib/notificationRecipients.js.map +2 -2
- package/dist/modules/notifications/lib/notificationService.js +39 -34
- package/dist/modules/notifications/lib/notificationService.js.map +2 -2
- package/dist/modules/notifications/workers/create-notification.worker.js +14 -13
- package/dist/modules/notifications/workers/create-notification.worker.js.map +2 -2
- package/dist/modules/payment_gateways/api/transactions/route.js +2 -2
- package/dist/modules/payment_gateways/api/transactions/route.js.map +2 -2
- package/dist/modules/payment_gateways/data/entities.js +2 -1
- package/dist/modules/payment_gateways/data/entities.js.map +2 -2
- package/dist/modules/payment_gateways/lib/gateway-service.js +1 -1
- package/dist/modules/payment_gateways/lib/gateway-service.js.map +2 -2
- package/dist/modules/payment_gateways/lib/webhook-utils.js +2 -2
- package/dist/modules/payment_gateways/lib/webhook-utils.js.map +2 -2
- package/dist/modules/perspectives/data/entities.js +1 -1
- package/dist/modules/perspectives/data/entities.js.map +2 -2
- package/dist/modules/planner/data/entities.js +1 -1
- package/dist/modules/planner/data/entities.js.map +2 -2
- package/dist/modules/progress/data/entities.js +2 -1
- package/dist/modules/progress/data/entities.js.map +2 -2
- package/dist/modules/progress/lib/progressServiceImpl.js +1 -1
- package/dist/modules/progress/lib/progressServiceImpl.js.map +2 -2
- package/dist/modules/query_index/api/status.js +66 -57
- package/dist/modules/query_index/api/status.js.map +2 -2
- package/dist/modules/query_index/cli.js +39 -24
- package/dist/modules/query_index/cli.js.map +2 -2
- package/dist/modules/query_index/data/entities.js +1 -1
- package/dist/modules/query_index/data/entities.js.map +2 -2
- package/dist/modules/query_index/di.js +25 -13
- package/dist/modules/query_index/di.js.map +2 -2
- package/dist/modules/query_index/lib/batch.js +31 -33
- package/dist/modules/query_index/lib/batch.js.map +2 -2
- package/dist/modules/query_index/lib/coverage.js +63 -50
- package/dist/modules/query_index/lib/coverage.js.map +2 -2
- package/dist/modules/query_index/lib/engine.js +592 -588
- package/dist/modules/query_index/lib/engine.js.map +2 -2
- package/dist/modules/query_index/lib/indexer.js +74 -47
- package/dist/modules/query_index/lib/indexer.js.map +2 -2
- package/dist/modules/query_index/lib/jobs.js +37 -24
- package/dist/modules/query_index/lib/jobs.js.map +2 -2
- package/dist/modules/query_index/lib/purge.js +19 -11
- package/dist/modules/query_index/lib/purge.js.map +2 -2
- package/dist/modules/query_index/lib/reindexer.js +47 -44
- package/dist/modules/query_index/lib/reindexer.js.map +2 -2
- package/dist/modules/query_index/lib/search-tokens.js +47 -25
- package/dist/modules/query_index/lib/search-tokens.js.map +2 -2
- package/dist/modules/query_index/lib/stale.js +14 -12
- package/dist/modules/query_index/lib/stale.js.map +2 -2
- package/dist/modules/query_index/lib/subscriber-scope.js +2 -2
- package/dist/modules/query_index/lib/subscriber-scope.js.map +2 -2
- package/dist/modules/query_index/subscribers/delete_one.js +3 -2
- package/dist/modules/query_index/subscribers/delete_one.js.map +2 -2
- package/dist/modules/resources/commands/tag-assignments.js +1 -1
- package/dist/modules/resources/commands/tag-assignments.js.map +2 -2
- package/dist/modules/resources/commands/tags.js +1 -1
- package/dist/modules/resources/commands/tags.js.map +2 -2
- package/dist/modules/resources/data/entities.js +2 -1
- package/dist/modules/resources/data/entities.js.map +2 -2
- package/dist/modules/sales/commands/documentAddresses.js +2 -2
- package/dist/modules/sales/commands/documentAddresses.js.map +2 -2
- package/dist/modules/sales/commands/notes.js.map +2 -2
- package/dist/modules/sales/commands/tags.js +1 -1
- package/dist/modules/sales/commands/tags.js.map +2 -2
- package/dist/modules/sales/data/enrichers.js +9 -8
- package/dist/modules/sales/data/enrichers.js.map +2 -2
- package/dist/modules/sales/data/entities.js +2 -11
- package/dist/modules/sales/data/entities.js.map +2 -2
- package/dist/modules/shipping_carriers/data/entities.js +2 -1
- package/dist/modules/shipping_carriers/data/entities.js.map +2 -2
- package/dist/modules/shipping_carriers/lib/shipping-service.js +1 -1
- package/dist/modules/shipping_carriers/lib/shipping-service.js.map +2 -2
- package/dist/modules/shipping_carriers/lib/webhook-utils.js +2 -2
- package/dist/modules/shipping_carriers/lib/webhook-utils.js.map +2 -2
- package/dist/modules/staff/data/entities.js +1 -1
- package/dist/modules/staff/data/entities.js.map +2 -2
- package/dist/modules/translations/api/[entityType]/[entityId]/route.js +3 -5
- package/dist/modules/translations/api/[entityType]/[entityId]/route.js.map +2 -2
- package/dist/modules/translations/api/context.js +2 -2
- package/dist/modules/translations/api/context.js.map +2 -2
- package/dist/modules/translations/commands/translations.js +46 -39
- package/dist/modules/translations/commands/translations.js.map +2 -2
- package/dist/modules/translations/components/TranslationManager.js +19 -10
- package/dist/modules/translations/components/TranslationManager.js.map +2 -2
- package/dist/modules/translations/data/entities.js +1 -1
- package/dist/modules/translations/data/entities.js.map +2 -2
- package/dist/modules/translations/lib/apply.js +4 -4
- package/dist/modules/translations/lib/apply.js.map +2 -2
- package/dist/modules/translations/lib/batch.js +3 -2
- package/dist/modules/translations/lib/batch.js.map +2 -2
- package/dist/modules/translations/subscribers/cleanup.js +3 -5
- package/dist/modules/translations/subscribers/cleanup.js.map +2 -2
- package/dist/modules/workflows/api/definitions/route.js +1 -1
- package/dist/modules/workflows/api/definitions/route.js.map +2 -2
- package/dist/modules/workflows/cli.js +5 -5
- package/dist/modules/workflows/cli.js.map +2 -2
- package/dist/modules/workflows/data/entities.js +2 -1
- package/dist/modules/workflows/data/entities.js.map +2 -2
- package/dist/modules/workflows/lib/event-logger.js +2 -2
- package/dist/modules/workflows/lib/event-logger.js.map +2 -2
- package/dist/modules/workflows/lib/seeds.js +16 -1
- package/dist/modules/workflows/lib/seeds.js.map +2 -2
- package/dist/modules/workflows/lib/step-handler.js +3 -3
- package/dist/modules/workflows/lib/step-handler.js.map +2 -2
- package/dist/modules/workflows/lib/task-handler.js +1 -1
- package/dist/modules/workflows/lib/task-handler.js.map +2 -2
- package/dist/modules/workflows/lib/transition-handler.js +1 -1
- package/dist/modules/workflows/lib/transition-handler.js.map +2 -2
- package/dist/modules/workflows/lib/workflow-executor.js +2 -2
- package/dist/modules/workflows/lib/workflow-executor.js.map +2 -2
- package/jest.config.cjs +4 -2
- package/package.json +3 -3
- package/src/modules/api_keys/data/entities.ts +1 -1
- package/src/modules/api_keys/services/apiKeyService.ts +5 -5
- package/src/modules/attachments/api/library/[id]/route.ts +1 -1
- package/src/modules/attachments/api/library/route.ts +10 -12
- package/src/modules/attachments/api/partitions/route.ts +3 -3
- package/src/modules/attachments/api/route.ts +10 -8
- package/src/modules/attachments/api/transfer/route.ts +1 -1
- package/src/modules/attachments/data/entities.ts +2 -1
- package/src/modules/attachments/lib/ocrQueue.ts +1 -1
- package/src/modules/audit_logs/api/audit-logs/actions/export/route.ts +4 -4
- package/src/modules/audit_logs/api/audit-logs/actions/route.ts +4 -4
- package/src/modules/audit_logs/data/entities.ts +1 -1
- package/src/modules/audit_logs/services/actionLogService.ts +96 -87
- package/src/modules/auth/api/roles/acl/route.ts +1 -1
- package/src/modules/auth/api/users/acl/route.ts +2 -2
- package/src/modules/auth/api/users/resend-invite/route.ts +1 -1
- package/src/modules/auth/cli.ts +46 -40
- package/src/modules/auth/commands/users.ts +1 -1
- package/src/modules/auth/data/entities.ts +1 -1
- package/src/modules/auth/lib/setup-app.ts +3 -3
- package/src/modules/auth/services/authService.ts +2 -2
- package/src/modules/business_rules/api/rules/route.ts +3 -3
- package/src/modules/business_rules/api/sets/[id]/members/route.ts +7 -4
- package/src/modules/business_rules/api/sets/route.ts +3 -3
- package/src/modules/business_rules/cli.ts +1 -1
- package/src/modules/business_rules/data/entities.ts +2 -9
- package/src/modules/business_rules/lib/rule-engine.ts +1 -1
- package/src/modules/catalog/api/option-schemas/route.ts +0 -1
- package/src/modules/catalog/data/entities.ts +2 -11
- package/src/modules/configs/data/entities.ts +2 -1
- package/src/modules/currencies/commands/fetch-configs.ts +3 -3
- package/src/modules/currencies/data/entities.ts +1 -1
- package/src/modules/customer_accounts/api/signup.ts +1 -1
- package/src/modules/customer_accounts/data/entities.ts +1 -1
- package/src/modules/customer_accounts/services/customerInvitationService.ts +1 -1
- package/src/modules/customer_accounts/services/customerSessionService.ts +1 -1
- package/src/modules/customer_accounts/services/customerTokenService.ts +26 -15
- package/src/modules/customers/api/interactions/conflicts/route.ts +26 -23
- package/src/modules/customers/api/interactions/counts/route.ts +13 -11
- package/src/modules/customers/api/interactions/route.ts +32 -44
- package/src/modules/customers/api/utils.ts +45 -37
- package/src/modules/customers/cli.ts +88 -67
- package/src/modules/customers/commands/dictionaries.ts +1 -1
- package/src/modules/customers/commands/tags.ts +1 -1
- package/src/modules/customers/data/entities.ts +2 -12
- package/src/modules/customers/lib/interactionProjection.ts +36 -25
- package/src/modules/customers/lib/personCompanyLinkTable.ts +13 -18
- package/src/modules/dashboards/api/roles/widgets/route.ts +1 -1
- package/src/modules/dashboards/api/users/widgets/route.ts +1 -1
- package/src/modules/dashboards/data/entities.ts +1 -1
- package/src/modules/data_sync/api/mappings/route.ts +1 -1
- package/src/modules/data_sync/data/entities.ts +2 -1
- package/src/modules/data_sync/lib/id-mapping.ts +1 -1
- package/src/modules/data_sync/lib/sync-run-service.ts +1 -1
- package/src/modules/dictionaries/commands/factory.ts +1 -1
- package/src/modules/dictionaries/data/entities.ts +2 -9
- package/src/modules/directory/commands/organizations.ts +4 -4
- package/src/modules/directory/data/entities.ts +2 -1
- package/src/modules/entities/api/definitions.ts +2 -2
- package/src/modules/entities/api/encryption.ts +2 -2
- package/src/modules/entities/api/relations/options.ts +8 -3
- package/src/modules/entities/cli.ts +4 -4
- package/src/modules/entities/data/entities.ts +1 -1
- package/src/modules/entities/lib/field-definitions.ts +2 -2
- package/src/modules/entities/lib/register.ts +1 -1
- package/src/modules/feature_toggles/data/entities.ts +2 -9
- package/src/modules/inbox_ops/api/proposals/counts/route.ts +10 -10
- package/src/modules/inbox_ops/data/entities.ts +2 -8
- package/src/modules/inbox_ops/lib/messagesIntegration.ts +12 -11
- package/src/modules/integrations/data/entities.ts +2 -1
- package/src/modules/integrations/lib/credentials-service.ts +1 -1
- package/src/modules/integrations/lib/log-service.ts +1 -1
- package/src/modules/integrations/lib/state-service.ts +1 -1
- package/src/modules/messages/api/route.ts +134 -123
- package/src/modules/messages/api/unread-count/route.ts +19 -16
- package/src/modules/messages/commands/confirmations.ts +1 -1
- package/src/modules/messages/commands/messages.ts +3 -3
- package/src/modules/messages/data/entities.ts +2 -1
- package/src/modules/messages/lib/email-sender.ts +1 -1
- package/src/modules/messages/lib/searchLookup.ts +16 -13
- package/src/modules/messages/lib/tokenConsumption.ts +16 -8
- package/src/modules/notifications/data/entities.ts +2 -1
- package/src/modules/notifications/lib/notificationRecipients.ts +42 -26
- package/src/modules/notifications/lib/notificationService.ts +53 -42
- package/src/modules/notifications/workers/create-notification.worker.ts +20 -17
- package/src/modules/payment_gateways/api/transactions/route.ts +2 -2
- package/src/modules/payment_gateways/data/entities.ts +2 -1
- package/src/modules/payment_gateways/lib/gateway-service.ts +1 -1
- package/src/modules/payment_gateways/lib/webhook-utils.ts +2 -2
- package/src/modules/perspectives/data/entities.ts +1 -1
- package/src/modules/planner/data/entities.ts +1 -1
- package/src/modules/progress/data/entities.ts +2 -1
- package/src/modules/progress/lib/progressServiceImpl.ts +1 -1
- package/src/modules/query_index/api/status.ts +85 -71
- package/src/modules/query_index/cli.ts +51 -31
- package/src/modules/query_index/data/entities.ts +1 -1
- package/src/modules/query_index/di.ts +41 -16
- package/src/modules/query_index/lib/batch.ts +68 -55
- package/src/modules/query_index/lib/coverage.ts +115 -88
- package/src/modules/query_index/lib/engine.ts +1036 -1096
- package/src/modules/query_index/lib/indexer.ts +115 -79
- package/src/modules/query_index/lib/jobs.ts +51 -31
- package/src/modules/query_index/lib/purge.ts +25 -19
- package/src/modules/query_index/lib/reindexer.ts +97 -84
- package/src/modules/query_index/lib/search-tokens.ts +67 -36
- package/src/modules/query_index/lib/stale.ts +14 -17
- package/src/modules/query_index/lib/subscriber-scope.ts +6 -5
- package/src/modules/query_index/subscribers/delete_one.ts +9 -6
- package/src/modules/resources/commands/tag-assignments.ts +1 -1
- package/src/modules/resources/commands/tags.ts +1 -1
- package/src/modules/resources/data/entities.ts +2 -1
- package/src/modules/sales/commands/documentAddresses.ts +2 -2
- package/src/modules/sales/commands/notes.ts +1 -1
- package/src/modules/sales/commands/tags.ts +1 -1
- package/src/modules/sales/data/enrichers.ts +17 -13
- package/src/modules/sales/data/entities.ts +2 -11
- package/src/modules/shipping_carriers/data/entities.ts +2 -1
- package/src/modules/shipping_carriers/lib/shipping-service.ts +1 -1
- package/src/modules/shipping_carriers/lib/webhook-utils.ts +2 -2
- package/src/modules/staff/data/entities.ts +1 -1
- package/src/modules/translations/api/[entityType]/[entityId]/route.ts +14 -11
- package/src/modules/translations/api/context.ts +4 -4
- package/src/modules/translations/commands/translations.ts +116 -81
- package/src/modules/translations/components/TranslationManager.tsx +23 -14
- package/src/modules/translations/data/entities.ts +1 -1
- package/src/modules/translations/i18n/de.json +1 -0
- package/src/modules/translations/i18n/en.json +1 -0
- package/src/modules/translations/i18n/es.json +1 -0
- package/src/modules/translations/i18n/pl.json +1 -0
- package/src/modules/translations/lib/apply.ts +6 -6
- package/src/modules/translations/lib/batch.ts +9 -7
- package/src/modules/translations/subscribers/cleanup.ts +10 -11
- package/src/modules/workflows/api/definitions/route.ts +1 -1
- package/src/modules/workflows/cli.ts +5 -5
- package/src/modules/workflows/data/entities.ts +2 -1
- package/src/modules/workflows/lib/event-logger.ts +2 -2
- package/src/modules/workflows/lib/seeds.ts +16 -1
- package/src/modules/workflows/lib/step-handler.ts +3 -3
- package/src/modules/workflows/lib/task-handler.ts +1 -1
- package/src/modules/workflows/lib/transition-handler.ts +1 -1
- package/src/modules/workflows/lib/workflow-executor.ts +2 -2
|
@@ -235,7 +235,7 @@ const composeMessageCommand: CommandHandler<unknown, { id: string; threadId: str
|
|
|
235
235
|
organizationId: input.organizationId,
|
|
236
236
|
})
|
|
237
237
|
|
|
238
|
-
await trx.
|
|
238
|
+
await trx.persist(message).flush()
|
|
239
239
|
if (!threadId && !input.isDraft && !message.threadId) {
|
|
240
240
|
message.threadId = message.id
|
|
241
241
|
await trx.flush()
|
|
@@ -567,7 +567,7 @@ const replyMessageCommand: CommandHandler<unknown, { id: string; externalEmail:
|
|
|
567
567
|
tenantId: input.tenantId,
|
|
568
568
|
organizationId: input.organizationId,
|
|
569
569
|
})
|
|
570
|
-
await trx.
|
|
570
|
+
await trx.persist(message).flush()
|
|
571
571
|
for (const recipientUserId of recipientIds) {
|
|
572
572
|
trx.persist(trx.create(MessageRecipient, {
|
|
573
573
|
messageId: message.id,
|
|
@@ -709,7 +709,7 @@ const forwardMessageCommand: CommandHandler<unknown, { id: string; externalEmail
|
|
|
709
709
|
tenantId: input.tenantId,
|
|
710
710
|
organizationId: input.organizationId,
|
|
711
711
|
})
|
|
712
|
-
await trx.
|
|
712
|
+
await trx.persist(newMessage).flush()
|
|
713
713
|
for (const recipient of input.recipients) {
|
|
714
714
|
trx.persist(trx.create(MessageRecipient, {
|
|
715
715
|
messageId: newMessage.id,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OptionalProps } from '@mikro-orm/core'
|
|
2
|
+
import { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
|
|
2
3
|
|
|
3
4
|
export type MessageStatus = 'draft' | 'sent'
|
|
4
5
|
export type MessagePriority = 'low' | 'normal' | 'high' | 'urgent'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
2
|
-
import type
|
|
2
|
+
import { type Kysely, sql } from 'kysely'
|
|
3
3
|
import { resolveSearchConfig } from '@open-mercato/shared/lib/search/config'
|
|
4
4
|
import { tokenizeText } from '@open-mercato/shared/lib/search/tokenize'
|
|
5
5
|
|
|
6
|
-
function
|
|
7
|
-
return
|
|
6
|
+
function getDb(em: EntityManager): Kysely<any> {
|
|
7
|
+
return em.getKysely<any>()
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export async function findMessageIdsBySearchTokens({
|
|
@@ -26,23 +26,26 @@ export async function findMessageIdsBySearchTokens({
|
|
|
26
26
|
const tokens = tokenizeText(trimmed, resolveSearchConfig())
|
|
27
27
|
if (!tokens.hashes.length) return []
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
let searchQuery =
|
|
29
|
+
const db = getDb(em) as any
|
|
30
|
+
let searchQuery = db
|
|
31
|
+
.selectFrom('search_tokens')
|
|
31
32
|
.select('entity_id')
|
|
32
|
-
.where('entity_type', 'messages:message')
|
|
33
|
-
.
|
|
34
|
-
.
|
|
35
|
-
.
|
|
36
|
-
.havingRaw('count(distinct token_hash) >= ?', [tokens.hashes.length])
|
|
33
|
+
.where('entity_type', '=', 'messages:message')
|
|
34
|
+
.where('field', 'in', fields)
|
|
35
|
+
.where('token_hash', 'in', tokens.hashes)
|
|
36
|
+
.where(sql<boolean>`tenant_id is not distinct from ${tenantId}`)
|
|
37
37
|
|
|
38
|
-
searchQuery = searchQuery.whereRaw('tenant_id is not distinct from ?', [tenantId])
|
|
39
38
|
if (organizationId) {
|
|
40
|
-
searchQuery = searchQuery.where('organization_id', organizationId)
|
|
39
|
+
searchQuery = searchQuery.where('organization_id', '=', organizationId)
|
|
41
40
|
} else {
|
|
42
|
-
searchQuery = searchQuery.
|
|
41
|
+
searchQuery = searchQuery.where(sql<boolean>`organization_id is not distinct from ${null}`)
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
const rows = await searchQuery
|
|
45
|
+
.groupBy('entity_id')
|
|
46
|
+
.having(sql<boolean>`count(distinct token_hash) >= ${tokens.hashes.length}`)
|
|
47
|
+
.execute()
|
|
48
|
+
|
|
46
49
|
return rows
|
|
47
50
|
.map((row: { entity_id?: unknown }) => (typeof row.entity_id === 'string' ? row.entity_id : null))
|
|
48
51
|
.filter((id: string | null): id is string => typeof id === 'string' && id.length > 0)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
2
|
+
import { type Kysely, sql } from 'kysely'
|
|
2
3
|
import { MessageAccessToken } from '../data/entities'
|
|
3
4
|
|
|
4
5
|
export const MAX_TOKEN_USE_COUNT = 25
|
|
@@ -9,20 +10,27 @@ export type TokenConsumptionResult =
|
|
|
9
10
|
| { ok: true }
|
|
10
11
|
| { ok: false; reason: TokenConsumptionFailureReason }
|
|
11
12
|
|
|
13
|
+
function getKysely(em: EntityManager): Kysely<any> {
|
|
14
|
+
return (em as unknown as { getKysely: () => Kysely<any> }).getKysely()
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
export async function consumeMessageAccessToken(
|
|
13
18
|
em: EntityManager,
|
|
14
19
|
tokenId: string,
|
|
15
20
|
): Promise<TokenConsumptionResult> {
|
|
16
|
-
const
|
|
21
|
+
const db = getKysely(em)
|
|
17
22
|
const now = new Date()
|
|
18
|
-
const
|
|
19
|
-
.
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
.update({
|
|
23
|
-
use_count: knex.raw('use_count + 1'),
|
|
23
|
+
const updateResult = await db
|
|
24
|
+
.updateTable('message_access_tokens' as any)
|
|
25
|
+
.set({
|
|
26
|
+
use_count: sql`use_count + 1`,
|
|
24
27
|
used_at: now,
|
|
25
|
-
})
|
|
28
|
+
} as any)
|
|
29
|
+
.where('id' as any, '=', tokenId)
|
|
30
|
+
.where('use_count' as any, '<', MAX_TOKEN_USE_COUNT)
|
|
31
|
+
.where('expires_at' as any, '>', now)
|
|
32
|
+
.executeTakeFirst()
|
|
33
|
+
const consumed = Number(updateResult?.numUpdatedRows ?? 0n)
|
|
26
34
|
if (consumed > 0) return { ok: true }
|
|
27
35
|
|
|
28
36
|
em.clear()
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OptionalProps } from '@mikro-orm/core'
|
|
2
|
+
import { Entity, Index, PrimaryKey, Property } from '@mikro-orm/decorators/legacy'
|
|
2
3
|
import type { NotificationActionData } from '@open-mercato/shared/modules/notifications/types'
|
|
3
4
|
|
|
4
5
|
export type NotificationStatus = 'unread' | 'read' | 'actioned' | 'dismissed'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Kysely } from 'kysely'
|
|
2
2
|
import { hasFeature } from '@open-mercato/shared/security/features'
|
|
3
3
|
|
|
4
4
|
interface AclRow {
|
|
@@ -35,47 +35,63 @@ function collectUsersWithFeature(
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export async function getRecipientUserIdsForRole(
|
|
38
|
-
|
|
38
|
+
db: Kysely<any>,
|
|
39
39
|
tenantId: string,
|
|
40
40
|
roleId: string
|
|
41
41
|
): Promise<string[]> {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
.
|
|
45
|
-
.
|
|
46
|
-
.
|
|
47
|
-
.where('
|
|
42
|
+
const builder: any = db
|
|
43
|
+
const userRoles = await builder
|
|
44
|
+
.selectFrom('user_roles')
|
|
45
|
+
.innerJoin('users', 'user_roles.user_id', 'users.id')
|
|
46
|
+
.where('user_roles.role_id', '=', roleId)
|
|
47
|
+
.where('user_roles.deleted_at', 'is', null)
|
|
48
|
+
.where('users.deleted_at', 'is', null)
|
|
49
|
+
.where('users.tenant_id', '=', tenantId)
|
|
48
50
|
.select('users.id as user_id')
|
|
51
|
+
.execute() as Array<{ user_id: string }>
|
|
49
52
|
|
|
50
|
-
return userRoles.map((row
|
|
53
|
+
return userRoles.map((row) => row.user_id)
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
export async function getRecipientUserIdsForFeature(
|
|
54
|
-
|
|
57
|
+
db: Kysely<any>,
|
|
55
58
|
tenantId: string,
|
|
56
59
|
requiredFeature: string
|
|
57
60
|
): Promise<string[]> {
|
|
58
61
|
const userIdsSet = new Set<string>()
|
|
62
|
+
const builder: any = db
|
|
59
63
|
|
|
60
|
-
const userAcls = await
|
|
61
|
-
.
|
|
62
|
-
.
|
|
63
|
-
.
|
|
64
|
-
.
|
|
65
|
-
.where('users.
|
|
66
|
-
.
|
|
64
|
+
const userAcls = await builder
|
|
65
|
+
.selectFrom('user_acls')
|
|
66
|
+
.innerJoin('users', 'user_acls.user_id', 'users.id')
|
|
67
|
+
.where('user_acls.tenant_id', '=', tenantId)
|
|
68
|
+
.where('user_acls.deleted_at', 'is', null)
|
|
69
|
+
.where('users.deleted_at', 'is', null)
|
|
70
|
+
.where('users.tenant_id', '=', tenantId)
|
|
71
|
+
.select([
|
|
72
|
+
'users.id as user_id',
|
|
73
|
+
'user_acls.features_json',
|
|
74
|
+
'user_acls.is_super_admin',
|
|
75
|
+
])
|
|
76
|
+
.execute() as AclRow[]
|
|
67
77
|
|
|
68
78
|
collectUsersWithFeature(userIdsSet, userAcls, requiredFeature)
|
|
69
79
|
|
|
70
|
-
const roleAcls = await
|
|
71
|
-
.
|
|
72
|
-
.
|
|
73
|
-
.
|
|
74
|
-
.
|
|
75
|
-
.
|
|
76
|
-
.
|
|
77
|
-
.where('users.
|
|
78
|
-
.
|
|
80
|
+
const roleAcls = await builder
|
|
81
|
+
.selectFrom('role_acls')
|
|
82
|
+
.innerJoin('user_roles', 'role_acls.role_id', 'user_roles.role_id')
|
|
83
|
+
.innerJoin('users', 'user_roles.user_id', 'users.id')
|
|
84
|
+
.where('role_acls.tenant_id', '=', tenantId)
|
|
85
|
+
.where('role_acls.deleted_at', 'is', null)
|
|
86
|
+
.where('user_roles.deleted_at', 'is', null)
|
|
87
|
+
.where('users.deleted_at', 'is', null)
|
|
88
|
+
.where('users.tenant_id', '=', tenantId)
|
|
89
|
+
.select([
|
|
90
|
+
'users.id as user_id',
|
|
91
|
+
'role_acls.features_json',
|
|
92
|
+
'role_acls.is_super_admin',
|
|
93
|
+
])
|
|
94
|
+
.execute() as AclRow[]
|
|
79
95
|
|
|
80
96
|
collectUsersWithFeature(userIdsSet, roleAcls, requiredFeature)
|
|
81
97
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
2
|
-
import type
|
|
2
|
+
import { type Kysely, sql } from 'kysely'
|
|
3
3
|
import { Notification, type NotificationStatus } from '../data/entities'
|
|
4
4
|
import type { CreateNotificationInput, CreateBatchNotificationInput, CreateRoleNotificationInput, CreateFeatureNotificationInput, ExecuteActionInput } from '../data/validators'
|
|
5
5
|
import type { NotificationPollData } from '@open-mercato/shared/modules/notifications/types'
|
|
@@ -24,8 +24,8 @@ function debug(...args: unknown[]): void {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function
|
|
28
|
-
return
|
|
27
|
+
function getDb(em: EntityManager): Kysely<any> {
|
|
28
|
+
return em.getKysely<any>()
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const UNIQUE_NOTIFICATION_ACTIVE_STATUSES: NotificationStatus[] = ['unread', 'read', 'actioned']
|
|
@@ -109,8 +109,8 @@ async function createOrRefreshNotification(
|
|
|
109
109
|
const orgScope = normalizeOrgScope(ctx.organizationId) ?? 'global'
|
|
110
110
|
const lockKey = `notifications:${ctx.tenantId}:${orgScope}:${recipientUserId}:${input.type}:${input.groupKey}`
|
|
111
111
|
try {
|
|
112
|
-
const
|
|
113
|
-
await
|
|
112
|
+
const db = getDb(em)
|
|
113
|
+
await sql`select pg_advisory_xact_lock(hashtext(${lockKey}))`.execute(db)
|
|
114
114
|
} catch {
|
|
115
115
|
// If advisory locks are unavailable, continue with best-effort dedupe.
|
|
116
116
|
}
|
|
@@ -228,8 +228,8 @@ export function createNotificationService(deps: NotificationServiceDeps): Notifi
|
|
|
228
228
|
async createForRole(input, ctx) {
|
|
229
229
|
const em = rootEm.fork()
|
|
230
230
|
|
|
231
|
-
const
|
|
232
|
-
const recipientUserIds = await getRecipientUserIdsForRole(
|
|
231
|
+
const db = getDb(em)
|
|
232
|
+
const recipientUserIds = await getRecipientUserIdsForRole(db, ctx.tenantId, input.roleId)
|
|
233
233
|
if (recipientUserIds.length === 0) {
|
|
234
234
|
return []
|
|
235
235
|
}
|
|
@@ -255,8 +255,8 @@ export function createNotificationService(deps: NotificationServiceDeps): Notifi
|
|
|
255
255
|
|
|
256
256
|
async createForFeature(input, ctx) {
|
|
257
257
|
const em = rootEm.fork()
|
|
258
|
-
const
|
|
259
|
-
const recipientUserIds = await getRecipientUserIdsForFeature(
|
|
258
|
+
const db = getDb(em)
|
|
259
|
+
const recipientUserIds = await getRecipientUserIdsForFeature(db, ctx.tenantId, input.requiredFeature)
|
|
260
260
|
|
|
261
261
|
if (recipientUserIds.length === 0) {
|
|
262
262
|
debug('No users found with feature:', input.requiredFeature, 'in tenant:', ctx.tenantId)
|
|
@@ -309,29 +309,39 @@ export function createNotificationService(deps: NotificationServiceDeps): Notifi
|
|
|
309
309
|
|
|
310
310
|
async markAllAsRead(ctx) {
|
|
311
311
|
const em = rootEm.fork()
|
|
312
|
-
const
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
recipient_user_id
|
|
316
|
-
tenant_id
|
|
317
|
-
status
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
312
|
+
const db = getDb(em)
|
|
313
|
+
const applyScope = <QB extends { where: (...args: any[]) => QB }>(q: QB): QB => {
|
|
314
|
+
let chain = q
|
|
315
|
+
.where('recipient_user_id' as any, '=', ctx.userId as any)
|
|
316
|
+
.where('tenant_id' as any, '=', ctx.tenantId)
|
|
317
|
+
.where('status' as any, '=', 'unread')
|
|
318
|
+
if (ctx.organizationId) {
|
|
319
|
+
chain = chain.where('organization_id' as any, '=', ctx.organizationId)
|
|
320
|
+
}
|
|
321
|
+
return chain
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
const targetRows = await
|
|
325
|
-
|
|
324
|
+
const targetRows = await applyScope(
|
|
325
|
+
db
|
|
326
|
+
.selectFrom('notifications' as any)
|
|
327
|
+
.select([
|
|
328
|
+
'id' as any,
|
|
329
|
+
'organization_id' as any,
|
|
330
|
+
'recipient_user_id' as any,
|
|
331
|
+
]),
|
|
332
|
+
).execute() as Array<{ id: string }>
|
|
326
333
|
|
|
327
334
|
if (!targetRows.length) {
|
|
328
335
|
return 0
|
|
329
336
|
}
|
|
330
337
|
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
338
|
+
const updateResult = await applyScope(
|
|
339
|
+
db.updateTable('notifications' as any).set({
|
|
340
|
+
status: 'read',
|
|
341
|
+
read_at: sql`now()`,
|
|
342
|
+
} as any) as any,
|
|
343
|
+
).executeTakeFirst() as { numUpdatedRows?: bigint | number } | undefined
|
|
344
|
+
const result = Number(updateResult?.numUpdatedRows ?? targetRows.length)
|
|
335
345
|
|
|
336
346
|
const notifications = await findWithDecryption(em, Notification, {
|
|
337
347
|
id: { $in: targetRows.map((row) => row.id) },
|
|
@@ -528,32 +538,33 @@ export function createNotificationService(deps: NotificationServiceDeps): Notifi
|
|
|
528
538
|
|
|
529
539
|
async cleanupExpired() {
|
|
530
540
|
const em = rootEm.fork()
|
|
531
|
-
const
|
|
541
|
+
const db = getDb(em)
|
|
532
542
|
|
|
533
|
-
const
|
|
534
|
-
.
|
|
535
|
-
.
|
|
536
|
-
.update({
|
|
543
|
+
const updateResult = await db
|
|
544
|
+
.updateTable('notifications' as any)
|
|
545
|
+
.set({
|
|
537
546
|
status: 'dismissed',
|
|
538
|
-
dismissed_at:
|
|
539
|
-
})
|
|
547
|
+
dismissed_at: sql`now()`,
|
|
548
|
+
} as any)
|
|
549
|
+
.where('expires_at' as any, '<', sql`now()`)
|
|
550
|
+
.where('status' as any, 'not in', ['actioned', 'dismissed'])
|
|
551
|
+
.executeTakeFirst() as { numUpdatedRows?: bigint | number } | undefined
|
|
540
552
|
|
|
541
|
-
return
|
|
553
|
+
return Number(updateResult?.numUpdatedRows ?? 0)
|
|
542
554
|
},
|
|
543
555
|
|
|
544
556
|
async deleteBySource(sourceEntityType, sourceEntityId, ctx) {
|
|
545
557
|
const em = rootEm.fork()
|
|
546
|
-
const
|
|
558
|
+
const db = getDb(em)
|
|
547
559
|
|
|
548
|
-
const
|
|
549
|
-
.
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}
|
|
554
|
-
.delete()
|
|
560
|
+
const deleteResult = await db
|
|
561
|
+
.deleteFrom('notifications' as any)
|
|
562
|
+
.where('source_entity_type' as any, '=', sourceEntityType)
|
|
563
|
+
.where('source_entity_id' as any, '=', sourceEntityId)
|
|
564
|
+
.where('tenant_id' as any, '=', ctx.tenantId)
|
|
565
|
+
.executeTakeFirst() as { numDeletedRows?: bigint | number } | undefined
|
|
555
566
|
|
|
556
|
-
return
|
|
567
|
+
return Number(deleteResult?.numDeletedRows ?? 0)
|
|
557
568
|
},
|
|
558
569
|
}
|
|
559
570
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { EntityManager } from '@mikro-orm/core'
|
|
2
|
-
import type {
|
|
2
|
+
import type { EntityManager as PgEntityManager } from '@mikro-orm/postgresql'
|
|
3
|
+
import { type Kysely, sql } from 'kysely'
|
|
3
4
|
import { Notification } from '../data/entities'
|
|
4
5
|
import type { CreateNotificationInput, CreateRoleNotificationInput, CreateFeatureNotificationInput } from '../data/validators'
|
|
5
6
|
import { buildNotificationEntity, emitNotificationCreated, emitNotificationCreatedBatch } from '../lib/notificationFactory'
|
|
6
7
|
import { getRecipientUserIdsForFeature, getRecipientUserIdsForRole } from '../lib/notificationRecipients'
|
|
7
8
|
|
|
8
|
-
function
|
|
9
|
-
return (em
|
|
9
|
+
function getDb(em: EntityManager): Kysely<any> {
|
|
10
|
+
return (em as unknown as PgEntityManager).getKysely<any>()
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export const NOTIFICATIONS_QUEUE_NAME = 'notifications'
|
|
@@ -61,7 +62,7 @@ export default async function handle(
|
|
|
61
62
|
const { recipientUserId, ...content } = input
|
|
62
63
|
const notification = buildNotificationEntity(em, content, recipientUserId, { tenantId, organizationId })
|
|
63
64
|
|
|
64
|
-
await em.
|
|
65
|
+
await em.persist(notification).flush()
|
|
65
66
|
|
|
66
67
|
await emitNotificationCreated(eventBus, notification, { tenantId, organizationId })
|
|
67
68
|
} else if (payload.type === 'create-role') {
|
|
@@ -69,8 +70,8 @@ export default async function handle(
|
|
|
69
70
|
const eventBus = ctx.resolve('eventBus') as { emit: (event: string, payload: unknown) => Promise<void> }
|
|
70
71
|
const { input, tenantId, organizationId } = payload
|
|
71
72
|
|
|
72
|
-
const
|
|
73
|
-
const recipientUserIds = await getRecipientUserIdsForRole(
|
|
73
|
+
const db = getDb(em)
|
|
74
|
+
const recipientUserIds = await getRecipientUserIdsForRole(db, tenantId, input.roleId)
|
|
74
75
|
if (recipientUserIds.length === 0) {
|
|
75
76
|
return
|
|
76
77
|
}
|
|
@@ -82,7 +83,7 @@ export default async function handle(
|
|
|
82
83
|
notifications.push(notification)
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
await em.
|
|
86
|
+
await em.persist(notifications).flush()
|
|
86
87
|
|
|
87
88
|
await emitNotificationCreatedBatch(eventBus, notifications, { tenantId, organizationId })
|
|
88
89
|
} else if (payload.type === 'create-feature') {
|
|
@@ -90,8 +91,8 @@ export default async function handle(
|
|
|
90
91
|
const eventBus = ctx.resolve('eventBus') as { emit: (event: string, payload: unknown) => Promise<void> }
|
|
91
92
|
const { input, tenantId, organizationId } = payload
|
|
92
93
|
|
|
93
|
-
const
|
|
94
|
-
const recipientUserIds = await getRecipientUserIdsForFeature(
|
|
94
|
+
const db = getDb(em)
|
|
95
|
+
const recipientUserIds = await getRecipientUserIdsForFeature(db, tenantId, input.requiredFeature)
|
|
95
96
|
|
|
96
97
|
if (recipientUserIds.length === 0) {
|
|
97
98
|
return
|
|
@@ -104,19 +105,21 @@ export default async function handle(
|
|
|
104
105
|
notifications.push(notification)
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
await em.
|
|
108
|
+
await em.persist(notifications).flush()
|
|
108
109
|
|
|
109
110
|
await emitNotificationCreatedBatch(eventBus, notifications, { tenantId, organizationId })
|
|
110
111
|
} else if (payload.type === 'cleanup-expired') {
|
|
111
112
|
const em = (ctx.resolve('em') as EntityManager).fork()
|
|
112
|
-
const
|
|
113
|
+
const db = getDb(em)
|
|
113
114
|
|
|
114
|
-
await
|
|
115
|
-
.
|
|
116
|
-
.
|
|
117
|
-
.update({
|
|
115
|
+
await db
|
|
116
|
+
.updateTable('notifications' as any)
|
|
117
|
+
.set({
|
|
118
118
|
status: 'dismissed',
|
|
119
|
-
dismissed_at:
|
|
120
|
-
})
|
|
119
|
+
dismissed_at: sql`now()`,
|
|
120
|
+
} as any)
|
|
121
|
+
.where('expires_at' as any, '<', sql`now()`)
|
|
122
|
+
.where('status' as any, 'not in', ['actioned', 'dismissed'])
|
|
123
|
+
.execute()
|
|
121
124
|
}
|
|
122
125
|
}
|
|
@@ -75,7 +75,7 @@ export async function GET(req: Request) {
|
|
|
75
75
|
|
|
76
76
|
const [items, total] = await Promise.all([
|
|
77
77
|
qb.getResultList(),
|
|
78
|
-
countQb.
|
|
78
|
+
countQb.getCount('gt.id', true),
|
|
79
79
|
])
|
|
80
80
|
|
|
81
81
|
return NextResponse.json({
|
|
@@ -99,7 +99,7 @@ export async function GET(req: Request) {
|
|
|
99
99
|
total,
|
|
100
100
|
page,
|
|
101
101
|
pageSize,
|
|
102
|
-
totalPages: Math.max(1, Math.ceil(total / pageSize)),
|
|
102
|
+
totalPages: Math.max(1, Math.ceil(Number(total) / pageSize)),
|
|
103
103
|
})
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OptionalProps } from '@mikro-orm/core'
|
|
2
|
+
import { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
|
|
2
3
|
|
|
3
4
|
@Entity({ tableName: 'gateway_transactions' })
|
|
4
5
|
@Index({ properties: ['paymentId', 'organizationId', 'tenantId'] })
|
|
@@ -168,7 +168,7 @@ export function createPaymentGatewayService(deps: PaymentGatewayServiceDeps) {
|
|
|
168
168
|
organizationId: input.organizationId,
|
|
169
169
|
tenantId: input.tenantId,
|
|
170
170
|
})
|
|
171
|
-
await em.
|
|
171
|
+
await em.persist(transaction).flush()
|
|
172
172
|
await emitPaymentGatewayEvent('payment_gateways.session.created', {
|
|
173
173
|
transactionId: transaction.id,
|
|
174
174
|
paymentId: transaction.paymentId,
|
|
@@ -19,7 +19,7 @@ export async function claimWebhookProcessing(
|
|
|
19
19
|
})
|
|
20
20
|
|
|
21
21
|
try {
|
|
22
|
-
await em.
|
|
22
|
+
await em.persist(record).flush()
|
|
23
23
|
return true
|
|
24
24
|
} catch (error: unknown) {
|
|
25
25
|
if (error instanceof UniqueConstraintViolationException) {
|
|
@@ -48,5 +48,5 @@ export async function releaseWebhookClaim(
|
|
|
48
48
|
scope,
|
|
49
49
|
)
|
|
50
50
|
if (!existing) return
|
|
51
|
-
await em.
|
|
51
|
+
await em.remove(existing).flush()
|
|
52
52
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entity, PrimaryKey, Property,
|
|
1
|
+
import { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
|
|
2
2
|
|
|
3
3
|
@Entity({ tableName: 'perspectives' })
|
|
4
4
|
@Index({ name: 'perspectives_user_scope_idx', properties: ['userId', 'tenantId', 'organizationId', 'tableId'] })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entity,
|
|
1
|
+
import { Entity, Enum, Index, PrimaryKey, Property } from '@mikro-orm/decorators/legacy'
|
|
2
2
|
|
|
3
3
|
export type PlannerAvailabilitySubjectType = 'member' | 'resource' | 'ruleset'
|
|
4
4
|
export type PlannerAvailabilityKind = 'availability' | 'unavailability'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OptionalProps } from '@mikro-orm/core'
|
|
2
|
+
import { Entity, Index, PrimaryKey, Property } from '@mikro-orm/decorators/legacy'
|
|
2
3
|
|
|
3
4
|
export type ProgressJobStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled'
|
|
4
5
|
|
|
@@ -42,7 +42,7 @@ export function createProgressService(em: EntityManager, eventBus: { emit: (even
|
|
|
42
42
|
status: 'pending',
|
|
43
43
|
})
|
|
44
44
|
|
|
45
|
-
await em.
|
|
45
|
+
await em.persist(job).flush()
|
|
46
46
|
|
|
47
47
|
await eventBus.emit(PROGRESS_EVENTS.JOB_CREATED, {
|
|
48
48
|
...buildJobPayload(job),
|