@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,989 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
layer,
|
|
4
|
+
ExecutorError,
|
|
5
|
+
ExecutorHost,
|
|
6
|
+
FileResolutionHost,
|
|
7
|
+
DEFAULT_VISIBILITY_TIMEOUT,
|
|
8
|
+
QueueService,
|
|
9
|
+
jobHandler,
|
|
10
|
+
makeJobDispatcher,
|
|
11
|
+
Runtime,
|
|
12
|
+
makeServerPluginJobLayer,
|
|
13
|
+
SqlClient,
|
|
14
|
+
CurrentPrincipal,
|
|
15
|
+
RequestTime,
|
|
16
|
+
layer2,
|
|
17
|
+
ConditionEvaluator,
|
|
18
|
+
makeConditionEvaluator,
|
|
19
|
+
ForEachItemsResolver,
|
|
20
|
+
makeForEachItemsResolver,
|
|
21
|
+
OrganisationProvider,
|
|
22
|
+
OrganisationProviderFromPath,
|
|
23
|
+
OrganisationProviderFromPathDev,
|
|
24
|
+
ScheduleEvaluator,
|
|
25
|
+
makeScheduleEvaluator,
|
|
26
|
+
SystemStepExecutor,
|
|
27
|
+
makeSystemStepExecutor,
|
|
28
|
+
CedarPoliciesProvider,
|
|
29
|
+
OrgCedarPoliciesProvider,
|
|
30
|
+
LOCAL_SQLITE_BUSY_TIMEOUT_MS,
|
|
31
|
+
sql,
|
|
32
|
+
eq,
|
|
33
|
+
and,
|
|
34
|
+
or,
|
|
35
|
+
lt,
|
|
36
|
+
lte,
|
|
37
|
+
inArray,
|
|
38
|
+
isNull,
|
|
39
|
+
desc,
|
|
40
|
+
jobQueue,
|
|
41
|
+
TypedSqliteDrizzle,
|
|
42
|
+
TypedSqliteDrizzleLayer,
|
|
43
|
+
FLOW_EXECUTION_QUEUE,
|
|
44
|
+
TODO_EVENT_QUEUE,
|
|
45
|
+
PROCESS_EVENT_QUEUE,
|
|
46
|
+
EXECUTION_EVENT_QUEUE,
|
|
47
|
+
SYSTEM_STEP_EXECUTION_QUEUE,
|
|
48
|
+
NOTIFICATION_DELIVERY_QUEUE,
|
|
49
|
+
UserDetails,
|
|
50
|
+
SqliteCompletedJobOperationsLive,
|
|
51
|
+
SqliteFileOperationsLive,
|
|
52
|
+
SqliteFlowExecutionOperationsLive,
|
|
53
|
+
SqliteGraphqlDbOperationsLive,
|
|
54
|
+
SqliteScheduledFlowOperationsLive,
|
|
55
|
+
DEFAULT_GRAPHQL_PORT,
|
|
56
|
+
GRAPHQL_PORT_FILE,
|
|
57
|
+
decodePortFromFileContent,
|
|
58
|
+
makeLocalSqlClientLayer,
|
|
59
|
+
LocalCedarConfigStatic,
|
|
60
|
+
LocalCedarConfigHotReload,
|
|
61
|
+
LocalCedarAuthorizationLive
|
|
62
|
+
} from "./chunk-9weqs8n8.js";
|
|
63
|
+
import {
|
|
64
|
+
HttpClient,
|
|
65
|
+
post,
|
|
66
|
+
setHeader,
|
|
67
|
+
bodyJson,
|
|
68
|
+
filterStatusOk,
|
|
69
|
+
TodoSummaryComputationLive,
|
|
70
|
+
SlaCalculationServiceLive,
|
|
71
|
+
ExecutionCollectionOps,
|
|
72
|
+
ExecutionCollectionOpsLive,
|
|
73
|
+
ProcessCollectionOps,
|
|
74
|
+
ProcessCollectionOpsLive,
|
|
75
|
+
TodoCollectionOpsLive,
|
|
76
|
+
SqliteQueueServiceLive,
|
|
77
|
+
warnIgnoredCronDeclarations,
|
|
78
|
+
getEffectiveFrontendBaseUrl,
|
|
79
|
+
LocalDocumentStoreConfig,
|
|
80
|
+
LocalDocumentStoreServiceLive,
|
|
81
|
+
ScheduledFlowNotFoundError,
|
|
82
|
+
ExecutionFromJobPublishError,
|
|
83
|
+
ExecutionFromJobPublisher,
|
|
84
|
+
executionEventHandler,
|
|
85
|
+
makeNotificationDeliveryConfig,
|
|
86
|
+
flowExecutionHandler,
|
|
87
|
+
LoggingEmailSenderLive,
|
|
88
|
+
notificationDeliveryHandler,
|
|
89
|
+
ProcessFromJobPublishError,
|
|
90
|
+
ProcessFromJobPublisher,
|
|
91
|
+
processEventHandler,
|
|
92
|
+
systemStepExecutionHandler,
|
|
93
|
+
TodoFromJobPublishError,
|
|
94
|
+
TodoFromJobPublisher,
|
|
95
|
+
todoEventHandler,
|
|
96
|
+
buildTodoChangeEvent
|
|
97
|
+
} from "./chunk-mvkr77wp.js";
|
|
98
|
+
|
|
99
|
+
// src/job-worker/job-worker.ts
|
|
100
|
+
import { existsSync as existsSync4 } from "fs";
|
|
101
|
+
import { join as join2 } from "path";
|
|
102
|
+
import { parseArgs as utilParseArgs } from "util";
|
|
103
|
+
import * as Otel from "@effect/opentelemetry";
|
|
104
|
+
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
|
|
105
|
+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
106
|
+
import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
|
107
|
+
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
108
|
+
import {
|
|
109
|
+
Context,
|
|
110
|
+
Data as Data2,
|
|
111
|
+
DateTime as DateTime2,
|
|
112
|
+
Effect as Effect8,
|
|
113
|
+
Exit,
|
|
114
|
+
FiberRef as FiberRef2,
|
|
115
|
+
Layer as Layer6,
|
|
116
|
+
LogLevel,
|
|
117
|
+
Logger,
|
|
118
|
+
Schema as Schema2
|
|
119
|
+
} from "effect";
|
|
120
|
+
|
|
121
|
+
// src/services/docker-file-resolver.ts
|
|
122
|
+
import { Effect, Layer } from "effect";
|
|
123
|
+
var LocalFileResolutionHostLive = Layer.succeed(FileResolutionHost, {
|
|
124
|
+
resolveDownloadUrl: ({ fileId, storePrefix }) => Effect.succeed(`file:///pf/document-store/${storePrefix}/${fileId}`)
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// src/services/docker-step-runtime.ts
|
|
128
|
+
import { spawn } from "child_process";
|
|
129
|
+
import { createHash } from "crypto";
|
|
130
|
+
import { existsSync } from "fs";
|
|
131
|
+
import { mkdtemp, readFile, rm, writeFile } from "fs/promises";
|
|
132
|
+
import { homedir, tmpdir } from "os";
|
|
133
|
+
import { join, resolve } from "path";
|
|
134
|
+
import { Data, Effect as Effect2, Either, Layer as Layer2, Schema } from "effect";
|
|
135
|
+
var localInternalApiSecret = process.env["INTERNAL_API_SECRET"] ?? "dev-secret";
|
|
136
|
+
var MAX_TAIL = 16384;
|
|
137
|
+
var trimTail = (value) => value.length <= MAX_TAIL ? value : value.slice(value.length - MAX_TAIL);
|
|
138
|
+
var runCommand = (command, args) => new Promise((resolvePromise, reject) => {
|
|
139
|
+
const proc = spawn(command, [...args], {
|
|
140
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
141
|
+
});
|
|
142
|
+
let stdout = "";
|
|
143
|
+
let stderr = "";
|
|
144
|
+
proc.stdout.on("data", (chunk) => {
|
|
145
|
+
const text = chunk.toString();
|
|
146
|
+
process.stdout.write(text);
|
|
147
|
+
stdout = trimTail(stdout + text);
|
|
148
|
+
});
|
|
149
|
+
proc.stderr.on("data", (chunk) => {
|
|
150
|
+
const text = chunk.toString();
|
|
151
|
+
process.stderr.write(text);
|
|
152
|
+
stderr = trimTail(stderr + text);
|
|
153
|
+
});
|
|
154
|
+
proc.once("error", reject);
|
|
155
|
+
proc.once("close", (code) => resolvePromise({ exitCode: code ?? 1, stdout, stderr }));
|
|
156
|
+
});
|
|
157
|
+
var buildImageTag = (stepPath) => {
|
|
158
|
+
const suffix = createHash("sha256").update(stepPath).digest("hex").slice(0, 16);
|
|
159
|
+
return `pf-docker-step-${suffix}`;
|
|
160
|
+
};
|
|
161
|
+
var resolveDockerfilePath = (contextPath, dockerfile) => resolve(contextPath, dockerfile);
|
|
162
|
+
var JsonValue = Schema.parseJson(Schema.Unknown);
|
|
163
|
+
|
|
164
|
+
class DockerStepResultParseError extends Data.TaggedError("DockerStepResultParseError") {
|
|
165
|
+
}
|
|
166
|
+
var parseResult = (resultPath) => Effect2.gen(function* () {
|
|
167
|
+
const resultText = yield* Effect2.tryPromise({
|
|
168
|
+
try: () => readFile(resultPath, "utf8"),
|
|
169
|
+
catch: (cause) => new DockerStepResultParseError({
|
|
170
|
+
message: "Failed to read Docker step result envelope",
|
|
171
|
+
cause
|
|
172
|
+
})
|
|
173
|
+
});
|
|
174
|
+
return yield* Schema.decodeUnknown(JsonValue)(resultText).pipe(Effect2.map((result) => result), Effect2.mapError((cause) => new DockerStepResultParseError({
|
|
175
|
+
message: "Failed to parse Docker step result envelope",
|
|
176
|
+
cause
|
|
177
|
+
})));
|
|
178
|
+
});
|
|
179
|
+
var normalizeLogText = (value) => {
|
|
180
|
+
const trimmed = value?.trim();
|
|
181
|
+
return trimmed && trimmed.length > 0 ? trimmed : undefined;
|
|
182
|
+
};
|
|
183
|
+
var formatFailureMessage = (params) => {
|
|
184
|
+
const details = [
|
|
185
|
+
normalizeLogText(params.error),
|
|
186
|
+
normalizeLogText(params.stderrTail),
|
|
187
|
+
normalizeLogText(params.stderr),
|
|
188
|
+
normalizeLogText(params.stdoutTail),
|
|
189
|
+
normalizeLogText(params.stdout),
|
|
190
|
+
typeof params.exitCode === "number" ? `Exit code ${params.exitCode}` : undefined
|
|
191
|
+
].filter((detail, index, values) => {
|
|
192
|
+
return typeof detail === "string" && values.indexOf(detail) === index;
|
|
193
|
+
});
|
|
194
|
+
return [params.title, ...details].join(`
|
|
195
|
+
`);
|
|
196
|
+
};
|
|
197
|
+
var acquireDockerStepWorkDir = Effect2.acquireRelease(Effect2.tryPromise({
|
|
198
|
+
try: () => mkdtemp(join(tmpdir(), "pf-docker-step-")),
|
|
199
|
+
catch: (error) => new ExecutorError({
|
|
200
|
+
message: `Failed to create Docker step work directory: ${String(error)}`,
|
|
201
|
+
cause: error
|
|
202
|
+
})
|
|
203
|
+
}), (hostWorkDir) => Effect2.tryPromise({
|
|
204
|
+
try: () => rm(hostWorkDir, { recursive: true, force: true }),
|
|
205
|
+
catch: (cause) => cause
|
|
206
|
+
}).pipe(Effect2.catchAll((cause) => Effect2.logWarning("Failed to clean up Docker step work directory", {
|
|
207
|
+
hostWorkDir,
|
|
208
|
+
error: String(cause)
|
|
209
|
+
}))));
|
|
210
|
+
var makeLocalExecutorHostLayer = (orgPath, options) => {
|
|
211
|
+
const executeCommand = options?.runCommand ?? runCommand;
|
|
212
|
+
return Layer2.succeed(ExecutorHost, {
|
|
213
|
+
run: (invocation, jobContext) => Effect2.scoped(Effect2.gen(function* () {
|
|
214
|
+
const contextPath = resolve(orgPath, invocation.source.context);
|
|
215
|
+
const dockerfilePath = resolveDockerfilePath(contextPath, invocation.source.definition);
|
|
216
|
+
const imageTag = buildImageTag(jobContext.stepPath);
|
|
217
|
+
const hostWorkDir = yield* acquireDockerStepWorkDir;
|
|
218
|
+
const inputPath = join(hostWorkDir, "input.json");
|
|
219
|
+
const resultPath = join(hostWorkDir, "result.json");
|
|
220
|
+
const encodedInput = yield* Schema.encode(JsonValue)(invocation.input).pipe(Effect2.mapError((cause) => new ExecutorError({
|
|
221
|
+
message: "Failed to encode Docker step input manifest",
|
|
222
|
+
cause
|
|
223
|
+
})));
|
|
224
|
+
yield* Effect2.tryPromise({
|
|
225
|
+
try: () => writeFile(inputPath, encodedInput),
|
|
226
|
+
catch: (error) => new ExecutorError({
|
|
227
|
+
message: `Failed to write Docker step input manifest: ${String(error)}`,
|
|
228
|
+
cause: error
|
|
229
|
+
})
|
|
230
|
+
});
|
|
231
|
+
const buildResult = yield* Effect2.tryPromise({
|
|
232
|
+
try: () => executeCommand("docker", [
|
|
233
|
+
"build",
|
|
234
|
+
"-t",
|
|
235
|
+
imageTag,
|
|
236
|
+
"-f",
|
|
237
|
+
dockerfilePath,
|
|
238
|
+
contextPath
|
|
239
|
+
]),
|
|
240
|
+
catch: (error) => new ExecutorError({
|
|
241
|
+
message: `Failed to build Docker image for ${jobContext.stepPath}: ${String(error)}`,
|
|
242
|
+
cause: error
|
|
243
|
+
})
|
|
244
|
+
});
|
|
245
|
+
if (buildResult.exitCode !== 0) {
|
|
246
|
+
return yield* new ExecutorError({
|
|
247
|
+
message: formatFailureMessage({
|
|
248
|
+
title: `Docker build failed for ${jobContext.stepPath}`,
|
|
249
|
+
exitCode: buildResult.exitCode,
|
|
250
|
+
error: undefined,
|
|
251
|
+
stderrTail: undefined,
|
|
252
|
+
stdoutTail: undefined,
|
|
253
|
+
stderr: buildResult.stderr,
|
|
254
|
+
stdout: buildResult.stdout
|
|
255
|
+
})
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
const dockerRunArgs = [
|
|
259
|
+
"run",
|
|
260
|
+
"--rm",
|
|
261
|
+
"-e",
|
|
262
|
+
"PF_INPUT_URL=file:///pf/work/input.json",
|
|
263
|
+
"-e",
|
|
264
|
+
"PF_RESULT_URL=file:///pf/work/result.json",
|
|
265
|
+
"-e",
|
|
266
|
+
"PF_STEP_INPUT_PATH=/pf/input.json",
|
|
267
|
+
"-e",
|
|
268
|
+
"PF_STEP_OUTPUT_PATH=/pf/output.json",
|
|
269
|
+
"-v",
|
|
270
|
+
`${hostWorkDir}:/pf/work`,
|
|
271
|
+
"-v",
|
|
272
|
+
`${resolve(orgPath, "files")}:/pf/document-store:ro`
|
|
273
|
+
];
|
|
274
|
+
dockerRunArgs.push("-e", `INTERNAL_API_SECRET=${localInternalApiSecret}`);
|
|
275
|
+
for (const envName of [
|
|
276
|
+
"AWS_PROFILE",
|
|
277
|
+
"AWS_REGION",
|
|
278
|
+
"AWS_DEFAULT_REGION",
|
|
279
|
+
"AWS_ACCESS_KEY_ID",
|
|
280
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
281
|
+
"AWS_SESSION_TOKEN"
|
|
282
|
+
]) {
|
|
283
|
+
const value = process.env[envName];
|
|
284
|
+
if (value) {
|
|
285
|
+
dockerRunArgs.push("-e", `${envName}=${value}`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const awsDir = join(homedir(), ".aws");
|
|
289
|
+
if (existsSync(awsDir)) {
|
|
290
|
+
dockerRunArgs.push("-v", `${awsDir}:/root/.aws:ro`);
|
|
291
|
+
}
|
|
292
|
+
dockerRunArgs.push(imageTag);
|
|
293
|
+
const runResult = yield* Effect2.tryPromise({
|
|
294
|
+
try: () => executeCommand("docker", dockerRunArgs),
|
|
295
|
+
catch: (error) => new ExecutorError({
|
|
296
|
+
message: `Failed to run Docker container for ${jobContext.stepPath}: ${String(error)}`,
|
|
297
|
+
cause: error
|
|
298
|
+
})
|
|
299
|
+
});
|
|
300
|
+
const resultEither = yield* Effect2.either(parseResult(resultPath).pipe(Effect2.mapError((error) => new DockerStepResultParseError({
|
|
301
|
+
message: `Failed to parse Docker step result for ${jobContext.stepPath}: ${String(error)}`,
|
|
302
|
+
cause: error
|
|
303
|
+
}))));
|
|
304
|
+
if (runResult.exitCode !== 0) {
|
|
305
|
+
const result = Either.isRight(resultEither) ? resultEither.right : undefined;
|
|
306
|
+
return yield* new ExecutorError({
|
|
307
|
+
message: formatFailureMessage({
|
|
308
|
+
title: `Docker step ${jobContext.stepPath} failed`,
|
|
309
|
+
error: result?.error,
|
|
310
|
+
exitCode: result?.exitCode ?? runResult.exitCode,
|
|
311
|
+
stderrTail: result?.stderrTail,
|
|
312
|
+
stdoutTail: result?.stdoutTail,
|
|
313
|
+
stderr: runResult.stderr,
|
|
314
|
+
stdout: runResult.stdout
|
|
315
|
+
})
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
if (Either.isLeft(resultEither)) {
|
|
319
|
+
return yield* new ExecutorError({
|
|
320
|
+
message: formatFailureMessage({
|
|
321
|
+
title: resultEither.left.message,
|
|
322
|
+
error: undefined,
|
|
323
|
+
exitCode: runResult.exitCode,
|
|
324
|
+
stderrTail: undefined,
|
|
325
|
+
stdoutTail: undefined,
|
|
326
|
+
stderr: runResult.stderr,
|
|
327
|
+
stdout: runResult.stdout
|
|
328
|
+
}),
|
|
329
|
+
cause: resultEither.left
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
const result = resultEither.right;
|
|
333
|
+
if (result.status !== "success") {
|
|
334
|
+
return yield* new ExecutorError({
|
|
335
|
+
message: formatFailureMessage({
|
|
336
|
+
title: `Docker step ${jobContext.stepPath} failed`,
|
|
337
|
+
error: result.error,
|
|
338
|
+
exitCode: result.exitCode ?? runResult.exitCode,
|
|
339
|
+
stderrTail: result.stderrTail,
|
|
340
|
+
stdoutTail: result.stdoutTail,
|
|
341
|
+
stderr: runResult.stderr,
|
|
342
|
+
stdout: runResult.stdout
|
|
343
|
+
})
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
return {
|
|
347
|
+
_tag: "Completed",
|
|
348
|
+
output: typeof result.output === "object" && result.output !== null ? result.output : {}
|
|
349
|
+
};
|
|
350
|
+
}))
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
// src/services/http-execution-from-job-publisher.ts
|
|
355
|
+
import { Array as Arr, Config as Config2, Effect as Effect4, Layer as Layer3 } from "effect";
|
|
356
|
+
|
|
357
|
+
// src/services/graphql-server-config.ts
|
|
358
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
359
|
+
import { Config } from "effect";
|
|
360
|
+
var defaultGraphqlPortFileReader = {
|
|
361
|
+
existsSync: existsSync2,
|
|
362
|
+
readFileSync: (path, encoding) => readFileSync(path, encoding)
|
|
363
|
+
};
|
|
364
|
+
var readGraphqlPort = (reader = defaultGraphqlPortFileReader) => {
|
|
365
|
+
if (!reader.existsSync(GRAPHQL_PORT_FILE)) {
|
|
366
|
+
return DEFAULT_GRAPHQL_PORT;
|
|
367
|
+
}
|
|
368
|
+
try {
|
|
369
|
+
const content = reader.readFileSync(GRAPHQL_PORT_FILE, "utf-8");
|
|
370
|
+
return decodePortFromFileContent(content) ?? DEFAULT_GRAPHQL_PORT;
|
|
371
|
+
} catch {
|
|
372
|
+
return DEFAULT_GRAPHQL_PORT;
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
var GraphqlServerUrl = Config.string("GRAPHQL_SERVER_URL").pipe(Config.orElse(() => Config.sync(() => {
|
|
376
|
+
const port = readGraphqlPort();
|
|
377
|
+
return `http://localhost:${port}`;
|
|
378
|
+
})));
|
|
379
|
+
|
|
380
|
+
// src/services/post-internal-event.ts
|
|
381
|
+
import { Effect as Effect3, Option } from "effect";
|
|
382
|
+
var postInternalEvent = (httpClient, baseUrl, path, event, callbackSecret, wrapError) => Effect3.gen(function* () {
|
|
383
|
+
let request = post(`${baseUrl}${path}`);
|
|
384
|
+
request = yield* bodyJson(request, event).pipe(Effect3.mapError(wrapError));
|
|
385
|
+
request = Option.match(callbackSecret, {
|
|
386
|
+
onNone: () => request,
|
|
387
|
+
onSome: (secret) => setHeader(request, "x-callback-secret", secret)
|
|
388
|
+
});
|
|
389
|
+
yield* httpClient.execute(request).pipe(Effect3.flatMap(filterStatusOk), Effect3.mapError(wrapError), Effect3.asVoid);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
// src/services/http-execution-from-job-publisher.ts
|
|
393
|
+
var HttpExecutionFromJobPublisherLive = Layer3.effect(ExecutionFromJobPublisher, Effect4.gen(function* () {
|
|
394
|
+
const executionOps = yield* ExecutionCollectionOps;
|
|
395
|
+
const httpClient = yield* HttpClient;
|
|
396
|
+
const userDetails = yield* UserDetails;
|
|
397
|
+
const sqlClient = yield* SqlClient;
|
|
398
|
+
const callbackSecret = yield* Config2.option(Config2.string("INTERNAL_API_SECRET"));
|
|
399
|
+
const baseUrl = yield* GraphqlServerUrl;
|
|
400
|
+
return {
|
|
401
|
+
publishExecutionChanged: (executionId) => Effect4.gen(function* () {
|
|
402
|
+
const graphqlExecutions = yield* sqlClient.withTransaction(Effect4.gen(function* () {
|
|
403
|
+
const executions = yield* executionOps.getByIds([executionId]);
|
|
404
|
+
return yield* Effect4.all(executions.map((execution) => executionOps.mapToGraphql(execution).pipe(Effect4.map((document) => ({
|
|
405
|
+
...document,
|
|
406
|
+
startedByEmail: execution.execution.startedByEmail,
|
|
407
|
+
startedByRolePath: execution.execution.startedByRolePath
|
|
408
|
+
})))));
|
|
409
|
+
})).pipe(Effect4.mapError((cause) => new ExecutionFromJobPublishError({
|
|
410
|
+
executionId,
|
|
411
|
+
cause
|
|
412
|
+
})));
|
|
413
|
+
if (!Arr.isNonEmptyReadonlyArray(graphqlExecutions)) {
|
|
414
|
+
return "skipped-not-found";
|
|
415
|
+
}
|
|
416
|
+
const lastExecution = Arr.lastNonEmpty(graphqlExecutions);
|
|
417
|
+
const event = {
|
|
418
|
+
documents: graphqlExecutions,
|
|
419
|
+
checkpoint: {
|
|
420
|
+
id: lastExecution.id,
|
|
421
|
+
updatedAt: lastExecution.updatedAt
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
yield* postInternalEvent(httpClient, baseUrl, "/internal/execution-event", event, callbackSecret, (cause) => new ExecutionFromJobPublishError({
|
|
425
|
+
executionId,
|
|
426
|
+
cause
|
|
427
|
+
}));
|
|
428
|
+
return "published";
|
|
429
|
+
}).pipe(Effect4.provideService(UserDetails, userDetails))
|
|
430
|
+
};
|
|
431
|
+
}));
|
|
432
|
+
|
|
433
|
+
// src/services/http-process-from-job-publisher.ts
|
|
434
|
+
import { Array as Arr2, Config as Config3, Effect as Effect5, Layer as Layer4 } from "effect";
|
|
435
|
+
var HttpProcessFromJobPublisherLive = Layer4.effect(ProcessFromJobPublisher, Effect5.gen(function* () {
|
|
436
|
+
const processOps = yield* ProcessCollectionOps;
|
|
437
|
+
const httpClient = yield* HttpClient;
|
|
438
|
+
const userDetails = yield* UserDetails;
|
|
439
|
+
const callbackSecret = yield* Config3.option(Config3.string("INTERNAL_API_SECRET"));
|
|
440
|
+
const baseUrl = yield* GraphqlServerUrl;
|
|
441
|
+
return {
|
|
442
|
+
publishProcessChanged: (processId) => Effect5.gen(function* () {
|
|
443
|
+
const processes = yield* processOps.getByIds([processId]).pipe(Effect5.mapError((cause) => new ProcessFromJobPublishError({
|
|
444
|
+
processId,
|
|
445
|
+
cause
|
|
446
|
+
})));
|
|
447
|
+
const graphqlProcesses = yield* Effect5.all(processes.map((process2) => processOps.mapToGraphql(process2))).pipe(Effect5.mapError((cause) => new ProcessFromJobPublishError({
|
|
448
|
+
processId,
|
|
449
|
+
cause
|
|
450
|
+
})));
|
|
451
|
+
if (!Arr2.isNonEmptyReadonlyArray(graphqlProcesses)) {
|
|
452
|
+
return "skipped-not-found";
|
|
453
|
+
}
|
|
454
|
+
const lastProcess = Arr2.lastNonEmpty(graphqlProcesses);
|
|
455
|
+
const event = {
|
|
456
|
+
documents: graphqlProcesses,
|
|
457
|
+
checkpoint: {
|
|
458
|
+
id: lastProcess.id,
|
|
459
|
+
updatedAt: lastProcess.updatedAt
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
yield* postInternalEvent(httpClient, baseUrl, "/internal/process-event", event, callbackSecret, (cause) => new ProcessFromJobPublishError({
|
|
463
|
+
processId,
|
|
464
|
+
cause
|
|
465
|
+
}));
|
|
466
|
+
return "published";
|
|
467
|
+
}).pipe(Effect5.provideService(UserDetails, userDetails))
|
|
468
|
+
};
|
|
469
|
+
}));
|
|
470
|
+
|
|
471
|
+
// src/services/http-todo-from-job-publisher.ts
|
|
472
|
+
import { Config as Config4, Effect as Effect6, Layer as Layer5 } from "effect";
|
|
473
|
+
var HttpTodoFromJobPublisherLive = Layer5.effect(TodoFromJobPublisher, Effect6.gen(function* () {
|
|
474
|
+
const httpClient = yield* HttpClient;
|
|
475
|
+
const callbackSecret = yield* Config4.option(Config4.string("INTERNAL_API_SECRET"));
|
|
476
|
+
const baseUrl = yield* GraphqlServerUrl;
|
|
477
|
+
return {
|
|
478
|
+
publishTodosCreated: (todos) => Effect6.gen(function* () {
|
|
479
|
+
const event = buildTodoChangeEvent(todos);
|
|
480
|
+
if (!event) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
const todoIds = todos.map((t) => t.id);
|
|
484
|
+
yield* postInternalEvent(httpClient, baseUrl, "/internal/todo-event", event, callbackSecret, (cause) => new TodoFromJobPublishError({
|
|
485
|
+
todoIds,
|
|
486
|
+
cause
|
|
487
|
+
}));
|
|
488
|
+
})
|
|
489
|
+
};
|
|
490
|
+
}));
|
|
491
|
+
|
|
492
|
+
// src/job-worker/queue-poller.ts
|
|
493
|
+
import { randomUUID } from "crypto";
|
|
494
|
+
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
495
|
+
import { dirname } from "path";
|
|
496
|
+
import {
|
|
497
|
+
Cause,
|
|
498
|
+
Duration as D,
|
|
499
|
+
DateTime,
|
|
500
|
+
Effect as Effect7,
|
|
501
|
+
FiberRef,
|
|
502
|
+
Metric,
|
|
503
|
+
Option as Option2,
|
|
504
|
+
Random,
|
|
505
|
+
Ref,
|
|
506
|
+
Schedule
|
|
507
|
+
} from "effect";
|
|
508
|
+
var sleepWithJitter = (base, maxJitter) => Effect7.gen(function* () {
|
|
509
|
+
const baseMs = D.toMillis(base);
|
|
510
|
+
const maxJitterMs = D.toMillis(maxJitter);
|
|
511
|
+
const jitterMs = Math.round(((yield* Random.next) * 2 - 1) * maxJitterMs);
|
|
512
|
+
const jitteredMs = Math.max(0, baseMs + jitterMs);
|
|
513
|
+
yield* Effect7.sleep(D.millis(jitteredMs));
|
|
514
|
+
});
|
|
515
|
+
var MAX_POLL_JITTER = D.millis(100);
|
|
516
|
+
var MAX_SUCCESS_DELAY_JITTER = D.millis(50);
|
|
517
|
+
var PAUSED_POLL_DELAY = D.millis(100);
|
|
518
|
+
var MAX_PAUSED_POLL_JITTER = D.millis(25);
|
|
519
|
+
var SQLITE_BUSY_RETRY_SCHEDULE = Schedule.addDelay(Schedule.recurs(4), () => D.millis(50));
|
|
520
|
+
var getLocalQueueSuccessDelay = () => {
|
|
521
|
+
const configuredDelayMs = process.env["PF_LOCAL_QUEUE_SUCCESS_DELAY_MS"];
|
|
522
|
+
if (!configuredDelayMs) {
|
|
523
|
+
return Option2.none();
|
|
524
|
+
}
|
|
525
|
+
const delayMs = Number.parseInt(configuredDelayMs, 10);
|
|
526
|
+
if (!Number.isFinite(delayMs) || delayMs <= 0) {
|
|
527
|
+
return Option2.none();
|
|
528
|
+
}
|
|
529
|
+
return Option2.some(D.millis(delayMs));
|
|
530
|
+
};
|
|
531
|
+
var getLocalQueuePauseFile = () => process.env["PF_LOCAL_QUEUE_PAUSE_FILE"];
|
|
532
|
+
var getLocalQueueStateFile = () => process.env["PF_LOCAL_QUEUE_STATE_FILE"];
|
|
533
|
+
var readLocalQueuePauseToken = () => {
|
|
534
|
+
const pauseFile = getLocalQueuePauseFile();
|
|
535
|
+
if (pauseFile === undefined || pauseFile.length === 0) {
|
|
536
|
+
return null;
|
|
537
|
+
}
|
|
538
|
+
try {
|
|
539
|
+
return existsSync3(pauseFile) ? readFileSync2(pauseFile, "utf8").trim() : null;
|
|
540
|
+
} catch {
|
|
541
|
+
return null;
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
var writeLocalQueueWorkerState = (state) => Effect7.try({
|
|
545
|
+
try: () => {
|
|
546
|
+
const stateFile = getLocalQueueStateFile();
|
|
547
|
+
if (stateFile === undefined || stateFile.length === 0) {
|
|
548
|
+
return true;
|
|
549
|
+
}
|
|
550
|
+
mkdirSync(dirname(stateFile), { recursive: true });
|
|
551
|
+
writeFileSync(stateFile, `${JSON.stringify(state)}
|
|
552
|
+
`, "utf8");
|
|
553
|
+
return true;
|
|
554
|
+
},
|
|
555
|
+
catch: (error) => error instanceof Error ? error : new Error(String(error))
|
|
556
|
+
}).pipe(Effect7.catchAll((error) => Effect7.logWarning("Failed to write local queue worker state", {
|
|
557
|
+
error: String(error)
|
|
558
|
+
}).pipe(Effect7.as(false))));
|
|
559
|
+
var isSqliteBusy = (error) => {
|
|
560
|
+
let current = error;
|
|
561
|
+
while (current != null) {
|
|
562
|
+
if (current instanceof Error) {
|
|
563
|
+
if (current.message.includes("SQLITE_BUSY") || current.message.includes("database is locked") || current.message.includes("SQL statements in progress")) {
|
|
564
|
+
return true;
|
|
565
|
+
}
|
|
566
|
+
current = current.cause;
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
if (typeof current === "object" && current !== null && "message" in current && typeof current.message === "string") {
|
|
570
|
+
if (current.message.includes("SQLITE_BUSY") || current.message.includes("database is locked") || current.message.includes("SQL statements in progress")) {
|
|
571
|
+
return true;
|
|
572
|
+
}
|
|
573
|
+
current = "cause" in current ? current.cause : undefined;
|
|
574
|
+
continue;
|
|
575
|
+
}
|
|
576
|
+
if (typeof current === "string" && (current.includes("SQLITE_BUSY") || current.includes("database is locked") || current.includes("SQL statements in progress"))) {
|
|
577
|
+
return true;
|
|
578
|
+
}
|
|
579
|
+
break;
|
|
580
|
+
}
|
|
581
|
+
return false;
|
|
582
|
+
};
|
|
583
|
+
var retrySqliteBusy = (effect) => effect.pipe(Effect7.retry({
|
|
584
|
+
schedule: SQLITE_BUSY_RETRY_SCHEDULE,
|
|
585
|
+
while: isSqliteBusy
|
|
586
|
+
}));
|
|
587
|
+
var IDLE_POLL_SCHEDULE = [
|
|
588
|
+
{
|
|
589
|
+
maxIdleMs: D.toMillis(D.seconds(30)),
|
|
590
|
+
delay: D.millis(500),
|
|
591
|
+
label: "500ms"
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
maxIdleMs: D.toMillis(D.minutes(1)),
|
|
595
|
+
delay: D.seconds(1),
|
|
596
|
+
label: "1s"
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
maxIdleMs: D.toMillis(D.minutes(2)),
|
|
600
|
+
delay: D.seconds(2),
|
|
601
|
+
label: "2s"
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
maxIdleMs: Number.POSITIVE_INFINITY,
|
|
605
|
+
delay: D.seconds(3),
|
|
606
|
+
label: "3s"
|
|
607
|
+
}
|
|
608
|
+
];
|
|
609
|
+
var LAST_IDLE_POLL_STAGE = IDLE_POLL_SCHEDULE.at(-1) ?? {
|
|
610
|
+
maxIdleMs: Number.POSITIVE_INFINITY,
|
|
611
|
+
delay: D.seconds(3),
|
|
612
|
+
label: "3s"
|
|
613
|
+
};
|
|
614
|
+
var MAX_IDLE_STAGE_START_MS = IDLE_POLL_SCHEDULE.at(-2)?.maxIdleMs ?? 0;
|
|
615
|
+
var ERROR_POLL_SCHEDULE = [
|
|
616
|
+
D.millis(250),
|
|
617
|
+
D.millis(500),
|
|
618
|
+
D.seconds(1)
|
|
619
|
+
];
|
|
620
|
+
var LAST_ERROR_POLL_DELAY = ERROR_POLL_SCHEDULE.at(-1) ?? D.seconds(1);
|
|
621
|
+
var getIdlePollStage = (idleFor) => {
|
|
622
|
+
const idleMs = D.toMillis(idleFor);
|
|
623
|
+
return IDLE_POLL_SCHEDULE.find((stage) => idleMs < stage.maxIdleMs) ?? LAST_IDLE_POLL_STAGE;
|
|
624
|
+
};
|
|
625
|
+
var getPollErrorDelay = (consecutiveErrors) => {
|
|
626
|
+
const index = Math.min(Math.max(consecutiveErrors - 1, 0), ERROR_POLL_SCHEDULE.length - 1);
|
|
627
|
+
return ERROR_POLL_SCHEDULE[index] ?? LAST_ERROR_POLL_DELAY;
|
|
628
|
+
};
|
|
629
|
+
var jobsProcessed = Metric.counter("jobs.processed", {
|
|
630
|
+
description: "Number of jobs processed"
|
|
631
|
+
});
|
|
632
|
+
var jobsFailed = Metric.counter("jobs.failed", {
|
|
633
|
+
description: "Number of jobs that failed"
|
|
634
|
+
});
|
|
635
|
+
var claimNextLocalJob = (queueNames) => Effect7.gen(function* () {
|
|
636
|
+
const db = yield* TypedSqliteDrizzle;
|
|
637
|
+
const now = yield* DateTime.now;
|
|
638
|
+
const lockedUntil = DateTime.add(now, {
|
|
639
|
+
millis: D.toMillis(DEFAULT_VISIBILITY_TIMEOUT)
|
|
640
|
+
});
|
|
641
|
+
const receipt = randomUUID();
|
|
642
|
+
const claimOrder = [
|
|
643
|
+
jobQueue.jobAttempts,
|
|
644
|
+
desc(jobQueue.availableAt),
|
|
645
|
+
desc(jobQueue.id)
|
|
646
|
+
];
|
|
647
|
+
const availableJobConditions = and(inArray(jobQueue.queue, queueNames), lte(jobQueue.availableAt, now), or(isNull(jobQueue.lockedUntil), lte(jobQueue.lockedUntil, now)), lt(jobQueue.jobAttempts, jobQueue.jobRetryLimit), eq(jobQueue._deleted, false));
|
|
648
|
+
const candidate = yield* db.select({ id: jobQueue.id }).from(jobQueue).where(availableJobConditions).orderBy(...claimOrder).limit(1).pipe(retrySqliteBusy);
|
|
649
|
+
const candidateRow = candidate[0];
|
|
650
|
+
if (candidateRow === undefined) {
|
|
651
|
+
return Option2.none();
|
|
652
|
+
}
|
|
653
|
+
const result = yield* db.update(jobQueue).set({
|
|
654
|
+
lockedUntil,
|
|
655
|
+
claimReceipt: receipt,
|
|
656
|
+
jobAttempts: sql`${jobQueue.jobAttempts} + 1`
|
|
657
|
+
}).where(and(eq(jobQueue.id, candidateRow.id), availableJobConditions)).returning({
|
|
658
|
+
id: jobQueue.id,
|
|
659
|
+
queue: jobQueue.queue,
|
|
660
|
+
jobPayload: jobQueue.jobPayload,
|
|
661
|
+
jobAttempts: jobQueue.jobAttempts,
|
|
662
|
+
jobRetryLimit: jobQueue.jobRetryLimit,
|
|
663
|
+
availableAt: jobQueue.availableAt,
|
|
664
|
+
lockedUntil: jobQueue.lockedUntil
|
|
665
|
+
}).pipe(retrySqliteBusy);
|
|
666
|
+
const row = result[0];
|
|
667
|
+
if (!row) {
|
|
668
|
+
return Option2.none();
|
|
669
|
+
}
|
|
670
|
+
return Option2.some({
|
|
671
|
+
jobId: row.id,
|
|
672
|
+
receipt,
|
|
673
|
+
queue: row.queue,
|
|
674
|
+
payload: row.jobPayload,
|
|
675
|
+
attempts: row.jobAttempts,
|
|
676
|
+
maxAttempts: row.jobRetryLimit,
|
|
677
|
+
availableAt: row.availableAt,
|
|
678
|
+
lockedUntil
|
|
679
|
+
});
|
|
680
|
+
});
|
|
681
|
+
var processClaimedJob = (job, queueHandlers) => Effect7.gen(function* () {
|
|
682
|
+
const queueService = yield* QueueService;
|
|
683
|
+
const requestTimeFiberRef = yield* RequestTime;
|
|
684
|
+
const now = yield* DateTime.now;
|
|
685
|
+
yield* FiberRef.set(requestTimeFiberRef, now);
|
|
686
|
+
yield* Effect7.log(`Processing job ${job.jobId} (attempt ${job.attempts})`);
|
|
687
|
+
const dispatcher = makeJobDispatcher(queueHandlers);
|
|
688
|
+
const result = yield* Runtime.job(dispatcher, job);
|
|
689
|
+
if (result.kind === "acknowledge") {
|
|
690
|
+
yield* queueService.acknowledge(job.jobId, job.receipt).pipe(Effect7.tapErrorCause((cause) => Effect7.gen(function* () {
|
|
691
|
+
const message = Cause.pretty(cause);
|
|
692
|
+
yield* Effect7.logError(`Job ${job.jobId} acknowledgement failed: ${message}`);
|
|
693
|
+
yield* Effect7.annotateCurrentSpan("job.failed", true);
|
|
694
|
+
yield* Effect7.annotateCurrentSpan("job.error", message);
|
|
695
|
+
yield* Metric.increment(jobsFailed);
|
|
696
|
+
})), Effect7.withSpan(`job.acknowledge.${job.queue}`, {
|
|
697
|
+
attributes: {
|
|
698
|
+
"job.id": job.jobId,
|
|
699
|
+
"job.queue": job.queue,
|
|
700
|
+
"job.attempts": job.attempts
|
|
701
|
+
}
|
|
702
|
+
}));
|
|
703
|
+
yield* Metric.increment(jobsProcessed);
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
const failure = Cause.failureOption(result.cause);
|
|
707
|
+
if (Cause.isInterruptedOnly(result.cause)) {
|
|
708
|
+
return yield* Effect7.interrupt;
|
|
709
|
+
}
|
|
710
|
+
if (Option2.isSome(failure) && failure.value instanceof ScheduledFlowNotFoundError) {
|
|
711
|
+
yield* Effect7.logInfo(`Job ${job.jobId} will retry: scheduled flow not yet visible`, {
|
|
712
|
+
scheduledFlowId: failure.value.scheduledFlowId,
|
|
713
|
+
attempt: job.attempts,
|
|
714
|
+
maxAttempts: job.maxAttempts
|
|
715
|
+
});
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
yield* Effect7.logError(`Job ${job.jobId} failed: ${Cause.pretty(result.cause)}`);
|
|
719
|
+
yield* Metric.increment(jobsFailed);
|
|
720
|
+
if (result.kind === "terminal") {
|
|
721
|
+
yield* queueService.fail(job.jobId, job.receipt, { retryable: false });
|
|
722
|
+
} else if (Option2.isSome(failure)) {
|
|
723
|
+
yield* queueService.fail(job.jobId, job.receipt, {
|
|
724
|
+
releaseImmediately: false
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
var createSingleQueuePoller = (queueHandlers, globalSemaphore, options = {}) => {
|
|
729
|
+
const queueNames = Object.keys(queueHandlers);
|
|
730
|
+
const successDelay = getLocalQueueSuccessDelay();
|
|
731
|
+
const notifyWorkerState = options.onWorkerStateChange ?? (() => Effect7.void);
|
|
732
|
+
const readPauseToken = options.readPauseToken ?? readLocalQueuePauseToken;
|
|
733
|
+
const waitAfterSuccessfulJob = Option2.match(successDelay, {
|
|
734
|
+
onNone: () => Effect7.void,
|
|
735
|
+
onSome: (delay) => sleepWithJitter(delay, MAX_SUCCESS_DELAY_JITTER)
|
|
736
|
+
});
|
|
737
|
+
return Effect7.gen(function* () {
|
|
738
|
+
let idleSinceMs = null;
|
|
739
|
+
let lastIdleStageLabel = null;
|
|
740
|
+
let consecutivePollErrors = 0;
|
|
741
|
+
let hasClaimedSinceStartup = false;
|
|
742
|
+
let lastPauseState = false;
|
|
743
|
+
let lastWorkerStateSnapshot = null;
|
|
744
|
+
const activeJobsRef = yield* Ref.make(0);
|
|
745
|
+
const writeState = (paused, pauseToken) => Effect7.gen(function* () {
|
|
746
|
+
const activeJobs = yield* Ref.get(activeJobsRef);
|
|
747
|
+
const snapshot = `${activeJobs}:${paused}:${pauseToken ?? ""}`;
|
|
748
|
+
if (snapshot === lastWorkerStateSnapshot) {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
const now = yield* DateTime.now;
|
|
752
|
+
const workerState = {
|
|
753
|
+
activeJobs,
|
|
754
|
+
paused,
|
|
755
|
+
pauseToken,
|
|
756
|
+
updatedAt: DateTime.formatIso(now)
|
|
757
|
+
};
|
|
758
|
+
const written = yield* writeLocalQueueWorkerState(workerState);
|
|
759
|
+
yield* notifyWorkerState(workerState);
|
|
760
|
+
if (written) {
|
|
761
|
+
lastWorkerStateSnapshot = snapshot;
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
const waitWithPauseToken = (pauseToken) => Effect7.gen(function* () {
|
|
765
|
+
if (!lastPauseState) {
|
|
766
|
+
lastPauseState = true;
|
|
767
|
+
yield* Effect7.logDebug("Local queue poller paused by pause file");
|
|
768
|
+
}
|
|
769
|
+
yield* writeState(true, pauseToken);
|
|
770
|
+
yield* sleepWithJitter(PAUSED_POLL_DELAY, MAX_PAUSED_POLL_JITTER);
|
|
771
|
+
});
|
|
772
|
+
const waitIfPaused = Effect7.gen(function* () {
|
|
773
|
+
const pauseToken = readPauseToken();
|
|
774
|
+
if (pauseToken === null) {
|
|
775
|
+
if (lastPauseState) {
|
|
776
|
+
lastPauseState = false;
|
|
777
|
+
yield* Effect7.logDebug("Local queue poller resumed");
|
|
778
|
+
yield* writeState(false, null);
|
|
779
|
+
}
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
782
|
+
yield* waitWithPauseToken(pauseToken);
|
|
783
|
+
return true;
|
|
784
|
+
});
|
|
785
|
+
return yield* Effect7.forever(Effect7.gen(function* () {
|
|
786
|
+
if (yield* waitIfPaused) {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
yield* globalSemaphore.take(1);
|
|
790
|
+
const releasePermit = globalSemaphore.release(1);
|
|
791
|
+
const pauseToken = readPauseToken();
|
|
792
|
+
if (pauseToken !== null) {
|
|
793
|
+
yield* releasePermit;
|
|
794
|
+
yield* waitWithPauseToken(pauseToken);
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
const jobOption = yield* claimNextLocalJob(queueNames).pipe(Effect7.withTracerEnabled(false), Effect7.tapErrorCause(() => releasePermit), Effect7.tap((jobOption) => Option2.isNone(jobOption) ? releasePermit : Effect7.void));
|
|
798
|
+
if (Option2.isNone(jobOption)) {
|
|
799
|
+
consecutivePollErrors = 0;
|
|
800
|
+
const now = yield* DateTime.now;
|
|
801
|
+
const nowMs = DateTime.toEpochMillis(now);
|
|
802
|
+
idleSinceMs ??= hasClaimedSinceStartup ? nowMs : nowMs - MAX_IDLE_STAGE_START_MS;
|
|
803
|
+
const idleStage = getIdlePollStage(D.millis(nowMs - idleSinceMs));
|
|
804
|
+
if (idleStage.label !== lastIdleStageLabel) {
|
|
805
|
+
lastIdleStageLabel = idleStage.label;
|
|
806
|
+
yield* Effect7.logDebug(`Local queue poller idle backoff now ${idleStage.label}`);
|
|
807
|
+
}
|
|
808
|
+
yield* sleepWithJitter(idleStage.delay, MAX_POLL_JITTER);
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
idleSinceMs = null;
|
|
812
|
+
lastIdleStageLabel = null;
|
|
813
|
+
consecutivePollErrors = 0;
|
|
814
|
+
hasClaimedSinceStartup = true;
|
|
815
|
+
const job = jobOption.value;
|
|
816
|
+
yield* Effect7.logDebug(`Processing job ${job.jobId} from ${job.queue}`);
|
|
817
|
+
yield* Ref.update(activeJobsRef, (count) => count + 1);
|
|
818
|
+
yield* writeState(false, null);
|
|
819
|
+
const releaseJobPermit = Effect7.gen(function* () {
|
|
820
|
+
yield* Ref.update(activeJobsRef, (count) => Math.max(0, count - 1));
|
|
821
|
+
const pauseToken = readPauseToken();
|
|
822
|
+
yield* writeState(pauseToken !== null, pauseToken);
|
|
823
|
+
yield* releasePermit;
|
|
824
|
+
});
|
|
825
|
+
yield* Effect7.fork(processClaimedJob(job, queueHandlers).pipe(Effect7.tap(() => waitAfterSuccessfulJob), Effect7.catchAllCause((cause) => Effect7.logError(`Job processing failed for ${job.jobId}`, cause)), Effect7.ensuring(releaseJobPermit)));
|
|
826
|
+
}).pipe(Effect7.catchAllCause((cause) => Effect7.gen(function* () {
|
|
827
|
+
consecutivePollErrors += 1;
|
|
828
|
+
const errorDelay = getPollErrorDelay(consecutivePollErrors);
|
|
829
|
+
yield* Effect7.logError("Failed to poll local queues", cause);
|
|
830
|
+
yield* sleepWithJitter(errorDelay, MAX_POLL_JITTER);
|
|
831
|
+
}))));
|
|
832
|
+
});
|
|
833
|
+
};
|
|
834
|
+
// src/job-worker/job-worker.ts
|
|
835
|
+
var makeAuthorizationLayer = (policyPaths, schemaPaths) => {
|
|
836
|
+
if (policyPaths.length > 0) {
|
|
837
|
+
const hotReloadConfig = LocalCedarConfigHotReload("/", policyPaths, schemaPaths);
|
|
838
|
+
return Layer6.provideMerge(LocalCedarAuthorizationLive, hotReloadConfig);
|
|
839
|
+
}
|
|
840
|
+
const staticConfig = LocalCedarConfigStatic(undefined, schemaPaths);
|
|
841
|
+
return Layer6.provideMerge(LocalCedarAuthorizationLive, staticConfig);
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
class InvalidUsageError extends Data2.TaggedError("InvalidUsageError") {
|
|
845
|
+
}
|
|
846
|
+
var ParsedArgsSchema = Schema2.Struct({
|
|
847
|
+
org: Schema2.String,
|
|
848
|
+
check: Schema2.Boolean
|
|
849
|
+
});
|
|
850
|
+
var parseArgs = (args) => Effect8.gen(function* () {
|
|
851
|
+
const parseResult = yield* Effect8.try({
|
|
852
|
+
try: () => utilParseArgs({
|
|
853
|
+
args,
|
|
854
|
+
options: {
|
|
855
|
+
org: { type: "string", short: "o" },
|
|
856
|
+
check: { type: "boolean", default: false }
|
|
857
|
+
},
|
|
858
|
+
strict: true,
|
|
859
|
+
allowPositionals: false
|
|
860
|
+
}),
|
|
861
|
+
catch: () => new InvalidUsageError({ _: undefined })
|
|
862
|
+
});
|
|
863
|
+
const org = parseResult.values.org ?? process.env["PF_ORG"];
|
|
864
|
+
if (!org) {
|
|
865
|
+
console.error("Error: --org is required (or set PF_ORG environment variable)");
|
|
866
|
+
return yield* new InvalidUsageError({ _: undefined });
|
|
867
|
+
}
|
|
868
|
+
return yield* Schema2.decodeUnknown(ParsedArgsSchema)({
|
|
869
|
+
org,
|
|
870
|
+
check: parseResult.values.check
|
|
871
|
+
}).pipe(Effect8.mapError(() => new InvalidUsageError({ _: undefined })));
|
|
872
|
+
});
|
|
873
|
+
var CliConfig = Context.GenericTag("processfocus:internal-tag/runtime-local/JobWorkerCliConfig");
|
|
874
|
+
var CliConfigLive = Layer6.effect(CliConfig, parseArgs(process.argv.slice(2)).pipe(Effect8.map((args) => ({
|
|
875
|
+
org: args.org,
|
|
876
|
+
check: args.check
|
|
877
|
+
})), Effect8.catchAll((error) => {
|
|
878
|
+
console.error("Invalid arguments. Usage: bun run job-worker.ts [--org ORG | -o ORG] [--check]");
|
|
879
|
+
console.error(" --org, -o Path to org project (or set PF_ORG env var)");
|
|
880
|
+
return Effect8.fail(error);
|
|
881
|
+
})));
|
|
882
|
+
var NodeSdkLive = Otel.NodeSdk.layer(() => ({
|
|
883
|
+
resource: { serviceName: "job-worker" },
|
|
884
|
+
metricReader: new PeriodicExportingMetricReader({
|
|
885
|
+
exporter: new OTLPMetricExporter({})
|
|
886
|
+
}),
|
|
887
|
+
spanProcessor: new BatchSpanProcessor(new OTLPTraceExporter({}))
|
|
888
|
+
}));
|
|
889
|
+
var RequestTimeLive = Layer6.succeed(RequestTime, FiberRef2.unsafeMake(DateTime2.unsafeMake(0)));
|
|
890
|
+
var CurrentPrincipalLive = Layer6.succeed(CurrentPrincipal, FiberRef2.unsafeMake(null));
|
|
891
|
+
var UserDetailsLive = Layer6.succeed(UserDetails, FiberRef2.unsafeMake({
|
|
892
|
+
by: "SYSTEM",
|
|
893
|
+
id: null
|
|
894
|
+
}));
|
|
895
|
+
var DefaultNotificationDeliveryConfigLive = makeNotificationDeliveryConfig(() => getEffectiveFrontendBaseUrl());
|
|
896
|
+
var createAppLayer = (org, orgProviderLayer, policyPaths, schemaPaths, orgPath) => {
|
|
897
|
+
const ConditionEvaluatorLive = Layer6.succeed(ConditionEvaluator, makeConditionEvaluator(org));
|
|
898
|
+
const ScheduleEvaluatorLive = Layer6.succeed(ScheduleEvaluator, makeScheduleEvaluator(org));
|
|
899
|
+
const SystemStepExecutorLive = Layer6.succeed(SystemStepExecutor, makeSystemStepExecutor(org));
|
|
900
|
+
const ForEachItemsResolverLive = Layer6.succeed(ForEachItemsResolver, makeForEachItemsResolver(org));
|
|
901
|
+
const AuthorizationLive = makeAuthorizationLayer(policyPaths, schemaPaths);
|
|
902
|
+
const internalApiSecret = process.env["INTERNAL_API_SECRET"] ?? "dev-secret";
|
|
903
|
+
const DocumentStoreConfigLive = Layer6.succeed(LocalDocumentStoreConfig, {
|
|
904
|
+
baseUrl: () => "http://localhost:4000",
|
|
905
|
+
storagePath: `${orgPath}/files`,
|
|
906
|
+
secret: internalApiSecret,
|
|
907
|
+
maxFileSize: 100 * 1024 * 1024
|
|
908
|
+
});
|
|
909
|
+
const DocumentStoreLive = Layer6.provide(LocalDocumentStoreServiceLive, DocumentStoreConfigLive);
|
|
910
|
+
const ExecutorHostLive = makeLocalExecutorHostLayer(orgPath);
|
|
911
|
+
const TodoCollectionOpsWithDeps = Layer6.provide(TodoCollectionOpsLive, SqliteGraphqlDbOperationsLive);
|
|
912
|
+
const ProcessCollectionOpsWithDeps = Layer6.provide(ProcessCollectionOpsLive, SqliteGraphqlDbOperationsLive);
|
|
913
|
+
const SlaCalculationServiceWithDeps = SlaCalculationServiceLive.pipe(Layer6.provide(SqliteGraphqlDbOperationsLive));
|
|
914
|
+
const ExecutionCollectionOpsWithDeps = ExecutionCollectionOpsLive.pipe(Layer6.provide(SlaCalculationServiceWithDeps), Layer6.provide(SqliteGraphqlDbOperationsLive), Layer6.provide(orgProviderLayer));
|
|
915
|
+
const TodoSummaryComputationWithDeps = TodoSummaryComputationLive.pipe(Layer6.provide(SqliteGraphqlDbOperationsLive), Layer6.provide(orgProviderLayer));
|
|
916
|
+
const SqliteQueueWithRequestContext = SqliteQueueServiceLive.pipe(Layer6.provide(Layer6.merge(RequestTimeLive, UserDetailsLive)));
|
|
917
|
+
return Layer6.mergeAll(SqliteQueueWithRequestContext, SqliteFlowExecutionOperationsLive, SqliteScheduledFlowOperationsLive, SqliteCompletedJobOperationsLive, SqliteFileOperationsLive, SqliteGraphqlDbOperationsLive, ConditionEvaluatorLive, ScheduleEvaluatorLive, SystemStepExecutorLive, ForEachItemsResolverLive, DocumentStoreLive, LocalFileResolutionHostLive, ExecutorHostLive, RequestTimeLive, UserDetailsLive, CurrentPrincipalLive, AuthorizationLive, TodoCollectionOpsWithDeps, ProcessCollectionOpsWithDeps, ExecutionCollectionOpsWithDeps, TodoSummaryComputationWithDeps, HttpTodoFromJobPublisherLive, Layer6.provide(HttpProcessFromJobPublisherLive, Layer6.merge(ProcessCollectionOpsWithDeps, UserDetailsLive)), Layer6.provide(HttpExecutionFromJobPublisherLive, Layer6.merge(ExecutionCollectionOpsWithDeps, UserDetailsLive))).pipe(Layer6.provideMerge(orgProviderLayer), Layer6.provideMerge(TypedSqliteDrizzleLayer), Layer6.provideMerge(makeLocalSqlClientLayer({ busy_timeout: LOCAL_SQLITE_BUSY_TIMEOUT_MS })), Layer6.provideMerge(layer));
|
|
918
|
+
};
|
|
919
|
+
var GLOBAL_MAX_CONCURRENT = 1;
|
|
920
|
+
var FRONTEND_PORT_FILE = ".frontend-port.json";
|
|
921
|
+
var getRuntimeRoot = () => process.env["PF_RUNTIME_ROOT"] ?? process.cwd();
|
|
922
|
+
var portFilePath = join2(getRuntimeRoot(), GRAPHQL_PORT_FILE);
|
|
923
|
+
if (existsSync4(portFilePath)) {
|
|
924
|
+
import(portFilePath).catch(() => {});
|
|
925
|
+
}
|
|
926
|
+
var frontendPortFilePath = join2(getRuntimeRoot(), FRONTEND_PORT_FILE);
|
|
927
|
+
if (existsSync4(frontendPortFilePath)) {
|
|
928
|
+
import(frontendPortFilePath).catch(() => {});
|
|
929
|
+
}
|
|
930
|
+
var queueHandlers = {
|
|
931
|
+
[FLOW_EXECUTION_QUEUE]: jobHandler(flowExecutionHandler),
|
|
932
|
+
[TODO_EVENT_QUEUE]: jobHandler(todoEventHandler),
|
|
933
|
+
[PROCESS_EVENT_QUEUE]: jobHandler(processEventHandler),
|
|
934
|
+
[EXECUTION_EVENT_QUEUE]: jobHandler(executionEventHandler),
|
|
935
|
+
[SYSTEM_STEP_EXECUTION_QUEUE]: jobHandler(systemStepExecutionHandler),
|
|
936
|
+
[NOTIFICATION_DELIVERY_QUEUE]: jobHandler(notificationDeliveryHandler)
|
|
937
|
+
};
|
|
938
|
+
var WorkerLive = Layer6.scopedDiscard(Effect8.gen(function* () {
|
|
939
|
+
yield* Effect8.log("Starting job worker...");
|
|
940
|
+
const globalSemaphore = yield* Effect8.makeSemaphore(GLOBAL_MAX_CONCURRENT);
|
|
941
|
+
const queueNames = Object.keys(queueHandlers).join(", ");
|
|
942
|
+
yield* Effect8.fork(createSingleQueuePoller(queueHandlers, globalSemaphore));
|
|
943
|
+
yield* Effect8.log(`Job worker started, polling ${queueNames} queues with a single dispatcher`);
|
|
944
|
+
return yield* Effect8.never;
|
|
945
|
+
}));
|
|
946
|
+
var buildOrgProviderLayer = (orgPath) => OrganisationProviderFromPathDev(orgPath).pipe(Layer6.provide(layer2));
|
|
947
|
+
var main = Effect8.gen(function* () {
|
|
948
|
+
const cliConfig = yield* CliConfig;
|
|
949
|
+
if (process.env["FRONTEND_BASE_URL"] === undefined) {
|
|
950
|
+
process.env["FRONTEND_BASE_URL"] = getEffectiveFrontendBaseUrl();
|
|
951
|
+
}
|
|
952
|
+
const OrgProviderLayer = cliConfig.check ? OrganisationProviderFromPath(cliConfig.org).pipe(Layer6.provide(layer2)) : buildOrgProviderLayer(cliConfig.org);
|
|
953
|
+
const CedarPoliciesLayer = OrgCedarPoliciesProvider.pipe(Layer6.provide(OrgProviderLayer));
|
|
954
|
+
const orgProvider = yield* OrganisationProvider.pipe(Effect8.provide(OrgProviderLayer));
|
|
955
|
+
yield* warnIgnoredCronDeclarations(orgProvider.organisation, "local job worker");
|
|
956
|
+
yield* Effect8.log(`\u2705 Loaded organisation: ${orgProvider.organisation.name}`);
|
|
957
|
+
const cedarPolicies = yield* CedarPoliciesProvider.pipe(Effect8.provide(CedarPoliciesLayer));
|
|
958
|
+
yield* Effect8.log(`\uD83D\uDCDC Loaded ${cedarPolicies.policyPaths.length} Cedar policy files`);
|
|
959
|
+
const AppLayer = createAppLayer(orgProvider.organisation, OrgProviderLayer, cedarPolicies.policyPaths, cedarPolicies.schemaPaths, orgProvider.orgPath);
|
|
960
|
+
const customJobLayer = orgProvider.customJobLayer;
|
|
961
|
+
const serverPluginJobLayer = Layer6.provide(makeServerPluginJobLayer(orgProvider.serverPlugins ?? []), AppLayer);
|
|
962
|
+
if (orgProvider.customDbLayer) {
|
|
963
|
+
yield* Effect8.log("\uD83D\uDD0C Loaded custom database layer from organisation");
|
|
964
|
+
}
|
|
965
|
+
if (customJobLayer) {
|
|
966
|
+
yield* Effect8.log("\u2709\uFE0F Loaded custom job layer from organisation");
|
|
967
|
+
}
|
|
968
|
+
const notificationServicesLayer = customJobLayer ? Layer6.provide(customJobLayer, Layer6.merge(AppLayer, serverPluginJobLayer)) : Layer6.merge(LoggingEmailSenderLive, DefaultNotificationDeliveryConfigLive);
|
|
969
|
+
const AppLayerWithNotificationServices = Layer6.mergeAll(AppLayer, serverPluginJobLayer, notificationServicesLayer);
|
|
970
|
+
const LocalSqlClientLive = makeLocalSqlClientLayer({
|
|
971
|
+
busy_timeout: LOCAL_SQLITE_BUSY_TIMEOUT_MS
|
|
972
|
+
});
|
|
973
|
+
const customDbLayerDeps = Layer6.mergeAll(SqliteFileOperationsLive, makeAuthorizationLayer(cedarPolicies.policyPaths, cedarPolicies.schemaPaths), CurrentPrincipalLive, RequestTimeLive).pipe(Layer6.provideMerge(TypedSqliteDrizzleLayer), Layer6.provideMerge(LocalSqlClientLive));
|
|
974
|
+
const customDbLayer = orgProvider.customDbLayer;
|
|
975
|
+
const customDbLayerWithDeps = customDbLayer ? Layer6.provide(customDbLayer, customDbLayerDeps) : undefined;
|
|
976
|
+
const AppLayerWithCustom = customDbLayerWithDeps ? Layer6.merge(AppLayerWithNotificationServices, customDbLayerWithDeps) : AppLayerWithNotificationServices;
|
|
977
|
+
if (cliConfig.check) {
|
|
978
|
+
yield* Layer6.build(AppLayerWithCustom).pipe(Effect8.scoped);
|
|
979
|
+
yield* Effect8.log("Job worker configuration check passed");
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
const AppLive = WorkerLive.pipe(Layer6.provide(AppLayerWithCustom));
|
|
983
|
+
return yield* Layer6.launch(AppLive).pipe(Effect8.provide(NodeSdkLive));
|
|
984
|
+
});
|
|
985
|
+
var exit = await Effect8.runPromiseExit(main.pipe(Effect8.provide(CliConfigLive), Effect8.tapErrorCause((cause) => Effect8.logError(`Local runtime startup blocked: job worker initialization failed.
|
|
986
|
+
${cause}
|
|
987
|
+
Fix the configuration above and restart the local runtime. Automatic process steps are unavailable.`)), Logger.withMinimumLogLevel(LogLevel.Debug), Effect8.provide(Logger.pretty)));
|
|
988
|
+
if (Exit.isFailure(exit))
|
|
989
|
+
process.exitCode = 1;
|