@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,1319 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
layer,
|
|
4
|
+
Runtime,
|
|
5
|
+
CurrentPrincipal,
|
|
6
|
+
RequestTime,
|
|
7
|
+
DelegationSessionServiceIsolated,
|
|
8
|
+
layer2,
|
|
9
|
+
OrganisationProvider,
|
|
10
|
+
OrganisationProviderFromPathDev,
|
|
11
|
+
CedarPoliciesProvider,
|
|
12
|
+
OrgCedarPoliciesProvider,
|
|
13
|
+
DatabaseConnectionInfo,
|
|
14
|
+
LOCAL_SQLITE_BUSY_TIMEOUT_MS,
|
|
15
|
+
TypedSqliteDrizzleLayer,
|
|
16
|
+
FileOperations,
|
|
17
|
+
UserDetails,
|
|
18
|
+
SqliteDelegationDatabaseLive,
|
|
19
|
+
SqliteAuthenticationDatabaseLive,
|
|
20
|
+
SqliteCompletedJobOperationsLive,
|
|
21
|
+
SqliteFileOperationsLive,
|
|
22
|
+
SqliteFlowExecutionOperationsLive,
|
|
23
|
+
SqliteGraphqlDbOperationsLive,
|
|
24
|
+
SqliteScheduledFlowOperationsLive,
|
|
25
|
+
DEFAULT_GRAPHQL_PORT,
|
|
26
|
+
GRAPHQL_PORT_FILE,
|
|
27
|
+
makeLocalSqlClientLayer,
|
|
28
|
+
CedarReloadNotifierService,
|
|
29
|
+
LocalCedarConfigStatic,
|
|
30
|
+
LocalCedarConfigHotReload,
|
|
31
|
+
LocalCedarAuthorizationLive
|
|
32
|
+
} from "./chunk-9weqs8n8.js";
|
|
33
|
+
import {
|
|
34
|
+
HttpClient,
|
|
35
|
+
post,
|
|
36
|
+
bodyJson,
|
|
37
|
+
filterStatusOk,
|
|
38
|
+
AuthConfig,
|
|
39
|
+
AuthConfigLive,
|
|
40
|
+
resolveBusinessMetricDimensions,
|
|
41
|
+
BusinessMetricDimensions,
|
|
42
|
+
makeDashboardActivityLayer,
|
|
43
|
+
versionInfo,
|
|
44
|
+
GraphQLError,
|
|
45
|
+
parse,
|
|
46
|
+
validate,
|
|
47
|
+
getOperationAST,
|
|
48
|
+
execute,
|
|
49
|
+
subscribe,
|
|
50
|
+
LocalDelegatedRealtime,
|
|
51
|
+
DraftProcessEvents,
|
|
52
|
+
TodoSummaryComputation,
|
|
53
|
+
TodoSummaryComputationLive,
|
|
54
|
+
ExecutionEvents,
|
|
55
|
+
ProcessDurationServiceLive,
|
|
56
|
+
ProcessEvents,
|
|
57
|
+
DraftProcessExecutionCollectionOpsLive,
|
|
58
|
+
SlaCalculationServiceLive,
|
|
59
|
+
ExecutionCollectionOps,
|
|
60
|
+
ExecutionCollectionOpsLive,
|
|
61
|
+
ProcessCollectionOps,
|
|
62
|
+
ProcessCollectionOpsLive,
|
|
63
|
+
TodoCollectionOps,
|
|
64
|
+
TodoCollectionOpsLive,
|
|
65
|
+
TodoEvents,
|
|
66
|
+
hasInvalidDownloadFilename,
|
|
67
|
+
formatContentDisposition,
|
|
68
|
+
ListExportServiceLive,
|
|
69
|
+
DynamicSchemaConfig,
|
|
70
|
+
AppSchemaBuilderLive,
|
|
71
|
+
Yoga,
|
|
72
|
+
ResolverRuntime,
|
|
73
|
+
YogaLive,
|
|
74
|
+
SqliteQueueServiceLive,
|
|
75
|
+
warnIgnoredCronDeclarations,
|
|
76
|
+
getEffectiveFrontendBaseUrl,
|
|
77
|
+
LocalDocumentStoreConfig,
|
|
78
|
+
generateLocalDocumentStoreToken,
|
|
79
|
+
LocalDocumentStoreServiceLive,
|
|
80
|
+
makeServerPluginWebhookRouter
|
|
81
|
+
} from "./chunk-mvkr77wp.js";
|
|
82
|
+
import {
|
|
83
|
+
serveOnExactPort,
|
|
84
|
+
serveWithPortFallback,
|
|
85
|
+
writePortFile
|
|
86
|
+
} from "./chunk-vpsm84e8.js";
|
|
87
|
+
|
|
88
|
+
// src/graphql-server/graphql-server.ts
|
|
89
|
+
import * as Otel from "@effect/opentelemetry";
|
|
90
|
+
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
|
|
91
|
+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
92
|
+
import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
|
93
|
+
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
94
|
+
import {
|
|
95
|
+
Cause as Cause3,
|
|
96
|
+
Config as Config2,
|
|
97
|
+
Context,
|
|
98
|
+
DateTime,
|
|
99
|
+
Effect as Effect4,
|
|
100
|
+
Exit as Exit2,
|
|
101
|
+
FiberRef,
|
|
102
|
+
Layer as Layer4,
|
|
103
|
+
LogLevel,
|
|
104
|
+
Logger,
|
|
105
|
+
ManagedRuntime,
|
|
106
|
+
Option as Option3,
|
|
107
|
+
Redacted
|
|
108
|
+
} from "effect";
|
|
109
|
+
|
|
110
|
+
// src/services/event-hub.ts
|
|
111
|
+
import { Cause, Effect, Layer, Queue, Runtime as Runtime2 } from "effect";
|
|
112
|
+
var DEFAULT_BUFFER_SIZE = 32;
|
|
113
|
+
var createEventHubLayer = (tag, options = {}) => {
|
|
114
|
+
const bufferSize = options.bufferSize ?? DEFAULT_BUFFER_SIZE;
|
|
115
|
+
return Layer.effect(tag, Effect.sync(() => {
|
|
116
|
+
const subscribers = new Set;
|
|
117
|
+
return {
|
|
118
|
+
emit: (event, _schema) => Effect.forEach(Array.from(subscribers), (queue) => Queue.offer(queue, event), { discard: true }),
|
|
119
|
+
subscribe: () => Effect.gen(function* () {
|
|
120
|
+
const queue = yield* Queue.sliding(bufferSize);
|
|
121
|
+
subscribers.add(queue);
|
|
122
|
+
const runtime = yield* Effect.runtime();
|
|
123
|
+
const run = Runtime2.runPromise(runtime);
|
|
124
|
+
let closed = false;
|
|
125
|
+
const close = async () => {
|
|
126
|
+
closed = true;
|
|
127
|
+
subscribers.delete(queue);
|
|
128
|
+
await run(Queue.shutdown(queue));
|
|
129
|
+
};
|
|
130
|
+
const iterator = {
|
|
131
|
+
[Symbol.asyncIterator]() {
|
|
132
|
+
return this;
|
|
133
|
+
},
|
|
134
|
+
async next() {
|
|
135
|
+
if (closed)
|
|
136
|
+
return { done: true, value: undefined };
|
|
137
|
+
try {
|
|
138
|
+
const event = await run(Queue.take(queue));
|
|
139
|
+
return closed ? { done: true, value: undefined } : { done: false, value: event };
|
|
140
|
+
} catch (error) {
|
|
141
|
+
if (closed)
|
|
142
|
+
return { done: true, value: undefined };
|
|
143
|
+
try {
|
|
144
|
+
await run(Effect.logError("Subscriber queue error", Cause.die(error)));
|
|
145
|
+
} catch {}
|
|
146
|
+
await close();
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
async return() {
|
|
151
|
+
await close();
|
|
152
|
+
return { done: true, value: undefined };
|
|
153
|
+
},
|
|
154
|
+
async throw(error) {
|
|
155
|
+
await close();
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
return iterator;
|
|
160
|
+
})
|
|
161
|
+
};
|
|
162
|
+
}));
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// src/services/draft-process-events.ts
|
|
166
|
+
var DraftProcessEventsLive = createEventHubLayer(DraftProcessEvents);
|
|
167
|
+
|
|
168
|
+
// src/services/execution-events.ts
|
|
169
|
+
var ExecutionEventsLive = createEventHubLayer(ExecutionEvents);
|
|
170
|
+
|
|
171
|
+
// src/services/http-cedar-reload-notifier.ts
|
|
172
|
+
import { Cause as Cause2, Config, Effect as Effect2, Layer as Layer2, Option, Runtime as Runtime3 } from "effect";
|
|
173
|
+
var HttpCedarReloadNotifierLive = Layer2.effect(CedarReloadNotifierService, Effect2.gen(function* () {
|
|
174
|
+
const httpClient = yield* HttpClient;
|
|
175
|
+
const runtime = yield* Effect2.runtime();
|
|
176
|
+
const revalidateSecret = yield* Config.option(Config.string("REVALIDATE_SECRET"));
|
|
177
|
+
if (Option.isNone(revalidateSecret)) {
|
|
178
|
+
yield* Effect2.logWarning("REVALIDATE_SECRET not configured; Cedar reloads will skip frontend cache invalidation");
|
|
179
|
+
} else {
|
|
180
|
+
yield* Effect2.log("Cedar reload notifier configured for frontend cache invalidation");
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
onCedarReloaded: () => {
|
|
184
|
+
const effect = Effect2.gen(function* () {
|
|
185
|
+
if (Option.isNone(revalidateSecret)) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const baseUrl = getEffectiveFrontendBaseUrl();
|
|
189
|
+
const request = yield* post(`${baseUrl}/api/revalidate`).pipe(bodyJson({
|
|
190
|
+
path: "/settings",
|
|
191
|
+
tag: "cedar-policies",
|
|
192
|
+
secret: revalidateSecret.value
|
|
193
|
+
}));
|
|
194
|
+
yield* Effect2.log(`Triggering frontend cache invalidation for cedar-policies and /settings at ${baseUrl}`);
|
|
195
|
+
yield* httpClient.execute(request).pipe(Effect2.flatMap(filterStatusOk), Effect2.scoped, Effect2.matchEffect({
|
|
196
|
+
onSuccess: () => Effect2.log(`Successfully invalidated frontend cedar-policies cache and /settings at ${baseUrl}`),
|
|
197
|
+
onFailure: (error) => Effect2.logWarning(`Failed to invalidate frontend cache at ${baseUrl} (non-fatal): ${error instanceof Error ? error.message : String(error)}`)
|
|
198
|
+
}));
|
|
199
|
+
}).pipe(Effect2.catchAllCause((cause) => Effect2.logWarning(`Failed to prepare frontend cache invalidation request (non-fatal): ${Cause2.pretty(cause)}`)));
|
|
200
|
+
Runtime3.runFork(runtime, effect);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}));
|
|
204
|
+
|
|
205
|
+
// src/services/process-events.ts
|
|
206
|
+
var ProcessEventsLive = createEventHubLayer(ProcessEvents);
|
|
207
|
+
|
|
208
|
+
// src/services/todo-events.ts
|
|
209
|
+
var TodoEventsLive = createEventHubLayer(TodoEvents);
|
|
210
|
+
|
|
211
|
+
// src/graphql-server/graphql-internal-server.ts
|
|
212
|
+
import { timingSafeEqual } from "crypto";
|
|
213
|
+
import { existsSync, mkdirSync, unlinkSync } from "fs";
|
|
214
|
+
import { join } from "path";
|
|
215
|
+
import { parseArgs as utilParseArgs } from "util";
|
|
216
|
+
import {
|
|
217
|
+
Data,
|
|
218
|
+
Effect as Effect3,
|
|
219
|
+
Context as EffectContext,
|
|
220
|
+
Exit,
|
|
221
|
+
Layer as Layer3,
|
|
222
|
+
Metric,
|
|
223
|
+
Option as Option2,
|
|
224
|
+
Schedule,
|
|
225
|
+
Schema
|
|
226
|
+
} from "effect";
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
function extendedTypeof(val) {
|
|
230
|
+
if (val === null) {
|
|
231
|
+
return "null";
|
|
232
|
+
}
|
|
233
|
+
if (Array.isArray(val)) {
|
|
234
|
+
return "array";
|
|
235
|
+
}
|
|
236
|
+
return typeof val;
|
|
237
|
+
}
|
|
238
|
+
function isObject(val) {
|
|
239
|
+
return extendedTypeof(val) === "object";
|
|
240
|
+
}
|
|
241
|
+
function isAsyncIterable(val) {
|
|
242
|
+
return typeof Object(val)[Symbol.asyncIterator] === "function";
|
|
243
|
+
}
|
|
244
|
+
function isAsyncGenerator(val) {
|
|
245
|
+
return isObject(val) && typeof Object(val)[Symbol.asyncIterator] === "function" && typeof val.return === "function";
|
|
246
|
+
}
|
|
247
|
+
function areGraphQLFormattedErrors(obj) {
|
|
248
|
+
return Array.isArray(obj) && obj.length > 0 && obj.every((ob) => ("message" in ob));
|
|
249
|
+
}
|
|
250
|
+
var GRAPHQL_TRANSPORT_WS_PROTOCOL = "graphql-transport-ws";
|
|
251
|
+
var CloseCode = /* @__PURE__ */ ((CloseCode2) => {
|
|
252
|
+
CloseCode2[CloseCode2["InternalServerError"] = 4500] = "InternalServerError";
|
|
253
|
+
CloseCode2[CloseCode2["InternalClientError"] = 4005] = "InternalClientError";
|
|
254
|
+
CloseCode2[CloseCode2["BadRequest"] = 4400] = "BadRequest";
|
|
255
|
+
CloseCode2[CloseCode2["BadResponse"] = 4004] = "BadResponse";
|
|
256
|
+
CloseCode2[CloseCode2["Unauthorized"] = 4401] = "Unauthorized";
|
|
257
|
+
CloseCode2[CloseCode2["Forbidden"] = 4403] = "Forbidden";
|
|
258
|
+
CloseCode2[CloseCode2["SubprotocolNotAcceptable"] = 4406] = "SubprotocolNotAcceptable";
|
|
259
|
+
CloseCode2[CloseCode2["ConnectionInitialisationTimeout"] = 4408] = "ConnectionInitialisationTimeout";
|
|
260
|
+
CloseCode2[CloseCode2["ConnectionAcknowledgementTimeout"] = 4504] = "ConnectionAcknowledgementTimeout";
|
|
261
|
+
CloseCode2[CloseCode2["SubscriberAlreadyExists"] = 4409] = "SubscriberAlreadyExists";
|
|
262
|
+
CloseCode2[CloseCode2["TooManyInitialisationRequests"] = 4429] = "TooManyInitialisationRequests";
|
|
263
|
+
return CloseCode2;
|
|
264
|
+
})(CloseCode || {});
|
|
265
|
+
var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
266
|
+
MessageType2["ConnectionInit"] = "connection_init";
|
|
267
|
+
MessageType2["ConnectionAck"] = "connection_ack";
|
|
268
|
+
MessageType2["Ping"] = "ping";
|
|
269
|
+
MessageType2["Pong"] = "pong";
|
|
270
|
+
MessageType2["Subscribe"] = "subscribe";
|
|
271
|
+
MessageType2["Next"] = "next";
|
|
272
|
+
MessageType2["Error"] = "error";
|
|
273
|
+
MessageType2["Complete"] = "complete";
|
|
274
|
+
return MessageType2;
|
|
275
|
+
})(MessageType || {});
|
|
276
|
+
function validateMessage(val) {
|
|
277
|
+
if (!isObject(val)) {
|
|
278
|
+
throw new Error(`Message is expected to be an object, but got ${extendedTypeof(val)}`);
|
|
279
|
+
}
|
|
280
|
+
if (!val.type) {
|
|
281
|
+
throw new Error(`Message is missing the 'type' property`);
|
|
282
|
+
}
|
|
283
|
+
if (typeof val.type !== "string") {
|
|
284
|
+
throw new Error(`Message is expects the 'type' property to be a string, but got ${extendedTypeof(val.type)}`);
|
|
285
|
+
}
|
|
286
|
+
switch (val.type) {
|
|
287
|
+
case "connection_init":
|
|
288
|
+
case "connection_ack":
|
|
289
|
+
case "ping":
|
|
290
|
+
case "pong": {
|
|
291
|
+
if (val.payload != null && !isObject(val.payload)) {
|
|
292
|
+
throw new Error(`"${val.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${val.payload}"`);
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
case "subscribe": {
|
|
297
|
+
if (typeof val.id !== "string") {
|
|
298
|
+
throw new Error(`"${val.type}" message expects the 'id' property to be a string, but got ${extendedTypeof(val.id)}`);
|
|
299
|
+
}
|
|
300
|
+
if (!val.id) {
|
|
301
|
+
throw new Error(`"${val.type}" message requires a non-empty 'id' property`);
|
|
302
|
+
}
|
|
303
|
+
if (!isObject(val.payload)) {
|
|
304
|
+
throw new Error(`"${val.type}" message expects the 'payload' property to be an object, but got ${extendedTypeof(val.payload)}`);
|
|
305
|
+
}
|
|
306
|
+
if (typeof val.payload.query !== "string") {
|
|
307
|
+
throw new Error(`"${val.type}" message payload expects the 'query' property to be a string, but got ${extendedTypeof(val.payload.query)}`);
|
|
308
|
+
}
|
|
309
|
+
if (val.payload.variables != null && !isObject(val.payload.variables)) {
|
|
310
|
+
throw new Error(`"${val.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${extendedTypeof(val.payload.variables)}`);
|
|
311
|
+
}
|
|
312
|
+
if (val.payload.operationName != null && extendedTypeof(val.payload.operationName) !== "string") {
|
|
313
|
+
throw new Error(`"${val.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${extendedTypeof(val.payload.operationName)}`);
|
|
314
|
+
}
|
|
315
|
+
if (val.payload.extensions != null && !isObject(val.payload.extensions)) {
|
|
316
|
+
throw new Error(`"${val.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${extendedTypeof(val.payload.extensions)}`);
|
|
317
|
+
}
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
case "next": {
|
|
321
|
+
if (typeof val.id !== "string") {
|
|
322
|
+
throw new Error(`"${val.type}" message expects the 'id' property to be a string, but got ${extendedTypeof(val.id)}`);
|
|
323
|
+
}
|
|
324
|
+
if (!val.id) {
|
|
325
|
+
throw new Error(`"${val.type}" message requires a non-empty 'id' property`);
|
|
326
|
+
}
|
|
327
|
+
if (!isObject(val.payload)) {
|
|
328
|
+
throw new Error(`"${val.type}" message expects the 'payload' property to be an object, but got ${extendedTypeof(val.payload)}`);
|
|
329
|
+
}
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
case "error": {
|
|
333
|
+
if (typeof val.id !== "string") {
|
|
334
|
+
throw new Error(`"${val.type}" message expects the 'id' property to be a string, but got ${extendedTypeof(val.id)}`);
|
|
335
|
+
}
|
|
336
|
+
if (!val.id) {
|
|
337
|
+
throw new Error(`"${val.type}" message requires a non-empty 'id' property`);
|
|
338
|
+
}
|
|
339
|
+
if (!areGraphQLFormattedErrors(val.payload)) {
|
|
340
|
+
throw new Error(`"${val.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(val.payload)}`);
|
|
341
|
+
}
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
case "complete": {
|
|
345
|
+
if (typeof val.id !== "string") {
|
|
346
|
+
throw new Error(`"${val.type}" message expects the 'id' property to be a string, but got ${extendedTypeof(val.id)}`);
|
|
347
|
+
}
|
|
348
|
+
if (!val.id) {
|
|
349
|
+
throw new Error(`"${val.type}" message requires a non-empty 'id' property`);
|
|
350
|
+
}
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
default:
|
|
354
|
+
throw new Error(`Invalid message 'type' property "${val.type}"`);
|
|
355
|
+
}
|
|
356
|
+
return val;
|
|
357
|
+
}
|
|
358
|
+
function parseMessage(data, reviver) {
|
|
359
|
+
return validateMessage(typeof data === "string" ? JSON.parse(data, reviver) : data);
|
|
360
|
+
}
|
|
361
|
+
function stringifyMessage(msg, replacer) {
|
|
362
|
+
validateMessage(msg);
|
|
363
|
+
return JSON.stringify(msg, replacer);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
function makeServer(options) {
|
|
368
|
+
const {
|
|
369
|
+
schema,
|
|
370
|
+
context,
|
|
371
|
+
roots,
|
|
372
|
+
parse: parse$1,
|
|
373
|
+
validate: validate$1,
|
|
374
|
+
execute: execute$1,
|
|
375
|
+
subscribe: subscribe$1,
|
|
376
|
+
connectionInitWaitTimeout = 3000,
|
|
377
|
+
onConnect,
|
|
378
|
+
onDisconnect,
|
|
379
|
+
onClose,
|
|
380
|
+
onSubscribe,
|
|
381
|
+
onOperation,
|
|
382
|
+
onNext,
|
|
383
|
+
onError,
|
|
384
|
+
onComplete,
|
|
385
|
+
jsonMessageReviver: reviver,
|
|
386
|
+
jsonMessageReplacer: replacer
|
|
387
|
+
} = options;
|
|
388
|
+
return {
|
|
389
|
+
opened(socket, extra) {
|
|
390
|
+
const ctx = {
|
|
391
|
+
connectionInitReceived: false,
|
|
392
|
+
acknowledged: false,
|
|
393
|
+
subscriptions: {},
|
|
394
|
+
extra
|
|
395
|
+
};
|
|
396
|
+
if (socket.protocol !== GRAPHQL_TRANSPORT_WS_PROTOCOL) {
|
|
397
|
+
socket.close(CloseCode.SubprotocolNotAcceptable, "Subprotocol not acceptable");
|
|
398
|
+
return async (code, reason) => {
|
|
399
|
+
await onClose?.(ctx, code, reason);
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
const connectionInitWait = connectionInitWaitTimeout > 0 && isFinite(connectionInitWaitTimeout) ? setTimeout(() => {
|
|
403
|
+
if (!ctx.connectionInitReceived)
|
|
404
|
+
socket.close(CloseCode.ConnectionInitialisationTimeout, "Connection initialisation timeout");
|
|
405
|
+
}, connectionInitWaitTimeout) : null;
|
|
406
|
+
socket.onMessage(async function onMessage(data) {
|
|
407
|
+
let message;
|
|
408
|
+
try {
|
|
409
|
+
message = parseMessage(data, reviver);
|
|
410
|
+
} catch (err) {
|
|
411
|
+
return socket.close(CloseCode.BadRequest, "Invalid message received");
|
|
412
|
+
}
|
|
413
|
+
switch (message.type) {
|
|
414
|
+
case MessageType.ConnectionInit: {
|
|
415
|
+
if (ctx.connectionInitReceived)
|
|
416
|
+
return socket.close(CloseCode.TooManyInitialisationRequests, "Too many initialisation requests");
|
|
417
|
+
ctx.connectionInitReceived = true;
|
|
418
|
+
if (isObject(message.payload))
|
|
419
|
+
ctx.connectionParams = message.payload;
|
|
420
|
+
const permittedOrPayload = await onConnect?.(ctx);
|
|
421
|
+
if (permittedOrPayload === false)
|
|
422
|
+
return socket.close(CloseCode.Forbidden, "Forbidden");
|
|
423
|
+
ctx.acknowledged = true;
|
|
424
|
+
await socket.send(stringifyMessage(isObject(permittedOrPayload) ? {
|
|
425
|
+
type: MessageType.ConnectionAck,
|
|
426
|
+
payload: permittedOrPayload
|
|
427
|
+
} : {
|
|
428
|
+
type: MessageType.ConnectionAck
|
|
429
|
+
}, replacer));
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
case MessageType.Ping: {
|
|
433
|
+
if (socket.onPing)
|
|
434
|
+
return await socket.onPing(message.payload);
|
|
435
|
+
await socket.send(stringifyMessage(message.payload ? { type: MessageType.Pong, payload: message.payload } : {
|
|
436
|
+
type: MessageType.Pong
|
|
437
|
+
}));
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
case MessageType.Pong:
|
|
441
|
+
return await socket.onPong?.(message.payload);
|
|
442
|
+
case MessageType.Subscribe: {
|
|
443
|
+
if (!ctx.acknowledged)
|
|
444
|
+
return socket.close(CloseCode.Unauthorized, "Unauthorized");
|
|
445
|
+
const { id, payload } = message;
|
|
446
|
+
if (id in ctx.subscriptions)
|
|
447
|
+
return socket.close(CloseCode.SubscriberAlreadyExists, `Subscriber for ${id} already exists`);
|
|
448
|
+
ctx.subscriptions[id] = null;
|
|
449
|
+
const emit = {
|
|
450
|
+
next: async (result, { id: id2, payload: payload2 }, args) => {
|
|
451
|
+
const { errors, ...resultWithoutErrors } = result;
|
|
452
|
+
const maybeResult = await onNext?.(ctx, id2, payload2, args, result);
|
|
453
|
+
await socket.send(stringifyMessage({
|
|
454
|
+
id: id2,
|
|
455
|
+
type: MessageType.Next,
|
|
456
|
+
payload: maybeResult || {
|
|
457
|
+
...resultWithoutErrors,
|
|
458
|
+
...errors ? { errors: errors.map((e) => e.toJSON()) } : {}
|
|
459
|
+
}
|
|
460
|
+
}, replacer));
|
|
461
|
+
},
|
|
462
|
+
error: async (errors, { id: id2, payload: payload2 }) => {
|
|
463
|
+
const maybeErrors = await onError?.(ctx, id2, payload2, errors);
|
|
464
|
+
await socket.send(stringifyMessage({
|
|
465
|
+
id: id2,
|
|
466
|
+
type: MessageType.Error,
|
|
467
|
+
payload: maybeErrors || errors.map((e) => e.toJSON())
|
|
468
|
+
}, replacer));
|
|
469
|
+
},
|
|
470
|
+
complete: async (notifyClient, { id: id2, payload: payload2 }) => {
|
|
471
|
+
await onComplete?.(ctx, id2, payload2);
|
|
472
|
+
if (notifyClient)
|
|
473
|
+
await socket.send(stringifyMessage({
|
|
474
|
+
id: id2,
|
|
475
|
+
type: MessageType.Complete
|
|
476
|
+
}, replacer));
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
try {
|
|
480
|
+
let execArgs;
|
|
481
|
+
const maybeExecArgsOrErrors = await onSubscribe?.(ctx, message.id, message.payload);
|
|
482
|
+
if (maybeExecArgsOrErrors) {
|
|
483
|
+
if (areGraphQLErrors(maybeExecArgsOrErrors))
|
|
484
|
+
return id in ctx.subscriptions ? await emit.error(maybeExecArgsOrErrors, message) : undefined;
|
|
485
|
+
else if (Array.isArray(maybeExecArgsOrErrors))
|
|
486
|
+
throw new Error("Invalid return value from onSubscribe hook, expected an array of GraphQLError objects");
|
|
487
|
+
execArgs = maybeExecArgsOrErrors;
|
|
488
|
+
} else {
|
|
489
|
+
if (!schema)
|
|
490
|
+
throw new Error("The GraphQL schema is not provided");
|
|
491
|
+
const args = {
|
|
492
|
+
operationName: payload.operationName,
|
|
493
|
+
document: (parse$1 ?? parse)(payload.query),
|
|
494
|
+
variableValues: payload.variables
|
|
495
|
+
};
|
|
496
|
+
execArgs = {
|
|
497
|
+
...args,
|
|
498
|
+
schema: typeof schema === "function" ? await schema(ctx, id, payload, args) : schema
|
|
499
|
+
};
|
|
500
|
+
const validationErrors = (validate$1 ?? validate)(execArgs.schema, execArgs.document);
|
|
501
|
+
if (validationErrors.length > 0)
|
|
502
|
+
return id in ctx.subscriptions ? await emit.error(validationErrors, message) : undefined;
|
|
503
|
+
}
|
|
504
|
+
const operationAST = getOperationAST(execArgs.document, execArgs.operationName);
|
|
505
|
+
if (!operationAST)
|
|
506
|
+
return id in ctx.subscriptions ? await emit.error([new GraphQLError("Unable to identify operation")], message) : undefined;
|
|
507
|
+
if (!("rootValue" in execArgs))
|
|
508
|
+
execArgs.rootValue = roots?.[operationAST.operation];
|
|
509
|
+
if (!("contextValue" in execArgs))
|
|
510
|
+
execArgs.contextValue = typeof context === "function" ? await context(ctx, id, payload, execArgs) : context;
|
|
511
|
+
let operationResult;
|
|
512
|
+
if (operationAST.operation === "subscription")
|
|
513
|
+
operationResult = await (subscribe$1 ?? subscribe)(execArgs);
|
|
514
|
+
else
|
|
515
|
+
operationResult = await (execute$1 ?? execute)(execArgs);
|
|
516
|
+
const maybeResult = await onOperation?.(ctx, id, payload, execArgs, operationResult);
|
|
517
|
+
if (maybeResult)
|
|
518
|
+
operationResult = maybeResult;
|
|
519
|
+
if (isAsyncIterable(operationResult)) {
|
|
520
|
+
if (!(id in ctx.subscriptions)) {
|
|
521
|
+
if (isAsyncGenerator(operationResult))
|
|
522
|
+
operationResult.return(undefined);
|
|
523
|
+
} else {
|
|
524
|
+
ctx.subscriptions[id] = operationResult;
|
|
525
|
+
try {
|
|
526
|
+
for await (const result of operationResult) {
|
|
527
|
+
await emit.next(result, message, execArgs);
|
|
528
|
+
}
|
|
529
|
+
} catch (err) {
|
|
530
|
+
const originalError = err instanceof Error ? err : new Error(String(err));
|
|
531
|
+
await emit.error([
|
|
532
|
+
versionInfo.major >= 17 ? new GraphQLError(originalError.message, { cause: originalError }) : versionInfo.major >= 16 ? new GraphQLError(originalError.message, { originalError }) : new GraphQLError(originalError.message, null, null, null, null, originalError)
|
|
533
|
+
], message);
|
|
534
|
+
delete ctx.subscriptions[id];
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
} else {
|
|
538
|
+
if (id in ctx.subscriptions)
|
|
539
|
+
await emit.next(operationResult, message, execArgs);
|
|
540
|
+
}
|
|
541
|
+
await emit.complete(id in ctx.subscriptions, message);
|
|
542
|
+
} finally {
|
|
543
|
+
delete ctx.subscriptions[id];
|
|
544
|
+
}
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
case MessageType.Complete: {
|
|
548
|
+
const subscription = ctx.subscriptions[message.id];
|
|
549
|
+
delete ctx.subscriptions[message.id];
|
|
550
|
+
if (isAsyncGenerator(subscription))
|
|
551
|
+
await subscription.return(undefined);
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
default:
|
|
555
|
+
throw new Error(`Unexpected message of type ${message.type} received`);
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
return async (code, reason) => {
|
|
559
|
+
if (connectionInitWait)
|
|
560
|
+
clearTimeout(connectionInitWait);
|
|
561
|
+
const subs = { ...ctx.subscriptions };
|
|
562
|
+
ctx.subscriptions = {};
|
|
563
|
+
await Promise.all(Object.values(subs).filter(isAsyncGenerator).map((sub) => sub.return(undefined)));
|
|
564
|
+
if (ctx.acknowledged)
|
|
565
|
+
await onDisconnect?.(ctx, code, reason);
|
|
566
|
+
await onClose?.(ctx, code, reason);
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function handleProtocols(protocols) {
|
|
572
|
+
switch (true) {
|
|
573
|
+
case (protocols instanceof Set && protocols.has(GRAPHQL_TRANSPORT_WS_PROTOCOL)):
|
|
574
|
+
case (Array.isArray(protocols) && protocols.includes(GRAPHQL_TRANSPORT_WS_PROTOCOL)):
|
|
575
|
+
case (typeof protocols === "string" && protocols.split(",").map((p) => p.trim()).includes(GRAPHQL_TRANSPORT_WS_PROTOCOL)):
|
|
576
|
+
return GRAPHQL_TRANSPORT_WS_PROTOCOL;
|
|
577
|
+
default:
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
function areGraphQLErrors(obj) {
|
|
582
|
+
return Array.isArray(obj) && obj.length > 0 && obj.every((ob) => ob instanceof GraphQLError);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
function makeHandler(options) {
|
|
586
|
+
const server = makeServer(options);
|
|
587
|
+
const clients = /* @__PURE__ */ new WeakMap;
|
|
588
|
+
return {
|
|
589
|
+
open(ws) {
|
|
590
|
+
const client = {
|
|
591
|
+
handleMessage: () => {
|
|
592
|
+
throw new Error("Message received before handler was registered");
|
|
593
|
+
},
|
|
594
|
+
closed: () => {
|
|
595
|
+
throw new Error("Closed before handler was registered");
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
client.closed = server.opened({
|
|
599
|
+
protocol: GRAPHQL_TRANSPORT_WS_PROTOCOL,
|
|
600
|
+
send: async (message) => {
|
|
601
|
+
if (clients.has(ws)) {
|
|
602
|
+
ws.sendText(message);
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
close: (code, reason) => {
|
|
606
|
+
if (clients.has(ws)) {
|
|
607
|
+
ws.close(code, reason);
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
onMessage: (cb) => client.handleMessage = cb
|
|
611
|
+
}, { socket: ws });
|
|
612
|
+
clients.set(ws, client);
|
|
613
|
+
},
|
|
614
|
+
message(ws, message) {
|
|
615
|
+
const client = clients.get(ws);
|
|
616
|
+
if (!client)
|
|
617
|
+
throw new Error("Message received for a missing client");
|
|
618
|
+
return client.handleMessage(String(message));
|
|
619
|
+
},
|
|
620
|
+
close(ws, code, message) {
|
|
621
|
+
const client = clients.get(ws);
|
|
622
|
+
if (!client)
|
|
623
|
+
throw new Error("Closing a missing client");
|
|
624
|
+
return client.closed(code, message);
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// src/graphql-server/graphql-internal-server.ts
|
|
630
|
+
var constantTimeEqual = (a, b) => {
|
|
631
|
+
try {
|
|
632
|
+
return timingSafeEqual(Buffer.from(a), Buffer.from(b));
|
|
633
|
+
} catch {
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
class Mutex {
|
|
639
|
+
current = Promise.resolve();
|
|
640
|
+
async runExclusive(fn) {
|
|
641
|
+
const previous = this.current;
|
|
642
|
+
let resolveNext;
|
|
643
|
+
this.current = new Promise((resolve) => {
|
|
644
|
+
resolveNext = resolve;
|
|
645
|
+
});
|
|
646
|
+
try {
|
|
647
|
+
await previous;
|
|
648
|
+
return await fn();
|
|
649
|
+
} finally {
|
|
650
|
+
if (resolveNext)
|
|
651
|
+
resolveNext();
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
class CallbackSecret extends EffectContext.Tag("processfocus:internal-tag/runtime-local/CallbackSecret")() {
|
|
657
|
+
}
|
|
658
|
+
var CallbackSecretLive = Layer3.effect(CallbackSecret, Effect3.sync(() => Option2.fromNullable(process.env["INTERNAL_API_SECRET"])));
|
|
659
|
+
var activeWebSocketConnections = Metric.gauge("graphql.websocket.connections.active", {
|
|
660
|
+
description: "Number of active WebSocket connections (subscribers)"
|
|
661
|
+
});
|
|
662
|
+
var activeGraphqlSubscriptions = Metric.gauge("graphql.subscriptions.active", {
|
|
663
|
+
description: "Number of active GraphQL subscriptions"
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
class InvalidUsageError extends Data.TaggedError("InvalidUsageError") {
|
|
667
|
+
}
|
|
668
|
+
var ParsedArgsSchema = Schema.Struct({
|
|
669
|
+
port: Schema.optional(Schema.NumberFromString.pipe(Schema.int(), Schema.between(0, 65535))),
|
|
670
|
+
org: Schema.String
|
|
671
|
+
});
|
|
672
|
+
var parseArgs = (args) => Effect3.gen(function* () {
|
|
673
|
+
const parseResult = yield* Effect3.try({
|
|
674
|
+
try: () => utilParseArgs({
|
|
675
|
+
args,
|
|
676
|
+
options: {
|
|
677
|
+
port: { type: "string", short: "p" },
|
|
678
|
+
org: { type: "string", short: "o" }
|
|
679
|
+
},
|
|
680
|
+
strict: true,
|
|
681
|
+
allowPositionals: false
|
|
682
|
+
}),
|
|
683
|
+
catch: () => new InvalidUsageError({ _: undefined })
|
|
684
|
+
});
|
|
685
|
+
const org = parseResult.values.org ?? process.env["PF_ORG"];
|
|
686
|
+
if (!org) {
|
|
687
|
+
console.error("Error: --org is required (or set PF_ORG environment variable)");
|
|
688
|
+
return yield* new InvalidUsageError({ _: undefined });
|
|
689
|
+
}
|
|
690
|
+
return yield* Schema.decodeUnknown(ParsedArgsSchema)({
|
|
691
|
+
port: parseResult.values.port,
|
|
692
|
+
org
|
|
693
|
+
}).pipe(Effect3.mapError(() => new InvalidUsageError({ _: undefined })));
|
|
694
|
+
});
|
|
695
|
+
var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
696
|
+
const yoga = yield* Yoga;
|
|
697
|
+
const resolverRuntime = yield* ResolverRuntime;
|
|
698
|
+
const routeServerPluginWebhook = yield* makeServerPluginWebhookRouter;
|
|
699
|
+
const callbackSecret = yield* CallbackSecret;
|
|
700
|
+
const docStoreConfig = yield* LocalDocumentStoreConfig;
|
|
701
|
+
const dbConnectionInfo = yield* DatabaseConnectionInfo;
|
|
702
|
+
yield* Effect3.log(`\uD83D\uDCBE Connecting to database: ${dbConnectionInfo}`);
|
|
703
|
+
const activeSubscriptions = new Map;
|
|
704
|
+
let connectionCounter = 0;
|
|
705
|
+
let connectionIdCounter = 0;
|
|
706
|
+
const connectionToId = new WeakMap;
|
|
707
|
+
const wsToContext = new WeakMap;
|
|
708
|
+
const contextFactoryMutex = new Mutex;
|
|
709
|
+
const websocketHandler = makeHandler({
|
|
710
|
+
execute: (args) => args.rootValue.execute(args),
|
|
711
|
+
subscribe: (args) => args.rootValue.subscribe(args),
|
|
712
|
+
onConnect: (ctx) => {
|
|
713
|
+
connectionCounter++;
|
|
714
|
+
connectionIdCounter++;
|
|
715
|
+
const connId = connectionIdCounter;
|
|
716
|
+
connectionToId.set(ctx, connId);
|
|
717
|
+
wsToContext.set(ctx.extra.socket, ctx);
|
|
718
|
+
console.log(`
|
|
719
|
+
\uD83D\uDD0C [WS #${connId}] Connection OPENED (total active: ${connectionCounter})`);
|
|
720
|
+
console.log(` Timestamp: ${new Date().toISOString()}`);
|
|
721
|
+
resolverRuntime.runFork(Metric.set(activeWebSocketConnections, connectionCounter));
|
|
722
|
+
return true;
|
|
723
|
+
},
|
|
724
|
+
onComplete: (ctx, id) => {
|
|
725
|
+
const sub = activeSubscriptions.get(id);
|
|
726
|
+
const connId = connectionToId.get(ctx) ?? "?";
|
|
727
|
+
if (sub) {
|
|
728
|
+
const duration = Date.now() - sub.startTime.getTime();
|
|
729
|
+
console.log(`\u2705 [WS #${connId}] Subscription COMPLETED: id=${id.slice(0, 8)} operation=${sub.operation} duration=${duration}ms`);
|
|
730
|
+
activeSubscriptions.delete(id);
|
|
731
|
+
}
|
|
732
|
+
console.log(`\uD83D\uDCCA [WS] Active subscriptions: ${activeSubscriptions.size}`);
|
|
733
|
+
resolverRuntime.runFork(Metric.set(activeGraphqlSubscriptions, activeSubscriptions.size));
|
|
734
|
+
},
|
|
735
|
+
onSubscribe: async (ctx, id, payload) => {
|
|
736
|
+
const connId = connectionToId.get(ctx) ?? 0;
|
|
737
|
+
activeSubscriptions.set(id, {
|
|
738
|
+
operation: payload.operationName || "unknown",
|
|
739
|
+
startTime: new Date,
|
|
740
|
+
connectionId: connId
|
|
741
|
+
});
|
|
742
|
+
console.log(`
|
|
743
|
+
\uD83D\uDCE5 [WS #${connId}] New subscription: id=${id.slice(0, 8)} operation=${payload.operationName}`);
|
|
744
|
+
console.log(` Timestamp: ${new Date().toISOString()}`);
|
|
745
|
+
console.log(`\uD83D\uDCCA [WS] Active subscriptions: ${activeSubscriptions.size}`);
|
|
746
|
+
resolverRuntime.runFork(Metric.set(activeGraphqlSubscriptions, activeSubscriptions.size));
|
|
747
|
+
const grouped = new Map;
|
|
748
|
+
for (const [, s] of activeSubscriptions) {
|
|
749
|
+
grouped.set(s.operation, (grouped.get(s.operation) || 0) + 1);
|
|
750
|
+
}
|
|
751
|
+
console.log(" By operation:", Array.from(grouped.entries()).map(([op, count]) => `${op}:${count}`).join(", "));
|
|
752
|
+
try {
|
|
753
|
+
const upgradeRequest = ctx.extra.socket.data.request;
|
|
754
|
+
const {
|
|
755
|
+
schema,
|
|
756
|
+
execute,
|
|
757
|
+
subscribe,
|
|
758
|
+
contextFactory,
|
|
759
|
+
parse,
|
|
760
|
+
validate
|
|
761
|
+
} = yoga.getEnveloped({
|
|
762
|
+
...ctx,
|
|
763
|
+
connectionParams: ctx.connectionParams,
|
|
764
|
+
request: upgradeRequest,
|
|
765
|
+
socket: ctx.extra.socket,
|
|
766
|
+
params: payload
|
|
767
|
+
});
|
|
768
|
+
const contextValue = await contextFactoryMutex.runExclusive(async () => contextFactory());
|
|
769
|
+
const args = {
|
|
770
|
+
schema,
|
|
771
|
+
operationName: payload.operationName,
|
|
772
|
+
document: parse(payload.query),
|
|
773
|
+
variableValues: payload.variables,
|
|
774
|
+
contextValue,
|
|
775
|
+
rootValue: {
|
|
776
|
+
execute,
|
|
777
|
+
subscribe
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
const errors = validate(args.schema, args.document);
|
|
781
|
+
if (errors.length)
|
|
782
|
+
return errors;
|
|
783
|
+
return args;
|
|
784
|
+
} catch (error) {
|
|
785
|
+
console.error(`[WS #${connId}] Subscription setup failed:`, error);
|
|
786
|
+
if (error instanceof GraphQLError) {
|
|
787
|
+
return [
|
|
788
|
+
new GraphQLError(error.message, {
|
|
789
|
+
extensions: error.extensions
|
|
790
|
+
})
|
|
791
|
+
];
|
|
792
|
+
}
|
|
793
|
+
return [new GraphQLError("Unexpected error.")];
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
const serverOptions = {
|
|
798
|
+
fetch: async (request, srv) => {
|
|
799
|
+
const url = new URL(request.url);
|
|
800
|
+
const webhookEffect = routeServerPluginWebhook(request);
|
|
801
|
+
if (webhookEffect !== undefined) {
|
|
802
|
+
return resolverRuntime.runPromise(webhookEffect);
|
|
803
|
+
}
|
|
804
|
+
if (url.pathname === "/internal/todo-event" && request.method === "POST") {
|
|
805
|
+
const providedSecret = request.headers.get("x-callback-secret");
|
|
806
|
+
if (Option2.isNone(callbackSecret)) {
|
|
807
|
+
return new Response("Unauthorized", { status: 401 });
|
|
808
|
+
}
|
|
809
|
+
if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
|
|
810
|
+
return new Response("Unauthorized", { status: 401 });
|
|
811
|
+
}
|
|
812
|
+
const event = await request.json();
|
|
813
|
+
const { schema } = yoga.getEnveloped({ req: request });
|
|
814
|
+
const emitEffect = Effect3.flatMap(TodoEvents, (todoEvents) => todoEvents.emit(event, schema));
|
|
815
|
+
const result = await resolverRuntime.runPromiseExit(emitEffect);
|
|
816
|
+
if (Exit.isFailure(result)) {
|
|
817
|
+
console.error("Failed to process todo event callback:", result.cause);
|
|
818
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
819
|
+
}
|
|
820
|
+
return new Response(null, { status: 204 });
|
|
821
|
+
}
|
|
822
|
+
if (url.pathname === "/internal/process-event" && request.method === "POST") {
|
|
823
|
+
const providedSecret = request.headers.get("x-callback-secret");
|
|
824
|
+
if (Option2.isNone(callbackSecret)) {
|
|
825
|
+
return new Response("Unauthorized", { status: 401 });
|
|
826
|
+
}
|
|
827
|
+
if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
|
|
828
|
+
return new Response("Unauthorized", { status: 401 });
|
|
829
|
+
}
|
|
830
|
+
const event = await request.json();
|
|
831
|
+
const { schema } = yoga.getEnveloped({ req: request });
|
|
832
|
+
const emitEffect = Effect3.flatMap(ProcessEvents, (processEvents) => processEvents.emit(event, schema));
|
|
833
|
+
const result = await resolverRuntime.runPromiseExit(emitEffect);
|
|
834
|
+
if (Exit.isFailure(result)) {
|
|
835
|
+
console.error("Failed to process process event callback:", result.cause);
|
|
836
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
837
|
+
}
|
|
838
|
+
return new Response(null, { status: 204 });
|
|
839
|
+
}
|
|
840
|
+
if (url.pathname === "/internal/execution-event" && request.method === "POST") {
|
|
841
|
+
const providedSecret = request.headers.get("x-callback-secret");
|
|
842
|
+
if (Option2.isNone(callbackSecret)) {
|
|
843
|
+
return new Response("Unauthorized", { status: 401 });
|
|
844
|
+
}
|
|
845
|
+
if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
|
|
846
|
+
return new Response("Unauthorized", { status: 401 });
|
|
847
|
+
}
|
|
848
|
+
const event = await request.json();
|
|
849
|
+
const { schema } = yoga.getEnveloped({ req: request });
|
|
850
|
+
const emitEffect = Effect3.flatMap(ExecutionEvents, (executionEvents) => executionEvents.emit(event, schema));
|
|
851
|
+
const result = await resolverRuntime.runPromiseExit(emitEffect);
|
|
852
|
+
if (Exit.isFailure(result)) {
|
|
853
|
+
console.error("Failed to process execution event callback:", result.cause);
|
|
854
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
855
|
+
}
|
|
856
|
+
return new Response(null, { status: 204 });
|
|
857
|
+
}
|
|
858
|
+
if (url.pathname === "/internal/import-completed" && request.method === "POST") {
|
|
859
|
+
const providedSecret = request.headers.get("x-callback-secret");
|
|
860
|
+
if (Option2.isNone(callbackSecret)) {
|
|
861
|
+
return new Response("Unauthorized", { status: 401 });
|
|
862
|
+
}
|
|
863
|
+
if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
|
|
864
|
+
return new Response("Unauthorized", { status: 401 });
|
|
865
|
+
}
|
|
866
|
+
const ImportCompletedPayload = Schema.Struct({
|
|
867
|
+
processPaths: Schema.Array(Schema.String)
|
|
868
|
+
});
|
|
869
|
+
let body;
|
|
870
|
+
try {
|
|
871
|
+
body = Schema.decodeUnknownSync(ImportCompletedPayload)(await request.json());
|
|
872
|
+
} catch {
|
|
873
|
+
return new Response("Invalid request body", { status: 400 });
|
|
874
|
+
}
|
|
875
|
+
const { processPaths } = body;
|
|
876
|
+
const { schema } = yoga.getEnveloped({ req: request });
|
|
877
|
+
const importCompletedEffect = Effect3.gen(function* () {
|
|
878
|
+
yield* Effect3.log(`Received import-completed for ${processPaths.length} process(es): ${processPaths.join(", ")}`);
|
|
879
|
+
const processOps = yield* ProcessCollectionOps;
|
|
880
|
+
const executionOps = yield* ExecutionCollectionOps;
|
|
881
|
+
const todoOps = yield* TodoCollectionOps;
|
|
882
|
+
const todoSummaryComputation = yield* TodoSummaryComputation;
|
|
883
|
+
const allProcessRows = yield* processOps.pull(null, 1e4);
|
|
884
|
+
const matchedProcessRows = allProcessRows.filter((row) => processPaths.includes(row.path));
|
|
885
|
+
if (matchedProcessRows.length === 0) {
|
|
886
|
+
yield* Effect3.log(`No matching processes found (${allProcessRows.length} in DB, none matching requested paths)`);
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
const graphqlProcesses = yield* Effect3.all(matchedProcessRows.map((row) => processOps.mapToGraphql(row)), { concurrency: "unbounded" });
|
|
890
|
+
const lastProcess = graphqlProcesses[graphqlProcesses.length - 1];
|
|
891
|
+
if (lastProcess) {
|
|
892
|
+
const processEvent = {
|
|
893
|
+
documents: graphqlProcesses,
|
|
894
|
+
checkpoint: {
|
|
895
|
+
id: lastProcess.id,
|
|
896
|
+
updatedAt: lastProcess.updatedAt
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
yield* Effect3.flatMap(ProcessEvents, (processEvents) => processEvents.emit(processEvent, schema));
|
|
900
|
+
}
|
|
901
|
+
yield* Effect3.log(`Emitted ${graphqlProcesses.length} process update(s)`);
|
|
902
|
+
const matchedPaths = new Set(graphqlProcesses.map((p) => p.path));
|
|
903
|
+
const allExecutionRows = yield* executionOps.pull(null, 1e4);
|
|
904
|
+
const matchedExecutionRows = allExecutionRows.filter((row) => matchedPaths.has(row.execution.processPath));
|
|
905
|
+
if (matchedExecutionRows.length > 0) {
|
|
906
|
+
const graphqlExecutions = yield* Effect3.all(matchedExecutionRows.map((row) => executionOps.mapToGraphql(row).pipe(Effect3.map((document) => ({
|
|
907
|
+
...document,
|
|
908
|
+
startedByEmail: row.execution.startedByEmail,
|
|
909
|
+
startedByRolePath: row.execution.startedByRolePath
|
|
910
|
+
})))), { concurrency: "unbounded" });
|
|
911
|
+
const lastExecution = graphqlExecutions[graphqlExecutions.length - 1];
|
|
912
|
+
if (lastExecution) {
|
|
913
|
+
const executionEvent = {
|
|
914
|
+
documents: graphqlExecutions,
|
|
915
|
+
checkpoint: {
|
|
916
|
+
id: lastExecution.id,
|
|
917
|
+
updatedAt: lastExecution.updatedAt
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
yield* Effect3.flatMap(ExecutionEvents, (executionEvents) => executionEvents.emit(executionEvent, schema));
|
|
921
|
+
}
|
|
922
|
+
yield* Effect3.log(`Emitted ${graphqlExecutions.length} execution update(s)`);
|
|
923
|
+
}
|
|
924
|
+
const matchedExecutionIds = new Set(matchedExecutionRows.map((row) => row.execution.id));
|
|
925
|
+
const allTodoRows = yield* todoOps.pull(null, 1e4);
|
|
926
|
+
const matchedTodoRows = allTodoRows.filter((row) => matchedExecutionIds.has(row.processExecutionId));
|
|
927
|
+
if (matchedTodoRows.length > 0) {
|
|
928
|
+
const matchedTodoRowsWithSummary = yield* todoSummaryComputation.enrichWithSummaries(matchedTodoRows);
|
|
929
|
+
const graphqlTodos = yield* Effect3.all(matchedTodoRowsWithSummary.map((row) => todoOps.mapToGraphql(row)), { concurrency: "unbounded" });
|
|
930
|
+
const sortedTodos = [...graphqlTodos].sort((a, b) => {
|
|
931
|
+
if (a.updatedAt !== b.updatedAt) {
|
|
932
|
+
return a.updatedAt - b.updatedAt;
|
|
933
|
+
}
|
|
934
|
+
return a.id.localeCompare(b.id);
|
|
935
|
+
});
|
|
936
|
+
const lastTodo = sortedTodos[sortedTodos.length - 1];
|
|
937
|
+
if (lastTodo) {
|
|
938
|
+
const todoEvent = {
|
|
939
|
+
documents: graphqlTodos,
|
|
940
|
+
checkpoint: {
|
|
941
|
+
id: lastTodo.id,
|
|
942
|
+
updatedAt: lastTodo.updatedAt,
|
|
943
|
+
mode: "INCREMENTAL" /* Incremental */
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
yield* Effect3.flatMap(TodoEvents, (todoEvents) => todoEvents.emit(todoEvent, schema));
|
|
947
|
+
}
|
|
948
|
+
yield* Effect3.log(`Emitted ${graphqlTodos.length} todo update(s)`);
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
const result = await resolverRuntime.runPromiseExit(importCompletedEffect);
|
|
952
|
+
if (Exit.isFailure(result)) {
|
|
953
|
+
await resolverRuntime.runPromise(Effect3.logError("Failed to process import-completed").pipe(Effect3.annotateLogs("cause", String(result.cause))));
|
|
954
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
955
|
+
}
|
|
956
|
+
await resolverRuntime.runPromise(Effect3.log("Import-completed processing done"));
|
|
957
|
+
return new Response(null, { status: 204 });
|
|
958
|
+
}
|
|
959
|
+
const fileCorsHeaders = {
|
|
960
|
+
"Access-Control-Allow-Origin": "*",
|
|
961
|
+
"Access-Control-Allow-Methods": "GET, PUT, OPTIONS",
|
|
962
|
+
"Access-Control-Allow-Headers": "Content-Type"
|
|
963
|
+
};
|
|
964
|
+
if (url.pathname.startsWith("/files/") && request.method === "OPTIONS") {
|
|
965
|
+
return new Response(null, { status: 204, headers: fileCorsHeaders });
|
|
966
|
+
}
|
|
967
|
+
if (url.pathname.startsWith("/files/") && request.method === "PUT") {
|
|
968
|
+
const pathParts = url.pathname.slice("/files/".length).split("/");
|
|
969
|
+
if (pathParts.length !== 2) {
|
|
970
|
+
return new Response("Bad Request", { status: 400 });
|
|
971
|
+
}
|
|
972
|
+
const [storePrefix, fileId] = pathParts;
|
|
973
|
+
const token = url.searchParams.get("token");
|
|
974
|
+
const expires = url.searchParams.get("expires");
|
|
975
|
+
if (!storePrefix || !fileId || !token || !expires) {
|
|
976
|
+
return new Response("Bad Request", { status: 400 });
|
|
977
|
+
}
|
|
978
|
+
const expiresNum = Number(expires);
|
|
979
|
+
if (Number.isNaN(expiresNum) || Date.now() / 1000 > expiresNum) {
|
|
980
|
+
return new Response("URL expired", { status: 403 });
|
|
981
|
+
}
|
|
982
|
+
if (Option2.isNone(callbackSecret)) {
|
|
983
|
+
return new Response("Unauthorized", { status: 401 });
|
|
984
|
+
}
|
|
985
|
+
const expectedToken = generateLocalDocumentStoreToken(storePrefix, fileId, expires, callbackSecret.value);
|
|
986
|
+
if (!constantTimeEqual(token, expectedToken)) {
|
|
987
|
+
return new Response("Unauthorized", { status: 401 });
|
|
988
|
+
}
|
|
989
|
+
const fileResult = await resolverRuntime.runPromiseExit(Effect3.gen(function* () {
|
|
990
|
+
const fileOps = yield* FileOperations;
|
|
991
|
+
return yield* fileOps.getFileWithStore(fileId);
|
|
992
|
+
}));
|
|
993
|
+
if (Exit.isFailure(fileResult)) {
|
|
994
|
+
console.error("File validation failed:", fileResult.cause);
|
|
995
|
+
return new Response("Internal Server Error", {
|
|
996
|
+
status: 500,
|
|
997
|
+
headers: fileCorsHeaders
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
const fileRecord = fileResult.value;
|
|
1001
|
+
if (!fileRecord) {
|
|
1002
|
+
return new Response("File not found", {
|
|
1003
|
+
status: 404,
|
|
1004
|
+
headers: fileCorsHeaders
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
if (!fileRecord.uploadPending) {
|
|
1008
|
+
return new Response("File already uploaded", {
|
|
1009
|
+
status: 409,
|
|
1010
|
+
headers: fileCorsHeaders
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
const contentType = request.headers.get("content-type") ?? "application/octet-stream";
|
|
1014
|
+
if (fileRecord.acceptedTypes && fileRecord.acceptedTypes.length > 0 && !fileRecord.acceptedTypes.includes(contentType)) {
|
|
1015
|
+
return new Response(`Content type '${contentType}' not accepted. Allowed: ${fileRecord.acceptedTypes.join(", ")}`, { status: 415, headers: fileCorsHeaders });
|
|
1016
|
+
}
|
|
1017
|
+
const maxFileSize = fileRecord.sizeLimit ?? docStoreConfig.maxFileSize;
|
|
1018
|
+
const contentLength = request.headers.get("content-length");
|
|
1019
|
+
if (contentLength != null) {
|
|
1020
|
+
const declaredSize = Number(contentLength);
|
|
1021
|
+
if (declaredSize > maxFileSize) {
|
|
1022
|
+
return new Response(`File too large: ${declaredSize} bytes exceeds limit of ${maxFileSize} bytes`, { status: 413, headers: fileCorsHeaders });
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
const storeDir = join(docStoreConfig.storagePath, storePrefix);
|
|
1026
|
+
if (!existsSync(storeDir)) {
|
|
1027
|
+
mkdirSync(storeDir, { recursive: true });
|
|
1028
|
+
}
|
|
1029
|
+
const filePath = join(docStoreConfig.storagePath, storePrefix, fileId);
|
|
1030
|
+
const requestBody = request.body;
|
|
1031
|
+
if (!requestBody) {
|
|
1032
|
+
return new Response("Empty request body", {
|
|
1033
|
+
status: 400,
|
|
1034
|
+
headers: fileCorsHeaders
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
let bytesWritten = 0;
|
|
1038
|
+
const writer = Bun.file(filePath).writer();
|
|
1039
|
+
let limitExceeded = false;
|
|
1040
|
+
try {
|
|
1041
|
+
for await (const chunk of requestBody) {
|
|
1042
|
+
bytesWritten += chunk.byteLength;
|
|
1043
|
+
if (bytesWritten > maxFileSize) {
|
|
1044
|
+
limitExceeded = true;
|
|
1045
|
+
break;
|
|
1046
|
+
}
|
|
1047
|
+
writer.write(chunk);
|
|
1048
|
+
}
|
|
1049
|
+
await writer.end();
|
|
1050
|
+
} catch (writeError) {
|
|
1051
|
+
try {
|
|
1052
|
+
await writer.end();
|
|
1053
|
+
} catch {}
|
|
1054
|
+
try {
|
|
1055
|
+
unlinkSync(filePath);
|
|
1056
|
+
} catch {}
|
|
1057
|
+
console.error(`Failed to write file ${fileId}:`, writeError);
|
|
1058
|
+
return new Response("Internal Server Error", {
|
|
1059
|
+
status: 500,
|
|
1060
|
+
headers: fileCorsHeaders
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
if (limitExceeded) {
|
|
1064
|
+
try {
|
|
1065
|
+
unlinkSync(filePath);
|
|
1066
|
+
} catch {}
|
|
1067
|
+
return new Response(`File too large: exceeds limit of ${maxFileSize} bytes`, { status: 413, headers: fileCorsHeaders });
|
|
1068
|
+
}
|
|
1069
|
+
const markResult = await resolverRuntime.runPromiseExit(Effect3.gen(function* () {
|
|
1070
|
+
const fileOps = yield* FileOperations;
|
|
1071
|
+
yield* fileOps.markFileUploaded(fileId, bytesWritten, contentType);
|
|
1072
|
+
}).pipe(Effect3.retry(Schedule.exponential("100 millis").pipe(Schedule.compose(Schedule.recurs(2))))));
|
|
1073
|
+
if (Exit.isFailure(markResult)) {
|
|
1074
|
+
console.error(`Failed to mark file ${fileId} as uploaded in DB:`, markResult.cause);
|
|
1075
|
+
try {
|
|
1076
|
+
unlinkSync(filePath);
|
|
1077
|
+
} catch {}
|
|
1078
|
+
return new Response("Internal Server Error", {
|
|
1079
|
+
status: 500,
|
|
1080
|
+
headers: fileCorsHeaders
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
console.log(`
|
|
1084
|
+
\uD83D\uDCE4 File UPLOADED: id=${fileId.slice(0, 8)}\u2026 store=${storePrefix} size=${bytesWritten} bytes contentType=${contentType}`);
|
|
1085
|
+
return new Response(null, {
|
|
1086
|
+
status: 204,
|
|
1087
|
+
headers: fileCorsHeaders
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
if (url.pathname.startsWith("/files/") && request.method === "GET") {
|
|
1091
|
+
const pathParts = url.pathname.slice("/files/".length).split("/");
|
|
1092
|
+
if (pathParts.length !== 2) {
|
|
1093
|
+
return new Response("Bad Request", { status: 400 });
|
|
1094
|
+
}
|
|
1095
|
+
const [storePrefix, fileId] = pathParts;
|
|
1096
|
+
const token = url.searchParams.get("token");
|
|
1097
|
+
const expires = url.searchParams.get("expires");
|
|
1098
|
+
const filename = url.searchParams.get("filename");
|
|
1099
|
+
if (!storePrefix || !fileId || !token || !expires) {
|
|
1100
|
+
return new Response("Bad Request", { status: 400 });
|
|
1101
|
+
}
|
|
1102
|
+
const expiresNum = Number(expires);
|
|
1103
|
+
if (Number.isNaN(expiresNum) || Date.now() / 1000 > expiresNum) {
|
|
1104
|
+
return new Response("URL expired", { status: 403 });
|
|
1105
|
+
}
|
|
1106
|
+
if (filename && hasInvalidDownloadFilename(filename)) {
|
|
1107
|
+
return new Response("Bad Request", { status: 400 });
|
|
1108
|
+
}
|
|
1109
|
+
if (Option2.isNone(callbackSecret)) {
|
|
1110
|
+
return new Response("Unauthorized", { status: 401 });
|
|
1111
|
+
}
|
|
1112
|
+
const expectedToken = generateLocalDocumentStoreToken(storePrefix, fileId, expires, callbackSecret.value, filename ?? undefined);
|
|
1113
|
+
if (!constantTimeEqual(token, expectedToken)) {
|
|
1114
|
+
return new Response("Unauthorized", { status: 401 });
|
|
1115
|
+
}
|
|
1116
|
+
const filePath = join(docStoreConfig.storagePath, storePrefix, fileId);
|
|
1117
|
+
if (!existsSync(filePath)) {
|
|
1118
|
+
console.log(`
|
|
1119
|
+
\uD83D\uDCE5 File DOWNLOAD failed: id=${fileId.slice(0, 8)}\u2026 store=${storePrefix} \u2014 not found`);
|
|
1120
|
+
return new Response("Not Found", { status: 404 });
|
|
1121
|
+
}
|
|
1122
|
+
const file = Bun.file(filePath);
|
|
1123
|
+
const responseHeaders = {
|
|
1124
|
+
...fileCorsHeaders
|
|
1125
|
+
};
|
|
1126
|
+
if (filename) {
|
|
1127
|
+
responseHeaders["Content-Disposition"] = formatContentDisposition(filename);
|
|
1128
|
+
}
|
|
1129
|
+
console.log(`
|
|
1130
|
+
\uD83D\uDCE5 File DOWNLOADED: id=${fileId.slice(0, 8)}\u2026 store=${storePrefix} size=${file.size} bytes`);
|
|
1131
|
+
return new Response(file, { headers: responseHeaders });
|
|
1132
|
+
}
|
|
1133
|
+
const upgradeHeader = request.headers.get("upgrade");
|
|
1134
|
+
if (upgradeHeader === "websocket") {
|
|
1135
|
+
const protocol = request.headers.get("sec-websocket-protocol") || "";
|
|
1136
|
+
if (!handleProtocols(protocol)) {
|
|
1137
|
+
return new Response("Bad Request", { status: 400 });
|
|
1138
|
+
}
|
|
1139
|
+
if (!srv.upgrade(request, {
|
|
1140
|
+
data: {
|
|
1141
|
+
request
|
|
1142
|
+
}
|
|
1143
|
+
})) {
|
|
1144
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
1145
|
+
}
|
|
1146
|
+
return new Response;
|
|
1147
|
+
}
|
|
1148
|
+
return yoga.fetch(request, srv);
|
|
1149
|
+
},
|
|
1150
|
+
websocket: {
|
|
1151
|
+
...websocketHandler,
|
|
1152
|
+
open(ws) {
|
|
1153
|
+
const result = websocketHandler.open?.(ws);
|
|
1154
|
+
return result;
|
|
1155
|
+
},
|
|
1156
|
+
close(ws, code, reason) {
|
|
1157
|
+
const ctx = wsToContext.get(ws);
|
|
1158
|
+
if (ctx) {
|
|
1159
|
+
connectionCounter--;
|
|
1160
|
+
const connId = connectionToId.get(ctx) ?? "?";
|
|
1161
|
+
console.log(`
|
|
1162
|
+
\uD83D\uDD0C [WS #${connId}] Connection CLOSED: code=${code} reason=${reason} (remaining: ${connectionCounter})`);
|
|
1163
|
+
console.log(` Timestamp: ${new Date().toISOString()}`);
|
|
1164
|
+
resolverRuntime.runFork(Metric.set(activeWebSocketConnections, connectionCounter));
|
|
1165
|
+
const remaining = Array.from(activeSubscriptions.entries()).filter(([, s]) => s.connectionId === connId);
|
|
1166
|
+
if (remaining.length > 0) {
|
|
1167
|
+
console.log(" \uD83E\uDDF9 Cleaning up orphaned subscriptions:", remaining.map(([id, s]) => `${id.slice(0, 8)}:${s.operation}`).join(", "));
|
|
1168
|
+
for (const [id] of remaining) {
|
|
1169
|
+
activeSubscriptions.delete(id);
|
|
1170
|
+
}
|
|
1171
|
+
console.log(`\uD83D\uDCCA [WS] Active subscriptions: ${activeSubscriptions.size}`);
|
|
1172
|
+
resolverRuntime.runFork(Metric.set(activeGraphqlSubscriptions, activeSubscriptions.size));
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
return websocketHandler.close?.(ws, code, reason);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
const serveEffect = Option2.isSome(port) ? serveOnExactPort(port.value, serverOptions) : serveWithPortFallback(DEFAULT_GRAPHQL_PORT, serverOptions);
|
|
1180
|
+
const server = yield* Effect3.acquireRelease(serveEffect, (srv) => Effect3.promise(() => srv.stop()));
|
|
1181
|
+
yield* Effect3.log(`\uD83D\uDE80 GraphQL server running at http://${server.hostname}:${server.port}/graphql`);
|
|
1182
|
+
yield* Effect3.log(`\uD83D\uDD0C WebSocket subscriptions available at ws://${server.hostname}:${server.port}/graphql`);
|
|
1183
|
+
return server;
|
|
1184
|
+
});
|
|
1185
|
+
|
|
1186
|
+
// src/graphql-server/graphql-server.ts
|
|
1187
|
+
var makeAuthorizationLayer = (policyPaths, schemaPaths) => {
|
|
1188
|
+
if (policyPaths.length > 0) {
|
|
1189
|
+
const hotReloadConfig = LocalCedarConfigHotReload("/", policyPaths, schemaPaths);
|
|
1190
|
+
return Layer4.provideMerge(LocalCedarAuthorizationLive, hotReloadConfig);
|
|
1191
|
+
}
|
|
1192
|
+
const staticConfig = LocalCedarConfigStatic(undefined, schemaPaths);
|
|
1193
|
+
return Layer4.provideMerge(LocalCedarAuthorizationLive, staticConfig);
|
|
1194
|
+
};
|
|
1195
|
+
var CliConfig = Context.GenericTag("processfocus:internal-tag/runtime-local/GraphqlServerCliConfig");
|
|
1196
|
+
var CliConfigLive = Layer4.effect(CliConfig, parseArgs(process.argv.slice(2)).pipe(Effect4.map((args) => ({
|
|
1197
|
+
port: Option3.fromNullable(args.port),
|
|
1198
|
+
org: args.org
|
|
1199
|
+
})), Effect4.catchAll((error) => {
|
|
1200
|
+
console.error("Invalid arguments. Usage: bun run main.ts [--port PORT | -p PORT] [--org ORG | -o ORG]");
|
|
1201
|
+
console.error(" --port, -p Exact port number (fails if in use, does not write port file)");
|
|
1202
|
+
console.error(" --org, -o Path to org project (or set PF_ORG env var)");
|
|
1203
|
+
return Effect4.fail(error);
|
|
1204
|
+
})));
|
|
1205
|
+
var RequestTimeLive = Layer4.succeed(RequestTime, FiberRef.unsafeMake(DateTime.unsafeMake(0)));
|
|
1206
|
+
var UserDetailsLive = Layer4.succeed(UserDetails, FiberRef.unsafeMake({
|
|
1207
|
+
by: "SYSTEM",
|
|
1208
|
+
id: null
|
|
1209
|
+
}));
|
|
1210
|
+
var CurrentPrincipalLive = Layer4.succeed(CurrentPrincipal, FiberRef.unsafeMake(null));
|
|
1211
|
+
var businessMetricDimensions = resolveBusinessMetricDimensions({
|
|
1212
|
+
accountId: process.env["PF_AWS_ACCOUNT_ID"],
|
|
1213
|
+
project: process.env["PF_PROJECT"],
|
|
1214
|
+
environment: process.env["PF_ENV"]
|
|
1215
|
+
});
|
|
1216
|
+
var BusinessMetricDimensionsLive = Layer4.succeed(BusinessMetricDimensions, businessMetricDimensions);
|
|
1217
|
+
var DashboardActivityLive = process.env["PF_ANALYTICS_IDENTITY_KEY"] ? makeDashboardActivityLayer({
|
|
1218
|
+
dimensions: businessMetricDimensions,
|
|
1219
|
+
key: Redacted.make(process.env["PF_ANALYTICS_IDENTITY_KEY"] ?? ""),
|
|
1220
|
+
logsUrl: process.env["OTLP_LOGS_URL"] ?? "http://127.0.0.1:4318/v1/logs",
|
|
1221
|
+
headers: {}
|
|
1222
|
+
}) : Layer4.empty;
|
|
1223
|
+
var NodeSdkLive = Layer4.unwrapEffect(Effect4.gen(function* () {
|
|
1224
|
+
const otlpMetricsUrl = yield* Config2.string("OTLP_METRICS_URL").pipe(Config2.withDefault("http://127.0.0.1:4318/v1/metrics"));
|
|
1225
|
+
const otlpTracesUrl = yield* Config2.string("OTLP_TRACES_URL").pipe(Config2.withDefault("http://127.0.0.1:4318/v1/traces"));
|
|
1226
|
+
return Otel.NodeSdk.layer(() => ({
|
|
1227
|
+
resource: {
|
|
1228
|
+
serviceName: "graphql-server",
|
|
1229
|
+
attributes: {
|
|
1230
|
+
"pf.account.id": businessMetricDimensions.accountId,
|
|
1231
|
+
"pf.account.name": businessMetricDimensions.accountName,
|
|
1232
|
+
"pf.account.scope": businessMetricDimensions.accountScope,
|
|
1233
|
+
"pf.project": businessMetricDimensions.project,
|
|
1234
|
+
"pf.env": businessMetricDimensions.environment
|
|
1235
|
+
}
|
|
1236
|
+
},
|
|
1237
|
+
metricReader: new PeriodicExportingMetricReader({
|
|
1238
|
+
exporter: new OTLPMetricExporter({
|
|
1239
|
+
url: otlpMetricsUrl
|
|
1240
|
+
})
|
|
1241
|
+
}),
|
|
1242
|
+
spanProcessor: new BatchSpanProcessor(new OTLPTraceExporter({
|
|
1243
|
+
url: otlpTracesUrl
|
|
1244
|
+
}))
|
|
1245
|
+
}));
|
|
1246
|
+
}));
|
|
1247
|
+
var main = Effect4.gen(function* () {
|
|
1248
|
+
const cliConfig = yield* CliConfig;
|
|
1249
|
+
const OrgProviderLayer = yield* Layer4.memoize(OrganisationProviderFromPathDev(cliConfig.org).pipe(Layer4.provide(layer2)));
|
|
1250
|
+
const CedarPoliciesLayer = OrgCedarPoliciesProvider.pipe(Layer4.provide(OrgProviderLayer));
|
|
1251
|
+
const orgProvider = yield* OrganisationProvider.pipe(Effect4.provide(OrgProviderLayer));
|
|
1252
|
+
yield* warnIgnoredCronDeclarations(orgProvider.organisation, "local GraphQL runtime");
|
|
1253
|
+
yield* Effect4.log(`\u2705 Loaded organisation: ${orgProvider.organisation.name}`);
|
|
1254
|
+
if (orgProvider.customDbLayer) {
|
|
1255
|
+
yield* Effect4.log(`\uD83D\uDCE6 Custom database layer available from organisation`);
|
|
1256
|
+
}
|
|
1257
|
+
const cedarPolicies = yield* CedarPoliciesProvider.pipe(Effect4.provide(CedarPoliciesLayer));
|
|
1258
|
+
yield* Effect4.log(`\uD83D\uDCDC Loaded ${cedarPolicies.policyPaths.length} Cedar policy files`);
|
|
1259
|
+
const DynamicSchemaConfigLive = Layer4.succeed(DynamicSchemaConfig, {
|
|
1260
|
+
schemaPath: orgProvider.schemaPath
|
|
1261
|
+
});
|
|
1262
|
+
const internalApiSecret = process.env["INTERNAL_API_SECRET"] ?? "dev-secret";
|
|
1263
|
+
let resolvedServerPort = Option3.isSome(cliConfig.port) ? cliConfig.port.value : DEFAULT_GRAPHQL_PORT;
|
|
1264
|
+
const LocalDocumentStoreConfigLive = Layer4.succeed(LocalDocumentStoreConfig, {
|
|
1265
|
+
baseUrl: () => `http://localhost:${resolvedServerPort}`,
|
|
1266
|
+
storagePath: `${orgProvider.orgPath}/files`,
|
|
1267
|
+
secret: internalApiSecret,
|
|
1268
|
+
maxFileSize: 100 * 1024 * 1024
|
|
1269
|
+
});
|
|
1270
|
+
const AuthorizationLive = makeAuthorizationLayer(cedarPolicies.policyPaths, cedarPolicies.schemaPaths);
|
|
1271
|
+
const TodoSummaryComputationWithDeps = TodoSummaryComputationLive.pipe(Layer4.provide(SqliteGraphqlDbOperationsLive), Layer4.provide(OrgProviderLayer));
|
|
1272
|
+
const SlaCalculationServiceWithDeps = SlaCalculationServiceLive.pipe(Layer4.provide(SqliteGraphqlDbOperationsLive));
|
|
1273
|
+
const ExecutionCollectionOpsWithDeps = ExecutionCollectionOpsLive.pipe(Layer4.provide(SlaCalculationServiceWithDeps), Layer4.provide(SqliteGraphqlDbOperationsLive));
|
|
1274
|
+
const ListExportServiceWithDeps = ListExportServiceLive.pipe(Layer4.provide(LocalDocumentStoreServiceLive), Layer4.provide(LocalDocumentStoreConfigLive), Layer4.provide(AuthorizationLive));
|
|
1275
|
+
const LocalSqlClientLive = makeLocalSqlClientLayer({
|
|
1276
|
+
busy_timeout: LOCAL_SQLITE_BUSY_TIMEOUT_MS
|
|
1277
|
+
});
|
|
1278
|
+
const customDbLayerDeps = Layer4.mergeAll(SqliteFileOperationsLive, AuthorizationLive, CurrentPrincipalLive, BusinessMetricDimensionsLive, DashboardActivityLive, RequestTimeLive).pipe(Layer4.provideMerge(TypedSqliteDrizzleLayer), Layer4.provideMerge(LocalSqlClientLive));
|
|
1279
|
+
const customDbLayerWithDeps = orgProvider.customDbLayer ? Layer4.provide(orgProvider.customDbLayer, customDbLayerDeps) : undefined;
|
|
1280
|
+
const HttpCedarReloadNotifierWithDeps = HttpCedarReloadNotifierLive.pipe(Layer4.provide(layer));
|
|
1281
|
+
const SqliteQueueWithRequestContext = SqliteQueueServiceLive.pipe(Layer4.provide(Layer4.merge(RequestTimeLive, UserDetailsLive)));
|
|
1282
|
+
const AppLayer = Layer4.mergeAll(DelegationSessionServiceIsolated.pipe(Layer4.provide(Layer4.mergeAll(SqliteAuthenticationDatabaseLive, SqliteDelegationDatabaseLive)), Layer4.provide(AuthorizationLive)), SqliteGraphqlDbOperationsLive, SqliteFileOperationsLive, SqliteFlowExecutionOperationsLive, SqliteCompletedJobOperationsLive, SqliteScheduledFlowOperationsLive, SqliteQueueWithRequestContext, DynamicSchemaConfigLive, Layer4.provide(LocalDocumentStoreServiceLive, LocalDocumentStoreConfigLive), LocalDocumentStoreConfigLive, ListExportServiceWithDeps, DraftProcessEventsLive, TodoEventsLive, ProcessEventsLive, ExecutionEventsLive, RequestTimeLive, UserDetailsLive, CurrentPrincipalLive, BusinessMetricDimensionsLive, DashboardActivityLive, AuthorizationLive, TodoSummaryComputationWithDeps, SlaCalculationServiceWithDeps, HttpCedarReloadNotifierWithDeps, Layer4.provide(DraftProcessExecutionCollectionOpsLive, SqliteGraphqlDbOperationsLive), Layer4.provide(ProcessCollectionOpsLive, SqliteGraphqlDbOperationsLive), Layer4.provide(ProcessDurationServiceLive, SqliteGraphqlDbOperationsLive), Layer4.provide(TodoCollectionOpsLive, SqliteGraphqlDbOperationsLive), ExecutionCollectionOpsWithDeps, ...customDbLayerWithDeps ? [customDbLayerWithDeps] : []).pipe(Layer4.provideMerge(OrgProviderLayer), Layer4.provideMerge(TypedSqliteDrizzleLayer), Layer4.provideMerge(LocalSqlClientLive), Layer4.provideMerge(layer));
|
|
1283
|
+
const ServerLive = Layer4.scopedDiscard(Effect4.gen(function* () {
|
|
1284
|
+
const authConfig = yield* AuthConfig;
|
|
1285
|
+
yield* Effect4.log(`\uD83D\uDD10 Authentication server: ${authConfig.issuerUrl}`);
|
|
1286
|
+
const server = yield* makeServerEffect(cliConfig.port);
|
|
1287
|
+
resolvedServerPort = server.port;
|
|
1288
|
+
if (Option3.isNone(cliConfig.port)) {
|
|
1289
|
+
yield* writePortFile(GRAPHQL_PORT_FILE, server.port);
|
|
1290
|
+
}
|
|
1291
|
+
return yield* Effect4.never;
|
|
1292
|
+
}));
|
|
1293
|
+
const QueueCapabilityLive = SqliteQueueWithRequestContext.pipe(Layer4.provide(AppLayer));
|
|
1294
|
+
const DocumentStoreCapabilityLive = LocalDocumentStoreServiceLive.pipe(Layer4.provide(LocalDocumentStoreConfigLive));
|
|
1295
|
+
const EventPublisherCapabilityLive = Layer4.mergeAll(DraftProcessEventsLive, TodoEventsLive, ProcessEventsLive, ExecutionEventsLive).pipe(Layer4.provide(AppLayer));
|
|
1296
|
+
return yield* Runtime.graphql({
|
|
1297
|
+
persistence: AppLayer,
|
|
1298
|
+
queue: QueueCapabilityLive,
|
|
1299
|
+
documentStore: DocumentStoreCapabilityLive,
|
|
1300
|
+
eventPublisher: EventPublisherCapabilityLive,
|
|
1301
|
+
organisationLoader: OrgProviderLayer,
|
|
1302
|
+
authorization: AuthorizationLive,
|
|
1303
|
+
transport: (services) => {
|
|
1304
|
+
const CapabilityLayer = Layer4.effectContext(Effect4.succeed(services));
|
|
1305
|
+
const ResolverRuntimeLive = Layer4.effect(ResolverRuntime, Effect4.sync(() => ManagedRuntime.make(Layer4.merge(CapabilityLayer, LocalDelegatedRealtime.layer).pipe(Layer4.provide(NodeSdkLive)))));
|
|
1306
|
+
const AppLive = ServerLive.pipe(Layer4.provide(YogaLive), Layer4.provide(AppSchemaBuilderLive), Layer4.provide(ResolverRuntimeLive), Layer4.provide(AuthConfigLive), Layer4.provide(CallbackSecretLive), Layer4.provide(CapabilityLayer));
|
|
1307
|
+
return Layer4.launch(AppLive);
|
|
1308
|
+
},
|
|
1309
|
+
logging: {
|
|
1310
|
+
decorate: (effect) => effect.pipe(Logger.withMinimumLogLevel(LogLevel.Debug), Effect4.provide(Logger.pretty))
|
|
1311
|
+
}
|
|
1312
|
+
});
|
|
1313
|
+
});
|
|
1314
|
+
Effect4.runPromiseExit(main.pipe(Effect4.scoped, Effect4.provide(CliConfigLive))).then((exit) => {
|
|
1315
|
+
if (Exit2.isFailure(exit)) {
|
|
1316
|
+
console.error("GraphQL server failed to start:", Cause3.pretty(exit.cause, { renderErrorCause: true }));
|
|
1317
|
+
process.exit(1);
|
|
1318
|
+
}
|
|
1319
|
+
});
|