@processfocus/runtime-local 0.1.0-next.2 → 0.1.0-next.3
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 +48 -253
- package/dist/authentication-server.mjs +52 -84
- package/dist/{chunk-yhzbn4vx.js → chunk-04r0t2mb.js} +34324 -49067
- package/dist/chunk-727y6qkb.js +156 -0
- package/dist/chunk-bg5r4wpv.js +4755 -0
- package/dist/chunk-cbd36jq1.js +512 -0
- package/dist/chunk-d4ctj079.js +241 -0
- package/dist/{chunk-352j1ayk.js → chunk-r5s2v669.js} +51753 -36263
- 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)/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 +145 -19
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +10 -2
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +29 -13
- 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/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 +11 -4
- 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 +47 -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 +4 -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 +112 -21
- 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/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/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 +169 -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 +900 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/origin.ts +42 -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 +193 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/todos.ts +237 -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 +48 -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 +272 -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 +48 -47
- package/dist/graphql-server.mjs +245 -200
- package/dist/job-worker-supervisor.mjs +262 -0
- package/dist/job-worker.mjs +234 -133
- package/dist/main.mjs +23 -4
- 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 +190 -51
- package/package.json +64 -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,17 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
layer,
|
|
4
|
-
Runtime,
|
|
5
|
-
CurrentPrincipal,
|
|
6
|
-
RequestTime,
|
|
7
|
-
DelegationSessionServiceIsolated,
|
|
8
|
-
layer2,
|
|
9
4
|
OrganisationProvider,
|
|
10
5
|
OrganisationProviderFromPathDev,
|
|
11
6
|
CedarPoliciesProvider,
|
|
12
7
|
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
8
|
CedarReloadNotifierService,
|
|
29
9
|
LocalCedarConfigStatic,
|
|
30
10
|
LocalCedarConfigHotReload,
|
|
31
|
-
LocalCedarAuthorizationLive
|
|
32
|
-
|
|
33
|
-
import {
|
|
34
|
-
HttpClient,
|
|
35
|
-
post,
|
|
36
|
-
bodyJson,
|
|
37
|
-
filterStatusOk,
|
|
38
|
-
AuthConfig,
|
|
39
|
-
AuthConfigLive,
|
|
11
|
+
LocalCedarAuthorizationLive,
|
|
12
|
+
DelegationSessionServiceIsolated,
|
|
40
13
|
resolveBusinessMetricDimensions,
|
|
41
14
|
BusinessMetricDimensions,
|
|
42
|
-
makeDashboardActivityLayer,
|
|
43
15
|
versionInfo,
|
|
44
16
|
GraphQLError,
|
|
45
17
|
parse,
|
|
@@ -48,6 +20,9 @@ import {
|
|
|
48
20
|
execute,
|
|
49
21
|
subscribe,
|
|
50
22
|
LocalDelegatedRealtime,
|
|
23
|
+
AuthConfig,
|
|
24
|
+
AuthConfigLive,
|
|
25
|
+
makeDashboardActivityLayer,
|
|
51
26
|
DraftProcessEvents,
|
|
52
27
|
TodoSummaryComputation,
|
|
53
28
|
TodoSummaryComputationLive,
|
|
@@ -63,30 +38,62 @@ import {
|
|
|
63
38
|
TodoCollectionOps,
|
|
64
39
|
TodoCollectionOpsLive,
|
|
65
40
|
TodoEvents,
|
|
66
|
-
hasInvalidDownloadFilename,
|
|
67
|
-
formatContentDisposition,
|
|
68
41
|
ListExportServiceLive,
|
|
69
42
|
DynamicSchemaConfig,
|
|
70
43
|
AppSchemaBuilderLive,
|
|
71
44
|
Yoga,
|
|
72
45
|
ResolverRuntime,
|
|
73
46
|
YogaLive,
|
|
74
|
-
SqliteQueueServiceLive,
|
|
75
47
|
warnIgnoredCronDeclarations,
|
|
76
48
|
getEffectiveFrontendBaseUrl,
|
|
77
49
|
LocalDocumentStoreConfig,
|
|
78
50
|
generateLocalDocumentStoreToken,
|
|
79
51
|
LocalDocumentStoreServiceLive,
|
|
80
|
-
makeServerPluginWebhookRouter
|
|
81
|
-
|
|
52
|
+
makeServerPluginWebhookRouter,
|
|
53
|
+
PROJECT_ACCOUNTING_QUEUE,
|
|
54
|
+
ProjectAccountingChange,
|
|
55
|
+
ProjectAccountingEvents,
|
|
56
|
+
LocalQueueServiceLive
|
|
57
|
+
} from "./chunk-r5s2v669.js";
|
|
58
|
+
import {
|
|
59
|
+
hasInvalidDownloadFilename,
|
|
60
|
+
formatContentDisposition,
|
|
61
|
+
QueueService,
|
|
62
|
+
Runtime,
|
|
63
|
+
DatabaseConnectionInfo,
|
|
64
|
+
LOCAL_SQLITE_BUSY_TIMEOUT_MS,
|
|
65
|
+
CurrentPrincipal,
|
|
66
|
+
AuthenticationDelegationIdentityFactsLive,
|
|
67
|
+
TypedSqliteDrizzleLayer,
|
|
68
|
+
FileOperations,
|
|
69
|
+
UserDetails,
|
|
70
|
+
SqliteDelegationDatabaseLive,
|
|
71
|
+
SqliteAuthenticationDatabaseLive,
|
|
72
|
+
makeLocalSqlClientLayer
|
|
73
|
+
} from "./chunk-04r0t2mb.js";
|
|
74
|
+
import {
|
|
75
|
+
NumberFromString,
|
|
76
|
+
DEFAULT_GRAPHQL_PORT,
|
|
77
|
+
GRAPHQL_PORT_FILE
|
|
78
|
+
} from "./chunk-cbd36jq1.js";
|
|
79
|
+
import {
|
|
80
|
+
RequestTime,
|
|
81
|
+
SqliteCompletedJobOperationsLive,
|
|
82
|
+
SqliteFileOperationsLive,
|
|
83
|
+
SqliteFlowExecutionOperationsLive,
|
|
84
|
+
SqliteGraphqlDbOperationsLive,
|
|
85
|
+
SqliteScheduledFlowOperationsLive
|
|
86
|
+
} from "./chunk-bg5r4wpv.js";
|
|
82
87
|
import {
|
|
83
88
|
serveOnExactPort,
|
|
84
89
|
serveWithPortFallback,
|
|
85
|
-
writePortFile
|
|
86
|
-
|
|
90
|
+
writePortFile,
|
|
91
|
+
LocalRuntimeAuditLive,
|
|
92
|
+
LocalPolicyRevisionPublisherLive
|
|
93
|
+
} from "./chunk-727y6qkb.js";
|
|
87
94
|
|
|
88
95
|
// src/graphql-server/graphql-server.ts
|
|
89
|
-
import * as
|
|
96
|
+
import * as NodeSdk from "@effect/opentelemetry/NodeSdk";
|
|
90
97
|
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
|
|
91
98
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
92
99
|
import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
|
@@ -96,71 +103,72 @@ import {
|
|
|
96
103
|
Config as Config2,
|
|
97
104
|
Context,
|
|
98
105
|
DateTime,
|
|
99
|
-
Effect as
|
|
106
|
+
Effect as Effect5,
|
|
100
107
|
Exit as Exit2,
|
|
101
|
-
|
|
102
|
-
Layer as Layer4,
|
|
103
|
-
LogLevel,
|
|
108
|
+
Layer as Layer5,
|
|
104
109
|
Logger,
|
|
105
110
|
ManagedRuntime,
|
|
106
|
-
Option as
|
|
107
|
-
Redacted
|
|
111
|
+
Option as Option4,
|
|
112
|
+
Redacted,
|
|
113
|
+
References
|
|
108
114
|
} from "effect";
|
|
115
|
+
import { FetchHttpClient } from "effect/http";
|
|
109
116
|
|
|
110
117
|
// src/services/event-hub.ts
|
|
111
|
-
import { Cause, Effect, Layer, Queue
|
|
118
|
+
import { Cause, Effect, Layer, Queue } from "effect";
|
|
112
119
|
var DEFAULT_BUFFER_SIZE = 32;
|
|
113
120
|
var createEventHubLayer = (tag, options = {}) => {
|
|
114
121
|
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
|
-
|
|
122
|
+
return Layer.effect(tag, createEventHub(bufferSize));
|
|
123
|
+
};
|
|
124
|
+
var createEventHub = (bufferSize = DEFAULT_BUFFER_SIZE) => Effect.sync(() => {
|
|
125
|
+
const subscribers = new Map;
|
|
126
|
+
return {
|
|
127
|
+
emit: (event) => Effect.forEach(Array.from(subscribers).filter(([, accepts]) => accepts(event)), ([queue]) => Queue.offer(queue, event), { discard: true }),
|
|
128
|
+
subscribe: (accepts = () => true) => Effect.gen(function* () {
|
|
129
|
+
const queue = yield* Queue.sliding(bufferSize);
|
|
130
|
+
subscribers.set(queue, accepts);
|
|
131
|
+
const runtime = yield* Effect.context();
|
|
132
|
+
const run = Effect.runPromiseWith(runtime);
|
|
133
|
+
let closed = false;
|
|
134
|
+
const close = async () => {
|
|
135
|
+
closed = true;
|
|
136
|
+
subscribers.delete(queue);
|
|
137
|
+
await run(Queue.shutdown(queue));
|
|
138
|
+
};
|
|
139
|
+
const iterator = {
|
|
140
|
+
[Symbol.asyncIterator]() {
|
|
141
|
+
return this;
|
|
142
|
+
},
|
|
143
|
+
async next() {
|
|
144
|
+
if (closed)
|
|
145
|
+
return { done: true, value: undefined };
|
|
146
|
+
try {
|
|
147
|
+
const event = await run(Queue.take(queue));
|
|
148
|
+
return closed ? { done: true, value: undefined } : { done: false, value: event };
|
|
149
|
+
} catch (error) {
|
|
135
150
|
if (closed)
|
|
136
151
|
return { done: true, value: undefined };
|
|
137
152
|
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) {
|
|
153
|
+
await run(Effect.logError("Subscriber queue error", Cause.die(error)));
|
|
154
|
+
} catch {}
|
|
155
155
|
await close();
|
|
156
156
|
throw error;
|
|
157
157
|
}
|
|
158
|
-
}
|
|
159
|
-
return
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
158
|
+
},
|
|
159
|
+
async return() {
|
|
160
|
+
await close();
|
|
161
|
+
return { done: true, value: undefined };
|
|
162
|
+
},
|
|
163
|
+
async throw(error) {
|
|
164
|
+
await close();
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
return iterator;
|
|
169
|
+
})
|
|
170
|
+
};
|
|
171
|
+
});
|
|
164
172
|
|
|
165
173
|
// src/services/draft-process-events.ts
|
|
166
174
|
var DraftProcessEventsLive = createEventHubLayer(DraftProcessEvents);
|
|
@@ -169,11 +177,12 @@ var DraftProcessEventsLive = createEventHubLayer(DraftProcessEvents);
|
|
|
169
177
|
var ExecutionEventsLive = createEventHubLayer(ExecutionEvents);
|
|
170
178
|
|
|
171
179
|
// src/services/http-cedar-reload-notifier.ts
|
|
172
|
-
import { Cause as Cause2, Config, Effect as Effect2, Layer as Layer2, Option
|
|
180
|
+
import { Cause as Cause2, Config, Effect as Effect2, Layer as Layer2, Option } from "effect";
|
|
181
|
+
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
173
182
|
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.
|
|
183
|
+
const httpClient = yield* HttpClient.HttpClient;
|
|
184
|
+
const runtime = yield* Effect2.context();
|
|
185
|
+
const revalidateSecret = yield* Config.option(Config.String("REVALIDATE_SECRET"));
|
|
177
186
|
if (Option.isNone(revalidateSecret)) {
|
|
178
187
|
yield* Effect2.logWarning("REVALIDATE_SECRET not configured; Cedar reloads will skip frontend cache invalidation");
|
|
179
188
|
} else {
|
|
@@ -186,18 +195,18 @@ var HttpCedarReloadNotifierLive = Layer2.effect(CedarReloadNotifierService, Effe
|
|
|
186
195
|
return;
|
|
187
196
|
}
|
|
188
197
|
const baseUrl = getEffectiveFrontendBaseUrl();
|
|
189
|
-
const request = yield* post(`${baseUrl}/api/revalidate`).pipe(bodyJson({
|
|
198
|
+
const request = yield* HttpClientRequest.post(`${baseUrl}/api/revalidate`).pipe(HttpClientRequest.bodyJson({
|
|
190
199
|
path: "/settings",
|
|
191
200
|
tag: "cedar-policies",
|
|
192
201
|
secret: revalidateSecret.value
|
|
193
202
|
}));
|
|
194
203
|
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({
|
|
204
|
+
yield* httpClient.execute(request).pipe(Effect2.flatMap(HttpClientResponse.filterStatusOk), Effect2.scoped, Effect2.matchEffect({
|
|
196
205
|
onSuccess: () => Effect2.log(`Successfully invalidated frontend cedar-policies cache and /settings at ${baseUrl}`),
|
|
197
206
|
onFailure: (error) => Effect2.logWarning(`Failed to invalidate frontend cache at ${baseUrl} (non-fatal): ${error instanceof Error ? error.message : String(error)}`)
|
|
198
207
|
}));
|
|
199
|
-
}).pipe(Effect2.
|
|
200
|
-
|
|
208
|
+
}).pipe(Effect2.catchCause((cause) => Effect2.logWarning(`Failed to prepare frontend cache invalidation request (non-fatal): ${Cause2.pretty(cause)}`)));
|
|
209
|
+
Effect2.runForkWith(runtime)(effect);
|
|
201
210
|
}
|
|
202
211
|
};
|
|
203
212
|
}));
|
|
@@ -205,6 +214,32 @@ var HttpCedarReloadNotifierLive = Layer2.effect(CedarReloadNotifierService, Effe
|
|
|
205
214
|
// src/services/process-events.ts
|
|
206
215
|
var ProcessEventsLive = createEventHubLayer(ProcessEvents);
|
|
207
216
|
|
|
217
|
+
// src/services/project-accounting-events.ts
|
|
218
|
+
import { Effect as Effect3, Layer as Layer3, Option as Option2, Schedule } from "effect";
|
|
219
|
+
var ProjectAccountingEventsLive = Layer3.effect(ProjectAccountingEvents, Effect3.gen(function* () {
|
|
220
|
+
const queue = yield* QueueService;
|
|
221
|
+
const hub = yield* createEventHub();
|
|
222
|
+
const dispatch = Effect3.gen(function* () {
|
|
223
|
+
const claimed = yield* QueueService.claim(PROJECT_ACCOUNTING_QUEUE, ProjectAccountingChange);
|
|
224
|
+
if (Option2.isNone(claimed))
|
|
225
|
+
return;
|
|
226
|
+
const job = claimed.value;
|
|
227
|
+
yield* hub.emit(job.payload);
|
|
228
|
+
yield* queue.acknowledge(job.jobId, job.receipt);
|
|
229
|
+
});
|
|
230
|
+
yield* dispatch.pipe(Effect3.catchCause(Effect3.logError), Effect3.repeat(Schedule.spaced("250 millis")), Effect3.forkScoped);
|
|
231
|
+
return {
|
|
232
|
+
emit: hub.emit,
|
|
233
|
+
subscribe: (projectId, recipientPrincipalId, environmentId) => hub.subscribe((event) => {
|
|
234
|
+
if ("recipientPrincipalId" in event)
|
|
235
|
+
return event.recipientPrincipalId === recipientPrincipalId;
|
|
236
|
+
if ("deployment" in event)
|
|
237
|
+
return event.deployment.projectId === projectId && event.deployment.environmentId === environmentId;
|
|
238
|
+
return environmentId === undefined && event.projectId === projectId;
|
|
239
|
+
})
|
|
240
|
+
};
|
|
241
|
+
}));
|
|
242
|
+
|
|
208
243
|
// src/services/todo-events.ts
|
|
209
244
|
var TodoEventsLive = createEventHubLayer(TodoEvents);
|
|
210
245
|
|
|
@@ -215,13 +250,13 @@ import { join } from "path";
|
|
|
215
250
|
import { parseArgs as utilParseArgs } from "util";
|
|
216
251
|
import {
|
|
217
252
|
Data,
|
|
218
|
-
Effect as
|
|
253
|
+
Effect as Effect4,
|
|
219
254
|
Context as EffectContext,
|
|
220
255
|
Exit,
|
|
221
|
-
Layer as
|
|
256
|
+
Layer as Layer4,
|
|
222
257
|
Metric,
|
|
223
|
-
Option as
|
|
224
|
-
Schedule,
|
|
258
|
+
Option as Option3,
|
|
259
|
+
Schedule as Schedule2,
|
|
225
260
|
Schema
|
|
226
261
|
} from "effect";
|
|
227
262
|
|
|
@@ -376,6 +411,8 @@ function makeServer(options) {
|
|
|
376
411
|
connectionInitWaitTimeout = 3000,
|
|
377
412
|
onConnect,
|
|
378
413
|
onDisconnect,
|
|
414
|
+
onPing,
|
|
415
|
+
onPong,
|
|
379
416
|
onClose,
|
|
380
417
|
onSubscribe,
|
|
381
418
|
onOperation,
|
|
@@ -390,7 +427,7 @@ function makeServer(options) {
|
|
|
390
427
|
const ctx = {
|
|
391
428
|
connectionInitReceived: false,
|
|
392
429
|
acknowledged: false,
|
|
393
|
-
subscriptions:
|
|
430
|
+
subscriptions: /* @__PURE__ */ Object.create(null),
|
|
394
431
|
extra
|
|
395
432
|
};
|
|
396
433
|
if (socket.protocol !== GRAPHQL_TRANSPORT_WS_PROTOCOL) {
|
|
@@ -430,14 +467,17 @@ function makeServer(options) {
|
|
|
430
467
|
return;
|
|
431
468
|
}
|
|
432
469
|
case MessageType.Ping: {
|
|
433
|
-
|
|
470
|
+
await onPing?.(ctx, message.payload);
|
|
471
|
+
if (socket.onPing) {
|
|
434
472
|
return await socket.onPing(message.payload);
|
|
473
|
+
}
|
|
435
474
|
await socket.send(stringifyMessage(message.payload ? { type: MessageType.Pong, payload: message.payload } : {
|
|
436
475
|
type: MessageType.Pong
|
|
437
|
-
}));
|
|
476
|
+
}, replacer));
|
|
438
477
|
return;
|
|
439
478
|
}
|
|
440
479
|
case MessageType.Pong:
|
|
480
|
+
await onPong?.(ctx, message.payload);
|
|
441
481
|
return await socket.onPong?.(message.payload);
|
|
442
482
|
case MessageType.Subscribe: {
|
|
443
483
|
if (!ctx.acknowledged)
|
|
@@ -559,7 +599,7 @@ function makeServer(options) {
|
|
|
559
599
|
if (connectionInitWait)
|
|
560
600
|
clearTimeout(connectionInitWait);
|
|
561
601
|
const subs = { ...ctx.subscriptions };
|
|
562
|
-
ctx.subscriptions =
|
|
602
|
+
ctx.subscriptions = /* @__PURE__ */ Object.create(null);
|
|
563
603
|
await Promise.all(Object.values(subs).filter(isAsyncGenerator).map((sub) => sub.return(undefined)));
|
|
564
604
|
if (ctx.acknowledged)
|
|
565
605
|
await onDisconnect?.(ctx, code, reason);
|
|
@@ -653,9 +693,9 @@ class Mutex {
|
|
|
653
693
|
}
|
|
654
694
|
}
|
|
655
695
|
|
|
656
|
-
class CallbackSecret extends EffectContext.
|
|
696
|
+
class CallbackSecret extends EffectContext.Service()("processfocus:internal-tag/runtime-local/CallbackSecret") {
|
|
657
697
|
}
|
|
658
|
-
var CallbackSecretLive =
|
|
698
|
+
var CallbackSecretLive = Layer4.effect(CallbackSecret, Effect4.sync(() => Option3.fromNullishOr(process.env["INTERNAL_API_SECRET"])));
|
|
659
699
|
var activeWebSocketConnections = Metric.gauge("graphql.websocket.connections.active", {
|
|
660
700
|
description: "Number of active WebSocket connections (subscribers)"
|
|
661
701
|
});
|
|
@@ -666,11 +706,11 @@ var activeGraphqlSubscriptions = Metric.gauge("graphql.subscriptions.active", {
|
|
|
666
706
|
class InvalidUsageError extends Data.TaggedError("InvalidUsageError") {
|
|
667
707
|
}
|
|
668
708
|
var ParsedArgsSchema = Schema.Struct({
|
|
669
|
-
port: Schema.optional(
|
|
709
|
+
port: Schema.optional(NumberFromString.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isBetween({ minimum: 0, maximum: 65535 })))),
|
|
670
710
|
org: Schema.String
|
|
671
711
|
});
|
|
672
|
-
var parseArgs = (args) =>
|
|
673
|
-
const parseResult = yield*
|
|
712
|
+
var parseArgs = (args) => Effect4.gen(function* () {
|
|
713
|
+
const parseResult = yield* Effect4.try({
|
|
674
714
|
try: () => utilParseArgs({
|
|
675
715
|
args,
|
|
676
716
|
options: {
|
|
@@ -687,19 +727,19 @@ var parseArgs = (args) => Effect3.gen(function* () {
|
|
|
687
727
|
console.error("Error: --org is required (or set PF_ORG environment variable)");
|
|
688
728
|
return yield* new InvalidUsageError({ _: undefined });
|
|
689
729
|
}
|
|
690
|
-
return yield* Schema.
|
|
730
|
+
return yield* Schema.decodeUnknownEffect(ParsedArgsSchema)({
|
|
691
731
|
port: parseResult.values.port,
|
|
692
732
|
org
|
|
693
|
-
}).pipe(
|
|
733
|
+
}).pipe(Effect4.mapError(() => new InvalidUsageError({ _: undefined })));
|
|
694
734
|
});
|
|
695
|
-
var makeServerEffect = (port) =>
|
|
735
|
+
var makeServerEffect = (port) => Effect4.gen(function* () {
|
|
696
736
|
const yoga = yield* Yoga;
|
|
697
737
|
const resolverRuntime = yield* ResolverRuntime;
|
|
698
738
|
const routeServerPluginWebhook = yield* makeServerPluginWebhookRouter;
|
|
699
739
|
const callbackSecret = yield* CallbackSecret;
|
|
700
740
|
const docStoreConfig = yield* LocalDocumentStoreConfig;
|
|
701
741
|
const dbConnectionInfo = yield* DatabaseConnectionInfo;
|
|
702
|
-
yield*
|
|
742
|
+
yield* Effect4.log(`\uD83D\uDCBE Connecting to database: ${dbConnectionInfo}`);
|
|
703
743
|
const activeSubscriptions = new Map;
|
|
704
744
|
let connectionCounter = 0;
|
|
705
745
|
let connectionIdCounter = 0;
|
|
@@ -718,7 +758,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
718
758
|
console.log(`
|
|
719
759
|
\uD83D\uDD0C [WS #${connId}] Connection OPENED (total active: ${connectionCounter})`);
|
|
720
760
|
console.log(` Timestamp: ${new Date().toISOString()}`);
|
|
721
|
-
resolverRuntime.runFork(Metric.
|
|
761
|
+
resolverRuntime.runFork(Metric.update(activeWebSocketConnections, connectionCounter));
|
|
722
762
|
return true;
|
|
723
763
|
},
|
|
724
764
|
onComplete: (ctx, id) => {
|
|
@@ -730,7 +770,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
730
770
|
activeSubscriptions.delete(id);
|
|
731
771
|
}
|
|
732
772
|
console.log(`\uD83D\uDCCA [WS] Active subscriptions: ${activeSubscriptions.size}`);
|
|
733
|
-
resolverRuntime.runFork(Metric.
|
|
773
|
+
resolverRuntime.runFork(Metric.update(activeGraphqlSubscriptions, activeSubscriptions.size));
|
|
734
774
|
},
|
|
735
775
|
onSubscribe: async (ctx, id, payload) => {
|
|
736
776
|
const connId = connectionToId.get(ctx) ?? 0;
|
|
@@ -743,7 +783,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
743
783
|
\uD83D\uDCE5 [WS #${connId}] New subscription: id=${id.slice(0, 8)} operation=${payload.operationName}`);
|
|
744
784
|
console.log(` Timestamp: ${new Date().toISOString()}`);
|
|
745
785
|
console.log(`\uD83D\uDCCA [WS] Active subscriptions: ${activeSubscriptions.size}`);
|
|
746
|
-
resolverRuntime.runFork(Metric.
|
|
786
|
+
resolverRuntime.runFork(Metric.update(activeGraphqlSubscriptions, activeSubscriptions.size));
|
|
747
787
|
const grouped = new Map;
|
|
748
788
|
for (const [, s] of activeSubscriptions) {
|
|
749
789
|
grouped.set(s.operation, (grouped.get(s.operation) || 0) + 1);
|
|
@@ -803,7 +843,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
803
843
|
}
|
|
804
844
|
if (url.pathname === "/internal/todo-event" && request.method === "POST") {
|
|
805
845
|
const providedSecret = request.headers.get("x-callback-secret");
|
|
806
|
-
if (
|
|
846
|
+
if (Option3.isNone(callbackSecret)) {
|
|
807
847
|
return new Response("Unauthorized", { status: 401 });
|
|
808
848
|
}
|
|
809
849
|
if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
|
|
@@ -811,7 +851,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
811
851
|
}
|
|
812
852
|
const event = await request.json();
|
|
813
853
|
const { schema } = yoga.getEnveloped({ req: request });
|
|
814
|
-
const emitEffect =
|
|
854
|
+
const emitEffect = Effect4.flatMap(TodoEvents, (todoEvents) => todoEvents.emit(event, schema));
|
|
815
855
|
const result = await resolverRuntime.runPromiseExit(emitEffect);
|
|
816
856
|
if (Exit.isFailure(result)) {
|
|
817
857
|
console.error("Failed to process todo event callback:", result.cause);
|
|
@@ -821,7 +861,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
821
861
|
}
|
|
822
862
|
if (url.pathname === "/internal/process-event" && request.method === "POST") {
|
|
823
863
|
const providedSecret = request.headers.get("x-callback-secret");
|
|
824
|
-
if (
|
|
864
|
+
if (Option3.isNone(callbackSecret)) {
|
|
825
865
|
return new Response("Unauthorized", { status: 401 });
|
|
826
866
|
}
|
|
827
867
|
if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
|
|
@@ -829,7 +869,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
829
869
|
}
|
|
830
870
|
const event = await request.json();
|
|
831
871
|
const { schema } = yoga.getEnveloped({ req: request });
|
|
832
|
-
const emitEffect =
|
|
872
|
+
const emitEffect = Effect4.flatMap(ProcessEvents, (processEvents) => processEvents.emit(event, schema));
|
|
833
873
|
const result = await resolverRuntime.runPromiseExit(emitEffect);
|
|
834
874
|
if (Exit.isFailure(result)) {
|
|
835
875
|
console.error("Failed to process process event callback:", result.cause);
|
|
@@ -839,7 +879,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
839
879
|
}
|
|
840
880
|
if (url.pathname === "/internal/execution-event" && request.method === "POST") {
|
|
841
881
|
const providedSecret = request.headers.get("x-callback-secret");
|
|
842
|
-
if (
|
|
882
|
+
if (Option3.isNone(callbackSecret)) {
|
|
843
883
|
return new Response("Unauthorized", { status: 401 });
|
|
844
884
|
}
|
|
845
885
|
if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
|
|
@@ -847,7 +887,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
847
887
|
}
|
|
848
888
|
const event = await request.json();
|
|
849
889
|
const { schema } = yoga.getEnveloped({ req: request });
|
|
850
|
-
const emitEffect =
|
|
890
|
+
const emitEffect = Effect4.flatMap(ExecutionEvents, (executionEvents) => executionEvents.emit(event, schema));
|
|
851
891
|
const result = await resolverRuntime.runPromiseExit(emitEffect);
|
|
852
892
|
if (Exit.isFailure(result)) {
|
|
853
893
|
console.error("Failed to process execution event callback:", result.cause);
|
|
@@ -857,7 +897,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
857
897
|
}
|
|
858
898
|
if (url.pathname === "/internal/import-completed" && request.method === "POST") {
|
|
859
899
|
const providedSecret = request.headers.get("x-callback-secret");
|
|
860
|
-
if (
|
|
900
|
+
if (Option3.isNone(callbackSecret)) {
|
|
861
901
|
return new Response("Unauthorized", { status: 401 });
|
|
862
902
|
}
|
|
863
903
|
if (!providedSecret || !constantTimeEqual(providedSecret, callbackSecret.value)) {
|
|
@@ -874,8 +914,8 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
874
914
|
}
|
|
875
915
|
const { processPaths } = body;
|
|
876
916
|
const { schema } = yoga.getEnveloped({ req: request });
|
|
877
|
-
const importCompletedEffect =
|
|
878
|
-
yield*
|
|
917
|
+
const importCompletedEffect = Effect4.gen(function* () {
|
|
918
|
+
yield* Effect4.log(`Received import-completed for ${processPaths.length} process(es): ${processPaths.join(", ")}`);
|
|
879
919
|
const processOps = yield* ProcessCollectionOps;
|
|
880
920
|
const executionOps = yield* ExecutionCollectionOps;
|
|
881
921
|
const todoOps = yield* TodoCollectionOps;
|
|
@@ -883,10 +923,10 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
883
923
|
const allProcessRows = yield* processOps.pull(null, 1e4);
|
|
884
924
|
const matchedProcessRows = allProcessRows.filter((row) => processPaths.includes(row.path));
|
|
885
925
|
if (matchedProcessRows.length === 0) {
|
|
886
|
-
yield*
|
|
926
|
+
yield* Effect4.log(`No matching processes found (${allProcessRows.length} in DB, none matching requested paths)`);
|
|
887
927
|
return;
|
|
888
928
|
}
|
|
889
|
-
const graphqlProcesses = yield*
|
|
929
|
+
const graphqlProcesses = yield* Effect4.all(matchedProcessRows.map((row) => processOps.mapToGraphql(row)), { concurrency: "unbounded" });
|
|
890
930
|
const lastProcess = graphqlProcesses[graphqlProcesses.length - 1];
|
|
891
931
|
if (lastProcess) {
|
|
892
932
|
const processEvent = {
|
|
@@ -896,14 +936,14 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
896
936
|
updatedAt: lastProcess.updatedAt
|
|
897
937
|
}
|
|
898
938
|
};
|
|
899
|
-
yield*
|
|
939
|
+
yield* Effect4.flatMap(ProcessEvents, (processEvents) => processEvents.emit(processEvent, schema));
|
|
900
940
|
}
|
|
901
|
-
yield*
|
|
941
|
+
yield* Effect4.log(`Emitted ${graphqlProcesses.length} process update(s)`);
|
|
902
942
|
const matchedPaths = new Set(graphqlProcesses.map((p) => p.path));
|
|
903
943
|
const allExecutionRows = yield* executionOps.pull(null, 1e4);
|
|
904
944
|
const matchedExecutionRows = allExecutionRows.filter((row) => matchedPaths.has(row.execution.processPath));
|
|
905
945
|
if (matchedExecutionRows.length > 0) {
|
|
906
|
-
const graphqlExecutions = yield*
|
|
946
|
+
const graphqlExecutions = yield* Effect4.all(matchedExecutionRows.map((row) => executionOps.mapToGraphql(row).pipe(Effect4.map((document) => ({
|
|
907
947
|
...document,
|
|
908
948
|
startedByEmail: row.execution.startedByEmail,
|
|
909
949
|
startedByRolePath: row.execution.startedByRolePath
|
|
@@ -917,16 +957,16 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
917
957
|
updatedAt: lastExecution.updatedAt
|
|
918
958
|
}
|
|
919
959
|
};
|
|
920
|
-
yield*
|
|
960
|
+
yield* Effect4.flatMap(ExecutionEvents, (executionEvents) => executionEvents.emit(executionEvent, schema));
|
|
921
961
|
}
|
|
922
|
-
yield*
|
|
962
|
+
yield* Effect4.log(`Emitted ${graphqlExecutions.length} execution update(s)`);
|
|
923
963
|
}
|
|
924
964
|
const matchedExecutionIds = new Set(matchedExecutionRows.map((row) => row.execution.id));
|
|
925
965
|
const allTodoRows = yield* todoOps.pull(null, 1e4);
|
|
926
966
|
const matchedTodoRows = allTodoRows.filter((row) => matchedExecutionIds.has(row.processExecutionId));
|
|
927
967
|
if (matchedTodoRows.length > 0) {
|
|
928
968
|
const matchedTodoRowsWithSummary = yield* todoSummaryComputation.enrichWithSummaries(matchedTodoRows);
|
|
929
|
-
const graphqlTodos = yield*
|
|
969
|
+
const graphqlTodos = yield* Effect4.all(matchedTodoRowsWithSummary.map((row) => todoOps.mapToGraphql(row)), { concurrency: "unbounded" });
|
|
930
970
|
const sortedTodos = [...graphqlTodos].sort((a, b) => {
|
|
931
971
|
if (a.updatedAt !== b.updatedAt) {
|
|
932
972
|
return a.updatedAt - b.updatedAt;
|
|
@@ -943,17 +983,17 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
943
983
|
mode: "INCREMENTAL" /* Incremental */
|
|
944
984
|
}
|
|
945
985
|
};
|
|
946
|
-
yield*
|
|
986
|
+
yield* Effect4.flatMap(TodoEvents, (todoEvents) => todoEvents.emit(todoEvent, schema));
|
|
947
987
|
}
|
|
948
|
-
yield*
|
|
988
|
+
yield* Effect4.log(`Emitted ${graphqlTodos.length} todo update(s)`);
|
|
949
989
|
}
|
|
950
990
|
});
|
|
951
991
|
const result = await resolverRuntime.runPromiseExit(importCompletedEffect);
|
|
952
992
|
if (Exit.isFailure(result)) {
|
|
953
|
-
await resolverRuntime.runPromise(
|
|
993
|
+
await resolverRuntime.runPromise(Effect4.logError("Failed to process import-completed").pipe(Effect4.annotateLogs("cause", String(result.cause))));
|
|
954
994
|
return new Response("Internal Server Error", { status: 500 });
|
|
955
995
|
}
|
|
956
|
-
await resolverRuntime.runPromise(
|
|
996
|
+
await resolverRuntime.runPromise(Effect4.log("Import-completed processing done"));
|
|
957
997
|
return new Response(null, { status: 204 });
|
|
958
998
|
}
|
|
959
999
|
const fileCorsHeaders = {
|
|
@@ -979,14 +1019,14 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
979
1019
|
if (Number.isNaN(expiresNum) || Date.now() / 1000 > expiresNum) {
|
|
980
1020
|
return new Response("URL expired", { status: 403 });
|
|
981
1021
|
}
|
|
982
|
-
if (
|
|
1022
|
+
if (Option3.isNone(callbackSecret)) {
|
|
983
1023
|
return new Response("Unauthorized", { status: 401 });
|
|
984
1024
|
}
|
|
985
1025
|
const expectedToken = generateLocalDocumentStoreToken(storePrefix, fileId, expires, callbackSecret.value);
|
|
986
1026
|
if (!constantTimeEqual(token, expectedToken)) {
|
|
987
1027
|
return new Response("Unauthorized", { status: 401 });
|
|
988
1028
|
}
|
|
989
|
-
const fileResult = await resolverRuntime.runPromiseExit(
|
|
1029
|
+
const fileResult = await resolverRuntime.runPromiseExit(Effect4.gen(function* () {
|
|
990
1030
|
const fileOps = yield* FileOperations;
|
|
991
1031
|
return yield* fileOps.getFileWithStore(fileId);
|
|
992
1032
|
}));
|
|
@@ -1066,10 +1106,10 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
1066
1106
|
} catch {}
|
|
1067
1107
|
return new Response(`File too large: exceeds limit of ${maxFileSize} bytes`, { status: 413, headers: fileCorsHeaders });
|
|
1068
1108
|
}
|
|
1069
|
-
const markResult = await resolverRuntime.runPromiseExit(
|
|
1109
|
+
const markResult = await resolverRuntime.runPromiseExit(Effect4.gen(function* () {
|
|
1070
1110
|
const fileOps = yield* FileOperations;
|
|
1071
1111
|
yield* fileOps.markFileUploaded(fileId, bytesWritten, contentType);
|
|
1072
|
-
}).pipe(
|
|
1112
|
+
}).pipe(Effect4.retry(Schedule2.exponential("100 millis").pipe((schedule) => Schedule2.max([schedule, Schedule2.recurs(2)])))));
|
|
1073
1113
|
if (Exit.isFailure(markResult)) {
|
|
1074
1114
|
console.error(`Failed to mark file ${fileId} as uploaded in DB:`, markResult.cause);
|
|
1075
1115
|
try {
|
|
@@ -1106,7 +1146,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
1106
1146
|
if (filename && hasInvalidDownloadFilename(filename)) {
|
|
1107
1147
|
return new Response("Bad Request", { status: 400 });
|
|
1108
1148
|
}
|
|
1109
|
-
if (
|
|
1149
|
+
if (Option3.isNone(callbackSecret)) {
|
|
1110
1150
|
return new Response("Unauthorized", { status: 401 });
|
|
1111
1151
|
}
|
|
1112
1152
|
const expectedToken = generateLocalDocumentStoreToken(storePrefix, fileId, expires, callbackSecret.value, filename ?? undefined);
|
|
@@ -1145,7 +1185,11 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
1145
1185
|
}
|
|
1146
1186
|
return new Response;
|
|
1147
1187
|
}
|
|
1148
|
-
|
|
1188
|
+
const response = await yoga.fetch(request, srv);
|
|
1189
|
+
if (response.headers.get("content-type")?.includes("text/event-stream")) {
|
|
1190
|
+
srv.timeout(request, 0);
|
|
1191
|
+
}
|
|
1192
|
+
return response;
|
|
1149
1193
|
},
|
|
1150
1194
|
websocket: {
|
|
1151
1195
|
...websocketHandler,
|
|
@@ -1161,7 +1205,7 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
1161
1205
|
console.log(`
|
|
1162
1206
|
\uD83D\uDD0C [WS #${connId}] Connection CLOSED: code=${code} reason=${reason} (remaining: ${connectionCounter})`);
|
|
1163
1207
|
console.log(` Timestamp: ${new Date().toISOString()}`);
|
|
1164
|
-
resolverRuntime.runFork(Metric.
|
|
1208
|
+
resolverRuntime.runFork(Metric.update(activeWebSocketConnections, connectionCounter));
|
|
1165
1209
|
const remaining = Array.from(activeSubscriptions.entries()).filter(([, s]) => s.connectionId === connId);
|
|
1166
1210
|
if (remaining.length > 0) {
|
|
1167
1211
|
console.log(" \uD83E\uDDF9 Cleaning up orphaned subscriptions:", remaining.map(([id, s]) => `${id.slice(0, 8)}:${s.operation}`).join(", "));
|
|
@@ -1169,61 +1213,62 @@ var makeServerEffect = (port) => Effect3.gen(function* () {
|
|
|
1169
1213
|
activeSubscriptions.delete(id);
|
|
1170
1214
|
}
|
|
1171
1215
|
console.log(`\uD83D\uDCCA [WS] Active subscriptions: ${activeSubscriptions.size}`);
|
|
1172
|
-
resolverRuntime.runFork(Metric.
|
|
1216
|
+
resolverRuntime.runFork(Metric.update(activeGraphqlSubscriptions, activeSubscriptions.size));
|
|
1173
1217
|
}
|
|
1174
1218
|
}
|
|
1175
1219
|
return websocketHandler.close?.(ws, code, reason);
|
|
1176
1220
|
}
|
|
1177
1221
|
}
|
|
1178
1222
|
};
|
|
1179
|
-
const serveEffect =
|
|
1180
|
-
const server = yield*
|
|
1181
|
-
yield*
|
|
1182
|
-
yield*
|
|
1223
|
+
const serveEffect = Option3.isSome(port) ? serveOnExactPort(port.value, serverOptions) : serveWithPortFallback(DEFAULT_GRAPHQL_PORT, serverOptions);
|
|
1224
|
+
const server = yield* Effect4.acquireRelease(serveEffect, (srv) => Effect4.promise(() => srv.stop()));
|
|
1225
|
+
yield* Effect4.log(`\uD83D\uDE80 GraphQL server running at http://${server.hostname}:${server.port}/graphql`);
|
|
1226
|
+
yield* Effect4.log(`\uD83D\uDD0C WebSocket subscriptions available at ws://${server.hostname}:${server.port}/graphql`);
|
|
1183
1227
|
return server;
|
|
1184
1228
|
});
|
|
1185
1229
|
|
|
1186
1230
|
// src/graphql-server/graphql-server.ts
|
|
1231
|
+
process.env["PF_RUNTIME_MODE"] = "local";
|
|
1187
1232
|
var makeAuthorizationLayer = (policyPaths, schemaPaths) => {
|
|
1188
1233
|
if (policyPaths.length > 0) {
|
|
1189
1234
|
const hotReloadConfig = LocalCedarConfigHotReload("/", policyPaths, schemaPaths);
|
|
1190
|
-
return
|
|
1235
|
+
return LocalCedarAuthorizationLive.pipe(Layer5.provide(LocalPolicyRevisionPublisherLive), Layer5.provideMerge(hotReloadConfig));
|
|
1191
1236
|
}
|
|
1192
1237
|
const staticConfig = LocalCedarConfigStatic(undefined, schemaPaths);
|
|
1193
|
-
return
|
|
1238
|
+
return LocalCedarAuthorizationLive.pipe(Layer5.provide(LocalPolicyRevisionPublisherLive), Layer5.provideMerge(staticConfig));
|
|
1194
1239
|
};
|
|
1195
|
-
var CliConfig = Context.
|
|
1196
|
-
var CliConfigLive =
|
|
1197
|
-
port:
|
|
1240
|
+
var CliConfig = Context.Service("processfocus:internal-tag/runtime-local/GraphqlServerCliConfig");
|
|
1241
|
+
var CliConfigLive = Layer5.effect(CliConfig, parseArgs(process.argv.slice(2)).pipe(Effect5.map((args) => ({
|
|
1242
|
+
port: Option4.fromNullishOr(args.port),
|
|
1198
1243
|
org: args.org
|
|
1199
|
-
})),
|
|
1244
|
+
})), Effect5.catch((error) => {
|
|
1200
1245
|
console.error("Invalid arguments. Usage: bun run main.ts [--port PORT | -p PORT] [--org ORG | -o ORG]");
|
|
1201
1246
|
console.error(" --port, -p Exact port number (fails if in use, does not write port file)");
|
|
1202
1247
|
console.error(" --org, -o Path to org project (or set PF_ORG env var)");
|
|
1203
|
-
return
|
|
1248
|
+
return Effect5.fail(error);
|
|
1204
1249
|
})));
|
|
1205
|
-
var RequestTimeLive =
|
|
1206
|
-
var UserDetailsLive =
|
|
1250
|
+
var RequestTimeLive = Layer5.succeed(RequestTime, DateTime.makeUnsafe(0));
|
|
1251
|
+
var UserDetailsLive = Layer5.succeed(UserDetails, {
|
|
1207
1252
|
by: "SYSTEM",
|
|
1208
1253
|
id: null
|
|
1209
|
-
})
|
|
1210
|
-
var CurrentPrincipalLive =
|
|
1254
|
+
});
|
|
1255
|
+
var CurrentPrincipalLive = Layer5.succeed(CurrentPrincipal, null);
|
|
1211
1256
|
var businessMetricDimensions = resolveBusinessMetricDimensions({
|
|
1212
1257
|
accountId: process.env["PF_AWS_ACCOUNT_ID"],
|
|
1213
1258
|
project: process.env["PF_PROJECT"],
|
|
1214
1259
|
environment: process.env["PF_ENV"]
|
|
1215
1260
|
});
|
|
1216
|
-
var BusinessMetricDimensionsLive =
|
|
1261
|
+
var BusinessMetricDimensionsLive = Layer5.succeed(BusinessMetricDimensions, businessMetricDimensions);
|
|
1217
1262
|
var DashboardActivityLive = process.env["PF_ANALYTICS_IDENTITY_KEY"] ? makeDashboardActivityLayer({
|
|
1218
1263
|
dimensions: businessMetricDimensions,
|
|
1219
1264
|
key: Redacted.make(process.env["PF_ANALYTICS_IDENTITY_KEY"] ?? ""),
|
|
1220
1265
|
logsUrl: process.env["OTLP_LOGS_URL"] ?? "http://127.0.0.1:4318/v1/logs",
|
|
1221
1266
|
headers: {}
|
|
1222
|
-
}) :
|
|
1223
|
-
var NodeSdkLive =
|
|
1224
|
-
const otlpMetricsUrl = yield* Config2.
|
|
1225
|
-
const otlpTracesUrl = yield* Config2.
|
|
1226
|
-
return
|
|
1267
|
+
}) : Layer5.empty;
|
|
1268
|
+
var NodeSdkLive = Layer5.unwrap(Effect5.gen(function* () {
|
|
1269
|
+
const otlpMetricsUrl = yield* Config2.String("OTLP_METRICS_URL").pipe(Config2.withDefault("http://127.0.0.1:4318/v1/metrics"));
|
|
1270
|
+
const otlpTracesUrl = yield* Config2.String("OTLP_TRACES_URL").pipe(Config2.withDefault("http://127.0.0.1:4318/v1/traces"));
|
|
1271
|
+
return NodeSdk.layer(() => ({
|
|
1227
1272
|
resource: {
|
|
1228
1273
|
serviceName: "graphql-server",
|
|
1229
1274
|
attributes: {
|
|
@@ -1244,55 +1289,55 @@ var NodeSdkLive = Layer4.unwrapEffect(Effect4.gen(function* () {
|
|
|
1244
1289
|
}))
|
|
1245
1290
|
}));
|
|
1246
1291
|
}));
|
|
1247
|
-
var main =
|
|
1292
|
+
var main = Effect5.gen(function* () {
|
|
1248
1293
|
const cliConfig = yield* CliConfig;
|
|
1249
|
-
const OrgProviderLayer =
|
|
1250
|
-
const CedarPoliciesLayer = OrgCedarPoliciesProvider.pipe(
|
|
1251
|
-
const orgProvider = yield* OrganisationProvider.pipe(
|
|
1294
|
+
const OrgProviderLayer = OrganisationProviderFromPathDev(cliConfig.org).pipe(Layer5.provide(layer));
|
|
1295
|
+
const CedarPoliciesLayer = OrgCedarPoliciesProvider.pipe(Layer5.provide(OrgProviderLayer));
|
|
1296
|
+
const orgProvider = yield* OrganisationProvider.pipe(Effect5.provide(OrgProviderLayer));
|
|
1252
1297
|
yield* warnIgnoredCronDeclarations(orgProvider.organisation, "local GraphQL runtime");
|
|
1253
|
-
yield*
|
|
1298
|
+
yield* Effect5.log(`\u2705 Loaded organisation: ${orgProvider.organisation.name}`);
|
|
1254
1299
|
if (orgProvider.customDbLayer) {
|
|
1255
|
-
yield*
|
|
1300
|
+
yield* Effect5.log(`\uD83D\uDCE6 Custom database layer available from organisation`);
|
|
1256
1301
|
}
|
|
1257
|
-
const cedarPolicies = yield* CedarPoliciesProvider.pipe(
|
|
1258
|
-
yield*
|
|
1259
|
-
const DynamicSchemaConfigLive =
|
|
1302
|
+
const cedarPolicies = yield* CedarPoliciesProvider.pipe(Effect5.provide(CedarPoliciesLayer));
|
|
1303
|
+
yield* Effect5.log(`\uD83D\uDCDC Loaded ${cedarPolicies.policyPaths.length} Cedar policy files`);
|
|
1304
|
+
const DynamicSchemaConfigLive = Layer5.succeed(DynamicSchemaConfig, {
|
|
1260
1305
|
schemaPath: orgProvider.schemaPath
|
|
1261
1306
|
});
|
|
1262
1307
|
const internalApiSecret = process.env["INTERNAL_API_SECRET"] ?? "dev-secret";
|
|
1263
|
-
let resolvedServerPort =
|
|
1264
|
-
const LocalDocumentStoreConfigLive =
|
|
1308
|
+
let resolvedServerPort = Option4.isSome(cliConfig.port) ? cliConfig.port.value : DEFAULT_GRAPHQL_PORT;
|
|
1309
|
+
const LocalDocumentStoreConfigLive = Layer5.succeed(LocalDocumentStoreConfig, {
|
|
1265
1310
|
baseUrl: () => `http://localhost:${resolvedServerPort}`,
|
|
1266
1311
|
storagePath: `${orgProvider.orgPath}/files`,
|
|
1267
1312
|
secret: internalApiSecret,
|
|
1268
1313
|
maxFileSize: 100 * 1024 * 1024
|
|
1269
1314
|
});
|
|
1270
1315
|
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(
|
|
1316
|
+
const TodoSummaryComputationWithDeps = TodoSummaryComputationLive.pipe(Layer5.provide(SqliteGraphqlDbOperationsLive), Layer5.provide(OrgProviderLayer));
|
|
1317
|
+
const SlaCalculationServiceWithDeps = SlaCalculationServiceLive.pipe(Layer5.provide(SqliteGraphqlDbOperationsLive));
|
|
1318
|
+
const ExecutionCollectionOpsWithDeps = ExecutionCollectionOpsLive.pipe(Layer5.provide(SlaCalculationServiceWithDeps), Layer5.provide(SqliteGraphqlDbOperationsLive));
|
|
1319
|
+
const ListExportServiceWithDeps = ListExportServiceLive.pipe(Layer5.provide(LocalDocumentStoreServiceLive), Layer5.provide(LocalDocumentStoreConfigLive), Layer5.provide(AuthorizationLive));
|
|
1275
1320
|
const LocalSqlClientLive = makeLocalSqlClientLayer({
|
|
1276
1321
|
busy_timeout: LOCAL_SQLITE_BUSY_TIMEOUT_MS
|
|
1277
1322
|
});
|
|
1278
|
-
const customDbLayerDeps =
|
|
1279
|
-
const customDbLayerWithDeps = orgProvider.customDbLayer ?
|
|
1280
|
-
const HttpCedarReloadNotifierWithDeps = HttpCedarReloadNotifierLive.pipe(
|
|
1281
|
-
const SqliteQueueWithRequestContext =
|
|
1282
|
-
const AppLayer =
|
|
1283
|
-
const ServerLive =
|
|
1323
|
+
const customDbLayerDeps = Layer5.mergeAll(SqliteFileOperationsLive, AuthorizationLive, CurrentPrincipalLive, BusinessMetricDimensionsLive, DashboardActivityLive, RequestTimeLive).pipe(Layer5.provideMerge(TypedSqliteDrizzleLayer), Layer5.provideMerge(LocalSqlClientLive));
|
|
1324
|
+
const customDbLayerWithDeps = orgProvider.customDbLayer ? Layer5.provide(orgProvider.customDbLayer, customDbLayerDeps) : undefined;
|
|
1325
|
+
const HttpCedarReloadNotifierWithDeps = HttpCedarReloadNotifierLive.pipe(Layer5.provide(FetchHttpClient.layer));
|
|
1326
|
+
const SqliteQueueWithRequestContext = LocalQueueServiceLive.pipe(Layer5.provide(Layer5.merge(RequestTimeLive, UserDetailsLive)));
|
|
1327
|
+
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, 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));
|
|
1328
|
+
const ServerLive = Layer5.effectDiscard(Effect5.gen(function* () {
|
|
1284
1329
|
const authConfig = yield* AuthConfig;
|
|
1285
|
-
yield*
|
|
1330
|
+
yield* Effect5.log(`\uD83D\uDD10 Authentication server: ${authConfig.issuerUrl}`);
|
|
1286
1331
|
const server = yield* makeServerEffect(cliConfig.port);
|
|
1287
1332
|
resolvedServerPort = server.port;
|
|
1288
|
-
if (
|
|
1333
|
+
if (Option4.isNone(cliConfig.port)) {
|
|
1289
1334
|
yield* writePortFile(GRAPHQL_PORT_FILE, server.port);
|
|
1290
1335
|
}
|
|
1291
|
-
return yield*
|
|
1336
|
+
return yield* Effect5.never;
|
|
1292
1337
|
}));
|
|
1293
|
-
const QueueCapabilityLive = SqliteQueueWithRequestContext.pipe(
|
|
1294
|
-
const DocumentStoreCapabilityLive = LocalDocumentStoreServiceLive.pipe(
|
|
1295
|
-
const EventPublisherCapabilityLive =
|
|
1338
|
+
const QueueCapabilityLive = SqliteQueueWithRequestContext.pipe(Layer5.provide(AppLayer));
|
|
1339
|
+
const DocumentStoreCapabilityLive = LocalDocumentStoreServiceLive.pipe(Layer5.provide(LocalDocumentStoreConfigLive));
|
|
1340
|
+
const EventPublisherCapabilityLive = Layer5.mergeAll(DraftProcessEventsLive, TodoEventsLive, ProcessEventsLive, ProjectAccountingEventsLive.pipe(Layer5.provide(SqliteQueueWithRequestContext)), ExecutionEventsLive).pipe(Layer5.provide(AppLayer));
|
|
1296
1341
|
return yield* Runtime.graphql({
|
|
1297
1342
|
persistence: AppLayer,
|
|
1298
1343
|
queue: QueueCapabilityLive,
|
|
@@ -1301,19 +1346,19 @@ var main = Effect4.gen(function* () {
|
|
|
1301
1346
|
organisationLoader: OrgProviderLayer,
|
|
1302
1347
|
authorization: AuthorizationLive,
|
|
1303
1348
|
transport: (services) => {
|
|
1304
|
-
const CapabilityLayer =
|
|
1305
|
-
const ResolverRuntimeLive =
|
|
1306
|
-
const AppLive = ServerLive.pipe(
|
|
1307
|
-
return
|
|
1349
|
+
const CapabilityLayer = Layer5.effectContext(Effect5.succeed(services));
|
|
1350
|
+
const ResolverRuntimeLive = Layer5.effect(ResolverRuntime, Effect5.sync(() => ManagedRuntime.make(Layer5.merge(CapabilityLayer, LocalDelegatedRealtime.layer).pipe(Layer5.provide(NodeSdkLive)))));
|
|
1351
|
+
const AppLive = ServerLive.pipe(Layer5.provide(YogaLive), Layer5.provide(AppSchemaBuilderLive), Layer5.provide(ResolverRuntimeLive), Layer5.provide(AuthConfigLive), Layer5.provide(CallbackSecretLive), Layer5.provide(CapabilityLayer));
|
|
1352
|
+
return Layer5.launch(AppLive);
|
|
1308
1353
|
},
|
|
1309
1354
|
logging: {
|
|
1310
|
-
decorate: (effect) => effect.pipe(
|
|
1355
|
+
decorate: (effect) => effect.pipe(Effect5.provideService(References.MinimumLogLevel, "Debug"), Effect5.provide(Logger.layer([Logger.consolePretty()])))
|
|
1311
1356
|
}
|
|
1312
1357
|
});
|
|
1313
1358
|
});
|
|
1314
|
-
|
|
1359
|
+
Effect5.runPromiseExit(main.pipe(Effect5.scoped, Effect5.provide(CliConfigLive))).then((exit) => {
|
|
1315
1360
|
if (Exit2.isFailure(exit)) {
|
|
1316
|
-
console.error("GraphQL server failed to start:", Cause3.pretty(exit.cause
|
|
1361
|
+
console.error("GraphQL server failed to start:", Cause3.pretty(exit.cause));
|
|
1317
1362
|
process.exit(1);
|
|
1318
1363
|
}
|
|
1319
1364
|
});
|