@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
|
@@ -2,6 +2,7 @@ import type { ModuleCli } from '@open-mercato/shared/modules/registry'
|
|
|
2
2
|
import { createRequestContainer, type AppContainer } from '@open-mercato/shared/lib/di/container'
|
|
3
3
|
import { randomUUID } from 'crypto'
|
|
4
4
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
5
|
+
import { type Kysely, sql } from 'kysely'
|
|
5
6
|
import { Dictionary, DictionaryEntry, type DictionaryManagerVisibility } from '@open-mercato/core/modules/dictionaries/data/entities'
|
|
6
7
|
import { installCustomEntitiesFromModules } from '@open-mercato/core/modules/entities/lib/install-from-ce'
|
|
7
8
|
import type { CacheStrategy } from '@open-mercato/cache/types'
|
|
@@ -1855,12 +1856,18 @@ async function seedCustomerStressTest(
|
|
|
1855
1856
|
const assignmentFlushThreshold = includeExtras ? 100 : 0
|
|
1856
1857
|
const cfInsertBatchSize = 500
|
|
1857
1858
|
const flushInterval = 100
|
|
1858
|
-
const
|
|
1859
|
-
const
|
|
1860
|
-
.
|
|
1861
|
-
.
|
|
1862
|
-
|
|
1863
|
-
|
|
1859
|
+
const db = em.getKysely<any>() as any
|
|
1860
|
+
const entityIndexesColumnRows = await db
|
|
1861
|
+
.selectFrom('information_schema.columns')
|
|
1862
|
+
.select(['column_name'])
|
|
1863
|
+
.where(sql<boolean>`table_schema = current_schema()`)
|
|
1864
|
+
.where('table_name', '=', 'entity_indexes')
|
|
1865
|
+
.execute()
|
|
1866
|
+
.catch(() => [] as Array<{ column_name: string }>)
|
|
1867
|
+
const entityIndexesColumnSet = new Set<string>(
|
|
1868
|
+
entityIndexesColumnRows.map((row: any) => String(row.column_name).toLowerCase()),
|
|
1869
|
+
)
|
|
1870
|
+
const hasColumn = (name: string) => entityIndexesColumnSet.has(name.toLowerCase())
|
|
1864
1871
|
const supportsOrgCoalesced = hasColumn('organization_id_coalesced')
|
|
1865
1872
|
|
|
1866
1873
|
type PendingIndexDoc = {
|
|
@@ -1992,37 +1999,42 @@ async function seedCustomerStressTest(
|
|
|
1992
1999
|
return
|
|
1993
2000
|
}
|
|
1994
2001
|
if (supportsOrgCoalesced) {
|
|
1995
|
-
await trx
|
|
1996
|
-
.
|
|
1997
|
-
.
|
|
1998
|
-
.
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2002
|
+
await trx
|
|
2003
|
+
.insertInto('entity_indexes')
|
|
2004
|
+
.values(rows.map((row) => ({ ...row, doc: sql`${JSON.stringify(row.doc)}::jsonb` })))
|
|
2005
|
+
.onConflict((oc: any) => oc
|
|
2006
|
+
.columns(['entity_type', 'entity_id', 'organization_id_coalesced'])
|
|
2007
|
+
.doUpdateSet({
|
|
2008
|
+
doc: sql`excluded.doc`,
|
|
2009
|
+
index_version: sql`excluded.index_version`,
|
|
2010
|
+
organization_id: sql`excluded.organization_id`,
|
|
2011
|
+
tenant_id: sql`excluded.tenant_id`,
|
|
2012
|
+
deleted_at: sql`excluded.deleted_at`,
|
|
2013
|
+
updated_at: sql`excluded.updated_at`,
|
|
2014
|
+
}))
|
|
2015
|
+
.execute()
|
|
2006
2016
|
} else {
|
|
2007
2017
|
for (const row of rows) {
|
|
2008
|
-
const
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
updated_at: row.updated_at,
|
|
2014
|
-
deleted_at: null as null,
|
|
2015
|
-
}
|
|
2016
|
-
const updated = await trx('entity_indexes')
|
|
2017
|
-
.where({
|
|
2018
|
-
entity_type: row.entity_type,
|
|
2019
|
-
entity_id: row.entity_id,
|
|
2018
|
+
const updated = await trx
|
|
2019
|
+
.updateTable('entity_indexes')
|
|
2020
|
+
.set({
|
|
2021
|
+
doc: sql`${JSON.stringify(row.doc)}::jsonb`,
|
|
2022
|
+
index_version: row.index_version,
|
|
2020
2023
|
organization_id: row.organization_id,
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
+
tenant_id: row.tenant_id,
|
|
2025
|
+
updated_at: row.updated_at,
|
|
2026
|
+
deleted_at: null,
|
|
2027
|
+
} as any)
|
|
2028
|
+
.where('entity_type', '=', row.entity_type)
|
|
2029
|
+
.where('entity_id', '=', row.entity_id)
|
|
2030
|
+
.where('organization_id', row.organization_id === null ? 'is' : '=', row.organization_id as any)
|
|
2031
|
+
.executeTakeFirst() as { numUpdatedRows?: bigint | number } | undefined
|
|
2032
|
+
if (updated && Number(updated.numUpdatedRows ?? 0) > 0) continue
|
|
2024
2033
|
try {
|
|
2025
|
-
await trx('entity_indexes').
|
|
2034
|
+
await trx.insertInto('entity_indexes').values({
|
|
2035
|
+
...row,
|
|
2036
|
+
doc: sql`${JSON.stringify(row.doc)}::jsonb`,
|
|
2037
|
+
} as any).execute()
|
|
2026
2038
|
} catch {
|
|
2027
2039
|
// ignored: row inserted concurrently
|
|
2028
2040
|
}
|
|
@@ -2129,7 +2141,7 @@ async function seedCustomerStressTest(
|
|
|
2129
2141
|
created_at: timestamp,
|
|
2130
2142
|
deleted_at: null,
|
|
2131
2143
|
}))
|
|
2132
|
-
await
|
|
2144
|
+
await db.insertInto('custom_field_values').values(payload).execute()
|
|
2133
2145
|
}
|
|
2134
2146
|
}
|
|
2135
2147
|
|
|
@@ -2292,11 +2304,14 @@ async function seedCustomerStressTest(
|
|
|
2292
2304
|
const entityInsertBatchSize = 1000
|
|
2293
2305
|
const contactsPerCompany = Math.max(1, Math.ceil(toCreate / companyCount))
|
|
2294
2306
|
|
|
2295
|
-
await warnIfStressTestSchemaChanged(
|
|
2307
|
+
await warnIfStressTestSchemaChanged(db)
|
|
2296
2308
|
|
|
2297
2309
|
const insertRows = async (trx: any, table: string, rows: unknown[]) => {
|
|
2298
2310
|
if (!rows.length) return
|
|
2299
|
-
|
|
2311
|
+
for (let i = 0; i < rows.length; i += entityInsertBatchSize) {
|
|
2312
|
+
const chunk = rows.slice(i, i + entityInsertBatchSize)
|
|
2313
|
+
await trx.insertInto(table).values(chunk as any).execute()
|
|
2314
|
+
}
|
|
2300
2315
|
rows.length = 0
|
|
2301
2316
|
}
|
|
2302
2317
|
|
|
@@ -2312,7 +2327,7 @@ async function seedCustomerStressTest(
|
|
|
2312
2327
|
activityRows.length +
|
|
2313
2328
|
commentRows.length
|
|
2314
2329
|
if (pendingCount === 0) return
|
|
2315
|
-
await
|
|
2330
|
+
await db.transaction().execute(async (trx: any) => {
|
|
2316
2331
|
await insertRows(trx, 'customer_entities', customerEntityRows)
|
|
2317
2332
|
await insertRows(trx, 'customer_companies', companyProfileRows)
|
|
2318
2333
|
await insertRows(trx, 'customer_people', personProfileRows)
|
|
@@ -2751,15 +2766,17 @@ const STRESS_TEST_REQUIRED_COLUMNS: Record<string, readonly string[]> = {
|
|
|
2751
2766
|
],
|
|
2752
2767
|
}
|
|
2753
2768
|
|
|
2754
|
-
async function warnIfStressTestSchemaChanged(
|
|
2769
|
+
async function warnIfStressTestSchemaChanged(db: Kysely<any>) {
|
|
2755
2770
|
try {
|
|
2756
2771
|
const warnings: string[] = []
|
|
2757
2772
|
for (const [table, requiredColumns] of Object.entries(STRESS_TEST_REQUIRED_COLUMNS)) {
|
|
2758
|
-
const rows = await
|
|
2773
|
+
const rows = await (db as any)
|
|
2774
|
+
.selectFrom('information_schema.columns')
|
|
2759
2775
|
.select('column_name')
|
|
2760
|
-
.
|
|
2761
|
-
.where(
|
|
2762
|
-
|
|
2776
|
+
.where(sql<boolean>`table_schema = current_schema()`)
|
|
2777
|
+
.where('table_name', '=', table)
|
|
2778
|
+
.execute() as Array<{ column_name: string }>
|
|
2779
|
+
const existing = new Set(rows.map((row) => row.column_name))
|
|
2763
2780
|
const missing = requiredColumns.filter((column) => !existing.has(column))
|
|
2764
2781
|
if (missing.length) warnings.push(`${table}: missing ${missing.join(', ')}`)
|
|
2765
2782
|
}
|
|
@@ -2969,7 +2986,7 @@ async function backfillInteractions(
|
|
|
2969
2986
|
container: { resolve: (name: string) => unknown },
|
|
2970
2987
|
args: SeedArgs,
|
|
2971
2988
|
): Promise<{ activitiesMigrated: number; todosMigrated: number; projectionsRecomputed: number; errors: number }> {
|
|
2972
|
-
const
|
|
2989
|
+
const db = em.getKysely<any>() as any
|
|
2973
2990
|
const { tenantId, organizationId } = args
|
|
2974
2991
|
|
|
2975
2992
|
let activitiesMigrated = 0
|
|
@@ -2981,8 +2998,9 @@ async function backfillInteractions(
|
|
|
2981
2998
|
// Step 1: Migrate activities → interactions
|
|
2982
2999
|
console.log('[backfill] Migrating activities to interactions...')
|
|
2983
3000
|
while (true) {
|
|
2984
|
-
const activities = await
|
|
2985
|
-
.
|
|
3001
|
+
const activities = await db
|
|
3002
|
+
.selectFrom('customer_activities')
|
|
3003
|
+
.select([
|
|
2986
3004
|
'customer_activities.id',
|
|
2987
3005
|
'customer_activities.organization_id',
|
|
2988
3006
|
'customer_activities.tenant_id',
|
|
@@ -2995,23 +3013,24 @@ async function backfillInteractions(
|
|
|
2995
3013
|
'customer_activities.appearance_color',
|
|
2996
3014
|
'customer_activities.entity_id',
|
|
2997
3015
|
'customer_activities.deal_id',
|
|
2998
|
-
)
|
|
2999
|
-
.where('customer_activities.tenant_id', tenantId)
|
|
3000
|
-
.
|
|
3001
|
-
.
|
|
3002
|
-
|
|
3003
|
-
.select(
|
|
3004
|
-
.
|
|
3005
|
-
)
|
|
3016
|
+
])
|
|
3017
|
+
.where('customer_activities.tenant_id', '=', tenantId)
|
|
3018
|
+
.where('customer_activities.organization_id', '=', organizationId)
|
|
3019
|
+
.where((eb: any) => eb.not(eb.exists(
|
|
3020
|
+
eb.selectFrom('customer_interactions')
|
|
3021
|
+
.select(sql<number>`1`.as('one'))
|
|
3022
|
+
.whereRef('customer_interactions.id', '=', 'customer_activities.id')
|
|
3023
|
+
)))
|
|
3006
3024
|
.orderBy('customer_activities.created_at', 'asc')
|
|
3007
3025
|
.limit(BACKFILL_BATCH_SIZE)
|
|
3026
|
+
.execute() as any[]
|
|
3008
3027
|
|
|
3009
3028
|
if (activities.length === 0) break
|
|
3010
3029
|
|
|
3011
3030
|
for (const activity of activities) {
|
|
3012
3031
|
try {
|
|
3013
3032
|
const status = activity.occurred_at ? 'done' : 'planned'
|
|
3014
|
-
await
|
|
3033
|
+
await db.insertInto('customer_interactions').values({
|
|
3015
3034
|
id: activity.id,
|
|
3016
3035
|
organization_id: activity.organization_id,
|
|
3017
3036
|
tenant_id: activity.tenant_id,
|
|
@@ -3029,7 +3048,7 @@ async function backfillInteractions(
|
|
|
3029
3048
|
deal_id: activity.deal_id,
|
|
3030
3049
|
created_at: new Date(),
|
|
3031
3050
|
updated_at: new Date(),
|
|
3032
|
-
})
|
|
3051
|
+
} as any).execute()
|
|
3033
3052
|
activitiesMigrated++
|
|
3034
3053
|
affectedEntityIds.add(activity.entity_id)
|
|
3035
3054
|
} catch (err) {
|
|
@@ -3054,8 +3073,9 @@ async function backfillInteractions(
|
|
|
3054
3073
|
}
|
|
3055
3074
|
|
|
3056
3075
|
while (true) {
|
|
3057
|
-
const todoLinks = await
|
|
3058
|
-
.
|
|
3076
|
+
const todoLinks = await db
|
|
3077
|
+
.selectFrom('customer_todo_links')
|
|
3078
|
+
.select([
|
|
3059
3079
|
'customer_todo_links.id',
|
|
3060
3080
|
'customer_todo_links.organization_id',
|
|
3061
3081
|
'customer_todo_links.tenant_id',
|
|
@@ -3063,16 +3083,17 @@ async function backfillInteractions(
|
|
|
3063
3083
|
'customer_todo_links.todo_source',
|
|
3064
3084
|
'customer_todo_links.entity_id',
|
|
3065
3085
|
'customer_todo_links.created_at',
|
|
3066
|
-
)
|
|
3067
|
-
.where('customer_todo_links.tenant_id', tenantId)
|
|
3068
|
-
.
|
|
3069
|
-
.
|
|
3070
|
-
|
|
3071
|
-
.select(
|
|
3072
|
-
.
|
|
3073
|
-
)
|
|
3086
|
+
])
|
|
3087
|
+
.where('customer_todo_links.tenant_id', '=', tenantId)
|
|
3088
|
+
.where('customer_todo_links.organization_id', '=', organizationId)
|
|
3089
|
+
.where((eb: any) => eb.not(eb.exists(
|
|
3090
|
+
eb.selectFrom('customer_interactions')
|
|
3091
|
+
.select(sql<number>`1`.as('one'))
|
|
3092
|
+
.whereRef('customer_interactions.id', '=', 'customer_todo_links.todo_id')
|
|
3093
|
+
)))
|
|
3074
3094
|
.orderBy('customer_todo_links.created_at', 'asc')
|
|
3075
3095
|
.limit(BACKFILL_BATCH_SIZE)
|
|
3096
|
+
.execute() as any[]
|
|
3076
3097
|
|
|
3077
3098
|
if (todoLinks.length === 0) break
|
|
3078
3099
|
|
|
@@ -3118,7 +3139,7 @@ async function backfillInteractions(
|
|
|
3118
3139
|
const title = summary?.title ?? 'Migrated task'
|
|
3119
3140
|
const status = summary?.isDone ? 'done' : 'planned'
|
|
3120
3141
|
|
|
3121
|
-
await
|
|
3142
|
+
await db.insertInto('customer_interactions').values({
|
|
3122
3143
|
id: link.todo_id,
|
|
3123
3144
|
organization_id: link.organization_id,
|
|
3124
3145
|
tenant_id: link.tenant_id,
|
|
@@ -3136,7 +3157,7 @@ async function backfillInteractions(
|
|
|
3136
3157
|
deal_id: null,
|
|
3137
3158
|
created_at: new Date(),
|
|
3138
3159
|
updated_at: new Date(),
|
|
3139
|
-
})
|
|
3160
|
+
} as any).execute()
|
|
3140
3161
|
todosMigrated++
|
|
3141
3162
|
affectedEntityIds.add(link.entity_id)
|
|
3142
3163
|
} catch (err) {
|
|
@@ -294,7 +294,7 @@ const createDictionaryEntryCommand: CommandHandler<CustomerDictionaryEntryCreate
|
|
|
294
294
|
{ tenantId: after.tenantId, organizationId: after.organizationId },
|
|
295
295
|
)
|
|
296
296
|
if (entry) {
|
|
297
|
-
await em.
|
|
297
|
+
await em.remove(entry).flush()
|
|
298
298
|
await invalidateCache(ctx, after)
|
|
299
299
|
return
|
|
300
300
|
}
|
|
@@ -470,7 +470,7 @@ const unassignTagCommand: CommandHandler<TagAssignmentInput, { assignmentId: str
|
|
|
470
470
|
organizationId: parsed.organizationId,
|
|
471
471
|
})
|
|
472
472
|
if (!existing) throw new CrudHttpError(404, { error: 'Tag assignment not found' })
|
|
473
|
-
await em.remove(existing)
|
|
473
|
+
await em.remove(existing).flush()
|
|
474
474
|
await em.flush()
|
|
475
475
|
|
|
476
476
|
const de = (ctx.container.resolve('dataEngine') as DataEngine)
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
PrimaryKey,
|
|
4
|
-
Property,
|
|
5
|
-
Index,
|
|
6
|
-
Unique,
|
|
7
|
-
OneToOne,
|
|
8
|
-
OneToMany,
|
|
9
|
-
ManyToOne,
|
|
10
|
-
Collection,
|
|
11
|
-
OptionalProps,
|
|
12
|
-
} from '@mikro-orm/core'
|
|
1
|
+
import { Collection, OptionalProps } from '@mikro-orm/core'
|
|
2
|
+
import { Entity, Index, ManyToOne, OneToMany, OneToOne, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
|
|
13
3
|
|
|
14
4
|
export type CustomerEntityKind = 'person' | 'company'
|
|
15
5
|
export type CustomerAddressFormat = 'line_first' | 'street_first'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
2
|
+
import { sql } from 'kysely'
|
|
2
3
|
|
|
3
4
|
export type NextInteractionProjectionResult = {
|
|
4
5
|
nextInteractionId: string | null
|
|
@@ -18,54 +19,64 @@ export async function recomputeNextInteraction(
|
|
|
18
19
|
entityId: string,
|
|
19
20
|
organizationId?: string | null,
|
|
20
21
|
): Promise<NextInteractionProjectionResult> {
|
|
21
|
-
const
|
|
22
|
+
const db = em.getKysely<any>() as any
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
.
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
let query = db
|
|
25
|
+
.selectFrom('customer_interactions')
|
|
26
|
+
.select([
|
|
27
|
+
'id',
|
|
28
|
+
'scheduled_at',
|
|
29
|
+
'title',
|
|
30
|
+
'interaction_type',
|
|
31
|
+
'appearance_icon',
|
|
32
|
+
'appearance_color',
|
|
33
|
+
])
|
|
34
|
+
.where('entity_id', '=', entityId)
|
|
35
|
+
.where('status', '=', 'planned')
|
|
36
|
+
.where('scheduled_at', 'is not', null)
|
|
37
|
+
.where('deleted_at', 'is', null)
|
|
29
38
|
if (organizationId) {
|
|
30
|
-
query.
|
|
39
|
+
query = query.where('organization_id', '=', organizationId)
|
|
31
40
|
}
|
|
32
41
|
|
|
33
42
|
const candidate = await query
|
|
34
|
-
.orderBy(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
])
|
|
40
|
-
.first()
|
|
43
|
+
.orderBy('scheduled_at', 'asc')
|
|
44
|
+
.orderBy(sql`priority desc nulls last`)
|
|
45
|
+
.orderBy('created_at', 'asc')
|
|
46
|
+
.orderBy('id', 'asc')
|
|
47
|
+
.executeTakeFirst() as Record<string, any> | undefined
|
|
41
48
|
|
|
42
49
|
if (candidate) {
|
|
43
50
|
const interactionName = candidate.title && candidate.title.trim() !== ''
|
|
44
51
|
? candidate.title
|
|
45
52
|
: candidate.interaction_type
|
|
46
53
|
|
|
47
|
-
await
|
|
48
|
-
.
|
|
49
|
-
.
|
|
54
|
+
await db
|
|
55
|
+
.updateTable('customer_entities')
|
|
56
|
+
.set({
|
|
50
57
|
next_interaction_at: candidate.scheduled_at,
|
|
51
58
|
next_interaction_name: interactionName,
|
|
52
59
|
next_interaction_ref_id: candidate.id,
|
|
53
60
|
next_interaction_icon: candidate.appearance_icon,
|
|
54
61
|
next_interaction_color: candidate.appearance_color,
|
|
55
|
-
updated_at:
|
|
56
|
-
})
|
|
62
|
+
updated_at: sql`now()`,
|
|
63
|
+
} as any)
|
|
64
|
+
.where('id', '=', entityId)
|
|
65
|
+
.execute()
|
|
57
66
|
return { nextInteractionId: String(candidate.id) }
|
|
58
67
|
} else {
|
|
59
|
-
await
|
|
60
|
-
.
|
|
61
|
-
.
|
|
68
|
+
await db
|
|
69
|
+
.updateTable('customer_entities')
|
|
70
|
+
.set({
|
|
62
71
|
next_interaction_at: null,
|
|
63
72
|
next_interaction_name: null,
|
|
64
73
|
next_interaction_ref_id: null,
|
|
65
74
|
next_interaction_icon: null,
|
|
66
75
|
next_interaction_color: null,
|
|
67
|
-
updated_at:
|
|
68
|
-
})
|
|
76
|
+
updated_at: sql`now()`,
|
|
77
|
+
} as any)
|
|
78
|
+
.where('id', '=', entityId)
|
|
79
|
+
.execute()
|
|
69
80
|
return { nextInteractionId: null }
|
|
70
81
|
}
|
|
71
82
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
2
|
+
import { sql } from '@mikro-orm/postgresql'
|
|
2
3
|
|
|
3
4
|
const PERSON_COMPANY_LINKS_TABLE = 'customer_person_company_links'
|
|
4
5
|
const PERSON_COMPANY_LINKS_DELETED_AT_COLUMN = 'deleted_at'
|
|
@@ -6,29 +7,23 @@ const PERSON_COMPANY_LINKS_DELETED_AT_COLUMN = 'deleted_at'
|
|
|
6
7
|
let supportsDeletedAtColumnPromise: Promise<boolean> | null = null
|
|
7
8
|
let warnedAboutMissingDeletedAtColumn = false
|
|
8
9
|
|
|
9
|
-
type KnexLike = (tableName: string) => {
|
|
10
|
-
where: (filters: Record<string, unknown>) => {
|
|
11
|
-
first: () => Promise<unknown>
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function getKnex(em: EntityManager): KnexLike {
|
|
16
|
-
return (em.getConnection() as unknown as { getKnex: () => KnexLike }).getKnex()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
10
|
export async function customerPersonCompanyLinksSupportDeletedAt(em: EntityManager): Promise<boolean> {
|
|
20
|
-
if (typeof (em as {
|
|
11
|
+
if (typeof (em as { getKysely?: unknown }).getKysely !== 'function') {
|
|
21
12
|
return true
|
|
22
13
|
}
|
|
23
14
|
if (!supportsDeletedAtColumnPromise) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.
|
|
30
|
-
.
|
|
15
|
+
const db = em.getKysely<any>() as any
|
|
16
|
+
const probe: Promise<boolean> = db
|
|
17
|
+
.selectFrom('information_schema.columns')
|
|
18
|
+
.select(['column_name'])
|
|
19
|
+
.where(sql<boolean>`table_schema = current_schema()`)
|
|
20
|
+
.where('table_name', '=', PERSON_COMPANY_LINKS_TABLE)
|
|
21
|
+
.where('column_name', '=', PERSON_COMPANY_LINKS_DELETED_AT_COLUMN)
|
|
22
|
+
.executeTakeFirst()
|
|
23
|
+
.then((row: unknown) => !!row)
|
|
31
24
|
.catch(() => false)
|
|
25
|
+
supportsDeletedAtColumnPromise = probe
|
|
26
|
+
return probe
|
|
32
27
|
}
|
|
33
28
|
return supportsDeletedAtColumnPromise
|
|
34
29
|
}
|
|
@@ -128,7 +128,7 @@ export async function PUT(req: Request) {
|
|
|
128
128
|
|
|
129
129
|
if (parsed.data.mode === 'inherit') {
|
|
130
130
|
if (record) {
|
|
131
|
-
await em.remove(record)
|
|
131
|
+
await em.remove(record).flush()
|
|
132
132
|
await em.flush()
|
|
133
133
|
}
|
|
134
134
|
return NextResponse.json({ ok: true, mode: 'inherit', widgetIds: [] })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entity, PrimaryKey, Property, Unique } from '@mikro-orm/
|
|
1
|
+
import { Entity, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
|
|
2
2
|
import type { DashboardLayoutItem } from '@open-mercato/shared/modules/dashboard/widgets'
|
|
3
3
|
|
|
4
4
|
@Entity({ tableName: 'dashboard_layouts' })
|
|
@@ -133,7 +133,7 @@ export async function POST(req: Request) {
|
|
|
133
133
|
organizationId: scope.organizationId,
|
|
134
134
|
tenantId: scope.tenantId,
|
|
135
135
|
})
|
|
136
|
-
await em.
|
|
136
|
+
await em.persist(created).flush()
|
|
137
137
|
|
|
138
138
|
return NextResponse.json({
|
|
139
139
|
id: created.id,
|
|
@@ -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
|
@Entity({ tableName: 'sync_runs' })
|
|
4
5
|
@Index({ properties: ['integrationId', 'entityType', 'status', 'organizationId', 'tenantId'] })
|
|
@@ -296,7 +296,7 @@ export function registerDictionaryEntryCommands<TCreate, TUpdate>(
|
|
|
296
296
|
scopeEnsurer(ctx, { tenantId: after.tenantId, organizationId: after.organizationId })
|
|
297
297
|
const entry = await em.findOne(DictionaryEntry, after.id)
|
|
298
298
|
if (entry) {
|
|
299
|
-
await em.
|
|
299
|
+
await em.remove(entry).flush()
|
|
300
300
|
return
|
|
301
301
|
}
|
|
302
302
|
await em.nativeDelete(DictionaryEntry, { id: after.id })
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
PrimaryKey,
|
|
4
|
-
Property,
|
|
5
|
-
Unique,
|
|
6
|
-
Index,
|
|
7
|
-
ManyToOne,
|
|
8
|
-
OptionalProps,
|
|
9
|
-
} from '@mikro-orm/core'
|
|
1
|
+
import { Entity, Index, ManyToOne, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
|
|
2
|
+
import { OptionalProps } from '@mikro-orm/core'
|
|
10
3
|
|
|
11
4
|
export type DictionaryManagerVisibility = 'default' | 'hidden'
|
|
12
5
|
|
|
@@ -199,7 +199,7 @@ async function restoreChildParents(em: EntityManager, tenantId: string, snapshot
|
|
|
199
199
|
toPersist.push(child)
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
if (toPersist.length) await em.
|
|
202
|
+
if (toPersist.length) await em.persist(toPersist).flush()
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
function normalizeChildIds(ids: readonly string[], exclude: string[]): string[] {
|
|
@@ -239,7 +239,7 @@ async function assignChildren(
|
|
|
239
239
|
toPersist.push(child)
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
if (toPersist.length) await em.
|
|
242
|
+
if (toPersist.length) await em.persist(toPersist).flush()
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
async function clearRemovedChildren(em: EntityManager, tenantId: string, recordId: string, desiredChildIds: Set<string>): Promise<void> {
|
|
@@ -248,7 +248,7 @@ async function clearRemovedChildren(em: EntityManager, tenantId: string, recordI
|
|
|
248
248
|
const toPersist = current.filter((child) => !desiredChildIds.has(String(child.id)))
|
|
249
249
|
if (!toPersist.length) return
|
|
250
250
|
for (const child of toPersist) child.parentId = null
|
|
251
|
-
await em.
|
|
251
|
+
await em.persist(toPersist).flush()
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
async function resolveUniqueSlug(em: EntityManager, tenantId: string, baseSlug: string, excludeId?: string): Promise<string> {
|
|
@@ -669,7 +669,7 @@ const deleteOrganizationCommand: CommandHandler<{ body: any; query: Record<strin
|
|
|
669
669
|
toPersist.push(child)
|
|
670
670
|
}
|
|
671
671
|
toPersist.push(deleted)
|
|
672
|
-
if (toPersist.length) await em.
|
|
672
|
+
if (toPersist.length) await em.persist(toPersist).flush()
|
|
673
673
|
setUndoMeta(deleted, { childParentsBefore: childSnapshotsBefore })
|
|
674
674
|
|
|
675
675
|
await rebuildHierarchyForTenant(em, tenantId)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Collection } from '@mikro-orm/core'
|
|
2
|
+
import { Entity, ManyToOne, OneToMany, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
|
|
2
3
|
|
|
3
4
|
@Entity({ tableName: 'tenants' })
|
|
4
5
|
export class Tenant {
|
|
@@ -4,7 +4,7 @@ import type { CacheStrategy } from '@open-mercato/cache'
|
|
|
4
4
|
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
5
5
|
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
6
6
|
import type { RbacService } from '@open-mercato/core/modules/auth/services/rbacService'
|
|
7
|
-
import { CustomFieldDef } from '@open-mercato/core/modules/entities/data/entities'
|
|
7
|
+
import { CustomEntity, CustomFieldDef } from '@open-mercato/core/modules/entities/data/entities'
|
|
8
8
|
import { upsertCustomFieldDefSchema, fieldsetCodeRegex } from '@open-mercato/core/modules/entities/data/validators'
|
|
9
9
|
import {
|
|
10
10
|
createDefinitionsCacheKey,
|
|
@@ -157,7 +157,7 @@ function parseEntityIds(url: URL): string[] {
|
|
|
157
157
|
|
|
158
158
|
async function resolveEntityDefaultEditor(em: any, entityId: string, tenantId: string | null | undefined): Promise<string | undefined> {
|
|
159
159
|
try {
|
|
160
|
-
const ent = await em.findOne(
|
|
160
|
+
const ent = await em.findOne(CustomEntity, {
|
|
161
161
|
entityId,
|
|
162
162
|
$and: [
|
|
163
163
|
{ $or: [ { tenantId: tenantId ?? undefined as any }, { tenantId: null } ] },
|
|
@@ -75,7 +75,7 @@ export async function POST(req: Request) {
|
|
|
75
75
|
existing.fieldsJson = payload.fields
|
|
76
76
|
existing.isActive = payload.isActive ?? true
|
|
77
77
|
existing.updatedAt = new Date()
|
|
78
|
-
await em.
|
|
78
|
+
await em.persist(existing).flush()
|
|
79
79
|
} else {
|
|
80
80
|
const map = repo.create({
|
|
81
81
|
entityId: payload.entityId,
|
|
@@ -84,7 +84,7 @@ export async function POST(req: Request) {
|
|
|
84
84
|
fieldsJson: payload.fields,
|
|
85
85
|
isActive: payload.isActive ?? true,
|
|
86
86
|
})
|
|
87
|
-
await em.
|
|
87
|
+
await em.persist(map).flush()
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
try {
|