@processfocus/runtime-local 0.1.0-next.1 → 0.1.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/README.md +48 -253
  2. package/dist/authentication-server.mjs +52 -84
  3. package/dist/{chunk-fn7b5pxw.js → chunk-04r0t2mb.js} +19364 -34104
  4. package/dist/chunk-727y6qkb.js +156 -0
  5. package/dist/chunk-bg5r4wpv.js +4755 -0
  6. package/dist/chunk-cbd36jq1.js +512 -0
  7. package/dist/chunk-d4ctj079.js +241 -0
  8. package/dist/{chunk-cq9xscgb.js → chunk-r5s2v669.js} +49079 -33564
  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)/executions/@modal/(.)[executionId]/client.tsx +1 -1
  14. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/page.tsx +2 -0
  15. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/process-state/page.tsx +2 -0
  16. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/default.tsx +3 -0
  17. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/page.tsx +3 -1
  18. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/process-state/page.tsx +2 -0
  19. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/client-layout.tsx +19 -0
  20. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/default.tsx +6 -0
  21. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/executions-client.tsx +1637 -0
  22. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/layout.tsx +5 -7
  23. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/page.tsx +4 -1589
  24. package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-page-client.tsx +1 -1
  25. package/dist/dashboard-source/apps/frontend/app/(protected)/layout.tsx +41 -33
  26. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/client.tsx +11 -17
  27. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/page.tsx +2 -0
  28. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/default.tsx +3 -0
  29. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/list-page-client.tsx +153 -16
  30. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +10 -2
  31. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +29 -13
  32. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-edit-form.tsx +22 -28
  33. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-load-error.tsx +49 -0
  34. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-schema-form.tsx +28 -0
  35. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/default.tsx +6 -0
  36. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/metric-control-url-state.ts +7 -16
  37. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-deleted-callback.ts +4 -6
  38. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-item-detail.ts +45 -142
  39. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/client.tsx +10 -20
  40. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/page.tsx +2 -0
  41. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/layout.tsx +3 -0
  42. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-process-dialog.tsx +72 -0
  43. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh-provider.tsx +65 -0
  44. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh.ts +162 -16
  45. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.tsx +19 -0
  46. package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/page.tsx +4 -9
  47. package/dist/dashboard-source/apps/frontend/app/(protected)/page.tsx +4 -0
  48. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/actions.ts +15 -18
  49. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/page.tsx +12 -6
  50. package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/passkeys-client.tsx +7 -16
  51. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client.tsx +26 -48
  52. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/page.tsx +4 -7
  53. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/default.tsx +3 -0
  54. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client-layout.tsx +28 -0
  55. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client.tsx +1 -3
  56. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/start-process-form.tsx +193 -117
  57. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/default.tsx +6 -0
  58. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/layout.tsx +7 -9
  59. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/page.tsx +3 -0
  60. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/processes-client.tsx +60 -204
  61. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/client.tsx +12 -51
  62. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/page.tsx +27 -4
  63. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/page.tsx +5 -4
  64. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-flow.tsx +0 -5
  65. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-form-preview-sheet.tsx +26 -19
  66. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/page.tsx +5 -2
  67. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-authorize.ts +85 -9
  68. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-types.ts +12 -1
  69. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/explorer.tsx +66 -4
  70. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/layout.tsx +3 -0
  71. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-handbook.ts +41 -13
  72. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/[invitationId]/page.tsx +2 -0
  73. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-client.tsx +442 -365
  74. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/new/page.tsx +8 -2
  75. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/page.tsx +7 -0
  76. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations-table.tsx +61 -43
  77. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/page.tsx +6 -67
  78. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/providers/page.tsx +7 -0
  79. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/roles/page.tsx +7 -0
  80. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-client.tsx +111 -189
  81. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-page.tsx +86 -0
  82. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/client.tsx +141 -256
  83. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/page.tsx +2 -0
  84. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/tokens/page.tsx +2 -0
  85. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/page.tsx +7 -0
  86. package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users-table.tsx +6 -4
  87. package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/page.tsx +3 -0
  88. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/client.tsx +30 -9
  89. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/page.tsx +3 -1
  90. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/default.tsx +3 -0
  91. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/client.tsx +2 -4
  92. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/page.tsx +3 -1
  93. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/complete-todo-form.tsx +47 -54
  94. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/public-completion-correction-form.tsx +37 -54
  95. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/todo-form-actions.tsx +1 -1
  96. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/correct/[...stepPath]/page.tsx +3 -1
  97. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/default.tsx +6 -0
  98. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/layout.tsx +3 -0
  99. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/lib/mobile-todo-list.ts +4 -25
  100. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/page.tsx +4 -1315
  101. package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/to-dos-client.tsx +1282 -0
  102. package/dist/dashboard-source/apps/frontend/app/api/auth/callback/route.ts +81 -65
  103. package/dist/dashboard-source/apps/frontend/app/api/auth/delegation/route.ts +8 -2
  104. package/dist/dashboard-source/apps/frontend/app/api/auth/login/route.ts +0 -1
  105. package/dist/dashboard-source/apps/frontend/app/api/auth/logout/route.ts +10 -5
  106. package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/start/route.ts +1 -3
  107. package/dist/dashboard-source/apps/frontend/app/api/auth/refresh/route.ts +0 -1
  108. package/dist/dashboard-source/apps/frontend/app/api/auth/revalidate-google/route.ts +68 -0
  109. package/dist/dashboard-source/apps/frontend/app/api/auth/switch-role/route.ts +1 -3
  110. package/dist/dashboard-source/apps/frontend/app/api/embed/lookup/route.ts +25 -7
  111. package/dist/dashboard-source/apps/frontend/app/api/embed/submit/route.ts +1 -2
  112. package/dist/dashboard-source/apps/frontend/app/api/public/start/[address]/route.ts +49 -0
  113. package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/lookup/route.ts +4 -3
  114. package/dist/dashboard-source/apps/frontend/app/api/revalidate/route.ts +15 -4
  115. package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +11 -4
  116. package/dist/dashboard-source/apps/frontend/app/cli-auth/route.ts +2 -1
  117. package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/embed-client.tsx +31 -18
  118. package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/page.tsx +5 -1
  119. package/dist/dashboard-source/apps/frontend/app/login/page.tsx +4 -4
  120. package/dist/dashboard-source/apps/frontend/app/login/passkey-button.tsx +11 -6
  121. package/dist/dashboard-source/apps/frontend/app/login/passkey-help/page.tsx +67 -0
  122. package/dist/dashboard-source/apps/frontend/app/mcp/[[...endpoint]]/route.ts +47 -0
  123. package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-client.tsx +44 -25
  124. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/form/page.tsx +10 -0
  125. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/layout.tsx +32 -0
  126. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-client.tsx +319 -0
  127. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-content.tsx +41 -0
  128. package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page.tsx +10 -0
  129. package/dist/dashboard-source/apps/frontend/app/public.css +1 -1
  130. package/dist/dashboard-source/apps/frontend/app/register/passkey/register-passkey-client.tsx +17 -0
  131. package/dist/dashboard-source/apps/frontend/components/DashboardSection.tsx +9 -15
  132. package/dist/dashboard-source/apps/frontend/components/Header.tsx +4 -8
  133. package/dist/dashboard-source/apps/frontend/components/anonymous-page-link.tsx +57 -0
  134. package/dist/dashboard-source/apps/frontend/components/anonymous-start-form.tsx +24 -0
  135. package/dist/dashboard-source/apps/frontend/components/app-sidebar.tsx +21 -7
  136. package/dist/dashboard-source/apps/frontend/components/auth-provider.tsx +12 -7
  137. package/dist/dashboard-source/apps/frontend/components/browser-only.tsx +19 -0
  138. package/dist/dashboard-source/apps/frontend/components/config-provider.tsx +0 -1
  139. package/dist/dashboard-source/apps/frontend/components/delegation-expiry.tsx +24 -13
  140. package/dist/dashboard-source/apps/frontend/components/form-dialog-content.tsx +22 -2
  141. package/dist/dashboard-source/apps/frontend/components/journey-timeline.tsx +52 -45
  142. package/dist/dashboard-source/apps/frontend/components/notification-bell.tsx +0 -1
  143. package/dist/dashboard-source/apps/frontend/components/sidebar-lists.tsx +0 -1
  144. package/dist/dashboard-source/apps/frontend/components/token-refresh-scheduler.tsx +38 -11
  145. package/dist/dashboard-source/apps/frontend/components/ui/sidebar.tsx +0 -1
  146. package/dist/dashboard-source/apps/frontend/components/ui/tab-pill.tsx +26 -15
  147. package/dist/dashboard-source/apps/frontend/components/workflow/step-node.tsx +0 -1
  148. package/dist/dashboard-source/apps/frontend/components/workflow/workflow-edge.tsx +5 -0
  149. package/dist/dashboard-source/apps/frontend/hooks/use-form-metadata.ts +21 -10
  150. package/dist/dashboard-source/apps/frontend/hooks/use-process-draft.ts +173 -0
  151. package/dist/dashboard-source/apps/frontend/hooks/use-weekly-execution-stats.ts +1 -3
  152. package/dist/dashboard-source/apps/frontend/lib/anonymous-page-form-values.ts +6 -0
  153. package/dist/dashboard-source/apps/frontend/lib/anonymous-page-server.ts +65 -0
  154. package/dist/dashboard-source/apps/frontend/lib/appsync-events/adapter.ts +9 -3
  155. package/dist/dashboard-source/apps/frontend/lib/appsync-events/client.ts +7 -340
  156. package/dist/dashboard-source/apps/frontend/lib/auth/client-session.ts +2 -0
  157. package/dist/dashboard-source/apps/frontend/lib/auth/delegations.ts +9 -7
  158. package/dist/dashboard-source/apps/frontend/lib/auth/google-revalidation.ts +111 -0
  159. package/dist/dashboard-source/apps/frontend/lib/auth/logout.ts +1 -1
  160. package/dist/dashboard-source/apps/frontend/lib/auth/passkeys.ts +28 -30
  161. package/dist/dashboard-source/apps/frontend/lib/auth/providers.ts +10 -0
  162. package/dist/dashboard-source/apps/frontend/lib/auth/realtime-session-token.ts +1 -0
  163. package/dist/dashboard-source/apps/frontend/lib/auth/reauthentication-state.ts +4 -4
  164. package/dist/dashboard-source/apps/frontend/lib/auth/session-admission.ts +11 -7
  165. package/dist/dashboard-source/apps/frontend/lib/auth/session.ts +27 -10
  166. package/dist/dashboard-source/apps/frontend/lib/auth/ssr-session.ts +76 -9
  167. package/dist/dashboard-source/apps/frontend/lib/auth/verify-passkey.ts +25 -3
  168. package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +112 -21
  169. package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution.ts +1 -8
  170. package/dist/dashboard-source/apps/frontend/lib/collections/execution.ts +6 -2
  171. package/dist/dashboard-source/apps/frontend/lib/collections/process-collection-provider.tsx +3 -0
  172. package/dist/dashboard-source/apps/frontend/lib/collections/process.ts +8 -2
  173. package/dist/dashboard-source/apps/frontend/lib/collections/replication-factory.ts +16 -4
  174. package/dist/dashboard-source/apps/frontend/lib/collections/todo.ts +1 -1
  175. package/dist/dashboard-source/apps/frontend/lib/effect/navigation.ts +4 -0
  176. package/dist/dashboard-source/apps/frontend/lib/effect/page-runtime.ts +29 -0
  177. package/dist/dashboard-source/apps/frontend/lib/effect/params.ts +18 -12
  178. package/dist/dashboard-source/apps/frontend/lib/effect/run-effect.ts +1 -1
  179. package/dist/dashboard-source/apps/frontend/lib/effect/runtime.ts +19 -23
  180. package/dist/dashboard-source/apps/frontend/lib/effect/services/access-token.ts +9 -12
  181. package/dist/dashboard-source/apps/frontend/lib/effect/services/authorization.ts +12 -12
  182. package/dist/dashboard-source/apps/frontend/lib/effect/services/form-validation.ts +20 -18
  183. package/dist/dashboard-source/apps/frontend/lib/effect/services/graphql.ts +32 -16
  184. package/dist/dashboard-source/apps/frontend/lib/embed-form-server.ts +35 -0
  185. package/dist/dashboard-source/apps/frontend/lib/embed-manifest.ts +10 -103
  186. package/dist/dashboard-source/apps/frontend/lib/forms/invitation.ts +43 -0
  187. package/dist/dashboard-source/apps/frontend/lib/forms/provider-user.ts +64 -0
  188. package/dist/dashboard-source/apps/frontend/lib/frontend-form-loaders.ts +40 -0
  189. package/dist/dashboard-source/apps/frontend/lib/frontend-manifest.ts +1 -33
  190. package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +123 -33
  191. package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +169 -30
  192. package/dist/dashboard-source/apps/frontend/lib/generated/gql/index.ts +1 -0
  193. package/dist/dashboard-source/apps/frontend/lib/graphql/anonymous-page.ts +27 -0
  194. package/dist/dashboard-source/apps/frontend/lib/graphql/dependent-lookup-query.ts +1 -0
  195. package/dist/dashboard-source/apps/frontend/lib/graphql/list-queries.ts +38 -29
  196. package/dist/dashboard-source/apps/frontend/lib/graphql/lookup-provider.tsx +82 -10
  197. package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-operations.ts +2 -5
  198. package/dist/dashboard-source/apps/frontend/lib/graphql/queries.ts +25 -4
  199. package/dist/dashboard-source/apps/frontend/lib/graphql/server-client.ts +11 -0
  200. package/dist/dashboard-source/apps/frontend/lib/graphql/settings-queries.ts +13 -104
  201. package/dist/dashboard-source/apps/frontend/lib/graphql/user-queries.ts +11 -4
  202. package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-operations.ts +1 -3
  203. package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-queries.ts +1 -0
  204. package/dist/dashboard-source/apps/frontend/lib/list-detail-selection.ts +54 -0
  205. package/dist/dashboard-source/apps/frontend/lib/mcp/executions.ts +110 -0
  206. package/dist/dashboard-source/apps/frontend/lib/mcp/list-writes.ts +395 -0
  207. package/dist/dashboard-source/apps/frontend/lib/mcp/lists.ts +263 -0
  208. package/dist/dashboard-source/apps/frontend/lib/mcp/oauth.ts +900 -0
  209. package/dist/dashboard-source/apps/frontend/lib/mcp/origin.ts +42 -0
  210. package/dist/dashboard-source/apps/frontend/lib/mcp/processes.ts +436 -0
  211. package/dist/dashboard-source/apps/frontend/lib/mcp/read-tool.ts +72 -0
  212. package/dist/dashboard-source/apps/frontend/lib/mcp/result.ts +4 -0
  213. package/dist/dashboard-source/apps/frontend/lib/mcp/server.ts +71 -0
  214. package/dist/dashboard-source/apps/frontend/lib/mcp/store.ts +193 -0
  215. package/dist/dashboard-source/apps/frontend/lib/mcp/todos.ts +237 -0
  216. package/dist/dashboard-source/apps/frontend/lib/notifications/notification-preference.ts +0 -1
  217. package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notification-observer.ts +0 -5
  218. package/dist/dashboard-source/apps/frontend/lib/org-chart-data.ts +0 -2
  219. package/dist/dashboard-source/apps/frontend/lib/org-identity.ts +6 -4
  220. package/dist/dashboard-source/apps/frontend/lib/organisation-form-loaders.ts +4 -0
  221. package/dist/dashboard-source/apps/frontend/lib/public-todo-form-runtime.ts +0 -1
  222. package/dist/dashboard-source/apps/frontend/lib/public-todo-model.ts +39 -139
  223. package/dist/dashboard-source/apps/frontend/lib/public-todo-server.ts +17 -16
  224. package/dist/dashboard-source/apps/frontend/lib/query-client.ts +0 -1
  225. package/dist/dashboard-source/apps/frontend/lib/todo-utils.ts +1 -77
  226. package/dist/dashboard-source/apps/frontend/lib/workflow/layout.ts +3 -7
  227. package/dist/dashboard-source/apps/frontend/next.config.ts +33 -13
  228. package/dist/dashboard-source/apps/frontend/package.json +48 -47
  229. package/dist/dashboard-source/apps/frontend/proxy.ts +72 -14
  230. package/dist/dashboard-source/modules/auth-local-cedar/src/index.ts +0 -3
  231. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/auth-local-cedar.ts +165 -233
  232. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/cedar-reload-notifier.ts +4 -3
  233. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/config-base.ts +111 -75
  234. package/dist/dashboard-source/modules/auth-local-cedar/src/lib/policy-watcher.ts +14 -18
  235. package/dist/dashboard-source/modules/auth-policy/src/index.ts +1 -0
  236. package/dist/dashboard-source/modules/auth-policy/src/lib/auth-policy.ts +19 -37
  237. package/dist/dashboard-source/modules/auth-policy/src/lib/current-principal.ts +33 -29
  238. package/dist/dashboard-source/modules/auth-policy/src/lib/policy-revision.ts +23 -0
  239. package/dist/dashboard-source/modules/auth-policy/src/lib/types.ts +24 -49
  240. package/dist/dashboard-source/modules/auth-session/src/index.ts +4 -0
  241. package/dist/dashboard-source/modules/auth-session/src/lib/project-subscription.ts +13 -0
  242. package/dist/dashboard-source/modules/auth-session/src/lib/realtime-recipient.ts +10 -2
  243. package/dist/dashboard-source/modules/auth-session/src/lib/subjects.ts +82 -8
  244. package/dist/dashboard-source/modules/auth-session/src/lib/workload-access.ts +48 -0
  245. package/dist/dashboard-source/modules/auth-session/src/lib/workload-audit.ts +52 -0
  246. package/dist/dashboard-source/modules/aws-common/src/index.ts +0 -1
  247. package/dist/dashboard-source/modules/effect-json-logger/src/lib/effect-json-logger.ts +6 -9
  248. package/dist/dashboard-source/modules/form/src/hooks/use-local-storage.ts +5 -3
  249. package/dist/dashboard-source/modules/form/src/index.ts +1 -10
  250. package/dist/dashboard-source/modules/form/src/lib/effect-schema-form.tsx +1271 -0
  251. package/dist/dashboard-source/modules/form/src/lib/form-actions.ts +26 -0
  252. package/dist/dashboard-source/modules/form/src/lib/form-prefill.tsx +79 -0
  253. package/dist/dashboard-source/modules/form/src/lib/initial-focus.ts +31 -0
  254. package/dist/dashboard-source/modules/form/src/lib/lookup-context.tsx +18 -0
  255. package/dist/dashboard-source/modules/form/src/lib/plugin-registry.ts +4 -0
  256. package/dist/dashboard-source/modules/form/src/lib/plugin-scripts.ts +26 -0
  257. package/dist/dashboard-source/modules/form/src/lib/registered-plugin-field.tsx +57 -0
  258. package/dist/dashboard-source/modules/form/src/lib/schema-lookup.tsx +124 -0
  259. package/dist/dashboard-source/modules/form/src/lib/schema-typeahead.tsx +522 -0
  260. package/dist/dashboard-source/modules/form/src/lib/validation-logic.ts +172 -0
  261. package/dist/dashboard-source/modules/form-schema/src/index.ts +4 -1
  262. package/dist/dashboard-source/modules/form-schema/src/lib/annotation-helpers.ts +19 -14
  263. package/dist/dashboard-source/modules/form-schema/src/lib/email.ts +13 -11
  264. package/dist/dashboard-source/modules/form-schema/src/lib/field-count.ts +15 -13
  265. package/dist/dashboard-source/modules/form-schema/src/lib/form-annotations.ts +14 -0
  266. package/dist/dashboard-source/modules/form-schema/src/lib/form-presentation.ts +33 -0
  267. package/dist/dashboard-source/modules/form-schema/src/lib/form-schema.ts +186 -80
  268. package/dist/dashboard-source/modules/form-schema/src/lib/number-from-string.ts +26 -0
  269. package/dist/dashboard-source/modules/form-schema/src/lib/phone.ts +8 -7
  270. package/dist/dashboard-source/modules/form-schema/src/lib/public-completion-correction.ts +7 -0
  271. package/dist/dashboard-source/modules/form-schema/src/lib/search-lookup-items.ts +27 -0
  272. package/dist/dashboard-source/modules/form-submission-schema/src/index.ts +5 -0
  273. package/dist/dashboard-source/modules/form-submission-schema/src/lib/executable-rules.ts +379 -0
  274. package/dist/dashboard-source/modules/form-submission-schema/src/lib/form-submission-schema.ts +475 -0
  275. package/dist/dashboard-source/modules/form-submission-schema/src/lib/json-schema.ts +58 -0
  276. package/dist/dashboard-source/modules/form-submission-schema/src/lib/schema-defaults.ts +158 -0
  277. package/dist/dashboard-source/modules/form-submission-schema/src/lib/submission-utils.ts +75 -0
  278. package/dist/dashboard-source/modules/frontend-manifest/src/lib/browser-plugin-artifact.ts +46 -0
  279. package/dist/dashboard-source/modules/frontend-manifest/src/lib/frontend-manifest.ts +37 -30
  280. package/dist/dashboard-source/modules/frontend-plugin-host/src/lib/frontend-plugin-host.ts +9 -1
  281. package/dist/dashboard-source/modules/openauth/src/client.ts +25 -17
  282. package/dist/dashboard-source/modules/openauth/src/util.ts +16 -0
  283. package/dist/dashboard-source/modules/{aws-common/src/lib/project-balance-admission.ts → project-accounting/src/admission.ts} +4 -8
  284. package/dist/dashboard-source/modules/realtime-client/src/appsync-client.ts +377 -0
  285. package/dist/dashboard-source/modules/realtime-client/src/index.ts +5 -0
  286. package/dist/dashboard-source/modules/realtime-client/src/subscription-presence.ts +163 -0
  287. package/dist/dashboard-source/modules/request-time/src/lib/request-time.ts +6 -24
  288. package/dist/dashboard-source/modules/rxdb-collections/generated/execution-schema.json +28 -21
  289. package/dist/dashboard-source/modules/rxdb-collections/src/lib/rxdb-collections.ts +25 -18
  290. package/dist/dashboard-source/modules/rxdb-collections/src/lib/to-rxdb-schema.ts +60 -10
  291. package/dist/dashboard-source/modules/shadcn-components/src/index.ts +18 -2
  292. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-calendar.tsx +93 -0
  293. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-field.tsx +147 -48
  294. package/dist/dashboard-source/modules/shadcn-components/src/lib/date-time-display.tsx +272 -0
  295. package/dist/dashboard-source/modules/shadcn-components/src/lib/local-date-time-input.tsx +108 -0
  296. package/dist/dashboard-source/modules/shadcn-components/src/lib/lookup-field.tsx +237 -351
  297. package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/popover.tsx +2 -1
  298. package/dist/dashboard-source.json +48 -47
  299. package/dist/graphql-server.mjs +245 -200
  300. package/dist/job-worker-supervisor.mjs +262 -0
  301. package/dist/job-worker.mjs +234 -133
  302. package/dist/main.mjs +23 -4
  303. package/dist/prepare-dashboard.mjs +8 -8
  304. package/dist/resources/cedar/policies.cedar +80 -38
  305. package/dist/resources/cedar/schema.cedarschema +39 -21
  306. package/dist/resources/graphql-schema/rxdb.graphql +2 -0
  307. package/dist/resources/graphql-schema/system.graphql +204 -51
  308. package/package.json +64 -62
  309. package/dist/chunk-6b6t8tyq.js +0 -85
  310. package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.ts +0 -20
  311. package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-form-actions.tsx +0 -105
  312. package/dist/dashboard-source/apps/frontend/hooks/use-draft-process-save.ts +0 -189
  313. package/dist/dashboard-source/apps/frontend/hooks/use-draft-state.ts +0 -79
  314. package/dist/dashboard-source/apps/frontend/hooks/use-processes-query.ts +0 -56
  315. package/dist/dashboard-source/modules/form/src/lib/ajv-standard-schema.ts +0 -152
  316. package/dist/dashboard-source/modules/form/src/lib/client-components-to-form.tsx +0 -1421
  317. package/dist/dashboard-source/modules/form/src/lib/friendly-validation-message.ts +0 -85
  318. package/dist/dashboard-source/modules/form/src/lib/walker.tsx +0 -1549
  319. package/dist/dashboard-source/modules/form-client-representation/src/lib/client-form-definition.ts +0 -440
  320. package/dist/dashboard-source/modules/form-client-representation/src/lib/plugin-registry.ts +0 -13
  321. package/dist/dashboard-source/modules/form-client-representation/src/lib/types.ts +0 -336
  322. package/dist/dashboard-source/modules/form-rule/src/index.ts +0 -21
  323. package/dist/dashboard-source/modules/form-rule/src/lib/evaluator.ts +0 -531
  324. package/dist/dashboard-source/modules/form-rule/src/lib/paths.ts +0 -102
  325. package/dist/dashboard-source/modules/form-rule/src/lib/types.ts +0 -121
  326. package/dist/dashboard-source/modules/form-schema/src/lib/property-signature.ts +0 -45
