@open-mercato/core 0.5.1-develop.2691.d8a0934b37 → 0.5.1-develop.2694.732417c5ec
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
package/src/modules/auth/cli.ts
CHANGED
|
@@ -59,17 +59,23 @@ const addUser: ModuleCli = {
|
|
|
59
59
|
organizationId: org.id,
|
|
60
60
|
tenantId: org.tenant.id,
|
|
61
61
|
})
|
|
62
|
-
await em.
|
|
62
|
+
await em.persist(u).flush()
|
|
63
63
|
if (rolesCsv) {
|
|
64
64
|
const names = rolesCsv.split(',').map(s => s.trim()).filter(Boolean)
|
|
65
65
|
for (const name of names) {
|
|
66
66
|
let role = await em.findOne(Role, { name, tenantId: normalizedTenantId })
|
|
67
|
+
if (!role && normalizedTenantId !== null) {
|
|
68
|
+
role = await em.findOne(Role, { name, tenantId: null })
|
|
69
|
+
}
|
|
67
70
|
if (!role) {
|
|
68
71
|
role = em.create(Role, { name, tenantId: normalizedTenantId, createdAt: new Date() })
|
|
69
|
-
await em.
|
|
72
|
+
await em.persist(role).flush()
|
|
73
|
+
} else if (normalizedTenantId !== null && role.tenantId !== normalizedTenantId) {
|
|
74
|
+
role.tenantId = normalizedTenantId
|
|
75
|
+
await em.persist(role).flush()
|
|
70
76
|
}
|
|
71
77
|
const link = em.create(UserRole, { user: u, role })
|
|
72
|
-
await em.
|
|
78
|
+
await em.persist(link).flush()
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
81
|
console.log('User created with id', u.id)
|
|
@@ -280,16 +286,16 @@ const rotateEncryptionKey: ModuleCli = {
|
|
|
280
286
|
const ids = pending.map((row: any) => String(row.id))
|
|
281
287
|
const users = rotate
|
|
282
288
|
? await em.find(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
289
|
+
User,
|
|
290
|
+
{ id: { $in: ids }, tenantId: scopeTenantId, organizationId: scopeOrganizationId },
|
|
291
|
+
)
|
|
286
292
|
: await findWithDecryption(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
+
em,
|
|
294
|
+
User,
|
|
295
|
+
{ id: { $in: ids }, tenantId: scopeTenantId, organizationId: scopeOrganizationId },
|
|
296
|
+
{},
|
|
297
|
+
{ tenantId: scopeTenantId, organizationId: scopeOrganizationId, encryptionService },
|
|
298
|
+
)
|
|
293
299
|
const usersById = new Map(users.map((user) => [String(user.id), user]))
|
|
294
300
|
let updated = 0
|
|
295
301
|
for (const row of pending) {
|
|
@@ -389,9 +395,9 @@ const addOrganization: ModuleCli = {
|
|
|
389
395
|
const em = resolve('em') as any
|
|
390
396
|
// Create tenant implicitly for simplicity
|
|
391
397
|
const tenant = em.create(Tenant, { name: `${name} Tenant` })
|
|
392
|
-
await em.
|
|
398
|
+
await em.persist(tenant).flush()
|
|
393
399
|
const org = em.create(Organization, { name, tenant })
|
|
394
|
-
await em.
|
|
400
|
+
await em.persist(org).flush()
|
|
395
401
|
await rebuildHierarchyForTenant(em, String(tenant.id))
|
|
396
402
|
console.log('Organization created with id', org.id, 'in tenant', tenant.id)
|
|
397
403
|
},
|
|
@@ -448,7 +454,7 @@ const setupApp: ModuleCli = {
|
|
|
448
454
|
console.log('⚠️ Updated roles if missing and reused tenant/organization.')
|
|
449
455
|
}
|
|
450
456
|
|
|
451
|
-
if(env.NODE_ENV !== 'test') {
|
|
457
|
+
if (env.NODE_ENV !== 'test') {
|
|
452
458
|
for (const snapshot of result.users) {
|
|
453
459
|
if (snapshot.created) {
|
|
454
460
|
if (snapshot.user.email === email && password) {
|
|
@@ -462,7 +468,7 @@ const setupApp: ModuleCli = {
|
|
|
462
468
|
}
|
|
463
469
|
}
|
|
464
470
|
|
|
465
|
-
if(env.NODE_ENV !== 'test')
|
|
471
|
+
if (env.NODE_ENV !== 'test') console.log('✅ Setup complete:', { tenantId: result.tenantId, organizationId: result.organizationId })
|
|
466
472
|
} catch (err) {
|
|
467
473
|
if (err instanceof Error && err.message === 'USER_EXISTS') {
|
|
468
474
|
console.error('Setup aborted: user already exists with the provided email.')
|
|
@@ -485,17 +491,17 @@ const listOrganizations: ModuleCli = {
|
|
|
485
491
|
{ populate: ['tenant'] },
|
|
486
492
|
{ tenantId: null, organizationId: null },
|
|
487
493
|
)
|
|
488
|
-
|
|
494
|
+
|
|
489
495
|
if (orgs.length === 0) {
|
|
490
496
|
console.log('No organizations found')
|
|
491
497
|
return
|
|
492
498
|
}
|
|
493
|
-
|
|
499
|
+
|
|
494
500
|
console.log(`Found ${orgs.length} organization(s):`)
|
|
495
501
|
console.log('')
|
|
496
502
|
console.log('ID | Name | Tenant ID | Created')
|
|
497
503
|
console.log('-------------------------------------|-------------------------|-------------------------------------|-------------------')
|
|
498
|
-
|
|
504
|
+
|
|
499
505
|
for (const org of orgs) {
|
|
500
506
|
const created = org.createdAt ? new Date(org.createdAt).toLocaleDateString() : 'N/A'
|
|
501
507
|
const id = org.id || 'N/A'
|
|
@@ -512,17 +518,17 @@ const listTenants: ModuleCli = {
|
|
|
512
518
|
const { resolve } = await createRequestContainer()
|
|
513
519
|
const em = resolve('em') as any
|
|
514
520
|
const tenants = await em.find(Tenant, {})
|
|
515
|
-
|
|
521
|
+
|
|
516
522
|
if (tenants.length === 0) {
|
|
517
523
|
console.log('No tenants found')
|
|
518
524
|
return
|
|
519
525
|
}
|
|
520
|
-
|
|
526
|
+
|
|
521
527
|
console.log(`Found ${tenants.length} tenant(s):`)
|
|
522
528
|
console.log('')
|
|
523
529
|
console.log('ID | Name | Created')
|
|
524
530
|
console.log('-------------------------------------|-------------------------|-------------------')
|
|
525
|
-
|
|
531
|
+
|
|
526
532
|
for (const tenant of tenants) {
|
|
527
533
|
const created = tenant.createdAt ? new Date(tenant.createdAt).toLocaleDateString() : 'N/A'
|
|
528
534
|
const id = tenant.id || 'N/A'
|
|
@@ -541,10 +547,10 @@ const listUsers: ModuleCli = {
|
|
|
541
547
|
const v = rest[i + 1]
|
|
542
548
|
if (k) args[k] = v
|
|
543
549
|
}
|
|
544
|
-
|
|
550
|
+
|
|
545
551
|
const { resolve } = await createRequestContainer()
|
|
546
552
|
const em = resolve('em') as any
|
|
547
|
-
|
|
553
|
+
|
|
548
554
|
// Build query with optional filters
|
|
549
555
|
const where: any = {}
|
|
550
556
|
if (args.organizationId || args.orgId || args.org) {
|
|
@@ -553,19 +559,19 @@ const listUsers: ModuleCli = {
|
|
|
553
559
|
if (args.tenantId || args.tenant) {
|
|
554
560
|
where.tenantId = args.tenantId || args.tenant
|
|
555
561
|
}
|
|
556
|
-
|
|
562
|
+
|
|
557
563
|
const users = await em.find(User, where)
|
|
558
|
-
|
|
564
|
+
|
|
559
565
|
if (users.length === 0) {
|
|
560
566
|
console.log('No users found')
|
|
561
567
|
return
|
|
562
568
|
}
|
|
563
|
-
|
|
569
|
+
|
|
564
570
|
console.log(`Found ${users.length} user(s):`)
|
|
565
571
|
console.log('')
|
|
566
572
|
console.log('ID | Email | Name | Organization ID | Tenant ID | Roles')
|
|
567
573
|
console.log('-------------------------------------|-------------------------|-------------------------|---------------------|---------------------|-------------------')
|
|
568
|
-
|
|
574
|
+
|
|
569
575
|
for (const user of users) {
|
|
570
576
|
// Get user roles separately
|
|
571
577
|
const userRoles = await findWithDecryption(
|
|
@@ -576,25 +582,25 @@ const listUsers: ModuleCli = {
|
|
|
576
582
|
{ tenantId: user.tenantId ?? null, organizationId: user.organizationId ?? null },
|
|
577
583
|
)
|
|
578
584
|
const roles = userRoles.map((ur: any) => ur.role?.name).filter(Boolean).join(', ') || 'None'
|
|
579
|
-
|
|
585
|
+
|
|
580
586
|
// Get organization and tenant names if IDs exist
|
|
581
587
|
let orgName = 'N/A'
|
|
582
588
|
let tenantName = 'N/A'
|
|
583
|
-
|
|
589
|
+
|
|
584
590
|
if (user.organizationId) {
|
|
585
591
|
const org = await em.findOne(Organization, { id: user.organizationId })
|
|
586
592
|
orgName = org?.name?.substring(0, 19) + '...' || user.organizationId.substring(0, 8) + '...'
|
|
587
593
|
}
|
|
588
|
-
|
|
594
|
+
|
|
589
595
|
if (user.tenantId) {
|
|
590
596
|
const tenant = await em.findOne(Tenant, { id: user.tenantId })
|
|
591
597
|
tenantName = tenant?.name?.substring(0, 19) + '...' || user.tenantId.substring(0, 8) + '...'
|
|
592
598
|
}
|
|
593
|
-
|
|
599
|
+
|
|
594
600
|
const id = user.id || 'N/A'
|
|
595
601
|
const email = (user.email || 'N/A').padEnd(23)
|
|
596
602
|
const name = (user.name || 'Unnamed').padEnd(23)
|
|
597
|
-
|
|
603
|
+
|
|
598
604
|
console.log(`${id.padEnd(35)} | ${email} | ${name} | ${orgName.padEnd(19)} | ${tenantName.padEnd(19)} | ${roles}`)
|
|
599
605
|
}
|
|
600
606
|
},
|
|
@@ -609,29 +615,29 @@ const setPassword: ModuleCli = {
|
|
|
609
615
|
const v = rest[i + 1]
|
|
610
616
|
if (k) args[k] = v
|
|
611
617
|
}
|
|
612
|
-
|
|
618
|
+
|
|
613
619
|
const email = args.email
|
|
614
620
|
const password = args.password
|
|
615
|
-
|
|
621
|
+
|
|
616
622
|
if (!email || !password) {
|
|
617
623
|
console.error('Usage: mercato auth set-password --email <email> --password <newPassword>')
|
|
618
624
|
return
|
|
619
625
|
}
|
|
620
626
|
if (!ensurePasswordPolicy(password)) return
|
|
621
|
-
|
|
627
|
+
|
|
622
628
|
const { resolve } = await createRequestContainer()
|
|
623
629
|
const em = resolve('em') as any
|
|
624
630
|
const emailHash = computeEmailHash(email)
|
|
625
631
|
const user = await em.findOne(User, { $or: [{ email }, { emailHash }] })
|
|
626
|
-
|
|
632
|
+
|
|
627
633
|
if (!user) {
|
|
628
634
|
console.error(`User with email "${email}" not found`)
|
|
629
635
|
return
|
|
630
636
|
}
|
|
631
|
-
|
|
637
|
+
|
|
632
638
|
user.passwordHash = await hash(password, 10)
|
|
633
|
-
await em.
|
|
634
|
-
|
|
639
|
+
await em.persist(user).flush()
|
|
640
|
+
|
|
635
641
|
console.log(`✅ Password updated successfully for user: ${email}`)
|
|
636
642
|
},
|
|
637
643
|
}
|
|
@@ -341,7 +341,7 @@ async function sendInviteToUser(
|
|
|
341
341
|
const tokenHash = hashAuthToken(rawToken)
|
|
342
342
|
const expiresAt = new Date(Date.now() + INVITE_TOKEN_TTL_MS)
|
|
343
343
|
const row = em.create(PasswordReset, { user, token: tokenHash, expiresAt, createdAt: new Date() })
|
|
344
|
-
await em.
|
|
344
|
+
await em.persist(row).flush()
|
|
345
345
|
|
|
346
346
|
const base = getSecurityEmailBaseUrl()
|
|
347
347
|
const inviteUrl = `${base}/reset/${rawToken}`
|
|
@@ -517,7 +517,7 @@ async function ensureRoleAclFor(
|
|
|
517
517
|
isSuperAdmin: !!options.isSuperAdmin,
|
|
518
518
|
createdAt: new Date(),
|
|
519
519
|
})
|
|
520
|
-
await em.
|
|
520
|
+
await em.persist(acl).flush()
|
|
521
521
|
return
|
|
522
522
|
}
|
|
523
523
|
const currentFeatures = Array.isArray(existing.featuresJson) ? existing.featuresJson : []
|
|
@@ -530,7 +530,7 @@ async function ensureRoleAclFor(
|
|
|
530
530
|
existing.isSuperAdmin = true
|
|
531
531
|
}
|
|
532
532
|
if (changed || options.isSuperAdmin) {
|
|
533
|
-
await em.
|
|
533
|
+
await em.persist(existing).flush()
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
536
|
|
|
@@ -550,7 +550,7 @@ async function deactivateDemoSuperAdminIfSelfOnboardingEnabled(em: EntityManager
|
|
|
550
550
|
dirty = true
|
|
551
551
|
}
|
|
552
552
|
if (dirty) {
|
|
553
|
-
await em.
|
|
553
|
+
await em.persist(user).flush()
|
|
554
554
|
}
|
|
555
555
|
} catch (error) {
|
|
556
556
|
console.error('[auth.setup] failed to deactivate demo superadmin user', error)
|
|
@@ -78,7 +78,7 @@ export class AuthService {
|
|
|
78
78
|
const rawToken = generateAuthToken()
|
|
79
79
|
const tokenHash = hashAuthToken(rawToken)
|
|
80
80
|
const sess = this.em.create(Session as any, { user, token: tokenHash, expiresAt, createdAt: new Date() } as any)
|
|
81
|
-
await this.em.
|
|
81
|
+
await this.em.persist(sess).flush()
|
|
82
82
|
return { session: sess as Session, token: rawToken }
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -126,7 +126,7 @@ export class AuthService {
|
|
|
126
126
|
const tokenHash = hashAuthToken(rawToken)
|
|
127
127
|
const expiresAt = new Date(Date.now() + 60 * 60 * 1000)
|
|
128
128
|
const row = this.em.create(PasswordReset as any, { user, token: tokenHash, expiresAt, createdAt: new Date() } as any)
|
|
129
|
-
await this.em.
|
|
129
|
+
await this.em.persist(row).flush()
|
|
130
130
|
return { user, token: rawToken }
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -211,7 +211,7 @@ export async function POST(req: Request) {
|
|
|
211
211
|
const rule = em.create(BusinessRule, data)
|
|
212
212
|
|
|
213
213
|
try {
|
|
214
|
-
await em.
|
|
214
|
+
await em.persist(rule).flush()
|
|
215
215
|
} catch (error) {
|
|
216
216
|
console.error('[business_rules.rules] Failed to persist new rule:', error)
|
|
217
217
|
return NextResponse.json(
|
|
@@ -273,7 +273,7 @@ export async function PUT(req: Request) {
|
|
|
273
273
|
em.assign(rule, parsed.data)
|
|
274
274
|
|
|
275
275
|
try {
|
|
276
|
-
await em.
|
|
276
|
+
await em.persist(rule).flush()
|
|
277
277
|
} catch (error) {
|
|
278
278
|
console.error('[business_rules.rules] Failed to persist rule update:', error)
|
|
279
279
|
return NextResponse.json(
|
|
@@ -313,7 +313,7 @@ export async function DELETE(req: Request) {
|
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
rule.deletedAt = new Date()
|
|
316
|
-
await em.
|
|
316
|
+
await em.persist(rule).flush()
|
|
317
317
|
|
|
318
318
|
return NextResponse.json({ ok: true })
|
|
319
319
|
}
|
|
@@ -119,12 +119,15 @@ export async function POST(req: Request, ctx: { params?: { id?: string } }) {
|
|
|
119
119
|
const validatedPayload = createRuleSetMemberSchema.parse(payload)
|
|
120
120
|
|
|
121
121
|
const member = em.create(RuleSetMember, {
|
|
122
|
-
|
|
122
|
+
sequence: validatedPayload.sequence,
|
|
123
|
+
enabled: validatedPayload.enabled,
|
|
124
|
+
tenantId: validatedPayload.tenantId,
|
|
125
|
+
organizationId: validatedPayload.organizationId,
|
|
123
126
|
ruleSet: ruleSet,
|
|
124
127
|
rule: rule,
|
|
125
128
|
})
|
|
126
129
|
|
|
127
|
-
await em.
|
|
130
|
+
await em.persist(member).flush()
|
|
128
131
|
|
|
129
132
|
return NextResponse.json({ id: member.id }, { status: 201 })
|
|
130
133
|
}
|
|
@@ -174,7 +177,7 @@ export async function PUT(req: Request, ctx: { params?: { id?: string } }) {
|
|
|
174
177
|
member.enabled = parsed.data.enabled
|
|
175
178
|
}
|
|
176
179
|
|
|
177
|
-
await em.
|
|
180
|
+
await em.persist(member).flush()
|
|
178
181
|
|
|
179
182
|
return NextResponse.json({ ok: true })
|
|
180
183
|
}
|
|
@@ -211,7 +214,7 @@ export async function DELETE(req: Request, ctx: { params?: { id?: string } }) {
|
|
|
211
214
|
return NextResponse.json({ error: 'Member not found' }, { status: 404 })
|
|
212
215
|
}
|
|
213
216
|
|
|
214
|
-
await em.
|
|
217
|
+
await em.remove(member).flush()
|
|
215
218
|
|
|
216
219
|
return NextResponse.json({ ok: true })
|
|
217
220
|
}
|
|
@@ -171,7 +171,7 @@ export async function POST(req: Request) {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
const ruleSet = em.create(RuleSet, parsed.data)
|
|
174
|
-
await em.
|
|
174
|
+
await em.persist(ruleSet).flush()
|
|
175
175
|
|
|
176
176
|
return NextResponse.json({ id: ruleSet.id }, { status: 201 })
|
|
177
177
|
}
|
|
@@ -222,7 +222,7 @@ export async function PUT(req: Request) {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
em.assign(ruleSet, parsed.data)
|
|
225
|
-
await em.
|
|
225
|
+
await em.persist(ruleSet).flush()
|
|
226
226
|
|
|
227
227
|
return NextResponse.json({ ok: true })
|
|
228
228
|
}
|
|
@@ -255,7 +255,7 @@ export async function DELETE(req: Request) {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
ruleSet.deletedAt = new Date()
|
|
258
|
-
await em.
|
|
258
|
+
await em.persist(ruleSet).flush()
|
|
259
259
|
|
|
260
260
|
return NextResponse.json({ ok: true })
|
|
261
261
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
PrimaryKey,
|
|
4
|
-
Property,
|
|
5
|
-
Index,
|
|
6
|
-
Unique,
|
|
7
|
-
OptionalProps,
|
|
8
|
-
ManyToOne,
|
|
9
|
-
} from '@mikro-orm/core'
|
|
1
|
+
import { OptionalProps } from '@mikro-orm/core'
|
|
2
|
+
import { Entity, Index, ManyToOne, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
|
|
10
3
|
|
|
11
4
|
export type RuleType = 'GUARD' | 'VALIDATION' | 'CALCULATION' | 'ACTION' | 'ASSIGNMENT'
|
|
12
5
|
export type ExecutionResult = 'SUCCESS' | 'FAILURE' | 'ERROR'
|
|
@@ -62,7 +62,6 @@ export async function buildOptionSchemaFilters(
|
|
|
62
62
|
}
|
|
63
63
|
const active = parseBooleanFlag(query.isActive)
|
|
64
64
|
if (active !== undefined) filters.is_active = active
|
|
65
|
-
if (!query.withDeleted) filters.deleted_at = null
|
|
66
65
|
const tenantId = ctx.auth?.tenantId ?? null
|
|
67
66
|
if (tenantId) {
|
|
68
67
|
try {
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
Entity,
|
|
4
|
-
Index,
|
|
5
|
-
ManyToOne,
|
|
6
|
-
OneToMany,
|
|
7
|
-
OptionalProps,
|
|
8
|
-
PrimaryKey,
|
|
9
|
-
Property,
|
|
10
|
-
Unique,
|
|
11
|
-
} from '@mikro-orm/core'
|
|
1
|
+
import { Collection, OptionalProps } from '@mikro-orm/core'
|
|
2
|
+
import { Entity, Index, ManyToOne, OneToMany, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
|
|
12
3
|
import type {
|
|
13
4
|
CatalogPriceDisplayMode,
|
|
14
5
|
CatalogProductOptionSchema,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OptionalProps } from '@mikro-orm/core'
|
|
2
|
+
import { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
|
|
2
3
|
|
|
3
4
|
@Entity({ tableName: 'module_configs' })
|
|
4
5
|
@Unique({ name: 'module_configs_module_name_unique', properties: ['moduleId', 'name'] })
|
|
@@ -40,7 +40,7 @@ export async function createFetchConfig(
|
|
|
40
40
|
updatedAt: new Date(),
|
|
41
41
|
})
|
|
42
42
|
|
|
43
|
-
await em.
|
|
43
|
+
await em.persist(config).flush()
|
|
44
44
|
return config
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -63,7 +63,7 @@ export async function updateFetchConfig(
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
em.assign(config, validated)
|
|
66
|
-
await em.
|
|
66
|
+
await em.persist(config).flush()
|
|
67
67
|
|
|
68
68
|
return config
|
|
69
69
|
}
|
|
@@ -83,5 +83,5 @@ export async function deleteFetchConfig(
|
|
|
83
83
|
throw new Error('Fetch config not found')
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
await em.
|
|
86
|
+
await em.remove(config).flush()
|
|
87
87
|
}
|
|
@@ -138,7 +138,7 @@ export async function POST(req: Request) {
|
|
|
138
138
|
em.persist(userRole)
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
await em.
|
|
141
|
+
await em.persist(user).flush()
|
|
142
142
|
|
|
143
143
|
const verificationToken = await customerTokenService.createEmailVerification(user.id, tenantId)
|
|
144
144
|
const verifyUrl = resolvePortalVerifyUrl(baseUrl, verificationToken, orgRow.slug)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entity,
|
|
1
|
+
import { Entity, Index, ManyToOne, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
|
|
2
2
|
|
|
3
3
|
@Entity({ tableName: 'customer_users' })
|
|
4
4
|
@Unique({ properties: ['tenantId', 'emailHash'], name: 'customer_users_tenant_email_hash_uniq' })
|
|
@@ -43,7 +43,7 @@ export class CustomerSessionService {
|
|
|
43
43
|
lastUsedAt: new Date(),
|
|
44
44
|
createdAt: new Date(),
|
|
45
45
|
} as any) as CustomerUserSession
|
|
46
|
-
await this.em.
|
|
46
|
+
await this.em.persist(session).flush()
|
|
47
47
|
|
|
48
48
|
const jwt = this.signCustomerJwt(user, resolvedFeatures, session.id)
|
|
49
49
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EntityManager } from '@mikro-orm/postgresql'
|
|
2
|
+
import type { Kysely } from 'kysely'
|
|
2
3
|
import {
|
|
3
4
|
CustomerUser,
|
|
4
5
|
CustomerUserEmailVerification,
|
|
@@ -6,6 +7,10 @@ import {
|
|
|
6
7
|
} from '@open-mercato/core/modules/customer_accounts/data/entities'
|
|
7
8
|
import { generateSecureToken, hashToken } from '@open-mercato/core/modules/customer_accounts/lib/tokenGenerator'
|
|
8
9
|
|
|
10
|
+
function getKysely(em: EntityManager): Kysely<any> {
|
|
11
|
+
return (em as unknown as { getKysely: () => Kysely<any> }).getKysely()
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
const EMAIL_VERIFICATION_TTL_MS = 24 * 60 * 60 * 1000 // 24 hours
|
|
10
15
|
const MAGIC_LINK_TTL_MS = 15 * 60 * 1000 // 15 minutes
|
|
11
16
|
const PASSWORD_RESET_TTL_MS = 60 * 60 * 1000 // 60 minutes
|
|
@@ -24,7 +29,7 @@ export class CustomerTokenService {
|
|
|
24
29
|
expiresAt,
|
|
25
30
|
createdAt: new Date(),
|
|
26
31
|
} as any)
|
|
27
|
-
await this.em.
|
|
32
|
+
await this.em.persist(record).flush()
|
|
28
33
|
return rawToken
|
|
29
34
|
}
|
|
30
35
|
|
|
@@ -39,7 +44,7 @@ export class CustomerTokenService {
|
|
|
39
44
|
expiresAt,
|
|
40
45
|
createdAt: new Date(),
|
|
41
46
|
} as any)
|
|
42
|
-
await this.em.
|
|
47
|
+
await this.em.persist(record).flush()
|
|
43
48
|
return rawToken
|
|
44
49
|
}
|
|
45
50
|
|
|
@@ -53,7 +58,7 @@ export class CustomerTokenService {
|
|
|
53
58
|
expiresAt,
|
|
54
59
|
createdAt: new Date(),
|
|
55
60
|
} as any)
|
|
56
|
-
await this.em.
|
|
61
|
+
await this.em.persist(record).flush()
|
|
57
62
|
return rawToken
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -70,12 +75,15 @@ export class CustomerTokenService {
|
|
|
70
75
|
const user = record.user as CustomerUser
|
|
71
76
|
if (tenantId && user?.tenantId !== tenantId) return null
|
|
72
77
|
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
.
|
|
76
|
-
.
|
|
77
|
-
.where('
|
|
78
|
-
.
|
|
78
|
+
const db = getKysely(this.em)
|
|
79
|
+
const updateResult = await db
|
|
80
|
+
.updateTable('customer_user_email_verifications' as any)
|
|
81
|
+
.set({ used_at: new Date() } as any)
|
|
82
|
+
.where('id' as any, '=', record.id)
|
|
83
|
+
.where('used_at' as any, 'is', null)
|
|
84
|
+
.where('expires_at' as any, '>', new Date())
|
|
85
|
+
.executeTakeFirst()
|
|
86
|
+
const consumed = Number(updateResult?.numUpdatedRows ?? 0n)
|
|
79
87
|
if (consumed === 0) return null
|
|
80
88
|
|
|
81
89
|
const resolvedUserId = typeof user === 'string' ? user : user.id
|
|
@@ -95,12 +103,15 @@ export class CustomerTokenService {
|
|
|
95
103
|
const user = record.user as CustomerUser
|
|
96
104
|
if (tenantId && user?.tenantId !== tenantId) return null
|
|
97
105
|
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
.
|
|
101
|
-
.
|
|
102
|
-
.where('
|
|
103
|
-
.
|
|
106
|
+
const db = getKysely(this.em)
|
|
107
|
+
const updateResult = await db
|
|
108
|
+
.updateTable('customer_user_password_resets' as any)
|
|
109
|
+
.set({ used_at: new Date() } as any)
|
|
110
|
+
.where('id' as any, '=', record.id)
|
|
111
|
+
.where('used_at' as any, 'is', null)
|
|
112
|
+
.where('expires_at' as any, '>', new Date())
|
|
113
|
+
.executeTakeFirst()
|
|
114
|
+
const consumed = Number(updateResult?.numUpdatedRows ?? 0n)
|
|
104
115
|
if (consumed === 0) return null
|
|
105
116
|
|
|
106
117
|
const resolvedUserId = typeof user === 'string' ? user : user.id
|