@processfocus/runtime-local 0.1.0-next.2 → 0.1.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -253
- package/dist/authentication-server.mjs +52 -84
- package/dist/chunk-3wzp2sax.js +4806 -0
- package/dist/chunk-5kjvzbwr.js +512 -0
- package/dist/chunk-egeb4821.js +156 -0
- package/dist/chunk-q5v72erd.js +241 -0
- package/dist/{chunk-yhzbn4vx.js → chunk-wvbz0nmd.js} +19485 -34180
- package/dist/{chunk-352j1ayk.js → chunk-y8fnwbx0.js} +51781 -36259
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/actions.ts +12 -12
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/delegations-client.tsx +31 -21
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/page.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/client-index.tsx +1 -12
- package/dist/dashboard-source/apps/frontend/app/(protected)/connected-apps/disconnect-form.tsx +57 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/connected-apps/page.tsx +97 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/client.tsx +1 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/process-state/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/page.tsx +3 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/process-state/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/client-layout.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/default.tsx +6 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/executions-client.tsx +1637 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/layout.tsx +5 -7
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/page.tsx +4 -1589
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-page-client.tsx +1 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/layout.tsx +41 -33
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/client.tsx +11 -17
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/list-page-client.tsx +169 -18
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +21 -14
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +36 -18
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-edit-form.tsx +22 -28
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-load-error.tsx +49 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-schema-form.tsx +28 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/default.tsx +6 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/metric-control-url-state.ts +7 -16
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-deleted-callback.ts +4 -6
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-item-detail.ts +45 -142
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/client.tsx +10 -20
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/layout.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-process-dialog.tsx +72 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh-provider.tsx +65 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh.ts +162 -16
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/page.tsx +4 -9
- package/dist/dashboard-source/apps/frontend/app/(protected)/page.tsx +4 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/actions.ts +15 -18
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/page.tsx +12 -6
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/passkeys-client.tsx +7 -16
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client.tsx +26 -48
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/page.tsx +4 -7
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client-layout.tsx +28 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client.tsx +1 -3
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/start-process-form.tsx +193 -117
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/default.tsx +6 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/layout.tsx +7 -9
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/page.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/processes-client.tsx +60 -204
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/client.tsx +12 -51
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/page.tsx +27 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/page.tsx +5 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-flow.tsx +0 -5
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-form-preview-sheet.tsx +26 -19
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/page.tsx +5 -2
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-authorize.ts +85 -9
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-types.ts +12 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/explorer.tsx +66 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/layout.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-handbook.ts +41 -13
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/[invitationId]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-client.tsx +442 -365
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/new/page.tsx +8 -2
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/page.tsx +7 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations-table.tsx +61 -43
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/page.tsx +6 -67
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/providers/page.tsx +7 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/roles/page.tsx +7 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-client.tsx +111 -189
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-page.tsx +86 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/client.tsx +141 -256
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/tokens/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/page.tsx +7 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users-table.tsx +6 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/page.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/client.tsx +30 -9
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/page.tsx +3 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/client.tsx +2 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/page.tsx +3 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/complete-todo-form.tsx +47 -54
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/public-completion-correction-form.tsx +37 -54
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/todo-form-actions.tsx +1 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/correct/[...stepPath]/page.tsx +3 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/default.tsx +6 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/layout.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/lib/mobile-todo-list.ts +4 -25
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/page.tsx +4 -1315
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/to-dos-client.tsx +1282 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/callback/route.ts +81 -65
- package/dist/dashboard-source/apps/frontend/app/api/auth/delegation/route.ts +8 -2
- package/dist/dashboard-source/apps/frontend/app/api/auth/login/route.ts +0 -1
- package/dist/dashboard-source/apps/frontend/app/api/auth/logout/route.ts +10 -5
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/start/route.ts +1 -3
- package/dist/dashboard-source/apps/frontend/app/api/auth/refresh/route.ts +0 -1
- package/dist/dashboard-source/apps/frontend/app/api/auth/revalidate-google/route.ts +68 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/switch-role/route.ts +1 -3
- package/dist/dashboard-source/apps/frontend/app/api/dev/import-events/route.ts +69 -1
- package/dist/dashboard-source/apps/frontend/app/api/embed/lookup/route.ts +25 -7
- package/dist/dashboard-source/apps/frontend/app/api/embed/submit/route.ts +1 -2
- package/dist/dashboard-source/apps/frontend/app/api/public/start/[address]/route.ts +49 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/lookup/route.ts +4 -3
- package/dist/dashboard-source/apps/frontend/app/api/revalidate/route.ts +15 -4
- package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +14 -6
- package/dist/dashboard-source/apps/frontend/app/cli-auth/route.ts +2 -1
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/embed-client.tsx +31 -18
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/page.tsx +5 -1
- package/dist/dashboard-source/apps/frontend/app/login/page.tsx +4 -4
- package/dist/dashboard-source/apps/frontend/app/login/passkey-button.tsx +11 -6
- package/dist/dashboard-source/apps/frontend/app/login/passkey-help/page.tsx +67 -0
- package/dist/dashboard-source/apps/frontend/app/mcp/[[...endpoint]]/route.ts +44 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-client.tsx +44 -25
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/form/page.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/layout.tsx +32 -0
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-client.tsx +319 -0
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-content.tsx +41 -0
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/app/public.css +1 -1
- package/dist/dashboard-source/apps/frontend/app/register/passkey/register-passkey-client.tsx +17 -0
- package/dist/dashboard-source/apps/frontend/components/DashboardSection.tsx +9 -15
- package/dist/dashboard-source/apps/frontend/components/Header.tsx +14 -8
- package/dist/dashboard-source/apps/frontend/components/anonymous-page-link.tsx +57 -0
- package/dist/dashboard-source/apps/frontend/components/anonymous-start-form.tsx +24 -0
- package/dist/dashboard-source/apps/frontend/components/app-sidebar.tsx +21 -7
- package/dist/dashboard-source/apps/frontend/components/auth-provider.tsx +12 -7
- package/dist/dashboard-source/apps/frontend/components/browser-only.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/components/config-provider.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/delegation-expiry.tsx +24 -13
- package/dist/dashboard-source/apps/frontend/components/form-dialog-content.tsx +22 -2
- package/dist/dashboard-source/apps/frontend/components/journey-timeline.tsx +52 -45
- package/dist/dashboard-source/apps/frontend/components/notification-bell.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/sidebar-lists.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/token-refresh-scheduler.tsx +38 -11
- package/dist/dashboard-source/apps/frontend/components/ui/sidebar.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/ui/tab-pill.tsx +26 -15
- package/dist/dashboard-source/apps/frontend/components/workflow/step-node.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/workflow/workflow-edge.tsx +5 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-form-metadata.ts +21 -10
- package/dist/dashboard-source/apps/frontend/hooks/use-process-draft.ts +173 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-weekly-execution-stats.ts +1 -3
- package/dist/dashboard-source/apps/frontend/lib/anonymous-page-form-values.ts +6 -0
- package/dist/dashboard-source/apps/frontend/lib/anonymous-page-server.ts +65 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/adapter.ts +9 -3
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/client.ts +7 -340
- package/dist/dashboard-source/apps/frontend/lib/auth/client-session.ts +2 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/delegations.ts +9 -7
- package/dist/dashboard-source/apps/frontend/lib/auth/google-revalidation.ts +111 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/logout.ts +1 -1
- package/dist/dashboard-source/apps/frontend/lib/auth/passkeys.ts +28 -30
- package/dist/dashboard-source/apps/frontend/lib/auth/providers.ts +10 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/realtime-session-token.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/reauthentication-state.ts +4 -4
- package/dist/dashboard-source/apps/frontend/lib/auth/session-admission.ts +11 -7
- package/dist/dashboard-source/apps/frontend/lib/auth/session.ts +27 -10
- package/dist/dashboard-source/apps/frontend/lib/auth/ssr-session.ts +76 -9
- package/dist/dashboard-source/apps/frontend/lib/auth/verify-passkey.ts +25 -3
- package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +115 -23
- package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution.ts +1 -8
- package/dist/dashboard-source/apps/frontend/lib/collections/execution.ts +6 -2
- package/dist/dashboard-source/apps/frontend/lib/collections/graphql-stream.ts +21 -1
- package/dist/dashboard-source/apps/frontend/lib/collections/process-collection-provider.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/process.ts +8 -2
- package/dist/dashboard-source/apps/frontend/lib/collections/replication-factory.ts +16 -4
- package/dist/dashboard-source/apps/frontend/lib/collections/todo.ts +1 -1
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-query-invalidation.tsx +66 -9
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-refresh.ts +10 -6
- package/dist/dashboard-source/apps/frontend/lib/effect/navigation.ts +4 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/page-runtime.ts +29 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/params.ts +18 -12
- package/dist/dashboard-source/apps/frontend/lib/effect/run-effect.ts +1 -1
- package/dist/dashboard-source/apps/frontend/lib/effect/runtime.ts +19 -23
- package/dist/dashboard-source/apps/frontend/lib/effect/services/access-token.ts +9 -12
- package/dist/dashboard-source/apps/frontend/lib/effect/services/authorization.ts +12 -12
- package/dist/dashboard-source/apps/frontend/lib/effect/services/form-validation.ts +20 -18
- package/dist/dashboard-source/apps/frontend/lib/effect/services/graphql.ts +32 -16
- package/dist/dashboard-source/apps/frontend/lib/embed-form-server.ts +35 -0
- package/dist/dashboard-source/apps/frontend/lib/embed-manifest.ts +10 -103
- package/dist/dashboard-source/apps/frontend/lib/forms/invitation.ts +43 -0
- package/dist/dashboard-source/apps/frontend/lib/forms/provider-user.ts +64 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-form-loaders.ts +40 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-manifest.ts +1 -33
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +123 -33
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +168 -30
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/index.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/anonymous-page.ts +27 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/dependent-lookup-query.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/list-queries.ts +34 -29
- package/dist/dashboard-source/apps/frontend/lib/graphql/lookup-provider.tsx +82 -10
- package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-operations.ts +2 -5
- package/dist/dashboard-source/apps/frontend/lib/graphql/queries.ts +25 -4
- package/dist/dashboard-source/apps/frontend/lib/graphql/server-client.ts +11 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/settings-queries.ts +13 -104
- package/dist/dashboard-source/apps/frontend/lib/graphql/user-queries.ts +11 -4
- package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-operations.ts +1 -3
- package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-queries.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/list-detail-selection.ts +54 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/executions.ts +110 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/list-writes.ts +395 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/lists.ts +263 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/oauth.ts +889 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/origin.ts +50 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/processes.ts +436 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/read-tool.ts +72 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/result.ts +4 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/server.ts +71 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/store.ts +107 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/todos.ts +260 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/notification-preference.ts +0 -1
- package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notification-observer.ts +0 -5
- package/dist/dashboard-source/apps/frontend/lib/org-chart-data.ts +0 -2
- package/dist/dashboard-source/apps/frontend/lib/org-identity.ts +6 -4
- package/dist/dashboard-source/apps/frontend/lib/organisation-form-loaders.ts +4 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-form-runtime.ts +0 -1
- package/dist/dashboard-source/apps/frontend/lib/public-todo-model.ts +39 -139
- package/dist/dashboard-source/apps/frontend/lib/public-todo-server.ts +17 -16
- package/dist/dashboard-source/apps/frontend/lib/query-client.ts +0 -1
- package/dist/dashboard-source/apps/frontend/lib/todo-utils.ts +1 -77
- package/dist/dashboard-source/apps/frontend/lib/workflow/layout.ts +3 -7
- package/dist/dashboard-source/apps/frontend/next.config.ts +33 -13
- package/dist/dashboard-source/apps/frontend/package.json +47 -47
- package/dist/dashboard-source/apps/frontend/proxy.ts +72 -14
- package/dist/dashboard-source/modules/auth-local-cedar/src/index.ts +0 -3
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/auth-local-cedar.ts +165 -233
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/cedar-reload-notifier.ts +4 -3
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/config-base.ts +111 -75
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/policy-watcher.ts +14 -18
- package/dist/dashboard-source/modules/auth-policy/src/index.ts +1 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/auth-policy.ts +19 -37
- package/dist/dashboard-source/modules/auth-policy/src/lib/current-principal.ts +33 -29
- package/dist/dashboard-source/modules/auth-policy/src/lib/policy-revision.ts +23 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/types.ts +24 -49
- package/dist/dashboard-source/modules/auth-session/src/index.ts +4 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/project-subscription.ts +13 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/realtime-recipient.ts +10 -2
- package/dist/dashboard-source/modules/auth-session/src/lib/subjects.ts +82 -8
- package/dist/dashboard-source/modules/auth-session/src/lib/workload-access.ts +48 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/workload-audit.ts +52 -0
- package/dist/dashboard-source/modules/aws-common/src/index.ts +0 -1
- package/dist/dashboard-source/modules/effect-json-logger/src/lib/effect-json-logger.ts +6 -9
- package/dist/dashboard-source/modules/form/src/hooks/use-local-storage.ts +5 -3
- package/dist/dashboard-source/modules/form/src/index.ts +1 -10
- package/dist/dashboard-source/modules/form/src/lib/effect-schema-form.tsx +1271 -0
- package/dist/dashboard-source/modules/form/src/lib/form-actions.ts +26 -0
- package/dist/dashboard-source/modules/form/src/lib/form-prefill.tsx +79 -0
- package/dist/dashboard-source/modules/form/src/lib/initial-focus.ts +31 -0
- package/dist/dashboard-source/modules/form/src/lib/lookup-context.tsx +18 -0
- package/dist/dashboard-source/modules/form/src/lib/plugin-registry.ts +4 -0
- package/dist/dashboard-source/modules/form/src/lib/plugin-scripts.ts +26 -0
- package/dist/dashboard-source/modules/form/src/lib/registered-plugin-field.tsx +57 -0
- package/dist/dashboard-source/modules/form/src/lib/schema-lookup.tsx +124 -0
- package/dist/dashboard-source/modules/form/src/lib/schema-typeahead.tsx +522 -0
- package/dist/dashboard-source/modules/form/src/lib/validation-logic.ts +172 -0
- package/dist/dashboard-source/modules/form-schema/src/index.ts +4 -1
- package/dist/dashboard-source/modules/form-schema/src/lib/annotation-helpers.ts +19 -14
- package/dist/dashboard-source/modules/form-schema/src/lib/email.ts +13 -11
- package/dist/dashboard-source/modules/form-schema/src/lib/field-count.ts +15 -13
- package/dist/dashboard-source/modules/form-schema/src/lib/form-annotations.ts +14 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/form-presentation.ts +33 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/form-schema.ts +186 -80
- package/dist/dashboard-source/modules/form-schema/src/lib/number-from-string.ts +26 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/phone.ts +8 -7
- package/dist/dashboard-source/modules/form-schema/src/lib/public-completion-correction.ts +7 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/search-lookup-items.ts +27 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/index.ts +5 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/executable-rules.ts +379 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/form-submission-schema.ts +475 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/json-schema.ts +58 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/schema-defaults.ts +158 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/submission-utils.ts +75 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/lib/browser-plugin-artifact.ts +46 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/lib/frontend-manifest.ts +37 -30
- package/dist/dashboard-source/modules/frontend-plugin-host/src/lib/frontend-plugin-host.ts +9 -1
- package/dist/dashboard-source/modules/openauth/src/client.ts +25 -17
- package/dist/dashboard-source/modules/openauth/src/util.ts +16 -0
- package/dist/dashboard-source/modules/{aws-common/src/lib/project-balance-admission.ts → project-accounting/src/admission.ts} +4 -8
- package/dist/dashboard-source/modules/realtime-client/src/appsync-client.ts +377 -0
- package/dist/dashboard-source/modules/realtime-client/src/index.ts +5 -0
- package/dist/dashboard-source/modules/realtime-client/src/subscription-presence.ts +163 -0
- package/dist/dashboard-source/modules/request-time/src/lib/request-time.ts +6 -24
- package/dist/dashboard-source/modules/rxdb-collections/generated/execution-schema.json +28 -21
- package/dist/dashboard-source/modules/rxdb-collections/src/lib/rxdb-collections.ts +25 -18
- package/dist/dashboard-source/modules/rxdb-collections/src/lib/to-rxdb-schema.ts +60 -10
- package/dist/dashboard-source/modules/shadcn-components/src/index.ts +18 -2
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-calendar.tsx +93 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-field.tsx +147 -48
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-time-display.tsx +273 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/local-date-time-input.tsx +108 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/lookup-field.tsx +237 -351
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/popover.tsx +2 -1
- package/dist/dashboard-source.json +47 -47
- package/dist/graphql-server.mjs +272 -200
- package/dist/job-worker-supervisor.mjs +262 -0
- package/dist/job-worker.mjs +234 -133
- package/dist/main.mjs +30 -6
- package/dist/prepare-dashboard.mjs +8 -8
- package/dist/resources/cedar/policies.cedar +80 -38
- package/dist/resources/cedar/schema.cedarschema +39 -21
- package/dist/resources/graphql-schema/rxdb.graphql +2 -0
- package/dist/resources/graphql-schema/system.graphql +191 -51
- package/package.json +63 -62
- package/dist/chunk-6ntmymmx.js +0 -85
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.ts +0 -20
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-form-actions.tsx +0 -105
- package/dist/dashboard-source/apps/frontend/hooks/use-draft-process-save.ts +0 -189
- package/dist/dashboard-source/apps/frontend/hooks/use-draft-state.ts +0 -79
- package/dist/dashboard-source/apps/frontend/hooks/use-processes-query.ts +0 -56
- package/dist/dashboard-source/modules/form/src/lib/ajv-standard-schema.ts +0 -152
- package/dist/dashboard-source/modules/form/src/lib/client-components-to-form.tsx +0 -1421
- package/dist/dashboard-source/modules/form/src/lib/friendly-validation-message.ts +0 -85
- package/dist/dashboard-source/modules/form/src/lib/walker.tsx +0 -1549
- package/dist/dashboard-source/modules/form-client-representation/src/lib/client-form-definition.ts +0 -440
- package/dist/dashboard-source/modules/form-client-representation/src/lib/plugin-registry.ts +0 -13
- package/dist/dashboard-source/modules/form-client-representation/src/lib/types.ts +0 -336
- package/dist/dashboard-source/modules/form-rule/src/index.ts +0 -21
- package/dist/dashboard-source/modules/form-rule/src/lib/evaluator.ts +0 -531
- package/dist/dashboard-source/modules/form-rule/src/lib/paths.ts +0 -102
- package/dist/dashboard-source/modules/form-rule/src/lib/types.ts +0 -121
- package/dist/dashboard-source/modules/form-schema/src/lib/property-signature.ts +0 -45
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { Schema as ES } from "effect"
|
|
2
2
|
|
|
3
|
+
// Preserve named date definitions used by the existing RxDB schema exporter.
|
|
4
|
+
const DateTimeUtcFromString = ES.DateTimeUtcFromString.annotate({
|
|
5
|
+
identifier: "DateTimeUtc",
|
|
6
|
+
})
|
|
7
|
+
|
|
3
8
|
/**
|
|
4
9
|
* Base schema that all RxDB documents must implement.
|
|
5
10
|
* Provides the required fields for RxDB replication protocol.
|
|
6
11
|
*/
|
|
7
12
|
export const RxDbDocumentSchema = ES.Struct({
|
|
8
|
-
id: ES.String.
|
|
13
|
+
id: ES.String.check(ES.isMaxLength(41)), // RxDB requires maxLength on primary key
|
|
9
14
|
updatedAt: ES.Number, // Unix timestamp in milliseconds
|
|
10
15
|
// Soft deletes are handled internally by RxDb and should not be part of our schema
|
|
11
16
|
// deleted: ES.Boolean,
|
|
@@ -29,10 +34,10 @@ export const DraftProcessExecutionSchema = ES.Struct({
|
|
|
29
34
|
processId: ES.String,
|
|
30
35
|
name: ES.String,
|
|
31
36
|
startStepPath: ES.String, // Path to the start step
|
|
32
|
-
state: ES.Record(
|
|
37
|
+
state: ES.Record(ES.String, ES.Unknown), // Record<string, unknown>
|
|
33
38
|
fieldsCompleted: ES.Int,
|
|
34
39
|
totalFields: ES.Int,
|
|
35
|
-
lastSaved:
|
|
40
|
+
lastSaved: DateTimeUtcFromString, // ISO date-time string
|
|
36
41
|
})
|
|
37
42
|
|
|
38
43
|
/**
|
|
@@ -65,7 +70,7 @@ export const TodoSummaryItemSchema = ES.Struct({
|
|
|
65
70
|
/**
|
|
66
71
|
* Task priority levels for todos.
|
|
67
72
|
*/
|
|
68
|
-
export const TaskPrioritySchema = ES.
|
|
73
|
+
export const TaskPrioritySchema = ES.Literals(["High", "Medium", "Low"])
|
|
69
74
|
export type TaskPriority = typeof TaskPrioritySchema.Type
|
|
70
75
|
|
|
71
76
|
/**
|
|
@@ -86,12 +91,12 @@ export const TodoSchema = ES.Struct({
|
|
|
86
91
|
description: ES.String,
|
|
87
92
|
|
|
88
93
|
// Status and priority
|
|
89
|
-
status: ES.
|
|
94
|
+
status: ES.Literals(["Active", "Completed", "Correction Required"]),
|
|
90
95
|
priority: TaskPrioritySchema,
|
|
91
96
|
|
|
92
97
|
// Timestamps (frontend computes display strings)
|
|
93
|
-
assignedAt:
|
|
94
|
-
dueAt: ES.optional(
|
|
98
|
+
assignedAt: DateTimeUtcFromString,
|
|
99
|
+
dueAt: ES.optional(DateTimeUtcFromString),
|
|
95
100
|
|
|
96
101
|
// Form metadata
|
|
97
102
|
formComplexity: ES.String, // Simple, Medium, Complex
|
|
@@ -123,17 +128,19 @@ export const RoleSchema = ES.Struct({
|
|
|
123
128
|
* - Future (somewhat hypothetical as we cannot predict all paths for complex processes).
|
|
124
129
|
*/
|
|
125
130
|
export const ExecutionStepSchema = ES.Struct({
|
|
131
|
+
deadlineActivity: ES.optional(ES.String),
|
|
126
132
|
id: ES.String,
|
|
127
133
|
name: ES.String,
|
|
128
134
|
path: ES.String,
|
|
129
|
-
status: ES.
|
|
135
|
+
status: ES.Literals([
|
|
130
136
|
"Completed",
|
|
131
137
|
"Waiting",
|
|
132
138
|
"Potential",
|
|
133
139
|
"Failed",
|
|
134
140
|
"Correction Required",
|
|
135
141
|
"Not started",
|
|
136
|
-
|
|
142
|
+
"Interrupted",
|
|
143
|
+
]),
|
|
137
144
|
failureReason: ES.optional(ES.String),
|
|
138
145
|
notStartedReason: ES.optional(ES.String),
|
|
139
146
|
role: ES.optional(RoleSchema),
|
|
@@ -141,8 +148,8 @@ export const ExecutionStepSchema = ES.Struct({
|
|
|
141
148
|
externalSubmitterEmail: ES.optional(ES.String),
|
|
142
149
|
assignedProviderUserEmail: ES.optional(ES.String),
|
|
143
150
|
providerUser: ES.optional(ProviderUserSchema),
|
|
144
|
-
startedAt: ES.optional(
|
|
145
|
-
completedAt: ES.optional(
|
|
151
|
+
startedAt: ES.optional(DateTimeUtcFromString), // ISO date-time string (todo created_at)
|
|
152
|
+
completedAt: ES.optional(DateTimeUtcFromString), // ISO date-time string (todo updated_at when completed)
|
|
146
153
|
})
|
|
147
154
|
|
|
148
155
|
/**
|
|
@@ -157,25 +164,25 @@ export const ExecutionSchema = ES.Struct({
|
|
|
157
164
|
processPath: ES.String,
|
|
158
165
|
canAbandonExecution: ES.optional(ES.Boolean),
|
|
159
166
|
canRestartExecution: ES.optional(ES.Boolean),
|
|
160
|
-
status: ES.
|
|
167
|
+
status: ES.Literals([
|
|
161
168
|
"Running",
|
|
162
169
|
"Completed",
|
|
163
170
|
"Failed",
|
|
164
171
|
"Abandoned",
|
|
165
172
|
"Not started",
|
|
166
|
-
),
|
|
173
|
+
]),
|
|
167
174
|
failureReason: ES.optional(ES.String),
|
|
168
175
|
abandonedReason: ES.optional(ES.String),
|
|
169
176
|
notStartedReason: ES.optional(ES.String),
|
|
170
|
-
startedAt:
|
|
171
|
-
finishedAt: ES.optional(
|
|
177
|
+
startedAt: DateTimeUtcFromString, // ISO date-time string
|
|
178
|
+
finishedAt: ES.optional(DateTimeUtcFromString), // ISO date-time string
|
|
172
179
|
durationMs: ES.optional(ES.Number),
|
|
173
180
|
steps: ES.Array(ExecutionStepSchema),
|
|
174
181
|
completedSteps: ES.Int, // Count of completed todos
|
|
175
182
|
totalSteps: ES.Int, // Count of total flows in process
|
|
176
|
-
estimatedCompletionAt: ES.optional(
|
|
177
|
-
slaWarningAt: ES.optional(
|
|
178
|
-
slaTargetAt: ES.optional(
|
|
183
|
+
estimatedCompletionAt: ES.optional(DateTimeUtcFromString), // Calculated from typical duration midpoint
|
|
184
|
+
slaWarningAt: ES.optional(DateTimeUtcFromString), // Calculated from process SLA warning threshold
|
|
185
|
+
slaTargetAt: ES.optional(DateTimeUtcFromString), // Calculated from process SLA settings
|
|
179
186
|
})
|
|
180
187
|
|
|
181
188
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { JsonSchema7, JsonSchema7Object } from "effect/JSONSchema"
|
|
1
|
+
import { Schema as ES } from "effect"
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Converts Effect Schema JSON output to RxDB-compatible format.
|
|
@@ -13,9 +12,9 @@ import type { JsonSchema7, JsonSchema7Object } from "effect/JSONSchema"
|
|
|
13
12
|
* so we need to transform the output for RxDB compatibility.
|
|
14
13
|
*/
|
|
15
14
|
|
|
16
|
-
type GeneratedJsonSchema =
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
type GeneratedJsonSchema = {
|
|
16
|
+
properties: Record<string, unknown>
|
|
17
|
+
required?: readonly string[]
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
/**
|
|
@@ -46,7 +45,17 @@ export const toRxDbProperties = (
|
|
|
46
45
|
continue
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
let prop = value as Record<string, unknown>
|
|
49
|
+
// v4 emits optional codecs as a nullable union. Top-level definitions
|
|
50
|
+
// were inlined before making optional properties nullable in v3.
|
|
51
|
+
if (
|
|
52
|
+
Array.isArray(prop["anyOf"]) &&
|
|
53
|
+
prop["anyOf"].length === 2 &&
|
|
54
|
+
prop["anyOf"][1]?.type === "null" &&
|
|
55
|
+
prop["anyOf"][0]?.$ref
|
|
56
|
+
) {
|
|
57
|
+
prop = prop["anyOf"][0]
|
|
58
|
+
}
|
|
50
59
|
|
|
51
60
|
// Handle $ref by inlining the definition
|
|
52
61
|
if ("$ref" in prop && typeof prop["$ref"] === "string") {
|
|
@@ -75,13 +84,50 @@ export const toRxDbProperties = (
|
|
|
75
84
|
export const toRxDbProperty = (
|
|
76
85
|
prop: Record<string, unknown>,
|
|
77
86
|
): Record<string, unknown> => {
|
|
87
|
+
// v4's JSON codec also encodes non-finite numbers as strings. Replication
|
|
88
|
+
// retains its existing JSON-number contract.
|
|
89
|
+
if (
|
|
90
|
+
Array.isArray(prop["anyOf"]) &&
|
|
91
|
+
(prop["anyOf"].length === 2 ||
|
|
92
|
+
(prop["anyOf"].length === 3 && prop["anyOf"][2]?.type === "null"))
|
|
93
|
+
) {
|
|
94
|
+
const [number, special] = prop["anyOf"]
|
|
95
|
+
if (
|
|
96
|
+
number?.type === "number" &&
|
|
97
|
+
special?.type === "string" &&
|
|
98
|
+
JSON.stringify(special.enum) ===
|
|
99
|
+
JSON.stringify(["Infinity", "-Infinity", "NaN"])
|
|
100
|
+
) {
|
|
101
|
+
return prop["anyOf"].length === 3
|
|
102
|
+
? makeNullable({ type: "number" })
|
|
103
|
+
: { type: "number" }
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (Array.isArray(prop["anyOf"]) && prop["anyOf"].length === 2) {
|
|
107
|
+
const branches = prop["anyOf"].map(toRxDbProperty)
|
|
108
|
+
const value = branches.find((branch) => branch["type"] !== "null")
|
|
109
|
+
if (branches.some((branch) => branch["type"] === "null") && value) {
|
|
110
|
+
return makeNullable(value)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (prop["type"] === "object" && !prop["properties"]) {
|
|
114
|
+
return { type: "object", properties: {}, required: [] }
|
|
115
|
+
}
|
|
116
|
+
|
|
78
117
|
// Handle Effect Schema's "unknown" type - use object type for JSON values
|
|
79
118
|
if (prop["$id"] === "/schemas/unknown") {
|
|
80
119
|
return { type: "object" }
|
|
81
120
|
}
|
|
82
121
|
|
|
83
122
|
// Remove Effect Schema metadata that RxDB doesn't accept
|
|
84
|
-
const { $id, $ref, title, description, additionalProperties, ...
|
|
123
|
+
const { $id, $ref, title, description, additionalProperties, ...rest } = prop
|
|
124
|
+
const clean: Record<string, unknown> = { ...rest }
|
|
125
|
+
|
|
126
|
+
// Effect 4.0.4+ encodes the safe-integer range on plain `Schema.Int`. Those
|
|
127
|
+
// bounds carry no information for our counters, and adding them would change
|
|
128
|
+
// the schema hash of existing local collections without a version bump.
|
|
129
|
+
if (clean["minimum"] === Number.MIN_SAFE_INTEGER) delete clean["minimum"]
|
|
130
|
+
if (clean["maximum"] === Number.MAX_SAFE_INTEGER) delete clean["maximum"]
|
|
85
131
|
|
|
86
132
|
// Recursively process nested objects
|
|
87
133
|
if (
|
|
@@ -143,8 +189,12 @@ export const toRxDbJsonSchema = <Fields extends ES.Struct.Fields>(
|
|
|
143
189
|
required: readonly string[]
|
|
144
190
|
} => {
|
|
145
191
|
// We have a struct, so we always have a JsonSchema7Object basically
|
|
146
|
-
const
|
|
147
|
-
const
|
|
192
|
+
const document = ES.toJsonSchemaDocument(schema)
|
|
193
|
+
const generated = document.schema as GeneratedJsonSchema
|
|
194
|
+
const allProperties = toRxDbProperties(
|
|
195
|
+
generated.properties,
|
|
196
|
+
document.definitions,
|
|
197
|
+
)
|
|
148
198
|
const requiredSet = new Set(generated.required)
|
|
149
199
|
|
|
150
200
|
// Make optional fields nullable (they're not in required array)
|
|
@@ -161,6 +211,6 @@ export const toRxDbJsonSchema = <Fields extends ES.Struct.Fields>(
|
|
|
161
211
|
|
|
162
212
|
return {
|
|
163
213
|
properties: propertiesWithNullable,
|
|
164
|
-
required: generated.required,
|
|
214
|
+
required: generated.required ?? [],
|
|
165
215
|
}
|
|
166
216
|
}
|
|
@@ -7,7 +7,17 @@ export {
|
|
|
7
7
|
type CalendarSlotFieldItem,
|
|
8
8
|
type CalendarSlotFieldProps,
|
|
9
9
|
} from "./lib/calendar-slot-field.tsx"
|
|
10
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
DateField,
|
|
12
|
+
normalizeDateFieldValue,
|
|
13
|
+
validateDateField,
|
|
14
|
+
} from "./lib/date-field.tsx"
|
|
15
|
+
export {
|
|
16
|
+
DateTimeDisplay,
|
|
17
|
+
type DateTimeDisplayMode,
|
|
18
|
+
type DateTimeDisplayProps,
|
|
19
|
+
DateTimeDisplayProvider,
|
|
20
|
+
} from "./lib/date-time-display.tsx"
|
|
11
21
|
export { FieldSetField } from "./lib/field-set.tsx"
|
|
12
22
|
export { FileField } from "./lib/file-field.tsx"
|
|
13
23
|
export {
|
|
@@ -24,6 +34,7 @@ export {
|
|
|
24
34
|
useFieldContext,
|
|
25
35
|
useFormContext,
|
|
26
36
|
} from "./lib/form-context.tsx"
|
|
37
|
+
export { LocalDateTimeInput } from "./lib/local-date-time-input.tsx"
|
|
27
38
|
export { LookupField, type LookupFieldItem } from "./lib/lookup-field.tsx"
|
|
28
39
|
export { RadioField, type RadioFieldOption } from "./lib/radio-field.tsx"
|
|
29
40
|
export { SelectField } from "./lib/select-field.tsx"
|
|
@@ -54,7 +65,12 @@ export {
|
|
|
54
65
|
} from "./lib/ui/field.tsx"
|
|
55
66
|
export { Input } from "./lib/ui/input.tsx"
|
|
56
67
|
export { Label } from "./lib/ui/label.tsx"
|
|
57
|
-
export {
|
|
68
|
+
export {
|
|
69
|
+
Popover,
|
|
70
|
+
PopoverAnchor,
|
|
71
|
+
PopoverContent,
|
|
72
|
+
PopoverTrigger,
|
|
73
|
+
} from "./lib/ui/popover.tsx"
|
|
58
74
|
export { Separator } from "./lib/ui/separator.tsx"
|
|
59
75
|
// Utilities
|
|
60
76
|
export { cn } from "./lib/utils/utils.ts"
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { UTCDate } from "@date-fns/utc"
|
|
2
|
+
import { DayPicker, type OnSelectHandler } from "react-day-picker"
|
|
3
|
+
|
|
4
|
+
const utcCalendar = {
|
|
5
|
+
newDate: (year: number, month: number, day: number): Date =>
|
|
6
|
+
new UTCDate(year, month, day),
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const calendarDate = (
|
|
10
|
+
year: number,
|
|
11
|
+
month: number,
|
|
12
|
+
day: number,
|
|
13
|
+
): Date | undefined => {
|
|
14
|
+
const date = new UTCDate(0)
|
|
15
|
+
date.setUTCFullYear(year, month - 1, day)
|
|
16
|
+
date.setUTCHours(0, 0, 0, 0)
|
|
17
|
+
return year >= 1 &&
|
|
18
|
+
year <= 9999 &&
|
|
19
|
+
date.getUTCFullYear() === year &&
|
|
20
|
+
date.getUTCMonth() === month - 1 &&
|
|
21
|
+
date.getUTCDate() === day
|
|
22
|
+
? date
|
|
23
|
+
: undefined
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const formatCalendarDay = (date: Date): string => {
|
|
27
|
+
const year = String(date.getUTCFullYear()).padStart(4, "0")
|
|
28
|
+
const month = String(date.getUTCMonth() + 1).padStart(2, "0")
|
|
29
|
+
const day = String(date.getUTCDate()).padStart(2, "0")
|
|
30
|
+
return `${year}-${month}-${day}`
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const parseCalendarDay = (value: string): Date | undefined => {
|
|
34
|
+
const iso = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value)
|
|
35
|
+
return iso
|
|
36
|
+
? calendarDate(Number(iso[1]), Number(iso[2]), Number(iso[3]))
|
|
37
|
+
: undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function DateCalendar({
|
|
41
|
+
selected,
|
|
42
|
+
month,
|
|
43
|
+
defaultMonth,
|
|
44
|
+
onMonthChange,
|
|
45
|
+
onSelect,
|
|
46
|
+
}: {
|
|
47
|
+
selected: Date | undefined
|
|
48
|
+
month?: Date | undefined
|
|
49
|
+
defaultMonth?: Date | undefined
|
|
50
|
+
onMonthChange?: (month: Date) => void
|
|
51
|
+
onSelect: OnSelectHandler<Date | undefined>
|
|
52
|
+
}) {
|
|
53
|
+
const now = new Date()
|
|
54
|
+
// Highlight the user's local "today", while doing calendar arithmetic in UTC.
|
|
55
|
+
const today = calendarDate(
|
|
56
|
+
now.getFullYear(),
|
|
57
|
+
now.getMonth() + 1,
|
|
58
|
+
now.getDate(),
|
|
59
|
+
)
|
|
60
|
+
return (
|
|
61
|
+
<DayPicker
|
|
62
|
+
mode="single"
|
|
63
|
+
dateLib={utcCalendar}
|
|
64
|
+
{...(today ? { today } : {})}
|
|
65
|
+
{...(month ? { month } : {})}
|
|
66
|
+
{...(defaultMonth ? { defaultMonth } : {})}
|
|
67
|
+
selected={selected}
|
|
68
|
+
{...(onMonthChange ? { onMonthChange } : {})}
|
|
69
|
+
onSelect={onSelect}
|
|
70
|
+
classNames={{
|
|
71
|
+
root: "text-sm",
|
|
72
|
+
months: "flex flex-col gap-4",
|
|
73
|
+
month: "space-y-3",
|
|
74
|
+
caption_label: "font-medium",
|
|
75
|
+
nav: "flex items-center gap-1",
|
|
76
|
+
chevron: "fill-current",
|
|
77
|
+
button_previous:
|
|
78
|
+
"rounded-md p-2 hover:bg-accent hover:text-accent-foreground",
|
|
79
|
+
button_next:
|
|
80
|
+
"rounded-md p-2 hover:bg-accent hover:text-accent-foreground",
|
|
81
|
+
weekdays: "grid grid-cols-7 text-muted-foreground",
|
|
82
|
+
weekday: "py-1 text-center text-xs font-medium",
|
|
83
|
+
week: "grid grid-cols-7",
|
|
84
|
+
day: "p-0 text-center",
|
|
85
|
+
day_button:
|
|
86
|
+
"size-9 rounded-md hover:bg-accent hover:text-accent-foreground disabled:opacity-50",
|
|
87
|
+
selected: "[&_button]:bg-primary [&_button]:text-primary-foreground",
|
|
88
|
+
today: "[&_button]:border [&_button]:border-primary",
|
|
89
|
+
outside: "text-muted-foreground opacity-50",
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { StandardSchemaV1Issue } from "@tanstack/react-form"
|
|
2
2
|
import { CalendarIcon } from "lucide-react"
|
|
3
|
-
import { useState } from "react"
|
|
4
|
-
import {
|
|
3
|
+
import { useRef, useState } from "react"
|
|
4
|
+
import {
|
|
5
|
+
DateCalendar,
|
|
6
|
+
calendarDate,
|
|
7
|
+
formatCalendarDay,
|
|
8
|
+
parseCalendarDay,
|
|
9
|
+
} from "./date-calendar.tsx"
|
|
5
10
|
import { useFieldContext, useFormContext } from "./form-context.tsx"
|
|
6
11
|
import { Button } from "./ui/button.tsx"
|
|
7
12
|
import { Field, FieldDescription, FieldError, FieldLabel } from "./ui/field.tsx"
|
|
13
|
+
import { Input } from "./ui/input.tsx"
|
|
8
14
|
import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover.tsx"
|
|
9
|
-
import { cn } from "./utils/utils.ts"
|
|
10
15
|
|
|
11
16
|
const dateFormatter = new Intl.DateTimeFormat("en-NZ", {
|
|
12
17
|
day: "numeric",
|
|
@@ -15,20 +20,78 @@ const dateFormatter = new Intl.DateTimeFormat("en-NZ", {
|
|
|
15
20
|
timeZone: "UTC",
|
|
16
21
|
})
|
|
17
22
|
|
|
23
|
+
export const formatDateInputDay = (date: Date): string =>
|
|
24
|
+
dateFormatter.format(date)
|
|
25
|
+
|
|
26
|
+
const months = [
|
|
27
|
+
"jan",
|
|
28
|
+
"feb",
|
|
29
|
+
"mar",
|
|
30
|
+
"apr",
|
|
31
|
+
"may",
|
|
32
|
+
"jun",
|
|
33
|
+
"jul",
|
|
34
|
+
"aug",
|
|
35
|
+
"sep",
|
|
36
|
+
"oct",
|
|
37
|
+
"nov",
|
|
38
|
+
"dec",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
const parseInputDate = (value: string): Date | undefined => {
|
|
42
|
+
const text = value.trim()
|
|
43
|
+
const numeric = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(text)
|
|
44
|
+
if (numeric) {
|
|
45
|
+
return calendarDate(
|
|
46
|
+
Number(numeric[3]),
|
|
47
|
+
Number(numeric[2]),
|
|
48
|
+
Number(numeric[1]),
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
const named = /^(\d{1,2})\s+([a-z]{3}|sept)\s+(\d{4})$/i.exec(text)
|
|
52
|
+
if (named) {
|
|
53
|
+
const month = (named[2] ?? "").toLowerCase()
|
|
54
|
+
return calendarDate(
|
|
55
|
+
Number(named[3]),
|
|
56
|
+
months.indexOf(month === "sept" ? "sep" : month) + 1,
|
|
57
|
+
Number(named[1]),
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
return parseCalendarDay(text)
|
|
61
|
+
}
|
|
62
|
+
|
|
18
63
|
const parseFieldDate = (value: unknown): Date | undefined => {
|
|
19
64
|
if (typeof value !== "string" || value.length === 0) return undefined
|
|
20
65
|
if (!/^\d{4}-\d{2}-\d{2}T00:00:00\.000Z$/.test(value)) return undefined
|
|
21
66
|
|
|
22
|
-
|
|
23
|
-
return
|
|
67
|
+
// Calendar validity must not depend on skipped days in the browser's timezone.
|
|
68
|
+
return parseInputDate(value.slice(0, 10))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const validateDateField = ({
|
|
72
|
+
value,
|
|
73
|
+
}: {
|
|
74
|
+
value: unknown
|
|
75
|
+
}): StandardSchemaV1Issue | undefined => {
|
|
76
|
+
// The form schema owns whether an empty date is required or optional.
|
|
77
|
+
if (value === undefined || value === null) return undefined
|
|
78
|
+
return parseFieldDate(value)
|
|
79
|
+
? undefined
|
|
80
|
+
: {
|
|
81
|
+
message: "Please enter a valid date (DD/MM/YYYY).",
|
|
82
|
+
}
|
|
24
83
|
}
|
|
25
84
|
|
|
26
85
|
const toUtcIsoDate = (date: Date): string => {
|
|
27
|
-
const year = date.getFullYear()
|
|
28
|
-
const month = String(date.getMonth() + 1).padStart(2, "0")
|
|
29
|
-
const day = String(date.getDate()).padStart(2, "0")
|
|
30
86
|
// Form state stores a date-only calendar choice as UTC midnight for Effect DateTimeUtc.
|
|
31
|
-
return `${
|
|
87
|
+
return `${formatCalendarDay(date)}T00:00:00.000Z`
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const normalizeDateFieldValue = (value: unknown): unknown => {
|
|
91
|
+
if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(value))
|
|
92
|
+
return value
|
|
93
|
+
const date = parseInputDate(value)
|
|
94
|
+
return date ? toUtcIsoDate(date) : value
|
|
32
95
|
}
|
|
33
96
|
|
|
34
97
|
export function DateField({
|
|
@@ -43,7 +106,13 @@ export function DateField({
|
|
|
43
106
|
readOnly?: boolean
|
|
44
107
|
}) {
|
|
45
108
|
const [open, setOpen] = useState(false)
|
|
46
|
-
const
|
|
109
|
+
const [month, setMonth] = useState<Date>()
|
|
110
|
+
const [draft, setDraft] = useState<{
|
|
111
|
+
value: string | undefined
|
|
112
|
+
text: string
|
|
113
|
+
}>()
|
|
114
|
+
const inputRef = useRef<HTMLInputElement>(null)
|
|
115
|
+
const field = useFieldContext<string | undefined>()
|
|
47
116
|
const form = useFormContext()
|
|
48
117
|
const validationErrors = field.state.meta
|
|
49
118
|
.errors as unknown as StandardSchemaV1Issue[]
|
|
@@ -59,61 +128,91 @@ export function DateField({
|
|
|
59
128
|
(isTouched && !isDefaultValue && allErrors.length > 0)
|
|
60
129
|
const errorId = `${field.name}-error`
|
|
61
130
|
const selected = parseFieldDate(field.state.value)
|
|
131
|
+
const calendarMonth = month ?? selected
|
|
62
132
|
|
|
63
133
|
return (
|
|
64
134
|
<Field>
|
|
65
135
|
<FieldLabel htmlFor={field.name}>{label}</FieldLabel>
|
|
66
136
|
<Popover open={open} onOpenChange={setOpen}>
|
|
67
|
-
<
|
|
68
|
-
<
|
|
137
|
+
<div className="relative">
|
|
138
|
+
<Input
|
|
139
|
+
ref={inputRef}
|
|
69
140
|
id={field.name}
|
|
70
|
-
|
|
71
|
-
|
|
141
|
+
name={field.name}
|
|
142
|
+
type="text"
|
|
143
|
+
value={
|
|
144
|
+
draft && draft.value === field.state.value
|
|
145
|
+
? draft.text
|
|
146
|
+
: selected
|
|
147
|
+
? formatDateInputDay(selected)
|
|
148
|
+
: (field.state.value ?? "")
|
|
149
|
+
}
|
|
150
|
+
placeholder="DD/MM/YYYY"
|
|
72
151
|
autoFocus={autoFocus}
|
|
73
|
-
|
|
152
|
+
readOnly={readOnly}
|
|
74
153
|
aria-invalid={isInvalid}
|
|
75
154
|
aria-describedby={isInvalid ? errorId : undefined}
|
|
76
|
-
className={
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
155
|
+
className={readOnly ? undefined : "pr-10"}
|
|
156
|
+
onChange={(event) => {
|
|
157
|
+
if (readOnly) return
|
|
158
|
+
const text = event.target.value
|
|
159
|
+
const date = parseInputDate(text)
|
|
160
|
+
const value =
|
|
161
|
+
text.trim() === ""
|
|
162
|
+
? undefined
|
|
163
|
+
: date
|
|
164
|
+
? toUtcIsoDate(date)
|
|
165
|
+
: text
|
|
166
|
+
setDraft({ text, value })
|
|
167
|
+
field.handleChange(value)
|
|
168
|
+
if (date) setMonth(date)
|
|
169
|
+
}}
|
|
170
|
+
onBlur={() => {
|
|
171
|
+
setDraft(undefined)
|
|
172
|
+
field.handleBlur()
|
|
173
|
+
}}
|
|
174
|
+
onKeyDown={(event) => {
|
|
175
|
+
if (event.key === "ArrowDown" && !readOnly) {
|
|
176
|
+
event.preventDefault()
|
|
177
|
+
setOpen(true)
|
|
178
|
+
}
|
|
179
|
+
}}
|
|
180
|
+
/>
|
|
181
|
+
{readOnly !== true && (
|
|
182
|
+
<PopoverTrigger asChild>
|
|
183
|
+
<Button
|
|
184
|
+
type="button"
|
|
185
|
+
variant="ghost"
|
|
186
|
+
size="icon"
|
|
187
|
+
aria-label={`Choose ${label}`}
|
|
188
|
+
className="absolute top-1/2 right-1 size-7 -translate-y-1/2"
|
|
189
|
+
>
|
|
190
|
+
<CalendarIcon />
|
|
191
|
+
</Button>
|
|
192
|
+
</PopoverTrigger>
|
|
193
|
+
)}
|
|
194
|
+
</div>
|
|
85
195
|
{readOnly !== true && (
|
|
86
|
-
<PopoverContent
|
|
87
|
-
|
|
88
|
-
|
|
196
|
+
<PopoverContent
|
|
197
|
+
className="w-auto p-3"
|
|
198
|
+
align="end"
|
|
199
|
+
onCloseAutoFocus={(event) => {
|
|
200
|
+
event.preventDefault()
|
|
201
|
+
inputRef.current?.focus()
|
|
202
|
+
}}
|
|
203
|
+
>
|
|
204
|
+
<DateCalendar
|
|
89
205
|
selected={selected}
|
|
206
|
+
month={calendarMonth}
|
|
207
|
+
onMonthChange={setMonth}
|
|
90
208
|
onSelect={(date) => {
|
|
91
209
|
if (!date) return
|
|
92
210
|
field.handleChange(toUtcIsoDate(date))
|
|
93
211
|
field.handleBlur()
|
|
212
|
+
setDraft(undefined)
|
|
213
|
+
setMonth(date)
|
|
94
214
|
setOpen(false)
|
|
95
215
|
}}
|
|
96
|
-
classNames={{
|
|
97
|
-
root: "text-sm",
|
|
98
|
-
months: "flex flex-col gap-4",
|
|
99
|
-
month: "space-y-3",
|
|
100
|
-
caption_label: "font-medium",
|
|
101
|
-
nav: "flex items-center gap-1",
|
|
102
|
-
button_previous:
|
|
103
|
-
"rounded-md p-2 hover:bg-accent hover:text-accent-foreground",
|
|
104
|
-
button_next:
|
|
105
|
-
"rounded-md p-2 hover:bg-accent hover:text-accent-foreground",
|
|
106
|
-
weekdays: "grid grid-cols-7 text-muted-foreground",
|
|
107
|
-
weekday: "py-1 text-center text-xs font-medium",
|
|
108
|
-
week: "grid grid-cols-7",
|
|
109
|
-
day: "p-0 text-center",
|
|
110
|
-
day_button:
|
|
111
|
-
"size-9 rounded-md hover:bg-accent hover:text-accent-foreground disabled:opacity-50",
|
|
112
|
-
selected:
|
|
113
|
-
"[&_button]:bg-primary [&_button]:text-primary-foreground",
|
|
114
|
-
today: "[&_button]:border [&_button]:border-primary",
|
|
115
|
-
outside: "text-muted-foreground opacity-50",
|
|
116
|
-
}}
|
|
117
216
|
/>
|
|
118
217
|
</PopoverContent>
|
|
119
218
|
)}
|