@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
4
|
+
import { sql } from 'kysely'
|
|
4
5
|
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
5
6
|
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
6
7
|
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
@@ -93,47 +94,49 @@ export async function GET(req: Request) {
|
|
|
93
94
|
|
|
94
95
|
const checkUserId = query.userId ?? auth.userId
|
|
95
96
|
const em = (container.resolve('em') as EntityManager).fork()
|
|
96
|
-
const
|
|
97
|
+
const kysely = em.getKysely<any>()
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
.
|
|
100
|
-
.
|
|
101
|
-
.
|
|
102
|
-
.
|
|
99
|
+
let baseQuery = (kysely as any)
|
|
100
|
+
.selectFrom('customer_interactions')
|
|
101
|
+
.select(['id', 'scheduled_at', 'duration_minutes', 'interaction_type'])
|
|
102
|
+
.where('tenant_id', '=', auth.tenantId)
|
|
103
|
+
.where('status', '=', 'planned')
|
|
104
|
+
.where('scheduled_at', 'is not', null)
|
|
105
|
+
.where('deleted_at', 'is', null)
|
|
103
106
|
|
|
104
107
|
if (organizationIds.length === 1) {
|
|
105
|
-
baseQuery.where('organization_id', organizationIds[0])
|
|
108
|
+
baseQuery = baseQuery.where('organization_id', '=', organizationIds[0])
|
|
106
109
|
} else if (organizationIds.length > 1) {
|
|
107
|
-
baseQuery.
|
|
110
|
+
baseQuery = baseQuery.where('organization_id', 'in', organizationIds)
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
if (checkUserId) {
|
|
111
|
-
baseQuery.where(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
baseQuery = baseQuery.where((eb: any) =>
|
|
115
|
+
eb.or([
|
|
116
|
+
eb('author_user_id', '=', checkUserId),
|
|
117
|
+
eb('owner_user_id', '=', checkUserId),
|
|
118
|
+
])
|
|
119
|
+
)
|
|
114
120
|
}
|
|
115
121
|
|
|
116
122
|
if (query.excludeId) {
|
|
117
|
-
baseQuery.
|
|
123
|
+
baseQuery = baseQuery.where('id', '!=', query.excludeId)
|
|
118
124
|
}
|
|
119
125
|
|
|
120
126
|
// Overlap condition: existing.start < windowEnd AND existing.end > windowStart
|
|
121
127
|
// end = scheduled_at + duration_minutes (default 30 if null)
|
|
122
|
-
baseQuery.where(
|
|
123
|
-
|
|
124
|
-
.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
),
|
|
129
|
-
)
|
|
130
|
-
})
|
|
128
|
+
baseQuery = baseQuery.where((eb: any) =>
|
|
129
|
+
eb.and([
|
|
130
|
+
eb('scheduled_at', '<', windowEnd.toISOString()),
|
|
131
|
+
eb(sql`(scheduled_at + make_interval(mins => COALESCE(duration_minutes, 30)))`, '>', windowStart.toISOString()),
|
|
132
|
+
])
|
|
133
|
+
)
|
|
131
134
|
|
|
132
135
|
// Raw SELECT: reads only unencrypted columns (id, scheduled_at, duration_minutes, interaction_type); title is excluded to avoid ciphertext leakage and is resolved below via findWithDecryption.
|
|
133
136
|
const rows = await baseQuery
|
|
134
|
-
.select('id', 'scheduled_at', 'duration_minutes', 'interaction_type')
|
|
135
137
|
.orderBy('scheduled_at', 'asc')
|
|
136
|
-
.limit(10)
|
|
138
|
+
.limit(10)
|
|
139
|
+
.execute() as Array<{
|
|
137
140
|
id: string
|
|
138
141
|
scheduled_at: string | Date
|
|
139
142
|
duration_minutes: number | null
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
4
|
+
import { sql } from 'kysely'
|
|
4
5
|
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
5
6
|
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
6
7
|
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
@@ -67,28 +68,29 @@ export async function GET(req: Request) {
|
|
|
67
68
|
? [auth.orgId]
|
|
68
69
|
: []
|
|
69
70
|
const em = (container.resolve('em') as EntityManager).fork()
|
|
70
|
-
const
|
|
71
|
+
const kysely = em.getKysely<any>()
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
.
|
|
74
|
-
.where('
|
|
75
|
-
.
|
|
73
|
+
let baseQuery = (kysely as any)
|
|
74
|
+
.selectFrom('customer_interactions')
|
|
75
|
+
.where('entity_id', '=', query.entityId)
|
|
76
|
+
.where('tenant_id', '=', auth.tenantId)
|
|
77
|
+
.where('deleted_at', 'is', null)
|
|
76
78
|
|
|
77
79
|
if (organizationIds.length === 1) {
|
|
78
|
-
baseQuery.where('organization_id', organizationIds[0])
|
|
80
|
+
baseQuery = baseQuery.where('organization_id', '=', organizationIds[0])
|
|
79
81
|
} else if (organizationIds.length > 1) {
|
|
80
|
-
baseQuery.
|
|
82
|
+
baseQuery = baseQuery.where('organization_id', 'in', organizationIds)
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
if (query.status) {
|
|
84
|
-
baseQuery.where('status', query.status)
|
|
86
|
+
baseQuery = baseQuery.where('status', '=', query.status)
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
// Raw SELECT: reads only unencrypted columns (id, interaction_type); title/notes are excluded to avoid ciphertext leakage.
|
|
88
90
|
const rows = await baseQuery
|
|
89
|
-
.select('interaction_type')
|
|
90
|
-
.
|
|
91
|
-
.
|
|
91
|
+
.select(['interaction_type', sql<string>`count(*)`.as('count')])
|
|
92
|
+
.groupBy('interaction_type')
|
|
93
|
+
.execute() as Array<{ interaction_type: string; count: string | number }>
|
|
92
94
|
|
|
93
95
|
const counts: Record<string, number> = { call: 0, email: 0, meeting: 0, note: 0 }
|
|
94
96
|
let total = 0
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
4
|
+
import { sql } from 'kysely'
|
|
4
5
|
import { makeCrudRoute } from '@open-mercato/shared/lib/crud/factory'
|
|
5
6
|
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
6
7
|
import { loadCustomFieldValues } from '@open-mercato/shared/lib/crud/custom-fields'
|
|
@@ -314,7 +315,7 @@ export async function GET(req: Request) {
|
|
|
314
315
|
: []
|
|
315
316
|
const selectedOrganizationId = scope?.selectedId ?? auth.orgId ?? organizationIds[0] ?? null
|
|
316
317
|
const em = (container.resolve('em') as EntityManager).fork()
|
|
317
|
-
const
|
|
318
|
+
const db = em.getKysely<any>() as any
|
|
318
319
|
|
|
319
320
|
const requestedSortField = query.sortField ?? 'scheduledAt'
|
|
320
321
|
const sortConfig = interactionSortConfig[requestedSortField]
|
|
@@ -327,8 +328,9 @@ export async function GET(req: Request) {
|
|
|
327
328
|
})
|
|
328
329
|
}
|
|
329
330
|
|
|
330
|
-
|
|
331
|
-
.
|
|
331
|
+
let rowsQuery = db
|
|
332
|
+
.selectFrom('customer_interactions')
|
|
333
|
+
.select([
|
|
332
334
|
'id',
|
|
333
335
|
'entity_id',
|
|
334
336
|
'deal_id',
|
|
@@ -359,72 +361,58 @@ export async function GET(req: Request) {
|
|
|
359
361
|
'tenant_id',
|
|
360
362
|
'created_at',
|
|
361
363
|
'updated_at',
|
|
362
|
-
|
|
364
|
+
sql`${sql.raw(sortSql)}`.as('__sort_value'),
|
|
363
365
|
])
|
|
364
|
-
.
|
|
365
|
-
.
|
|
366
|
+
.where('deleted_at', 'is', null)
|
|
367
|
+
.where('tenant_id', '=', auth.tenantId)
|
|
366
368
|
.limit(query.limit + 1)
|
|
367
369
|
|
|
368
370
|
if (organizationIds.length > 0) {
|
|
369
|
-
rowsQuery.
|
|
370
|
-
}
|
|
371
|
-
if (query.entityId) {
|
|
372
|
-
rowsQuery.andWhere('entity_id', query.entityId)
|
|
373
|
-
}
|
|
374
|
-
if (query.dealId) {
|
|
375
|
-
rowsQuery.andWhere('deal_id', query.dealId)
|
|
376
|
-
}
|
|
377
|
-
if (query.status) {
|
|
378
|
-
rowsQuery.andWhere('status', query.status)
|
|
379
|
-
}
|
|
380
|
-
if (query.interactionType) {
|
|
381
|
-
rowsQuery.andWhere('interaction_type', query.interactionType)
|
|
371
|
+
rowsQuery = rowsQuery.where('organization_id', 'in', organizationIds)
|
|
382
372
|
}
|
|
373
|
+
if (query.entityId) rowsQuery = rowsQuery.where('entity_id', '=', query.entityId)
|
|
374
|
+
if (query.dealId) rowsQuery = rowsQuery.where('deal_id', '=', query.dealId)
|
|
375
|
+
if (query.status) rowsQuery = rowsQuery.where('status', '=', query.status)
|
|
376
|
+
if (query.interactionType) rowsQuery = rowsQuery.where('interaction_type', '=', query.interactionType)
|
|
383
377
|
if (query.type) {
|
|
384
378
|
const types = query.type.split(',').map((t) => t.trim()).filter(Boolean)
|
|
385
379
|
if (types.length > 0) {
|
|
386
|
-
rowsQuery.
|
|
380
|
+
rowsQuery = rowsQuery.where('interaction_type', 'in', types)
|
|
387
381
|
}
|
|
388
382
|
}
|
|
389
383
|
if (query.pinned === 'true') {
|
|
390
|
-
rowsQuery.
|
|
384
|
+
rowsQuery = rowsQuery.where('pinned', '=', true)
|
|
391
385
|
} else if (query.pinned === 'false') {
|
|
392
|
-
rowsQuery.
|
|
393
|
-
}
|
|
394
|
-
if (query.excludeInteractionType) {
|
|
395
|
-
rowsQuery.andWhereNot('interaction_type', query.excludeInteractionType)
|
|
386
|
+
rowsQuery = rowsQuery.where('pinned', '=', false)
|
|
396
387
|
}
|
|
388
|
+
if (query.excludeInteractionType) rowsQuery = rowsQuery.where('interaction_type', '!=', query.excludeInteractionType)
|
|
397
389
|
if (query.search) {
|
|
398
390
|
const searchTerm = `%${query.search}%`
|
|
399
|
-
rowsQuery.
|
|
400
|
-
this.whereRaw("coalesce(title, '') ilike ?", [searchTerm]).orWhereRaw("coalesce(body, '') ilike ?", [searchTerm])
|
|
401
|
-
})
|
|
391
|
+
rowsQuery = rowsQuery.where(sql<boolean>`coalesce(title, '') ilike ${searchTerm} or coalesce(body, '') ilike ${searchTerm}`)
|
|
402
392
|
}
|
|
403
393
|
if (query.from) {
|
|
404
|
-
rowsQuery.
|
|
405
|
-
"coalesce(occurred_at, scheduled_at, created_at) >= ?",
|
|
406
|
-
[new Date(query.from)],
|
|
407
|
-
)
|
|
394
|
+
rowsQuery = rowsQuery.where(sql<boolean>`coalesce(occurred_at, scheduled_at, created_at) >= ${new Date(query.from)}`)
|
|
408
395
|
}
|
|
409
396
|
if (query.to) {
|
|
410
|
-
rowsQuery.
|
|
411
|
-
"coalesce(occurred_at, scheduled_at, created_at) <= ?",
|
|
412
|
-
[new Date(query.to)],
|
|
413
|
-
)
|
|
397
|
+
rowsQuery = rowsQuery.where(sql<boolean>`coalesce(occurred_at, scheduled_at, created_at) <= ${new Date(query.to)}`)
|
|
414
398
|
}
|
|
399
|
+
|
|
415
400
|
if (cursor) {
|
|
416
401
|
const op = sortDir === 'asc' ? '>' : '<'
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
421
|
-
|
|
402
|
+
const opRaw = sql.raw(op)
|
|
403
|
+
const sortRaw = sql.raw(sortSql)
|
|
404
|
+
rowsQuery = rowsQuery.where((eb: any) => eb.or([
|
|
405
|
+
sql<boolean>`${sortRaw} ${opRaw} ${cursor.sortValue}`,
|
|
406
|
+
eb.and([
|
|
407
|
+
sql<boolean>`${sortRaw} = ${cursor.sortValue}`,
|
|
408
|
+
eb('id', op, cursor.id),
|
|
409
|
+
]),
|
|
410
|
+
]))
|
|
422
411
|
}
|
|
423
412
|
|
|
424
|
-
rowsQuery.
|
|
425
|
-
rowsQuery.orderBy('id', sortDir)
|
|
413
|
+
rowsQuery = rowsQuery.orderBy(sql`${sql.raw(sortSql)} ${sql.raw(sortDir)}`).orderBy('id', sortDir)
|
|
426
414
|
|
|
427
|
-
const rows = await rowsQuery
|
|
415
|
+
const rows = await rowsQuery.execute() as InteractionListRow[]
|
|
428
416
|
const pageRows = rows.slice(0, query.limit)
|
|
429
417
|
const hasMore = rows.length > query.limit
|
|
430
418
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createScopedApiHelpers } from '@open-mercato/shared/lib/api/scoped'
|
|
2
2
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
3
|
+
import { sql } from 'kysely'
|
|
3
4
|
import type { CrudCtx } from '@open-mercato/shared/lib/crud/factory'
|
|
4
5
|
import type { EntityId } from '@open-mercato/shared/modules/entities'
|
|
5
6
|
import type { QueryCustomFieldSource, QueryJoinEdge, QueryEngine } from '@open-mercato/shared/lib/query/types'
|
|
@@ -50,28 +51,33 @@ async function enrichSearchSourcesWithCustomFieldTokens(
|
|
|
50
51
|
if (!entityTypes.length) return sources
|
|
51
52
|
|
|
52
53
|
const em = ctx.container.resolve('em') as EntityManager
|
|
53
|
-
const
|
|
54
|
-
let defsQuery =
|
|
55
|
-
.
|
|
56
|
-
.
|
|
57
|
-
.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
const db = em.getKysely<any>() as any
|
|
55
|
+
let defsQuery = db
|
|
56
|
+
.selectFrom('custom_field_defs')
|
|
57
|
+
.select(['entity_id', 'key', 'kind'])
|
|
58
|
+
.where('entity_id', 'in', entityTypes)
|
|
59
|
+
.where('is_active', '=', true)
|
|
60
|
+
|
|
61
|
+
const tenantScope = ctx.auth?.tenantId ?? null
|
|
62
|
+
defsQuery = defsQuery.where((eb: any) => eb.or([
|
|
63
|
+
eb('tenant_id', '=', tenantScope),
|
|
64
|
+
eb('tenant_id', 'is', null),
|
|
65
|
+
]))
|
|
62
66
|
|
|
63
67
|
if (ctx.selectedOrganizationId) {
|
|
64
|
-
defsQuery = defsQuery.
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
defsQuery = defsQuery.where((eb: any) => eb.or([
|
|
69
|
+
eb('organization_id', '=', ctx.selectedOrganizationId),
|
|
70
|
+
eb('organization_id', 'is', null),
|
|
71
|
+
]))
|
|
67
72
|
} else if (Array.isArray(ctx.organizationIds) && ctx.organizationIds.length > 0) {
|
|
68
|
-
defsQuery = defsQuery.
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
defsQuery = defsQuery.where((eb: any) => eb.or([
|
|
74
|
+
eb('organization_id', 'in', ctx.organizationIds),
|
|
75
|
+
eb('organization_id', 'is', null),
|
|
76
|
+
]))
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
const customFieldKeysByEntity = new Map<string, Set<string>>()
|
|
74
|
-
const rows = await defsQuery
|
|
80
|
+
const rows = await defsQuery.execute()
|
|
75
81
|
for (const row of rows as Array<{ entity_id?: unknown; key?: unknown; kind?: unknown }>) {
|
|
76
82
|
if (row.kind === 'attachment') continue
|
|
77
83
|
const entityType = typeof row.entity_id === 'string' ? row.entity_id : null
|
|
@@ -108,28 +114,29 @@ async function findSearchTokenEntityIds({
|
|
|
108
114
|
if (!tokens.hashes.length) return []
|
|
109
115
|
|
|
110
116
|
const em = ctx.container.resolve('em') as EntityManager
|
|
111
|
-
const
|
|
112
|
-
let searchQuery =
|
|
117
|
+
const db = em.getKysely<any>() as any
|
|
118
|
+
let searchQuery = db
|
|
119
|
+
.selectFrom('search_tokens')
|
|
113
120
|
.select('entity_id')
|
|
114
|
-
.where('entity_type', entityType)
|
|
115
|
-
.
|
|
116
|
-
.
|
|
121
|
+
.where('entity_type', '=', entityType)
|
|
122
|
+
.where('field', 'in', fields)
|
|
123
|
+
.where('token_hash', 'in', tokens.hashes)
|
|
117
124
|
.groupBy('entity_id')
|
|
118
|
-
.
|
|
125
|
+
.having(sql<boolean>`count(distinct token_hash) >= ${tokens.hashes.length}`)
|
|
119
126
|
|
|
120
127
|
if (ctx.auth?.tenantId !== undefined) {
|
|
121
|
-
searchQuery = searchQuery.
|
|
128
|
+
searchQuery = searchQuery.where(sql<boolean>`tenant_id is not distinct from ${ctx.auth?.tenantId ?? null}`)
|
|
122
129
|
}
|
|
123
130
|
if (ctx.selectedOrganizationId) {
|
|
124
|
-
searchQuery = searchQuery.where('organization_id', ctx.selectedOrganizationId)
|
|
131
|
+
searchQuery = searchQuery.where('organization_id', '=', ctx.selectedOrganizationId)
|
|
125
132
|
} else if (Array.isArray(ctx.organizationIds) && ctx.organizationIds.length > 0) {
|
|
126
|
-
searchQuery = searchQuery.
|
|
133
|
+
searchQuery = searchQuery.where('organization_id', 'in', ctx.organizationIds)
|
|
127
134
|
}
|
|
128
135
|
|
|
129
|
-
const rows = await searchQuery
|
|
136
|
+
const rows = await searchQuery.execute() as Array<{ entity_id?: unknown }>
|
|
130
137
|
return rows
|
|
131
|
-
.map((row
|
|
132
|
-
.filter((id
|
|
138
|
+
.map((row) => (typeof row.entity_id === 'string' ? row.entity_id : null))
|
|
139
|
+
.filter((id): id is string => typeof id === 'string' && id.length > 0)
|
|
133
140
|
}
|
|
134
141
|
|
|
135
142
|
async function mapScopedEntityIds({
|
|
@@ -144,31 +151,32 @@ async function mapScopedEntityIds({
|
|
|
144
151
|
if (!ids.length) return []
|
|
145
152
|
|
|
146
153
|
const em = ctx.container.resolve('em') as EntityManager
|
|
147
|
-
const
|
|
154
|
+
const db = em.getKysely<any>() as any
|
|
148
155
|
const sourceColumn = config.sourceColumn ?? 'id'
|
|
149
156
|
const tenantColumn = config.tenantColumn ?? 'tenant_id'
|
|
150
157
|
const organizationColumn = config.organizationColumn ?? 'organization_id'
|
|
151
158
|
|
|
152
|
-
let mapQuery =
|
|
159
|
+
let mapQuery = db
|
|
160
|
+
.selectFrom(config.table)
|
|
153
161
|
.select(config.targetColumn)
|
|
154
|
-
.
|
|
162
|
+
.where(sourceColumn, 'in', ids)
|
|
155
163
|
|
|
156
164
|
if (ctx.auth?.tenantId !== undefined) {
|
|
157
|
-
mapQuery = mapQuery.
|
|
165
|
+
mapQuery = mapQuery.where(sql<boolean>`${sql.ref(tenantColumn)} is not distinct from ${ctx.auth?.tenantId ?? null}`)
|
|
158
166
|
}
|
|
159
167
|
if (ctx.selectedOrganizationId) {
|
|
160
|
-
mapQuery = mapQuery.where(organizationColumn, ctx.selectedOrganizationId)
|
|
168
|
+
mapQuery = mapQuery.where(organizationColumn, '=', ctx.selectedOrganizationId)
|
|
161
169
|
} else if (Array.isArray(ctx.organizationIds) && ctx.organizationIds.length > 0) {
|
|
162
|
-
mapQuery = mapQuery.
|
|
170
|
+
mapQuery = mapQuery.where(organizationColumn, 'in', ctx.organizationIds)
|
|
163
171
|
}
|
|
164
172
|
|
|
165
|
-
const rows = await mapQuery
|
|
173
|
+
const rows = await mapQuery.execute() as Array<Record<string, unknown>>
|
|
166
174
|
return rows
|
|
167
|
-
.map((row
|
|
175
|
+
.map((row) => {
|
|
168
176
|
const value = row[config.targetColumn]
|
|
169
177
|
return typeof value === 'string' ? value : null
|
|
170
178
|
})
|
|
171
|
-
.filter((id
|
|
179
|
+
.filter((id): id is string => typeof id === 'string' && id.length > 0)
|
|
172
180
|
}
|
|
173
181
|
|
|
174
182
|
export async function findMatchingEntityIdsBySearchTokensAcrossSources({
|