@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.
Files changed (332) hide show
  1. package/README.md +51 -253
  2. package/dist/authentication-server.mjs +52 -84
  3. package/dist/chunk-3wzp2sax.js +4806 -0
  4. package/dist/chunk-5kjvzbwr.js +512 -0
  5. package/dist/chunk-egeb4821.js +156 -0
  6. package/dist/chunk-q5v72erd.js +241 -0
  7. package/dist/{chunk-yhzbn4vx.js → chunk-wvbz0nmd.js} +19485 -34180
  8. package/dist/{chunk-352j1ayk.js → chunk-y8fnwbx0.js} +51781 -36259
  9. package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/actions.ts +12 -12
  10. package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/delegations-client.tsx +31 -21
  11. package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/page.tsx +3 -0
  12. package/dist/dashboard-source/apps/frontend/app/(protected)/client-index.tsx +1 -12
  13. package/dist/dashboard-source/apps/frontend/app/(protected)/connected-apps/disconnect-form.tsx +57 -0
  14. package/dist/dashboard-source/apps/frontend/app/(protected)/connected-apps/page.tsx +97 -0
  15. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/client.tsx +1 -1
  16. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/page.tsx +2 -0
  17. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/process-state/page.tsx +2 -0
  18. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/default.tsx +3 -0
  19. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/page.tsx +3 -1
  20. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/process-state/page.tsx +2 -0
  21. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/client-layout.tsx +19 -0
  22. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/default.tsx +6 -0
  23. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/executions-client.tsx +1637 -0
  24. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/layout.tsx +5 -7
  25. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/page.tsx +4 -1589
  26. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-page-client.tsx +1 -1
  27. package/dist/dashboard-source/apps/frontend/app/(protected)/layout.tsx +41 -33
  28. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/client.tsx +11 -17
  29. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/page.tsx +2 -0
  30. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/default.tsx +3 -0
  31. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/list-page-client.tsx +169 -18
  32. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +21 -14
  33. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +36 -18
  34. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-edit-form.tsx +22 -28
  35. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-load-error.tsx +49 -0
  36. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-schema-form.tsx +28 -0
  37. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/default.tsx +6 -0
  38. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/metric-control-url-state.ts +7 -16
  39. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-deleted-callback.ts +4 -6
  40. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-item-detail.ts +45 -142
  41. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/client.tsx +10 -20
  42. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/page.tsx +2 -0
  43. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/layout.tsx +3 -0
  44. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-process-dialog.tsx +72 -0
  45. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh-provider.tsx +65 -0
  46. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh.ts +162 -16
  47. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.tsx +19 -0
  48. package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/page.tsx +4 -9
  49. package/dist/dashboard-source/apps/frontend/app/(protected)/page.tsx +4 -0
  50. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/actions.ts +15 -18
  51. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/page.tsx +12 -6
  52. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/passkeys-client.tsx +7 -16
  53. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client.tsx +26 -48
  54. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/page.tsx +4 -7
  55. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/default.tsx +3 -0
  56. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client-layout.tsx +28 -0
  57. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client.tsx +1 -3
  58. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/start-process-form.tsx +193 -117
  59. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/default.tsx +6 -0
  60. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/layout.tsx +7 -9
  61. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/page.tsx +3 -0
  62. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/processes-client.tsx +60 -204
  63. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/client.tsx +12 -51
  64. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/page.tsx +27 -4
  65. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/page.tsx +5 -4
  66. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-flow.tsx +0 -5
  67. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-form-preview-sheet.tsx +26 -19
  68. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/page.tsx +5 -2
  69. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-authorize.ts +85 -9
  70. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-types.ts +12 -1
  71. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/explorer.tsx +66 -4
  72. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/layout.tsx +3 -0
  73. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-handbook.ts +41 -13
  74. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/[invitationId]/page.tsx +2 -0
  75. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-client.tsx +442 -365
  76. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/new/page.tsx +8 -2
  77. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/page.tsx +7 -0
  78. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations-table.tsx +61 -43
  79. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/page.tsx +6 -67
  80. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/providers/page.tsx +7 -0
  81. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/roles/page.tsx +7 -0
  82. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-client.tsx +111 -189
  83. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-page.tsx +86 -0
  84. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/client.tsx +141 -256
  85. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/page.tsx +2 -0
  86. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/tokens/page.tsx +2 -0
  87. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/page.tsx +7 -0
  88. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users-table.tsx +6 -4
  89. package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/page.tsx +3 -0
  90. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/client.tsx +30 -9
  91. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/page.tsx +3 -1
  92. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/default.tsx +3 -0
  93. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/client.tsx +2 -4
  94. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/page.tsx +3 -1
  95. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/complete-todo-form.tsx +47 -54
  96. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/public-completion-correction-form.tsx +37 -54
  97. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/todo-form-actions.tsx +1 -1
  98. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/correct/[...stepPath]/page.tsx +3 -1
  99. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/default.tsx +6 -0
  100. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/layout.tsx +3 -0
  101. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/lib/mobile-todo-list.ts +4 -25
  102. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/page.tsx +4 -1315
  103. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/to-dos-client.tsx +1282 -0
  104. package/dist/dashboard-source/apps/frontend/app/api/auth/callback/route.ts +81 -65
  105. package/dist/dashboard-source/apps/frontend/app/api/auth/delegation/route.ts +8 -2
  106. package/dist/dashboard-source/apps/frontend/app/api/auth/login/route.ts +0 -1
  107. package/dist/dashboard-source/apps/frontend/app/api/auth/logout/route.ts +10 -5
  108. package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/start/route.ts +1 -3
  109. package/dist/dashboard-source/apps/frontend/app/api/auth/refresh/route.ts +0 -1
  110. package/dist/dashboard-source/apps/frontend/app/api/auth/revalidate-google/route.ts +68 -0
  111. package/dist/dashboard-source/apps/frontend/app/api/auth/switch-role/route.ts +1 -3
  112. package/dist/dashboard-source/apps/frontend/app/api/dev/import-events/route.ts +69 -1
  113. package/dist/dashboard-source/apps/frontend/app/api/embed/lookup/route.ts +25 -7
  114. package/dist/dashboard-source/apps/frontend/app/api/embed/submit/route.ts +1 -2
  115. package/dist/dashboard-source/apps/frontend/app/api/public/start/[address]/route.ts +49 -0
  116. package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/lookup/route.ts +4 -3
  117. package/dist/dashboard-source/apps/frontend/app/api/revalidate/route.ts +15 -4
  118. package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +14 -6
  119. package/dist/dashboard-source/apps/frontend/app/cli-auth/route.ts +2 -1
  120. package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/embed-client.tsx +31 -18
  121. package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/page.tsx +5 -1
  122. package/dist/dashboard-source/apps/frontend/app/login/page.tsx +4 -4
  123. package/dist/dashboard-source/apps/frontend/app/login/passkey-button.tsx +11 -6
  124. package/dist/dashboard-source/apps/frontend/app/login/passkey-help/page.tsx +67 -0
  125. package/dist/dashboard-source/apps/frontend/app/mcp/[[...endpoint]]/route.ts +44 -0
  126. package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-client.tsx +44 -25
  127. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/form/page.tsx +10 -0
  128. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/layout.tsx +32 -0
  129. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-client.tsx +319 -0
  130. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-content.tsx +41 -0
  131. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page.tsx +10 -0
  132. package/dist/dashboard-source/apps/frontend/app/public.css +1 -1
  133. package/dist/dashboard-source/apps/frontend/app/register/passkey/register-passkey-client.tsx +17 -0
  134. package/dist/dashboard-source/apps/frontend/components/DashboardSection.tsx +9 -15
  135. package/dist/dashboard-source/apps/frontend/components/Header.tsx +14 -8
  136. package/dist/dashboard-source/apps/frontend/components/anonymous-page-link.tsx +57 -0
  137. package/dist/dashboard-source/apps/frontend/components/anonymous-start-form.tsx +24 -0
  138. package/dist/dashboard-source/apps/frontend/components/app-sidebar.tsx +21 -7
  139. package/dist/dashboard-source/apps/frontend/components/auth-provider.tsx +12 -7
  140. package/dist/dashboard-source/apps/frontend/components/browser-only.tsx +19 -0
  141. package/dist/dashboard-source/apps/frontend/components/config-provider.tsx +0 -1
  142. package/dist/dashboard-source/apps/frontend/components/delegation-expiry.tsx +24 -13
  143. package/dist/dashboard-source/apps/frontend/components/form-dialog-content.tsx +22 -2
  144. package/dist/dashboard-source/apps/frontend/components/journey-timeline.tsx +52 -45
  145. package/dist/dashboard-source/apps/frontend/components/notification-bell.tsx +0 -1
  146. package/dist/dashboard-source/apps/frontend/components/sidebar-lists.tsx +0 -1
  147. package/dist/dashboard-source/apps/frontend/components/token-refresh-scheduler.tsx +38 -11
  148. package/dist/dashboard-source/apps/frontend/components/ui/sidebar.tsx +0 -1
  149. package/dist/dashboard-source/apps/frontend/components/ui/tab-pill.tsx +26 -15
  150. package/dist/dashboard-source/apps/frontend/components/workflow/step-node.tsx +0 -1
  151. package/dist/dashboard-source/apps/frontend/components/workflow/workflow-edge.tsx +5 -0
  152. package/dist/dashboard-source/apps/frontend/hooks/use-form-metadata.ts +21 -10
  153. package/dist/dashboard-source/apps/frontend/hooks/use-process-draft.ts +173 -0
  154. package/dist/dashboard-source/apps/frontend/hooks/use-weekly-execution-stats.ts +1 -3
  155. package/dist/dashboard-source/apps/frontend/lib/anonymous-page-form-values.ts +6 -0
  156. package/dist/dashboard-source/apps/frontend/lib/anonymous-page-server.ts +65 -0
  157. package/dist/dashboard-source/apps/frontend/lib/appsync-events/adapter.ts +9 -3
  158. package/dist/dashboard-source/apps/frontend/lib/appsync-events/client.ts +7 -340
  159. package/dist/dashboard-source/apps/frontend/lib/auth/client-session.ts +2 -0
  160. package/dist/dashboard-source/apps/frontend/lib/auth/delegations.ts +9 -7
  161. package/dist/dashboard-source/apps/frontend/lib/auth/google-revalidation.ts +111 -0
  162. package/dist/dashboard-source/apps/frontend/lib/auth/logout.ts +1 -1
  163. package/dist/dashboard-source/apps/frontend/lib/auth/passkeys.ts +28 -30
  164. package/dist/dashboard-source/apps/frontend/lib/auth/providers.ts +10 -0
  165. package/dist/dashboard-source/apps/frontend/lib/auth/realtime-session-token.ts +1 -0
  166. package/dist/dashboard-source/apps/frontend/lib/auth/reauthentication-state.ts +4 -4
  167. package/dist/dashboard-source/apps/frontend/lib/auth/session-admission.ts +11 -7
  168. package/dist/dashboard-source/apps/frontend/lib/auth/session.ts +27 -10
  169. package/dist/dashboard-source/apps/frontend/lib/auth/ssr-session.ts +76 -9
  170. package/dist/dashboard-source/apps/frontend/lib/auth/verify-passkey.ts +25 -3
  171. package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +115 -23
  172. package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution.ts +1 -8
  173. package/dist/dashboard-source/apps/frontend/lib/collections/execution.ts +6 -2
  174. package/dist/dashboard-source/apps/frontend/lib/collections/graphql-stream.ts +21 -1
  175. package/dist/dashboard-source/apps/frontend/lib/collections/process-collection-provider.tsx +3 -0
  176. package/dist/dashboard-source/apps/frontend/lib/collections/process.ts +8 -2
  177. package/dist/dashboard-source/apps/frontend/lib/collections/replication-factory.ts +16 -4
  178. package/dist/dashboard-source/apps/frontend/lib/collections/todo.ts +1 -1
  179. package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-query-invalidation.tsx +66 -9
  180. package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-refresh.ts +10 -6
  181. package/dist/dashboard-source/apps/frontend/lib/effect/navigation.ts +4 -0
  182. package/dist/dashboard-source/apps/frontend/lib/effect/page-runtime.ts +29 -0
  183. package/dist/dashboard-source/apps/frontend/lib/effect/params.ts +18 -12
  184. package/dist/dashboard-source/apps/frontend/lib/effect/run-effect.ts +1 -1
  185. package/dist/dashboard-source/apps/frontend/lib/effect/runtime.ts +19 -23
  186. package/dist/dashboard-source/apps/frontend/lib/effect/services/access-token.ts +9 -12
  187. package/dist/dashboard-source/apps/frontend/lib/effect/services/authorization.ts +12 -12
  188. package/dist/dashboard-source/apps/frontend/lib/effect/services/form-validation.ts +20 -18
  189. package/dist/dashboard-source/apps/frontend/lib/effect/services/graphql.ts +32 -16
  190. package/dist/dashboard-source/apps/frontend/lib/embed-form-server.ts +35 -0
  191. package/dist/dashboard-source/apps/frontend/lib/embed-manifest.ts +10 -103
  192. package/dist/dashboard-source/apps/frontend/lib/forms/invitation.ts +43 -0
  193. package/dist/dashboard-source/apps/frontend/lib/forms/provider-user.ts +64 -0
  194. package/dist/dashboard-source/apps/frontend/lib/frontend-form-loaders.ts +40 -0
  195. package/dist/dashboard-source/apps/frontend/lib/frontend-manifest.ts +1 -33
  196. package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +123 -33
  197. package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +168 -30
  198. package/dist/dashboard-source/apps/frontend/lib/generated/gql/index.ts +1 -0
  199. package/dist/dashboard-source/apps/frontend/lib/graphql/anonymous-page.ts +27 -0
  200. package/dist/dashboard-source/apps/frontend/lib/graphql/dependent-lookup-query.ts +1 -0
  201. package/dist/dashboard-source/apps/frontend/lib/graphql/list-queries.ts +34 -29
  202. package/dist/dashboard-source/apps/frontend/lib/graphql/lookup-provider.tsx +82 -10
  203. package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-operations.ts +2 -5
  204. package/dist/dashboard-source/apps/frontend/lib/graphql/queries.ts +25 -4
  205. package/dist/dashboard-source/apps/frontend/lib/graphql/server-client.ts +11 -0
  206. package/dist/dashboard-source/apps/frontend/lib/graphql/settings-queries.ts +13 -104
  207. package/dist/dashboard-source/apps/frontend/lib/graphql/user-queries.ts +11 -4
  208. package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-operations.ts +1 -3
  209. package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-queries.ts +1 -0
  210. package/dist/dashboard-source/apps/frontend/lib/list-detail-selection.ts +54 -0
  211. package/dist/dashboard-source/apps/frontend/lib/mcp/executions.ts +110 -0
  212. package/dist/dashboard-source/apps/frontend/lib/mcp/list-writes.ts +395 -0
  213. package/dist/dashboard-source/apps/frontend/lib/mcp/lists.ts +263 -0
  214. package/dist/dashboard-source/apps/frontend/lib/mcp/oauth.ts +889 -0
  215. package/dist/dashboard-source/apps/frontend/lib/mcp/origin.ts +50 -0
  216. package/dist/dashboard-source/apps/frontend/lib/mcp/processes.ts +436 -0
  217. package/dist/dashboard-source/apps/frontend/lib/mcp/read-tool.ts +72 -0
  218. package/dist/dashboard-source/apps/frontend/lib/mcp/result.ts +4 -0
  219. package/dist/dashboard-source/apps/frontend/lib/mcp/server.ts +71 -0
  220. package/dist/dashboard-source/apps/frontend/lib/mcp/store.ts +107 -0
  221. package/dist/dashboard-source/apps/frontend/lib/mcp/todos.ts +260 -0
  222. package/dist/dashboard-source/apps/frontend/lib/notifications/notification-preference.ts +0 -1
  223. package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notification-observer.ts +0 -5
  224. package/dist/dashboard-source/apps/frontend/lib/org-chart-data.ts +0 -2
  225. package/dist/dashboard-source/apps/frontend/lib/org-identity.ts +6 -4
  226. package/dist/dashboard-source/apps/frontend/lib/organisation-form-loaders.ts +4 -0
  227. package/dist/dashboard-source/apps/frontend/lib/public-todo-form-runtime.ts +0 -1
  228. package/dist/dashboard-source/apps/frontend/lib/public-todo-model.ts +39 -139
  229. package/dist/dashboard-source/apps/frontend/lib/public-todo-server.ts +17 -16
  230. package/dist/dashboard-source/apps/frontend/lib/query-client.ts +0 -1
  231. package/dist/dashboard-source/apps/frontend/lib/todo-utils.ts +1 -77
  232. package/dist/dashboard-source/apps/frontend/lib/workflow/layout.ts +3 -7
  233. package/dist/dashboard-source/apps/frontend/next.config.ts +33 -13
  234. package/dist/dashboard-source/apps/frontend/package.json +47 -47
  235. package/dist/dashboard-source/apps/frontend/proxy.ts +72 -14
  236. package/dist/dashboard-source/modules/auth-local-cedar/src/index.ts +0 -3
  237. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/auth-local-cedar.ts +165 -233
  238. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/cedar-reload-notifier.ts +4 -3
  239. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/config-base.ts +111 -75
  240. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/policy-watcher.ts +14 -18
  241. package/dist/dashboard-source/modules/auth-policy/src/index.ts +1 -0
  242. package/dist/dashboard-source/modules/auth-policy/src/lib/auth-policy.ts +19 -37
  243. package/dist/dashboard-source/modules/auth-policy/src/lib/current-principal.ts +33 -29
  244. package/dist/dashboard-source/modules/auth-policy/src/lib/policy-revision.ts +23 -0
  245. package/dist/dashboard-source/modules/auth-policy/src/lib/types.ts +24 -49
  246. package/dist/dashboard-source/modules/auth-session/src/index.ts +4 -0
  247. package/dist/dashboard-source/modules/auth-session/src/lib/project-subscription.ts +13 -0
  248. package/dist/dashboard-source/modules/auth-session/src/lib/realtime-recipient.ts +10 -2
  249. package/dist/dashboard-source/modules/auth-session/src/lib/subjects.ts +82 -8
  250. package/dist/dashboard-source/modules/auth-session/src/lib/workload-access.ts +48 -0
  251. package/dist/dashboard-source/modules/auth-session/src/lib/workload-audit.ts +52 -0
  252. package/dist/dashboard-source/modules/aws-common/src/index.ts +0 -1
  253. package/dist/dashboard-source/modules/effect-json-logger/src/lib/effect-json-logger.ts +6 -9
  254. package/dist/dashboard-source/modules/form/src/hooks/use-local-storage.ts +5 -3
  255. package/dist/dashboard-source/modules/form/src/index.ts +1 -10
  256. package/dist/dashboard-source/modules/form/src/lib/effect-schema-form.tsx +1271 -0
  257. package/dist/dashboard-source/modules/form/src/lib/form-actions.ts +26 -0
  258. package/dist/dashboard-source/modules/form/src/lib/form-prefill.tsx +79 -0
  259. package/dist/dashboard-source/modules/form/src/lib/initial-focus.ts +31 -0
  260. package/dist/dashboard-source/modules/form/src/lib/lookup-context.tsx +18 -0
  261. package/dist/dashboard-source/modules/form/src/lib/plugin-registry.ts +4 -0
  262. package/dist/dashboard-source/modules/form/src/lib/plugin-scripts.ts +26 -0
  263. package/dist/dashboard-source/modules/form/src/lib/registered-plugin-field.tsx +57 -0
  264. package/dist/dashboard-source/modules/form/src/lib/schema-lookup.tsx +124 -0
  265. package/dist/dashboard-source/modules/form/src/lib/schema-typeahead.tsx +522 -0
  266. package/dist/dashboard-source/modules/form/src/lib/validation-logic.ts +172 -0
  267. package/dist/dashboard-source/modules/form-schema/src/index.ts +4 -1
  268. package/dist/dashboard-source/modules/form-schema/src/lib/annotation-helpers.ts +19 -14
  269. package/dist/dashboard-source/modules/form-schema/src/lib/email.ts +13 -11
  270. package/dist/dashboard-source/modules/form-schema/src/lib/field-count.ts +15 -13
  271. package/dist/dashboard-source/modules/form-schema/src/lib/form-annotations.ts +14 -0
  272. package/dist/dashboard-source/modules/form-schema/src/lib/form-presentation.ts +33 -0
  273. package/dist/dashboard-source/modules/form-schema/src/lib/form-schema.ts +186 -80
  274. package/dist/dashboard-source/modules/form-schema/src/lib/number-from-string.ts +26 -0
  275. package/dist/dashboard-source/modules/form-schema/src/lib/phone.ts +8 -7
  276. package/dist/dashboard-source/modules/form-schema/src/lib/public-completion-correction.ts +7 -0
  277. package/dist/dashboard-source/modules/form-schema/src/lib/search-lookup-items.ts +27 -0
  278. package/dist/dashboard-source/modules/form-submission-schema/src/index.ts +5 -0
  279. package/dist/dashboard-source/modules/form-submission-schema/src/lib/executable-rules.ts +379 -0
  280. package/dist/dashboard-source/modules/form-submission-schema/src/lib/form-submission-schema.ts +475 -0
  281. package/dist/dashboard-source/modules/form-submission-schema/src/lib/json-schema.ts +58 -0
  282. package/dist/dashboard-source/modules/form-submission-schema/src/lib/schema-defaults.ts +158 -0
  283. package/dist/dashboard-source/modules/form-submission-schema/src/lib/submission-utils.ts +75 -0
  284. package/dist/dashboard-source/modules/frontend-manifest/src/lib/browser-plugin-artifact.ts +46 -0
  285. package/dist/dashboard-source/modules/frontend-manifest/src/lib/frontend-manifest.ts +37 -30
  286. package/dist/dashboard-source/modules/frontend-plugin-host/src/lib/frontend-plugin-host.ts +9 -1
  287. package/dist/dashboard-source/modules/openauth/src/client.ts +25 -17
  288. package/dist/dashboard-source/modules/openauth/src/util.ts +16 -0
  289. package/dist/dashboard-source/modules/{aws-common/src/lib/project-balance-admission.ts → project-accounting/src/admission.ts} +4 -8
  290. package/dist/dashboard-source/modules/realtime-client/src/appsync-client.ts +377 -0
  291. package/dist/dashboard-source/modules/realtime-client/src/index.ts +5 -0
  292. package/dist/dashboard-source/modules/realtime-client/src/subscription-presence.ts +163 -0
  293. package/dist/dashboard-source/modules/request-time/src/lib/request-time.ts +6 -24
  294. package/dist/dashboard-source/modules/rxdb-collections/generated/execution-schema.json +28 -21
  295. package/dist/dashboard-source/modules/rxdb-collections/src/lib/rxdb-collections.ts +25 -18
  296. package/dist/dashboard-source/modules/rxdb-collections/src/lib/to-rxdb-schema.ts +60 -10
  297. package/dist/dashboard-source/modules/shadcn-components/src/index.ts +18 -2
  298. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-calendar.tsx +93 -0
  299. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-field.tsx +147 -48
  300. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-time-display.tsx +273 -0
  301. package/dist/dashboard-source/modules/shadcn-components/src/lib/local-date-time-input.tsx +108 -0
  302. package/dist/dashboard-source/modules/shadcn-components/src/lib/lookup-field.tsx +237 -351
  303. package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/popover.tsx +2 -1
  304. package/dist/dashboard-source.json +47 -47
  305. package/dist/graphql-server.mjs +272 -200
  306. package/dist/job-worker-supervisor.mjs +262 -0
  307. package/dist/job-worker.mjs +234 -133
  308. package/dist/main.mjs +30 -6
  309. package/dist/prepare-dashboard.mjs +8 -8
  310. package/dist/resources/cedar/policies.cedar +80 -38
  311. package/dist/resources/cedar/schema.cedarschema +39 -21
  312. package/dist/resources/graphql-schema/rxdb.graphql +2 -0
  313. package/dist/resources/graphql-schema/system.graphql +191 -51
  314. package/package.json +63 -62
  315. package/dist/chunk-6ntmymmx.js +0 -85
  316. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.ts +0 -20
  317. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-form-actions.tsx +0 -105
  318. package/dist/dashboard-source/apps/frontend/hooks/use-draft-process-save.ts +0 -189
  319. package/dist/dashboard-source/apps/frontend/hooks/use-draft-state.ts +0 -79
  320. package/dist/dashboard-source/apps/frontend/hooks/use-processes-query.ts +0 -56
  321. package/dist/dashboard-source/modules/form/src/lib/ajv-standard-schema.ts +0 -152
  322. package/dist/dashboard-source/modules/form/src/lib/client-components-to-form.tsx +0 -1421
  323. package/dist/dashboard-source/modules/form/src/lib/friendly-validation-message.ts +0 -85
  324. package/dist/dashboard-source/modules/form/src/lib/walker.tsx +0 -1549
  325. package/dist/dashboard-source/modules/form-client-representation/src/lib/client-form-definition.ts +0 -440
  326. package/dist/dashboard-source/modules/form-client-representation/src/lib/plugin-registry.ts +0 -13
  327. package/dist/dashboard-source/modules/form-client-representation/src/lib/types.ts +0 -336
  328. package/dist/dashboard-source/modules/form-rule/src/index.ts +0 -21
  329. package/dist/dashboard-source/modules/form-rule/src/lib/evaluator.ts +0 -531
  330. package/dist/dashboard-source/modules/form-rule/src/lib/paths.ts +0 -102
  331. package/dist/dashboard-source/modules/form-rule/src/lib/types.ts +0 -121
  332. package/dist/dashboard-source/modules/form-schema/src/lib/property-signature.ts +0 -45