@@ -43,9 +43,6 @@ import { useAuth } from "@/components/auth-provider"
43
43
  import { useRuntimeConfig } from "@/components/config-provider"
44
44
  import { getSessionCacheScope } from "@/lib/auth/session-cache-scope"
45
45
 
46
- /**
47
- * Configuration for creating a collection provider
48
- */
49
46
  /**
50
47
  * Base type for all RxDB documents - must have id and updatedAt
51
48
  */
@@ -70,6 +67,10 @@ interface CollectionProviderConfig<TDoc extends RxDbDocumentBase> {
70
67
  */
71
68
  name: string
72
69
 
70
+ /** Override when a server-owned collection must restart its pull checkpoint. */
71
+ replicationIdentifier?: string
72
+ streamMode?: "documents" | "resync"
73
+
73
74
  /**
74
75
  * Pull query builder for fetching data from server
75
76
  */
@@ -167,7 +168,15 @@ export interface ReplicationRuntimeConfig {
167
168
  userId: string
168
169
  }
169
170
 
171
+ export type InitialSyncState =
172
+ | { status: "loading" }
173
+ | { status: "complete" }
174
+ | { status: "error"; error: Error }
175
+
170
176
  export interface CollectionContextValue<TDoc extends RxDbDocumentBase> {
177
+ /** Server bootstrap and adapter commits, independent of local availability. */
178
+ initialSync: InitialSyncState
179
+ retryInitialSync: () => void
171
180
  db: ProcessFocusDatabase | null
172
181
  rxCollection: RxCollection<TDoc> | null
173
182
  state: CollectionState<TDoc>
@@ -247,7 +256,51 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
247
256
  let persistentState: CollectionState<TDoc> =
248
257
  createPendingState("waiting-for-rxdb")
249
258
 
250
- // Prevents duplicate initialization starts (needed for React 18 Strict Mode double-mount)
259
+ // Bootstrap observers belong to the current cache/replication generation.
260
+ let initialSync: InitialSyncState = { status: "loading" }
261
+ let disposeInitialSync = () => {}
262
+ let awaitQueryPropagation: () => Promise<void> = async () => {}
263
+
264
+ function resetInitialSync(): void {
265
+ disposeInitialSync()
266
+ initialSync = { status: "loading" }
267
+ }
268
+
269
+ function observeInitialSync(
270
+ replication: RxReplicationState<TDoc, PullCheckpoint>,
271
+ ): void {
272
+ disposeInitialSync()
273
+ if (initialSync.status === "complete") return
274
+ let current = true
275
+ const subscription = replication.error$.subscribe((error) => {
276
+ // RC_STREAM is recoverable independently of the required HTTP pull.
277
+ if (!current || error.code !== "RC_PULL") return
278
+ initialSync = { status: "error", error: asError(error) }
279
+ triggerAllUpdates()
280
+ })
281
+ disposeInitialSync = () => {
282
+ current = false
283
+ subscription.unsubscribe()
284
+ }
285
+ const propagate = awaitQueryPropagation
286
+ void replication
287
+ .awaitInitialReplication()
288
+ .then(async () => {
289
+ if (!current) return
290
+ await propagate()
291
+ if (!current) return
292
+ initialSync = { status: "complete" }
293
+ disposeInitialSync()
294
+ triggerAllUpdates()
295
+ })
296
+ .catch((error: unknown) => {
297
+ if (!current) return
298
+ initialSync = { status: "error", error: asError(error) }
299
+ triggerAllUpdates()
300
+ })
301
+ }
302
+
303
+ // Prevents duplicate initialization starts across Strict Mode mounts.
251
304
  let initializationInProgress = false
252
305
 
253
306
  // Generation counter - incremented on cleanup() to invalidate in-progress initializations.
@@ -320,8 +373,8 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
320
373
  */
321
374
  async function cleanup(): Promise<void> {
322
375
  cleanupGeneration++
376
+ resetInitialSync()
323
377
  const previousState = persistentState
324
- // Unregister from the replication registry
325
378
  unregisterReplication(config.name)
326
379
 
327
380
  // Invalidate synchronously, before waiting for storage/socket teardown.
@@ -372,6 +425,7 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
372
425
 
373
426
  initializationInProgress = false
374
427
  cleanupGeneration++
428
+ resetInitialSync()
375
429
  moduleRxCollection = null
376
430
  replicationAuthority = null
377
431
  activeReplicationConfig = null
@@ -433,6 +487,8 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
433
487
  }
434
488
  const isCurrent = () => !isStaleInitialization(startGeneration)
435
489
 
490
+ resetInitialSync()
491
+ triggerAllUpdates()
436
492
  console.log(`Recreating ${config.name} replication...`)
437
493
 
438
494
  try {
@@ -483,7 +539,6 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
483
539
  console.log(`No local ${config.name} documents to remove`)
484
540
  }
485
541
 
486
- // 4. Build replication config
487
542
  const recipientId = await getRealtimeRecipientId(
488
543
  authority.session,
489
544
  expiresAt,
@@ -494,7 +549,8 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
494
549
  collection: rxCollection,
495
550
  pullQueryBuilder: config.pullQueryBuilder,
496
551
  deletedField: config.deletedField,
497
- replicationIdentifier: config.name,
552
+ replicationIdentifier: config.replicationIdentifier ?? config.name,
553
+ streamMode: config.streamMode ?? "documents",
498
554
  pullResultKey: config.pullResultKey,
499
555
  appSyncChannel: config.appSyncChannel,
500
556
  graphqlEndpoint: runtimeConfig.graphqlEndpoint,
@@ -519,7 +575,6 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
519
575
  : { pushQueryBuilder: undefined, pushResultKey: undefined }),
520
576
  }
521
577
 
522
- // 5. Create new replication
523
578
  console.log(`Creating new ${config.name} replication...`)
524
579
  const newReplicationState = await createReplication(replicationConfig)
525
580
  if (!isCurrent()) {
@@ -537,9 +592,9 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
537
592
  promise: persistentState.promise,
538
593
  }
539
594
 
595
+ observeInitialSync(newReplicationState)
540
596
  console.log(`${config.name} replication recreated successfully`)
541
597
 
542
- // 7. Trigger re-render if callback provided
543
598
  if (forceUpdate) {
544
599
  forceUpdate()
545
600
  }
@@ -574,6 +629,7 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
574
629
  replicationAuthority = { session, expiresAt }
575
630
  return
576
631
  }
