@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
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
5
|
+
import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
|
|
6
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
7
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
8
|
+
import { Spinner } from "@open-mercato/ui/primitives/spinner";
|
|
9
|
+
import { Textarea } from "@open-mercato/ui/primitives/textarea";
|
|
10
|
+
import { Badge } from "@open-mercato/ui/primitives/badge";
|
|
11
|
+
import { emitSalesDocumentDataRefresh } from "@open-mercato/core/modules/sales/lib/frontend/documentDataEvents";
|
|
12
|
+
const WORKFLOW_ID = "sales_order_approval_v1";
|
|
13
|
+
function OrderApprovalWidget({ data }) {
|
|
14
|
+
const t = useT();
|
|
15
|
+
const queryClient = useQueryClient();
|
|
16
|
+
const orderId = data?.id;
|
|
17
|
+
const [decision, setDecision] = React.useState("");
|
|
18
|
+
const [comments, setComments] = React.useState("");
|
|
19
|
+
const [error, setError] = React.useState(null);
|
|
20
|
+
const [isWaitingForProcessing, setIsWaitingForProcessing] = React.useState(false);
|
|
21
|
+
const { data: orderData } = useQuery({
|
|
22
|
+
queryKey: ["order-status", orderId],
|
|
23
|
+
queryFn: async () => {
|
|
24
|
+
if (!orderId) return null;
|
|
25
|
+
const result = await apiCall(
|
|
26
|
+
`/api/sales/orders?id=${orderId}&pageSize=1`
|
|
27
|
+
);
|
|
28
|
+
return result.ok && result.result?.items?.[0] ? result.result.items[0] : null;
|
|
29
|
+
},
|
|
30
|
+
enabled: Boolean(orderId),
|
|
31
|
+
staleTime: 5e3,
|
|
32
|
+
// Poll when waiting for processing to detect status change
|
|
33
|
+
refetchInterval: isWaitingForProcessing ? 2e3 : false
|
|
34
|
+
});
|
|
35
|
+
const currentOrderStatus = orderData?.status || data?.status;
|
|
36
|
+
const { data: instancesData, isLoading: instancesLoading } = useQuery({
|
|
37
|
+
queryKey: ["workflow-instances", orderId],
|
|
38
|
+
queryFn: async () => {
|
|
39
|
+
if (!orderId) return { data: [] };
|
|
40
|
+
const result = await apiCall(
|
|
41
|
+
`/api/workflows/instances?entityId=${orderId}&status=RUNNING,PAUSED,WAITING_FOR_ACTIVITIES`
|
|
42
|
+
);
|
|
43
|
+
return result.ok ? result.result : { data: [] };
|
|
44
|
+
},
|
|
45
|
+
enabled: Boolean(orderId),
|
|
46
|
+
staleTime: 5e3,
|
|
47
|
+
// Poll every 2 seconds when waiting for processing
|
|
48
|
+
refetchInterval: isWaitingForProcessing ? 2e3 : false
|
|
49
|
+
});
|
|
50
|
+
const activeInstance = instancesData?.data?.find(
|
|
51
|
+
(inst) => inst.workflowId === WORKFLOW_ID && !["COMPLETED", "FAILED", "CANCELLED"].includes(inst.status)
|
|
52
|
+
);
|
|
53
|
+
const { data: tasksData, isLoading: tasksLoading } = useQuery({
|
|
54
|
+
queryKey: ["workflow-tasks", activeInstance?.id],
|
|
55
|
+
queryFn: async () => {
|
|
56
|
+
if (!activeInstance?.id) return { data: [] };
|
|
57
|
+
const result = await apiCall(
|
|
58
|
+
`/api/workflows/tasks?workflowInstanceId=${activeInstance.id}&status=PENDING,IN_PROGRESS`
|
|
59
|
+
);
|
|
60
|
+
return result.ok ? result.result : { data: [] };
|
|
61
|
+
},
|
|
62
|
+
enabled: Boolean(activeInstance?.id),
|
|
63
|
+
staleTime: 5e3,
|
|
64
|
+
// Poll every 2 seconds when waiting for processing
|
|
65
|
+
refetchInterval: isWaitingForProcessing ? 2e3 : false
|
|
66
|
+
});
|
|
67
|
+
const pendingTask = tasksData?.data?.[0];
|
|
68
|
+
const isProcessing = activeInstance && !pendingTask && !["COMPLETED", "FAILED", "CANCELLED"].includes(activeInstance.status);
|
|
69
|
+
const prevStatusRef = React.useRef(data?.status);
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
if (isProcessing) {
|
|
72
|
+
setIsWaitingForProcessing(true);
|
|
73
|
+
} else if (!activeInstance || activeInstance.status === "COMPLETED") {
|
|
74
|
+
setIsWaitingForProcessing(false);
|
|
75
|
+
}
|
|
76
|
+
}, [isProcessing, activeInstance]);
|
|
77
|
+
React.useEffect(() => {
|
|
78
|
+
const newStatus = orderData?.status;
|
|
79
|
+
const oldStatus = prevStatusRef.current;
|
|
80
|
+
if (newStatus && oldStatus && newStatus !== oldStatus) {
|
|
81
|
+
if (orderId) {
|
|
82
|
+
emitSalesDocumentDataRefresh({ documentId: orderId, kind: "order" });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
prevStatusRef.current = newStatus || oldStatus;
|
|
86
|
+
}, [orderData?.status, orderId]);
|
|
87
|
+
const { data: dictionariesData } = useQuery({
|
|
88
|
+
queryKey: ["dictionaries"],
|
|
89
|
+
queryFn: async () => {
|
|
90
|
+
const result = await apiCall(
|
|
91
|
+
"/api/dictionaries"
|
|
92
|
+
);
|
|
93
|
+
return result.ok ? result.result : { items: [] };
|
|
94
|
+
},
|
|
95
|
+
staleTime: 6e4
|
|
96
|
+
});
|
|
97
|
+
const orderStatusDictionaryId = React.useMemo(() => {
|
|
98
|
+
const dict = dictionariesData?.items?.find((d) => d.key === "sales.order_status");
|
|
99
|
+
return dict?.id;
|
|
100
|
+
}, [dictionariesData]);
|
|
101
|
+
const { data: statusEntriesData } = useQuery({
|
|
102
|
+
queryKey: ["dictionary-entries", orderStatusDictionaryId],
|
|
103
|
+
queryFn: async () => {
|
|
104
|
+
if (!orderStatusDictionaryId) return { items: [] };
|
|
105
|
+
const result = await apiCall(
|
|
106
|
+
`/api/dictionaries/${orderStatusDictionaryId}/entries`
|
|
107
|
+
);
|
|
108
|
+
return result.ok ? result.result : { items: [] };
|
|
109
|
+
},
|
|
110
|
+
enabled: Boolean(orderStatusDictionaryId),
|
|
111
|
+
staleTime: 6e4
|
|
112
|
+
});
|
|
113
|
+
const findStatusId = React.useCallback((code) => {
|
|
114
|
+
const entries = statusEntriesData?.items || [];
|
|
115
|
+
const entry = entries.find(
|
|
116
|
+
(e) => e.value === code || e.label?.toLowerCase() === code.toLowerCase()
|
|
117
|
+
);
|
|
118
|
+
return entry?.id;
|
|
119
|
+
}, [statusEntriesData]);
|
|
120
|
+
const startWorkflowMutation = useMutation({
|
|
121
|
+
mutationFn: async () => {
|
|
122
|
+
const pendingApprovalStatusId = findStatusId("pending_approval");
|
|
123
|
+
const approvedStatusId = findStatusId("approved");
|
|
124
|
+
const rejectedStatusId = findStatusId("rejected");
|
|
125
|
+
if (!pendingApprovalStatusId || !approvedStatusId || !rejectedStatusId) {
|
|
126
|
+
throw new Error(t("workflows.orderApproval.missingStatuses", "Missing order status entries. Please ensure pending_approval, approved, and rejected statuses exist in the sales.order_status dictionary."));
|
|
127
|
+
}
|
|
128
|
+
const result = await apiCall("/api/workflows/instances", {
|
|
129
|
+
method: "POST",
|
|
130
|
+
body: JSON.stringify({
|
|
131
|
+
workflowId: WORKFLOW_ID,
|
|
132
|
+
initialContext: {
|
|
133
|
+
orderId,
|
|
134
|
+
pendingApprovalStatusId,
|
|
135
|
+
approvedStatusId,
|
|
136
|
+
rejectedStatusId
|
|
137
|
+
},
|
|
138
|
+
metadata: {
|
|
139
|
+
entityType: "SalesOrder",
|
|
140
|
+
entityId: orderId
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
});
|
|
144
|
+
if (!result.ok) {
|
|
145
|
+
const errorResult = result.result;
|
|
146
|
+
throw new Error(errorResult?.error || t("workflows.orderApproval.startError", "Failed to start approval workflow"));
|
|
147
|
+
}
|
|
148
|
+
return result.result;
|
|
149
|
+
},
|
|
150
|
+
onSuccess: () => {
|
|
151
|
+
setError(null);
|
|
152
|
+
queryClient.invalidateQueries({ queryKey: ["workflow-instances", orderId] });
|
|
153
|
+
},
|
|
154
|
+
onError: (err) => {
|
|
155
|
+
setError(err.message);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
const completeTaskMutation = useMutation({
|
|
159
|
+
mutationFn: async ({ taskId, formData }) => {
|
|
160
|
+
const result = await apiCall(`/api/workflows/tasks/${taskId}/complete`, {
|
|
161
|
+
method: "POST",
|
|
162
|
+
body: JSON.stringify({ formData })
|
|
163
|
+
});
|
|
164
|
+
if (!result.ok) {
|
|
165
|
+
const errorResult = result.result;
|
|
166
|
+
throw new Error(errorResult?.error || t("workflows.orderApproval.completeError", "Failed to complete approval task"));
|
|
167
|
+
}
|
|
168
|
+
return result.result;
|
|
169
|
+
},
|
|
170
|
+
onSuccess: () => {
|
|
171
|
+
setError(null);
|
|
172
|
+
setDecision("");
|
|
173
|
+
setComments("");
|
|
174
|
+
setIsWaitingForProcessing(true);
|
|
175
|
+
queryClient.invalidateQueries({ queryKey: ["workflow-instances", orderId] });
|
|
176
|
+
queryClient.invalidateQueries({ queryKey: ["workflow-tasks", activeInstance?.id] });
|
|
177
|
+
queryClient.invalidateQueries({ queryKey: ["sales-order", orderId] });
|
|
178
|
+
},
|
|
179
|
+
onError: (err) => {
|
|
180
|
+
setError(err.message);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
const handleStartWorkflow = () => {
|
|
184
|
+
setIsWaitingForProcessing(true);
|
|
185
|
+
startWorkflowMutation.mutate();
|
|
186
|
+
};
|
|
187
|
+
const handleCompleteTask = () => {
|
|
188
|
+
if (!pendingTask || !decision) return;
|
|
189
|
+
completeTaskMutation.mutate({
|
|
190
|
+
taskId: pendingTask.id,
|
|
191
|
+
formData: { decision, comments }
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
const handleKeyDown = (e) => {
|
|
195
|
+
if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
if (pendingTask && decision && !isSubmitting) {
|
|
198
|
+
handleCompleteTask();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const isLoading = instancesLoading || tasksLoading;
|
|
203
|
+
const isSubmitting = startWorkflowMutation.isPending || completeTaskMutation.isPending;
|
|
204
|
+
if (!orderId) return null;
|
|
205
|
+
const orderStatus = currentOrderStatus?.toLowerCase();
|
|
206
|
+
if (orderStatus !== "pending_approval") {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
if (isLoading) {
|
|
210
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4", children: [
|
|
211
|
+
/* @__PURE__ */ jsx(Spinner, { size: "sm" }),
|
|
212
|
+
/* @__PURE__ */ jsx("span", { className: "ml-2 text-sm text-muted-foreground", children: t("common.loading", "Loading...") })
|
|
213
|
+
] });
|
|
214
|
+
}
|
|
215
|
+
const getStatusBadge = () => {
|
|
216
|
+
if (!activeInstance) return null;
|
|
217
|
+
const statusVariants = {
|
|
218
|
+
RUNNING: "default",
|
|
219
|
+
PAUSED: "secondary",
|
|
220
|
+
WAITING_FOR_ACTIVITIES: "secondary",
|
|
221
|
+
COMPLETED: "default",
|
|
222
|
+
FAILED: "destructive",
|
|
223
|
+
CANCELLED: "outline"
|
|
224
|
+
};
|
|
225
|
+
return /* @__PURE__ */ jsx(Badge, { variant: statusVariants[activeInstance.status] || "outline", children: t(`workflows.instances.statuses.${activeInstance.status}`, activeInstance.status) });
|
|
226
|
+
};
|
|
227
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3 rounded-lg border bg-card p-4 shadow-sm", children: [
|
|
228
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
229
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
230
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm font-semibold text-foreground", children: t("workflows.orderApproval.groupLabel", "Order Approval") }),
|
|
231
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("workflows.orderApproval.groupDescription", "Review and approve or reject this order") })
|
|
232
|
+
] }),
|
|
233
|
+
getStatusBadge()
|
|
234
|
+
] }),
|
|
235
|
+
error && /* @__PURE__ */ jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3 text-xs text-red-800", children: error }),
|
|
236
|
+
!activeInstance && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
237
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("workflows.orderApproval.noWorkflowActive", "No approval workflow is active for this order.") }),
|
|
238
|
+
/* @__PURE__ */ jsxs(
|
|
239
|
+
Button,
|
|
240
|
+
{
|
|
241
|
+
onClick: handleStartWorkflow,
|
|
242
|
+
disabled: isSubmitting,
|
|
243
|
+
variant: "default",
|
|
244
|
+
size: "sm",
|
|
245
|
+
children: [
|
|
246
|
+
isSubmitting && /* @__PURE__ */ jsx(Spinner, { size: "sm", className: "mr-2" }),
|
|
247
|
+
t("workflows.orderApproval.requestApproval", "Request Approval")
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
)
|
|
251
|
+
] }),
|
|
252
|
+
activeInstance && pendingTask && /* @__PURE__ */ jsxs("div", { className: "space-y-3", onKeyDown: handleKeyDown, children: [
|
|
253
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-md border border-amber-200 bg-amber-50 p-3", children: [
|
|
254
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-amber-800", children: t("workflows.orderApproval.pendingTitle", "Pending Approval") }),
|
|
255
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-amber-700 mt-1", children: t("workflows.orderApproval.pendingDescription", "This order requires approval before processing.") })
|
|
256
|
+
] }),
|
|
257
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
258
|
+
/* @__PURE__ */ jsx("label", { className: "text-sm font-medium", children: t("workflows.orderApproval.decisionLabel", "Decision") }),
|
|
259
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
260
|
+
/* @__PURE__ */ jsx(
|
|
261
|
+
Button,
|
|
262
|
+
{
|
|
263
|
+
variant: decision === "approve" ? "default" : "outline",
|
|
264
|
+
size: "sm",
|
|
265
|
+
onClick: () => setDecision("approve"),
|
|
266
|
+
className: decision === "approve" ? "bg-emerald-600 hover:bg-emerald-700" : "",
|
|
267
|
+
children: t("workflows.orderApproval.approveButton", "Approve")
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
/* @__PURE__ */ jsx(
|
|
271
|
+
Button,
|
|
272
|
+
{
|
|
273
|
+
variant: decision === "reject" ? "destructive" : "outline",
|
|
274
|
+
size: "sm",
|
|
275
|
+
onClick: () => setDecision("reject"),
|
|
276
|
+
children: t("workflows.orderApproval.rejectButton", "Reject")
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
] })
|
|
280
|
+
] }),
|
|
281
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
282
|
+
/* @__PURE__ */ jsxs("label", { className: "text-sm font-medium", children: [
|
|
283
|
+
t("workflows.orderApproval.commentsLabel", "Comments"),
|
|
284
|
+
" ",
|
|
285
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground font-normal", children: [
|
|
286
|
+
"(",
|
|
287
|
+
t("common.optional", "optional"),
|
|
288
|
+
")"
|
|
289
|
+
] })
|
|
290
|
+
] }),
|
|
291
|
+
/* @__PURE__ */ jsx(
|
|
292
|
+
Textarea,
|
|
293
|
+
{
|
|
294
|
+
value: comments,
|
|
295
|
+
onChange: (e) => setComments(e.target.value),
|
|
296
|
+
placeholder: t("workflows.orderApproval.commentsPlaceholder", "Add optional comments..."),
|
|
297
|
+
rows: 2
|
|
298
|
+
}
|
|
299
|
+
)
|
|
300
|
+
] }),
|
|
301
|
+
/* @__PURE__ */ jsxs(
|
|
302
|
+
Button,
|
|
303
|
+
{
|
|
304
|
+
onClick: handleCompleteTask,
|
|
305
|
+
disabled: !decision || isSubmitting,
|
|
306
|
+
variant: "default",
|
|
307
|
+
size: "sm",
|
|
308
|
+
className: "w-full",
|
|
309
|
+
children: [
|
|
310
|
+
isSubmitting && /* @__PURE__ */ jsx(Spinner, { size: "sm", className: "mr-2" }),
|
|
311
|
+
t("workflows.orderApproval.submitDecision", "Submit Decision")
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
)
|
|
315
|
+
] }),
|
|
316
|
+
activeInstance && !pendingTask && activeInstance.status !== "COMPLETED" && /* @__PURE__ */ jsx("div", { className: "rounded-md border border-blue-200 bg-blue-50 p-3", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-blue-800", children: t("workflows.orderApproval.processing", "Workflow is processing...") }) }),
|
|
317
|
+
activeInstance && activeInstance.status === "COMPLETED" && /* @__PURE__ */ jsx("div", { className: "rounded-md border border-emerald-200 bg-emerald-50 p-3", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-emerald-800", children: t("workflows.orderApproval.completed", "Approval workflow completed.") }) })
|
|
318
|
+
] });
|
|
319
|
+
}
|
|
320
|
+
export {
|
|
321
|
+
OrderApprovalWidget as default
|
|
322
|
+
};
|
|
323
|
+
//# sourceMappingURL=widget.client.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/workflows/widgets/injection/order-approval/widget.client.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport type { InjectionWidgetComponentProps } from '@open-mercato/shared/modules/widgets/injection'\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { Textarea } from '@open-mercato/ui/primitives/textarea'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { emitSalesDocumentDataRefresh } from '@open-mercato/core/modules/sales/lib/frontend/documentDataEvents'\n\ntype OrderRecord = {\n id: string\n orderNumber?: string\n status?: string\n statusEntryId?: string\n}\n\ntype WorkflowInstance = {\n id: string\n workflowId: string\n status: 'RUNNING' | 'PAUSED' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'WAITING_FOR_ACTIVITIES'\n currentStepId: string\n context: Record<string, any>\n}\n\ntype UserTask = {\n id: string\n taskName: string\n status: 'PENDING' | 'IN_PROGRESS' | 'COMPLETED' | 'CANCELLED'\n workflowInstanceId: string\n claimedBy: string | null\n}\n\ntype DictionaryEntry = {\n id: string\n value: string\n label: string\n color?: string\n icon?: string\n}\n\nconst WORKFLOW_ID = 'sales_order_approval_v1'\n\nexport default function OrderApprovalWidget({ data }: InjectionWidgetComponentProps<unknown, OrderRecord>) {\n const t = useT()\n const queryClient = useQueryClient()\n const orderId = data?.id\n\n const [decision, setDecision] = React.useState<'approve' | 'reject' | ''>('')\n const [comments, setComments] = React.useState('')\n const [error, setError] = React.useState<string | null>(null)\n\n // Track if we're waiting for workflow to process (for polling)\n const [isWaitingForProcessing, setIsWaitingForProcessing] = React.useState(false)\n\n // Fetch current order status directly (to detect when workflow updates it)\n // Use list endpoint with ID filter since single-item endpoint doesn't exist\n const { data: orderData } = useQuery({\n queryKey: ['order-status', orderId],\n queryFn: async () => {\n if (!orderId) return null\n const result = await apiCall<{ items: Array<{ id: string; status?: string | null }> }>(\n `/api/sales/orders?id=${orderId}&pageSize=1`\n )\n return result.ok && result.result?.items?.[0] ? result.result.items[0] : null\n },\n enabled: Boolean(orderId),\n staleTime: 5_000,\n // Poll when waiting for processing to detect status change\n refetchInterval: isWaitingForProcessing ? 2_000 : false,\n })\n\n // Use fresh order status from query, fallback to prop data\n // The API returns status as a string value (e.g., \"approved\", \"pending_approval\")\n const currentOrderStatus = orderData?.status || data?.status\n\n // Fetch active workflow instances for this order\n const { data: instancesData, isLoading: instancesLoading } = useQuery({\n queryKey: ['workflow-instances', orderId],\n queryFn: async () => {\n if (!orderId) return { data: [] }\n const result = await apiCall<{ data: WorkflowInstance[] }>(\n `/api/workflows/instances?entityId=${orderId}&status=RUNNING,PAUSED,WAITING_FOR_ACTIVITIES`\n )\n return result.ok ? result.result : { data: [] }\n },\n enabled: Boolean(orderId),\n staleTime: 5_000,\n // Poll every 2 seconds when waiting for processing\n refetchInterval: isWaitingForProcessing ? 2_000 : false,\n })\n\n const activeInstance = instancesData?.data?.find(\n (inst) => inst.workflowId === WORKFLOW_ID && !['COMPLETED', 'FAILED', 'CANCELLED'].includes(inst.status)\n )\n\n // Fetch pending user tasks for active instance\n const { data: tasksData, isLoading: tasksLoading } = useQuery({\n queryKey: ['workflow-tasks', activeInstance?.id],\n queryFn: async () => {\n if (!activeInstance?.id) return { data: [] }\n const result = await apiCall<{ data: UserTask[] }>(\n `/api/workflows/tasks?workflowInstanceId=${activeInstance.id}&status=PENDING,IN_PROGRESS`\n )\n return result.ok ? result.result : { data: [] }\n },\n enabled: Boolean(activeInstance?.id),\n staleTime: 5_000,\n // Poll every 2 seconds when waiting for processing\n refetchInterval: isWaitingForProcessing ? 2_000 : false,\n })\n\n const pendingTask = tasksData?.data?.[0]\n\n // Auto-detect when workflow is processing (active instance but no pending task)\n const isProcessing = activeInstance && !pendingTask && !['COMPLETED', 'FAILED', 'CANCELLED'].includes(activeInstance.status)\n\n // Track previous status to detect changes\n const prevStatusRef = React.useRef<string | undefined>(data?.status)\n\n // Update polling state when processing state changes\n React.useEffect(() => {\n if (isProcessing) {\n setIsWaitingForProcessing(true)\n } else if (!activeInstance || activeInstance.status === 'COMPLETED') {\n setIsWaitingForProcessing(false)\n }\n }, [isProcessing, activeInstance])\n\n // When order status changes, emit refresh event to update the page\n React.useEffect(() => {\n const newStatus = orderData?.status\n const oldStatus = prevStatusRef.current\n\n if (newStatus && oldStatus && newStatus !== oldStatus) {\n // Status changed - emit document refresh event to reload the page data\n if (orderId) {\n emitSalesDocumentDataRefresh({ documentId: orderId, kind: 'order' })\n }\n }\n\n prevStatusRef.current = newStatus || oldStatus\n }, [orderData?.status, orderId])\n\n // First fetch dictionaries to find the order_status dictionary ID\n const { data: dictionariesData } = useQuery({\n queryKey: ['dictionaries'],\n queryFn: async () => {\n const result = await apiCall<{ items: Array<{ id: string; key: string }> }>(\n '/api/dictionaries'\n )\n return result.ok ? result.result : { items: [] }\n },\n staleTime: 60_000,\n })\n\n const orderStatusDictionaryId = React.useMemo(() => {\n const dict = dictionariesData?.items?.find(d => d.key === 'sales.order_status')\n return dict?.id\n }, [dictionariesData])\n\n // Fetch order status dictionary entries using the dictionary ID\n const { data: statusEntriesData } = useQuery({\n queryKey: ['dictionary-entries', orderStatusDictionaryId],\n queryFn: async () => {\n if (!orderStatusDictionaryId) return { items: [] }\n const result = await apiCall<{ items: DictionaryEntry[] }>(\n `/api/dictionaries/${orderStatusDictionaryId}/entries`\n )\n return result.ok ? result.result : { items: [] }\n },\n enabled: Boolean(orderStatusDictionaryId),\n staleTime: 60_000,\n })\n\n const findStatusId = React.useCallback((code: string) => {\n const entries = statusEntriesData?.items || []\n // The API returns 'value' as the code/key for dictionary entries\n const entry = entries.find(\n (e) => e.value === code || e.label?.toLowerCase() === code.toLowerCase()\n )\n return entry?.id\n }, [statusEntriesData])\n\n // Start workflow mutation\n const startWorkflowMutation = useMutation({\n mutationFn: async () => {\n const pendingApprovalStatusId = findStatusId('pending_approval')\n const approvedStatusId = findStatusId('approved')\n const rejectedStatusId = findStatusId('rejected')\n\n if (!pendingApprovalStatusId || !approvedStatusId || !rejectedStatusId) {\n throw new Error(t('workflows.orderApproval.missingStatuses', 'Missing order status entries. Please ensure pending_approval, approved, and rejected statuses exist in the sales.order_status dictionary.'))\n }\n\n const result = await apiCall<{ data: WorkflowInstance }>('/api/workflows/instances', {\n method: 'POST',\n body: JSON.stringify({\n workflowId: WORKFLOW_ID,\n initialContext: {\n orderId,\n pendingApprovalStatusId,\n approvedStatusId,\n rejectedStatusId,\n },\n metadata: {\n entityType: 'SalesOrder',\n entityId: orderId,\n },\n }),\n })\n\n if (!result.ok) {\n const errorResult = result.result as { error?: string } | null\n throw new Error(errorResult?.error || t('workflows.orderApproval.startError', 'Failed to start approval workflow'))\n }\n\n return result.result\n },\n onSuccess: () => {\n setError(null)\n queryClient.invalidateQueries({ queryKey: ['workflow-instances', orderId] })\n },\n onError: (err: Error) => {\n setError(err.message)\n },\n })\n\n // Complete task mutation\n const completeTaskMutation = useMutation({\n mutationFn: async ({ taskId, formData }: { taskId: string; formData: { decision: string; comments?: string } }) => {\n const result = await apiCall(`/api/workflows/tasks/${taskId}/complete`, {\n method: 'POST',\n body: JSON.stringify({ formData }),\n })\n\n if (!result.ok) {\n const errorResult = result.result as { error?: string } | null\n throw new Error(errorResult?.error || t('workflows.orderApproval.completeError', 'Failed to complete approval task'))\n }\n\n return result.result\n },\n onSuccess: () => {\n setError(null)\n setDecision('')\n setComments('')\n // Start polling immediately after submitting decision\n setIsWaitingForProcessing(true)\n queryClient.invalidateQueries({ queryKey: ['workflow-instances', orderId] })\n queryClient.invalidateQueries({ queryKey: ['workflow-tasks', activeInstance?.id] })\n // Also refresh the order data\n queryClient.invalidateQueries({ queryKey: ['sales-order', orderId] })\n },\n onError: (err: Error) => {\n setError(err.message)\n },\n })\n\n const handleStartWorkflow = () => {\n // Start polling after starting workflow\n setIsWaitingForProcessing(true)\n startWorkflowMutation.mutate()\n }\n\n const handleCompleteTask = () => {\n if (!pendingTask || !decision) return\n completeTaskMutation.mutate({\n taskId: pendingTask.id,\n formData: { decision, comments },\n })\n }\n\n // Handle keyboard shortcuts (Cmd/Ctrl+Enter to submit)\n const handleKeyDown = (e: React.KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {\n e.preventDefault()\n if (pendingTask && decision && !isSubmitting) {\n handleCompleteTask()\n }\n }\n }\n\n const isLoading = instancesLoading || tasksLoading\n const isSubmitting = startWorkflowMutation.isPending || completeTaskMutation.isPending\n\n // Don't render if no orderId\n if (!orderId) return null\n\n // Only show widget when order status is pending_approval\n const orderStatus = currentOrderStatus?.toLowerCase()\n if (orderStatus !== 'pending_approval') {\n return null\n }\n\n // Loading state\n if (isLoading) {\n return (\n <div className=\"flex items-center justify-center p-4\">\n <Spinner size=\"sm\" />\n <span className=\"ml-2 text-sm text-muted-foreground\">{t('common.loading', 'Loading...')}</span>\n </div>\n )\n }\n\n // Show workflow status badge\n const getStatusBadge = () => {\n if (!activeInstance) return null\n\n const statusVariants: Record<string, 'default' | 'secondary' | 'destructive' | 'outline'> = {\n RUNNING: 'default',\n PAUSED: 'secondary',\n WAITING_FOR_ACTIVITIES: 'secondary',\n COMPLETED: 'default',\n FAILED: 'destructive',\n CANCELLED: 'outline',\n }\n\n return (\n <Badge variant={statusVariants[activeInstance.status] || 'outline'}>\n {t(`workflows.instances.statuses.${activeInstance.status}`, activeInstance.status)}\n </Badge>\n )\n }\n\n return (\n <div className=\"space-y-3 rounded-lg border bg-card p-4 shadow-sm\">\n <div className=\"flex items-start justify-between gap-3\">\n <div>\n <div className=\"text-sm font-semibold text-foreground\">\n {t('workflows.orderApproval.groupLabel', 'Order Approval')}\n </div>\n <p className=\"text-xs text-muted-foreground\">\n {t('workflows.orderApproval.groupDescription', 'Review and approve or reject this order')}\n </p>\n </div>\n {getStatusBadge()}\n </div>\n\n {error && (\n <div className=\"rounded-md border border-red-200 bg-red-50 p-3 text-xs text-red-800\">\n {error}\n </div>\n )}\n\n {/* No active workflow - show request approval button */}\n {!activeInstance && (\n <div className=\"space-y-3\">\n <p className=\"text-sm text-muted-foreground\">\n {t('workflows.orderApproval.noWorkflowActive', 'No approval workflow is active for this order.')}\n </p>\n <Button\n onClick={handleStartWorkflow}\n disabled={isSubmitting}\n variant=\"default\"\n size=\"sm\"\n >\n {isSubmitting && <Spinner size=\"sm\" className=\"mr-2\" />}\n {t('workflows.orderApproval.requestApproval', 'Request Approval')}\n </Button>\n </div>\n )}\n\n {/* Active workflow with pending task - show approve/reject UI */}\n {activeInstance && pendingTask && (\n <div className=\"space-y-3\" onKeyDown={handleKeyDown}>\n <div className=\"rounded-md border border-amber-200 bg-amber-50 p-3\">\n <p className=\"text-sm font-medium text-amber-800\">\n {t('workflows.orderApproval.pendingTitle', 'Pending Approval')}\n </p>\n <p className=\"text-xs text-amber-700 mt-1\">\n {t('workflows.orderApproval.pendingDescription', 'This order requires approval before processing.')}\n </p>\n </div>\n\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">\n {t('workflows.orderApproval.decisionLabel', 'Decision')}\n </label>\n <div className=\"flex gap-2\">\n <Button\n variant={decision === 'approve' ? 'default' : 'outline'}\n size=\"sm\"\n onClick={() => setDecision('approve')}\n className={decision === 'approve' ? 'bg-emerald-600 hover:bg-emerald-700' : ''}\n >\n {t('workflows.orderApproval.approveButton', 'Approve')}\n </Button>\n <Button\n variant={decision === 'reject' ? 'destructive' : 'outline'}\n size=\"sm\"\n onClick={() => setDecision('reject')}\n >\n {t('workflows.orderApproval.rejectButton', 'Reject')}\n </Button>\n </div>\n </div>\n\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">\n {t('workflows.orderApproval.commentsLabel', 'Comments')} <span className=\"text-muted-foreground font-normal\">({t('common.optional', 'optional')})</span>\n </label>\n <Textarea\n value={comments}\n onChange={(e) => setComments(e.target.value)}\n placeholder={t('workflows.orderApproval.commentsPlaceholder', 'Add optional comments...')}\n rows={2}\n />\n </div>\n\n <Button\n onClick={handleCompleteTask}\n disabled={!decision || isSubmitting}\n variant=\"default\"\n size=\"sm\"\n className=\"w-full\"\n >\n {isSubmitting && <Spinner size=\"sm\" className=\"mr-2\" />}\n {t('workflows.orderApproval.submitDecision', 'Submit Decision')}\n </Button>\n </div>\n )}\n\n {/* Active workflow but no pending task (processing) */}\n {activeInstance && !pendingTask && activeInstance.status !== 'COMPLETED' && (\n <div className=\"rounded-md border border-blue-200 bg-blue-50 p-3\">\n <p className=\"text-sm text-blue-800\">\n {t('workflows.orderApproval.processing', 'Workflow is processing...')}\n </p>\n </div>\n )}\n\n {/* Completed workflow */}\n {activeInstance && activeInstance.status === 'COMPLETED' && (\n <div className=\"rounded-md border border-emerald-200 bg-emerald-50 p-3\">\n <p className=\"text-sm text-emerald-800\">\n {t('workflows.orderApproval.completed', 'Approval workflow completed.')}\n </p>\n </div>\n )}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA6SM,SACE,KADF;AA3SN,YAAY,WAAW;AAEvB,SAAS,UAAU,aAAa,sBAAsB;AACtD,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,SAAS,oCAAoC;AAiC7C,MAAM,cAAc;AAEL,SAAR,oBAAqC,EAAE,KAAK,GAAwD;AACzG,QAAM,IAAI,KAAK;AACf,QAAM,cAAc,eAAe;AACnC,QAAM,UAAU,MAAM;AAEtB,QAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAoC,EAAE;AAC5E,QAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAS,EAAE;AACjD,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAwB,IAAI;AAG5D,QAAM,CAAC,wBAAwB,yBAAyB,IAAI,MAAM,SAAS,KAAK;AAIhF,QAAM,EAAE,MAAM,UAAU,IAAI,SAAS;AAAA,IACnC,UAAU,CAAC,gBAAgB,OAAO;AAAA,IAClC,SAAS,YAAY;AACnB,UAAI,CAAC,QAAS,QAAO;AACrB,YAAM,SAAS,MAAM;AAAA,QACnB,wBAAwB,OAAO;AAAA,MACjC;AACA,aAAO,OAAO,MAAM,OAAO,QAAQ,QAAQ,CAAC,IAAI,OAAO,OAAO,MAAM,CAAC,IAAI;AAAA,IAC3E;AAAA,IACA,SAAS,QAAQ,OAAO;AAAA,IACxB,WAAW;AAAA;AAAA,IAEX,iBAAiB,yBAAyB,MAAQ;AAAA,EACpD,CAAC;AAID,QAAM,qBAAqB,WAAW,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AU,CAAC,YAAY;AAAA,UACvB,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,WAAU;AAAA,UAET;AAAA,4BAAgB,oBAAC,WAAQ,MAAK,MAAK,WAAU,QAAO;AAAA,YACpD,EAAE,0CAA0C,iBAAiB;AAAA;AAAA;AAAA,MAChE;AAAA,OACF;AAAA,IAID,kBAAkB,CAAC,eAAe,eAAe,WAAW,eAC3D,oBAAC,SAAI,WAAU,oDACb,8BAAC,OAAE,WAAU,yBACV,YAAE,sCAAsC,2BAA2B,GACtE,GACF;AAAA,IAID,kBAAkB,eAAe,WAAW,eAC3C,oBAAC,SAAI,WAAU,0DACb,8BAAC,OAAE,WAAU,4BACV,YAAE,qCAAqC,8BAA8B,GACxE,GACF;AAAA,KAEJ;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import OrderApprovalWidget from "./widget.client.js";
|
|
2
|
+
const widget = {
|
|
3
|
+
metadata: {
|
|
4
|
+
id: "workflows.injection.order-approval",
|
|
5
|
+
title: "Order Approval",
|
|
6
|
+
description: "Approve or reject orders requiring authorization",
|
|
7
|
+
features: ["sales.orders.approve"],
|
|
8
|
+
priority: 100,
|
|
9
|
+
enabled: true
|
|
10
|
+
},
|
|
11
|
+
Widget: OrderApprovalWidget
|
|
12
|
+
};
|
|
13
|
+
var widget_default = widget;
|
|
14
|
+
export {
|
|
15
|
+
widget_default as default
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=widget.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/workflows/widgets/injection/order-approval/widget.ts"],
|
|
4
|
+
"sourcesContent": ["import type { InjectionWidgetModule } from '@open-mercato/shared/modules/widgets/injection'\nimport OrderApprovalWidget from './widget.client'\n\nconst widget: InjectionWidgetModule<any, any> = {\n metadata: {\n id: 'workflows.injection.order-approval',\n title: 'Order Approval',\n description: 'Approve or reject orders requiring authorization',\n features: ['sales.orders.approve'],\n priority: 100,\n enabled: true,\n },\n Widget: OrderApprovalWidget,\n}\n\nexport default widget\n"],
|
|
5
|
+
"mappings": "AACA,OAAO,yBAAyB;AAEhC,MAAM,SAA0C;AAAA,EAC9C,UAAU;AAAA,IACR,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU,CAAC,sBAAsB;AAAA,IACjC,UAAU;AAAA,IACV,SAAS;AAAA,EACX;AAAA,EACA,QAAQ;AACV;AAEA,IAAO,iBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const injectionTable = {
|
|
2
|
+
// Inject the order approval widget into the sales order detail page
|
|
3
|
+
"sales.document.detail.order:details": [
|
|
4
|
+
{
|
|
5
|
+
widgetId: "workflows.injection.order-approval",
|
|
6
|
+
kind: "group",
|
|
7
|
+
column: 2,
|
|
8
|
+
groupLabel: "workflows.orderApproval.groupLabel",
|
|
9
|
+
groupDescription: "workflows.orderApproval.groupDescription",
|
|
10
|
+
priority: 200
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
};
|
|
14
|
+
var injection_table_default = injectionTable;
|
|
15
|
+
export {
|
|
16
|
+
injection_table_default as default,
|
|
17
|
+
injectionTable
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=injection-table.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/workflows/widgets/injection-table.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ModuleInjectionTable } from '@open-mercato/shared/modules/widgets/injection'\n\n/**\n * Workflows module injection table\n * Maps injection spot IDs to widget IDs for automatic widget injection\n */\nexport const injectionTable: ModuleInjectionTable = {\n // Inject the order approval widget into the sales order detail page\n 'sales.document.detail.order:details': [\n {\n widgetId: 'workflows.injection.order-approval',\n kind: 'group',\n column: 2,\n groupLabel: 'workflows.orderApproval.groupLabel',\n groupDescription: 'workflows.orderApproval.groupDescription',\n priority: 200,\n },\n ],\n}\n\nexport default injectionTable\n"],
|
|
5
|
+
"mappings": "AAMO,MAAM,iBAAuC;AAAA;AAAA,EAElD,uCAAuC;AAAA,IACrC;AAAA,MACE,UAAU;AAAA,MACV,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,kBAAkB;AAAA,MAClB,UAAU;AAAA,IACZ;AAAA,EACF;AACF;AAEA,IAAO,0BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const id = 'id'
|
|
2
|
+
export const name = 'name'
|
|
3
|
+
export const description = 'description'
|
|
4
|
+
export const workflow_definition_id = 'workflow_definition_id'
|
|
5
|
+
export const event_pattern = 'event_pattern'
|
|
6
|
+
export const config = 'config'
|
|
7
|
+
export const enabled = 'enabled'
|
|
8
|
+
export const priority = 'priority'
|
|
9
|
+
export const tenant_id = 'tenant_id'
|
|
10
|
+
export const organization_id = 'organization_id'
|
|
11
|
+
export const created_by = 'created_by'
|
|
12
|
+
export const updated_by = 'updated_by'
|
|
13
|
+
export const created_at = 'created_at'
|
|
14
|
+
export const updated_at = 'updated_at'
|
|
15
|
+
export const deleted_at = 'deleted_at'
|
|
@@ -21,8 +21,7 @@ export const M = {
|
|
|
21
21
|
"currencies": "currencies",
|
|
22
22
|
"planner": "planner",
|
|
23
23
|
"resources": "resources",
|
|
24
|
-
"staff": "staff"
|
|
25
|
-
"notifications": "notifications"
|
|
24
|
+
"staff": "staff"
|
|
26
25
|
} as const
|
|
27
26
|
export const E = {
|
|
28
27
|
"dashboards": {
|
|
@@ -155,6 +154,7 @@ export const E = {
|
|
|
155
154
|
"user_task": "workflows:user_task",
|
|
156
155
|
"workflow_definition": "workflows:workflow_definition",
|
|
157
156
|
"workflow_event": "workflows:workflow_event",
|
|
157
|
+
"workflow_event_trigger": "workflows:workflow_event_trigger",
|
|
158
158
|
"workflow_instance": "workflows:workflow_instance"
|
|
159
159
|
},
|
|
160
160
|
"currencies": {
|
|
@@ -183,9 +183,6 @@ export const E = {
|
|
|
183
183
|
"staff_team_member_comment": "staff:staff_team_member_comment",
|
|
184
184
|
"staff_team_member_job_history": "staff:staff_team_member_job_history",
|
|
185
185
|
"staff_team_role": "staff:staff_team_role"
|
|
186
|
-
},
|
|
187
|
-
"notifications": {
|
|
188
|
-
"notification": "notifications:notification"
|
|
189
186
|
}
|
|
190
187
|
} as const
|
|
191
188
|
export type KnownModuleId = keyof typeof M
|
|
@@ -53,7 +53,6 @@ import * as feature_toggle_override from './entities/feature_toggle_override/ind
|
|
|
53
53
|
import * as indexer_error_log from './entities/indexer_error_log/index'
|
|
54
54
|
import * as indexer_status_log from './entities/indexer_status_log/index'
|
|
55
55
|
import * as module_config from './entities/module_config/index'
|
|
56
|
-
import * as notification from './entities/notification/index'
|
|
57
56
|
import * as organization from './entities/organization/index'
|
|
58
57
|
import * as password_reset from './entities/password_reset/index'
|
|
59
58
|
import * as perspective from './entities/perspective/index'
|
|
@@ -117,6 +116,7 @@ import * as user_sidebar_preference from './entities/user_sidebar_preference/ind
|
|
|
117
116
|
import * as user_task from './entities/user_task/index'
|
|
118
117
|
import * as workflow_definition from './entities/workflow_definition/index'
|
|
119
118
|
import * as workflow_event from './entities/workflow_event/index'
|
|
119
|
+
import * as workflow_event_trigger from './entities/workflow_event_trigger/index'
|
|
120
120
|
import * as workflow_instance from './entities/workflow_instance/index'
|
|
121
121
|
|
|
122
122
|
export const entityFieldsRegistry: Record<string, Record<string, string>> = {
|
|
@@ -173,7 +173,6 @@ export const entityFieldsRegistry: Record<string, Record<string, string>> = {
|
|
|
173
173
|
indexer_error_log,
|
|
174
174
|
indexer_status_log,
|
|
175
175
|
module_config,
|
|
176
|
-
notification,
|
|
177
176
|
organization,
|
|
178
177
|
password_reset,
|
|
179
178
|
perspective,
|
|
@@ -237,6 +236,7 @@ export const entityFieldsRegistry: Record<string, Record<string, string>> = {
|
|
|
237
236
|
user_task,
|
|
238
237
|
workflow_definition,
|
|
239
238
|
workflow_event,
|
|
239
|
+
workflow_event_trigger,
|
|
240
240
|
workflow_instance
|
|
241
241
|
}
|
|
242
242
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/core",
|
|
3
|
-
"version": "0.4.2-canary-
|
|
3
|
+
"version": "0.4.2-canary-f821f89ef6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
}
|
|
208
208
|
},
|
|
209
209
|
"dependencies": {
|
|
210
|
-
"@open-mercato/shared": "0.4.2-canary-
|
|
210
|
+
"@open-mercato/shared": "0.4.2-canary-f821f89ef6",
|
|
211
211
|
"@xyflow/react": "^12.6.0",
|
|
212
212
|
"date-fns": "^4.1.0",
|
|
213
213
|
"date-fns-tz": "^3.2.0"
|
|
@@ -2,7 +2,6 @@ import ApiDocsExplorer from './Explorer'
|
|
|
2
2
|
import { getModules } from '@open-mercato/shared/lib/i18n/server'
|
|
3
3
|
import { buildOpenApiDocument } from '@open-mercato/shared/lib/openapi'
|
|
4
4
|
import { resolveApiDocsBaseUrl } from '@open-mercato/core/modules/api_docs/lib/resources'
|
|
5
|
-
import { APP_VERSION } from '@open-mercato/shared/lib/version'
|
|
6
5
|
|
|
7
6
|
type ExplorerOperation = {
|
|
8
7
|
id: string
|
|
@@ -55,7 +54,7 @@ export default async function ApiDocsViewerPage() {
|
|
|
55
54
|
const modules = getModules()
|
|
56
55
|
const doc = buildOpenApiDocument(modules, {
|
|
57
56
|
title: 'Open Mercato API',
|
|
58
|
-
version:
|
|
57
|
+
version: '1.0.0',
|
|
59
58
|
description: 'Auto-generated OpenAPI definition for all enabled modules.',
|
|
60
59
|
servers: [{ url: baseUrl, description: 'Default environment' }],
|
|
61
60
|
baseUrlForExamples: baseUrl,
|
|
@@ -68,7 +67,7 @@ export default async function ApiDocsViewerPage() {
|
|
|
68
67
|
return (
|
|
69
68
|
<ApiDocsExplorer
|
|
70
69
|
title={doc.info?.title ?? 'Open Mercato API'}
|
|
71
|
-
version={doc.info?.version ??
|
|
70
|
+
version={doc.info?.version ?? '1.0.0'}
|
|
72
71
|
description={doc.info?.description}
|
|
73
72
|
operations={operations}
|
|
74
73
|
tagOrder={tagOrder}
|
|
@@ -175,7 +175,7 @@ export default function ApiKeysListPage() {
|
|
|
175
175
|
perspective={{ tableId: 'api_keys.list' }}
|
|
176
176
|
rowActions={(row) => (
|
|
177
177
|
<RowActions items={[
|
|
178
|
-
{
|
|
178
|
+
{ label: t('common.delete'), destructive: true, onSelect: () => { void handleDelete(row) } },
|
|
179
179
|
]} />
|
|
180
180
|
)}
|
|
181
181
|
pagination={{ page, pageSize: 20, total, totalPages, onPageChange: setPage }}
|
|
@@ -1056,7 +1056,6 @@ export function AttachmentLibrary() {
|
|
|
1056
1056
|
<RowActions
|
|
1057
1057
|
items={[
|
|
1058
1058
|
{
|
|
1059
|
-
id: 'open',
|
|
1060
1059
|
label: t('attachments.library.actions.open', 'Open'),
|
|
1061
1060
|
onSelect: () => {
|
|
1062
1061
|
if (!row.url) return
|
|
@@ -1064,12 +1063,10 @@ export function AttachmentLibrary() {
|
|
|
1064
1063
|
},
|
|
1065
1064
|
},
|
|
1066
1065
|
{
|
|
1067
|
-
id: 'edit',
|
|
1068
1066
|
label: t('attachments.library.actions.edit', 'Edit metadata'),
|
|
1069
1067
|
onSelect: () => openMetadataDialog(row),
|
|
1070
1068
|
},
|
|
1071
1069
|
{
|
|
1072
|
-
id: 'copy-url',
|
|
1073
1070
|
label: t('attachments.library.actions.copyUrl', 'Copy URL'),
|
|
1074
1071
|
onSelect: () => {
|
|
1075
1072
|
if (!row.url) {
|
|
@@ -1094,7 +1091,6 @@ export function AttachmentLibrary() {
|
|
|
1094
1091
|
},
|
|
1095
1092
|
},
|
|
1096
1093
|
{
|
|
1097
|
-
id: 'delete',
|
|
1098
1094
|
label: t('attachments.library.actions.delete', 'Delete'),
|
|
1099
1095
|
destructive: true,
|
|
1100
1096
|
onSelect: () => openDeleteDialog(row),
|
|
@@ -305,12 +305,10 @@ export function AttachmentPartitionSettings() {
|
|
|
305
305
|
<RowActions
|
|
306
306
|
items={[
|
|
307
307
|
{
|
|
308
|
-
id: 'edit',
|
|
309
308
|
label: t('attachments.partitions.actions.edit', 'Edit'),
|
|
310
309
|
onSelect: () => openDialog({ mode: 'edit', entry }),
|
|
311
310
|
},
|
|
312
311
|
{
|
|
313
|
-
id: 'delete',
|
|
314
312
|
label: t('attachments.partitions.actions.delete', 'Delete'),
|
|
315
313
|
destructive: true,
|
|
316
314
|
onSelect: () => { void handleDelete(entry) },
|
|
@@ -8,7 +8,7 @@ Features:
|
|
|
8
8
|
- `mercato auth add-user --email <e> --password <p> --organizationId <id> [--roles r1,r2]`
|
|
9
9
|
- `mercato auth seed-roles`
|
|
10
10
|
- `mercato auth add-org --name <org>`
|
|
11
|
-
- `mercato auth setup --orgName <org> --email <e> --password <p> [--roles superadmin,admin]
|
|
11
|
+
- `mercato auth setup --orgName <org> --email <e> --password <p> [--roles superadmin,admin]`
|
|
12
12
|
|
|
13
13
|
DB entities used (defined in root schema):
|
|
14
14
|
- `users` with: `email`, `password_hash`, `is_confirmed`, `last_login_at`, `organization_id`, timestamps.
|
|
@@ -46,7 +46,7 @@ describe('auth CLI setup seeds ACLs', () => {
|
|
|
46
46
|
findOneOrFail.mockImplementation(async (_: any, where: any) => ({ id: 'role-' + where.name, name: where.name }))
|
|
47
47
|
|
|
48
48
|
// Act
|
|
49
|
-
await setup.run(['--orgName', 'Acme', '--email', 'root@acme.com', '--password', 'secret'
|
|
49
|
+
await setup.run(['--orgName', 'Acme', '--email', 'root@acme.com', '--password', 'secret'])
|
|
50
50
|
|
|
51
51
|
// Assert: persistAndFlush was called to create three RoleAcl rows with expected flags/features
|
|
52
52
|
const calls = persistAndFlush.mock.calls.map((c) => c[0])
|