@@ -3,16 +3,15 @@
3
3
  import { useQueryClient } from "@tanstack/react-query"
4
4
  import { AlertCircle, ArrowLeft, Loader2 } from "lucide-react"
5
5
  import Link from "next/link"
6
- import { useRouter } from "next/navigation"
7
6
  import { useCallback } from "react"
8
- import type { JsonSchemaRoot } from "../../../../../../../modules/form/src/index.ts"
9
7
  import { Button } from "../../../../../../../modules/shadcn-components/src/index.ts"
10
8
  import { ListItemEditForm } from "../../components/list-item-edit-form.tsx"
9
+ import { ListItemLoadError } from "../../components/list-item-load-error.tsx"
11
10
  import { useListDeletedCallback } from "../../hooks/use-list-deleted-callback.ts"
12
11
  import { useListItemDetail } from "../../hooks/use-list-item-detail.ts"
13
12
  import { listDetailTitle } from "../../lib/list-detail-title.ts"
14
- import { markListStale } from "../../lib/list-refresh.ts"
15
- import { formatCellValue } from "../../utils.ts"
13
+ import { formatCellValue } from "../../utils.tsx"
14
+ import { useListRefresh } from "@/app/(protected)/lists/lib/list-refresh-provider"
16
15
 
17
16
  interface ListDetailClientProps {
18
17
  listPath: string
@@ -23,9 +22,9 @@ export default function ListDetailClient({
23
22
  listPath,
24
23
  itemId,
25
24
  }: ListDetailClientProps) {
26
- const router = useRouter()
25
+ const refreshState = useListRefresh()
27
26
  const queryClient = useQueryClient()
28
- const { currentList, itemDetail, formMetadata, isLoading, error } =
27
+ const { currentList, itemDetail, formMetadata, isLoading, error, refetch } =
29
28
  useListItemDetail(listPath, itemId)
30
29
 
31
30
  const handleClose = useCallback(() => {
@@ -36,16 +35,14 @@ export default function ListDetailClient({
36
35
  queryClient.invalidateQueries({
37
36
  queryKey: ["listItem", listPath, itemId],
38
37
  })
39
- markListStale(listPath)
40
- router.refresh()
41
- }, [queryClient, listPath, itemId, router])
38
+ refreshState.invalidate(listPath)
39
+ }, [queryClient, listPath, itemId, refreshState])
42
40
 
43
41
  const handleDeleted = useListDeletedCallback(listPath, itemId)
44
42
 
45
43
  const detailTitle = listDetailTitle(currentList)
46
44
  const isAnyLoading = isLoading
47
45
 
48
- // Loading state
49
46
  if (isAnyLoading) {
50
47
  return (
51
48
  <div className="flex-1">
@@ -69,7 +66,7 @@ export default function ListDetailClient({
69
66
  }
70
67
 
71
68
  // List not found or no item query
72
- if (!currentList?.itemQueryName) {
69
+ if (!error && !currentList?.itemQueryName) {
73
70
  return (
74
71
  <div className="flex-1">
75
72
  <div className="mx-auto max-w-2xl">
@@ -99,7 +96,6 @@ export default function ListDetailClient({
99
96
  )
100
97
  }
101
98
 
102
- // Error state
103
99
  if (error) {
104
100
  return (
105
101
  <div className="flex-1">
@@ -111,9 +107,7 @@ export default function ListDetailClient({
111
107
  <h1 className="text-2xl font-semibold text-rose-900 dark:text-rose-100">
112
108
  Error Loading Item
113
109
  </h1>
114
- <p className="mt-2 text-sm text-rose-600 dark:text-rose-400">
115
- {String(error)}
116
- </p>
110
+ <ListItemLoadError error={error} onRetry={refetch} />
117
111
  </div>
118
112
  </div>
119
113
  <Link href={`/lists${listPath}`}>
@@ -128,7 +122,7 @@ export default function ListDetailClient({
128
122
  )
129
123
  }
130
124
 
131
- // Item not found
125
+ if (!currentList) return null
132
126
  if (!itemDetail) {
133
127
  return (
134
128
  <div className="flex-1">
@@ -174,8 +168,6 @@ export default function ListDetailClient({
174
168
  ),
175
169
  )
176
170
  : (itemDetail as Record<string, unknown> | null)
177
- const jsonSchema =
178
- (formMetadata.jsonSchema as JsonSchemaRoot | null) ?? null
179
171
 
180
172
  return (
181
173
  <div className="flex-1">
@@ -201,8 +193,6 @@ export default function ListDetailClient({
201
193
  updateInputTypeName={formMetadata.updateInputTypeName ?? null}
202
194
  deleteMutationName={formMetadata.deleteMutationName ?? null}
203
195
  defaultValues={defaultValues}
204
- formDefinition={formMetadata.formDefinition}
205
- jsonSchema={jsonSchema}
206
196
  outputFields={currentList.outputColumns.map((c) => c.field)}
207
197
  onClose={handleClose}
208
198
  onSaved={handleSaved}
@@ -2,6 +2,8 @@ import { Loader2 } from "lucide-react"
2
2
  import { Suspense } from "react"
3
3
  import ListDetailClient from "./client.tsx"
4
4
 
5
+ export const instant = false
6
+
5
7
  interface PageProps {
6
8
  params: Promise<{ id: string }>
7
9
  searchParams: Promise<{ list?: string }>
@@ -1,3 +1,6 @@
1
+ // The authenticated shell can omit this subtree before a session is ready.
2
+ export const instant = false
3
+
1
4
  export default function ListsLayout({
2
5
  children,
3
6
  modal,
@@ -0,0 +1,72 @@
1
+ "use client"
2
+
3
+ import { usePathname, useSearchParams } from "next/navigation"
4
+ import { useMemo, useState } from "react"
5
+ import { parseListReturnDestination } from "./list-refresh.ts"
6
+ import { useReturnToList } from "./list-refresh-provider.tsx"
7
+ import StartProcessModalClient from "@/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client"
8
+
9
+ const startPrefix = "/processes/start/"
10
+
11
+ /** The retained List reads its own URL state while the form owns the address bar. */
12
+ export function useListSearchParams() {
13
+ const pathname = usePathname()
14
+ const params = useSearchParams()
15
+ return useMemo(() => {
16
+ const destination = pathname.startsWith(startPrefix)
17
+ ? parseListReturnDestination(params.get("returnTo"), "http://localhost")
18
+ : null
19
+ return destination
20
+ ? new URL(destination.href, "http://localhost").searchParams
21
+ : params
22
+ }, [pathname, params])
23
+ }
24
+
25
+ /** Also mounted by the hard-navigation start page, using the same List server page. */
26
+ export function ListProcessDialog({ listPath }: { readonly listPath: string }) {
27
+ const pathname = usePathname()
28
+ const params = useSearchParams()
29
+ const destination = parseListReturnDestination(
30
+ params.get("returnTo"),
31
+ "http://localhost",
32
+ )
33
+ if (!pathname.startsWith(startPrefix) || destination?.listPath !== listPath)
34
+ return null
35
+ return (
36
+ <RetainedListProcessDialog
37
+ key={pathname}
38
+ startStepPath={`/${decodeURIComponent(pathname.slice(startPrefix.length))}`}
39
+ sourceRecordId={params.get("sourceRecordId")}
40
+ />
41
+ )
42
+ }
43
+
44
+ function RetainedListProcessDialog({
45
+ startStepPath,
46
+ sourceRecordId,
47
+ }: {
48
+ readonly startStepPath: string
49
+ readonly sourceRecordId: string | null
50
+ }) {
51
+ const returnToList = useReturnToList(true)
52
+ const [initiator] = useState(() =>
53
+ typeof document === "undefined" ? null : document.activeElement,
54
+ )
55
+ return (
56
+ <StartProcessModalClient
57
+ startStepPath={startStepPath}
58
+ description={
59
+ sourceRecordId
60
+ ? `Start a process for List record ${sourceRecordId}`
61
+ : "Start a process"
62
+ }
63
+ onClose={returnToList}
64
+ onCloseAutoFocus={(event) => {
65
+ event.preventDefault()
66
+ if (initiator instanceof HTMLElement && initiator.isConnected) {
67
+ initiator.focus()
68
+ }
69
+ }}
70
+ />
71
+ )
72
+ }
@@ -0,0 +1,65 @@
1
+ "use client"
2
+
3
+ import { useRouter, useSearchParams } from "next/navigation"
4
+ import { type ReactNode, createContext, useContext, useState } from "react"
5
+ import { ListRefreshState, parseListReturnDestination } from "./list-refresh.ts"
6
+ import { useSession } from "@/components/auth-provider"
7
+ import { useRuntimeConfig } from "@/components/config-provider"
8
+ import { getSessionCacheScope } from "@/lib/auth/session-cache-scope"
9
+
10
+ const ListRefreshContext = createContext<ListRefreshState | null>(null)
11
+
12
+ export function ListRefreshProvider({ children }: { children: ReactNode }) {
13
+ const session = useSession()
14
+ const { orgId, graphqlEndpoint } = useRuntimeConfig()
15
+ const scope = JSON.stringify([
16
+ orgId,
17
+ graphqlEndpoint,
18
+ getSessionCacheScope(session),
19
+ ])
20
+ return (
21
+ <ScopedListRefreshProvider key={scope}>
22
+ {children}
23
+ </ScopedListRefreshProvider>
24
+ )
25
+ }
26
+
27
+ function ScopedListRefreshProvider({ children }: { children: ReactNode }) {
28
+ const [state] = useState(() => new ListRefreshState())
29
+ return (
30
+ <ListRefreshContext.Provider value={state}>
31
+ {children}
32
+ </ListRefreshContext.Provider>
33
+ )
34
+ }
35
+
36
+ export function useListRefresh(): ListRefreshState {
37
+ const state = useContext(ListRefreshContext)
38
+ if (!state) throw new Error("ListRefreshProvider is required")
39
+ return state
40
+ }
41
+
42
+ /** Both process routes share the success/cancellation and warm-history contract. */
43
+ export function useReturnToList(retainList = false) {
44
+ const router = useRouter()
45
+ const params = useSearchParams()
46
+ const state = useListRefresh()
47
+ return (result: "submitted" | "cancelled"): boolean => {
48
+ const destination = parseListReturnDestination(
49
+ params.get("returnTo"),
50
+ window.location.origin,
51
+ )
52
+ if (!destination) return false
53
+ const { href, listPath } = destination
54
+ if (result === "submitted") state.invalidate(listPath)
55
+ if (state.canReturn(params.get("listReturn"), href)) {
56
+ router.back()
57
+ } else if (retainList) {
58
+ window.history.replaceState(null, "", href)
59
+ } else {
60
+ // A direct/reloaded form has no retained shell. Load the normal SSR route.
61
+ router.push(href)
62
+ }
63
+ return true
64
+ }
65
+ }
@@ -1,26 +1,172 @@
1
- "use client"
1
+ import type {
2
+ ListDataResult,
3
+ ListQueryVariables,
4
+ } from "@/lib/graphql/list-queries"
2
5
 
3
- const staleListKeyPrefix = "pf:list-stale:"
6
+ type RefreshResult =
7
+ | { readonly kind: "loading" }
8
+ | { readonly kind: "error" }
9
+ | { readonly kind: "ready"; readonly data: ListDataResult }
4
10
 
5
- // Full-page item routes unmount the list before router.refresh() can repaint it.
6
- // Marking the list stale lets the next list mount request fresh server data.
7
- export function markListStale(listPath: string): void {
8
- try {
9
- window.sessionStorage.setItem(`${staleListKeyPrefix}${listPath}`, "1")
10
- } catch {
11
- // Ignore storage failures; direct router.refresh() still handles current routes.
11
+ type RefreshEntry = {
12
+ version: number
13
+ sources: ReadonlySet<ListDataResult>
14
+ result: RefreshResult
15
+ }
16
+
17
+ type ListRefreshSnapshot = {
18
+ readonly versions: ReadonlyMap<string, number>
19
+ readonly results: ReadonlyMap<string, RefreshEntry>
20
+ }
21
+
22
+ /** Owned by one authenticated shell, never persisted across logout/reload. */
23
+ export class ListRefreshState {
24
+ private versions = new Map<string, number>()
25
+ private results = new Map<string, RefreshEntry>()
26
+ private returns = new Map<string, string>()
27
+ private listeners = new Set<() => void>()
28
+ private current: ListRefreshSnapshot = {
29
+ versions: new Map(),
30
+ results: new Map(),
31
+ }
32
+ private initial = this.current
33
+
34
+ subscribe = (listener: () => void) => {
35
+ this.listeners.add(listener)
36
+ return () => {
37
+ this.listeners.delete(listener)
38
+ }
39
+ }
40
+ snapshot = () => this.current
41
+ serverSnapshot = () => this.initial
42
+ private emit() {
43
+ this.current = {
44
+ versions: new Map(this.versions),
45
+ results: new Map(this.results),
46
+ }
47
+ for (const listener of this.listeners) listener()
48
+ }
49
+
50
+ rememberReturn(destination: string): string {
51
+ const token = crypto.randomUUID()
52
+ this.returns.set(token, destination)
53
+ return token
54
+ }
55
+
56
+ canReturn(token: string | null, destination: string): boolean {
57
+ return token !== null && this.returns.get(token) === destination
58
+ }
59
+
60
+ invalidate(path: string): void {
61
+ this.versions.set(path, (this.versions.get(path) ?? 0) + 1)
62
+ this.emit()
63
+ }
64
+
65
+ private key(path: string, variables: ListQueryVariables): string {
66
+ return JSON.stringify([
67
+ path,
68
+ variables.page,
69
+ variables.limit,
70
+ variables.filter,
71
+ variables.sort ?? null,
72
+ ])
73
+ }
74
+
75
+ read(
76
+ path: string,
77
+ variables: ListQueryVariables,
78
+ initial: ListDataResult,
79
+ snapshot = this.current,
80
+ ): RefreshResult {
81
+ const version = snapshot.versions.get(path) ?? 0
82
+ if (version === 0) return { kind: "ready", data: initial }
83
+ const entry = snapshot.results.get(this.key(path, variables))
84
+ return entry?.version === version && entry.sources.has(initial)
85
+ ? entry.result
86
+ : { kind: "loading" }
87
+ }
88
+
89
+ async refresh(
90
+ path: string,
91
+ variables: ListQueryVariables,
92
+ initial: ListDataResult,
93
+ fetch: (variables: ListQueryVariables) => Promise<ListDataResult>,
94
+ snapshot = this.current,
95
+ ): Promise<void> {
96
+ const version = snapshot.versions.get(path) ?? 0
97
+ if ((this.versions.get(path) ?? 0) !== version) return
98
+ const key = this.key(path, variables)
99
+ const previous = this.results.get(key)
100
+ if (previous?.version === version && previous.sources.has(initial)) return
101
+ const sources = new Set(previous?.sources)
102
+ sources.add(initial)
103
+ const pending: RefreshEntry = {
104
+ version,
105
+ sources,
106
+ result: { kind: "loading" },
107
+ }
108
+ if (version === 0) {
109
+ this.results.set(key, {
110
+ ...pending,
111
+ result: { kind: "ready", data: initial },
112
+ })
113
+ this.emit()
114
+ return
115
+ }
116
+ // A new RSC payload can follow a write outside this List. Revalidate it
117
+ // rather than masking it with cached rows or trusting an older prefetch.
118
+ // Previously seen payloads (Back/Forward) keep the latest refreshed rows.
119
+ this.results.set(key, pending)
120
+ this.emit()
121
+ try {
122
+ const data = await fetch(variables)
123
+ if (
124
+ this.versions.get(path) !== version ||
125
+ this.results.get(key) !== pending
126
+ )
127
+ return
128
+ this.results.set(key, {
129
+ version,
130
+ sources,
131
+ result: { kind: "ready", data },
132
+ })
133
+ if (data.page !== variables.page) {
134
+ this.results.set(this.key(path, { ...variables, page: data.page }), {
135
+ version,
136
+ sources,
137
+ result: { kind: "ready", data },
138
+ })
139
+ }
140
+ } catch {
141
+ if (
142
+ this.versions.get(path) !== version ||
143
+ this.results.get(key) !== pending
144
+ )
145
+ return
146
+ this.results.set(key, { version, sources, result: { kind: "error" } })
147
+ }
148
+ this.emit()
12
149
  }
13
150
  }
14
151
 
15
- export function consumeListStale(listPath: string): boolean {
152
+ /** Parse untrusted return URLs before navigating or invalidating List state. */
153
+ export function parseListReturnDestination(
154
+ returnTo: string | null,
155
+ origin: string,
156
+ ) {
157
+ if (!returnTo?.startsWith("/lists/")) return null
16
158
  try {
17
- const key = `${staleListKeyPrefix}${listPath}`
18
- const isStale = window.sessionStorage.getItem(key) === "1"
19
- if (isStale) {
20
- window.sessionStorage.removeItem(key)
159
+ const destination = new URL(returnTo, origin)
160
+ if (
161
+ destination.origin !== origin ||
162
+ !destination.pathname.startsWith("/lists/")
163
+ )
164
+ return null
165
+ return {
166
+ href: `${destination.pathname}${destination.search}`,
167
+ listPath: decodeURIComponent(destination.pathname).slice("/lists".length),
21
168
  }
22
- return isStale
23
169
  } catch {
24
- return false
170
+ return null
25
171
  }
26
172
  }
@@ -0,0 +1,19 @@
1
+ import { DateTimeDisplay } from "../../../../../modules/shadcn-components/src/lib/date-time-display.tsx"
2
+
3
+ /** ISO 8601 date pattern */
4
+ const ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/
5
+
6
+ /**
7
+ * Format a cell value for display.
8
+ * ISO calendar dates retain their day; ISO date/times represent instants.
9
+ */
10
+ export function formatCellValue(value: unknown) {
11
+ if (value == null) return ""
12
+ if (typeof value === "string" && ISO_DATE_PATTERN.test(value)) {
13
+ return <DateTimeDisplay kind="timestamp" value={value} />
14
+ }
15
+ if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value)) {
16
+ return <DateTimeDisplay kind="calendar-date" value={value} />
17
+ }
18
+ return String(value)
19
+ }
@@ -7,13 +7,14 @@ import { flattenOrgUnits } from "@/lib/org-chart-data"
7
7
  import { getDepthConfig } from "@/lib/org-chart-depth-config"
8
8
  import { layoutOrgChart } from "@/lib/org-chart-layout"
9
9
 
10
+ // The authenticated layout can omit this page while checking the session.
11
+ export const instant = false
12
+
10
13
  const OrgChartPage = Effect.fn("OrgChartPage")(function* () {
11
14
  // Fetch data with error handling - return empty state on error
12
15
  const data = yield* fetchOrgChartDataEffect().pipe(
13
- Effect.catchAll((error) => {
14
- // Log error for debugging
16
+ Effect.catch((error) => {
15
17
  console.error("Failed to fetch org chart data:", error.message)
16
- // Return empty data structure for graceful degradation
17
18
  return Effect.succeed({
18
19
  orgLevels: [],
19
20
  org: {
@@ -26,7 +27,6 @@ const OrgChartPage = Effect.fn("OrgChartPage")(function* () {
26
27
  }),
27
28
  )
28
29
 
29
- // Handle empty data case
30
30
  if (data.orgLevels.length === 0) {
31
31
  return (
32
32
  <div className="flex h-full flex-col">
@@ -45,21 +45,17 @@ const OrgChartPage = Effect.fn("OrgChartPage")(function* () {
45
45
  )
46
46
  }
47
47
 
48
- // Create mapping from level name to depth (maxDepth)
49
48
  const levelToDepth = new Map(
50
49
  data.orgLevels.map((level) => [level.level, level.maxDepth]),
51
50
  )
52
51
 
53
- // Flatten nested structure to flat array with parentId
54
52
  // Type assertion is safe because the GraphQL type is structurally compatible with RecursiveOrgUnit
55
53
  const flatOrgUnits = flattenOrgUnits(
56
54
  data.org as Parameters<typeof flattenOrgUnits>[0],
57
55
  )
58
56
 
59
- // Layout the org chart
60
57
  const { nodes, edges } = layoutOrgChart(flatOrgUnits)
61
58
 
62
- // Enrich nodes with depth information from levelToDepth mapping
63
59
  const enrichedNodes = nodes.map((node) => ({
64
60
  ...node,
65
61
  data: {
@@ -68,7 +64,6 @@ const OrgChartPage = Effect.fn("OrgChartPage")(function* () {
68
64
  },
69
65
  }))
70
66
 
71
- // Create legend items from actual org levels
72
67
  const legendItems = data.orgLevels
73
68
  .sort((a, b) => a.maxDepth - b.maxDepth)
74
69
  .map((level) => {
@@ -2,6 +2,10 @@ import ClientPage from "./client.tsx"
2
2
  import { ExecutionCollectionProvider } from "@/lib/collections/execution-collection-provider"
3
3
  import { ProcessCollectionProvider } from "@/lib/collections/process-collection-provider"
4
4
 
5
+ // The authenticated layout can omit children while redirecting or reissuing a
6
+ // session, so this page is not rendered in every instant-validation pass.
7
+ export const instant = false
8
+
5
9
  export default function Page() {
6
10
  return (
7
11
  <ProcessCollectionProvider>
@@ -1,11 +1,7 @@
1
1
  "use server"
2
2
 
3
- import {
4
- FetchHttpClient,
5
- HttpClient,
6
- HttpClientRequest,
7
- } from "@effect/platform"
8
- import { Effect, Either, Schema } from "effect"
3
+ import { Effect, Exit, Schema } from "effect"
4
+ import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http"
9
5
  import { getIssuerUrl } from "@/lib/auth/issuer"
10
6
  import {
11
7
  PasskeyEnrollmentOptions,
@@ -54,7 +50,7 @@ function requestPasskeys<
54
50
  }: {
55
51
  method: "GET" | "PATCH" | "POST" | "DELETE"
56
52
  body?: unknown
57
- schema: Schema.Schema<A, I>
53
+ schema: Schema.Codec<A, I>
58
54
  kind: K
59
55
  message: string
60
56
  statuses?: Readonly<Record<number, Failure | NoInfer<Extra>>>
@@ -73,12 +69,13 @@ function requestPasskeys<
73
69
  if (response.status < 200 || response.status >= 300)
74
70
  return statuses[response.status] ?? { kind: "error" as const, message }
75
71
  const data = yield* response.json.pipe(
76
- Effect.flatMap(Schema.decodeUnknown(schema)),
72
+ Effect.flatMap(Schema.decodeUnknownEffect(schema)),
77
73
  )
78
74
  return { kind, ...data }
79
75
  }).pipe(
80
- Effect.catchAll(() => Effect.succeed({ kind: "error" as const, message })),
76
+ Effect.catch(() => Effect.succeed({ kind: "error" as const, message })),
81
77
  Effect.provide(FetchHttpClient.layer),
78
+ Effect.provideService(FetchHttpClient.Fetch, globalThis.fetch),
82
79
  Effect.provideService(FetchHttpClient.RequestInit, {
83
80
  cache: "no-store",
84
81
  redirect: "error",
@@ -101,15 +98,15 @@ export async function listPasskeys(): Promise<Listed | Failure> {
101
98
  }
102
99
 
103
100
  export async function renamePasskey(input: unknown): Promise<Listed | Failure> {
104
- const parsed = Schema.decodeUnknownEither(RenamePasskey)(input)
105
- if (Either.isLeft(parsed)) return { kind: "error", message: nameError }
101
+ const parsed = Schema.decodeUnknownExit(RenamePasskey)(input)
102
+ if (Exit.isFailure(parsed)) return { kind: "error", message: nameError }
106
103
  return requestPasskeys<
107
104
  typeof PasskeyList.Type,
108
105
  typeof PasskeyList.Encoded,
109
106
  "success"
110
107
  >({
111
108
  method: "PATCH",
112
- body: parsed.right,
109
+ body: parsed.value,
113
110
  schema: PasskeyList,
114
111
  kind: "success",
115
112
  message: "Unable to rename this Passkey.",
@@ -120,15 +117,15 @@ export async function renamePasskey(input: unknown): Promise<Listed | Failure> {
120
117
  export async function startPasskeyEnrollment(
121
118
  input: unknown,
122
119
  ): Promise<Enrollment | Failure> {
123
- const parsed = Schema.decodeUnknownEither(StartPasskeyEnrollment)(input)
124
- if (Either.isLeft(parsed)) return { kind: "error", message: nameError }
120
+ const parsed = Schema.decodeUnknownExit(StartPasskeyEnrollment)(input)
121
+ if (Exit.isFailure(parsed)) return { kind: "error", message: nameError }
125
122
  return requestPasskeys<
126
123
  typeof PasskeyEnrollmentOptions.Type,
127
124
  typeof PasskeyEnrollmentOptions.Encoded,
128
125
  "options"
129
126
  >({
130
127
  method: "POST",
131
- body: parsed.right,
128
+ body: parsed.value,
132
129
  schema: PasskeyEnrollmentOptions,
133
130
  kind: "options",
134
131
  message: "Unable to start Passkey registration.",
@@ -165,8 +162,8 @@ export async function verifyPasskeyEnrollment(
165
162
  }
166
163
 
167
164
  export async function removePasskey(input: unknown): Promise<Listed | Failure> {
168
- const parsed = Schema.decodeUnknownEither(RemovePasskey)(input)
169
- if (Either.isLeft(parsed))
165
+ const parsed = Schema.decodeUnknownExit(RemovePasskey)(input)
166
+ if (Exit.isFailure(parsed))
170
167
  return { kind: "error", message: "Unable to remove this Passkey." }
171
168
  return requestPasskeys<
172
169
  typeof PasskeyList.Type,
@@ -174,7 +171,7 @@ export async function removePasskey(input: unknown): Promise<Listed | Failure> {
174
171
  "success"
175
172
  >({
176
173
  method: "DELETE",
177
- body: parsed.right,
174
+ body: parsed.value,
178
175
  schema: PasskeyList,
179
176
  kind: "success",
180
177
  message: "Unable to remove this Passkey.",
@@ -1,8 +1,12 @@
1
1
  import { Effect } from "effect"
2
+ import { DateTimeDisplayProvider } from "../../../../../modules/shadcn-components/src/lib/date-time-display.tsx"
2
3
  import { listPasskeys } from "./actions.ts"
3
4
  import { PasskeysClient } from "./passkeys-client.tsx"
4
5
  import { BasePage } from "@/lib/effect/runtime"
5
6
 
7
+ // The authenticated layout can omit this page while checking the session.
8
+ export const instant = false
9
+
6
10
  const Passkeys = BasePage.build(() =>
7
11
  Effect.gen(function* () {
8
12
  const result = yield* Effect.promise(() => listPasskeys())
@@ -18,12 +22,14 @@ const Passkeys = BasePage.build(() =>
18
22
  {result.kind !== "success" ? (
19
23
  <p role="alert">{result.message}</p>
20
24
  ) : (
21
- <PasskeysClient
22
- key={result.account.userId}
23
- organisationName={result.organisation.name}
24
- account={result.account}
25
- initialCredentials={result.credentials}
26
- />
25
+ <DateTimeDisplayProvider initialNow={Date.now()}>
26
+ <PasskeysClient
27
+ key={result.account.userId}
28
+ organisationName={result.organisation.name}
29
+ account={result.account}
30
+ initialCredentials={result.credentials}
31
+ />
32
+ </DateTimeDisplayProvider>
27
33
  )}
28
34
  </div>
29
35
  )