@processfocus/runtime-local 0.1.0-next.2 → 0.1.0-next.4
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/README.md +51 -253
- package/dist/authentication-server.mjs +52 -84
- package/dist/chunk-3wzp2sax.js +4806 -0
- package/dist/chunk-5kjvzbwr.js +512 -0
- package/dist/chunk-egeb4821.js +156 -0
- package/dist/chunk-q5v72erd.js +241 -0
- package/dist/{chunk-yhzbn4vx.js → chunk-wvbz0nmd.js} +19485 -34180
- package/dist/{chunk-352j1ayk.js → chunk-y8fnwbx0.js} +51781 -36259
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/actions.ts +12 -12
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/delegations-client.tsx +31 -21
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/page.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/client-index.tsx +1 -12
- package/dist/dashboard-source/apps/frontend/app/(protected)/connected-apps/disconnect-form.tsx +57 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/connected-apps/page.tsx +97 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/client.tsx +1 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/process-state/page.tsx +2 -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 +3 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/process-state/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/client-layout.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/default.tsx +6 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/executions-client.tsx +1637 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/layout.tsx +5 -7
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/page.tsx +4 -1589
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-page-client.tsx +1 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/layout.tsx +41 -33
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/client.tsx +11 -17
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/page.tsx +2 -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 +169 -18
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +21 -14
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +36 -18
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-edit-form.tsx +22 -28
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-load-error.tsx +49 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-schema-form.tsx +28 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/default.tsx +6 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/metric-control-url-state.ts +7 -16
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-deleted-callback.ts +4 -6
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-item-detail.ts +45 -142
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/client.tsx +10 -20
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/layout.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-process-dialog.tsx +72 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh-provider.tsx +65 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh.ts +162 -16
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/page.tsx +4 -9
- package/dist/dashboard-source/apps/frontend/app/(protected)/page.tsx +4 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/actions.ts +15 -18
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/page.tsx +12 -6
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/passkeys-client.tsx +7 -16
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client.tsx +26 -48
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/page.tsx +4 -7
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client-layout.tsx +28 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client.tsx +1 -3
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/start-process-form.tsx +193 -117
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/default.tsx +6 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/layout.tsx +7 -9
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/page.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/processes-client.tsx +60 -204
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/client.tsx +12 -51
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/page.tsx +27 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/page.tsx +5 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-flow.tsx +0 -5
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-form-preview-sheet.tsx +26 -19
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/page.tsx +5 -2
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-authorize.ts +85 -9
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-types.ts +12 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/explorer.tsx +66 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/layout.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-handbook.ts +41 -13
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/[invitationId]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-client.tsx +442 -365
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/new/page.tsx +8 -2
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/page.tsx +7 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations-table.tsx +61 -43
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/page.tsx +6 -67
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/providers/page.tsx +7 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/roles/page.tsx +7 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-client.tsx +111 -189
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-page.tsx +86 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/client.tsx +141 -256
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/tokens/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/page.tsx +7 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users-table.tsx +6 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/page.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/client.tsx +30 -9
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/page.tsx +3 -1
- 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 +2 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/page.tsx +3 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/complete-todo-form.tsx +47 -54
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/public-completion-correction-form.tsx +37 -54
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/todo-form-actions.tsx +1 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/correct/[...stepPath]/page.tsx +3 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/default.tsx +6 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/layout.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/lib/mobile-todo-list.ts +4 -25
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/page.tsx +4 -1315
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/to-dos-client.tsx +1282 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/callback/route.ts +81 -65
- package/dist/dashboard-source/apps/frontend/app/api/auth/delegation/route.ts +8 -2
- package/dist/dashboard-source/apps/frontend/app/api/auth/login/route.ts +0 -1
- package/dist/dashboard-source/apps/frontend/app/api/auth/logout/route.ts +10 -5
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/start/route.ts +1 -3
- package/dist/dashboard-source/apps/frontend/app/api/auth/refresh/route.ts +0 -1
- package/dist/dashboard-source/apps/frontend/app/api/auth/revalidate-google/route.ts +68 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/switch-role/route.ts +1 -3
- package/dist/dashboard-source/apps/frontend/app/api/dev/import-events/route.ts +69 -1
- package/dist/dashboard-source/apps/frontend/app/api/embed/lookup/route.ts +25 -7
- package/dist/dashboard-source/apps/frontend/app/api/embed/submit/route.ts +1 -2
- package/dist/dashboard-source/apps/frontend/app/api/public/start/[address]/route.ts +49 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/lookup/route.ts +4 -3
- package/dist/dashboard-source/apps/frontend/app/api/revalidate/route.ts +15 -4
- package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +14 -6
- package/dist/dashboard-source/apps/frontend/app/cli-auth/route.ts +2 -1
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/embed-client.tsx +31 -18
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/page.tsx +5 -1
- package/dist/dashboard-source/apps/frontend/app/login/page.tsx +4 -4
- package/dist/dashboard-source/apps/frontend/app/login/passkey-button.tsx +11 -6
- package/dist/dashboard-source/apps/frontend/app/login/passkey-help/page.tsx +67 -0
- package/dist/dashboard-source/apps/frontend/app/mcp/[[...endpoint]]/route.ts +44 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-client.tsx +44 -25
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/form/page.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/layout.tsx +32 -0
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-client.tsx +319 -0
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-content.tsx +41 -0
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/app/public.css +1 -1
- package/dist/dashboard-source/apps/frontend/app/register/passkey/register-passkey-client.tsx +17 -0
- package/dist/dashboard-source/apps/frontend/components/DashboardSection.tsx +9 -15
- package/dist/dashboard-source/apps/frontend/components/Header.tsx +14 -8
- package/dist/dashboard-source/apps/frontend/components/anonymous-page-link.tsx +57 -0
- package/dist/dashboard-source/apps/frontend/components/anonymous-start-form.tsx +24 -0
- package/dist/dashboard-source/apps/frontend/components/app-sidebar.tsx +21 -7
- package/dist/dashboard-source/apps/frontend/components/auth-provider.tsx +12 -7
- package/dist/dashboard-source/apps/frontend/components/browser-only.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/components/config-provider.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/delegation-expiry.tsx +24 -13
- package/dist/dashboard-source/apps/frontend/components/form-dialog-content.tsx +22 -2
- package/dist/dashboard-source/apps/frontend/components/journey-timeline.tsx +52 -45
- package/dist/dashboard-source/apps/frontend/components/notification-bell.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/sidebar-lists.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/token-refresh-scheduler.tsx +38 -11
- package/dist/dashboard-source/apps/frontend/components/ui/sidebar.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/ui/tab-pill.tsx +26 -15
- package/dist/dashboard-source/apps/frontend/components/workflow/step-node.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/workflow/workflow-edge.tsx +5 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-form-metadata.ts +21 -10
- package/dist/dashboard-source/apps/frontend/hooks/use-process-draft.ts +173 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-weekly-execution-stats.ts +1 -3
- package/dist/dashboard-source/apps/frontend/lib/anonymous-page-form-values.ts +6 -0
- package/dist/dashboard-source/apps/frontend/lib/anonymous-page-server.ts +65 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/adapter.ts +9 -3
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/client.ts +7 -340
- package/dist/dashboard-source/apps/frontend/lib/auth/client-session.ts +2 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/delegations.ts +9 -7
- package/dist/dashboard-source/apps/frontend/lib/auth/google-revalidation.ts +111 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/logout.ts +1 -1
- package/dist/dashboard-source/apps/frontend/lib/auth/passkeys.ts +28 -30
- package/dist/dashboard-source/apps/frontend/lib/auth/providers.ts +10 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/realtime-session-token.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/reauthentication-state.ts +4 -4
- package/dist/dashboard-source/apps/frontend/lib/auth/session-admission.ts +11 -7
- package/dist/dashboard-source/apps/frontend/lib/auth/session.ts +27 -10
- package/dist/dashboard-source/apps/frontend/lib/auth/ssr-session.ts +76 -9
- package/dist/dashboard-source/apps/frontend/lib/auth/verify-passkey.ts +25 -3
- package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +115 -23
- package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution.ts +1 -8
- package/dist/dashboard-source/apps/frontend/lib/collections/execution.ts +6 -2
- package/dist/dashboard-source/apps/frontend/lib/collections/graphql-stream.ts +21 -1
- package/dist/dashboard-source/apps/frontend/lib/collections/process-collection-provider.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/process.ts +8 -2
- package/dist/dashboard-source/apps/frontend/lib/collections/replication-factory.ts +16 -4
- package/dist/dashboard-source/apps/frontend/lib/collections/todo.ts +1 -1
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-query-invalidation.tsx +66 -9
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-refresh.ts +10 -6
- package/dist/dashboard-source/apps/frontend/lib/effect/navigation.ts +4 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/page-runtime.ts +29 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/params.ts +18 -12
- package/dist/dashboard-source/apps/frontend/lib/effect/run-effect.ts +1 -1
- package/dist/dashboard-source/apps/frontend/lib/effect/runtime.ts +19 -23
- package/dist/dashboard-source/apps/frontend/lib/effect/services/access-token.ts +9 -12
- package/dist/dashboard-source/apps/frontend/lib/effect/services/authorization.ts +12 -12
- package/dist/dashboard-source/apps/frontend/lib/effect/services/form-validation.ts +20 -18
- package/dist/dashboard-source/apps/frontend/lib/effect/services/graphql.ts +32 -16
- package/dist/dashboard-source/apps/frontend/lib/embed-form-server.ts +35 -0
- package/dist/dashboard-source/apps/frontend/lib/embed-manifest.ts +10 -103
- package/dist/dashboard-source/apps/frontend/lib/forms/invitation.ts +43 -0
- package/dist/dashboard-source/apps/frontend/lib/forms/provider-user.ts +64 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-form-loaders.ts +40 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-manifest.ts +1 -33
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +123 -33
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +168 -30
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/index.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/anonymous-page.ts +27 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/dependent-lookup-query.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/list-queries.ts +34 -29
- package/dist/dashboard-source/apps/frontend/lib/graphql/lookup-provider.tsx +82 -10
- package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-operations.ts +2 -5
- package/dist/dashboard-source/apps/frontend/lib/graphql/queries.ts +25 -4
- package/dist/dashboard-source/apps/frontend/lib/graphql/server-client.ts +11 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/settings-queries.ts +13 -104
- package/dist/dashboard-source/apps/frontend/lib/graphql/user-queries.ts +11 -4
- package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-operations.ts +1 -3
- package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-queries.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/list-detail-selection.ts +54 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/executions.ts +110 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/list-writes.ts +395 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/lists.ts +263 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/oauth.ts +889 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/origin.ts +50 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/processes.ts +436 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/read-tool.ts +72 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/result.ts +4 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/server.ts +71 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/store.ts +107 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/todos.ts +260 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/notification-preference.ts +0 -1
- package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notification-observer.ts +0 -5
- package/dist/dashboard-source/apps/frontend/lib/org-chart-data.ts +0 -2
- package/dist/dashboard-source/apps/frontend/lib/org-identity.ts +6 -4
- package/dist/dashboard-source/apps/frontend/lib/organisation-form-loaders.ts +4 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-form-runtime.ts +0 -1
- package/dist/dashboard-source/apps/frontend/lib/public-todo-model.ts +39 -139
- package/dist/dashboard-source/apps/frontend/lib/public-todo-server.ts +17 -16
- package/dist/dashboard-source/apps/frontend/lib/query-client.ts +0 -1
- package/dist/dashboard-source/apps/frontend/lib/todo-utils.ts +1 -77
- package/dist/dashboard-source/apps/frontend/lib/workflow/layout.ts +3 -7
- package/dist/dashboard-source/apps/frontend/next.config.ts +33 -13
- package/dist/dashboard-source/apps/frontend/package.json +47 -47
- package/dist/dashboard-source/apps/frontend/proxy.ts +72 -14
- package/dist/dashboard-source/modules/auth-local-cedar/src/index.ts +0 -3
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/auth-local-cedar.ts +165 -233
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/cedar-reload-notifier.ts +4 -3
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/config-base.ts +111 -75
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/policy-watcher.ts +14 -18
- package/dist/dashboard-source/modules/auth-policy/src/index.ts +1 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/auth-policy.ts +19 -37
- package/dist/dashboard-source/modules/auth-policy/src/lib/current-principal.ts +33 -29
- package/dist/dashboard-source/modules/auth-policy/src/lib/policy-revision.ts +23 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/types.ts +24 -49
- package/dist/dashboard-source/modules/auth-session/src/index.ts +4 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/project-subscription.ts +13 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/realtime-recipient.ts +10 -2
- package/dist/dashboard-source/modules/auth-session/src/lib/subjects.ts +82 -8
- package/dist/dashboard-source/modules/auth-session/src/lib/workload-access.ts +48 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/workload-audit.ts +52 -0
- package/dist/dashboard-source/modules/aws-common/src/index.ts +0 -1
- package/dist/dashboard-source/modules/effect-json-logger/src/lib/effect-json-logger.ts +6 -9
- package/dist/dashboard-source/modules/form/src/hooks/use-local-storage.ts +5 -3
- package/dist/dashboard-source/modules/form/src/index.ts +1 -10
- package/dist/dashboard-source/modules/form/src/lib/effect-schema-form.tsx +1271 -0
- package/dist/dashboard-source/modules/form/src/lib/form-actions.ts +26 -0
- package/dist/dashboard-source/modules/form/src/lib/form-prefill.tsx +79 -0
- package/dist/dashboard-source/modules/form/src/lib/initial-focus.ts +31 -0
- package/dist/dashboard-source/modules/form/src/lib/lookup-context.tsx +18 -0
- package/dist/dashboard-source/modules/form/src/lib/plugin-registry.ts +4 -0
- package/dist/dashboard-source/modules/form/src/lib/plugin-scripts.ts +26 -0
- package/dist/dashboard-source/modules/form/src/lib/registered-plugin-field.tsx +57 -0
- package/dist/dashboard-source/modules/form/src/lib/schema-lookup.tsx +124 -0
- package/dist/dashboard-source/modules/form/src/lib/schema-typeahead.tsx +522 -0
- package/dist/dashboard-source/modules/form/src/lib/validation-logic.ts +172 -0
- package/dist/dashboard-source/modules/form-schema/src/index.ts +4 -1
- package/dist/dashboard-source/modules/form-schema/src/lib/annotation-helpers.ts +19 -14
- package/dist/dashboard-source/modules/form-schema/src/lib/email.ts +13 -11
- package/dist/dashboard-source/modules/form-schema/src/lib/field-count.ts +15 -13
- package/dist/dashboard-source/modules/form-schema/src/lib/form-annotations.ts +14 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/form-presentation.ts +33 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/form-schema.ts +186 -80
- package/dist/dashboard-source/modules/form-schema/src/lib/number-from-string.ts +26 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/phone.ts +8 -7
- package/dist/dashboard-source/modules/form-schema/src/lib/public-completion-correction.ts +7 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/search-lookup-items.ts +27 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/index.ts +5 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/executable-rules.ts +379 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/form-submission-schema.ts +475 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/json-schema.ts +58 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/schema-defaults.ts +158 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/submission-utils.ts +75 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/lib/browser-plugin-artifact.ts +46 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/lib/frontend-manifest.ts +37 -30
- package/dist/dashboard-source/modules/frontend-plugin-host/src/lib/frontend-plugin-host.ts +9 -1
- package/dist/dashboard-source/modules/openauth/src/client.ts +25 -17
- package/dist/dashboard-source/modules/openauth/src/util.ts +16 -0
- package/dist/dashboard-source/modules/{aws-common/src/lib/project-balance-admission.ts → project-accounting/src/admission.ts} +4 -8
- package/dist/dashboard-source/modules/realtime-client/src/appsync-client.ts +377 -0
- package/dist/dashboard-source/modules/realtime-client/src/index.ts +5 -0
- package/dist/dashboard-source/modules/realtime-client/src/subscription-presence.ts +163 -0
- package/dist/dashboard-source/modules/request-time/src/lib/request-time.ts +6 -24
- package/dist/dashboard-source/modules/rxdb-collections/generated/execution-schema.json +28 -21
- package/dist/dashboard-source/modules/rxdb-collections/src/lib/rxdb-collections.ts +25 -18
- package/dist/dashboard-source/modules/rxdb-collections/src/lib/to-rxdb-schema.ts +60 -10
- package/dist/dashboard-source/modules/shadcn-components/src/index.ts +18 -2
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-calendar.tsx +93 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-field.tsx +147 -48
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-time-display.tsx +273 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/local-date-time-input.tsx +108 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/lookup-field.tsx +237 -351
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/popover.tsx +2 -1
- package/dist/dashboard-source.json +47 -47
- package/dist/graphql-server.mjs +272 -200
- package/dist/job-worker-supervisor.mjs +262 -0
- package/dist/job-worker.mjs +234 -133
- package/dist/main.mjs +30 -6
- package/dist/prepare-dashboard.mjs +8 -8
- package/dist/resources/cedar/policies.cedar +80 -38
- package/dist/resources/cedar/schema.cedarschema +39 -21
- package/dist/resources/graphql-schema/rxdb.graphql +2 -0
- package/dist/resources/graphql-schema/system.graphql +191 -51
- package/package.json +63 -62
- package/dist/chunk-6ntmymmx.js +0 -85
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.ts +0 -20
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-form-actions.tsx +0 -105
- package/dist/dashboard-source/apps/frontend/hooks/use-draft-process-save.ts +0 -189
- package/dist/dashboard-source/apps/frontend/hooks/use-draft-state.ts +0 -79
- package/dist/dashboard-source/apps/frontend/hooks/use-processes-query.ts +0 -56
- package/dist/dashboard-source/modules/form/src/lib/ajv-standard-schema.ts +0 -152
- package/dist/dashboard-source/modules/form/src/lib/client-components-to-form.tsx +0 -1421
- package/dist/dashboard-source/modules/form/src/lib/friendly-validation-message.ts +0 -85
- package/dist/dashboard-source/modules/form/src/lib/walker.tsx +0 -1549
- package/dist/dashboard-source/modules/form-client-representation/src/lib/client-form-definition.ts +0 -440
- package/dist/dashboard-source/modules/form-client-representation/src/lib/plugin-registry.ts +0 -13
- package/dist/dashboard-source/modules/form-client-representation/src/lib/types.ts +0 -336
- package/dist/dashboard-source/modules/form-rule/src/index.ts +0 -21
- package/dist/dashboard-source/modules/form-rule/src/lib/evaluator.ts +0 -531
- package/dist/dashboard-source/modules/form-rule/src/lib/paths.ts +0 -102
- package/dist/dashboard-source/modules/form-rule/src/lib/types.ts +0 -121
- package/dist/dashboard-source/modules/form-schema/src/lib/property-signature.ts +0 -45
package/dist/graphql-server.mjs
CHANGED
|
@@ -1,45 +1,19 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
layer,
|
|
4
|
-
|
|
5
|
-
CurrentPrincipal,
|
|
6
|
-
RequestTime,
|
|
7
|
-
DelegationSessionServiceIsolated,
|
|
8
|
-
layer2,
|
|
4
|
+
normalizePath,
|
|
9
5
|
OrganisationProvider,
|
|
6
|
+
OrganisationProviderFromPath,
|
|
10
7
|
OrganisationProviderFromPathDev,
|
|
11
8
|
CedarPoliciesProvider,
|
|
12
9
|
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
10
|
CedarReloadNotifierService,
|
|
29
11
|
LocalCedarConfigStatic,
|
|
30
12
|
LocalCedarConfigHotReload,
|
|
31
|
-
LocalCedarAuthorizationLive
|
|
32
|
-
|
|
33
|
-
import {
|
|
34
|
-
HttpClient,
|
|
35
|
-
post,
|
|
36
|
-
bodyJson,
|
|
37
|
-
filterStatusOk,
|
|
38
|
-
AuthConfig,
|
|
39
|
-
AuthConfigLive,
|
|
13
|
+
LocalCedarAuthorizationLive,
|
|
14
|
+
DelegationSessionServiceIsolated,
|
|
40
15
|
resolveBusinessMetricDimensions,
|
|
41
16
|
BusinessMetricDimensions,
|
|
42
|
-
makeDashboardActivityLayer,
|
|
43
17
|
versionInfo,
|
|
44
18
|
GraphQLError,
|
|
45
19
|
parse,
|
|
@@ -48,6 +22,9 @@ import {
|
|
|
48
22
|
execute,
|
|
49
23
|
subscribe,
|
|
50
24
|
LocalDelegatedRealtime,
|
|
25
|
+
AuthConfig,
|
|
26
|
+
AuthConfigLive,
|
|
27
|
+
makeDashboardActivityLayer,
|
|
51
28
|
DraftProcessEvents,
|
|
52
29
|
TodoSummaryComputation,
|
|
53
30
|
TodoSummaryComputationLive,
|
|
@@ -63,30 +40,66 @@ import {
|
|
|
63
40
|
TodoCollectionOps,
|
|
64
41
|
TodoCollectionOpsLive,
|
|
65
42
|
TodoEvents,
|
|
66
|
-
hasInvalidDownloadFilename,
|
|
67
|
-
formatContentDisposition,
|
|
68
43
|
ListExportServiceLive,
|
|
69
44
|
DynamicSchemaConfig,
|
|
70
45
|
AppSchemaBuilderLive,
|
|
71
46
|
Yoga,
|
|
72
47
|
ResolverRuntime,
|
|
73
48
|
YogaLive,
|
|
74
|
-
|
|
49
|
+
makeMcpOAuthStorageRoute,
|
|
75
50
|
warnIgnoredCronDeclarations,
|
|
76
51
|
getEffectiveFrontendBaseUrl,
|
|
77
52
|
LocalDocumentStoreConfig,
|
|
78
53
|
generateLocalDocumentStoreToken,
|
|
79
54
|
LocalDocumentStoreServiceLive,
|
|
80
|
-
makeServerPluginWebhookRouter
|
|
81
|
-
|
|
55
|
+
makeServerPluginWebhookRouter,
|
|
56
|
+
PROJECT_ACCOUNTING_QUEUE,
|
|
57
|
+
ProjectAccountingChange,
|
|
58
|
+
ProjectAccountingEvents,
|
|
59
|
+
LocalQueueServiceLive
|
|
60
|
+
} from "./chunk-y8fnwbx0.js";
|
|
61
|
+
import {
|
|
62
|
+
hasInvalidDownloadFilename,
|
|
63
|
+
formatContentDisposition,
|
|
64
|
+
QueueService,
|
|
65
|
+
Runtime,
|
|
66
|
+
DatabaseConnectionInfo,
|
|
67
|
+
LOCAL_SQLITE_BUSY_TIMEOUT_MS,
|
|
68
|
+
CurrentPrincipal,
|
|
69
|
+
AuthenticationDelegationIdentityFactsLive,
|
|
70
|
+
TypedSqliteDrizzleLayer,
|
|
71
|
+
FileOperations,
|
|
72
|
+
UserDetails,
|
|
73
|
+
SqliteDelegationDatabaseLive,
|
|
74
|
+
SqliteAuthenticationDatabaseLive,
|
|
75
|
+
makeLocalSqlClientLayer
|
|
76
|
+
} from "./chunk-wvbz0nmd.js";
|
|
77
|
+
import {
|
|
78
|
+
NumberFromString,
|
|
79
|
+
DEFAULT_GRAPHQL_PORT,
|
|
80
|
+
GRAPHQL_PORT_FILE
|
|
81
|
+
} from "./chunk-5kjvzbwr.js";
|
|
82
|
+
import {
|
|
83
|
+
RequestTime,
|
|
84
|
+
SqliteCompletedJobOperationsLive,
|
|
85
|
+
SqliteFileOperationsLive,
|
|
86
|
+
SqliteFlowExecutionOperationsLive,
|
|
87
|
+
SqliteGraphqlDbOperationsLive,
|
|
88
|
+
SqliteMcpOAuthRecordsLive,
|
|
89
|
+
SqliteScheduledFlowOperationsLive
|
|
90
|
+
} from "./chunk-3wzp2sax.js";
|
|
82
91
|
import {
|
|
83
92
|
serveOnExactPort,
|
|
84
93
|
serveWithPortFallback,
|
|
85
|
-
writePortFile
|
|
86
|
-
|
|
94
|
+
writePortFile,
|
|
95
|
+
LocalRuntimeAuditLive,
|
|
96
|
+
LocalPolicyRevisionPublisherLive
|
|
97
|
+
} from "./chunk-egeb4821.js";
|
|
87
98
|
|
|
88
99
|
// src/graphql-server/graphql-server.ts
|
|
89
|
-
import
|
|
100
|
+
import { randomUUID } from "crypto";
|
|
101
|
+
import { join as join2, resolve } from "path";
|
|
102
|
+
import * as NodeSdk from "@effect/opentelemetry/NodeSdk";
|
|
90
103
|
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
|
|
91
104
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
92
105
|
import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
|
@@ -96,71 +109,73 @@ import {
|
|
|
96
109
|
Config as Config2,
|
|
97
110
|
Context,
|
|
98
111
|
DateTime,
|
|
99
|
-
Effect as
|
|
112
|
+
Effect as Effect5,
|
|
100
113
|
Exit as Exit2,
|
|
101
|
-
|
|
102
|
-
Layer as
|
|
103
|
-
LogLevel,
|
|
114
|
+
FileSystem,
|
|
115
|
+
Layer as Layer5,
|
|
104
116
|
Logger,
|
|
105
117
|
ManagedRuntime,
|
|
106
|
-
Option as
|
|
107
|
-
Redacted
|
|
118
|
+
Option as Option4,
|
|
119
|
+
Redacted,
|
|
120
|
+
References
|
|
108
121
|
} from "effect";
|
|
122
|
+
import { FetchHttpClient } from "effect/http";
|
|
109
123
|
|
|
110
124
|
// src/services/event-hub.ts
|
|
111
|
-
import { Cause, Effect, Layer, Queue
|
|
125
|
+
import { Cause, Effect, Layer, Queue } from "effect";
|
|
112
126
|
var DEFAULT_BUFFER_SIZE = 32;
|
|
113
127
|
var createEventHubLayer = (tag, options = {}) => {
|
|
114
128
|
const bufferSize = options.bufferSize ?? DEFAULT_BUFFER_SIZE;
|
|
115
|
-
return Layer.effect(tag,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
return Layer.effect(tag, createEventHub(bufferSize));
|
|
130
|
+
};
|
|
131
|
+
var createEventHub = (bufferSize = DEFAULT_BUFFER_SIZE) => Effect.sync(() => {
|
|
132
|
+
const subscribers = new Map;
|
|
133
|
+
return {
|
|
134
|
+
emit: (event) => Effect.forEach(Array.from(subscribers).filter(([, accepts]) => accepts(event)), ([queue]) => Queue.offer(queue, event), { discard: true }),
|
|
135
|
+
subscribe: (accepts = () => true) => Effect.gen(function* () {
|
|
136
|
+
const queue = yield* Queue.sliding(bufferSize);
|
|
137
|
+
subscribers.set(queue, accepts);
|
|
138
|
+
const runtime = yield* Effect.context();
|
|
139
|
+
const run = Effect.runPromiseWith(runtime);
|
|
140
|
+
let closed = false;
|
|
141
|
+
const close = async () => {
|
|
142
|
+
closed = true;
|
|
143
|
+
subscribers.delete(queue);
|
|
144
|
+
await run(Queue.shutdown(queue));
|
|
145
|
+
};
|
|
146
|
+
const iterator = {
|
|
147
|
+
[Symbol.asyncIterator]() {
|
|
148
|
+
return this;
|
|
149
|
+
},
|
|
150
|
+
async next() {
|
|
151
|
+
if (closed)
|
|
152
|
+
return { done: true, value: undefined };
|
|
153
|
+
try {
|
|
154
|
+
const event = await run(Queue.take(queue));
|
|
155
|
+
return closed ? { done: true, value: undefined } : { done: false, value: event };
|
|
156
|
+
} catch (error) {
|
|
135
157
|
if (closed)
|
|
136
158
|
return { done: true, value: undefined };
|
|
137
159
|
try {
|
|
138
|
-
|
|
139
|
-
|
|
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) {
|
|
160
|
+
await run(Effect.logError("Subscriber queue error", Cause.die(error)));
|
|
161
|
+
} catch {}
|
|
155
162
|
await close();
|
|
156
163
|
throw error;
|
|
157
164
|
}
|
|
158
|
-
}
|
|
159
|
-
return
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
165
|
+
},
|
|
166
|
+
async return() {
|
|
167
|
+
await close();
|
|
168
|
+
return { done: true, value: undefined };
|
|
169
|
+
},
|
|
170
|
+
async throw(error) {
|
|
171
|
+
await close();
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
return iterator;
|
|
176
|
+
})
|
|
177
|
+
};
|
|
178
|
+
});
|
|
164
179
|
|
|
165
180
|
// src/services/draft-process-events.ts
|
|
166
181
|
var DraftProcessEventsLive = createEventHubLayer(DraftProcessEvents);
|
|
@@ -169,11 +184,12 @@ var DraftProcessEventsLive = createEventHubLayer(DraftProcessEvents);
|
|
|
169
184
|
var ExecutionEventsLive = createEventHubLayer(ExecutionEvents);
|
|
170
185
|
|
|
171
186
|
// src/services/http-cedar-reload-notifier.ts
|
|
172
|
-
import { Cause as Cause2, Config, Effect as Effect2, Layer as Layer2, Option
|
|
187
|
+
import { Cause as Cause2, Config, Effect as Effect2, Layer as Layer2, Option } from "effect";
|
|
188
|
+
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
173
189
|
var HttpCedarReloadNotifierLive = Layer2.effect(CedarReloadNotifierService, Effect2.gen(function* () {
|
|
174
|
-
const httpClient = yield* HttpClient;
|
|
175
|
-
const runtime = yield* Effect2.
|
|
176
|
-
const revalidateSecret = yield* Config.option(Config.
|
|
190
|
+
const httpClient = yield* HttpClient.HttpClient;
|
|
191
|
+
const runtime = yield* Effect2.context();
|
|
192
|
+
const revalidateSecret = yield* Config.option(Config.String("REVALIDATE_SECRET"));
|
|
177
193
|
if (Option.isNone(revalidateSecret)) {
|
|
178
194
|
yield* Effect2.logWarning("REVALIDATE_SECRET not configured; Cedar reloads will skip frontend cache invalidation");
|
|
179
195
|
} else {
|
|
@@ -186,18 +202,18 @@ var HttpCedarReloadNotifierLive = Layer2.effect(CedarReloadNotifierService, Effe
|
|
|
186
202
|
return;
|
|
187
203
|
}
|
|
188
204
|
const baseUrl = getEffectiveFrontendBaseUrl();
|
|
189
|
-
const request = yield* post(`${baseUrl}/api/revalidate`).pipe(bodyJson({
|
|
205
|
+
const request = yield* HttpClientRequest.post(`${baseUrl}/api/revalidate`).pipe(HttpClientRequest.bodyJson({
|
|
190
206
|
path: "/settings",
|
|
191
207
|
tag: "cedar-policies",
|
|
192
208
|
secret: revalidateSecret.value
|
|
193
209
|
}));
|
|
194
210
|
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({
|
|
211
|
+
yield* httpClient.execute(request).pipe(Effect2.flatMap(HttpClientResponse.filterStatusOk), Effect2.scoped, Effect2.matchEffect({
|
|
196
212
|
onSuccess: () => Effect2.log(`Successfully invalidated frontend cedar-policies cache and /settings at ${baseUrl}`),
|
|
197
213
|
onFailure: (error) => Effect2.logWarning(`Failed to invalidate frontend cache at ${baseUrl} (non-fatal): ${error instanceof Error ? error.message : String(error)}`)
|
|
198
214
|
}));
|
|
199
|
-
}).pipe(Effect2.
|
|
200
|
-
|
|
215
|
+
}).pipe(Effect2.catchCause((cause) => Effect2.logWarning(`Failed to prepare frontend cache invalidation request (non-fatal): ${Cause2.pretty(cause)}`)));
|
|
216
|
+
Effect2.runForkWith(runtime)(effect);
|
|
201
217
|
}
|
|
202
218
|
};
|
|
203
219
|
}));
|
|
@@ -205,6 +221,32 @@ var HttpCedarReloadNotifierLive = Layer2.effect(CedarReloadNotifierService, Effe
|
|
|
205
221
|
// src/services/process-events.ts
|
|
206
222
|
var ProcessEventsLive = createEventHubLayer(ProcessEvents);
|
|
207
223
|
|
|
224
|
+
// src/services/project-accounting-events.ts
|
|
225
|
+
import { Effect as Effect3, Layer as Layer3, Option as Option2, Schedule } from "effect";
|
|
226
|
+
var ProjectAccountingEventsLive = Layer3.effect(ProjectAccountingEvents, Effect3.gen(function* () {
|
|
227
|
+
const queue = yield* QueueService;
|
|
228
|
+
const hub = yield* createEventHub();
|
|
229
|
+
const dispatch = Effect3.gen(function* () {
|
|
230
|
+
const claimed = yield* QueueService.claim(PROJECT_ACCOUNTING_QUEUE, ProjectAccountingChange);
|
|
231
|
+
if (Option2.isNone(claimed))
|
|
232
|
+
return;
|
|
233
|
+
const job = claimed.value;
|
|
234
|
+
yield* hub.emit(job.payload);
|
|
235
|
+
yield* queue.acknowledge(job.jobId, job.receipt);
|
|
236
|
+
});
|
|
237
|
+
yield* dispatch.pipe(Effect3.catchCause(Effect3.logError), Effect3.repeat(Schedule.spaced("250 millis")), Effect3.forkScoped);
|
|
238
|
+
return {
|
|
239
|
+
emit: hub.emit,
|
|
240
|
+
subscribe: (projectId, recipientPrincipalId, environmentId) => hub.subscribe((event) => {
|
|
241
|
+
if ("recipientPrincipalId" in event)
|
|
242
|
+
return event.recipientPrincipalId === recipientPrincipalId;
|
|
243
|
+
if ("deployment" in event)
|
|
244
|
+
return event.deployment.projectId === projectId && event.deployment.environmentId === environmentId;
|
|
245
|
+
return environmentId === undefined && event.projectId === projectId;
|
|
246
|
+
})
|
|
247
|
+
};
|
|
248
|
+
}));
|
|
249
|
+
|
|
208
250
|
// src/services/todo-events.ts
|
|
209
251
|
var TodoEventsLive = createEventHubLayer(TodoEvents);
|
|
210
252
|
|
|
@@ -215,13 +257,13 @@ import { join } from "path";
|
|
|
215
257
|
import { parseArgs as utilParseArgs } from "util";
|
|
216
258
|
import {
|
|
217
259
|
Data,
|
|
218
|
-
Effect as
|
|
260
|
+
Effect as Effect4,
|
|
219
261
|
Context as EffectContext,
|
|
220
262
|
Exit,
|
|
221
|
-
Layer as
|
|
263
|
+
Layer as Layer4,
|
|
222
264
|
Metric,
|
|
223
|
-
Option as
|
|
224
|
-
Schedule,
|
|
265
|
+
Option as Option3,
|
|
266
|
+
Schedule as Schedule2,
|
|
225
267
|
Schema
|
|
226
268
|
} from "effect";
|
|
227
269
|
|
|
@@ -376,6 +418,8 @@ function makeServer(options) {
|
|
|
376
418
|
connectionInitWaitTimeout = 3000,
|
|
377
419
|
onConnect,
|
|
378
420
|
onDisconnect,
|
|
421
|
+
onPing,
|
|
422
|
+
onPong,
|
|
379
423
|
onClose,
|
|
380
424
|
onSubscribe,
|
|
381
425
|
onOperation,
|
|
@@ -390,7 +434,7 @@ function makeServer(options) {
|
|
|
390
434
|
const ctx = {
|
|
391
435
|
connectionInitReceived: false,
|
|
392
436
|
acknowledged: false,
|
|
393
|
-
subscriptions:
|
|
437
|
+
subscriptions: /* @__PURE__ */ Object.create(null),
|
|
394
438
|
extra
|
|
395
439
|
};
|
|
396
440
|
if (socket.protocol !== GRAPHQL_TRANSPORT_WS_PROTOCOL) {
|
|
@@ -430,14 +474,17 @@ function makeServer(options) {
|
|
|
430
474
|
return;
|
|
431
475
|
}
|
|
432
476
|
case MessageType.Ping: {
|
|
433
|
-
|
|
477
|
+
await onPing?.(ctx, message.payload);
|
|
478
|
+
if (socket.onPing) {
|
|
434
479
|
return await socket.onPing(message.payload);
|
|
480
|
+
}
|
|
435
481
|
await socket.send(stringifyMessage(message.payload ? { type: MessageType.Pong, payload: message.payload } : {
|
|
436
482
|
type: MessageType.Pong
|
|
437
|
-
}));
|
|
483
|
+
}, replacer));
|
|
438
484
|
return;
|
|
439
485
|
}
|
|
440
486
|
case MessageType.Pong:
|
|
487
|
+
await onPong?.(ctx, message.payload);
|
|
441
488
|
return await socket.onPong?.(message.payload);
|
|
442
489
|
case MessageType.Subscribe: {
|
|
443
490
|
if (!ctx.acknowledged)
|
|
@@ -559,7 +606,7 @@ function makeServer(options) {
|
|
|
559
606
|
if (connectionInitWait)
|
|
560
607
|
clearTimeout(connectionInitWait);
|
|
561
608
|
const subs = { ...ctx.subscriptions };
|
|
562
|
-
ctx.subscriptions =
|
|
609
|
+
ctx.subscriptions = /* @__PURE__ */ Object.create(null);
|
|
563
610
|
await Promise.all(Object.values(subs).filter(isAsyncGenerator).map((sub) => sub.return(undefined)));
|
|
564
611
|
if (ctx.acknowledged)
|
|
565
612
|
await onDisconnect?.(ctx, code, reason);
|
|
@@ -653,9 +700,9 @@ class Mutex {
|
|
|
653
700
|
}
|
|
654
701
|
}
|
|
655
702
|
|
|
656
|
-
class CallbackSecret extends EffectContext.
|
|
703
|
+
class CallbackSecret extends EffectContext.Service()("processfocus:internal-tag/runtime-local/CallbackSecret") {
|
|
657
704
|
}
|
|
658
|
-
var CallbackSecretLive =
|
|
705
|
+
var CallbackSecretLive = Layer4.effect(CallbackSecret, Effect4.sync(() => Option3.fromNullishOr(process.env["INTERNAL_API_SECRET"])));
|
|
659
706
|
var activeWebSocketConnections = Metric.gauge("graphql.websocket.connections.active", {
|
|
660
707
|
description: "Number of active WebSocket connections (subscribers)"
|
|
661
708
|
});
|
|
@@ -666,11 +713,11 @@ var activeGraphqlSubscriptions = Metric.gauge("graphql.subscriptions.active", {
|
|
|
666
713
|
class InvalidUsageError extends Data.TaggedError("InvalidUsageError") {
|
|
667
714
|
}
|
|
668
715
|
var ParsedArgsSchema = Schema.Struct({
|
|
669
|
-
port: Schema.optional(
|
|
716
|
+
port: Schema.optional(NumberFromString.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isBetween({ minimum: 0, maximum: 65535 })))),
|
|
670
717
|
org: Schema.String
|
|
671
718
|
});
|
|
672
|
-
var parseArgs = (args) =>
|
|
673
|
-
const parseResult = yield*
|
|
719
|
+
var parseArgs = (args) => Effect4.gen(function* () {
|
|
720
|
+
const parseResult = yield* Effect4.try({
|
|
674
721
|
try: () => utilParseArgs({
|
|
675
722
|
args,
|
|
676
723
|
options: {
|
|
@@ -687,19 +734,20 @@ var parseArgs = (args) => Effect3.gen(function* () {
|
|
|
687
734
|
console.error("Error: --org is required (or set PF_ORG environment variable)");
|
|
688
735
|
return yield* new InvalidUsageError({ _: undefined });
|
|
689
736
|
}
|
|
690
|
-
return yield* Schema.
|
|
737
|
+
return yield* Schema.decodeUnknownEffect(ParsedArgsSchema)({
|
|
691
738
|
port: parseResult.values.port,
|
|
692
739
|
org
|
|
693
|
-
}).pipe(
|
|
740
|
+
}).pipe(Effect4.mapError(() => new InvalidUsageError({ _: undefined })));
|
|
694
741
|
});
|
|
695
|
-
var makeServerEffect = (port) =>
|
|
742
|
+
var makeServerEffect = (port) => Effect4.gen(function* () {
|
|
696
743
|
const yoga = yield* Yoga;
|
|
697
744
|
const resolverRuntime = yield* ResolverRuntime;
|
|
698
745
|
const routeServerPluginWebhook = yield* makeServerPluginWebhookRouter;
|
|
699
746
|
const callbackSecret = yield* CallbackSecret;
|
|
747
|
+
const routeMcpOAuthStorage = yield* makeMcpOAuthStorageRoute(process.env["PF_MCP_STORAGE_SECRET"]);
|
|
700
748
|
const docStoreConfig = yield* LocalDocumentStoreConfig;
|
|
701
749
|
const dbConnectionInfo = yield* DatabaseConnectionInfo;
|
|
702
|
-
yield*
|
|
750
|
+
yield* Effect4.log(`\uD83D\uDCBE Connecting to database: ${dbConnectionInfo}`);
|
|
703
751
|
const activeSubscriptions = new Map;
|
|
704
752
|
let connectionCounter = 0;
|
|
705
753
|
let connectionIdCounter = 0;
|
|
@@ -718,7 +766,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
718
766
|
console.log(`
|
|
719
767
|
\uD83D\uDD0C [WS #${connId}] Connection OPENED (total active: ${connectionCounter})`);
|
|
720
768
|
console.log(` Timestamp: ${new Date().toISOString()}`);
|
|
721
|
-
resolverRuntime.runFork(Metric.
|
|
769
|
+
resolverRuntime.runFork(Metric.update(activeWebSocketConnections, connectionCounter));
|
|
722
770
|
return true;
|
|
723
771
|
},
|
|
724
772
|
onComplete: (ctx, id) => {
|
|
@@ -730,7 +778,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
730
778
|
activeSubscriptions.delete(id);
|
|
731
779
|
}
|
|
732
780
|
console.log(`\uD83D\uDCCA [WS] Active subscriptions: ${activeSubscriptions.size}`);
|
|
733
|
-
resolverRuntime.runFork(Metric.
|
|
781
|
+
resolverRuntime.runFork(Metric.update(activeGraphqlSubscriptions, activeSubscriptions.size));
|
|
734
782
|
},
|
|
735
783
|
onSubscribe: async (ctx, id, payload) => {
|
|
736
784
|
const connId = connectionToId.get(ctx) ?? 0;
|
|
@@ -743,7 +791,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
743
791
|
\uD83D\uDCE5 [WS #${connId}] New subscription: id=${id.slice(0, 8)} operation=${payload.operationName}`);
|
|
744
792
|
console.log(` Timestamp: ${new Date().toISOString()}`);
|
|
745
793
|
console.log(`\uD83D\uDCCA [WS] Active subscriptions: ${activeSubscriptions.size}`);
|
|
746
|
-
resolverRuntime.runFork(Metric.
|
|
794
|
+
resolverRuntime.runFork(Metric.update(activeGraphqlSubscriptions, activeSubscriptions.size));
|
|
747
795
|
const grouped = new Map;
|
|
748
796
|
for (const [, s] of activeSubscriptions) {
|
|
749
797
|
grouped.set(s.operation, (grouped.get(s.operation) || 0) + 1);
|
|
@@ -797,13 +845,16 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
797
845
|
const serverOptions = {
|
|
798
846
|
fetch: async (request, srv) => {
|
|
799
847
|
const url = new URL(request.url);
|
|
848
|
+
const mcpOAuthEffect = routeMcpOAuthStorage(request);
|
|
849
|
+
if (mcpOAuthEffect !== undefined)
|
|
850
|
+
return resolverRuntime.runPromise(mcpOAuthEffect);
|
|
800
851
|
const webhookEffect = routeServerPluginWebhook(request);
|
|
801
852
|
if (webhookEffect !== undefined) {
|
|
802
853
|
return resolverRuntime.runPromise(webhookEffect);
|
|
803
854
|
}
|
|
804
855
|
if (url.pathname === "/internal/todo-event" && request.method === "POST") {
|
|
805
856
|
const providedSecret = request.headers.get("x-callback-secret");
|
|
806
|
-
if (
|
|
857
|
+
if (Option3.isNone(callbackSecret)) {
|
|
807
858
|
return new Response("Unauthorized", { status: 401 });
|
|
808
859
|
}
|
|
809
860
|
if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
|
|
@@ -811,7 +862,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
811
862
|
}
|
|
812
863
|
const event = await request.json();
|
|
813
864
|
const { schema } = yoga.getEnveloped({ req: request });
|
|
814
|
-
const emitEffect =
|
|
865
|
+
const emitEffect = Effect4.flatMap(TodoEvents, (todoEvents) => todoEvents.emit(event, schema));
|
|
815
866
|
const result = await resolverRuntime.runPromiseExit(emitEffect);
|
|
816
867
|
if (Exit.isFailure(result)) {
|
|
817
868
|
console.error("Failed to process todo event callback:", result.cause);
|
|
@@ -821,7 +872,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
821
872
|
}
|
|
822
873
|
if (url.pathname === "/internal/process-event" && request.method === "POST") {
|
|
823
874
|
const providedSecret = request.headers.get("x-callback-secret");
|
|
824
|
-
if (
|
|
875
|
+
if (Option3.isNone(callbackSecret)) {
|
|
825
876
|
return new Response("Unauthorized", { status: 401 });
|
|
826
877
|
}
|
|
827
878
|
if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
|
|
@@ -829,7 +880,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
829
880
|
}
|
|
830
881
|
const event = await request.json();
|
|
831
882
|
const { schema } = yoga.getEnveloped({ req: request });
|
|
832
|
-
const emitEffect =
|
|
883
|
+
const emitEffect = Effect4.flatMap(ProcessEvents, (processEvents) => processEvents.emit(event, schema));
|
|
833
884
|
const result = await resolverRuntime.runPromiseExit(emitEffect);
|
|
834
885
|
if (Exit.isFailure(result)) {
|
|
835
886
|
console.error("Failed to process process event callback:", result.cause);
|
|
@@ -839,7 +890,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
839
890
|
}
|
|
840
891
|
if (url.pathname === "/internal/execution-event" && request.method === "POST") {
|
|
841
892
|
const providedSecret = request.headers.get("x-callback-secret");
|
|
842
|
-
if (
|
|
893
|
+
if (Option3.isNone(callbackSecret)) {
|
|
843
894
|
return new Response("Unauthorized", { status: 401 });
|
|
844
895
|
}
|
|
845
896
|
if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
|
|
@@ -847,7 +898,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
847
898
|
}
|
|
848
899
|
const event = await request.json();
|
|
849
900
|
const { schema } = yoga.getEnveloped({ req: request });
|
|
850
|
-
const emitEffect =
|
|
901
|
+
const emitEffect = Effect4.flatMap(ExecutionEvents, (executionEvents) => executionEvents.emit(event, schema));
|
|
851
902
|
const result = await resolverRuntime.runPromiseExit(emitEffect);
|
|
852
903
|
if (Exit.isFailure(result)) {
|
|
853
904
|
console.error("Failed to process execution event callback:", result.cause);
|
|
@@ -857,7 +908,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
857
908
|
}
|
|
858
909
|
if (url.pathname === "/internal/import-completed" && request.method === "POST") {
|
|
859
910
|
const providedSecret = request.headers.get("x-callback-secret");
|
|
860
|
-
if (
|
|
911
|
+
if (Option3.isNone(callbackSecret)) {
|
|
861
912
|
return new Response("Unauthorized", { status: 401 });
|
|
862
913
|
}
|
|
863
914
|
if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
|
|
@@ -874,8 +925,8 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
874
925
|
}
|
|
875
926
|
const { processPaths } = body;
|
|
876
927
|
const { schema } = yoga.getEnveloped({ req: request });
|
|
877
|
-
const importCompletedEffect =
|
|
878
|
-
yield*
|
|
928
|
+
const importCompletedEffect = Effect4.gen(function* () {
|
|
929
|
+
yield* Effect4.log(`Received import-completed for ${processPaths.length} process(es): ${processPaths.join(", ")}`);
|
|
879
930
|
const processOps = yield* ProcessCollectionOps;
|
|
880
931
|
const executionOps = yield* ExecutionCollectionOps;
|
|
881
932
|
const todoOps = yield* TodoCollectionOps;
|
|
@@ -883,10 +934,10 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
883
934
|
const allProcessRows = yield* processOps.pull(null, 1e4);
|
|
884
935
|
const matchedProcessRows = allProcessRows.filter((row) => processPaths.includes(row.path));
|
|
885
936
|
if (matchedProcessRows.length === 0) {
|
|
886
|
-
yield*
|
|
937
|
+
yield* Effect4.log(`No matching processes found (${allProcessRows.length} in DB, none matching requested paths)`);
|
|
887
938
|
return;
|
|
888
939
|
}
|
|
889
|
-
const graphqlProcesses = yield*
|
|
940
|
+
const graphqlProcesses = yield* Effect4.all(matchedProcessRows.map((row) => processOps.mapToGraphql(row)), { concurrency: "unbounded" });
|
|
890
941
|
const lastProcess = graphqlProcesses[graphqlProcesses.length - 1];
|
|
891
942
|
if (lastProcess) {
|
|
892
943
|
const processEvent = {
|
|
@@ -896,14 +947,14 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
896
947
|
updatedAt: lastProcess.updatedAt
|
|
897
948
|
}
|
|
898
949
|
};
|
|
899
|
-
yield*
|
|
950
|
+
yield* Effect4.flatMap(ProcessEvents, (processEvents) => processEvents.emit(processEvent, schema));
|
|
900
951
|
}
|
|
901
|
-
yield*
|
|
952
|
+
yield* Effect4.log(`Emitted ${graphqlProcesses.length} process update(s)`);
|
|
902
953
|
const matchedPaths = new Set(graphqlProcesses.map((p) => p.path));
|
|
903
954
|
const allExecutionRows = yield* executionOps.pull(null, 1e4);
|
|
904
955
|
const matchedExecutionRows = allExecutionRows.filter((row) => matchedPaths.has(row.execution.processPath));
|
|
905
956
|
if (matchedExecutionRows.length > 0) {
|
|
906
|
-
const graphqlExecutions = yield*
|
|
957
|
+
const graphqlExecutions = yield* Effect4.all(matchedExecutionRows.map((row) => executionOps.mapToGraphql(row).pipe(Effect4.map((document) => ({
|
|
907
958
|
...document,
|
|
908
959
|
startedByEmail: row.execution.startedByEmail,
|
|
909
960
|
startedByRolePath: row.execution.startedByRolePath
|
|
@@ -917,16 +968,16 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
917
968
|
updatedAt: lastExecution.updatedAt
|
|
918
969
|
}
|
|
919
970
|
};
|
|
920
|
-
yield*
|
|
971
|
+
yield* Effect4.flatMap(ExecutionEvents, (executionEvents) => executionEvents.emit(executionEvent, schema));
|
|
921
972
|
}
|
|
922
|
-
yield*
|
|
973
|
+
yield* Effect4.log(`Emitted ${graphqlExecutions.length} execution update(s)`);
|
|
923
974
|
}
|
|
924
975
|
const matchedExecutionIds = new Set(matchedExecutionRows.map((row) => row.execution.id));
|
|
925
976
|
const allTodoRows = yield* todoOps.pull(null, 1e4);
|
|
926
977
|
const matchedTodoRows = allTodoRows.filter((row) => matchedExecutionIds.has(row.processExecutionId));
|
|
927
978
|
if (matchedTodoRows.length > 0) {
|
|
928
979
|
const matchedTodoRowsWithSummary = yield* todoSummaryComputation.enrichWithSummaries(matchedTodoRows);
|
|
929
|
-
const graphqlTodos = yield*
|
|
980
|
+
const graphqlTodos = yield* Effect4.all(matchedTodoRowsWithSummary.map((row) => todoOps.mapToGraphql(row)), { concurrency: "unbounded" });
|
|
930
981
|
const sortedTodos = [...graphqlTodos].sort((a, b) => {
|
|
931
982
|
if (a.updatedAt !== b.updatedAt) {
|
|
932
983
|
return a.updatedAt - b.updatedAt;
|
|
@@ -943,17 +994,17 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
943
994
|
mode: "INCREMENTAL" /* Incremental */
|
|
944
995
|
}
|
|
945
996
|
};
|
|
946
|
-
yield*
|
|
997
|
+
yield* Effect4.flatMap(TodoEvents, (todoEvents) => todoEvents.emit(todoEvent, schema));
|
|
947
998
|
}
|
|
948
|
-
yield*
|
|
999
|
+
yield* Effect4.log(`Emitted ${graphqlTodos.length} todo update(s)`);
|
|
949
1000
|
}
|
|
950
1001
|
});
|
|
951
1002
|
const result = await resolverRuntime.runPromiseExit(importCompletedEffect);
|
|
952
1003
|
if (Exit.isFailure(result)) {
|
|
953
|
-
await resolverRuntime.runPromise(
|
|
1004
|
+
await resolverRuntime.runPromise(Effect4.logError("Failed to process import-completed").pipe(Effect4.annotateLogs("cause", String(result.cause))));
|
|
954
1005
|
return new Response("Internal Server Error", { status: 500 });
|
|
955
1006
|
}
|
|
956
|
-
await resolverRuntime.runPromise(
|
|
1007
|
+
await resolverRuntime.runPromise(Effect4.log("Import-completed processing done"));
|
|
957
1008
|
return new Response(null, { status: 204 });
|
|
958
1009
|
}
|
|
959
1010
|
const fileCorsHeaders = {
|
|
@@ -979,14 +1030,14 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
979
1030
|
if (Number.isNaN(expiresNum) || Date.now() / 1000 > expiresNum) {
|
|
980
1031
|
return new Response("URL expired", { status: 403 });
|
|
981
1032
|
}
|
|
982
|
-
if (
|
|
1033
|
+
if (Option3.isNone(callbackSecret)) {
|
|
983
1034
|
return new Response("Unauthorized", { status: 401 });
|
|
984
1035
|
}
|
|
985
1036
|
const expectedToken = generateLocalDocumentStoreToken(storePrefix, fileId, expires, callbackSecret.value);
|
|
986
1037
|
if (!constantTimeEqual(token, expectedToken)) {
|
|
987
1038
|
return new Response("Unauthorized", { status: 401 });
|
|
988
1039
|
}
|
|
989
|
-
const fileResult = await resolverRuntime.runPromiseExit(
|
|
1040
|
+
const fileResult = await resolverRuntime.runPromiseExit(Effect4.gen(function* () {
|
|
990
1041
|
const fileOps = yield* FileOperations;
|
|
991
1042
|
return yield* fileOps.getFileWithStore(fileId);
|
|
992
1043
|
}));
|
|
@@ -1066,10 +1117,10 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
1066
1117
|
} catch {}
|
|
1067
1118
|
return new Response(`File too large: exceeds limit of ${maxFileSize} bytes`, { status: 413, headers: fileCorsHeaders });
|
|
1068
1119
|
}
|
|
1069
|
-
const markResult = await resolverRuntime.runPromiseExit(
|
|
1120
|
+
const markResult = await resolverRuntime.runPromiseExit(Effect4.gen(function* () {
|
|
1070
1121
|
const fileOps = yield* FileOperations;
|
|
1071
1122
|
yield* fileOps.markFileUploaded(fileId, bytesWritten, contentType);
|
|
1072
|
-
}).pipe(
|
|
1123
|
+
}).pipe(Effect4.retry(Schedule2.exponential("100 millis").pipe((schedule) => Schedule2.max([schedule, Schedule2.recurs(2)])))));
|
|
1073
1124
|
if (Exit.isFailure(markResult)) {
|
|
1074
1125
|
console.error(`Failed to mark file ${fileId} as uploaded in DB:`, markResult.cause);
|
|
1075
1126
|
try {
|
|
@@ -1106,7 +1157,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
1106
1157
|
if (filename && hasInvalidDownloadFilename(filename)) {
|
|
1107
1158
|
return new Response("Bad Request", { status: 400 });
|
|
1108
1159
|
}
|
|
1109
|
-
if (
|
|
1160
|
+
if (Option3.isNone(callbackSecret)) {
|
|
1110
1161
|
return new Response("Unauthorized", { status: 401 });
|
|
1111
1162
|
}
|
|
1112
1163
|
const expectedToken = generateLocalDocumentStoreToken(storePrefix, fileId, expires, callbackSecret.value, filename ?? undefined);
|
|
@@ -1145,7 +1196,11 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
1145
1196
|
}
|
|
1146
1197
|
return new Response;
|
|
1147
1198
|
}
|
|
1148
|
-
|
|
1199
|
+
const response = await yoga.fetch(request, srv);
|
|
1200
|
+
if (response.headers.get("content-type")?.includes("text/event-stream")) {
|
|
1201
|
+
srv.timeout(request, 0);
|
|
1202
|
+
}
|
|
1203
|
+
return response;
|
|
1149
1204
|
},
|
|
1150
1205
|
websocket: {
|
|
1151
1206
|
...websocketHandler,
|
|
@@ -1161,7 +1216,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
1161
1216
|
console.log(`
|
|
1162
1217
|
\uD83D\uDD0C [WS #${connId}] Connection CLOSED: code=${code} reason=${reason} (remaining: ${connectionCounter})`);
|
|
1163
1218
|
console.log(` Timestamp: ${new Date().toISOString()}`);
|
|
1164
|
-
resolverRuntime.runFork(Metric.
|
|
1219
|
+
resolverRuntime.runFork(Metric.update(activeWebSocketConnections, connectionCounter));
|
|
1165
1220
|
const remaining = Array.from(activeSubscriptions.entries()).filter(([, s]) => s.connectionId === connId);
|
|
1166
1221
|
if (remaining.length > 0) {
|
|
1167
1222
|
console.log(" \uD83E\uDDF9 Cleaning up orphaned subscriptions:", remaining.map(([id, s]) => `${id.slice(0, 8)}:${s.operation}`).join(", "));
|
|
@@ -1169,61 +1224,62 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
1169
1224
|
activeSubscriptions.delete(id);
|
|
1170
1225
|
}
|
|
1171
1226
|
console.log(`\uD83D\uDCCA [WS] Active subscriptions: ${activeSubscriptions.size}`);
|
|
1172
|
-
resolverRuntime.runFork(Metric.
|
|
1227
|
+
resolverRuntime.runFork(Metric.update(activeGraphqlSubscriptions, activeSubscriptions.size));
|
|
1173
1228
|
}
|
|
1174
1229
|
}
|
|
1175
1230
|
return websocketHandler.close?.(ws, code, reason);
|
|
1176
1231
|
}
|
|
1177
1232
|
}
|
|
1178
1233
|
};
|
|
1179
|
-
const serveEffect =
|
|
1180
|
-
const server = yield*
|
|
1181
|
-
yield*
|
|
1182
|
-
yield*
|
|
1234
|
+
const serveEffect = Option3.isSome(port) ? serveOnExactPort(port.value, serverOptions) : serveWithPortFallback(DEFAULT_GRAPHQL_PORT, serverOptions);
|
|
1235
|
+
const server = yield* Effect4.acquireRelease(serveEffect, (srv) => Effect4.promise(() => srv.stop()));
|
|
1236
|
+
yield* Effect4.log(`\uD83D\uDE80 GraphQL server running at http://${server.hostname}:${server.port}/graphql`);
|
|
1237
|
+
yield* Effect4.log(`\uD83D\uDD0C WebSocket subscriptions available at ws://${server.hostname}:${server.port}/graphql`);
|
|
1183
1238
|
return server;
|
|
1184
1239
|
});
|
|
1185
1240
|
|
|
1186
1241
|
// src/graphql-server/graphql-server.ts
|
|
1242
|
+
process.env["PF_RUNTIME_MODE"] = "local";
|
|
1187
1243
|
var makeAuthorizationLayer = (policyPaths, schemaPaths) => {
|
|
1188
1244
|
if (policyPaths.length > 0) {
|
|
1189
1245
|
const hotReloadConfig = LocalCedarConfigHotReload("/", policyPaths, schemaPaths);
|
|
1190
|
-
return
|
|
1246
|
+
return LocalCedarAuthorizationLive.pipe(Layer5.provide(LocalPolicyRevisionPublisherLive), Layer5.provideMerge(hotReloadConfig));
|
|
1191
1247
|
}
|
|
1192
1248
|
const staticConfig = LocalCedarConfigStatic(undefined, schemaPaths);
|
|
1193
|
-
return
|
|
1249
|
+
return LocalCedarAuthorizationLive.pipe(Layer5.provide(LocalPolicyRevisionPublisherLive), Layer5.provideMerge(staticConfig));
|
|
1194
1250
|
};
|
|
1195
|
-
var CliConfig = Context.
|
|
1196
|
-
var CliConfigLive =
|
|
1197
|
-
port:
|
|
1251
|
+
var CliConfig = Context.Service("processfocus:internal-tag/runtime-local/GraphqlServerCliConfig");
|
|
1252
|
+
var CliConfigLive = Layer5.effect(CliConfig, parseArgs(process.argv.slice(2)).pipe(Effect5.map((args) => ({
|
|
1253
|
+
port: Option4.fromNullishOr(args.port),
|
|
1198
1254
|
org: args.org
|
|
1199
|
-
})),
|
|
1255
|
+
})), Effect5.catch((error) => {
|
|
1200
1256
|
console.error("Invalid arguments. Usage: bun run main.ts [--port PORT | -p PORT] [--org ORG | -o ORG]");
|
|
1201
1257
|
console.error(" --port, -p Exact port number (fails if in use, does not write port file)");
|
|
1202
1258
|
console.error(" --org, -o Path to org project (or set PF_ORG env var)");
|
|
1203
|
-
return
|
|
1259
|
+
return Effect5.fail(error);
|
|
1204
1260
|
})));
|
|
1205
|
-
var RequestTimeLive =
|
|
1206
|
-
var UserDetailsLive =
|
|
1261
|
+
var RequestTimeLive = Layer5.succeed(RequestTime, DateTime.makeUnsafe(0));
|
|
1262
|
+
var UserDetailsLive = Layer5.succeed(UserDetails, {
|
|
1207
1263
|
by: "SYSTEM",
|
|
1208
1264
|
id: null
|
|
1209
|
-
})
|
|
1210
|
-
var CurrentPrincipalLive =
|
|
1265
|
+
});
|
|
1266
|
+
var CurrentPrincipalLive = Layer5.succeed(CurrentPrincipal, null);
|
|
1211
1267
|
var businessMetricDimensions = resolveBusinessMetricDimensions({
|
|
1212
1268
|
accountId: process.env["PF_AWS_ACCOUNT_ID"],
|
|
1213
1269
|
project: process.env["PF_PROJECT"],
|
|
1214
1270
|
environment: process.env["PF_ENV"]
|
|
1215
1271
|
});
|
|
1216
|
-
var BusinessMetricDimensionsLive =
|
|
1272
|
+
var BusinessMetricDimensionsLive = Layer5.succeed(BusinessMetricDimensions, businessMetricDimensions);
|
|
1217
1273
|
var DashboardActivityLive = process.env["PF_ANALYTICS_IDENTITY_KEY"] ? makeDashboardActivityLayer({
|
|
1218
1274
|
dimensions: businessMetricDimensions,
|
|
1219
1275
|
key: Redacted.make(process.env["PF_ANALYTICS_IDENTITY_KEY"] ?? ""),
|
|
1220
1276
|
logsUrl: process.env["OTLP_LOGS_URL"] ?? "http://127.0.0.1:4318/v1/logs",
|
|
1221
1277
|
headers: {}
|
|
1222
|
-
}) :
|
|
1223
|
-
var NodeSdkLive =
|
|
1224
|
-
const otlpMetricsUrl = yield* Config2.
|
|
1225
|
-
const otlpTracesUrl = yield* Config2.
|
|
1226
|
-
return
|
|
1278
|
+
}) : Layer5.empty;
|
|
1279
|
+
var NodeSdkLive = Layer5.unwrap(Effect5.gen(function* () {
|
|
1280
|
+
const otlpMetricsUrl = yield* Config2.String("OTLP_METRICS_URL").pipe(Config2.withDefault("http://127.0.0.1:4318/v1/metrics"));
|
|
1281
|
+
const otlpTracesUrl = yield* Config2.String("OTLP_TRACES_URL").pipe(Config2.withDefault("http://127.0.0.1:4318/v1/traces"));
|
|
1282
|
+
return NodeSdk.layer(() => ({
|
|
1227
1283
|
resource: {
|
|
1228
1284
|
serviceName: "graphql-server",
|
|
1229
1285
|
attributes: {
|
|
@@ -1244,55 +1300,71 @@ var NodeSdkLive = Layer4.unwrapEffect(Effect4.gen(function* () {
|
|
|
1244
1300
|
}))
|
|
1245
1301
|
}));
|
|
1246
1302
|
}));
|
|
1247
|
-
var main =
|
|
1303
|
+
var main = Effect5.gen(function* () {
|
|
1248
1304
|
const cliConfig = yield* CliConfig;
|
|
1249
|
-
const
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1305
|
+
const importDir = process.env["PF_LOCAL_GRAPHQL_IMPORT"] === "1" ? resolve(cliConfig.org, ".processfocus/local-graphql") : undefined;
|
|
1306
|
+
const OrgProviderLayer = (importDir ? Layer5.effect(OrganisationProvider, Effect5.gen(function* () {
|
|
1307
|
+
const slot = (yield* Effect5.promise(() => import(join2(importDir, "active.json")))).default;
|
|
1308
|
+
if (slot !== "a" && slot !== "b")
|
|
1309
|
+
return yield* Effect5.fail(new Error("Invalid local GraphQL import slot"));
|
|
1310
|
+
const loaded = yield* OrganisationProvider.pipe(Effect5.provide(OrganisationProviderFromPath(join2(importDir, slot))));
|
|
1311
|
+
return { ...loaded, orgPath: resolve(cliConfig.org) };
|
|
1312
|
+
})) : OrganisationProviderFromPathDev(cliConfig.org)).pipe(Layer5.provide(layer));
|
|
1313
|
+
const CedarPoliciesLayer = OrgCedarPoliciesProvider.pipe(Layer5.provide(OrgProviderLayer));
|
|
1314
|
+
const orgProvider = yield* OrganisationProvider.pipe(Effect5.provide(OrgProviderLayer));
|
|
1252
1315
|
yield* warnIgnoredCronDeclarations(orgProvider.organisation, "local GraphQL runtime");
|
|
1253
|
-
yield*
|
|
1316
|
+
yield* Effect5.log(`\u2705 Loaded organisation: ${orgProvider.organisation.name}`);
|
|
1254
1317
|
if (orgProvider.customDbLayer) {
|
|
1255
|
-
yield*
|
|
1318
|
+
yield* Effect5.log(`\uD83D\uDCE6 Custom database layer available from organisation`);
|
|
1256
1319
|
}
|
|
1257
|
-
const cedarPolicies = yield* CedarPoliciesProvider.pipe(
|
|
1258
|
-
yield*
|
|
1259
|
-
const DynamicSchemaConfigLive =
|
|
1320
|
+
const cedarPolicies = yield* CedarPoliciesProvider.pipe(Effect5.provide(CedarPoliciesLayer));
|
|
1321
|
+
yield* Effect5.log(`\uD83D\uDCDC Loaded ${cedarPolicies.policyPaths.length} Cedar policy files`);
|
|
1322
|
+
const DynamicSchemaConfigLive = Layer5.succeed(DynamicSchemaConfig, {
|
|
1260
1323
|
schemaPath: orgProvider.schemaPath
|
|
1261
1324
|
});
|
|
1262
1325
|
const internalApiSecret = process.env["INTERNAL_API_SECRET"] ?? "dev-secret";
|
|
1263
|
-
let resolvedServerPort =
|
|
1264
|
-
const LocalDocumentStoreConfigLive =
|
|
1326
|
+
let resolvedServerPort = Option4.isSome(cliConfig.port) ? cliConfig.port.value : DEFAULT_GRAPHQL_PORT;
|
|
1327
|
+
const LocalDocumentStoreConfigLive = Layer5.succeed(LocalDocumentStoreConfig, {
|
|
1265
1328
|
baseUrl: () => `http://localhost:${resolvedServerPort}`,
|
|
1266
1329
|
storagePath: `${orgProvider.orgPath}/files`,
|
|
1267
1330
|
secret: internalApiSecret,
|
|
1268
1331
|
maxFileSize: 100 * 1024 * 1024
|
|
1269
1332
|
});
|
|
1270
1333
|
const AuthorizationLive = makeAuthorizationLayer(cedarPolicies.policyPaths, cedarPolicies.schemaPaths);
|
|
1271
|
-
const TodoSummaryComputationWithDeps = TodoSummaryComputationLive.pipe(
|
|
1272
|
-
const SlaCalculationServiceWithDeps = SlaCalculationServiceLive.pipe(
|
|
1273
|
-
const ExecutionCollectionOpsWithDeps = ExecutionCollectionOpsLive.pipe(
|
|
1274
|
-
const ListExportServiceWithDeps = ListExportServiceLive.pipe(
|
|
1334
|
+
const TodoSummaryComputationWithDeps = TodoSummaryComputationLive.pipe(Layer5.provide(SqliteGraphqlDbOperationsLive), Layer5.provide(OrgProviderLayer));
|
|
1335
|
+
const SlaCalculationServiceWithDeps = SlaCalculationServiceLive.pipe(Layer5.provide(SqliteGraphqlDbOperationsLive));
|
|
1336
|
+
const ExecutionCollectionOpsWithDeps = ExecutionCollectionOpsLive.pipe(Layer5.provide(SlaCalculationServiceWithDeps), Layer5.provide(SqliteGraphqlDbOperationsLive));
|
|
1337
|
+
const ListExportServiceWithDeps = ListExportServiceLive.pipe(Layer5.provide(LocalDocumentStoreServiceLive), Layer5.provide(LocalDocumentStoreConfigLive), Layer5.provide(AuthorizationLive));
|
|
1275
1338
|
const LocalSqlClientLive = makeLocalSqlClientLayer({
|
|
1276
1339
|
busy_timeout: LOCAL_SQLITE_BUSY_TIMEOUT_MS
|
|
1277
1340
|
});
|
|
1278
|
-
const customDbLayerDeps =
|
|
1279
|
-
const customDbLayerWithDeps = orgProvider.customDbLayer ?
|
|
1280
|
-
const HttpCedarReloadNotifierWithDeps = HttpCedarReloadNotifierLive.pipe(
|
|
1281
|
-
const SqliteQueueWithRequestContext =
|
|
1282
|
-
const AppLayer =
|
|
1283
|
-
const ServerLive =
|
|
1341
|
+
const customDbLayerDeps = Layer5.mergeAll(SqliteFileOperationsLive, AuthorizationLive, CurrentPrincipalLive, BusinessMetricDimensionsLive, DashboardActivityLive, RequestTimeLive).pipe(Layer5.provideMerge(TypedSqliteDrizzleLayer), Layer5.provideMerge(LocalSqlClientLive));
|
|
1342
|
+
const customDbLayerWithDeps = orgProvider.customDbLayer ? Layer5.provide(orgProvider.customDbLayer, customDbLayerDeps) : undefined;
|
|
1343
|
+
const HttpCedarReloadNotifierWithDeps = HttpCedarReloadNotifierLive.pipe(Layer5.provide(FetchHttpClient.layer));
|
|
1344
|
+
const SqliteQueueWithRequestContext = LocalQueueServiceLive.pipe(Layer5.provide(Layer5.merge(RequestTimeLive, UserDetailsLive)));
|
|
1345
|
+
const AppLayer = Layer5.mergeAll(LocalRuntimeAuditLive, AuthenticationDelegationIdentityFactsLive.pipe(Layer5.provideMerge(SqliteAuthenticationDatabaseLive)), DelegationSessionServiceIsolated.pipe(Layer5.provide(Layer5.mergeAll(AuthenticationDelegationIdentityFactsLive.pipe(Layer5.provide(SqliteAuthenticationDatabaseLive)), SqliteDelegationDatabaseLive)), Layer5.provide(AuthorizationLive)), SqliteGraphqlDbOperationsLive, SqliteMcpOAuthRecordsLive, SqliteFileOperationsLive, SqliteFlowExecutionOperationsLive, SqliteCompletedJobOperationsLive, SqliteScheduledFlowOperationsLive, SqliteQueueWithRequestContext, DynamicSchemaConfigLive, Layer5.provide(LocalDocumentStoreServiceLive, LocalDocumentStoreConfigLive), LocalDocumentStoreConfigLive, ListExportServiceWithDeps, DraftProcessEventsLive, TodoEventsLive, ProcessEventsLive, ProjectAccountingEventsLive.pipe(Layer5.provide(SqliteQueueWithRequestContext)), ExecutionEventsLive, RequestTimeLive, UserDetailsLive, CurrentPrincipalLive, BusinessMetricDimensionsLive, DashboardActivityLive, AuthorizationLive, TodoSummaryComputationWithDeps, SlaCalculationServiceWithDeps, HttpCedarReloadNotifierWithDeps, Layer5.provide(DraftProcessExecutionCollectionOpsLive, SqliteGraphqlDbOperationsLive), Layer5.provide(ProcessCollectionOpsLive, SqliteGraphqlDbOperationsLive), Layer5.provide(ProcessDurationServiceLive, SqliteGraphqlDbOperationsLive), Layer5.provide(TodoCollectionOpsLive, SqliteGraphqlDbOperationsLive), ExecutionCollectionOpsWithDeps, ...customDbLayerWithDeps ? [customDbLayerWithDeps] : []).pipe(Layer5.provideMerge(OrgProviderLayer), Layer5.provideMerge(TypedSqliteDrizzleLayer), Layer5.provideMerge(LocalSqlClientLive), Layer5.provideMerge(FetchHttpClient.layer));
|
|
1346
|
+
const ServerLive = Layer5.effectDiscard(Effect5.gen(function* () {
|
|
1284
1347
|
const authConfig = yield* AuthConfig;
|
|
1285
|
-
yield*
|
|
1348
|
+
yield* Effect5.log(`\uD83D\uDD10 Authentication server: ${authConfig.issuerUrl}`);
|
|
1286
1349
|
const server = yield* makeServerEffect(cliConfig.port);
|
|
1287
1350
|
resolvedServerPort = server.port;
|
|
1288
|
-
if (
|
|
1351
|
+
if (Option4.isNone(cliConfig.port)) {
|
|
1289
1352
|
yield* writePortFile(GRAPHQL_PORT_FILE, server.port);
|
|
1290
1353
|
}
|
|
1291
|
-
|
|
1354
|
+
if (importDir) {
|
|
1355
|
+
const fs = yield* FileSystem.FileSystem.pipe(Effect5.provide(layer));
|
|
1356
|
+
const ready = join2(importDir, "ready.json");
|
|
1357
|
+
yield* fs.writeFileString(`${ready}.tmp`, JSON.stringify({
|
|
1358
|
+
revision: randomUUID(),
|
|
1359
|
+
processPaths: orgProvider.organisation.processes().map((p) => normalizePath(p.node.path))
|
|
1360
|
+
}));
|
|
1361
|
+
yield* fs.rename(`${ready}.tmp`, ready);
|
|
1362
|
+
}
|
|
1363
|
+
return yield* Effect5.never;
|
|
1292
1364
|
}));
|
|
1293
|
-
const QueueCapabilityLive = SqliteQueueWithRequestContext.pipe(
|
|
1294
|
-
const DocumentStoreCapabilityLive = LocalDocumentStoreServiceLive.pipe(
|
|
1295
|
-
const EventPublisherCapabilityLive =
|
|
1365
|
+
const QueueCapabilityLive = SqliteQueueWithRequestContext.pipe(Layer5.provide(AppLayer));
|
|
1366
|
+
const DocumentStoreCapabilityLive = LocalDocumentStoreServiceLive.pipe(Layer5.provide(LocalDocumentStoreConfigLive));
|
|
1367
|
+
const EventPublisherCapabilityLive = Layer5.mergeAll(DraftProcessEventsLive, TodoEventsLive, ProcessEventsLive, ProjectAccountingEventsLive.pipe(Layer5.provide(SqliteQueueWithRequestContext)), ExecutionEventsLive).pipe(Layer5.provide(AppLayer));
|
|
1296
1368
|
return yield* Runtime.graphql({
|
|
1297
1369
|
persistence: AppLayer,
|
|
1298
1370
|
queue: QueueCapabilityLive,
|
|
@@ -1301,19 +1373,19 @@ var main = Effect4.gen(function* () {
|
|
|
1301
1373
|
organisationLoader: OrgProviderLayer,
|
|
1302
1374
|
authorization: AuthorizationLive,
|
|
1303
1375
|
transport: (services) => {
|
|
1304
|
-
const CapabilityLayer =
|
|
1305
|
-
const ResolverRuntimeLive =
|
|
1306
|
-
const AppLive = ServerLive.pipe(
|
|
1307
|
-
return
|
|
1376
|
+
const CapabilityLayer = Layer5.effectContext(Effect5.succeed(services));
|
|
1377
|
+
const ResolverRuntimeLive = Layer5.effect(ResolverRuntime, Effect5.sync(() => ManagedRuntime.make(Layer5.merge(CapabilityLayer, LocalDelegatedRealtime.layer).pipe(Layer5.provide(NodeSdkLive)))));
|
|
1378
|
+
const AppLive = ServerLive.pipe(Layer5.provide(YogaLive), Layer5.provide(AppSchemaBuilderLive), Layer5.provide(ResolverRuntimeLive), Layer5.provide(AuthConfigLive), Layer5.provide(CallbackSecretLive), Layer5.provide(CapabilityLayer));
|
|
1379
|
+
return Layer5.launch(AppLive);
|
|
1308
1380
|
},
|
|
1309
1381
|
logging: {
|
|
1310
|
-
decorate: (effect) => effect.pipe(
|
|
1382
|
+
decorate: (effect) => effect.pipe(Effect5.provideService(References.MinimumLogLevel, "Debug"), Effect5.provide(Logger.layer([Logger.consolePretty()])))
|
|
1311
1383
|
}
|
|
1312
1384
|
});
|
|
1313
1385
|
});
|
|
1314
|
-
|
|
1386
|
+
Effect5.runPromiseExit(main.pipe(Effect5.scoped, Effect5.provide(CliConfigLive))).then((exit) => {
|
|
1315
1387
|
if (Exit2.isFailure(exit)) {
|
|
1316
|
-
console.error("GraphQL server failed to start:", Cause3.pretty(exit.cause
|
|
1388
|
+
console.error("GraphQL server failed to start:", Cause3.pretty(exit.cause));
|
|
1317
1389
|
process.exit(1);
|
|
1318
1390
|
}
|
|
1319
1391
|
});
|