@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/dashboard-source/modules/form-submission-schema/src/lib/form-submission-schema.ts
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { Data, Effect, Result, Schema, SchemaAST } from "effect"
|
|
2
|
+
import {
|
|
3
|
+
type FlattenMarker,
|
|
4
|
+
type ListFieldMarker,
|
|
5
|
+
type ReadOnlyMarker,
|
|
6
|
+
type StructuralOnlyMarker,
|
|
7
|
+
hasFlattenAnnotation,
|
|
8
|
+
hasStructuralOnlyAnnotation,
|
|
9
|
+
isReadOnlyField,
|
|
10
|
+
} from "../../../form-schema/src/index.ts"
|
|
11
|
+
|
|
12
|
+
// Error for field name collisions during flattening
|
|
13
|
+
export class FieldNameCollisionError extends Data.TaggedError(
|
|
14
|
+
"FieldNameCollisionError",
|
|
15
|
+
)<{
|
|
16
|
+
readonly fieldName: string
|
|
17
|
+
readonly wrapperField: string
|
|
18
|
+
}> {
|
|
19
|
+
override get message() {
|
|
20
|
+
return `Field name collision: "${this.wrapperField}" is already present as "${this.fieldName}" in its parent struct`
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Error for invalid flatten annotation usage (on non-struct fields)
|
|
25
|
+
export class InvalidFlattenAnnotationError extends Data.TaggedError(
|
|
26
|
+
"InvalidFlattenAnnotationError",
|
|
27
|
+
)<{
|
|
28
|
+
readonly fieldName: string
|
|
29
|
+
readonly astTag: string
|
|
30
|
+
}> {
|
|
31
|
+
override get message() {
|
|
32
|
+
return `Invalid schema: field "${this.fieldName}" has flatten annotation but is not a struct (AST tag: ${this.astTag}). Only use Wrapper() with Schema.Struct().`
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type UnionToIntersection<U> = (
|
|
37
|
+
U extends unknown
|
|
38
|
+
? (k: U) => void
|
|
39
|
+
: never
|
|
40
|
+
) extends (k: infer I) => void
|
|
41
|
+
? I
|
|
42
|
+
: never
|
|
43
|
+
|
|
44
|
+
type IsExcluded<Field> = Field extends StructuralOnlyMarker | ReadOnlyMarker
|
|
45
|
+
? true
|
|
46
|
+
: Field extends { readonly schema: infer Inner }
|
|
47
|
+
? IsExcluded<Inner>
|
|
48
|
+
: Field extends { readonly from: infer From }
|
|
49
|
+
? IsExcluded<From>
|
|
50
|
+
: Field extends { readonly members: ReadonlyArray<infer Member> }
|
|
51
|
+
? true extends IsExcluded<Member>
|
|
52
|
+
? true
|
|
53
|
+
: false
|
|
54
|
+
: false
|
|
55
|
+
|
|
56
|
+
type ProjectedStruct<
|
|
57
|
+
Fields extends Schema.Struct.Fields,
|
|
58
|
+
KeepReadOnly extends boolean,
|
|
59
|
+
> = Schema.Struct<
|
|
60
|
+
(
|
|
61
|
+
KeepReadOnly extends true
|
|
62
|
+
? FlattenFieldsKeepingReadOnly<Fields>
|
|
63
|
+
: FlattenFields<Fields>
|
|
64
|
+
) extends infer F extends Schema.Struct.Fields
|
|
65
|
+
? F
|
|
66
|
+
: never
|
|
67
|
+
>
|
|
68
|
+
|
|
69
|
+
// Preserve wrapper contracts while projecting their contained schemas.
|
|
70
|
+
// Detail arrays recurse like ListField; ordinary submission arrays retain their
|
|
71
|
+
// existing projection.
|
|
72
|
+
type ProjectSchema<
|
|
73
|
+
S extends Schema.Constraint,
|
|
74
|
+
KeepReadOnly extends boolean = false,
|
|
75
|
+
> =
|
|
76
|
+
S extends Schema.Struct<infer Fields>
|
|
77
|
+
? ProjectedStruct<Fields, KeepReadOnly>
|
|
78
|
+
: S extends ListFieldMarker<infer Items>
|
|
79
|
+
? Schema.$Array<ProjectedStruct<Items, KeepReadOnly>>
|
|
80
|
+
: S extends Schema.Union<infer Members>
|
|
81
|
+
? Schema.Union<{
|
|
82
|
+
[K in keyof Members]: ProjectSchema<Members[K], KeepReadOnly>
|
|
83
|
+
}>
|
|
84
|
+
: S extends Schema.optionalKey<infer Inner>
|
|
85
|
+
? Schema.optionalKey<ProjectSchema<Inner, KeepReadOnly>>
|
|
86
|
+
: S extends Schema.optional<infer Inner>
|
|
87
|
+
? Schema.optional<ProjectSchema<Inner, KeepReadOnly>>
|
|
88
|
+
: S extends Schema.decodeTo<
|
|
89
|
+
infer To,
|
|
90
|
+
infer From,
|
|
91
|
+
infer RD,
|
|
92
|
+
infer RE
|
|
93
|
+
>
|
|
94
|
+
? Schema.decodeTo<
|
|
95
|
+
ProjectSchema<To, KeepReadOnly>,
|
|
96
|
+
ProjectSchema<From, KeepReadOnly>,
|
|
97
|
+
RD,
|
|
98
|
+
RE
|
|
99
|
+
>
|
|
100
|
+
: S extends Schema.toType<infer Inner>
|
|
101
|
+
? Schema.toType<ProjectSchema<Inner, KeepReadOnly>>
|
|
102
|
+
: S extends Schema.toEncoded<infer Inner>
|
|
103
|
+
? Schema.toEncoded<ProjectSchema<Inner, KeepReadOnly>>
|
|
104
|
+
: KeepReadOnly extends true
|
|
105
|
+
? S extends Schema.$Array<infer Item>
|
|
106
|
+
? Schema.$Array<ProjectSchema<Item, KeepReadOnly>>
|
|
107
|
+
: S
|
|
108
|
+
: S
|
|
109
|
+
|
|
110
|
+
type ProjectField<Field extends Schema.Struct.Fields[string]> =
|
|
111
|
+
ProjectSchema<Field>
|
|
112
|
+
|
|
113
|
+
type WrapperFields<Field> = Field extends Schema.Struct<infer Fields> &
|
|
114
|
+
FlattenMarker
|
|
115
|
+
? FlattenFields<Fields>
|
|
116
|
+
: Field extends Schema.toEncoded<infer Inner>
|
|
117
|
+
? WrapperFields<Inner> extends infer Fields extends Schema.Struct.Fields
|
|
118
|
+
? { [K in keyof Fields]: Schema.toEncoded<Fields[K]> }
|
|
119
|
+
: never
|
|
120
|
+
: never
|
|
121
|
+
|
|
122
|
+
// Wrapper fields flatten; ordinary containers keep their keys and optionality.
|
|
123
|
+
export type FlattenFields<Fields extends Schema.Struct.Fields> =
|
|
124
|
+
UnionToIntersection<
|
|
125
|
+
{
|
|
126
|
+
[K in keyof Fields]: IsExcluded<Fields[K]> extends true
|
|
127
|
+
? never
|
|
128
|
+
: [WrapperFields<Fields[K]>] extends [never]
|
|
129
|
+
? { [P in K]: ProjectField<Fields[K]> }
|
|
130
|
+
: WrapperFields<Fields[K]>
|
|
131
|
+
}[keyof Fields]
|
|
132
|
+
>
|
|
133
|
+
|
|
134
|
+
type IsStructuralOnly<Field> = Field extends StructuralOnlyMarker
|
|
135
|
+
? true
|
|
136
|
+
: Field extends { readonly schema: infer Inner }
|
|
137
|
+
? IsStructuralOnly<Inner>
|
|
138
|
+
: Field extends { readonly from: infer From }
|
|
139
|
+
? IsStructuralOnly<From>
|
|
140
|
+
: Field extends { readonly members: ReadonlyArray<infer Member> }
|
|
141
|
+
? true extends IsStructuralOnly<Member>
|
|
142
|
+
? true
|
|
143
|
+
: false
|
|
144
|
+
: false
|
|
145
|
+
|
|
146
|
+
type WrapperFieldsKeepingReadOnly<Field> = Field extends Schema.Struct<
|
|
147
|
+
infer Fields
|
|
148
|
+
> &
|
|
149
|
+
FlattenMarker
|
|
150
|
+
? FlattenFieldsKeepingReadOnly<Fields>
|
|
151
|
+
: Field extends Schema.toEncoded<infer Inner>
|
|
152
|
+
? WrapperFieldsKeepingReadOnly<Inner> extends infer Fields extends
|
|
153
|
+
Schema.Struct.Fields
|
|
154
|
+
? { [K in keyof Fields]: Schema.toEncoded<Fields[K]> }
|
|
155
|
+
: never
|
|
156
|
+
: never
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Flatten wrapper fields like `FlattenFields`, but keep read-only fields:
|
|
160
|
+
* detail/output data is display-only content that queries still return.
|
|
161
|
+
* Structural-only elements are omitted, matching GraphQL output walking.
|
|
162
|
+
*/
|
|
163
|
+
export type FlattenFieldsKeepingReadOnly<Fields extends Schema.Struct.Fields> =
|
|
164
|
+
UnionToIntersection<
|
|
165
|
+
{
|
|
166
|
+
[K in keyof Fields]: IsStructuralOnly<Fields[K]> extends true
|
|
167
|
+
? never
|
|
168
|
+
: [WrapperFieldsKeepingReadOnly<Fields[K]>] extends [never]
|
|
169
|
+
? { [P in K]: ProjectSchema<Fields[K], true> }
|
|
170
|
+
: WrapperFieldsKeepingReadOnly<Fields[K]>
|
|
171
|
+
}[keyof Fields]
|
|
172
|
+
>
|
|
173
|
+
|
|
174
|
+
export const isStructSchema = (
|
|
175
|
+
field: Schema.Constraint,
|
|
176
|
+
): field is Schema.Struct<Schema.Struct.Fields> =>
|
|
177
|
+
field.ast._tag === "Objects" && "fields" in field
|
|
178
|
+
|
|
179
|
+
type FlattenedSubmissionStruct<Fields extends Schema.Struct.Fields> =
|
|
180
|
+
Schema.Struct<
|
|
181
|
+
FlattenFields<Fields> extends infer F extends Schema.Struct.Fields
|
|
182
|
+
? F
|
|
183
|
+
: never
|
|
184
|
+
>
|
|
185
|
+
|
|
186
|
+
export type SubmissionSchemaError =
|
|
187
|
+
| FieldNameCollisionError
|
|
188
|
+
| InvalidFlattenAnnotationError
|
|
189
|
+
|
|
190
|
+
// Checks whether a field is a flattenable Wrapper struct (errors on invalid annotation).
|
|
191
|
+
const isFlattenableStruct = (
|
|
192
|
+
field: Schema.Constraint,
|
|
193
|
+
fieldName: string,
|
|
194
|
+
): Effect.Effect<boolean, InvalidFlattenAnnotationError> =>
|
|
195
|
+
Effect.gen(function* () {
|
|
196
|
+
const hasFlatten = hasFlattenAnnotation(field)
|
|
197
|
+
const isStructAst = field.ast._tag === "Objects"
|
|
198
|
+
|
|
199
|
+
// Defensive: if has flatten annotation but isn't a struct, that's a programming error
|
|
200
|
+
if (hasFlatten && !isStructAst) {
|
|
201
|
+
return yield* new InvalidFlattenAnnotationError({
|
|
202
|
+
fieldName,
|
|
203
|
+
astTag: field.ast._tag,
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return hasFlatten && isStructAst
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
// Creates a submission schema by flattening Wrapper fields while preserving regular nested structs
|
|
211
|
+
export const submissionSchema = <Fields extends Schema.Struct.Fields>(
|
|
212
|
+
schema: Schema.Struct<Fields>,
|
|
213
|
+
): Effect.Effect<FlattenedSubmissionStruct<Fields>, SubmissionSchemaError> =>
|
|
214
|
+
Effect.gen(function* () {
|
|
215
|
+
const flatFields: Record<string, Schema.Struct.Fields[string]> = {}
|
|
216
|
+
|
|
217
|
+
for (const [key, field] of Object.entries(schema.fields)) {
|
|
218
|
+
const fieldAsAny = field as Schema.Top
|
|
219
|
+
|
|
220
|
+
if (hasStructuralOnlyAnnotation(fieldAsAny)) {
|
|
221
|
+
// Skip structural-only fields (UI-only, not in submission)
|
|
222
|
+
continue
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (isReadOnlyField(fieldAsAny)) {
|
|
226
|
+
// Skip read-only fields (display-only, not submittable)
|
|
227
|
+
continue
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (yield* isFlattenableStruct(fieldAsAny, String(key))) {
|
|
231
|
+
// This is a Wrapper - recursively flatten it first to handle nested Wrappers
|
|
232
|
+
const recursivelyFlattened = yield* submissionSchema(
|
|
233
|
+
fieldAsAny as Schema.Struct<Schema.Struct.Fields>,
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
// Spread the recursively flattened fields with collision detection
|
|
237
|
+
for (const [nestedKey, nestedValue] of Object.entries(
|
|
238
|
+
recursivelyFlattened.fields,
|
|
239
|
+
)) {
|
|
240
|
+
if (nestedKey in flatFields) {
|
|
241
|
+
return yield* new FieldNameCollisionError({
|
|
242
|
+
fieldName: nestedKey,
|
|
243
|
+
wrapperField: `${key}...${nestedKey}`,
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
flatFields[nestedKey] = nestedValue as Schema.Top
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
if (key in flatFields)
|
|
250
|
+
return yield* new FieldNameCollisionError({
|
|
251
|
+
fieldName: key,
|
|
252
|
+
wrapperField: key,
|
|
253
|
+
})
|
|
254
|
+
// Project nested containers without changing their nesting or array cardinality.
|
|
255
|
+
flatFields[key] = yield* projectField(field)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
yield* prepareExpansion(schema.ast)
|
|
260
|
+
return Schema.Struct(
|
|
261
|
+
flatFields,
|
|
262
|
+
) as unknown as FlattenedSubmissionStruct<Fields>
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
/** Rebuild signatures without losing intrinsic defaults, key mappings or codecs. */
|
|
266
|
+
const projectField = (
|
|
267
|
+
field: Schema.Struct.Fields[string],
|
|
268
|
+
): Effect.Effect<Schema.Struct.Fields[string], SubmissionSchemaError> =>
|
|
269
|
+
Effect.map(projectNested(field.ast), (ast) => Schema.make(ast))
|
|
270
|
+
|
|
271
|
+
const projectNested = (
|
|
272
|
+
ast: SchemaAST.AST,
|
|
273
|
+
): Effect.Effect<SchemaAST.AST, SubmissionSchemaError> =>
|
|
274
|
+
Effect.gen(function* () {
|
|
275
|
+
const encoding = ast.encoding
|
|
276
|
+
? yield* Effect.forEach(ast.encoding, (link) =>
|
|
277
|
+
Effect.map(
|
|
278
|
+
projectNested(link.to),
|
|
279
|
+
(to) => new SchemaAST.Link(to, link.transformation),
|
|
280
|
+
),
|
|
281
|
+
)
|
|
282
|
+
: undefined
|
|
283
|
+
if (ast._tag === "Objects") {
|
|
284
|
+
const properties: SchemaAST.PropertySignature[] = []
|
|
285
|
+
const names = new Set<PropertyKey>()
|
|
286
|
+
for (const property of ast.propertySignatures) {
|
|
287
|
+
const field = Schema.make(property.type)
|
|
288
|
+
if (hasStructuralOnlyAnnotation(field) || isReadOnlyField(field))
|
|
289
|
+
continue
|
|
290
|
+
const flatten = yield* isFlattenableStruct(field, String(property.name))
|
|
291
|
+
const projected = yield* projectNested(property.type)
|
|
292
|
+
const children =
|
|
293
|
+
flatten && projected._tag === "Objects"
|
|
294
|
+
? projected.propertySignatures
|
|
295
|
+
: [new SchemaAST.PropertySignature(property.name, projected)]
|
|
296
|
+
for (const child of children) {
|
|
297
|
+
if (names.has(child.name))
|
|
298
|
+
return yield* new FieldNameCollisionError({
|
|
299
|
+
fieldName: String(child.name),
|
|
300
|
+
wrapperField: `${String(property.name)}...${String(child.name)}`,
|
|
301
|
+
})
|
|
302
|
+
names.add(child.name)
|
|
303
|
+
properties.push(child)
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return new SchemaAST.Objects(
|
|
307
|
+
properties,
|
|
308
|
+
ast.indexSignatures,
|
|
309
|
+
ast.annotations,
|
|
310
|
+
ast.checks,
|
|
311
|
+
encoding,
|
|
312
|
+
ast.context,
|
|
313
|
+
ast.encodingChecks,
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
if (ast._tag === "Union")
|
|
317
|
+
return new SchemaAST.Union(
|
|
318
|
+
yield* Effect.forEach(ast.types, projectNested),
|
|
319
|
+
ast.options,
|
|
320
|
+
ast.annotations,
|
|
321
|
+
ast.checks,
|
|
322
|
+
encoding,
|
|
323
|
+
ast.context,
|
|
324
|
+
ast.encodingChecks,
|
|
325
|
+
)
|
|
326
|
+
if (ast._tag === "Arrays")
|
|
327
|
+
return new SchemaAST.Arrays(
|
|
328
|
+
ast.isMutable,
|
|
329
|
+
yield* Effect.forEach(ast.elements, projectNested),
|
|
330
|
+
yield* Effect.forEach(ast.rest, projectNested),
|
|
331
|
+
ast.annotations,
|
|
332
|
+
ast.checks,
|
|
333
|
+
encoding,
|
|
334
|
+
ast.context,
|
|
335
|
+
ast.encodingChecks,
|
|
336
|
+
)
|
|
337
|
+
return encoding
|
|
338
|
+
? Object.assign(Object.create(Object.getPrototypeOf(ast)), ast, {
|
|
339
|
+
encoding,
|
|
340
|
+
})
|
|
341
|
+
: ast
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Synchronous boundary for model construction and other non-Effect call sites.
|
|
346
|
+
* Rethrows the original TaggedError on failure (not a FiberFailure wrapper).
|
|
347
|
+
*/
|
|
348
|
+
export const submissionSchemaSync = <Fields extends Schema.Struct.Fields>(
|
|
349
|
+
schema: Schema.Struct<Fields>,
|
|
350
|
+
): FlattenedSubmissionStruct<Fields> => {
|
|
351
|
+
const result = Effect.runSync(Effect.result(submissionSchema(schema)))
|
|
352
|
+
if (Result.isFailure(result)) {
|
|
353
|
+
throw result.failure
|
|
354
|
+
}
|
|
355
|
+
return result.success
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export const expandSubmissionInput = <Fields extends Schema.Struct.Fields>(
|
|
359
|
+
schema: Schema.Struct<Fields>,
|
|
360
|
+
input: Record<string, unknown>,
|
|
361
|
+
): Record<string, unknown> => {
|
|
362
|
+
// Accepted schemas are prepared during construction. Direct callers prepare once.
|
|
363
|
+
const prepared =
|
|
364
|
+
expansionCache.get(schema.ast) ??
|
|
365
|
+
Effect.runSync(prepareExpansion(schema.ast))
|
|
366
|
+
return expandStructInput(prepared.ast, input, prepared.members)
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
type UnionMember = {
|
|
370
|
+
readonly ast: SchemaAST.AST
|
|
371
|
+
readonly matches: (input: unknown) => boolean
|
|
372
|
+
}
|
|
373
|
+
type UnionMembers = ReadonlyMap<SchemaAST.AST, ReadonlyArray<UnionMember>>
|
|
374
|
+
|
|
375
|
+
const expansionCache = new WeakMap<
|
|
376
|
+
SchemaAST.AST,
|
|
377
|
+
{ readonly ast: SchemaAST.AST; readonly members: UnionMembers }
|
|
378
|
+
>()
|
|
379
|
+
|
|
380
|
+
// Compile encoded union selectors at schema construction, never per submission/row.
|
|
381
|
+
const prepareExpansion = (source: SchemaAST.AST) =>
|
|
382
|
+
Effect.gen(function* () {
|
|
383
|
+
const cached = expansionCache.get(source)
|
|
384
|
+
if (cached) return cached
|
|
385
|
+
// Keep authored annotations: encodedAST drops them when rebuilding codec containers.
|
|
386
|
+
// Traversal follows .from at each codec, so expansion still operates on wire values.
|
|
387
|
+
const ast = SchemaAST.toEncoded(source)
|
|
388
|
+
const members = new Map<SchemaAST.AST, ReadonlyArray<UnionMember>>()
|
|
389
|
+
const visit = (
|
|
390
|
+
node: SchemaAST.AST,
|
|
391
|
+
): Effect.Effect<void, SubmissionSchemaError> =>
|
|
392
|
+
Effect.gen(function* () {
|
|
393
|
+
if (node._tag === "Union") {
|
|
394
|
+
members.set(
|
|
395
|
+
node,
|
|
396
|
+
yield* Effect.forEach(node.types, (member) =>
|
|
397
|
+
Effect.gen(function* () {
|
|
398
|
+
const projected = yield* projectNested(member)
|
|
399
|
+
yield* visit(member)
|
|
400
|
+
return {
|
|
401
|
+
ast: member,
|
|
402
|
+
matches: Schema.is(Schema.toEncoded(Schema.make(projected))),
|
|
403
|
+
}
|
|
404
|
+
}),
|
|
405
|
+
),
|
|
406
|
+
)
|
|
407
|
+
} else if (node._tag === "Objects") {
|
|
408
|
+
yield* Effect.forEach(node.propertySignatures, (property) => {
|
|
409
|
+
const field = Schema.make(property.type)
|
|
410
|
+
return hasStructuralOnlyAnnotation(field) || isReadOnlyField(field)
|
|
411
|
+
? Effect.void
|
|
412
|
+
: visit(property.type)
|
|
413
|
+
})
|
|
414
|
+
} else if (node._tag === "Arrays") {
|
|
415
|
+
yield* Effect.forEach([...node.elements, ...node.rest], (element) =>
|
|
416
|
+
visit(element),
|
|
417
|
+
)
|
|
418
|
+
}
|
|
419
|
+
})
|
|
420
|
+
yield* visit(ast)
|
|
421
|
+
const prepared = { ast, members }
|
|
422
|
+
expansionCache.set(source, prepared)
|
|
423
|
+
return prepared
|
|
424
|
+
})
|
|
425
|
+
|
|
426
|
+
const isInputRecord = (input: unknown): input is Record<string, unknown> =>
|
|
427
|
+
typeof input === "object" && input !== null && !Array.isArray(input)
|
|
428
|
+
|
|
429
|
+
// Expansion rearranges encoded values; it must not run business codecs or defaults.
|
|
430
|
+
const expandNestedInput = (
|
|
431
|
+
ast: SchemaAST.AST,
|
|
432
|
+
input: unknown,
|
|
433
|
+
members: UnionMembers,
|
|
434
|
+
): unknown => {
|
|
435
|
+
if (ast._tag === "Union") {
|
|
436
|
+
const member = members
|
|
437
|
+
.get(ast)
|
|
438
|
+
?.find((candidate) => candidate.matches(input))
|
|
439
|
+
return member ? expandNestedInput(member.ast, input, members) : input
|
|
440
|
+
}
|
|
441
|
+
if (ast._tag === "Objects" && isInputRecord(input))
|
|
442
|
+
return expandStructInput(ast, input, members)
|
|
443
|
+
if (ast._tag === "Arrays" && Array.isArray(input))
|
|
444
|
+
return input.map((value, index) => {
|
|
445
|
+
const element = ast.elements[index] ?? ast.rest[0]
|
|
446
|
+
return element ? expandNestedInput(element, value, members) : value
|
|
447
|
+
})
|
|
448
|
+
return input
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
const expandStructInput = (
|
|
452
|
+
ast: SchemaAST.AST,
|
|
453
|
+
input: Record<string, unknown>,
|
|
454
|
+
members: UnionMembers,
|
|
455
|
+
): Record<string, unknown> => {
|
|
456
|
+
if (ast._tag !== "Objects") return input
|
|
457
|
+
const expanded: Record<string, unknown> = {}
|
|
458
|
+
for (const property of ast.propertySignatures) {
|
|
459
|
+
if (typeof property.name !== "string") continue
|
|
460
|
+
const key = property.name
|
|
461
|
+
const field = Schema.make(property.type)
|
|
462
|
+
if (hasStructuralOnlyAnnotation(field) || isReadOnlyField(field)) continue
|
|
463
|
+
if (hasFlattenAnnotation(field)) {
|
|
464
|
+
expanded[key] = expandNestedInput(property.type, input, members)
|
|
465
|
+
continue
|
|
466
|
+
}
|
|
467
|
+
if (Object.hasOwn(input, key)) {
|
|
468
|
+
expanded[key] = expandNestedInput(property.type, input[key], members)
|
|
469
|
+
continue
|
|
470
|
+
}
|
|
471
|
+
if (!property.type.context?.isOptional && property.type._tag === "Objects")
|
|
472
|
+
expanded[key] = expandStructInput(property.type, {}, members)
|
|
473
|
+
}
|
|
474
|
+
return expanded
|
|
475
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { JsonSchema, Schema, SchemaRepresentation } from "effect"
|
|
2
|
+
|
|
3
|
+
/** Keep the v3 JSON-number contract instead of v4's non-finite string codec. */
|
|
4
|
+
const preserveJsonNumbers = (value: unknown): unknown => {
|
|
5
|
+
if (Array.isArray(value)) return value.map(preserveJsonNumbers)
|
|
6
|
+
if (value === null || typeof value !== "object") return value
|
|
7
|
+
const object = value as Record<string, unknown>
|
|
8
|
+
const assertions = object["allOf"]
|
|
9
|
+
if (
|
|
10
|
+
Array.isArray(assertions) &&
|
|
11
|
+
assertions.length === 1 &&
|
|
12
|
+
assertions[0]?.enum
|
|
13
|
+
) {
|
|
14
|
+
const { allOf: _, ...rest } = object
|
|
15
|
+
return preserveJsonNumbers({ ...rest, ...assertions[0] })
|
|
16
|
+
}
|
|
17
|
+
const alternatives = object["anyOf"]
|
|
18
|
+
if (
|
|
19
|
+
Array.isArray(alternatives) &&
|
|
20
|
+
alternatives.length === 2 &&
|
|
21
|
+
alternatives[0]?.type === "number" &&
|
|
22
|
+
alternatives[1]?.type === "string" &&
|
|
23
|
+
Array.isArray(alternatives[1].enum) &&
|
|
24
|
+
alternatives[1].enum.length === 3 &&
|
|
25
|
+
["Infinity", "-Infinity", "NaN"].every((value) =>
|
|
26
|
+
alternatives[1].enum.includes(value),
|
|
27
|
+
)
|
|
28
|
+
) {
|
|
29
|
+
const { anyOf: _, ...rest } = object
|
|
30
|
+
return { ...rest, ...alternatives[0] }
|
|
31
|
+
}
|
|
32
|
+
return Object.fromEntries(
|
|
33
|
+
Object.entries(object).map(([key, item]) => [
|
|
34
|
+
key,
|
|
35
|
+
preserveJsonNumbers(item),
|
|
36
|
+
]),
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Render the existing draft-07 form contract, including referenced definitions. */
|
|
41
|
+
export const toFormJsonSchema = (
|
|
42
|
+
schema: Schema.Constraint,
|
|
43
|
+
): JsonSchema.JsonSchema => {
|
|
44
|
+
const document = JsonSchema.toDocumentDraft07(
|
|
45
|
+
// Compile the authored encoded shape directly. Canonical JSON codecs add
|
|
46
|
+
// a Number transformation that drops its checks and annotations.
|
|
47
|
+
SchemaRepresentation.toJsonSchemaDocument(Schema.toRepresentation(schema), {
|
|
48
|
+
onExcessProperty: "error",
|
|
49
|
+
}),
|
|
50
|
+
)
|
|
51
|
+
return preserveJsonNumbers({
|
|
52
|
+
$schema: JsonSchema.META_SCHEMA_URI_DRAFT_07,
|
|
53
|
+
...document.schema,
|
|
54
|
+
...(Object.keys(document.definitions).length
|
|
55
|
+
? { definitions: document.definitions }
|
|
56
|
+
: {}),
|
|
57
|
+
}) as JsonSchema.JsonSchema
|
|
58
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Match, type Schema } from "effect"
|
|
2
|
+
import * as AST from "effect/SchemaAST"
|
|
3
|
+
import {
|
|
4
|
+
FormLookupInput,
|
|
5
|
+
fieldAnnotation,
|
|
6
|
+
hasFlattenAnnotation,
|
|
7
|
+
hasStructuralOnlyAnnotation,
|
|
8
|
+
isReadOnlyField,
|
|
9
|
+
} from "../../../form-schema/src/index.ts"
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Recursively removes readonly modifiers from all properties
|
|
13
|
+
*/
|
|
14
|
+
export type DeepWritable<T> = T extends object
|
|
15
|
+
? { -readonly [K in keyof T]: DeepWritable<T[K]> }
|
|
16
|
+
: T
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Generate type-compatible default values from Effect Schema fields.
|
|
20
|
+
*
|
|
21
|
+
* This creates empty/zero values to satisfy Tanstack Form's type requirements.
|
|
22
|
+
* Values are NOT validated - they're just type-compatible placeholders.
|
|
23
|
+
*
|
|
24
|
+
* Without this we have an uncontrolled input error.
|
|
25
|
+
*/
|
|
26
|
+
export const getSchemaDefaults = <Fields extends Schema.Struct.Fields>(
|
|
27
|
+
fields: Fields,
|
|
28
|
+
): { [K in keyof Fields]: DeepWritable<Schema.Schema.Type<Fields[K]>> } => {
|
|
29
|
+
const result: Record<string, unknown> = {}
|
|
30
|
+
|
|
31
|
+
for (const [key, fieldSchema] of Object.entries(fields)) {
|
|
32
|
+
const schema = fieldSchema as Schema.Codec<unknown, unknown, never, never>
|
|
33
|
+
// Skip structural-only fields (UI-only elements like TextBlock, Divider)
|
|
34
|
+
if (hasStructuralOnlyAnnotation(schema) || isReadOnlyField(schema)) {
|
|
35
|
+
continue
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (hasFlattenAnnotation(schema) && schema.ast._tag === "Objects") {
|
|
39
|
+
Object.assign(result, getDefaultsForObjects(schema.ast))
|
|
40
|
+
continue
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const ast = AST.toEncoded(fieldSchema.ast)
|
|
44
|
+
result[key] = getDefaultForSchema(ast, ast.context?.isOptional)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return result as {
|
|
48
|
+
[K in keyof Fields]: DeepWritable<Schema.Schema.Type<Fields[K]>>
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const getDefaultsForObjects = (
|
|
53
|
+
typeLiteral: AST.Objects,
|
|
54
|
+
): Record<string, unknown> => {
|
|
55
|
+
const result: Record<string, unknown> = {}
|
|
56
|
+
|
|
57
|
+
for (const prop of typeLiteral.propertySignatures) {
|
|
58
|
+
const key = String(prop.name)
|
|
59
|
+
const fieldSchema = prop.type as AST.AST
|
|
60
|
+
const fieldAsSchema = { ast: fieldSchema } as Schema.Top
|
|
61
|
+
|
|
62
|
+
if (
|
|
63
|
+
hasStructuralOnlyAnnotation(fieldAsSchema) ||
|
|
64
|
+
isReadOnlyField(fieldAsSchema)
|
|
65
|
+
) {
|
|
66
|
+
continue
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (fieldSchema._tag === "Objects") {
|
|
70
|
+
if (hasFlattenAnnotation(fieldAsSchema)) {
|
|
71
|
+
Object.assign(result, getDefaultsForObjects(fieldSchema))
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
result[key] = getDefaultForSchema(
|
|
77
|
+
fieldSchema,
|
|
78
|
+
prop.type.context?.isOptional,
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return result
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const unionMembers = (ast: AST.AST): readonly AST.AST[] =>
|
|
86
|
+
ast._tag === "Union" ? ast.types.flatMap(unionMembers) : [ast]
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get default value for a single schema AST node
|
|
90
|
+
*/
|
|
91
|
+
const getDefaultForSchema = (ast: AST.AST, isOptional = false): unknown => {
|
|
92
|
+
const lookup = fieldAnnotation(ast, FormLookupInput)
|
|
93
|
+
if (
|
|
94
|
+
typeof lookup === "object" &&
|
|
95
|
+
lookup !== null &&
|
|
96
|
+
"mode" in lookup &&
|
|
97
|
+
(lookup.mode === "server" || lookup.mode === "local")
|
|
98
|
+
) {
|
|
99
|
+
const members = unionMembers(AST.toEncoded(ast))
|
|
100
|
+
if (isOptional || members.some((member) => member._tag === "Undefined"))
|
|
101
|
+
return undefined
|
|
102
|
+
if (members.some((member) => member._tag === "Null")) return null
|
|
103
|
+
}
|
|
104
|
+
const match = Match.type<AST.AST>().pipe(
|
|
105
|
+
Match.tag("String", () => ""),
|
|
106
|
+
Match.tag("Number", () => 0),
|
|
107
|
+
Match.tag("Boolean", () => false),
|
|
108
|
+
Match.tag("Literal", (literal) =>
|
|
109
|
+
isOptional && typeof literal.literal === "string" ? undefined : "",
|
|
110
|
+
),
|
|
111
|
+
Match.tag("Union", (union) => {
|
|
112
|
+
const members = unionMembers(union)
|
|
113
|
+
if (
|
|
114
|
+
members.some((member) => member._tag === "Boolean") &&
|
|
115
|
+
members.every(
|
|
116
|
+
(member) => member._tag === "Boolean" || member._tag === "Undefined",
|
|
117
|
+
)
|
|
118
|
+
) {
|
|
119
|
+
return false
|
|
120
|
+
}
|
|
121
|
+
const choices = members.filter(
|
|
122
|
+
(member) => member._tag !== "Undefined" && !(member._tag === "Null"),
|
|
123
|
+
)
|
|
124
|
+
if (
|
|
125
|
+
choices.length > 0 &&
|
|
126
|
+
choices.every(
|
|
127
|
+
(member) =>
|
|
128
|
+
member._tag === "Literal" && typeof member.literal === "string",
|
|
129
|
+
)
|
|
130
|
+
) {
|
|
131
|
+
if (members.some((member) => member._tag === "Null")) {
|
|
132
|
+
return null
|
|
133
|
+
}
|
|
134
|
+
if (
|
|
135
|
+
isOptional ||
|
|
136
|
+
members.some((member) => member._tag === "Undefined")
|
|
137
|
+
) {
|
|
138
|
+
return undefined
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return ""
|
|
142
|
+
}),
|
|
143
|
+
Match.tag("Objects", (typeLiteral) => {
|
|
144
|
+
const nestedResult: Record<string, unknown> = {}
|
|
145
|
+
for (const prop of typeLiteral.propertySignatures) {
|
|
146
|
+
nestedResult[String(prop.name)] = getDefaultForSchema(
|
|
147
|
+
prop.type,
|
|
148
|
+
prop.type.context?.isOptional,
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
return nestedResult
|
|
152
|
+
}),
|
|
153
|
+
Match.tag("Arrays", () => []),
|
|
154
|
+
Match.orElse(() => ""),
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
return match(AST.toEncoded(ast))
|
|
158
|
+
}
|