@processfocus/runtime-local 0.1.0-next.0
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/LICENSE.md +28 -0
- package/README.md +290 -0
- package/dist/authentication-server.mjs +188 -0
- package/dist/chunk-2sb4v2sx.js +70 -0
- package/dist/chunk-9weqs8n8.js +56031 -0
- package/dist/chunk-mvkr77wp.js +54113 -0
- package/dist/chunk-tkn4cnc8.js +453 -0
- package/dist/chunk-vpsm84e8.js +85 -0
- package/dist/dashboard-source/apps/frontend/app/%5Fpf/app-icons/[...path]/route.ts +63 -0
- package/dist/dashboard-source/apps/frontend/app/%5Fpf/health/page.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/app/%5Fpf/public-form-branding/[...path]/route.ts +95 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/actions.ts +248 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/delegations-client.tsx +751 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/page.tsx +46 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/client-index.tsx +375 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/client.tsx +14 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/client.tsx +73 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/page.tsx +20 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/process-state/page.tsx +22 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/page.tsx +11 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/process-state/page.tsx +23 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/abandon-execution-dialog.tsx +137 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/execution-card-menu.tsx +233 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/layout.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/page.tsx +1549 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-dialog.tsx +91 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-modal-client.tsx +33 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-page-client.tsx +31 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-route-fallback.tsx +18 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/restart-execution-feedback.tsx +40 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/layout.tsx +129 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/client.tsx +215 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/page.tsx +23 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/list-page-client.tsx +678 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/loading.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +228 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +147 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-edit-form.tsx +246 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/metric-control-url-state.ts +71 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-deleted-callback.ts +22 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-item-detail.ts +315 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/client.tsx +259 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/page.tsx +46 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/layout.tsx +14 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-detail-title.ts +20 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh.ts +26 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.ts +20 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/loading.tsx +5 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/org-chart-client.tsx +74 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/page.tsx +120 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/page.tsx +13 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/actions.ts +188 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/page.tsx +33 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/passkeys-client.tsx +320 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client.tsx +152 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/page.tsx +41 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client.tsx +33 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-form-actions.tsx +105 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-submit-button.tsx +81 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/start-process-form.tsx +282 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/layout.tsx +21 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/lib/mobile-process-catalog.ts +28 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/lib/start-process-actions.ts +13 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/loading.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/page.tsx +5 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/processes-client.tsx +504 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/client.tsx +153 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/page.tsx +39 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/loading.tsx +20 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/page.tsx +131 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/process-documentation.tsx +209 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/use-workflow-auto-refresh.ts +120 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-flow.tsx +319 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-form-preview-sheet.tsx +98 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/loading.tsx +1 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/page.tsx +100 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/access-handbook.tsx +110 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/authorization-loading.tsx +25 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/authorization-tabs.tsx +47 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-authorize.ts +261 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-helpers.ts +17 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-source.tsx +34 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-types.ts +79 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/evaluate-cedar.ts +43 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/explorer.tsx +526 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/layout.tsx +23 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-cedar.ts +174 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-handbook.ts +390 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/org-data.ts +70 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/[invitationId]/page.tsx +22 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-client.tsx +594 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-skeleton.tsx +48 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/new/page.tsx +5 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations-table.tsx +186 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/page.tsx +69 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/providers-table.tsx +48 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/roles-table.tsx +62 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-client.tsx +244 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/client.tsx +329 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/page.tsx +21 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/tokens/page.tsx +39 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users-table.tsx +82 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/error.tsx +34 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/not-found.tsx +13 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/page.tsx +84 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/stats-data-fetcher.tsx +93 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/client.tsx +143 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/page.tsx +50 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/client.tsx +131 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/page.tsx +50 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/complete-todo-form.tsx +172 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/public-completion-correction-form.tsx +233 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/todo-form-actions.tsx +26 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/correct/[...stepPath]/page.tsx +58 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/layout.tsx +14 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/lib/mobile-todo-list.ts +154 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/page.tsx +1317 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/callback/route.ts +259 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/delegation/route.ts +127 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/login/route.ts +49 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/logout/route.ts +33 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/auth-options/route.ts +79 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/auth-verify/route.ts +142 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/register/route.ts +103 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/register-verify/route.ts +136 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/registration-session/route.ts +129 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/start/route.ts +153 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/refresh/route.ts +122 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/switch-role/route.ts +177 -0
- package/dist/dashboard-source/apps/frontend/app/api/dev/import-completed/route.ts +22 -0
- package/dist/dashboard-source/apps/frontend/app/api/dev/import-events/route.ts +38 -0
- package/dist/dashboard-source/apps/frontend/app/api/embed/lookup/route.ts +266 -0
- package/dist/dashboard-source/apps/frontend/app/api/embed/submit/route.ts +118 -0
- package/dist/dashboard-source/apps/frontend/app/api/embed/test-host/route.ts +125 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/calendar-slots/route.ts +44 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/complete/route.ts +56 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/lookup/route.ts +61 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/request-fresh-link/route.ts +41 -0
- package/dist/dashboard-source/apps/frontend/app/api/revalidate/route.ts +61 -0
- package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +100 -0
- package/dist/dashboard-source/apps/frontend/app/cli-auth/route.ts +261 -0
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/embed-client.tsx +393 -0
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/loading.tsx +13 -0
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/page.tsx +51 -0
- package/dist/dashboard-source/apps/frontend/app/embed/embedded.css +48 -0
- package/dist/dashboard-source/apps/frontend/app/embed/layout.tsx +15 -0
- package/dist/dashboard-source/apps/frontend/app/global.css +13 -0
- package/dist/dashboard-source/apps/frontend/app/layout.tsx +102 -0
- package/dist/dashboard-source/apps/frontend/app/login/layout.tsx +9 -0
- package/dist/dashboard-source/apps/frontend/app/login/login-button.tsx +35 -0
- package/dist/dashboard-source/apps/frontend/app/login/login-form-content.tsx +117 -0
- package/dist/dashboard-source/apps/frontend/app/login/login-form.tsx +30 -0
- package/dist/dashboard-source/apps/frontend/app/login/page.tsx +52 -0
- package/dist/dashboard-source/apps/frontend/app/login/passkey-button.tsx +226 -0
- package/dist/dashboard-source/apps/frontend/app/login/secret-login-form.tsx +91 -0
- package/dist/dashboard-source/apps/frontend/app/manifest.ts +7 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/error.tsx +63 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/layout.tsx +34 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/page.tsx +129 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-form-branding-card.tsx +42 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-form-branding-context.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-form-branding-html.tsx +40 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-client.tsx +553 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-state-content.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/app/public.css +33 -0
- package/dist/dashboard-source/apps/frontend/app/register/passkey/layout.tsx +49 -0
- package/dist/dashboard-source/apps/frontend/app/register/passkey/page.tsx +36 -0
- package/dist/dashboard-source/apps/frontend/app/register/passkey/register-passkey-client.tsx +292 -0
- package/dist/dashboard-source/apps/frontend/app/theme.css +117 -0
- package/dist/dashboard-source/apps/frontend/components/DashboardSection.tsx +693 -0
- package/dist/dashboard-source/apps/frontend/components/Header.tsx +481 -0
- package/dist/dashboard-source/apps/frontend/components/OrgUnitNode.tsx +41 -0
- package/dist/dashboard-source/apps/frontend/components/app-sidebar.tsx +245 -0
- package/dist/dashboard-source/apps/frontend/components/auth-provider.tsx +158 -0
- package/dist/dashboard-source/apps/frontend/components/collections/collection-table-card.tsx +218 -0
- package/dist/dashboard-source/apps/frontend/components/collections/collection-table-header-row.tsx +97 -0
- package/dist/dashboard-source/apps/frontend/components/config-provider.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/components/copy-button.tsx +40 -0
- package/dist/dashboard-source/apps/frontend/components/dashboard-activity.tsx +35 -0
- package/dist/dashboard-source/apps/frontend/components/dashboard-skeleton.tsx +17 -0
- package/dist/dashboard-source/apps/frontend/components/delegation-expiry.tsx +21 -0
- package/dist/dashboard-source/apps/frontend/components/feature-permissions-provider.tsx +28 -0
- package/dist/dashboard-source/apps/frontend/components/form-dialog-content.tsx +66 -0
- package/dist/dashboard-source/apps/frontend/components/frontend-client-plugin-host.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/components/frontend-client-plugin-identify.tsx +33 -0
- package/dist/dashboard-source/apps/frontend/components/frontend-client-plugin-provider.tsx +55 -0
- package/dist/dashboard-source/apps/frontend/components/journey-timeline.tsx +378 -0
- package/dist/dashboard-source/apps/frontend/components/mobile-home-switchboard.tsx +98 -0
- package/dist/dashboard-source/apps/frontend/components/mocks-provider.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/components/notification-bell.tsx +137 -0
- package/dist/dashboard-source/apps/frontend/components/org-settings-provider.tsx +26 -0
- package/dist/dashboard-source/apps/frontend/components/process-workflow-link.tsx +36 -0
- package/dist/dashboard-source/apps/frontend/components/session-reissue.tsx +48 -0
- package/dist/dashboard-source/apps/frontend/components/sidebar-lists.tsx +89 -0
- package/dist/dashboard-source/apps/frontend/components/sidebar-stats-views.tsx +65 -0
- package/dist/dashboard-source/apps/frontend/components/theme-provider.tsx +132 -0
- package/dist/dashboard-source/apps/frontend/components/todo-count-badge.tsx +59 -0
- package/dist/dashboard-source/apps/frontend/components/token-refresh-scheduler.tsx +304 -0
- package/dist/dashboard-source/apps/frontend/components/ui/checkbox.tsx +31 -0
- package/dist/dashboard-source/apps/frontend/components/ui/dialog.tsx +142 -0
- package/dist/dashboard-source/apps/frontend/components/ui/dropdown-menu.tsx +256 -0
- package/dist/dashboard-source/apps/frontend/components/ui/input.tsx +20 -0
- package/dist/dashboard-source/apps/frontend/components/ui/pagination.tsx +59 -0
- package/dist/dashboard-source/apps/frontend/components/ui/sheet.tsx +138 -0
- package/dist/dashboard-source/apps/frontend/components/ui/sidebar.tsx +741 -0
- package/dist/dashboard-source/apps/frontend/components/ui/skeleton.tsx +13 -0
- package/dist/dashboard-source/apps/frontend/components/ui/tab-pill.tsx +30 -0
- package/dist/dashboard-source/apps/frontend/components/ui/table.tsx +115 -0
- package/dist/dashboard-source/apps/frontend/components/ui/tooltip.tsx +60 -0
- package/dist/dashboard-source/apps/frontend/components/without-waiting-badge.tsx +24 -0
- package/dist/dashboard-source/apps/frontend/components/workflow/step-node.tsx +116 -0
- package/dist/dashboard-source/apps/frontend/components/workflow/swimlane-node.tsx +46 -0
- package/dist/dashboard-source/apps/frontend/components/workflow/workflow-edge.tsx +172 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-draft-process-save.ts +189 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-draft-state.ts +79 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-form-metadata.ts +74 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-mobile.ts +27 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-notification-preference.ts +246 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-processes-query.ts +56 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-weekly-execution-stats.ts +101 -0
- package/dist/dashboard-source/apps/frontend/index.d.ts +12 -0
- package/dist/dashboard-source/apps/frontend/instrumentation.node.ts +25 -0
- package/dist/dashboard-source/apps/frontend/instrumentation.ts +19 -0
- package/dist/dashboard-source/apps/frontend/lib/app-icons-metadata.ts +66 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/adapter.ts +128 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/client.ts +355 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/config.ts +18 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/reconnect-registry.ts +34 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/act-on-behalf-menu.ts +9 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/callback-error.ts +26 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/client-session.ts +32 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/client.ts +46 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/config.ts +48 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/delegations.ts +62 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/issuer.ts +164 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/jwt.ts +17 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/logout.ts +35 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/passkeys-menu.ts +9 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/passkeys.ts +117 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/providers.ts +52 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/realtime-session-token.ts +62 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/reauthentication-state.ts +16 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/redirect.ts +105 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/secret-login-presentation.ts +33 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/session-cache-scope.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/session-role.ts +6 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/session.ts +277 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/ssr-session.ts +76 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/verify-passkey.ts +95 -0
- package/dist/dashboard-source/apps/frontend/lib/authorization-tabs.ts +19 -0
- package/dist/dashboard-source/apps/frontend/lib/cedar-highlight.ts +116 -0
- package/dist/dashboard-source/apps/frontend/lib/client-plugin-error-reporting.ts +28 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +1119 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-scope.ts +48 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/database-error-ui.tsx +61 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution-collection-provider.tsx +32 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution.ts +161 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/execution-collection-provider.tsx +42 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/execution.ts +215 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/graphql-stream.ts +123 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/process-collection-provider.tsx +30 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/process.ts +123 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/replication-factory.ts +394 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/replication-registry.ts +196 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/rxdb-database-name.ts +19 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/rxdb-lifecycle.ts +368 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/rxdb-provider.tsx +577 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/todo-collection-provider.tsx +30 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/todo.ts +133 -0
- package/dist/dashboard-source/apps/frontend/lib/current-provider-user.ts +30 -0
- package/dist/dashboard-source/apps/frontend/lib/dev/frontend-port-file.ts +41 -0
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-events.ts +21 -0
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-query-invalidation.tsx +62 -0
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-refresh.ts +40 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/error-boundary.tsx +84 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/index.ts +31 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/params.ts +57 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/run-effect.ts +17 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/runtime.ts +168 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/access-token.ts +48 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/authorization.ts +206 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/form-validation.ts +36 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/graphql.ts +94 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/index.ts +21 -0
- package/dist/dashboard-source/apps/frontend/lib/embed-manifest-store.ts +20 -0
- package/dist/dashboard-source/apps/frontend/lib/embed-manifest.ts +152 -0
- package/dist/dashboard-source/apps/frontend/lib/embed-request-origin.ts +39 -0
- package/dist/dashboard-source/apps/frontend/lib/errors/get-display-error-message.ts +22 -0
- package/dist/dashboard-source/apps/frontend/lib/execution-menu-actions-registry.ts +26 -0
- package/dist/dashboard-source/apps/frontend/lib/feature-permissions.ts +13 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-boot-health.tsx +161 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-client-plugin-registry.ts +45 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-manifest-store.ts +214 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-manifest.ts +74 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-plugin-loaders.ts +191 -0
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/fragment-masking.ts +87 -0
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +292 -0
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +443 -0
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/index.ts +2 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/client-consumer.tsx +23 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/client-error-reporting.ts +268 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/client-provider.tsx +59 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/dashboard-activity.ts +7 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/dependent-lookup-query.ts +78 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/endpoint.ts +26 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/execution-queries.ts +70 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/file-upload-provider.tsx +82 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/graphql-identifiers.ts +10 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/list-queries.ts +327 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/lookup-provider.tsx +81 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-operations.ts +63 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-queries.ts +67 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/provider-user-queries.ts +65 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/queries.ts +80 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/server-client.ts +15 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/settings-queries.ts +634 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/stats-views-server.ts +16 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/stats-views.ts +33 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/user-queries.ts +138 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-operations.ts +54 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-queries.ts +50 -0
- package/dist/dashboard-source/apps/frontend/lib/mobile-home-view-model.ts +74 -0
- package/dist/dashboard-source/apps/frontend/lib/mobile-shell-policy.ts +124 -0
- package/dist/dashboard-source/apps/frontend/lib/mock-data.ts +364 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/notification-preference.ts +251 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notification-observer.ts +178 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notifications-runtime.tsx +14 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/use-todo-notifications.tsx +103 -0
- package/dist/dashboard-source/apps/frontend/lib/org-chart-data.ts +50 -0
- package/dist/dashboard-source/apps/frontend/lib/org-chart-depth-config.ts +71 -0
- package/dist/dashboard-source/apps/frontend/lib/org-chart-layout.ts +149 -0
- package/dist/dashboard-source/apps/frontend/lib/org-chart-types.ts +17 -0
- package/dist/dashboard-source/apps/frontend/lib/org-identity.ts +57 -0
- package/dist/dashboard-source/apps/frontend/lib/organisation-plugin-loaders.ts +13 -0
- package/dist/dashboard-source/apps/frontend/lib/organisation-plugin-preparation.ts +2 -0
- package/dist/dashboard-source/apps/frontend/lib/plugins-client.tsx +99 -0
- package/dist/dashboard-source/apps/frontend/lib/plugins.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-form-runtime.ts +9 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-graphql-errors.ts +45 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-model.ts +200 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-server.ts +209 -0
- package/dist/dashboard-source/apps/frontend/lib/query-client.ts +41 -0
- package/dist/dashboard-source/apps/frontend/lib/restart-execution-action.ts +76 -0
- package/dist/dashboard-source/apps/frontend/lib/runtime-config.ts +23 -0
- package/dist/dashboard-source/apps/frontend/lib/telemetry/constants.ts +5 -0
- package/dist/dashboard-source/apps/frontend/lib/telemetry/otlp-config.ts +16 -0
- package/dist/dashboard-source/apps/frontend/lib/telemetry/register-otel.ts +308 -0
- package/dist/dashboard-source/apps/frontend/lib/theme.ts +9 -0
- package/dist/dashboard-source/apps/frontend/lib/todo-types.ts +64 -0
- package/dist/dashboard-source/apps/frontend/lib/todo-utils.ts +144 -0
- package/dist/dashboard-source/apps/frontend/lib/types/org-identity.ts +7 -0
- package/dist/dashboard-source/apps/frontend/lib/utils.ts +16 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/constants.ts +118 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/edge-routing.ts +195 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/form-preview.ts +8 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/layout.ts +878 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/types.ts +63 -0
- package/dist/dashboard-source/apps/frontend/next.config.ts +238 -0
- package/dist/dashboard-source/apps/frontend/package.json +71 -0
- package/dist/dashboard-source/apps/frontend/postcss.config.mjs +5 -0
- package/dist/dashboard-source/apps/frontend/proxy.ts +293 -0
- package/dist/dashboard-source/apps/frontend/public/.gitkeep +0 -0
- package/dist/dashboard-source/apps/frontend/public/favicon.ico +0 -0
- package/dist/dashboard-source/apps/frontend/public/processfocus-embed.js +553 -0
- package/dist/dashboard-source/apps/frontend/tsconfig.json +35 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/index.ts +7 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/auth-local-cedar.ts +1397 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/cedar-reload-notifier.ts +18 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/config-base.ts +346 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/policy-watcher.ts +172 -0
- package/dist/dashboard-source/modules/auth-policy/src/index.ts +4 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/auth-policy.ts +263 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/current-principal.ts +34 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/errors.ts +47 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/types.ts +595 -0
- package/dist/dashboard-source/modules/auth-session/src/index.ts +22 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/issuer-url.ts +192 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/realtime-recipient.ts +76 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/session-cache-scope.ts +24 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/subjects.ts +54 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/url.ts +2 -0
- package/dist/dashboard-source/modules/aws-common/src/index.ts +3 -0
- package/dist/dashboard-source/modules/aws-common/src/lib/acm.ts +50 -0
- package/dist/dashboard-source/modules/aws-common/src/lib/otlp-config.ts +66 -0
- package/dist/dashboard-source/modules/aws-common/src/lib/runtime-ssm.ts +28 -0
- package/dist/dashboard-source/modules/effect-json-logger/src/index.ts +1 -0
- package/dist/dashboard-source/modules/effect-json-logger/src/lib/effect-json-logger.ts +65 -0
- package/dist/dashboard-source/modules/form/src/hooks/use-local-storage.ts +78 -0
- package/dist/dashboard-source/modules/form/src/index.ts +20 -0
- package/dist/dashboard-source/modules/form/src/lib/ajv-standard-schema.ts +152 -0
- package/dist/dashboard-source/modules/form/src/lib/client-components-to-form.tsx +1421 -0
- package/dist/dashboard-source/modules/form/src/lib/friendly-validation-message.ts +85 -0
- package/dist/dashboard-source/modules/form/src/lib/lookup-context.tsx +58 -0
- package/dist/dashboard-source/modules/form/src/lib/plugin-registry.ts +34 -0
- package/dist/dashboard-source/modules/form/src/lib/walker.tsx +1554 -0
- package/dist/dashboard-source/modules/form-client-representation/src/lib/client-form-definition.ts +440 -0
- package/dist/dashboard-source/modules/form-client-representation/src/lib/plugin-registry.ts +13 -0
- package/dist/dashboard-source/modules/form-client-representation/src/lib/types.ts +336 -0
- package/dist/dashboard-source/modules/form-rule/src/index.ts +21 -0
- package/dist/dashboard-source/modules/form-rule/src/lib/evaluator.ts +531 -0
- package/dist/dashboard-source/modules/form-rule/src/lib/paths.ts +102 -0
- package/dist/dashboard-source/modules/form-rule/src/lib/types.ts +121 -0
- package/dist/dashboard-source/modules/form-schema/src/index.ts +8 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/annotation-helpers.ts +44 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/deferred-value.ts +21 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/email.ts +50 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/field-count.ts +82 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/form-annotations.ts +58 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/form-schema.ts +975 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/phone.ts +60 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/property-signature.ts +45 -0
- package/dist/dashboard-source/modules/frontend-endpoints/src/endpoint.ts +137 -0
- package/dist/dashboard-source/modules/frontend-endpoints/src/index.ts +11 -0
- package/dist/dashboard-source/modules/frontend-endpoints/src/port-files.ts +219 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/index.ts +2 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/lib/browser-plugin-artifact.ts +201 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/lib/frontend-manifest.ts +408 -0
- package/dist/dashboard-source/modules/frontend-plugin-host/src/index.ts +29 -0
- package/dist/dashboard-source/modules/frontend-plugin-host/src/lib/frontend-plugin-host.ts +288 -0
- package/dist/dashboard-source/modules/openauth/src/client.ts +1045 -0
- package/dist/dashboard-source/modules/openauth/src/error.ts +140 -0
- package/dist/dashboard-source/modules/openauth/src/pkce.ts +40 -0
- package/dist/dashboard-source/modules/openauth/src/random.ts +24 -0
- package/dist/dashboard-source/modules/openauth/src/subject.ts +132 -0
- package/dist/dashboard-source/modules/openauth/src/util.ts +13 -0
- package/dist/dashboard-source/modules/request-time/src/index.ts +1 -0
- package/dist/dashboard-source/modules/request-time/src/lib/request-time.ts +30 -0
- package/dist/dashboard-source/modules/rxdb-collections/generated/draft-process-execution-schema.json +45 -0
- package/dist/dashboard-source/modules/rxdb-collections/generated/execution-schema.json +217 -0
- package/dist/dashboard-source/modules/rxdb-collections/generated/process-schema.json +77 -0
- package/dist/dashboard-source/modules/rxdb-collections/generated/todo-schema.json +94 -0
- package/dist/dashboard-source/modules/rxdb-collections/src/index.ts +2 -0
- package/dist/dashboard-source/modules/rxdb-collections/src/lib/rxdb-collections.ts +181 -0
- package/dist/dashboard-source/modules/rxdb-collections/src/lib/to-rxdb-schema.ts +166 -0
- package/dist/dashboard-source/modules/shadcn-components/src/index.ts +60 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/boolean-field.tsx +73 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/calendar-slot-field.tsx +808 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-field.tsx +127 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/field-set.tsx +14 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/file-field.tsx +321 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/file-upload-context.tsx +45 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/form-context.tsx +19 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/lookup-field.tsx +394 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/radio-field.tsx +96 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/select-field.tsx +106 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/text-field.tsx +245 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/button.tsx +63 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/checkbox.tsx +31 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/command.tsx +101 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/field.tsx +275 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/input.tsx +29 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/label.tsx +23 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/popover.tsx +31 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/separator.tsx +27 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/textarea.tsx +19 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/utils/utils.ts +4 -0
- package/dist/dashboard-source.json +70 -0
- package/dist/graphql-server.mjs +1319 -0
- package/dist/job-worker.mjs +989 -0
- package/dist/main.mjs +495 -0
- package/dist/prepare-dashboard.mjs +35 -0
- package/dist/resources/cedar/policies.cedar +315 -0
- package/dist/resources/cedar/schema.cedarschema +276 -0
- package/dist/resources/graphql-schema/rxdb.graphql +401 -0
- package/dist/resources/graphql-schema/system.graphql +1200 -0
- package/package.json +98 -0
|
@@ -0,0 +1,878 @@
|
|
|
1
|
+
import type { Edge, Node } from "@xyflow/react"
|
|
2
|
+
import { ROLE_LABEL_WIDTH } from "./constants.ts"
|
|
3
|
+
import type {
|
|
4
|
+
WorkflowPhaseInfo,
|
|
5
|
+
WorkflowStepData,
|
|
6
|
+
WorkflowSwimlaneData,
|
|
7
|
+
} from "./types.ts"
|
|
8
|
+
import type { ProcessWorkflowQuery } from "@/lib/generated/gql/graphql"
|
|
9
|
+
|
|
10
|
+
// Layout constants
|
|
11
|
+
const INITIAL_SWIMLANE_HEIGHT = 160 // Generous initial height before measurement
|
|
12
|
+
const STEP_WIDTH = 280
|
|
13
|
+
export const DEFAULT_STEP_GAP = 80
|
|
14
|
+
const SWIMLANE_PADDING = 24 // Vertical padding around steps
|
|
15
|
+
const STACKED_STEP_GAP = 16 // Gap between vertically stacked steps in same column
|
|
16
|
+
export const BRANCH_TRACK_GAP = 16
|
|
17
|
+
// Keep this estimate aligned with the rendered edge-label font size and family.
|
|
18
|
+
const EDGE_LABEL_ESTIMATED_CHAR_WIDTH = 6.5
|
|
19
|
+
const EDGE_LABEL_MIN_WRAP_WIDTH = 120
|
|
20
|
+
const EDGE_LABEL_MAX_WRAP_WIDTH = 180
|
|
21
|
+
const EDGE_LABEL_HORIZONTAL_MARGIN = 16
|
|
22
|
+
|
|
23
|
+
// Exported constants for container height calculation
|
|
24
|
+
export const SWIMLANE_VERTICAL_GAP = 20
|
|
25
|
+
export const CONTAINER_PADDING = 40
|
|
26
|
+
export const MIN_CONTAINER_HEIGHT = 400
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Result of layout functions including nodes, edges, and phase info.
|
|
30
|
+
*/
|
|
31
|
+
interface LayoutResult {
|
|
32
|
+
nodes: Array<Node<WorkflowStepData> | Node<WorkflowSwimlaneData>>
|
|
33
|
+
edges: Edge[]
|
|
34
|
+
phases: WorkflowPhaseInfo[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface StepCell {
|
|
38
|
+
roleId: string
|
|
39
|
+
track: number
|
|
40
|
+
column: number
|
|
41
|
+
steps: Node[]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type WorkflowData = NonNullable<ProcessWorkflowQuery["processWorkflow"]>
|
|
45
|
+
type WorkflowFlow = WorkflowData["flows"][number]
|
|
46
|
+
type FlowDirection = "up" | "straight" | "down"
|
|
47
|
+
type WorkflowHandleSlot = WorkflowStepData["sourceHandleSlots"][number]
|
|
48
|
+
|
|
49
|
+
const SYSTEM_ROLE_ID = "__system__"
|
|
50
|
+
const SYSTEM_ROLE_NAME = "SYSTEM"
|
|
51
|
+
const ANONYMOUS_SWIMLANE_SUFFIX = "__anonymous__"
|
|
52
|
+
const ANONYMOUS_SWIMLANE_NAME = "Anonymous"
|
|
53
|
+
// Exact same-row flows share a Y; keep this below the 1px same-cell tie-breaker.
|
|
54
|
+
const STRAIGHT_LINE_Y_TOLERANCE_PX = 0.5
|
|
55
|
+
|
|
56
|
+
function getFlowLabel(flow: WorkflowFlow): string | undefined {
|
|
57
|
+
if (flow.condition) return flow.condition
|
|
58
|
+
if (flow.isOnError) {
|
|
59
|
+
return flow.taggedErrors && flow.taggedErrors.length > 0
|
|
60
|
+
? `onError(${flow.taggedErrors.join(", ")})`
|
|
61
|
+
: "onError"
|
|
62
|
+
}
|
|
63
|
+
if (flow.isElse) return "else"
|
|
64
|
+
return flow.schedule ?? undefined
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function getOrderedHandleSlots(
|
|
68
|
+
slots: ReadonlySet<WorkflowHandleSlot> | undefined,
|
|
69
|
+
): WorkflowHandleSlot[] {
|
|
70
|
+
if (!slots) return []
|
|
71
|
+
|
|
72
|
+
return (["top", "middle", "bottom"] as const).filter((slot) =>
|
|
73
|
+
slots.has(slot),
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function getFlowDirection(
|
|
78
|
+
sourceY: number | undefined,
|
|
79
|
+
targetY: number | undefined,
|
|
80
|
+
isStraight: boolean,
|
|
81
|
+
): FlowDirection {
|
|
82
|
+
if (isStraight || sourceY === undefined || targetY === undefined) {
|
|
83
|
+
return "straight"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (targetY < sourceY) return "up"
|
|
87
|
+
if (targetY > sourceY) return "down"
|
|
88
|
+
return "straight"
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getPreferredSourceHandleSlot(
|
|
92
|
+
direction: FlowDirection,
|
|
93
|
+
): WorkflowHandleSlot {
|
|
94
|
+
if (direction === "up") return "top"
|
|
95
|
+
if (direction === "down") return "bottom"
|
|
96
|
+
return "middle"
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function getPreferredTargetHandleSlot(
|
|
100
|
+
direction: FlowDirection,
|
|
101
|
+
): WorkflowHandleSlot {
|
|
102
|
+
if (direction === "up") return "bottom"
|
|
103
|
+
if (direction === "down") return "top"
|
|
104
|
+
return "middle"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function assignHandleSlots(
|
|
108
|
+
flows: ReadonlyArray<WorkflowFlow>,
|
|
109
|
+
getPreferredSlot: (flow: WorkflowFlow) => WorkflowHandleSlot,
|
|
110
|
+
): Map<string, WorkflowHandleSlot> {
|
|
111
|
+
const assignedSlots = new Map<string, WorkflowHandleSlot>()
|
|
112
|
+
const remainingTwoSlots: WorkflowHandleSlot[] = ["top", "bottom"]
|
|
113
|
+
const remainingThreeSlots: WorkflowHandleSlot[] = ["top", "middle", "bottom"]
|
|
114
|
+
|
|
115
|
+
if (flows.length <= 1) {
|
|
116
|
+
const flow = flows[0]
|
|
117
|
+
if (flow) assignedSlots.set(flow.id, "middle")
|
|
118
|
+
return assignedSlots
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (flows.length > 3) {
|
|
122
|
+
// More than three flows may share anchors; preserving up/down direction is
|
|
123
|
+
// more important than forcing every line onto a distinct slot.
|
|
124
|
+
for (const flow of flows) {
|
|
125
|
+
assignedSlots.set(flow.id, getPreferredSlot(flow))
|
|
126
|
+
}
|
|
127
|
+
return assignedSlots
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const remainingSlots =
|
|
131
|
+
flows.length === 2 ? remainingTwoSlots : remainingThreeSlots
|
|
132
|
+
const usedSlots = new Set<WorkflowHandleSlot>()
|
|
133
|
+
|
|
134
|
+
for (const flow of flows) {
|
|
135
|
+
const preferredSlot = getPreferredSlot(flow)
|
|
136
|
+
if (preferredSlot === "middle") {
|
|
137
|
+
// Straight lines always stay centre-to-centre, even when there are two
|
|
138
|
+
// flows and the normal two-flow slots would otherwise be top and bottom.
|
|
139
|
+
assignedSlots.set(flow.id, "middle")
|
|
140
|
+
usedSlots.add("middle")
|
|
141
|
+
continue
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (
|
|
145
|
+
!usedSlots.has(preferredSlot) &&
|
|
146
|
+
remainingSlots.includes(preferredSlot)
|
|
147
|
+
) {
|
|
148
|
+
assignedSlots.set(flow.id, preferredSlot)
|
|
149
|
+
usedSlots.add(preferredSlot)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
for (const flow of flows) {
|
|
154
|
+
if (assignedSlots.has(flow.id)) continue
|
|
155
|
+
|
|
156
|
+
const fallbackSlot = remainingSlots.find((slot) => !usedSlots.has(slot))
|
|
157
|
+
// If all distinct slots are taken, the edge-level fallback keeps the line centred.
|
|
158
|
+
if (!fallbackSlot) continue
|
|
159
|
+
|
|
160
|
+
assignedSlots.set(flow.id, fallbackSlot)
|
|
161
|
+
usedSlots.add(fallbackSlot)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return assignedSlots
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function groupFlowsByStepId(
|
|
168
|
+
flows: ReadonlyArray<WorkflowFlow>,
|
|
169
|
+
getStepId: (flow: WorkflowFlow) => string,
|
|
170
|
+
): Map<string, WorkflowFlow[]> {
|
|
171
|
+
const flowsByStepId = new Map<string, WorkflowFlow[]>()
|
|
172
|
+
|
|
173
|
+
for (const flow of flows) {
|
|
174
|
+
const stepId = getStepId(flow)
|
|
175
|
+
const groupedFlows = flowsByStepId.get(stepId) ?? []
|
|
176
|
+
groupedFlows.push(flow)
|
|
177
|
+
flowsByStepId.set(stepId, groupedFlows)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return flowsByStepId
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function getStepDirectionYByStepId(
|
|
184
|
+
stepNodes: ReadonlyArray<Node>,
|
|
185
|
+
): Map<string, number> {
|
|
186
|
+
const directionYByStepId = new Map<string, number>()
|
|
187
|
+
const stepNodesByCell = new Map<string, Node[]>()
|
|
188
|
+
|
|
189
|
+
for (const stepNode of stepNodes) {
|
|
190
|
+
const data = stepNode.data as WorkflowStepData
|
|
191
|
+
const key = `${data.roleId}:${data.branchTrack}:${data.column}`
|
|
192
|
+
const cellStepNodes = stepNodesByCell.get(key) ?? []
|
|
193
|
+
cellStepNodes.push(stepNode)
|
|
194
|
+
stepNodesByCell.set(key, cellStepNodes)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
for (const cellStepNodes of stepNodesByCell.values()) {
|
|
198
|
+
cellStepNodes.forEach((stepNode, index) => {
|
|
199
|
+
// Initial layout stacks same-cell steps at the same Y. Use the insertion
|
|
200
|
+
// order as a deterministic pre-measurement vertical tie-breaker.
|
|
201
|
+
directionYByStepId.set(stepNode.id, stepNode.position.y + index)
|
|
202
|
+
})
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return directionYByStepId
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Returns 0 when no extra gap is needed, otherwise the wrapped label width to
|
|
209
|
+
// reserve before adding horizontal margins.
|
|
210
|
+
function estimateWrappedLabelWidth(label: string): number {
|
|
211
|
+
const normalizedLabel = label.trim().replace(/\s+/g, " ")
|
|
212
|
+
if (normalizedLabel.length === 0) return 0
|
|
213
|
+
|
|
214
|
+
const estimatedSingleLineWidth =
|
|
215
|
+
normalizedLabel.length * EDGE_LABEL_ESTIMATED_CHAR_WIDTH
|
|
216
|
+
|
|
217
|
+
if (
|
|
218
|
+
estimatedSingleLineWidth <=
|
|
219
|
+
DEFAULT_STEP_GAP - EDGE_LABEL_HORIZONTAL_MARGIN * 2
|
|
220
|
+
) {
|
|
221
|
+
return 0
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return Math.min(
|
|
225
|
+
EDGE_LABEL_MAX_WRAP_WIDTH,
|
|
226
|
+
Math.max(EDGE_LABEL_MIN_WRAP_WIDTH, estimatedSingleLineWidth),
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Create initial layout for workflow nodes.
|
|
232
|
+
* Steps are positioned at the top of swimlanes initially.
|
|
233
|
+
* After React Flow measures nodes, use applyMeasuredLayout() to center them.
|
|
234
|
+
*/
|
|
235
|
+
export function createInitialLayout(workflowData: WorkflowData): LayoutResult {
|
|
236
|
+
// Guard clause for empty workflows
|
|
237
|
+
if (workflowData.steps.length === 0) {
|
|
238
|
+
return { nodes: [], edges: [], phases: [] }
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const nodes: Array<Node<WorkflowStepData> | Node<WorkflowSwimlaneData>> = []
|
|
242
|
+
|
|
243
|
+
// Count outgoing and incoming edges per step for handle positioning
|
|
244
|
+
const outgoingEdgeCounts = new Map<string, number>()
|
|
245
|
+
const incomingEdgeCounts = new Map<string, number>()
|
|
246
|
+
for (const flow of workflowData.flows) {
|
|
247
|
+
outgoingEdgeCounts.set(
|
|
248
|
+
flow.sourceStepId,
|
|
249
|
+
(outgoingEdgeCounts.get(flow.sourceStepId) ?? 0) + 1,
|
|
250
|
+
)
|
|
251
|
+
incomingEdgeCounts.set(
|
|
252
|
+
flow.targetStepId,
|
|
253
|
+
(incomingEdgeCounts.get(flow.targetStepId) ?? 0) + 1,
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Build unique phases list sorted by phase order
|
|
258
|
+
const phaseMap = new Map<
|
|
259
|
+
string,
|
|
260
|
+
{ id: string; name: string; order: number }
|
|
261
|
+
>()
|
|
262
|
+
for (const step of workflowData.steps) {
|
|
263
|
+
if (step.phase && !phaseMap.has(step.phase.id)) {
|
|
264
|
+
phaseMap.set(step.phase.id, {
|
|
265
|
+
id: step.phase.id,
|
|
266
|
+
name: step.phase.name,
|
|
267
|
+
order: step.phase.order,
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
// Sort by order and assign color indices
|
|
272
|
+
const sortedPhases = [...phaseMap.values()].sort((a, b) => a.order - b.order)
|
|
273
|
+
const phases: WorkflowPhaseInfo[] = sortedPhases.map((phase, index) => ({
|
|
274
|
+
id: phase.id,
|
|
275
|
+
name: phase.name,
|
|
276
|
+
index, // color index based on sorted position
|
|
277
|
+
order: phase.order,
|
|
278
|
+
}))
|
|
279
|
+
// Build lookup for phaseId -> color index
|
|
280
|
+
const phaseIndexMap = new Map<string, number>()
|
|
281
|
+
for (const phase of phases) {
|
|
282
|
+
phaseIndexMap.set(phase.id, phase.index)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Build responsibility lookup by roleId (responsibility text and order)
|
|
286
|
+
const responsibilityByRoleId = new Map<
|
|
287
|
+
string,
|
|
288
|
+
{ responsibility: string; order: number | null | undefined }
|
|
289
|
+
>()
|
|
290
|
+
for (const resp of workflowData.responsibilities) {
|
|
291
|
+
responsibilityByRoleId.set(resp.roleId, {
|
|
292
|
+
responsibility: resp.responsibility,
|
|
293
|
+
order: resp.order,
|
|
294
|
+
})
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
type WorkflowStep = (typeof workflowData.steps)[number]
|
|
298
|
+
type WorkflowLane = {
|
|
299
|
+
id: string
|
|
300
|
+
name: string
|
|
301
|
+
responsibility?: string | undefined
|
|
302
|
+
order: number | null | undefined
|
|
303
|
+
encounterIndex: number
|
|
304
|
+
isSystem: boolean
|
|
305
|
+
baseRoleId: string
|
|
306
|
+
steps: WorkflowStep[]
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Group steps by display swimlane. Embedded anonymous start steps render in a
|
|
310
|
+
// separate swimlane so the process entry point is visible without hiding the
|
|
311
|
+
// underlying role's regular swimlane.
|
|
312
|
+
const lanesById = new Map<string, WorkflowLane>()
|
|
313
|
+
const stepLaneIdByStepId = new Map<string, string>()
|
|
314
|
+
workflowData.steps.forEach((step, encounterIndex) => {
|
|
315
|
+
const baseRoleId = step.role?.id ?? SYSTEM_ROLE_ID
|
|
316
|
+
const isAnonymousEmbeddedLane = Boolean(
|
|
317
|
+
step.role && step.isStartStep && step.isEmbedded,
|
|
318
|
+
)
|
|
319
|
+
const laneId = isAnonymousEmbeddedLane
|
|
320
|
+
? `${baseRoleId}${ANONYMOUS_SWIMLANE_SUFFIX}`
|
|
321
|
+
: baseRoleId
|
|
322
|
+
const laneName = step.role
|
|
323
|
+
? isAnonymousEmbeddedLane
|
|
324
|
+
? `${ANONYMOUS_SWIMLANE_NAME} / ${step.role.name}`
|
|
325
|
+
: step.role.name
|
|
326
|
+
: SYSTEM_ROLE_NAME
|
|
327
|
+
stepLaneIdByStepId.set(step.id, laneId)
|
|
328
|
+
const existingLane = lanesById.get(laneId)
|
|
329
|
+
|
|
330
|
+
if (existingLane) {
|
|
331
|
+
existingLane.steps.push(step)
|
|
332
|
+
return
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const responsibility = responsibilityByRoleId.get(baseRoleId)
|
|
336
|
+
lanesById.set(laneId, {
|
|
337
|
+
id: laneId,
|
|
338
|
+
name: laneName,
|
|
339
|
+
responsibility: responsibility?.responsibility,
|
|
340
|
+
order: responsibility?.order,
|
|
341
|
+
encounterIndex,
|
|
342
|
+
isSystem: baseRoleId === SYSTEM_ROLE_ID,
|
|
343
|
+
baseRoleId,
|
|
344
|
+
steps: [step],
|
|
345
|
+
})
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
// Sort swimlanes by responsibility order (if defined), otherwise by encounter order.
|
|
349
|
+
// Embedded anonymous swimlanes stay adjacent to their role and appear first.
|
|
350
|
+
const sortedLanes = [...lanesById.values()].sort((a, b) => {
|
|
351
|
+
if (a.isSystem) return 1
|
|
352
|
+
if (b.isSystem) return -1
|
|
353
|
+
|
|
354
|
+
if (a.order != null && b.order != null && a.order !== b.order) {
|
|
355
|
+
return a.order - b.order
|
|
356
|
+
}
|
|
357
|
+
if (a.order != null && b.order == null) return -1
|
|
358
|
+
if (a.order == null && b.order != null) return 1
|
|
359
|
+
|
|
360
|
+
if (a.baseRoleId === b.baseRoleId) {
|
|
361
|
+
const aIsAnonymousLane = a.id !== a.baseRoleId
|
|
362
|
+
const bIsAnonymousLane = b.id !== b.baseRoleId
|
|
363
|
+
|
|
364
|
+
if (aIsAnonymousLane !== bIsAnonymousLane) {
|
|
365
|
+
return aIsAnonymousLane ? -1 : 1
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return a.encounterIndex - b.encounterIndex
|
|
370
|
+
})
|
|
371
|
+
|
|
372
|
+
// Calculate swimlane width and column positions based on max column.
|
|
373
|
+
// Gaps expand only where edge labels need room to wrap without overlapping steps.
|
|
374
|
+
const maxColumn =
|
|
375
|
+
workflowData.steps.length > 0
|
|
376
|
+
? Math.max(...workflowData.steps.map((s) => s.column))
|
|
377
|
+
: 1
|
|
378
|
+
|
|
379
|
+
const stepColumnMap = new Map<string, number>()
|
|
380
|
+
for (const step of workflowData.steps) {
|
|
381
|
+
stepColumnMap.set(step.id, step.column)
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const gapWidthByColumn = new Map<number, number>()
|
|
385
|
+
for (let column = 1; column <= maxColumn; column += 1) {
|
|
386
|
+
gapWidthByColumn.set(column, DEFAULT_STEP_GAP)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
for (const flow of workflowData.flows) {
|
|
390
|
+
const label = getFlowLabel(flow)
|
|
391
|
+
if (!label) continue
|
|
392
|
+
|
|
393
|
+
const sourceColumn = stepColumnMap.get(flow.sourceStepId) ?? 1
|
|
394
|
+
const wrappedLabelWidth = estimateWrappedLabelWidth(label)
|
|
395
|
+
const requiredGapWidth = Math.max(
|
|
396
|
+
DEFAULT_STEP_GAP,
|
|
397
|
+
wrappedLabelWidth + EDGE_LABEL_HORIZONTAL_MARGIN * 2,
|
|
398
|
+
)
|
|
399
|
+
|
|
400
|
+
gapWidthByColumn.set(
|
|
401
|
+
sourceColumn,
|
|
402
|
+
Math.max(
|
|
403
|
+
gapWidthByColumn.get(sourceColumn) ?? DEFAULT_STEP_GAP,
|
|
404
|
+
requiredGapWidth,
|
|
405
|
+
),
|
|
406
|
+
)
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const branchTrackByStepId = new Map<string, number>()
|
|
410
|
+
for (const flow of workflowData.flows) {
|
|
411
|
+
const sourceLaneId = stepLaneIdByStepId.get(flow.sourceStepId)
|
|
412
|
+
const targetLaneId = stepLaneIdByStepId.get(flow.targetStepId)
|
|
413
|
+
if (
|
|
414
|
+
sourceLaneId === undefined ||
|
|
415
|
+
targetLaneId === undefined ||
|
|
416
|
+
sourceLaneId === targetLaneId
|
|
417
|
+
) {
|
|
418
|
+
continue
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
const sourceColumn = stepColumnMap.get(flow.sourceStepId)
|
|
422
|
+
const targetColumn = stepColumnMap.get(flow.targetStepId)
|
|
423
|
+
if (
|
|
424
|
+
sourceColumn === undefined ||
|
|
425
|
+
targetColumn === undefined ||
|
|
426
|
+
targetColumn <= sourceColumn + 1
|
|
427
|
+
) {
|
|
428
|
+
continue
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const crossesUnrelatedStepInSourceLane = workflowData.steps.some((step) => {
|
|
432
|
+
if (step.id === flow.sourceStepId || step.id === flow.targetStepId) {
|
|
433
|
+
return false
|
|
434
|
+
}
|
|
435
|
+
if (stepLaneIdByStepId.get(step.id) !== sourceLaneId) {
|
|
436
|
+
return false
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const stepColumn = stepColumnMap.get(step.id)
|
|
440
|
+
return (
|
|
441
|
+
stepColumn !== undefined &&
|
|
442
|
+
stepColumn > sourceColumn &&
|
|
443
|
+
stepColumn < targetColumn
|
|
444
|
+
)
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
if (crossesUnrelatedStepInSourceLane) {
|
|
448
|
+
// One alternate track covers this conservative guard; richer branch
|
|
449
|
+
// packing can be added when multiple simultaneous obstacles need it.
|
|
450
|
+
branchTrackByStepId.set(flow.sourceStepId, 1)
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const columnLeftXByColumn = new Map<number, number>()
|
|
455
|
+
let currentColumnX = ROLE_LABEL_WIDTH + DEFAULT_STEP_GAP
|
|
456
|
+
for (let column = 1; column <= maxColumn; column += 1) {
|
|
457
|
+
columnLeftXByColumn.set(column, currentColumnX)
|
|
458
|
+
currentColumnX +=
|
|
459
|
+
STEP_WIDTH + (gapWidthByColumn.get(column) ?? DEFAULT_STEP_GAP)
|
|
460
|
+
}
|
|
461
|
+
const swimlaneWidth = currentColumnX - ROLE_LABEL_WIDTH
|
|
462
|
+
|
|
463
|
+
// Create nodes for each display swimlane
|
|
464
|
+
let currentY = 0
|
|
465
|
+
for (const lane of sortedLanes) {
|
|
466
|
+
const stepsInLane = lane.steps
|
|
467
|
+
if (stepsInLane.length === 0) continue
|
|
468
|
+
|
|
469
|
+
const firstStep = stepsInLane[0]
|
|
470
|
+
if (!firstStep) continue
|
|
471
|
+
const roleId = lane.id
|
|
472
|
+
const roleName = lane.name
|
|
473
|
+
const isSystemSwimlane = lane.isSystem
|
|
474
|
+
|
|
475
|
+
// Use initial height - will be adjusted after measurement
|
|
476
|
+
const swimlaneHeight = INITIAL_SWIMLANE_HEIGHT
|
|
477
|
+
|
|
478
|
+
// Create swimlane background node - positioned at x:0 to include role label in bounds
|
|
479
|
+
const swimlaneNode: Node<WorkflowSwimlaneData> = {
|
|
480
|
+
id: `swimlane-${roleId}`,
|
|
481
|
+
type: "swimlane",
|
|
482
|
+
position: { x: 0, y: currentY },
|
|
483
|
+
data: {
|
|
484
|
+
roleId,
|
|
485
|
+
roleName,
|
|
486
|
+
responsibility: isSystemSwimlane ? undefined : lane.responsibility,
|
|
487
|
+
width: swimlaneWidth,
|
|
488
|
+
height: swimlaneHeight,
|
|
489
|
+
isSystem: isSystemSwimlane,
|
|
490
|
+
},
|
|
491
|
+
draggable: false,
|
|
492
|
+
selectable: false,
|
|
493
|
+
}
|
|
494
|
+
nodes.push(swimlaneNode)
|
|
495
|
+
|
|
496
|
+
// Create step nodes - positioned at top initially
|
|
497
|
+
for (const step of stepsInLane) {
|
|
498
|
+
const stepX = columnLeftXByColumn.get(step.column)
|
|
499
|
+
// step.column is always between 1 and maxColumn, so this lookup should exist.
|
|
500
|
+
if (stepX == null) continue
|
|
501
|
+
|
|
502
|
+
const stepNode: Node<WorkflowStepData> = {
|
|
503
|
+
id: step.id,
|
|
504
|
+
type: "workflowStep",
|
|
505
|
+
position: {
|
|
506
|
+
x: stepX,
|
|
507
|
+
y: currentY + SWIMLANE_PADDING,
|
|
508
|
+
},
|
|
509
|
+
data: {
|
|
510
|
+
id: step.id,
|
|
511
|
+
name: step.name,
|
|
512
|
+
path: step.path,
|
|
513
|
+
purpose: step.purpose,
|
|
514
|
+
roleName,
|
|
515
|
+
roleId,
|
|
516
|
+
column: step.column,
|
|
517
|
+
branchTrack: branchTrackByStepId.get(step.id) ?? 0,
|
|
518
|
+
phaseName: step.phase?.name,
|
|
519
|
+
phaseId: step.phase?.id,
|
|
520
|
+
phaseIndex: step.phase?.id
|
|
521
|
+
? phaseIndexMap.get(step.phase.id)
|
|
522
|
+
: undefined,
|
|
523
|
+
isStartStep: step.isStartStep,
|
|
524
|
+
isEmbedded: step.isEmbedded,
|
|
525
|
+
outgoingEdgeCount: outgoingEdgeCounts.get(step.id) ?? 0,
|
|
526
|
+
incomingEdgeCount: incomingEdgeCounts.get(step.id) ?? 0,
|
|
527
|
+
sourceHandleSlots: [],
|
|
528
|
+
targetHandleSlots: [],
|
|
529
|
+
isSystemStep: step.role === null,
|
|
530
|
+
},
|
|
531
|
+
draggable: false,
|
|
532
|
+
}
|
|
533
|
+
stepLaneIdByStepId.set(step.id, roleId)
|
|
534
|
+
nodes.push(stepNode)
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
currentY += swimlaneHeight + SWIMLANE_VERTICAL_GAP
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// Create edges from flows
|
|
541
|
+
const workflowStepNodes = nodes.filter((node) => node.type === "workflowStep")
|
|
542
|
+
const stepYByStepId = getStepDirectionYByStepId(workflowStepNodes)
|
|
543
|
+
const directionByFlowId = new Map<string, FlowDirection>()
|
|
544
|
+
|
|
545
|
+
for (const flow of workflowData.flows) {
|
|
546
|
+
const sourceColumn = stepColumnMap.get(flow.sourceStepId) ?? 1
|
|
547
|
+
const targetColumn = stepColumnMap.get(flow.targetStepId) ?? 1
|
|
548
|
+
const sourceY = stepYByStepId.get(flow.sourceStepId)
|
|
549
|
+
const targetY = stepYByStepId.get(flow.targetStepId)
|
|
550
|
+
const isStraight =
|
|
551
|
+
sourceY !== undefined &&
|
|
552
|
+
targetY !== undefined &&
|
|
553
|
+
Math.abs(sourceY - targetY) < STRAIGHT_LINE_Y_TOLERANCE_PX &&
|
|
554
|
+
targetColumn === sourceColumn + 1
|
|
555
|
+
|
|
556
|
+
directionByFlowId.set(
|
|
557
|
+
flow.id,
|
|
558
|
+
getFlowDirection(sourceY, targetY, isStraight),
|
|
559
|
+
)
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
const flowsBySourceStepId = groupFlowsByStepId(
|
|
563
|
+
workflowData.flows,
|
|
564
|
+
(flow) => flow.sourceStepId,
|
|
565
|
+
)
|
|
566
|
+
const flowsByTargetStepId = groupFlowsByStepId(
|
|
567
|
+
workflowData.flows,
|
|
568
|
+
(flow) => flow.targetStepId,
|
|
569
|
+
)
|
|
570
|
+
const sourceHandleSlotByFlowId = new Map<string, WorkflowHandleSlot>()
|
|
571
|
+
const targetHandleSlotByFlowId = new Map<string, WorkflowHandleSlot>()
|
|
572
|
+
|
|
573
|
+
for (const flows of flowsBySourceStepId.values()) {
|
|
574
|
+
const assignedSlots = assignHandleSlots(flows, (flow) =>
|
|
575
|
+
getPreferredSourceHandleSlot(
|
|
576
|
+
directionByFlowId.get(flow.id) ?? "straight",
|
|
577
|
+
),
|
|
578
|
+
)
|
|
579
|
+
for (const [flowId, slot] of assignedSlots) {
|
|
580
|
+
sourceHandleSlotByFlowId.set(flowId, slot)
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
for (const flows of flowsByTargetStepId.values()) {
|
|
585
|
+
const assignedSlots = assignHandleSlots(flows, (flow) =>
|
|
586
|
+
getPreferredTargetHandleSlot(
|
|
587
|
+
directionByFlowId.get(flow.id) ?? "straight",
|
|
588
|
+
),
|
|
589
|
+
)
|
|
590
|
+
for (const [flowId, slot] of assignedSlots) {
|
|
591
|
+
targetHandleSlotByFlowId.set(flowId, slot)
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
const sourceHandleSlotsByStepId = new Map<string, Set<WorkflowHandleSlot>>()
|
|
596
|
+
const targetHandleSlotsByStepId = new Map<string, Set<WorkflowHandleSlot>>()
|
|
597
|
+
for (const flow of workflowData.flows) {
|
|
598
|
+
const sourceSlot = sourceHandleSlotByFlowId.get(flow.id) ?? "middle"
|
|
599
|
+
const targetSlot = targetHandleSlotByFlowId.get(flow.id) ?? "middle"
|
|
600
|
+
const sourceSlots =
|
|
601
|
+
sourceHandleSlotsByStepId.get(flow.sourceStepId) ??
|
|
602
|
+
new Set<WorkflowHandleSlot>()
|
|
603
|
+
const targetSlots =
|
|
604
|
+
targetHandleSlotsByStepId.get(flow.targetStepId) ??
|
|
605
|
+
new Set<WorkflowHandleSlot>()
|
|
606
|
+
|
|
607
|
+
sourceSlots.add(sourceSlot)
|
|
608
|
+
targetSlots.add(targetSlot)
|
|
609
|
+
sourceHandleSlotsByStepId.set(flow.sourceStepId, sourceSlots)
|
|
610
|
+
targetHandleSlotsByStepId.set(flow.targetStepId, targetSlots)
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
for (const node of workflowStepNodes) {
|
|
614
|
+
const data = node.data as WorkflowStepData
|
|
615
|
+
node.data = {
|
|
616
|
+
...data,
|
|
617
|
+
sourceHandleSlots: getOrderedHandleSlots(
|
|
618
|
+
sourceHandleSlotsByStepId.get(node.id),
|
|
619
|
+
),
|
|
620
|
+
targetHandleSlots: getOrderedHandleSlots(
|
|
621
|
+
targetHandleSlotsByStepId.get(node.id),
|
|
622
|
+
),
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// Track edge index per source for spreading multiple edges in the gap
|
|
627
|
+
const sourceEdgeIndex = new Map<string, number>()
|
|
628
|
+
|
|
629
|
+
const edges: Edge[] = workflowData.flows.map((flow) => {
|
|
630
|
+
// Get edge index for spreading multiple edges from same source
|
|
631
|
+
const edgeIdx = sourceEdgeIndex.get(flow.sourceStepId) ?? 0
|
|
632
|
+
sourceEdgeIndex.set(flow.sourceStepId, edgeIdx + 1)
|
|
633
|
+
|
|
634
|
+
// Get total outgoing edges from source for spreading
|
|
635
|
+
const totalFromSource = outgoingEdgeCounts.get(flow.sourceStepId) ?? 1
|
|
636
|
+
|
|
637
|
+
// Get column info for routing
|
|
638
|
+
const sourceColumn = stepColumnMap.get(flow.sourceStepId) ?? 1
|
|
639
|
+
const targetColumn = stepColumnMap.get(flow.targetStepId) ?? 1
|
|
640
|
+
const gapWidth = gapWidthByColumn.get(sourceColumn) ?? DEFAULT_STEP_GAP
|
|
641
|
+
const sourceLaneId = stepLaneIdByStepId.get(flow.sourceStepId)
|
|
642
|
+
const targetLaneId = stepLaneIdByStepId.get(flow.targetStepId)
|
|
643
|
+
// Forward edges read best when they turn in the gap before the target step.
|
|
644
|
+
// We compute that preceding gap for every edge, but only forward cross-lane
|
|
645
|
+
// routes use it. `gapWidthByColumn` stores the gap after each column, so the
|
|
646
|
+
// gap before `targetColumn` lives at `targetColumn - 1`.
|
|
647
|
+
const targetPrecedingGapWidth =
|
|
648
|
+
targetColumn > 1
|
|
649
|
+
? (gapWidthByColumn.get(targetColumn - 1) ?? DEFAULT_STEP_GAP)
|
|
650
|
+
: DEFAULT_STEP_GAP
|
|
651
|
+
const label = getFlowLabel(flow)
|
|
652
|
+
|
|
653
|
+
return {
|
|
654
|
+
id: flow.id,
|
|
655
|
+
source: flow.sourceStepId,
|
|
656
|
+
target: flow.targetStepId,
|
|
657
|
+
sourceHandle: `source-${sourceHandleSlotByFlowId.get(flow.id) ?? "middle"}`,
|
|
658
|
+
targetHandle: `target-${targetHandleSlotByFlowId.get(flow.id) ?? "middle"}`,
|
|
659
|
+
type: "workflow",
|
|
660
|
+
style: { strokeWidth: 2 },
|
|
661
|
+
// Label priority: condition text > onError > else > schedule
|
|
662
|
+
label,
|
|
663
|
+
labelStyle: { fontSize: 11, fill: "#64748b" },
|
|
664
|
+
labelBgStyle: { fill: "#f8fafc", stroke: "#e2e8f0" },
|
|
665
|
+
labelBgPadding: [4, 2] as [number, number],
|
|
666
|
+
labelBgBorderRadius: 4,
|
|
667
|
+
// Custom data for edge routing
|
|
668
|
+
data: {
|
|
669
|
+
edgeIndex: edgeIdx,
|
|
670
|
+
totalEdges: totalFromSource,
|
|
671
|
+
sourceColumn,
|
|
672
|
+
targetColumn,
|
|
673
|
+
gapWidth,
|
|
674
|
+
targetPrecedingGapWidth,
|
|
675
|
+
labelMaxWidth:
|
|
676
|
+
label && gapWidth > DEFAULT_STEP_GAP
|
|
677
|
+
? gapWidth - EDGE_LABEL_HORIZONTAL_MARGIN * 2
|
|
678
|
+
: undefined,
|
|
679
|
+
isCrossLane:
|
|
680
|
+
sourceLaneId !== undefined &&
|
|
681
|
+
targetLaneId !== undefined &&
|
|
682
|
+
sourceLaneId !== targetLaneId,
|
|
683
|
+
isOnError: flow.isOnError,
|
|
684
|
+
isConditional: (!!flow.condition || flow.isElse) && !flow.schedule,
|
|
685
|
+
isScheduled: !!flow.schedule && !flow.condition && !flow.isElse,
|
|
686
|
+
isConditionalAndScheduled:
|
|
687
|
+
(!!flow.condition || flow.isElse) && !!flow.schedule,
|
|
688
|
+
},
|
|
689
|
+
}
|
|
690
|
+
})
|
|
691
|
+
|
|
692
|
+
return { nodes, edges, phases }
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Apply measured layout to nodes.
|
|
697
|
+
* Uses actual measured heights to:
|
|
698
|
+
* 1. Set swimlane heights based on max column height (accounting for stacked steps)
|
|
699
|
+
* 2. Vertically center single steps, or center stacked groups within their swimlanes
|
|
700
|
+
*
|
|
701
|
+
* @param nodes - Nodes with measured dimensions from React Flow
|
|
702
|
+
* @returns Repositioned nodes with correct vertical centering
|
|
703
|
+
*/
|
|
704
|
+
export function applyMeasuredLayout(
|
|
705
|
+
nodes: Node[],
|
|
706
|
+
): Array<Node<WorkflowStepData> | Node<WorkflowSwimlaneData>> {
|
|
707
|
+
// Separate swimlanes and steps
|
|
708
|
+
const swimlanes = nodes.filter((n) => n.type === "swimlane")
|
|
709
|
+
const steps = nodes.filter((n) => n.type === "workflowStep")
|
|
710
|
+
|
|
711
|
+
const getStepStackHeight = (stepsInCell: Node[]) => {
|
|
712
|
+
const stepsHeight = stepsInCell.reduce(
|
|
713
|
+
(height, step) => height + (step.measured?.height ?? 0),
|
|
714
|
+
0,
|
|
715
|
+
)
|
|
716
|
+
|
|
717
|
+
return stepsInCell.length > 1
|
|
718
|
+
? stepsHeight + (stepsInCell.length - 1) * STACKED_STEP_GAP
|
|
719
|
+
: stepsHeight
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// Group steps by (roleId, branchTrack, column) to identify stacked steps while
|
|
723
|
+
// keeping alternate branches on stable vertical tracks across columns.
|
|
724
|
+
const stepsByRoleTrackAndColumn = new Map<string, StepCell>()
|
|
725
|
+
|
|
726
|
+
for (const step of steps) {
|
|
727
|
+
const data = step.data as WorkflowStepData
|
|
728
|
+
const key = `${data.roleId}:${data.branchTrack}:${data.column}`
|
|
729
|
+
const existing = stepsByRoleTrackAndColumn.get(key)
|
|
730
|
+
if (existing) {
|
|
731
|
+
existing.steps.push(step)
|
|
732
|
+
continue
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
stepsByRoleTrackAndColumn.set(key, {
|
|
736
|
+
roleId: data.roleId,
|
|
737
|
+
track: data.branchTrack,
|
|
738
|
+
column: data.column,
|
|
739
|
+
steps: [step],
|
|
740
|
+
})
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// Calculate required height per branch track and swimlane.
|
|
744
|
+
const trackHeightByRoleId = new Map<string, Map<number, number>>()
|
|
745
|
+
|
|
746
|
+
for (const cell of stepsByRoleTrackAndColumn.values()) {
|
|
747
|
+
const cellHeight = getStepStackHeight(cell.steps)
|
|
748
|
+
const trackHeights = trackHeightByRoleId.get(cell.roleId) ?? new Map()
|
|
749
|
+
const currentTrackHeight = trackHeights.get(cell.track) ?? 0
|
|
750
|
+
if (cellHeight > currentTrackHeight) {
|
|
751
|
+
trackHeights.set(cell.track, cellHeight)
|
|
752
|
+
}
|
|
753
|
+
trackHeightByRoleId.set(cell.roleId, trackHeights)
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// Calculate new swimlane positions and heights
|
|
757
|
+
const swimlaneInfo = new Map<
|
|
758
|
+
string,
|
|
759
|
+
{
|
|
760
|
+
y: number
|
|
761
|
+
height: number
|
|
762
|
+
roleId: string
|
|
763
|
+
trackLayouts: Map<number, { y: number; height: number }>
|
|
764
|
+
}
|
|
765
|
+
>()
|
|
766
|
+
let currentY = 0
|
|
767
|
+
|
|
768
|
+
// Sort swimlanes by their current Y position to maintain order
|
|
769
|
+
const sortedSwimlanes = [...swimlanes].sort(
|
|
770
|
+
(a, b) => a.position.y - b.position.y,
|
|
771
|
+
)
|
|
772
|
+
|
|
773
|
+
for (const swimlane of sortedSwimlanes) {
|
|
774
|
+
const roleId = (swimlane.data as WorkflowSwimlaneData).roleId
|
|
775
|
+
const trackHeights = trackHeightByRoleId.get(roleId) ?? new Map([[0, 0]])
|
|
776
|
+
const sortedTrackHeights = [...trackHeights.entries()].sort(
|
|
777
|
+
([trackA], [trackB]) => trackA - trackB,
|
|
778
|
+
)
|
|
779
|
+
const totalTrackHeight = sortedTrackHeights.reduce(
|
|
780
|
+
(height, [, trackHeight]) => height + trackHeight,
|
|
781
|
+
0,
|
|
782
|
+
)
|
|
783
|
+
const trackGapHeight =
|
|
784
|
+
sortedTrackHeights.length > 1
|
|
785
|
+
? (sortedTrackHeights.length - 1) * BRANCH_TRACK_GAP
|
|
786
|
+
: 0
|
|
787
|
+
const branchTracksHeight = totalTrackHeight + trackGapHeight
|
|
788
|
+
const swimlaneHeight = Math.max(
|
|
789
|
+
INITIAL_SWIMLANE_HEIGHT,
|
|
790
|
+
branchTracksHeight + SWIMLANE_PADDING * 2,
|
|
791
|
+
)
|
|
792
|
+
const trackLayouts = new Map<number, { y: number; height: number }>()
|
|
793
|
+
let currentTrackY = currentY + (swimlaneHeight - branchTracksHeight) / 2
|
|
794
|
+
|
|
795
|
+
for (const [track, trackHeight] of sortedTrackHeights) {
|
|
796
|
+
trackLayouts.set(track, { y: currentTrackY, height: trackHeight })
|
|
797
|
+
currentTrackY += trackHeight + BRANCH_TRACK_GAP
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
swimlaneInfo.set(swimlane.id, {
|
|
801
|
+
y: currentY,
|
|
802
|
+
height: swimlaneHeight,
|
|
803
|
+
roleId,
|
|
804
|
+
trackLayouts,
|
|
805
|
+
})
|
|
806
|
+
|
|
807
|
+
currentY += swimlaneHeight + SWIMLANE_VERTICAL_GAP
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// Build new nodes array with updated positions
|
|
811
|
+
const newNodes: Array<Node<WorkflowStepData> | Node<WorkflowSwimlaneData>> =
|
|
812
|
+
[]
|
|
813
|
+
|
|
814
|
+
// Update swimlanes with new heights and positions
|
|
815
|
+
for (const swimlane of swimlanes) {
|
|
816
|
+
const info = swimlaneInfo.get(swimlane.id)
|
|
817
|
+
if (!info) continue
|
|
818
|
+
|
|
819
|
+
const newSwimlane: Node<WorkflowSwimlaneData> = {
|
|
820
|
+
...swimlane,
|
|
821
|
+
position: { ...swimlane.position, y: info.y },
|
|
822
|
+
data: {
|
|
823
|
+
...(swimlane.data as WorkflowSwimlaneData),
|
|
824
|
+
height: info.height,
|
|
825
|
+
},
|
|
826
|
+
}
|
|
827
|
+
newNodes.push(newSwimlane)
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// Update steps with proper vertical positions.
|
|
831
|
+
for (const cell of stepsByRoleTrackAndColumn.values()) {
|
|
832
|
+
const swimlaneId = `swimlane-${cell.roleId}`
|
|
833
|
+
const info = swimlaneInfo.get(swimlaneId)
|
|
834
|
+
if (!info) continue
|
|
835
|
+
const trackLayout = info.trackLayouts.get(cell.track)
|
|
836
|
+
if (!trackLayout) continue
|
|
837
|
+
|
|
838
|
+
if (cell.steps.length === 1) {
|
|
839
|
+
// Single step: center it vertically
|
|
840
|
+
const step = cell.steps[0]
|
|
841
|
+
if (!step) continue
|
|
842
|
+
|
|
843
|
+
const stepHeight = step.measured?.height ?? 0
|
|
844
|
+
const centeredY = trackLayout.y + (trackLayout.height - stepHeight) / 2
|
|
845
|
+
|
|
846
|
+
const newStep: Node<WorkflowStepData> = {
|
|
847
|
+
...step,
|
|
848
|
+
position: { ...step.position, y: centeredY },
|
|
849
|
+
data: step.data as WorkflowStepData,
|
|
850
|
+
}
|
|
851
|
+
newNodes.push(newStep)
|
|
852
|
+
} else {
|
|
853
|
+
// Multiple steps: stack them vertically, centered as a group
|
|
854
|
+
const totalStackHeight = getStepStackHeight(cell.steps)
|
|
855
|
+
|
|
856
|
+
// Calculate starting Y to center the stack within its branch track
|
|
857
|
+
const stackStartY =
|
|
858
|
+
trackLayout.y + (trackLayout.height - totalStackHeight) / 2
|
|
859
|
+
|
|
860
|
+
// Position each step in the stack
|
|
861
|
+
let currentStepY = stackStartY
|
|
862
|
+
for (const step of cell.steps) {
|
|
863
|
+
const stepHeight = step.measured?.height ?? 0
|
|
864
|
+
|
|
865
|
+
const newStep: Node<WorkflowStepData> = {
|
|
866
|
+
...step,
|
|
867
|
+
position: { ...step.position, y: currentStepY },
|
|
868
|
+
data: step.data as WorkflowStepData,
|
|
869
|
+
}
|
|
870
|
+
newNodes.push(newStep)
|
|
871
|
+
|
|
872
|
+
currentStepY += stepHeight + STACKED_STEP_GAP
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
return newNodes
|
|
878
|
+
}
|