632
+ disposeInitialSync()
577
633
  const generation = ++cleanupGeneration
578
634
  const isCurrent = () => !isStaleInitialization(generation)
579
635
  // Invalidate old requests before waiting for socket/storage cancellation.
@@ -594,6 +650,7 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
594
650
  replicationAuthority = { session, expiresAt }
595
651
  activeReplicationConfig = nextConfig
596
652
  persistentState = { ...previousState, replicationState }
653
+ observeInitialSync(replicationState)
597
654
  triggerAllUpdates()
598
655
  }
599
656
 
@@ -658,7 +715,6 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
658
715
  useEffect(() => {
659
716
  let cancelled = false
660
717
 
661
- // Early return if RxDB not ready
662
718
  if (!db || !rxCollection) {
663
719
  return
664
720
  }
@@ -711,7 +767,8 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
711
767
  cacheScope: sessionCacheScope,
712
768
  pullQueryBuilder: config.pullQueryBuilder,
713
769
  deletedField: config.deletedField,
714
- replicationIdentifier: config.name,
770
+ replicationIdentifier: config.replicationIdentifier ?? config.name,
771
+ streamMode: config.streamMode ?? "documents",
715
772
  pullResultKey: config.pullResultKey,
716
773
  appSyncChannel: config.appSyncChannel,
717
774
  graphqlEndpoint,
@@ -768,12 +825,32 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
768
825
  // replication stay alive and proceed to update module state to "ready".
769
826
  // The second mount will see status != "waiting-for-rxdb" and skip initialization.
770
827
 
771
- const collection: Collection<TDoc, string> = createCollection(
772
- rxdbCollectionOptions({
773
- rxCollection,
774
- startSync: true,
775
- }),
776
- )
828
+ const options = rxdbCollectionOptions({
829
+ rxCollection,
830
+ startSync: true,
831
+ })
832
+ const pendingCommits = new Set<Promise<unknown>>()
833
+ const collection: Collection<TDoc, string> = createCollection({
834
+ ...options,
835
+ sync: {
836
+ ...options.sync,
837
+ sync: (params) =>
838
+ options.sync.sync({
839
+ ...params,
840
+ commit: (signal) => {
841
+ const receipt = params.commit(signal)
842
+ if (receipt !== true) {
843
+ pendingCommits.add(receipt)
844
+ void receipt.then(
845
+ () => pendingCommits.delete(receipt),
846
+ () => pendingCommits.delete(receipt),
847
+ )
848
+ }
849
+ return receipt
850
+ },
851
+ }),
852
+ },
853
+ })
777
854
 
778
855
  if (config.createIndexes) {
779
856
  config.createIndexes(collection)
@@ -804,7 +881,6 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
804
881
  console.error("Unexpected state during initialization completion")
805
882
  }
806
883
 
807
- // Store in singleton
808
884
  persistentState = {
809
885
  status: "ready",
810
886
  collection,
@@ -816,8 +892,15 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
816
892
  // Store rxCollection at module level for registry access
817
893
  moduleRxCollection = rxCollection
818
894
  activeReplicationConfig = resolvedConfig
895
+ awaitQueryPropagation = async () => {
896
+ // RxDB first-in-sync includes persistence and its change events.
897
+ // The adapter can still be buffering its local scan or applying
898
+ // asynchronous TanStack transactions. Await their actual receipts.
899
+ await collection.preload()
900
+ await Promise.all([...pendingCommits])
901
+ }
902
+ observeInitialSync(replicationState)
819
903
 
820
- // Clear the in-progress flag now that we're done
821
904
  initializationInProgress = false
822
905
 
823
906
  // Every mounted Provider shares this singleton state. Notify all of
@@ -850,7 +933,6 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
850
933
  promise: persistentState.promise,
851
934
  }
852
935
 
853
- // Clear the in-progress flag on error
854
936
  initializationInProgress = false
855
937
 
856
938
  // Ensure the app-level recovery surface updates even when another
@@ -881,7 +963,6 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
881
963
  promise: persistentState.promise,
882
964
  }
883
965
 
884
- // Clear the in-progress flag on error
885
966
  initializationInProgress = false
886
967
 
887
968
  triggerAllUpdates()
@@ -1062,6 +1143,16 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
1062
1143
  const contextValue: CollectionContextValue<TDoc> = {
1063
1144
  db,
1064
1145
  rxCollection,
1146
+ initialSync,
1147
+ retryInitialSync: () => {
1148
+ if (activeScopeKey === scopeKey && persistentState.status === "ready") {
1149
+ if (initialSync.status === "error") {
1150
+ initialSync = { status: "loading" }
1151
+ triggerAllUpdates()
1152
+ }
1153
+ persistentState.replicationState.reSync()
1154
+ }
1155
+ },
1065
1156
  state: persistentState,
1066
1157
  collectionPromise: getCollectionPromise(),
1067
1158
  recreateReplication: recreateReplicationCallback,
@@ -14,7 +14,7 @@ import type {
14
14
  */
15
15
 
16
16
  // Derive TypeScript type from Effect Schema (encoded form for JSON storage)
17
- export type DraftProcessExecutionDocType = ES.Schema.Encoded<
17
+ export type DraftProcessExecutionDocType = ES.Codec.Encoded<
18
18
  typeof DraftProcessExecutionSchema
19
19
  >
20
20
 
@@ -44,22 +44,15 @@ export const migrationStrategies = {
44
44
  4: (oldDoc: unknown) => oldDoc,
45
45
  // Migration from version 4 to 5: remove updatedAt index
46
46
  5: (oldDoc: unknown) => oldDoc,
47
- // Migration from version 5 to 6
48
47
  6: (oldDoc: unknown) => oldDoc,
49
- // Migration from version 6 to 7
50
48
  7: (oldDoc: unknown) => ({
51
49
  ...(oldDoc as Record<string, unknown>),
52
50
  state: {},
53
51
  }),
54
- // Migration from version 7 to 8
55
52
  8: (oldDoc: unknown) => oldDoc,
56
- // Migration from version 8 to 9
57
53
  9: (oldDoc: unknown) => oldDoc,
58
- // Migration from version 9 to 10
59
54
  10: (oldDoc: unknown) => oldDoc,
60
- // Migration from version 10 to 11
61
55
  11: (oldDoc: unknown) => oldDoc,
62
- // Migration from version 11 to 12
63
56
  12: (oldDoc: unknown) => oldDoc,
64
57
  // Migration from version 12 to 13: add startStepPath field - delete existing documents
65
58
  13: () => null,
@@ -20,12 +20,12 @@ import type {
20
20
  const EXECUTION_SYNC_WEEKS = 5
21
21
 
22
22
  // Derive TypeScript type from Effect Schema (encoded form for JSON storage)
23
- export type ExecutionDocType = ES.Schema.Encoded<typeof ExecutionSchema>
23
+ export type ExecutionDocType = ES.Codec.Encoded<typeof ExecutionSchema>
24
24
 
25
25
  // Use pre-generated RxDB-compatible JSON Schema (generated by cli/generate-rxdb)
26
26
  export const executionSchema: RxJsonSchema<ExecutionDocType> = {
27
27
  title: "Executions",
28
- version: 14,
28
+ version: 16,
29
29
  primaryKey: "id",
30
30
  type: "object",
31
31
  additionalProperties: false,
@@ -36,6 +36,8 @@ export const executionSchema: RxJsonSchema<ExecutionDocType> = {
36
36
  }
37
37
 
38
38
  export const migrationStrategies = {
39
+ 16: (oldDoc: ExecutionDocType) => oldDoc, // Allow interrupted steps.
40
+ 15: () => null, // Repull durable deadline activity.
39
41
  // New terminal outcome and server-owned refusal reasons.
40
42
  14: () => null,
41
43
  // Repull server-owned execution scheduling metadata and capabilities.
@@ -115,6 +117,7 @@ export const pullQueryBuilder = (
115
117
  path
116
118
  status
117
119
  failureReason
120
+ deadlineActivity
118
121
  notStartedReason
119
122
  role {
120
123
  id
@@ -185,6 +188,7 @@ export const pullStreamQueryBuilder = () => {
185
188
  path
186
189
  status
187
190
  failureReason
191
+ deadlineActivity
188
192
  notStartedReason
189
193
  role {
190
194
  id
@@ -6,6 +6,7 @@ import {
6
6
  deletedField,
7
7
  pullQueryBuilder,
8
8
  pullStreamQueryBuilder,
9
+ replicationIdentifier,
9
10
  } from "./process.ts"
10
11
 
11
12
  const {
@@ -14,8 +15,10 @@ const {
14
15
  cleanup: cleanupProcessCollection,
15
16
  } = createCollectionProvider<ProcessDocType>({
16
17
  name: "Process",
18
+ streamMode: "resync",
17
19
  pullQueryBuilder,
18
20
  pullStreamQueryBuilder,
21
+ replicationIdentifier,
19
22
  deletedField,
20
23
  appSyncChannel: "/rxdb/collection/process",
21
24
  pullResultKey: "pullProcess",
@@ -14,12 +14,12 @@ import type {
14
14
  */
15
15
 
16
16
  // Derive TypeScript type from Effect Schema (encoded form for JSON storage)
17
- export type ProcessDocType = ES.Schema.Encoded<typeof ProcessSchema>
17
+ export type ProcessDocType = ES.Codec.Encoded<typeof ProcessSchema>
18
18
 
19
19
  // Use pre-generated RxDB-compatible JSON Schema (generated by cli/generate-rxdb)
20
20
  export const processSchema: RxJsonSchema<ProcessDocType> = {
21
21
  title: "Processes",
22
- version: 3,
22
+ version: 4,
23
23
  primaryKey: "id",
24
24
  type: "object",
25
25
  additionalProperties: false,
@@ -29,7 +29,13 @@ export const processSchema: RxJsonSchema<ProcessDocType> = {
29
29
  required: processRxdbSchema.required as StringKeys<ProcessDocType>[],
30
30
  }
31
31
 
32
+ export const replicationIdentifier = "Process-visibility-v1"
33
+
32
34
  export const migrationStrategies = {
35
+ // Pre-history caches cannot prove prior entitlement. Rebuild only this
36
+ // server-owned collection in the current authenticated scope, then full-pull
37
+ // current access to establish server-side history (never upload cached IDs).
38
+ 4: () => null,
33
39
  // Repull server-owned execution scheduling metadata and capabilities.
34
40
  3: () => null,
35
41
  // Version 1: Added startStepPath field - remove old docs, they'll be pulled fresh
@@ -6,6 +6,7 @@ import type {
6
6
  import { newRxError } from "rxdb/plugins/core"
7
7
  import { replicateRxCollection } from "rxdb/plugins/replication"
8
8
  import { replicateGraphQL } from "rxdb/plugins/replication-graphql"
9
+ import { map } from "rxjs"
9
10
  import type { Session } from "../../../../modules/auth-session/src/index.ts"
10
11
  import { isRealtimeRecipientId } from "../../../../modules/auth-session/src/lib/realtime-recipient.ts"
11
12
  import { AppSyncEventsAdapter } from "../appsync-events/adapter.ts"
@@ -14,6 +15,8 @@ import { matchesRealtimeSessionToken } from "../auth/realtime-session-token.ts"
14
15
  import type { PullCheckpoint } from "../generated/gql/graphql.ts"
15
16
  import { createGraphQLStream } from "./graphql-stream.ts"
16
17
 
18
+ const PULL_BATCH_SIZE = 100
19
+
17
20
  /**
18
21
  * Base type for all RxDB documents - must have id and updatedAt
19
22
  */
@@ -58,6 +61,8 @@ interface BaseReplicationConfig<TDoc extends RxDbDocumentBase> {
58
61
  * Unique identifier for this replication (e.g., "draft-process-execution", "process")
59
62
  */
60
63
  replicationIdentifier: string
64
+ /** Unordered notifications cannot advance a durable pull checkpoint. */
65
+ streamMode?: "documents" | "resync"
61
66
 
62
67
  /**
63
68
  * Key to extract pull result from GraphQL response (e.g., "pullDraftProcessExecution", "pullProcess")
@@ -137,7 +142,7 @@ const createGraphQLReplication = <TDoc extends RxDbDocumentBase>(
137
142
  SyncOptionsGraphQL<TDoc, PullCheckpoint>["pull"]
138
143
  > = {
139
144
  queryBuilder: config.pullQueryBuilder,
140
- batchSize: 50,
145
+ batchSize: PULL_BATCH_SIZE,
141
146
  }
142
147
 
143
148
  const baseConfig: SyncOptionsGraphQL<TDoc, PullCheckpoint> = {
@@ -210,7 +215,11 @@ const createGraphQLReplication = <TDoc extends RxDbDocumentBase>(
210
215
  : undefined
211
216
  // Own the stream subscription lifecycle without replacing the RxDB state,
212
217
  // documents, or checkpoints when graphql-ws sends a terminal frame.
213
- if (stream && replication.pull) replication.pull.stream$ = stream.stream$
218
+ if (stream && replication.pull)
219
+ replication.pull.stream$ =
220
+ config.streamMode === "resync"
221
+ ? stream.stream$.pipe(map((): "RESYNC" => "RESYNC"))
222
+ : stream.stream$
214
223
  const cancel = replication.cancel.bind(replication)
215
224
  replication.cancel = () => {
216
225
  stream?.close()
@@ -284,8 +293,11 @@ const createAppSyncEventsReplication = async <TDoc extends RxDbDocumentBase>(
284
293
  deletedField: config.deletedField,
285
294
  pull: {
286
295
  handler: pullHandler,
287
- batchSize: 50,
288
- stream$: eventsAdapter.getStream(),
296
+ batchSize: PULL_BATCH_SIZE,
297
+ stream$:
298
+ config.streamMode === "resync"
299
+ ? eventsAdapter.getStream().pipe(map((): "RESYNC" => "RESYNC"))
300
+ : eventsAdapter.getStream(),
289
301
  },
290
302
  live: true,
291
303
  retryTime: 10000,
@@ -14,7 +14,7 @@ import type {
14
14
  */
15
15
 
16
16
  // Derive TypeScript type from Effect Schema (encoded form for JSON storage)
17
- export type TodoDocType = ES.Schema.Encoded<typeof TodoSchema>
17
+ export type TodoDocType = ES.Codec.Encoded<typeof TodoSchema>
18
18
 
19
19
  // Use pre-generated RxDB-compatible JSON Schema (generated by cli/generate-rxdb)
20
20
  export const todoSchema: RxJsonSchema<TodoDocType> = {
@@ -0,0 +1,4 @@
1
+ import { Effect } from "effect"
2
+ import { notFound } from "next/navigation"
3
+
4
+ export const NotFound: Effect.Effect<never> = Effect.sync(notFound)
@@ -0,0 +1,29 @@
1
+ import { Cause, Effect, Exit, type Layer } from "effect"
2
+ import { unstable_rethrow } from "next/navigation"
3
+
4
+ /** Each invocation owns its layers and finalizers, including on navigation. */
5
+ export const makePageRuntime = <R, E>(
6
+ name: string,
7
+ layer: Layer.Layer<R, E>,
8
+ ) => ({
9
+ build:
10
+ <Args extends unknown[], A, E2>(
11
+ handler: (...args: Args) => Effect.Effect<A, E2, R>,
12
+ ) =>
13
+ async (...args: Args): Promise<A> => {
14
+ const exit = await Effect.runPromiseExit(
15
+ Effect.suspend(() => handler(...args)).pipe(
16
+ Effect.withSpan(name),
17
+ Effect.provide(layer),
18
+ ),
19
+ )
20
+ if (Exit.isSuccess(exit)) return exit.value
21
+ // Framework control flow must retain its original exception, even when
22
+ // another failure occurs during scope finalization.
23
+ for (const reason of exit.cause.reasons) {
24
+ if (Cause.isDieReason(reason)) unstable_rethrow(reason.defect)
25
+ else if (Cause.isFailReason(reason)) unstable_rethrow(reason.error)
26
+ }
27
+ throw Cause.squash(exit.cause)
28
+ },
29
+ })
@@ -1,15 +1,19 @@
1
+ import { NumberFromString } from "../../../../modules/form-schema/src/index.ts"
1
2
  import "server-only"
2
- import {
3
- decodeParamsUnknown,
4
- decodeSearchParamsUnknown,
5
- } from "@mcrovero/effect-nextjs/Params"
6
- import { Schema as ES } from "effect"
3
+ import { Schema as ES, Effect } from "effect"
7
4
 
8
- /**
9
- * Re-export param validation utilities from @mcrovero/effect-nextjs
10
- * for easier access throughout the application.
11
- */
12
- export { decodeParamsUnknown, decodeSearchParamsUnknown }
5
+ type NextParams = Promise<Record<string, string | string[] | undefined>>
6
+
7
+ export const decodeParamsUnknown =
8
+ <S extends ES.Constraint>(schema: S) =>
9
+ (
10
+ params: NextParams,
11
+ ): Effect.Effect<S["Type"], ES.SchemaError, S["DecodingServices"]> =>
12
+ Effect.promise(() => params).pipe(
13
+ Effect.flatMap(ES.decodeUnknownEffect(schema)),
14
+ )
15
+
16
+ export const decodeSearchParamsUnknown = decodeParamsUnknown
13
17
 
14
18
  /**
15
19
  * Common route parameter schemas for reuse across pages.
@@ -43,8 +47,10 @@ export const ExecutionIdParams = ES.Struct({
43
47
  * Schema for validating pagination search parameters.
44
48
  */
45
49
  export const PaginationSearchParams = ES.Struct({
46
- page: ES.NumberFromString.pipe(ES.optionalWith({ default: () => 1 })),
47
- pageSize: ES.NumberFromString.pipe(ES.optionalWith({ default: () => 10 })),
50
+ page: NumberFromString.pipe(ES.withDecodingDefaultType(Effect.succeed(1))),
51
+ pageSize: NumberFromString.pipe(
52
+ ES.withDecodingDefaultType(Effect.succeed(10)),
53
+ ),
48
54
  })
49
55
 
50
56
  /**
@@ -5,7 +5,7 @@ import { StdoutJsonLoggerLive } from "../../../../modules/effect-json-logger/src
5
5
  export const LoggerLive =
6
6
  process.env["NODE_ENV"] === "production"
7
7
  ? StdoutJsonLoggerLive
8
- : Logger.pretty
8
+ : Logger.layer([Logger.consolePretty()])
9
9
 
10
10
  export const runEffect = <A, E>(
11
11
  effect: Effect.Effect<A, E, never>,
@@ -1,8 +1,8 @@
1
1
  import "server-only"
2
- import { Tracer as OtelTracer, Resource } from "@effect/opentelemetry"
3
- import { Next } from "@mcrovero/effect-nextjs"
4
- import { Effect, FiberRef, Layer } from "effect"
2
+ import { OtelTracer, Resource } from "@effect/opentelemetry"
3
+ import { Effect, Layer } from "effect"
5
4
  import { connection } from "next/server"
5
+ import { makePageRuntime } from "./page-runtime.ts"
6
6
  import { LoggerLive } from "./run-effect.ts"
7
7
  import { AccessToken, AccessTokenLive } from "./services/access-token.ts"
8
8
  import { CedarAuthorizationLayer } from "./services/authorization.ts"
@@ -34,8 +34,6 @@ const otelRegistration = process.env["AWS_LAMBDA_FUNCTION_NAME"]
34
34
  *
35
35
  * OtelTracer.layerGlobal picks up the global TracerProvider and configures the
36
36
  * Effect fiber tracer so that Effect.withSpan creates real OTEL spans.
37
- *
38
- * Pattern from: https://github.com/mcrovero/effect-nextjs#opentelemetry
39
37
  */
40
38
  const layerTracer = OtelTracer.layerGlobal.pipe(
41
39
  Layer.provide(Resource.layer({ serviceName: SERVICE_NAME })),
@@ -45,11 +43,10 @@ const layerTracer = OtelTracer.layerGlobal.pipe(
45
43
  * Application-wide Effect runtime layer.
46
44
  * This combines all service layers needed by the application.
47
45
  *
48
- * Note: All layers must be stateless as per @mcrovero/effect-nextjs requirements.
49
- * For stateful layers, use globalValue with ManagedRuntime.
46
+ * Layers are acquired and released within each page invocation.
50
47
  */
51
48
  export const AppLive = Layer.mergeAll(
52
- AccessTokenLive, // Provides FiberRef for access token
49
+ AccessTokenLive, // Provides request-local service for access token
53
50
  GraphQLServiceLive, // Depends on AccessToken at runtime
54
51
  FormValidationServiceLive,
55
52
  LoggerLive,
@@ -63,9 +60,8 @@ export const AppLive = Layer.mergeAll(
63
60
  * Pages using this layer should handle errors gracefully.
64
61
  */
65
62
  export const AppWithAuthorizationLive: Layer.Layer<
66
- | Layer.Layer.Success<typeof AppLive>
67
- | Layer.Layer.Success<typeof CedarAuthorizationLayer>,
68
- Layer.Layer.Error<typeof CedarAuthorizationLayer>
63
+ Layer.Success<typeof AppLive> | Layer.Success<typeof CedarAuthorizationLayer>,
64
+ Layer.Error<typeof CedarAuthorizationLayer>
69
65
  > = Layer.mergeAll(AppLive, CedarAuthorizationLayer)
70
66
 
71
67
  /**
@@ -80,7 +76,7 @@ const AppWithAuthorizationLiveWithTracer = AppWithAuthorizationLive.pipe(
80
76
 
81
77
  /**
82
78
  * Wrapper that retrieves the access token from session cookies and sets it
83
- * in the AccessToken FiberRef before running the page effect.
79
+ * in the AccessToken request-local service before running the page effect.
84
80
  *
85
81
  * This follows the same pattern as RequestTime/UserDetails in the backend GraphQL API.
86
82
  *
@@ -94,16 +90,16 @@ const withAccessToken = <A, E, R>(
94
90
  Effect.tapError((error) =>
95
91
  Effect.logError("Failed to get session with token", error),
96
92
  ),
97
- Effect.catchAll(() => Effect.succeed(null)),
93
+ Effect.catch(() => Effect.succeed(null)),
94
+ )
95
+ return yield* pageEffect.pipe(
96
+ Effect.provideService(AccessToken, {
97
+ token: session?.accessToken ?? null,
98
+ }),
98
99
  )
99
- const accessTokenRef = yield* AccessToken
100
-
101
- yield* FiberRef.set(accessTokenRef, { token: session?.accessToken ?? null })
102
-
103
- return yield* pageEffect
104
100
  })
105
101
 
106
- const nextBasePage = Next.make("BasePage", AppLiveWithTracer)
102
+ const nextBasePage = makePageRuntime("BasePage", AppLiveWithTracer)
107
103
 
108
104
  /**
109
105
  * Base page runtime for server-side pages with automatic authentication.
@@ -114,7 +110,7 @@ export const BasePage = {
114
110
  build: <Args extends unknown[], A>(
115
111
  pageEffect: (
116
112
  ...args: Args
117
- ) => Effect.Effect<A, never, Layer.Layer.Success<typeof AppLive>>,
113
+ ) => Effect.Effect<A, never, Layer.Success<typeof AppLive>>,
118
114
  ) => {
119
115
  const wrappedEffect = (...args: Args) =>
120
116
  withAccessToken(pageEffect(...args))
@@ -128,7 +124,7 @@ export const BasePage = {
128
124
  },
129
125
  }
130
126
 
131
- const nextBasePageWithAuth = Next.make(
127
+ const nextBasePageWithAuth = makePageRuntime(
132
128
  "BasePageWithAuth",
133
129
  AppWithAuthorizationLiveWithTracer,
134
130
  )
@@ -146,7 +142,7 @@ export const BasePageWithAuthorization = {
146
142
  ) => Effect.Effect<
147
143
  A,
148
144
  never,
149
- Layer.Layer.Success<typeof AppWithAuthorizationLive>
145
+ Layer.Success<typeof AppWithAuthorizationLive>
150
146
  >,
151
147
  ) => {
152
148
  const wrappedEffect = (...args: Args) =>
@@ -165,4 +161,4 @@ export const BasePageWithAuthorization = {
165
161
  * Base layout runtime for layouts.
166
162
  * Layouts can use the same runtime infrastructure as pages.
167
163
  */
168
- export const BaseLayout = Next.make("BaseLayout", AppLiveWithTracer)
164
+ export const BaseLayout = makePageRuntime("BaseLayout", AppLiveWithTracer)