@open-mercato/core 0.4.2-canary-c71ef83148 → 0.4.2-canary-f821f89ef6
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/generated/entities/workflow_event_trigger/index.js +33 -0
- package/dist/generated/entities/workflow_event_trigger/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +2 -5
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +2 -2
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/api_docs/frontend/docs/api/page.js +2 -3
- package/dist/modules/api_docs/frontend/docs/api/page.js.map +2 -2
- package/dist/modules/api_keys/backend/api-keys/page.js +1 -1
- package/dist/modules/api_keys/backend/api-keys/page.js.map +2 -2
- package/dist/modules/attachments/components/AttachmentLibrary.js +0 -4
- package/dist/modules/attachments/components/AttachmentLibrary.js.map +2 -2
- package/dist/modules/attachments/components/AttachmentPartitionSettings.js +0 -2
- package/dist/modules/attachments/components/AttachmentPartitionSettings.js.map +2 -2
- package/dist/modules/auth/api/admin/nav.js +3 -4
- package/dist/modules/auth/api/admin/nav.js.map +2 -2
- package/dist/modules/auth/api/login.js +6 -25
- package/dist/modules/auth/api/login.js.map +2 -2
- package/dist/modules/auth/api/reset/confirm.js +2 -25
- package/dist/modules/auth/api/reset/confirm.js.map +2 -2
- package/dist/modules/auth/api/reset.js +0 -23
- package/dist/modules/auth/api/reset.js.map +2 -2
- package/dist/modules/auth/api/sidebar/preferences/route.js +9 -14
- package/dist/modules/auth/api/sidebar/preferences/route.js.map +2 -2
- package/dist/modules/auth/api/users/route.js +2 -4
- package/dist/modules/auth/api/users/route.js.map +2 -2
- package/dist/modules/auth/backend/roles/[id]/edit/page.js +1 -4
- package/dist/modules/auth/backend/roles/[id]/edit/page.js.map +2 -2
- package/dist/modules/auth/backend/roles/page.js +3 -3
- package/dist/modules/auth/backend/roles/page.js.map +2 -2
- package/dist/modules/auth/backend/users/[id]/edit/page.js +3 -18
- package/dist/modules/auth/backend/users/[id]/edit/page.js.map +2 -2
- package/dist/modules/auth/backend/users/create/page.js +2 -15
- package/dist/modules/auth/backend/users/create/page.js.map +2 -2
- package/dist/modules/auth/backend/users/page.js +3 -3
- package/dist/modules/auth/backend/users/page.js.map +2 -2
- package/dist/modules/auth/cli.js +11 -25
- package/dist/modules/auth/cli.js.map +2 -2
- package/dist/modules/auth/commands/users.js +2 -59
- package/dist/modules/auth/commands/users.js.map +2 -2
- package/dist/modules/auth/data/validators.js +3 -6
- package/dist/modules/auth/data/validators.js.map +2 -2
- package/dist/modules/auth/events.js +30 -0
- package/dist/modules/auth/events.js.map +7 -0
- package/dist/modules/auth/frontend/login.js +3 -105
- package/dist/modules/auth/frontend/login.js.map +2 -2
- package/dist/modules/auth/frontend/reset/[token]/page.js +10 -20
- package/dist/modules/auth/frontend/reset/[token]/page.js.map +2 -2
- package/dist/modules/auth/lib/setup-app.js +8 -42
- package/dist/modules/auth/lib/setup-app.js.map +2 -2
- package/dist/modules/auth/services/authService.js +3 -24
- package/dist/modules/auth/services/authService.js.map +2 -2
- package/dist/modules/business_rules/api/execute/[ruleId]/route.js +145 -0
- package/dist/modules/business_rules/api/execute/[ruleId]/route.js.map +7 -0
- package/dist/modules/business_rules/api/execute/route.js +1 -7
- package/dist/modules/business_rules/api/execute/route.js.map +2 -2
- package/dist/modules/business_rules/backend/rules/page.js +0 -4
- package/dist/modules/business_rules/backend/rules/page.js.map +2 -2
- package/dist/modules/business_rules/backend/sets/page.js +0 -3
- package/dist/modules/business_rules/backend/sets/page.js.map +2 -2
- package/dist/modules/business_rules/cli.js +1 -2
- package/dist/modules/business_rules/cli.js.map +2 -2
- package/dist/modules/business_rules/data/validators.js +34 -0
- package/dist/modules/business_rules/data/validators.js.map +2 -2
- package/dist/modules/business_rules/index.js +21 -1
- package/dist/modules/business_rules/index.js.map +2 -2
- package/dist/modules/business_rules/lib/rule-engine.js +185 -34
- package/dist/modules/business_rules/lib/rule-engine.js.map +2 -2
- package/dist/modules/catalog/components/PriceKindSettings.js +0 -2
- package/dist/modules/catalog/components/PriceKindSettings.js.map +2 -2
- package/dist/modules/catalog/components/categories/CategoriesDataTable.js +2 -2
- package/dist/modules/catalog/components/categories/CategoriesDataTable.js.map +2 -2
- package/dist/modules/catalog/components/products/ProductsDataTable.js +0 -2
- package/dist/modules/catalog/components/products/ProductsDataTable.js.map +2 -2
- package/dist/modules/catalog/events.js +34 -0
- package/dist/modules/catalog/events.js.map +7 -0
- package/dist/modules/configs/cli.js +0 -6
- package/dist/modules/configs/cli.js.map +2 -2
- package/dist/modules/configs/components/CachePanel.js +4 -4
- package/dist/modules/configs/components/CachePanel.js.map +2 -2
- package/dist/modules/configs/lib/system-status.js +1 -48
- package/dist/modules/configs/lib/system-status.js.map +2 -2
- package/dist/modules/configs/lib/upgrade-actions.js +0 -18
- package/dist/modules/configs/lib/upgrade-actions.js.map +2 -2
- package/dist/modules/currencies/backend/currencies/page.js +0 -3
- package/dist/modules/currencies/backend/currencies/page.js.map +2 -2
- package/dist/modules/currencies/backend/exchange-rates/page.js +0 -2
- package/dist/modules/currencies/backend/exchange-rates/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/companies/page.js +0 -3
- package/dist/modules/customers/backend/customers/companies/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/page.js +0 -3
- package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/people/page.js +0 -3
- package/dist/modules/customers/backend/customers/people/page.js.map +2 -2
- package/dist/modules/customers/commands/deals.js +0 -31
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/components/CustomerTodosTable.js +0 -1
- package/dist/modules/customers/components/CustomerTodosTable.js.map +2 -2
- package/dist/modules/customers/events.js +49 -0
- package/dist/modules/customers/events.js.map +7 -0
- package/dist/modules/customers/widgets/dashboard/customer-todos/widget.js +1 -2
- package/dist/modules/customers/widgets/dashboard/customer-todos/widget.js.map +2 -2
- package/dist/modules/customers/widgets/dashboard/new-customers/widget.js +1 -2
- package/dist/modules/customers/widgets/dashboard/new-customers/widget.js.map +2 -2
- package/dist/modules/customers/widgets/dashboard/new-deals/widget.js +1 -2
- package/dist/modules/customers/widgets/dashboard/new-deals/widget.js.map +2 -2
- package/dist/modules/customers/widgets/dashboard/next-interactions/widget.js +1 -2
- package/dist/modules/customers/widgets/dashboard/next-interactions/widget.js.map +2 -2
- package/dist/modules/dashboards/cli.js +5 -44
- package/dist/modules/dashboards/cli.js.map +2 -2
- package/dist/modules/dashboards/components/WidgetVisibilityEditor.js +11 -16
- package/dist/modules/dashboards/components/WidgetVisibilityEditor.js.map +3 -3
- package/dist/modules/dashboards/services/widgetDataService.js +3 -139
- package/dist/modules/dashboards/services/widgetDataService.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/aov-kpi/widget.js +1 -2
- package/dist/modules/dashboards/widgets/dashboard/aov-kpi/widget.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/new-customers-kpi/widget.js +1 -2
- package/dist/modules/dashboards/widgets/dashboard/new-customers-kpi/widget.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/orders-by-status/widget.js +1 -2
- package/dist/modules/dashboards/widgets/dashboard/orders-by-status/widget.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/orders-kpi/widget.js +1 -2
- package/dist/modules/dashboards/widgets/dashboard/orders-kpi/widget.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/pipeline-summary/widget.js +1 -2
- package/dist/modules/dashboards/widgets/dashboard/pipeline-summary/widget.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/revenue-kpi/widget.js +1 -2
- package/dist/modules/dashboards/widgets/dashboard/revenue-kpi/widget.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/revenue-trend/widget.js +1 -2
- package/dist/modules/dashboards/widgets/dashboard/revenue-trend/widget.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/sales-by-region/widget.js +1 -2
- package/dist/modules/dashboards/widgets/dashboard/sales-by-region/widget.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/top-customers/widget.js +1 -2
- package/dist/modules/dashboards/widgets/dashboard/top-customers/widget.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/top-products/widget.js +1 -2
- package/dist/modules/dashboards/widgets/dashboard/top-products/widget.js.map +2 -2
- package/dist/modules/dictionaries/components/DictionaryTable.js +0 -2
- package/dist/modules/dictionaries/components/DictionaryTable.js.map +2 -2
- package/dist/modules/directory/backend/directory/organizations/page.js +2 -2
- package/dist/modules/directory/backend/directory/organizations/page.js.map +2 -2
- package/dist/modules/directory/backend/directory/tenants/page.js +2 -2
- package/dist/modules/directory/backend/directory/tenants/page.js.map +2 -2
- package/dist/modules/directory/events.js +23 -0
- package/dist/modules/directory/events.js.map +7 -0
- package/dist/modules/entities/backend/entities/user/[entityId]/records/page.js +2 -2
- package/dist/modules/entities/backend/entities/user/[entityId]/records/page.js.map +2 -2
- package/dist/modules/entities/components/SystemEntitiesTable.js +1 -1
- package/dist/modules/entities/components/SystemEntitiesTable.js.map +2 -2
- package/dist/modules/entities/components/UserEntitiesTable.js +2 -2
- package/dist/modules/entities/components/UserEntitiesTable.js.map +2 -2
- package/dist/modules/feature_toggles/components/FeatureTogglesTable.js +3 -3
- package/dist/modules/feature_toggles/components/FeatureTogglesTable.js.map +2 -2
- package/dist/modules/feature_toggles/components/OverridesTable.js +1 -1
- package/dist/modules/feature_toggles/components/OverridesTable.js.map +2 -2
- package/dist/modules/planner/backend/planner/availability-rulesets/page.js +2 -2
- package/dist/modules/planner/backend/planner/availability-rulesets/page.js.map +2 -2
- package/dist/modules/query_index/cli.js +7 -63
- package/dist/modules/query_index/cli.js.map +2 -2
- package/dist/modules/query_index/components/QueryIndexesTable.js +1 -7
- package/dist/modules/query_index/components/QueryIndexesTable.js.map +2 -2
- package/dist/modules/resources/backend/resources/resource-types/page.js +2 -2
- package/dist/modules/resources/backend/resources/resource-types/page.js.map +2 -2
- package/dist/modules/resources/backend/resources/resources/page.js +2 -2
- package/dist/modules/resources/backend/resources/resources/page.js.map +2 -2
- package/dist/modules/sales/acl.js +1 -0
- package/dist/modules/sales/acl.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/offers/page.js +0 -2
- package/dist/modules/sales/backend/sales/channels/offers/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/page.js +0 -2
- package/dist/modules/sales/backend/sales/channels/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/documents/[id]/page.js +12 -0
- package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +62 -53
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/commands/payments.js +0 -26
- package/dist/modules/sales/commands/payments.js.map +2 -2
- package/dist/modules/sales/components/AdjustmentKindSettings.js +2 -2
- package/dist/modules/sales/components/AdjustmentKindSettings.js.map +2 -2
- package/dist/modules/sales/components/PaymentMethodsSettings.js +2 -2
- package/dist/modules/sales/components/PaymentMethodsSettings.js.map +2 -2
- package/dist/modules/sales/components/ShippingMethodsSettings.js +2 -2
- package/dist/modules/sales/components/ShippingMethodsSettings.js.map +2 -2
- package/dist/modules/sales/components/TaxRatesSettings.js +2 -2
- package/dist/modules/sales/components/TaxRatesSettings.js.map +2 -2
- package/dist/modules/sales/components/channels/SalesChannelOffersPanel.js +0 -2
- package/dist/modules/sales/components/channels/SalesChannelOffersPanel.js.map +2 -2
- package/dist/modules/sales/components/documents/AdjustmentsSection.js +0 -2
- package/dist/modules/sales/components/documents/AdjustmentsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/PaymentsSection.js +1 -2
- package/dist/modules/sales/components/documents/PaymentsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/SalesDocumentsTable.js +0 -2
- package/dist/modules/sales/components/documents/SalesDocumentsTable.js.map +2 -2
- package/dist/modules/sales/events.js +63 -0
- package/dist/modules/sales/events.js.map +7 -0
- package/dist/modules/sales/lib/dictionaries.js +3 -0
- package/dist/modules/sales/lib/dictionaries.js.map +2 -2
- package/dist/modules/sales/lib/frontend/documentDataEvents.js +25 -0
- package/dist/modules/sales/lib/frontend/documentDataEvents.js.map +7 -0
- package/dist/modules/staff/backend/staff/team-members/page.js +1 -1
- package/dist/modules/staff/backend/staff/team-members/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/team-roles/page.js +2 -2
- package/dist/modules/staff/backend/staff/team-roles/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js +2 -2
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/teams/page.js +2 -2
- package/dist/modules/staff/backend/staff/teams/page.js.map +2 -2
- package/dist/modules/staff/commands/leave-requests.js +0 -79
- package/dist/modules/staff/commands/leave-requests.js.map +2 -2
- package/dist/modules/workflows/acl.js +2 -0
- package/dist/modules/workflows/acl.js.map +2 -2
- package/dist/modules/workflows/api/instances/route.js +18 -6
- package/dist/modules/workflows/api/instances/route.js.map +2 -2
- package/dist/modules/workflows/api/tasks/route.js +6 -1
- package/dist/modules/workflows/api/tasks/route.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/[id]/page.js +9 -1
- package/dist/modules/workflows/backend/definitions/[id]/page.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/[id]/page.meta.js +1 -1
- package/dist/modules/workflows/backend/definitions/[id]/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/create/page.js +24 -15
- package/dist/modules/workflows/backend/definitions/create/page.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/create/page.meta.js +1 -1
- package/dist/modules/workflows/backend/definitions/create/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/page.js +0 -5
- package/dist/modules/workflows/backend/definitions/page.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js +150 -132
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/visual-editor/page.meta.js +1 -1
- package/dist/modules/workflows/backend/definitions/visual-editor/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/events/[id]/page.js +1 -1
- package/dist/modules/workflows/backend/events/[id]/page.js.map +2 -2
- package/dist/modules/workflows/backend/events/[id]/page.meta.js +2 -2
- package/dist/modules/workflows/backend/events/[id]/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/instances/[id]/page.meta.js +2 -2
- package/dist/modules/workflows/backend/instances/[id]/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/instances/page.js +0 -3
- package/dist/modules/workflows/backend/instances/page.js.map +2 -2
- package/dist/modules/workflows/backend/tasks/[id]/page.js +1 -1
- package/dist/modules/workflows/backend/tasks/[id]/page.js.map +2 -2
- package/dist/modules/workflows/backend/tasks/[id]/page.meta.js +2 -2
- package/dist/modules/workflows/backend/tasks/[id]/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/tasks/page.js +5 -9
- package/dist/modules/workflows/backend/tasks/page.js.map +2 -2
- package/dist/modules/workflows/cli.js +93 -15
- package/dist/modules/workflows/cli.js.map +3 -3
- package/dist/modules/workflows/components/DefinitionTriggersEditor.js +481 -0
- package/dist/modules/workflows/components/DefinitionTriggersEditor.js.map +7 -0
- package/dist/modules/workflows/components/EventTriggersEditor.js +553 -0
- package/dist/modules/workflows/components/EventTriggersEditor.js.map +7 -0
- package/dist/modules/workflows/data/entities.js +64 -1
- package/dist/modules/workflows/data/entities.js.map +2 -2
- package/dist/modules/workflows/data/validators.js +115 -0
- package/dist/modules/workflows/data/validators.js.map +2 -2
- package/dist/modules/workflows/events.js +38 -0
- package/dist/modules/workflows/events.js.map +7 -0
- package/dist/modules/workflows/examples/checkout-demo-definition.json +1 -5
- package/dist/modules/workflows/examples/order-approval-definition.json +257 -0
- package/dist/modules/workflows/examples/order-approval-guard-rules.json +32 -0
- package/dist/modules/workflows/lib/activity-executor.js +75 -13
- package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
- package/dist/modules/workflows/lib/event-trigger-service.js +308 -0
- package/dist/modules/workflows/lib/event-trigger-service.js.map +7 -0
- package/dist/modules/workflows/lib/graph-utils.js +71 -2
- package/dist/modules/workflows/lib/graph-utils.js.map +2 -2
- package/dist/modules/workflows/lib/seeds.js +22 -5
- package/dist/modules/workflows/lib/seeds.js.map +2 -2
- package/dist/modules/workflows/lib/start-validator.js +33 -23
- package/dist/modules/workflows/lib/start-validator.js.map +2 -2
- package/dist/modules/workflows/lib/transition-handler.js +161 -57
- package/dist/modules/workflows/lib/transition-handler.js.map +3 -3
- package/dist/modules/workflows/migrations/Migration20260123143500.js +36 -0
- package/dist/modules/workflows/migrations/Migration20260123143500.js.map +7 -0
- package/dist/modules/workflows/subscribers/event-trigger.js +78 -0
- package/dist/modules/workflows/subscribers/event-trigger.js.map +7 -0
- package/dist/modules/workflows/widgets/injection/order-approval/widget.client.js +323 -0
- package/dist/modules/workflows/widgets/injection/order-approval/widget.client.js.map +7 -0
- package/dist/modules/workflows/widgets/injection/order-approval/widget.js +17 -0
- package/dist/modules/workflows/widgets/injection/order-approval/widget.js.map +7 -0
- package/dist/modules/workflows/widgets/injection-table.js +19 -0
- package/dist/modules/workflows/widgets/injection-table.js.map +7 -0
- package/generated/entities/workflow_event_trigger/index.ts +15 -0
- package/generated/entities.ids.generated.ts +2 -5
- package/generated/entity-fields-registry.ts +2 -2
- package/package.json +2 -2
- package/src/modules/api_docs/frontend/docs/api/page.tsx +2 -3
- package/src/modules/api_keys/backend/api-keys/page.tsx +1 -1
- package/src/modules/attachments/components/AttachmentLibrary.tsx +0 -4
- package/src/modules/attachments/components/AttachmentPartitionSettings.tsx +0 -2
- package/src/modules/auth/README.md +1 -1
- package/src/modules/auth/__tests__/cli-setup-acl.test.ts +1 -1
- package/src/modules/auth/api/__tests__/login.test.ts +0 -2
- package/src/modules/auth/api/admin/nav.ts +6 -10
- package/src/modules/auth/api/login.ts +7 -26
- package/src/modules/auth/api/reset/confirm.ts +2 -25
- package/src/modules/auth/api/reset.ts +0 -23
- package/src/modules/auth/api/sidebar/preferences/route.ts +12 -21
- package/src/modules/auth/api/users/route.ts +2 -5
- package/src/modules/auth/backend/roles/[id]/edit/page.tsx +1 -4
- package/src/modules/auth/backend/roles/page.tsx +3 -3
- package/src/modules/auth/backend/users/[id]/edit/page.tsx +3 -22
- package/src/modules/auth/backend/users/create/page.tsx +2 -19
- package/src/modules/auth/backend/users/page.tsx +3 -3
- package/src/modules/auth/cli.ts +11 -38
- package/src/modules/auth/commands/users.ts +2 -73
- package/src/modules/auth/data/validators.ts +2 -6
- package/src/modules/auth/events.ts +39 -0
- package/src/modules/auth/frontend/login.tsx +5 -131
- package/src/modules/auth/frontend/reset/[token]/page.tsx +11 -24
- package/src/modules/auth/i18n/de.json +1 -48
- package/src/modules/auth/i18n/en.json +1 -48
- package/src/modules/auth/i18n/es.json +1 -48
- package/src/modules/auth/i18n/pl.json +1 -48
- package/src/modules/auth/lib/setup-app.ts +9 -58
- package/src/modules/auth/services/authService.ts +4 -27
- package/src/modules/business_rules/api/execute/[ruleId]/route.ts +163 -0
- package/src/modules/business_rules/api/execute/route.ts +1 -8
- package/src/modules/business_rules/backend/rules/page.tsx +0 -4
- package/src/modules/business_rules/backend/sets/page.tsx +0 -3
- package/src/modules/business_rules/cli.ts +1 -2
- package/src/modules/business_rules/data/validators.ts +40 -0
- package/src/modules/business_rules/i18n/en.json +1 -3
- package/src/modules/business_rules/index.ts +25 -0
- package/src/modules/business_rules/lib/__tests__/rule-engine.test.ts +0 -51
- package/src/modules/business_rules/lib/rule-engine.ts +277 -51
- package/src/modules/catalog/components/PriceKindSettings.tsx +0 -2
- package/src/modules/catalog/components/categories/CategoriesDataTable.tsx +2 -2
- package/src/modules/catalog/components/products/ProductsDataTable.tsx +0 -2
- package/src/modules/catalog/events.ts +45 -0
- package/src/modules/catalog/i18n/en.json +1 -3
- package/src/modules/configs/cli.ts +0 -6
- package/src/modules/configs/components/CachePanel.tsx +4 -4
- package/src/modules/configs/i18n/en.json +2 -12
- package/src/modules/configs/i18n/pl.json +2 -12
- package/src/modules/configs/lib/system-status.ts +1 -48
- package/src/modules/configs/lib/system-status.types.ts +0 -1
- package/src/modules/configs/lib/upgrade-actions.ts +0 -18
- package/src/modules/currencies/backend/currencies/page.tsx +0 -3
- package/src/modules/currencies/backend/exchange-rates/page.tsx +0 -2
- package/src/modules/customers/backend/customers/companies/page.tsx +0 -3
- package/src/modules/customers/backend/customers/deals/page.tsx +0 -3
- package/src/modules/customers/backend/customers/people/page.tsx +0 -3
- package/src/modules/customers/commands/deals.ts +0 -39
- package/src/modules/customers/components/CustomerTodosTable.tsx +0 -1
- package/src/modules/customers/events.ts +63 -0
- package/src/modules/customers/i18n/en.json +1 -5
- package/src/modules/customers/widgets/dashboard/customer-todos/widget.ts +2 -2
- package/src/modules/customers/widgets/dashboard/new-customers/widget.ts +2 -2
- package/src/modules/customers/widgets/dashboard/new-deals/widget.ts +2 -2
- package/src/modules/customers/widgets/dashboard/next-interactions/widget.ts +2 -2
- package/src/modules/dashboards/cli.ts +5 -55
- package/src/modules/dashboards/components/WidgetVisibilityEditor.tsx +11 -22
- package/src/modules/dashboards/services/widgetDataService.ts +4 -164
- package/src/modules/dashboards/widgets/dashboard/aov-kpi/widget.ts +2 -2
- package/src/modules/dashboards/widgets/dashboard/new-customers-kpi/widget.ts +2 -2
- package/src/modules/dashboards/widgets/dashboard/orders-by-status/widget.ts +2 -2
- package/src/modules/dashboards/widgets/dashboard/orders-kpi/widget.ts +2 -2
- package/src/modules/dashboards/widgets/dashboard/pipeline-summary/widget.ts +2 -2
- package/src/modules/dashboards/widgets/dashboard/revenue-kpi/widget.ts +2 -2
- package/src/modules/dashboards/widgets/dashboard/revenue-trend/widget.ts +2 -2
- package/src/modules/dashboards/widgets/dashboard/sales-by-region/widget.ts +2 -2
- package/src/modules/dashboards/widgets/dashboard/top-customers/widget.ts +2 -2
- package/src/modules/dashboards/widgets/dashboard/top-products/widget.ts +2 -2
- package/src/modules/dictionaries/components/DictionaryTable.tsx +0 -2
- package/src/modules/directory/backend/directory/organizations/page.tsx +2 -2
- package/src/modules/directory/backend/directory/tenants/page.tsx +2 -2
- package/src/modules/directory/events.ts +31 -0
- package/src/modules/entities/backend/entities/user/[entityId]/records/page.tsx +2 -2
- package/src/modules/entities/components/SystemEntitiesTable.tsx +1 -1
- package/src/modules/entities/components/UserEntitiesTable.tsx +2 -2
- package/src/modules/feature_toggles/components/FeatureTogglesTable.tsx +4 -3
- package/src/modules/feature_toggles/components/OverridesTable.tsx +1 -1
- package/src/modules/planner/backend/planner/availability-rulesets/page.tsx +2 -2
- package/src/modules/query_index/cli.ts +13 -82
- package/src/modules/query_index/components/QueryIndexesTable.tsx +2 -8
- package/src/modules/resources/backend/resources/resource-types/page.tsx +2 -2
- package/src/modules/resources/backend/resources/resources/page.tsx +2 -2
- package/src/modules/sales/acl.ts +1 -0
- package/src/modules/sales/backend/sales/channels/offers/page.tsx +0 -2
- package/src/modules/sales/backend/sales/channels/page.tsx +0 -2
- package/src/modules/sales/backend/sales/documents/[id]/page.tsx +16 -0
- package/src/modules/sales/commands/documents.ts +70 -62
- package/src/modules/sales/commands/payments.ts +0 -33
- package/src/modules/sales/components/AdjustmentKindSettings.tsx +2 -2
- package/src/modules/sales/components/PaymentMethodsSettings.tsx +2 -2
- package/src/modules/sales/components/ShippingMethodsSettings.tsx +2 -2
- package/src/modules/sales/components/TaxRatesSettings.tsx +2 -2
- package/src/modules/sales/components/channels/SalesChannelOffersPanel.tsx +0 -2
- package/src/modules/sales/components/documents/AdjustmentsSection.tsx +0 -2
- package/src/modules/sales/components/documents/PaymentsSection.tsx +1 -2
- package/src/modules/sales/components/documents/SalesDocumentsTable.tsx +0 -2
- package/src/modules/sales/events.ts +82 -0
- package/src/modules/sales/i18n/de.json +0 -20
- package/src/modules/sales/i18n/en.json +1 -25
- package/src/modules/sales/i18n/es.json +0 -20
- package/src/modules/sales/i18n/pl.json +0 -20
- package/src/modules/sales/lib/dictionaries.ts +3 -0
- package/src/modules/sales/lib/frontend/documentDataEvents.ts +28 -0
- package/src/modules/staff/backend/staff/team-members/page.tsx +1 -1
- package/src/modules/staff/backend/staff/team-roles/page.tsx +2 -2
- package/src/modules/staff/backend/staff/teams/[id]/edit/page.tsx +2 -2
- package/src/modules/staff/backend/staff/teams/page.tsx +2 -2
- package/src/modules/staff/commands/leave-requests.ts +0 -94
- package/src/modules/staff/i18n/de.json +0 -4
- package/src/modules/staff/i18n/en.json +1 -9
- package/src/modules/staff/i18n/es.json +0 -4
- package/src/modules/staff/i18n/pl.json +0 -4
- package/src/modules/workflows/acl.ts +2 -0
- package/src/modules/workflows/api/__tests__/instances.route.test.ts +5 -2
- package/src/modules/workflows/api/instances/route.ts +21 -7
- package/src/modules/workflows/api/tasks/route.ts +7 -1
- package/src/modules/workflows/backend/definitions/[id]/page.meta.ts +1 -1
- package/src/modules/workflows/backend/definitions/[id]/page.tsx +9 -0
- package/src/modules/workflows/backend/definitions/create/page.meta.ts +1 -1
- package/src/modules/workflows/backend/definitions/create/page.tsx +9 -0
- package/src/modules/workflows/backend/definitions/page.tsx +0 -5
- package/src/modules/workflows/backend/definitions/visual-editor/page.meta.ts +1 -1
- package/src/modules/workflows/backend/definitions/visual-editor/page.tsx +21 -3
- package/src/modules/workflows/backend/events/[id]/page.meta.ts +2 -2
- package/src/modules/workflows/backend/events/[id]/page.tsx +1 -1
- package/src/modules/workflows/backend/instances/[id]/page.meta.ts +2 -2
- package/src/modules/workflows/backend/instances/page.tsx +1 -4
- package/src/modules/workflows/backend/tasks/[id]/page.meta.ts +2 -2
- package/src/modules/workflows/backend/tasks/[id]/page.tsx +1 -1
- package/src/modules/workflows/backend/tasks/page.tsx +6 -10
- package/src/modules/workflows/cli.ts +123 -12
- package/src/modules/workflows/components/DefinitionTriggersEditor.tsx +581 -0
- package/src/modules/workflows/components/EventTriggersEditor.tsx +664 -0
- package/src/modules/workflows/data/entities.ts +124 -0
- package/src/modules/workflows/data/validators.ts +138 -0
- package/src/modules/workflows/events.ts +49 -0
- package/src/modules/workflows/examples/checkout-demo-definition.json +1 -5
- package/src/modules/workflows/examples/order-approval-definition.json +257 -0
- package/src/modules/workflows/examples/order-approval-guard-rules.json +32 -0
- package/src/modules/workflows/i18n/en.json +72 -3
- package/src/modules/workflows/lib/__tests__/activity-executor.test.ts +43 -36
- package/src/modules/workflows/lib/__tests__/transition-handler.test.ts +170 -90
- package/src/modules/workflows/lib/activity-executor.ts +129 -16
- package/src/modules/workflows/lib/event-trigger-service.ts +557 -0
- package/src/modules/workflows/lib/graph-utils.ts +117 -2
- package/src/modules/workflows/lib/seeds.ts +34 -8
- package/src/modules/workflows/lib/start-validator.ts +38 -28
- package/src/modules/workflows/lib/transition-handler.ts +212 -71
- package/src/modules/workflows/migrations/Migration20260123143500.ts +38 -0
- package/src/modules/workflows/subscribers/event-trigger.ts +109 -0
- package/src/modules/workflows/widgets/injection/order-approval/widget.client.tsx +446 -0
- package/src/modules/workflows/widgets/injection/order-approval/widget.ts +16 -0
- package/src/modules/workflows/widgets/injection-table.ts +21 -0
- package/dist/generated/entities/notification/index.js +0 -57
- package/dist/generated/entities/notification/index.js.map +0 -7
- package/dist/modules/auth/api/profile/route.js +0 -157
- package/dist/modules/auth/api/profile/route.js.map +0 -7
- package/dist/modules/auth/backend/auth/profile/page.js +0 -141
- package/dist/modules/auth/backend/auth/profile/page.js.map +0 -7
- package/dist/modules/auth/backend/auth/profile/page.meta.js +0 -13
- package/dist/modules/auth/backend/auth/profile/page.meta.js.map +0 -7
- package/dist/modules/auth/notifications.js +0 -112
- package/dist/modules/auth/notifications.js.map +0 -7
- package/dist/modules/business_rules/notifications.js +0 -28
- package/dist/modules/business_rules/notifications.js.map +0 -7
- package/dist/modules/business_rules/subscribers/rule-execution-failed-notification.js +0 -37
- package/dist/modules/business_rules/subscribers/rule-execution-failed-notification.js.map +0 -7
- package/dist/modules/catalog/notifications.js +0 -28
- package/dist/modules/catalog/notifications.js.map +0 -7
- package/dist/modules/catalog/subscribers/low-stock-notification.js +0 -38
- package/dist/modules/catalog/subscribers/low-stock-notification.js.map +0 -7
- package/dist/modules/customers/notifications.js +0 -48
- package/dist/modules/customers/notifications.js.map +0 -7
- package/dist/modules/dashboards/lib/role-widgets.js +0 -58
- package/dist/modules/dashboards/lib/role-widgets.js.map +0 -7
- package/dist/modules/directory/api/get/tenants/lookup.js +0 -70
- package/dist/modules/directory/api/get/tenants/lookup.js.map +0 -7
- package/dist/modules/notifications/acl.js +0 -11
- package/dist/modules/notifications/acl.js.map +0 -7
- package/dist/modules/notifications/api/[id]/action/route.js +0 -74
- package/dist/modules/notifications/api/[id]/action/route.js.map +0 -7
- package/dist/modules/notifications/api/[id]/dismiss/route.js +0 -15
- package/dist/modules/notifications/api/[id]/dismiss/route.js.map +0 -7
- package/dist/modules/notifications/api/[id]/read/route.js +0 -15
- package/dist/modules/notifications/api/[id]/read/route.js.map +0 -7
- package/dist/modules/notifications/api/[id]/restore/route.js +0 -53
- package/dist/modules/notifications/api/[id]/restore/route.js.map +0 -7
- package/dist/modules/notifications/api/batch/route.js +0 -17
- package/dist/modules/notifications/api/batch/route.js.map +0 -7
- package/dist/modules/notifications/api/feature/route.js +0 -17
- package/dist/modules/notifications/api/feature/route.js.map +0 -7
- package/dist/modules/notifications/api/mark-all-read/route.js +0 -35
- package/dist/modules/notifications/api/mark-all-read/route.js.map +0 -7
- package/dist/modules/notifications/api/openapi.js +0 -76
- package/dist/modules/notifications/api/openapi.js.map +0 -7
- package/dist/modules/notifications/api/role/route.js +0 -17
- package/dist/modules/notifications/api/role/route.js.map +0 -7
- package/dist/modules/notifications/api/route.js +0 -85
- package/dist/modules/notifications/api/route.js.map +0 -7
- package/dist/modules/notifications/api/settings/route.js +0 -155
- package/dist/modules/notifications/api/settings/route.js.map +0 -7
- package/dist/modules/notifications/api/unread-count/route.js +0 -38
- package/dist/modules/notifications/api/unread-count/route.js.map +0 -7
- package/dist/modules/notifications/backend/config/notifications/page.js +0 -10
- package/dist/modules/notifications/backend/config/notifications/page.js.map +0 -7
- package/dist/modules/notifications/backend/config/notifications/page.meta.js +0 -24
- package/dist/modules/notifications/backend/config/notifications/page.meta.js.map +0 -7
- package/dist/modules/notifications/cli.js +0 -16
- package/dist/modules/notifications/cli.js.map +0 -7
- package/dist/modules/notifications/data/entities.js +0 -112
- package/dist/modules/notifications/data/entities.js.map +0 -7
- package/dist/modules/notifications/data/validators.js +0 -98
- package/dist/modules/notifications/data/validators.js.map +0 -7
- package/dist/modules/notifications/di.js +0 -13
- package/dist/modules/notifications/di.js.map +0 -7
- package/dist/modules/notifications/emails/NotificationEmail.js +0 -58
- package/dist/modules/notifications/emails/NotificationEmail.js.map +0 -7
- package/dist/modules/notifications/frontend/NotificationInboxPageClient.js +0 -44
- package/dist/modules/notifications/frontend/NotificationInboxPageClient.js.map +0 -7
- package/dist/modules/notifications/frontend/NotificationSettingsPageClient.js +0 -220
- package/dist/modules/notifications/frontend/NotificationSettingsPageClient.js.map +0 -7
- package/dist/modules/notifications/index.js +0 -14
- package/dist/modules/notifications/index.js.map +0 -7
- package/dist/modules/notifications/lib/deliveryConfig.js +0 -107
- package/dist/modules/notifications/lib/deliveryConfig.js.map +0 -7
- package/dist/modules/notifications/lib/deliveryStrategies.js +0 -14
- package/dist/modules/notifications/lib/deliveryStrategies.js.map +0 -7
- package/dist/modules/notifications/lib/events.js +0 -12
- package/dist/modules/notifications/lib/events.js.map +0 -7
- package/dist/modules/notifications/lib/notificationBuilder.js +0 -66
- package/dist/modules/notifications/lib/notificationBuilder.js.map +0 -7
- package/dist/modules/notifications/lib/notificationFactory.js +0 -54
- package/dist/modules/notifications/lib/notificationFactory.js.map +0 -7
- package/dist/modules/notifications/lib/notificationMapper.js +0 -34
- package/dist/modules/notifications/lib/notificationMapper.js.map +0 -7
- package/dist/modules/notifications/lib/notificationRecipients.js +0 -35
- package/dist/modules/notifications/lib/notificationRecipients.js.map +0 -7
- package/dist/modules/notifications/lib/notificationService.js +0 -279
- package/dist/modules/notifications/lib/notificationService.js.map +0 -7
- package/dist/modules/notifications/lib/routeHelpers.js +0 -101
- package/dist/modules/notifications/lib/routeHelpers.js.map +0 -7
- package/dist/modules/notifications/lib/safeHref.js +0 -24
- package/dist/modules/notifications/lib/safeHref.js.map +0 -7
- package/dist/modules/notifications/migrations/Migration20260123000001.js +0 -70
- package/dist/modules/notifications/migrations/Migration20260123000001.js.map +0 -7
- package/dist/modules/notifications/migrations/Migration20260126150000.js +0 -37
- package/dist/modules/notifications/migrations/Migration20260126150000.js.map +0 -7
- package/dist/modules/notifications/migrations/Migration20260129082610.js +0 -13
- package/dist/modules/notifications/migrations/Migration20260129082610.js.map +0 -7
- package/dist/modules/notifications/subscribers/deliver-notification.js +0 -165
- package/dist/modules/notifications/subscribers/deliver-notification.js.map +0 -7
- package/dist/modules/notifications/workers/create-notification.worker.js +0 -70
- package/dist/modules/notifications/workers/create-notification.worker.js.map +0 -7
- package/dist/modules/sales/notifications.client.js +0 -51
- package/dist/modules/sales/notifications.client.js.map +0 -7
- package/dist/modules/sales/notifications.js +0 -88
- package/dist/modules/sales/notifications.js.map +0 -7
- package/dist/modules/sales/subscribers/quote-expiring-notification.js +0 -38
- package/dist/modules/sales/subscribers/quote-expiring-notification.js.map +0 -7
- package/dist/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.js +0 -137
- package/dist/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.js.map +0 -7
- package/dist/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.js +0 -137
- package/dist/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.js.map +0 -7
- package/dist/modules/sales/widgets/notifications/index.js +0 -7
- package/dist/modules/sales/widgets/notifications/index.js.map +0 -7
- package/dist/modules/sales/widgets/notifications/useSalesDocumentTotals.js +0 -60
- package/dist/modules/sales/widgets/notifications/useSalesDocumentTotals.js.map +0 -7
- package/dist/modules/staff/notifications.js +0 -75
- package/dist/modules/staff/notifications.js.map +0 -7
- package/dist/modules/workflows/notifications.js +0 -28
- package/dist/modules/workflows/notifications.js.map +0 -7
- package/dist/modules/workflows/subscribers/task-assigned-notification.js +0 -38
- package/dist/modules/workflows/subscribers/task-assigned-notification.js.map +0 -7
- package/generated/entities/notification/index.ts +0 -27
- package/src/modules/auth/api/profile/route.ts +0 -163
- package/src/modules/auth/backend/auth/profile/page.meta.ts +0 -9
- package/src/modules/auth/backend/auth/profile/page.tsx +0 -174
- package/src/modules/auth/notifications.ts +0 -109
- package/src/modules/business_rules/notifications.ts +0 -25
- package/src/modules/business_rules/subscribers/rule-execution-failed-notification.ts +0 -50
- package/src/modules/catalog/notifications.ts +0 -25
- package/src/modules/catalog/subscribers/low-stock-notification.ts +0 -52
- package/src/modules/customers/notifications.ts +0 -44
- package/src/modules/dashboards/lib/role-widgets.ts +0 -80
- package/src/modules/directory/api/get/tenants/lookup.ts +0 -75
- package/src/modules/notifications/__tests__/deliver-notification.test.ts +0 -195
- package/src/modules/notifications/__tests__/deliveryStrategies.test.ts +0 -19
- package/src/modules/notifications/__tests__/notificationService.test.ts +0 -208
- package/src/modules/notifications/acl.ts +0 -7
- package/src/modules/notifications/api/[id]/action/route.ts +0 -75
- package/src/modules/notifications/api/[id]/dismiss/route.ts +0 -12
- package/src/modules/notifications/api/[id]/read/route.ts +0 -12
- package/src/modules/notifications/api/[id]/restore/route.ts +0 -53
- package/src/modules/notifications/api/batch/route.ts +0 -14
- package/src/modules/notifications/api/feature/route.ts +0 -14
- package/src/modules/notifications/api/mark-all-read/route.ts +0 -34
- package/src/modules/notifications/api/openapi.ts +0 -76
- package/src/modules/notifications/api/role/route.ts +0 -14
- package/src/modules/notifications/api/route.ts +0 -92
- package/src/modules/notifications/api/settings/route.ts +0 -157
- package/src/modules/notifications/api/unread-count/route.ts +0 -38
- package/src/modules/notifications/backend/config/notifications/page.meta.ts +0 -22
- package/src/modules/notifications/backend/config/notifications/page.tsx +0 -12
- package/src/modules/notifications/cli.ts +0 -18
- package/src/modules/notifications/data/entities.ts +0 -99
- package/src/modules/notifications/data/validators.ts +0 -115
- package/src/modules/notifications/di.ts +0 -11
- package/src/modules/notifications/emails/NotificationEmail.tsx +0 -98
- package/src/modules/notifications/frontend/NotificationInboxPageClient.tsx +0 -42
- package/src/modules/notifications/frontend/NotificationSettingsPageClient.tsx +0 -233
- package/src/modules/notifications/i18n/de.json +0 -50
- package/src/modules/notifications/i18n/en.json +0 -50
- package/src/modules/notifications/i18n/es.json +0 -50
- package/src/modules/notifications/i18n/pl.json +0 -50
- package/src/modules/notifications/index.ts +0 -12
- package/src/modules/notifications/lib/deliveryConfig.ts +0 -153
- package/src/modules/notifications/lib/deliveryStrategies.ts +0 -50
- package/src/modules/notifications/lib/events.ts +0 -48
- package/src/modules/notifications/lib/notificationBuilder.ts +0 -121
- package/src/modules/notifications/lib/notificationFactory.ts +0 -76
- package/src/modules/notifications/lib/notificationMapper.ts +0 -33
- package/src/modules/notifications/lib/notificationRecipients.ts +0 -83
- package/src/modules/notifications/lib/notificationService.ts +0 -414
- package/src/modules/notifications/lib/routeHelpers.ts +0 -151
- package/src/modules/notifications/lib/safeHref.ts +0 -29
- package/src/modules/notifications/migrations/.snapshot-open-mercato.json +0 -336
- package/src/modules/notifications/migrations/Migration20260123000001.ts +0 -73
- package/src/modules/notifications/migrations/Migration20260126150000.ts +0 -39
- package/src/modules/notifications/migrations/Migration20260129082610.ts +0 -13
- package/src/modules/notifications/subscribers/deliver-notification.ts +0 -204
- package/src/modules/notifications/workers/create-notification.worker.ts +0 -122
- package/src/modules/sales/notifications.client.ts +0 -65
- package/src/modules/sales/notifications.ts +0 -82
- package/src/modules/sales/subscribers/quote-expiring-notification.ts +0 -53
- package/src/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.tsx +0 -156
- package/src/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.tsx +0 -156
- package/src/modules/sales/widgets/notifications/index.ts +0 -2
- package/src/modules/sales/widgets/notifications/useSalesDocumentTotals.ts +0 -81
- package/src/modules/staff/notifications.ts +0 -71
- package/src/modules/workflows/notifications.ts +0 -25
- package/src/modules/workflows/subscribers/task-assigned-notification.ts +0 -53
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { parseBooleanWithDefault } from "@open-mercato/shared/lib/boolean";
|
|
2
|
-
import { notificationDeliveryConfigSchema } from "../data/validators.js";
|
|
3
|
-
const NOTIFICATIONS_DELIVERY_CONFIG_KEY = "delivery_strategies";
|
|
4
|
-
const envString = (value) => {
|
|
5
|
-
if (!value) return void 0;
|
|
6
|
-
const trimmed = value.trim();
|
|
7
|
-
return trimmed.length ? trimmed : void 0;
|
|
8
|
-
};
|
|
9
|
-
const resolveEnvDefaults = () => {
|
|
10
|
-
const appUrl = envString(
|
|
11
|
-
process.env.NOTIFICATIONS_APP_URL || process.env.APPLICATION_URL || process.env.NEXT_PUBLIC_APP_URL || process.env.APP_URL
|
|
12
|
-
);
|
|
13
|
-
const panelPath = envString(process.env.NOTIFICATIONS_PANEL_PATH);
|
|
14
|
-
const emailEnabled = parseBooleanWithDefault(process.env.NOTIFICATIONS_EMAIL_ENABLED, true);
|
|
15
|
-
const emailFrom = envString(process.env.NOTIFICATIONS_EMAIL_FROM || process.env.EMAIL_FROM);
|
|
16
|
-
const emailReplyTo = envString(process.env.NOTIFICATIONS_EMAIL_REPLY_TO || process.env.ADMIN_EMAIL);
|
|
17
|
-
const emailSubjectPrefix = envString(process.env.NOTIFICATIONS_EMAIL_SUBJECT_PREFIX);
|
|
18
|
-
return {
|
|
19
|
-
appUrl,
|
|
20
|
-
panelPath,
|
|
21
|
-
emailEnabled,
|
|
22
|
-
emailFrom,
|
|
23
|
-
emailReplyTo,
|
|
24
|
-
emailSubjectPrefix
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
const DEFAULT_NOTIFICATION_DELIVERY_CONFIG = (() => {
|
|
28
|
-
const env = resolveEnvDefaults();
|
|
29
|
-
return {
|
|
30
|
-
appUrl: env.appUrl,
|
|
31
|
-
panelPath: env.panelPath ?? "/backend/notifications",
|
|
32
|
-
strategies: {
|
|
33
|
-
database: { enabled: true },
|
|
34
|
-
email: {
|
|
35
|
-
enabled: env.emailEnabled,
|
|
36
|
-
from: env.emailFrom,
|
|
37
|
-
replyTo: env.emailReplyTo,
|
|
38
|
-
subjectPrefix: env.emailSubjectPrefix
|
|
39
|
-
},
|
|
40
|
-
custom: {}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
})();
|
|
44
|
-
const normalizeDeliveryConfig = (input) => {
|
|
45
|
-
const parsed = notificationDeliveryConfigSchema.safeParse(input ?? {});
|
|
46
|
-
if (!parsed.success) {
|
|
47
|
-
return { ...DEFAULT_NOTIFICATION_DELIVERY_CONFIG };
|
|
48
|
-
}
|
|
49
|
-
const value = parsed.data ?? {};
|
|
50
|
-
const strategies = value.strategies ?? {};
|
|
51
|
-
return {
|
|
52
|
-
appUrl: value.appUrl,
|
|
53
|
-
panelPath: value.panelPath ?? DEFAULT_NOTIFICATION_DELIVERY_CONFIG.panelPath,
|
|
54
|
-
strategies: {
|
|
55
|
-
database: {
|
|
56
|
-
enabled: DEFAULT_NOTIFICATION_DELIVERY_CONFIG.strategies.database.enabled
|
|
57
|
-
},
|
|
58
|
-
email: {
|
|
59
|
-
enabled: strategies.email?.enabled ?? DEFAULT_NOTIFICATION_DELIVERY_CONFIG.strategies.email.enabled,
|
|
60
|
-
from: strategies.email?.from,
|
|
61
|
-
replyTo: strategies.email?.replyTo,
|
|
62
|
-
subjectPrefix: strategies.email?.subjectPrefix
|
|
63
|
-
},
|
|
64
|
-
custom: strategies.custom ?? {}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
async function resolveNotificationDeliveryConfig(resolver, options) {
|
|
69
|
-
const fallback = options?.defaultValue ?? DEFAULT_NOTIFICATION_DELIVERY_CONFIG;
|
|
70
|
-
let service;
|
|
71
|
-
try {
|
|
72
|
-
service = resolver.resolve("moduleConfigService");
|
|
73
|
-
} catch {
|
|
74
|
-
return { ...fallback };
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
const value = await service.getValue("notifications", NOTIFICATIONS_DELIVERY_CONFIG_KEY, { defaultValue: fallback });
|
|
78
|
-
return normalizeDeliveryConfig(value);
|
|
79
|
-
} catch {
|
|
80
|
-
return { ...fallback };
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
async function saveNotificationDeliveryConfig(resolver, config) {
|
|
84
|
-
let service;
|
|
85
|
-
try {
|
|
86
|
-
service = resolver.resolve("moduleConfigService");
|
|
87
|
-
} catch {
|
|
88
|
-
throw new Error("Configuration service unavailable");
|
|
89
|
-
}
|
|
90
|
-
const normalized = normalizeDeliveryConfig(config);
|
|
91
|
-
await service.setValue("notifications", NOTIFICATIONS_DELIVERY_CONFIG_KEY, normalized);
|
|
92
|
-
}
|
|
93
|
-
function resolveNotificationPanelUrl(config) {
|
|
94
|
-
const base = config.appUrl || process.env.APPLICATION_URL || process.env.NEXT_PUBLIC_APP_URL || process.env.APP_URL;
|
|
95
|
-
if (!base || !base.trim()) {
|
|
96
|
-
return config.panelPath;
|
|
97
|
-
}
|
|
98
|
-
return `${base.replace(/\/$/, "")}${config.panelPath}`;
|
|
99
|
-
}
|
|
100
|
-
export {
|
|
101
|
-
DEFAULT_NOTIFICATION_DELIVERY_CONFIG,
|
|
102
|
-
NOTIFICATIONS_DELIVERY_CONFIG_KEY,
|
|
103
|
-
resolveNotificationDeliveryConfig,
|
|
104
|
-
resolveNotificationPanelUrl,
|
|
105
|
-
saveNotificationDeliveryConfig
|
|
106
|
-
};
|
|
107
|
-
//# sourceMappingURL=deliveryConfig.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/modules/notifications/lib/deliveryConfig.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ModuleConfigService } from '@open-mercato/core/modules/configs/lib/module-config-service'\nimport { parseBooleanWithDefault } from '@open-mercato/shared/lib/boolean'\nimport { notificationDeliveryConfigSchema, type NotificationDeliveryConfigInput } from '../data/validators'\n\nexport const NOTIFICATIONS_DELIVERY_CONFIG_KEY = 'delivery_strategies'\n\nexport type NotificationDeliveryStrategyState = {\n enabled: boolean\n}\n\nexport type NotificationCustomDeliveryConfig = {\n enabled?: boolean\n config?: unknown\n}\n\nexport type NotificationEmailDeliveryConfig = NotificationDeliveryStrategyState & {\n from?: string\n replyTo?: string\n subjectPrefix?: string\n}\n\nexport type NotificationDeliveryConfig = {\n appUrl?: string\n panelPath: string\n strategies: {\n database: NotificationDeliveryStrategyState\n email: NotificationEmailDeliveryConfig\n custom?: Record<string, NotificationCustomDeliveryConfig>\n }\n}\n\nconst envString = (value: string | undefined | null) => {\n if (!value) return undefined\n const trimmed = value.trim()\n return trimmed.length ? trimmed : undefined\n}\n\nconst resolveEnvDefaults = () => {\n const appUrl = envString(\n process.env.NOTIFICATIONS_APP_URL ||\n process.env.APPLICATION_URL ||\n process.env.NEXT_PUBLIC_APP_URL ||\n process.env.APP_URL\n )\n const panelPath = envString(process.env.NOTIFICATIONS_PANEL_PATH)\n const emailEnabled = parseBooleanWithDefault(process.env.NOTIFICATIONS_EMAIL_ENABLED, true)\n const emailFrom = envString(process.env.NOTIFICATIONS_EMAIL_FROM || process.env.EMAIL_FROM)\n const emailReplyTo = envString(process.env.NOTIFICATIONS_EMAIL_REPLY_TO || process.env.ADMIN_EMAIL)\n const emailSubjectPrefix = envString(process.env.NOTIFICATIONS_EMAIL_SUBJECT_PREFIX)\n\n return {\n appUrl,\n panelPath,\n emailEnabled,\n emailFrom,\n emailReplyTo,\n emailSubjectPrefix,\n }\n}\n\nexport const DEFAULT_NOTIFICATION_DELIVERY_CONFIG: NotificationDeliveryConfig = (() => {\n const env = resolveEnvDefaults()\n return {\n appUrl: env.appUrl,\n panelPath: env.panelPath ?? '/backend/notifications',\n strategies: {\n database: { enabled: true },\n email: {\n enabled: env.emailEnabled,\n from: env.emailFrom,\n replyTo: env.emailReplyTo,\n subjectPrefix: env.emailSubjectPrefix,\n },\n custom: {},\n },\n }\n})()\n\nconst normalizeDeliveryConfig = (input?: unknown | null): NotificationDeliveryConfig => {\n const parsed = notificationDeliveryConfigSchema.safeParse(input ?? {})\n if (!parsed.success) {\n return { ...DEFAULT_NOTIFICATION_DELIVERY_CONFIG }\n }\n\n const value = parsed.data ?? {}\n const strategies = value.strategies ?? {}\n\n return {\n appUrl: value.appUrl,\n panelPath: value.panelPath ?? DEFAULT_NOTIFICATION_DELIVERY_CONFIG.panelPath,\n strategies: {\n database: {\n enabled: DEFAULT_NOTIFICATION_DELIVERY_CONFIG.strategies.database.enabled,\n },\n email: {\n enabled: strategies.email?.enabled ?? DEFAULT_NOTIFICATION_DELIVERY_CONFIG.strategies.email.enabled,\n from: strategies.email?.from,\n replyTo: strategies.email?.replyTo,\n subjectPrefix: strategies.email?.subjectPrefix,\n },\n custom: strategies.custom ?? {},\n },\n }\n}\n\ntype Resolver = {\n resolve: <T = unknown>(name: string) => T\n}\n\nexport async function resolveNotificationDeliveryConfig(\n resolver: Resolver,\n options?: { defaultValue?: NotificationDeliveryConfig }\n): Promise<NotificationDeliveryConfig> {\n const fallback = options?.defaultValue ?? DEFAULT_NOTIFICATION_DELIVERY_CONFIG\n let service: ModuleConfigService\n try {\n service = resolver.resolve<ModuleConfigService>('moduleConfigService')\n } catch {\n return { ...fallback }\n }\n try {\n const value = await service.getValue('notifications', NOTIFICATIONS_DELIVERY_CONFIG_KEY, { defaultValue: fallback })\n return normalizeDeliveryConfig(value)\n } catch {\n return { ...fallback }\n }\n}\n\nexport async function saveNotificationDeliveryConfig(\n resolver: Resolver,\n config: NotificationDeliveryConfigInput\n): Promise<void> {\n let service: ModuleConfigService\n try {\n service = resolver.resolve<ModuleConfigService>('moduleConfigService')\n } catch {\n throw new Error('Configuration service unavailable')\n }\n\n const normalized = normalizeDeliveryConfig(config)\n await service.setValue('notifications', NOTIFICATIONS_DELIVERY_CONFIG_KEY, normalized)\n}\n\nexport function resolveNotificationPanelUrl(config: NotificationDeliveryConfig): string | null {\n const base = config.appUrl\n || process.env.APPLICATION_URL\n || process.env.NEXT_PUBLIC_APP_URL\n || process.env.APP_URL\n if (!base || !base.trim()) {\n return config.panelPath\n }\n return `${base.replace(/\\/$/, '')}${config.panelPath}`\n}\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,+BAA+B;AACxC,SAAS,wCAA8E;AAEhF,MAAM,oCAAoC;AA2BjD,MAAM,YAAY,CAAC,UAAqC;AACtD,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,UAAU,MAAM,KAAK;AAC3B,SAAO,QAAQ,SAAS,UAAU;AACpC;AAEA,MAAM,qBAAqB,MAAM;AAC/B,QAAM,SAAS;AAAA,IACb,QAAQ,IAAI,yBACZ,QAAQ,IAAI,mBACZ,QAAQ,IAAI,uBACZ,QAAQ,IAAI;AAAA,EACd;AACA,QAAM,YAAY,UAAU,QAAQ,IAAI,wBAAwB;AAChE,QAAM,eAAe,wBAAwB,QAAQ,IAAI,6BAA6B,IAAI;AAC1F,QAAM,YAAY,UAAU,QAAQ,IAAI,4BAA4B,QAAQ,IAAI,UAAU;AAC1F,QAAM,eAAe,UAAU,QAAQ,IAAI,gCAAgC,QAAQ,IAAI,WAAW;AAClG,QAAM,qBAAqB,UAAU,QAAQ,IAAI,kCAAkC;AAEnF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,wCAAoE,MAAM;AACrF,QAAM,MAAM,mBAAmB;AAC/B,SAAO;AAAA,IACL,QAAQ,IAAI;AAAA,IACZ,WAAW,IAAI,aAAa;AAAA,IAC5B,YAAY;AAAA,MACV,UAAU,EAAE,SAAS,KAAK;AAAA,MAC1B,OAAO;AAAA,QACL,SAAS,IAAI;AAAA,QACb,MAAM,IAAI;AAAA,QACV,SAAS,IAAI;AAAA,QACb,eAAe,IAAI;AAAA,MACrB;AAAA,MACA,QAAQ,CAAC;AAAA,IACX;AAAA,EACF;AACF,GAAG;AAEH,MAAM,0BAA0B,CAAC,UAAuD;AACtF,QAAM,SAAS,iCAAiC,UAAU,SAAS,CAAC,CAAC;AACrE,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,EAAE,GAAG,qCAAqC;AAAA,EACnD;AAEA,QAAM,QAAQ,OAAO,QAAQ,CAAC;AAC9B,QAAM,aAAa,MAAM,cAAc,CAAC;AAExC,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,WAAW,MAAM,aAAa,qCAAqC;AAAA,IACnE,YAAY;AAAA,MACV,UAAU;AAAA,QACR,SAAS,qCAAqC,WAAW,SAAS;AAAA,MACpE;AAAA,MACA,OAAO;AAAA,QACL,SAAS,WAAW,OAAO,WAAW,qCAAqC,WAAW,MAAM;AAAA,QAC5F,MAAM,WAAW,OAAO;AAAA,QACxB,SAAS,WAAW,OAAO;AAAA,QAC3B,eAAe,WAAW,OAAO;AAAA,MACnC;AAAA,MACA,QAAQ,WAAW,UAAU,CAAC;AAAA,IAChC;AAAA,EACF;AACF;AAMA,eAAsB,kCACpB,UACA,SACqC;AACrC,QAAM,WAAW,SAAS,gBAAgB;AAC1C,MAAI;AACJ,MAAI;AACF,cAAU,SAAS,QAA6B,qBAAqB;AAAA,EACvE,QAAQ;AACN,WAAO,EAAE,GAAG,SAAS;AAAA,EACvB;AACA,MAAI;AACF,UAAM,QAAQ,MAAM,QAAQ,SAAS,iBAAiB,mCAAmC,EAAE,cAAc,SAAS,CAAC;AACnH,WAAO,wBAAwB,KAAK;AAAA,EACtC,QAAQ;AACN,WAAO,EAAE,GAAG,SAAS;AAAA,EACvB;AACF;AAEA,eAAsB,+BACpB,UACA,QACe;AACf,MAAI;AACJ,MAAI;AACF,cAAU,SAAS,QAA6B,qBAAqB;AAAA,EACvE,QAAQ;AACN,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,QAAM,aAAa,wBAAwB,MAAM;AACjD,QAAM,QAAQ,SAAS,iBAAiB,mCAAmC,UAAU;AACvF;AAEO,SAAS,4BAA4B,QAAmD;AAC7F,QAAM,OAAO,OAAO,UACf,QAAQ,IAAI,mBACZ,QAAQ,IAAI,uBACZ,QAAQ,IAAI;AACjB,MAAI,CAAC,QAAQ,CAAC,KAAK,KAAK,GAAG;AACzB,WAAO,OAAO;AAAA,EAChB;AACA,SAAO,GAAG,KAAK,QAAQ,OAAO,EAAE,CAAC,GAAG,OAAO,SAAS;AACtD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const registry = [];
|
|
2
|
-
function registerNotificationDeliveryStrategy(strategy, options) {
|
|
3
|
-
const priority = options?.priority ?? 0;
|
|
4
|
-
registry.push({ ...strategy, priority });
|
|
5
|
-
registry.sort((a, b) => b.priority - a.priority);
|
|
6
|
-
}
|
|
7
|
-
function getNotificationDeliveryStrategies() {
|
|
8
|
-
return registry;
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
getNotificationDeliveryStrategies,
|
|
12
|
-
registerNotificationDeliveryStrategy
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=deliveryStrategies.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/modules/notifications/lib/deliveryStrategies.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Notification } from '../data/entities'\nimport type { NotificationDeliveryConfig } from './deliveryConfig'\n\nexport type NotificationDeliveryStrategyConfig = {\n enabled?: boolean\n config?: unknown\n}\n\nexport type NotificationDeliveryRecipient = {\n email?: string | null\n name?: string | null\n}\n\nexport type NotificationDeliveryContext = {\n notification: Notification\n recipient: NotificationDeliveryRecipient\n title: string\n body: string | null\n panelUrl: string | null\n panelLink: string | null\n actionLinks: Array<{ id: string; label: string; href: string }>\n deliveryConfig: NotificationDeliveryConfig\n config: NotificationDeliveryStrategyConfig\n resolve: <T = unknown>(name: string) => T\n t: (key: string, fallback?: string, variables?: Record<string, string>) => string\n}\n\nexport type NotificationDeliveryStrategy = {\n id: string\n label?: string\n defaultEnabled?: boolean\n deliver: (ctx: NotificationDeliveryContext) => Promise<void> | void\n}\n\ntype RegisteredStrategy = NotificationDeliveryStrategy & { priority: number }\n\nconst registry: RegisteredStrategy[] = []\n\nexport function registerNotificationDeliveryStrategy(\n strategy: NotificationDeliveryStrategy,\n options?: { priority?: number }\n): void {\n const priority = options?.priority ?? 0\n registry.push({ ...strategy, priority })\n registry.sort((a, b) => b.priority - a.priority)\n}\n\nexport function getNotificationDeliveryStrategies(): NotificationDeliveryStrategy[] {\n return registry\n}\n"],
|
|
5
|
-
"mappings": "AAoCA,MAAM,WAAiC,CAAC;AAEjC,SAAS,qCACd,UACA,SACM;AACN,QAAM,WAAW,SAAS,YAAY;AACtC,WAAS,KAAK,EAAE,GAAG,UAAU,SAAS,CAAC;AACvC,WAAS,KAAK,CAAC,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;AACjD;AAEO,SAAS,oCAAoE;AAClF,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const NOTIFICATION_EVENTS = {
|
|
2
|
-
CREATED: "notifications.created",
|
|
3
|
-
READ: "notifications.read",
|
|
4
|
-
ACTIONED: "notifications.actioned",
|
|
5
|
-
DISMISSED: "notifications.dismissed",
|
|
6
|
-
RESTORED: "notifications.restored",
|
|
7
|
-
EXPIRED: "notifications.expired"
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
NOTIFICATION_EVENTS
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=events.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/modules/notifications/lib/events.ts"],
|
|
4
|
-
"sourcesContent": ["export const NOTIFICATION_EVENTS = {\n CREATED: 'notifications.created',\n READ: 'notifications.read',\n ACTIONED: 'notifications.actioned',\n DISMISSED: 'notifications.dismissed',\n RESTORED: 'notifications.restored',\n EXPIRED: 'notifications.expired',\n} as const\n\nexport type NotificationCreatedPayload = {\n notificationId: string\n recipientUserId: string\n type: string\n title: string\n tenantId: string\n organizationId?: string | null\n}\n\nexport type NotificationReadPayload = {\n notificationId: string\n userId: string\n tenantId: string\n}\n\nexport type NotificationActionedPayload = {\n notificationId: string\n actionId: string\n userId: string\n tenantId: string\n}\n\nexport type NotificationDismissedPayload = {\n notificationId: string\n userId: string\n tenantId: string\n}\n\nexport type NotificationRestoredPayload = {\n notificationId: string\n userId: string\n tenantId: string\n status: 'read' | 'unread'\n}\n\nexport type NotificationExpiredPayload = {\n notificationIds: string[]\n tenantId: string\n}\n"],
|
|
5
|
-
"mappings": "AAAO,MAAM,sBAAsB;AAAA,EACjC,SAAS;AAAA,EACT,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU;AAAA,EACV,SAAS;AACX;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
function mapActions(actions) {
|
|
2
|
-
if (!actions || actions.length === 0) return void 0;
|
|
3
|
-
return actions.map((action) => ({
|
|
4
|
-
id: action.id,
|
|
5
|
-
label: action.labelKey,
|
|
6
|
-
labelKey: action.labelKey,
|
|
7
|
-
variant: action.variant,
|
|
8
|
-
icon: action.icon,
|
|
9
|
-
commandId: action.commandId,
|
|
10
|
-
href: action.href,
|
|
11
|
-
confirmRequired: action.confirmRequired,
|
|
12
|
-
confirmMessage: action.confirmMessageKey
|
|
13
|
-
}));
|
|
14
|
-
}
|
|
15
|
-
function buildBaseNotificationFields(typeDef, options) {
|
|
16
|
-
return {
|
|
17
|
-
type: typeDef.type,
|
|
18
|
-
titleKey: typeDef.titleKey,
|
|
19
|
-
bodyKey: typeDef.bodyKey,
|
|
20
|
-
titleVariables: options.titleVariables,
|
|
21
|
-
bodyVariables: options.bodyVariables,
|
|
22
|
-
title: typeDef.titleKey,
|
|
23
|
-
body: typeDef.bodyKey,
|
|
24
|
-
icon: typeDef.icon,
|
|
25
|
-
severity: typeDef.severity,
|
|
26
|
-
actions: mapActions(typeDef.actions),
|
|
27
|
-
primaryActionId: typeDef.primaryActionId,
|
|
28
|
-
sourceModule: typeDef.module,
|
|
29
|
-
sourceEntityType: options.sourceEntityType,
|
|
30
|
-
sourceEntityId: options.sourceEntityId,
|
|
31
|
-
linkHref: options.linkHref ?? typeDef.linkHref,
|
|
32
|
-
groupKey: options.groupKey,
|
|
33
|
-
expiresAt: options.expiresAt ?? (typeDef.expiresAfterHours ? new Date(Date.now() + typeDef.expiresAfterHours * 60 * 60 * 1e3).toISOString() : void 0)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function buildNotificationFromType(typeDef, options) {
|
|
37
|
-
return {
|
|
38
|
-
recipientUserId: options.recipientUserId,
|
|
39
|
-
...buildBaseNotificationFields(typeDef, options)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function buildBatchNotificationFromType(typeDef, options) {
|
|
43
|
-
return {
|
|
44
|
-
recipientUserIds: options.recipientUserIds,
|
|
45
|
-
...buildBaseNotificationFields(typeDef, options)
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function buildRoleNotificationFromType(typeDef, options) {
|
|
49
|
-
return {
|
|
50
|
-
roleId: options.roleId,
|
|
51
|
-
...buildBaseNotificationFields(typeDef, options)
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function buildFeatureNotificationFromType(typeDef, options) {
|
|
55
|
-
return {
|
|
56
|
-
requiredFeature: options.requiredFeature,
|
|
57
|
-
...buildBaseNotificationFields(typeDef, options)
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
export {
|
|
61
|
-
buildBatchNotificationFromType,
|
|
62
|
-
buildFeatureNotificationFromType,
|
|
63
|
-
buildNotificationFromType,
|
|
64
|
-
buildRoleNotificationFromType
|
|
65
|
-
};
|
|
66
|
-
//# sourceMappingURL=notificationBuilder.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/modules/notifications/lib/notificationBuilder.ts"],
|
|
4
|
-
"sourcesContent": ["import type { NotificationTypeDefinition, NotificationTypeAction } from '@open-mercato/shared/modules/notifications/types'\nimport type { CreateNotificationInput, CreateBatchNotificationInput, CreateRoleNotificationInput, CreateFeatureNotificationInput } from '../data/validators'\n\n/**\n * Transform type definition actions to API input actions.\n * Type definitions use labelKey (i18n-first), while API input uses label with optional labelKey.\n */\nfunction mapActions(actions: NotificationTypeAction[] | undefined) {\n if (!actions || actions.length === 0) return undefined\n return actions.map((action) => ({\n id: action.id,\n label: action.labelKey,\n labelKey: action.labelKey,\n variant: action.variant,\n icon: action.icon,\n commandId: action.commandId,\n href: action.href,\n confirmRequired: action.confirmRequired,\n confirmMessage: action.confirmMessageKey,\n }))\n}\n\n/**\n * Common options for building notifications from type definitions\n */\ninterface CommonBuildOptions {\n titleVariables?: Record<string, string>\n bodyVariables?: Record<string, string>\n sourceEntityType?: string\n sourceEntityId?: string\n linkHref?: string\n groupKey?: string\n expiresAt?: string\n}\n\n/**\n * Build base notification fields from a type definition.\n * Shared logic used by all notification builder functions.\n */\nfunction buildBaseNotificationFields(\n typeDef: NotificationTypeDefinition,\n options: CommonBuildOptions\n) {\n return {\n type: typeDef.type,\n titleKey: typeDef.titleKey,\n bodyKey: typeDef.bodyKey,\n titleVariables: options.titleVariables,\n bodyVariables: options.bodyVariables,\n title: typeDef.titleKey,\n body: typeDef.bodyKey,\n icon: typeDef.icon,\n severity: typeDef.severity,\n actions: mapActions(typeDef.actions),\n primaryActionId: typeDef.primaryActionId,\n sourceModule: typeDef.module,\n sourceEntityType: options.sourceEntityType,\n sourceEntityId: options.sourceEntityId,\n linkHref: options.linkHref ?? typeDef.linkHref,\n groupKey: options.groupKey,\n expiresAt: options.expiresAt ?? (\n typeDef.expiresAfterHours\n ? new Date(Date.now() + typeDef.expiresAfterHours * 60 * 60 * 1000).toISOString()\n : undefined\n ),\n }\n}\n\n/**\n * Build a notification input from a type definition with i18n support.\n * This is the recommended way to create notifications - use type definitions from notifications.ts\n * to ensure i18n-first approach.\n */\nexport function buildNotificationFromType(\n typeDef: NotificationTypeDefinition,\n options: CommonBuildOptions & { recipientUserId: string }\n): CreateNotificationInput {\n return {\n recipientUserId: options.recipientUserId,\n ...buildBaseNotificationFields(typeDef, options),\n }\n}\n\n/**\n * Build a batch notification input from a type definition\n */\nexport function buildBatchNotificationFromType(\n typeDef: NotificationTypeDefinition,\n options: CommonBuildOptions & { recipientUserIds: string[] }\n): CreateBatchNotificationInput {\n return {\n recipientUserIds: options.recipientUserIds,\n ...buildBaseNotificationFields(typeDef, options),\n }\n}\n\n/**\n * Build a role notification input from a type definition\n */\nexport function buildRoleNotificationFromType(\n typeDef: NotificationTypeDefinition,\n options: CommonBuildOptions & { roleId: string }\n): CreateRoleNotificationInput {\n return {\n roleId: options.roleId,\n ...buildBaseNotificationFields(typeDef, options),\n }\n}\n\n/**\n * Build a feature-based notification input from a type definition\n */\nexport function buildFeatureNotificationFromType(\n typeDef: NotificationTypeDefinition,\n options: CommonBuildOptions & { requiredFeature: string }\n): CreateFeatureNotificationInput {\n return {\n requiredFeature: options.requiredFeature,\n ...buildBaseNotificationFields(typeDef, options),\n }\n}\n"],
|
|
5
|
-
"mappings": "AAOA,SAAS,WAAW,SAA+C;AACjE,MAAI,CAAC,WAAW,QAAQ,WAAW,EAAG,QAAO;AAC7C,SAAO,QAAQ,IAAI,CAAC,YAAY;AAAA,IAC9B,IAAI,OAAO;AAAA,IACX,OAAO,OAAO;AAAA,IACd,UAAU,OAAO;AAAA,IACjB,SAAS,OAAO;AAAA,IAChB,MAAM,OAAO;AAAA,IACb,WAAW,OAAO;AAAA,IAClB,MAAM,OAAO;AAAA,IACb,iBAAiB,OAAO;AAAA,IACxB,gBAAgB,OAAO;AAAA,EACzB,EAAE;AACJ;AAmBA,SAAS,4BACP,SACA,SACA;AACA,SAAO;AAAA,IACL,MAAM,QAAQ;AAAA,IACd,UAAU,QAAQ;AAAA,IAClB,SAAS,QAAQ;AAAA,IACjB,gBAAgB,QAAQ;AAAA,IACxB,eAAe,QAAQ;AAAA,IACvB,OAAO,QAAQ;AAAA,IACf,MAAM,QAAQ;AAAA,IACd,MAAM,QAAQ;AAAA,IACd,UAAU,QAAQ;AAAA,IAClB,SAAS,WAAW,QAAQ,OAAO;AAAA,IACnC,iBAAiB,QAAQ;AAAA,IACzB,cAAc,QAAQ;AAAA,IACtB,kBAAkB,QAAQ;AAAA,IAC1B,gBAAgB,QAAQ;AAAA,IACxB,UAAU,QAAQ,YAAY,QAAQ;AAAA,IACtC,UAAU,QAAQ;AAAA,IAClB,WAAW,QAAQ,cACjB,QAAQ,oBACJ,IAAI,KAAK,KAAK,IAAI,IAAI,QAAQ,oBAAoB,KAAK,KAAK,GAAI,EAAE,YAAY,IAC9E;AAAA,EAER;AACF;AAOO,SAAS,0BACd,SACA,SACyB;AACzB,SAAO;AAAA,IACL,iBAAiB,QAAQ;AAAA,IACzB,GAAG,4BAA4B,SAAS,OAAO;AAAA,EACjD;AACF;AAKO,SAAS,+BACd,SACA,SAC8B;AAC9B,SAAO;AAAA,IACL,kBAAkB,QAAQ;AAAA,IAC1B,GAAG,4BAA4B,SAAS,OAAO;AAAA,EACjD;AACF;AAKO,SAAS,8BACd,SACA,SAC6B;AAC7B,SAAO;AAAA,IACL,QAAQ,QAAQ;AAAA,IAChB,GAAG,4BAA4B,SAAS,OAAO;AAAA,EACjD;AACF;AAKO,SAAS,iCACd,SACA,SACgC;AAChC,SAAO;AAAA,IACL,iBAAiB,QAAQ;AAAA,IACzB,GAAG,4BAA4B,SAAS,OAAO;AAAA,EACjD;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Notification } from "../data/entities.js";
|
|
2
|
-
import { NOTIFICATION_EVENTS } from "./events.js";
|
|
3
|
-
import { assertSafeNotificationHref, sanitizeNotificationActions } from "./safeHref.js";
|
|
4
|
-
function buildNotificationEntity(em, input, recipientUserId, ctx) {
|
|
5
|
-
const actions = sanitizeNotificationActions(input.actions);
|
|
6
|
-
const linkHref = assertSafeNotificationHref(input.linkHref);
|
|
7
|
-
return em.create(Notification, {
|
|
8
|
-
recipientUserId,
|
|
9
|
-
type: input.type,
|
|
10
|
-
// i18n-first: store keys and variables for translation at display time
|
|
11
|
-
titleKey: input.titleKey,
|
|
12
|
-
bodyKey: input.bodyKey,
|
|
13
|
-
titleVariables: input.titleVariables,
|
|
14
|
-
bodyVariables: input.bodyVariables,
|
|
15
|
-
// Fallback text (required for backward compatibility)
|
|
16
|
-
title: input.title || input.titleKey || "",
|
|
17
|
-
body: input.body,
|
|
18
|
-
icon: input.icon,
|
|
19
|
-
severity: input.severity ?? "info",
|
|
20
|
-
actionData: actions ? {
|
|
21
|
-
actions,
|
|
22
|
-
primaryActionId: input.primaryActionId
|
|
23
|
-
} : null,
|
|
24
|
-
sourceModule: input.sourceModule,
|
|
25
|
-
sourceEntityType: input.sourceEntityType,
|
|
26
|
-
sourceEntityId: input.sourceEntityId,
|
|
27
|
-
linkHref,
|
|
28
|
-
groupKey: input.groupKey,
|
|
29
|
-
expiresAt: input.expiresAt ? new Date(input.expiresAt) : null,
|
|
30
|
-
tenantId: ctx.tenantId,
|
|
31
|
-
organizationId: ctx.organizationId
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
async function emitNotificationCreated(eventBus, notification, ctx) {
|
|
35
|
-
await eventBus.emit(NOTIFICATION_EVENTS.CREATED, {
|
|
36
|
-
notificationId: notification.id,
|
|
37
|
-
recipientUserId: notification.recipientUserId,
|
|
38
|
-
type: notification.type,
|
|
39
|
-
title: notification.title,
|
|
40
|
-
tenantId: ctx.tenantId,
|
|
41
|
-
organizationId: ctx.organizationId
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
async function emitNotificationCreatedBatch(eventBus, notifications, ctx) {
|
|
45
|
-
for (const notification of notifications) {
|
|
46
|
-
await emitNotificationCreated(eventBus, notification, ctx);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
export {
|
|
50
|
-
buildNotificationEntity,
|
|
51
|
-
emitNotificationCreated,
|
|
52
|
-
emitNotificationCreatedBatch
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=notificationFactory.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/modules/notifications/lib/notificationFactory.ts"],
|
|
4
|
-
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/core'\nimport { Notification } from '../data/entities'\nimport type { CreateNotificationInput } from '../data/validators'\nimport { NOTIFICATION_EVENTS } from './events'\nimport { assertSafeNotificationHref, sanitizeNotificationActions } from './safeHref'\n\nexport type NotificationContentInput = Omit<CreateNotificationInput, 'recipientUserId'>\n\nexport type NotificationTenantContext = {\n tenantId: string\n organizationId?: string | null\n}\n\nexport function buildNotificationEntity(\n em: EntityManager,\n input: NotificationContentInput,\n recipientUserId: string,\n ctx: NotificationTenantContext\n): Notification {\n const actions = sanitizeNotificationActions(input.actions)\n const linkHref = assertSafeNotificationHref(input.linkHref)\n\n return em.create(Notification, {\n recipientUserId,\n type: input.type,\n // i18n-first: store keys and variables for translation at display time\n titleKey: input.titleKey,\n bodyKey: input.bodyKey,\n titleVariables: input.titleVariables,\n bodyVariables: input.bodyVariables,\n // Fallback text (required for backward compatibility)\n title: input.title || input.titleKey || '',\n body: input.body,\n icon: input.icon,\n severity: input.severity ?? 'info',\n actionData: actions\n ? {\n actions,\n primaryActionId: input.primaryActionId,\n }\n : null,\n sourceModule: input.sourceModule,\n sourceEntityType: input.sourceEntityType,\n sourceEntityId: input.sourceEntityId,\n linkHref,\n groupKey: input.groupKey,\n expiresAt: input.expiresAt ? new Date(input.expiresAt) : null,\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n })\n}\n\nexport async function emitNotificationCreated(\n eventBus: { emit: (event: string, payload: unknown) => Promise<void> },\n notification: Notification,\n ctx: NotificationTenantContext\n): Promise<void> {\n await eventBus.emit(NOTIFICATION_EVENTS.CREATED, {\n notificationId: notification.id,\n recipientUserId: notification.recipientUserId,\n type: notification.type,\n title: notification.title,\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n })\n}\n\nexport async function emitNotificationCreatedBatch(\n eventBus: { emit: (event: string, payload: unknown) => Promise<void> },\n notifications: Notification[],\n ctx: NotificationTenantContext\n): Promise<void> {\n for (const notification of notifications) {\n await emitNotificationCreated(eventBus, notification, ctx)\n }\n}\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,oBAAoB;AAE7B,SAAS,2BAA2B;AACpC,SAAS,4BAA4B,mCAAmC;AASjE,SAAS,wBACd,IACA,OACA,iBACA,KACc;AACd,QAAM,UAAU,4BAA4B,MAAM,OAAO;AACzD,QAAM,WAAW,2BAA2B,MAAM,QAAQ;AAE1D,SAAO,GAAG,OAAO,cAAc;AAAA,IAC7B;AAAA,IACA,MAAM,MAAM;AAAA;AAAA,IAEZ,UAAU,MAAM;AAAA,IAChB,SAAS,MAAM;AAAA,IACf,gBAAgB,MAAM;AAAA,IACtB,eAAe,MAAM;AAAA;AAAA,IAErB,OAAO,MAAM,SAAS,MAAM,YAAY;AAAA,IACxC,MAAM,MAAM;AAAA,IACZ,MAAM,MAAM;AAAA,IACZ,UAAU,MAAM,YAAY;AAAA,IAC5B,YAAY,UACR;AAAA,MACE;AAAA,MACA,iBAAiB,MAAM;AAAA,IACzB,IACA;AAAA,IACJ,cAAc,MAAM;AAAA,IACpB,kBAAkB,MAAM;AAAA,IACxB,gBAAgB,MAAM;AAAA,IACtB;AAAA,IACA,UAAU,MAAM;AAAA,IAChB,WAAW,MAAM,YAAY,IAAI,KAAK,MAAM,SAAS,IAAI;AAAA,IACzD,UAAU,IAAI;AAAA,IACd,gBAAgB,IAAI;AAAA,EACtB,CAAC;AACH;AAEA,eAAsB,wBACpB,UACA,cACA,KACe;AACf,QAAM,SAAS,KAAK,oBAAoB,SAAS;AAAA,IAC/C,gBAAgB,aAAa;AAAA,IAC7B,iBAAiB,aAAa;AAAA,IAC9B,MAAM,aAAa;AAAA,IACnB,OAAO,aAAa;AAAA,IACpB,UAAU,IAAI;AAAA,IACd,gBAAgB,IAAI;AAAA,EACtB,CAAC;AACH;AAEA,eAAsB,6BACpB,UACA,eACA,KACe;AACf,aAAW,gBAAgB,eAAe;AACxC,UAAM,wBAAwB,UAAU,cAAc,GAAG;AAAA,EAC3D;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
function toNotificationDto(notification) {
|
|
2
|
-
return {
|
|
3
|
-
id: notification.id,
|
|
4
|
-
type: notification.type,
|
|
5
|
-
title: notification.title,
|
|
6
|
-
body: notification.body,
|
|
7
|
-
titleKey: notification.titleKey,
|
|
8
|
-
bodyKey: notification.bodyKey,
|
|
9
|
-
titleVariables: notification.titleVariables,
|
|
10
|
-
bodyVariables: notification.bodyVariables,
|
|
11
|
-
icon: notification.icon,
|
|
12
|
-
severity: notification.severity,
|
|
13
|
-
status: notification.status,
|
|
14
|
-
actions: notification.actionData?.actions?.map((action) => ({
|
|
15
|
-
id: action.id,
|
|
16
|
-
label: action.label,
|
|
17
|
-
labelKey: action.labelKey,
|
|
18
|
-
variant: action.variant,
|
|
19
|
-
icon: action.icon
|
|
20
|
-
})) ?? [],
|
|
21
|
-
primaryActionId: notification.actionData?.primaryActionId,
|
|
22
|
-
sourceModule: notification.sourceModule,
|
|
23
|
-
sourceEntityType: notification.sourceEntityType,
|
|
24
|
-
sourceEntityId: notification.sourceEntityId,
|
|
25
|
-
linkHref: notification.linkHref,
|
|
26
|
-
createdAt: notification.createdAt.toISOString(),
|
|
27
|
-
readAt: notification.readAt?.toISOString() ?? null,
|
|
28
|
-
actionTaken: notification.actionTaken
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
toNotificationDto
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=notificationMapper.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/modules/notifications/lib/notificationMapper.ts"],
|
|
4
|
-
"sourcesContent": ["import type { NotificationDto } from '@open-mercato/shared/modules/notifications/types'\nimport { Notification } from '../data/entities'\n\nexport function toNotificationDto(notification: Notification): NotificationDto {\n return {\n id: notification.id,\n type: notification.type,\n title: notification.title,\n body: notification.body,\n titleKey: notification.titleKey,\n bodyKey: notification.bodyKey,\n titleVariables: notification.titleVariables,\n bodyVariables: notification.bodyVariables,\n icon: notification.icon,\n severity: notification.severity,\n status: notification.status,\n actions: notification.actionData?.actions?.map((action) => ({\n id: action.id,\n label: action.label,\n labelKey: action.labelKey,\n variant: action.variant,\n icon: action.icon,\n })) ?? [],\n primaryActionId: notification.actionData?.primaryActionId,\n sourceModule: notification.sourceModule,\n sourceEntityType: notification.sourceEntityType,\n sourceEntityId: notification.sourceEntityId,\n linkHref: notification.linkHref,\n createdAt: notification.createdAt.toISOString(),\n readAt: notification.readAt?.toISOString() ?? null,\n actionTaken: notification.actionTaken,\n }\n}\n"],
|
|
5
|
-
"mappings": "AAGO,SAAS,kBAAkB,cAA6C;AAC7E,SAAO;AAAA,IACL,IAAI,aAAa;AAAA,IACjB,MAAM,aAAa;AAAA,IACnB,OAAO,aAAa;AAAA,IACpB,MAAM,aAAa;AAAA,IACnB,UAAU,aAAa;AAAA,IACvB,SAAS,aAAa;AAAA,IACtB,gBAAgB,aAAa;AAAA,IAC7B,eAAe,aAAa;AAAA,IAC5B,MAAM,aAAa;AAAA,IACnB,UAAU,aAAa;AAAA,IACvB,QAAQ,aAAa;AAAA,IACrB,SAAS,aAAa,YAAY,SAAS,IAAI,CAAC,YAAY;AAAA,MAC1D,IAAI,OAAO;AAAA,MACX,OAAO,OAAO;AAAA,MACd,UAAU,OAAO;AAAA,MACjB,SAAS,OAAO;AAAA,MAChB,MAAM,OAAO;AAAA,IACf,EAAE,KAAK,CAAC;AAAA,IACR,iBAAiB,aAAa,YAAY;AAAA,IAC1C,cAAc,aAAa;AAAA,IAC3B,kBAAkB,aAAa;AAAA,IAC/B,gBAAgB,aAAa;AAAA,IAC7B,UAAU,aAAa;AAAA,IACvB,WAAW,aAAa,UAAU,YAAY;AAAA,IAC9C,QAAQ,aAAa,QAAQ,YAAY,KAAK;AAAA,IAC9C,aAAa,aAAa;AAAA,EAC5B;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { hasFeature } from "@open-mercato/shared/security/features";
|
|
2
|
-
function normalizeFeatures(features) {
|
|
3
|
-
if (!Array.isArray(features)) return void 0;
|
|
4
|
-
const normalized = features.filter((feature) => typeof feature === "string");
|
|
5
|
-
return normalized.length ? normalized : void 0;
|
|
6
|
-
}
|
|
7
|
-
function collectUsersWithFeature(userIdsSet, rows, requiredFeature) {
|
|
8
|
-
for (const row of rows) {
|
|
9
|
-
if (row.is_super_admin) {
|
|
10
|
-
userIdsSet.add(row.user_id);
|
|
11
|
-
continue;
|
|
12
|
-
}
|
|
13
|
-
const features = normalizeFeatures(row.features_json);
|
|
14
|
-
if (features && hasFeature(features, requiredFeature)) {
|
|
15
|
-
userIdsSet.add(row.user_id);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
async function getRecipientUserIdsForRole(knex, tenantId, roleId) {
|
|
20
|
-
const userRoles = await knex("user_roles").join("users", "user_roles.user_id", "users.id").where("user_roles.role_id", roleId).whereNull("user_roles.deleted_at").whereNull("users.deleted_at").where("users.tenant_id", tenantId).select("users.id as user_id");
|
|
21
|
-
return userRoles.map((row) => row.user_id);
|
|
22
|
-
}
|
|
23
|
-
async function getRecipientUserIdsForFeature(knex, tenantId, requiredFeature) {
|
|
24
|
-
const userIdsSet = /* @__PURE__ */ new Set();
|
|
25
|
-
const userAcls = await knex("user_acls").join("users", "user_acls.user_id", "users.id").where("user_acls.tenant_id", tenantId).whereNull("user_acls.deleted_at").whereNull("users.deleted_at").where("users.tenant_id", tenantId).select("users.id as user_id", "user_acls.features_json", "user_acls.is_super_admin");
|
|
26
|
-
collectUsersWithFeature(userIdsSet, userAcls, requiredFeature);
|
|
27
|
-
const roleAcls = await knex("role_acls").join("user_roles", "role_acls.role_id", "user_roles.role_id").join("users", "user_roles.user_id", "users.id").where("role_acls.tenant_id", tenantId).whereNull("role_acls.deleted_at").whereNull("user_roles.deleted_at").whereNull("users.deleted_at").where("users.tenant_id", tenantId).select("users.id as user_id", "role_acls.features_json", "role_acls.is_super_admin");
|
|
28
|
-
collectUsersWithFeature(userIdsSet, roleAcls, requiredFeature);
|
|
29
|
-
return Array.from(userIdsSet);
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
getRecipientUserIdsForFeature,
|
|
33
|
-
getRecipientUserIdsForRole
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=notificationRecipients.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/modules/notifications/lib/notificationRecipients.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Knex } from 'knex'\nimport { hasFeature } from '@open-mercato/shared/security/features'\n\ninterface AclRow {\n user_id: string\n features_json: unknown\n is_super_admin: boolean\n}\n\nfunction normalizeFeatures(features: unknown): string[] | undefined {\n if (!Array.isArray(features)) return undefined\n const normalized = features.filter((feature): feature is string => typeof feature === 'string')\n return normalized.length ? normalized : undefined\n}\n\n/**\n * Extract user IDs from ACL rows that have the required feature or are super admins.\n */\nfunction collectUsersWithFeature(\n userIdsSet: Set<string>,\n rows: AclRow[],\n requiredFeature: string\n): void {\n for (const row of rows) {\n if (row.is_super_admin) {\n userIdsSet.add(row.user_id)\n continue\n }\n\n const features = normalizeFeatures(row.features_json)\n if (features && hasFeature(features, requiredFeature)) {\n userIdsSet.add(row.user_id)\n }\n }\n}\n\nexport async function getRecipientUserIdsForRole(\n knex: Knex,\n tenantId: string,\n roleId: string\n): Promise<string[]> {\n const userRoles = await knex('user_roles')\n .join('users', 'user_roles.user_id', 'users.id')\n .where('user_roles.role_id', roleId)\n .whereNull('user_roles.deleted_at')\n .whereNull('users.deleted_at')\n .where('users.tenant_id', tenantId)\n .select('users.id as user_id')\n\n return userRoles.map((row: { user_id: string }) => row.user_id)\n}\n\nexport async function getRecipientUserIdsForFeature(\n knex: Knex,\n tenantId: string,\n requiredFeature: string\n): Promise<string[]> {\n const userIdsSet = new Set<string>()\n\n const userAcls = await knex('user_acls')\n .join('users', 'user_acls.user_id', 'users.id')\n .where('user_acls.tenant_id', tenantId)\n .whereNull('user_acls.deleted_at')\n .whereNull('users.deleted_at')\n .where('users.tenant_id', tenantId)\n .select('users.id as user_id', 'user_acls.features_json', 'user_acls.is_super_admin')\n\n collectUsersWithFeature(userIdsSet, userAcls, requiredFeature)\n\n const roleAcls = await knex('role_acls')\n .join('user_roles', 'role_acls.role_id', 'user_roles.role_id')\n .join('users', 'user_roles.user_id', 'users.id')\n .where('role_acls.tenant_id', tenantId)\n .whereNull('role_acls.deleted_at')\n .whereNull('user_roles.deleted_at')\n .whereNull('users.deleted_at')\n .where('users.tenant_id', tenantId)\n .select('users.id as user_id', 'role_acls.features_json', 'role_acls.is_super_admin')\n\n collectUsersWithFeature(userIdsSet, roleAcls, requiredFeature)\n\n return Array.from(userIdsSet)\n}\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,kBAAkB;AAQ3B,SAAS,kBAAkB,UAAyC;AAClE,MAAI,CAAC,MAAM,QAAQ,QAAQ,EAAG,QAAO;AACrC,QAAM,aAAa,SAAS,OAAO,CAAC,YAA+B,OAAO,YAAY,QAAQ;AAC9F,SAAO,WAAW,SAAS,aAAa;AAC1C;AAKA,SAAS,wBACP,YACA,MACA,iBACM;AACN,aAAW,OAAO,MAAM;AACtB,QAAI,IAAI,gBAAgB;AACtB,iBAAW,IAAI,IAAI,OAAO;AAC1B;AAAA,IACF;AAEA,UAAM,WAAW,kBAAkB,IAAI,aAAa;AACpD,QAAI,YAAY,WAAW,UAAU,eAAe,GAAG;AACrD,iBAAW,IAAI,IAAI,OAAO;AAAA,IAC5B;AAAA,EACF;AACF;AAEA,eAAsB,2BACpB,MACA,UACA,QACmB;AACnB,QAAM,YAAY,MAAM,KAAK,YAAY,EACtC,KAAK,SAAS,sBAAsB,UAAU,EAC9C,MAAM,sBAAsB,MAAM,EAClC,UAAU,uBAAuB,EACjC,UAAU,kBAAkB,EAC5B,MAAM,mBAAmB,QAAQ,EACjC,OAAO,qBAAqB;AAE/B,SAAO,UAAU,IAAI,CAAC,QAA6B,IAAI,OAAO;AAChE;AAEA,eAAsB,8BACpB,MACA,UACA,iBACmB;AACnB,QAAM,aAAa,oBAAI,IAAY;AAEnC,QAAM,WAAW,MAAM,KAAK,WAAW,EACpC,KAAK,SAAS,qBAAqB,UAAU,EAC7C,MAAM,uBAAuB,QAAQ,EACrC,UAAU,sBAAsB,EAChC,UAAU,kBAAkB,EAC5B,MAAM,mBAAmB,QAAQ,EACjC,OAAO,uBAAuB,2BAA2B,0BAA0B;AAEtF,0BAAwB,YAAY,UAAU,eAAe;AAE7D,QAAM,WAAW,MAAM,KAAK,WAAW,EACpC,KAAK,cAAc,qBAAqB,oBAAoB,EAC5D,KAAK,SAAS,sBAAsB,UAAU,EAC9C,MAAM,uBAAuB,QAAQ,EACrC,UAAU,sBAAsB,EAChC,UAAU,uBAAuB,EACjC,UAAU,kBAAkB,EAC5B,MAAM,mBAAmB,QAAQ,EACjC,OAAO,uBAAuB,2BAA2B,0BAA0B;AAEtF,0BAAwB,YAAY,UAAU,eAAe;AAE7D,SAAO,MAAM,KAAK,UAAU;AAC9B;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|