@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
@@ -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.
@@ -338,7 +391,8 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
338
391
  try {
339
392
  await Promise.all([
340
393
  previousState.replicationState.cancel(),
341
- previousState.collection.cleanup(),
394
+ // Logout runs while the Dashboard's live queries are still mounted.
395
+ previousState.collection.cleanup({ dependents: true }),
342
396
  ])
343
397
  } catch (error) {
344
398
  console.error(
@@ -372,6 +426,7 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
372
426
 
373
427
  initializationInProgress = false
374
428
  cleanupGeneration++
429
+ resetInitialSync()
375
430
  moduleRxCollection = null
376
431
  replicationAuthority = null
377
432
  activeReplicationConfig = null
@@ -381,7 +436,7 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
381
436
  if (previousState.status === "ready") {
382
437
  return Promise.all([
383
438
  previousState.replicationState.cancel(),
384
- previousState.collection.cleanup(),
439
+ previousState.collection.cleanup({ dependents: true }),
385
440
  ])
386
441
  .then(() => undefined)
387
442
  .catch((error: unknown) => {
@@ -433,6 +488,8 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
433
488
  }
434
489
  const isCurrent = () => !isStaleInitialization(startGeneration)
435
490
 
491
+ resetInitialSync()
492
+ triggerAllUpdates()
436
493
  console.log(`Recreating ${config.name} replication...`)
437
494
 
438
495
  try {
@@ -483,7 +540,6 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
483
540
  console.log(`No local ${config.name} documents to remove`)
484
541
  }
485
542
 
486
- // 4. Build replication config
487
543
  const recipientId = await getRealtimeRecipientId(
488
544
  authority.session,
489
545
  expiresAt,
@@ -494,7 +550,8 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
494
550
  collection: rxCollection,
495
551
  pullQueryBuilder: config.pullQueryBuilder,
496
552
  deletedField: config.deletedField,
497
- replicationIdentifier: config.name,
553
+ replicationIdentifier: config.replicationIdentifier ?? config.name,
554
+ streamMode: config.streamMode ?? "documents",
498
555
  pullResultKey: config.pullResultKey,
499
556
  appSyncChannel: config.appSyncChannel,
500
557
  graphqlEndpoint: runtimeConfig.graphqlEndpoint,
@@ -519,7 +576,6 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
519
576
  : { pushQueryBuilder: undefined, pushResultKey: undefined }),
520
577
  }
521
578
 
522
- // 5. Create new replication
523
579
  console.log(`Creating new ${config.name} replication...`)
524
580
  const newReplicationState = await createReplication(replicationConfig)
525
581
  if (!isCurrent()) {
@@ -537,9 +593,9 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
537
593
  promise: persistentState.promise,
538
594
  }
539
595
 
596
+ observeInitialSync(newReplicationState)
540
597
  console.log(`${config.name} replication recreated successfully`)
541
598
 
542
- // 7. Trigger re-render if callback provided
543
599
  if (forceUpdate) {
544
600
  forceUpdate()
545
601
  }
@@ -574,6 +630,7 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
574
630
  replicationAuthority = { session, expiresAt }
575
631
  return
576
632
  }
633
+ disposeInitialSync()
577
634
  const generation = ++cleanupGeneration
578
635
  const isCurrent = () => !isStaleInitialization(generation)
579
636
  // Invalidate old requests before waiting for socket/storage cancellation.
@@ -594,6 +651,7 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
594
651
  replicationAuthority = { session, expiresAt }
595
652
  activeReplicationConfig = nextConfig
596
653
  persistentState = { ...previousState, replicationState }
654
+ observeInitialSync(replicationState)
597
655
  triggerAllUpdates()
598
656
  }
599
657
 
@@ -658,7 +716,6 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
658
716
  useEffect(() => {
659
717
  let cancelled = false
660
718
 
661
- // Early return if RxDB not ready
662
719
  if (!db || !rxCollection) {
663
720
  return
664
721
  }
@@ -711,7 +768,8 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
711
768
  cacheScope: sessionCacheScope,
712
769
  pullQueryBuilder: config.pullQueryBuilder,
713
770
  deletedField: config.deletedField,
714
- replicationIdentifier: config.name,
771
+ replicationIdentifier: config.replicationIdentifier ?? config.name,
772
+ streamMode: config.streamMode ?? "documents",
715
773
  pullResultKey: config.pullResultKey,
716
774
  appSyncChannel: config.appSyncChannel,
717
775
  graphqlEndpoint,
@@ -768,12 +826,32 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
768
826
  // replication stay alive and proceed to update module state to "ready".
769
827
  // The second mount will see status != "waiting-for-rxdb" and skip initialization.
770
828
 
771
- const collection: Collection<TDoc, string> = createCollection(
772
- rxdbCollectionOptions({
773
- rxCollection,
774
- startSync: true,
775
- }),
776
- )
829
+ const options = rxdbCollectionOptions({
830
+ rxCollection,
831
+ startSync: true,
832
+ })
833
+ const pendingCommits = new Set<Promise<unknown>>()
834
+ const collection: Collection<TDoc, string> = createCollection({
835
+ ...options,
836
+ sync: {
837
+ ...options.sync,
838
+ sync: (params) =>
839
+ options.sync.sync({
840
+ ...params,
841
+ commit: (signal) => {
842
+ const receipt = params.commit(signal)
843
+ if (receipt !== true) {
844
+ pendingCommits.add(receipt)
845
+ void receipt.then(
846
+ () => pendingCommits.delete(receipt),
847
+ () => pendingCommits.delete(receipt),
848
+ )
849
+ }
850
+ return receipt
851
+ },
852
+ }),
853
+ },
854
+ })
777
855
 
778
856
  if (config.createIndexes) {
779
857
  config.createIndexes(collection)
@@ -804,7 +882,6 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
804
882
  console.error("Unexpected state during initialization completion")
805
883
  }
806
884
 
807
- // Store in singleton
808
885
  persistentState = {
809
886
  status: "ready",
810
887
  collection,
@@ -816,8 +893,15 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
816
893
  // Store rxCollection at module level for registry access
817
894
  moduleRxCollection = rxCollection
818
895
  activeReplicationConfig = resolvedConfig
896
+ awaitQueryPropagation = async () => {
897
+ // RxDB first-in-sync includes persistence and its change events.
898
+ // The adapter can still be buffering its local scan or applying
899
+ // asynchronous TanStack transactions. Await their actual receipts.
900
+ await collection.preload()
901
+ await Promise.all([...pendingCommits])
902
+ }
903
+ observeInitialSync(replicationState)
819
904
 
820
- // Clear the in-progress flag now that we're done
821
905
  initializationInProgress = false
822
906
 
823
907
  // Every mounted Provider shares this singleton state. Notify all of
@@ -850,7 +934,6 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
850
934
  promise: persistentState.promise,
851
935
  }
852
936
 
853
- // Clear the in-progress flag on error
854
937
  initializationInProgress = false
855
938
 
856
939
  // Ensure the app-level recovery surface updates even when another
@@ -881,7 +964,6 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
881
964
  promise: persistentState.promise,
882
965
  }
883
966
 
884
- // Clear the in-progress flag on error
885
967
  initializationInProgress = false
886
968
 
887
969
  triggerAllUpdates()
@@ -1062,6 +1144,16 @@ export function createCollectionProvider<TDoc extends RxDbDocumentBase>(
1062
1144
  const contextValue: CollectionContextValue<TDoc> = {
1063
1145
  db,
1064
1146
  rxCollection,
1147
+ initialSync,
1148
+ retryInitialSync: () => {
1149
+ if (activeScopeKey === scopeKey && persistentState.status === "ready") {
1150
+ if (initialSync.status === "error") {
1151
+ initialSync = { status: "loading" }
1152
+ triggerAllUpdates()
1153
+ }
1154
+ persistentState.replicationState.reSync()
1155
+ }
1156
+ },
1065
1157
  state: persistentState,
1066
1158
  collectionPromise: getCollectionPromise(),
1067
1159
  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
@@ -102,7 +102,27 @@ export function createGraphQLStream<TDoc>({
102
102
  active = false
103
103
  unsubscribe()
104
104
  removeConnected()
105
- removeGraphQLWebSocketRef(url)
105
+ const shared = GRAPHQL_WEBSOCKET_BY_URL.get(url)
106
+ if (shared?.refCount !== 1) {
107
+ removeGraphQLWebSocketRef(url)
108
+ return
109
+ }
110
+ // RxDB drops the dispose promise on final release. Evict synchronously
111
+ // so the replacement gets a new client, then observe the pending retry.
112
+ shared.refCount = 0
113
+ GRAPHQL_WEBSOCKET_BY_URL.delete(url)
114
+ void Promise.resolve(client.dispose()).catch((error: unknown) => {
115
+ if (
116
+ typeof error === "object" &&
117
+ error !== null &&
118
+ "code" in error &&
119
+ error.code === 1000 &&
120
+ "reason" in error &&
121
+ error.reason === "All Subscriptions Gone"
122
+ )
123
+ return
124
+ onError(error)
125
+ })
106
126
  }
107
127
  },
108
128
  }
@@ -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> = {
@@ -1,12 +1,22 @@
1
1
  "use client"
2
2
 
3
3
  import { useQueryClient } from "@tanstack/react-query"
4
- import { useEffect, useEffectEvent } from "react"
4
+ import { usePathname } from "next/navigation"
5
+ import {
6
+ type ReactNode,
7
+ createContext,
8
+ useContext,
9
+ useEffect,
10
+ useEffectEvent,
11
+ useRef,
12
+ useState,
13
+ } from "react"
5
14
  import type { ImportCompletedPayload } from "./import-completed-events.ts"
6
15
  import {
7
16
  invalidateImportCompletedQueries,
8
17
  refreshImportCompletedCollections,
9
18
  } from "./import-completed-refresh.ts"
19
+ import { parseListReturnDestination } from "@/app/(protected)/lists/lib/list-refresh"
10
20
  import { useSession } from "@/components/auth-provider"
11
21
  import { useRuntimeConfig } from "@/components/config-provider"
12
22
 
@@ -26,10 +36,42 @@ const parseImportCompletedPayload = (
26
36
  }
27
37
  }
28
38
 
29
- export function DevImportCompletedQueryInvalidation() {
39
+ const ImportRevision = createContext<string | null>(null)
40
+
41
+ export const useDevImportRevision = () => useContext(ImportRevision)
42
+
43
+ export function DevImportCompletedProvider({
44
+ children,
45
+ }: {
46
+ children: ReactNode
47
+ }) {
30
48
  const queryClient = useQueryClient()
31
49
  const runtimeConfig = useRuntimeConfig()
32
50
  const session = useSession()
51
+ const pathname = usePathname()
52
+ const deferredProcessImport = useRef<ImportCompletedPayload | null>(null)
53
+ const lastEventId = useRef<string | null>(null)
54
+ const [revision, setRevision] = useState<string | null>(null)
55
+ const refreshImport = useEffectEvent((payload: ImportCompletedPayload) => {
56
+ void invalidateImportCompletedQueries(queryClient, payload)
57
+ void refreshImportCompletedCollections(
58
+ runtimeConfig,
59
+ session.userId,
60
+ payload,
61
+ )
62
+ })
63
+
64
+ // Refetching form defaults or recreating draft replication can reset inputs in a
65
+ // retained List's process dialog. Apply the latest import after leaving the form.
66
+ useEffect(() => {
67
+ if (
68
+ !pathname.startsWith("/processes/start/") &&
69
+ deferredProcessImport.current
70
+ ) {
71
+ refreshImport(deferredProcessImport.current)
72
+ deferredProcessImport.current = null
73
+ }
74
+ }, [pathname])
33
75
 
34
76
  const handleMessage = useEffectEvent((event: MessageEvent<string>) => {
35
77
  let payload: ImportCompletedPayload | null
@@ -40,12 +82,23 @@ export function DevImportCompletedQueryInvalidation() {
40
82
  }
41
83
 
42
84
  if (payload) {
43
- void invalidateImportCompletedQueries(queryClient, payload)
44
- void refreshImportCompletedCollections(
45
- runtimeConfig,
46
- session.userId,
47
- payload,
48
- )
85
+ if (event.lastEventId) {
86
+ if (event.lastEventId === lastEventId.current) return
87
+ // The first receipt establishes the baseline for this connection.
88
+ if (lastEventId.current !== null) setRevision(event.lastEventId)
89
+ lastEventId.current = event.lastEventId
90
+ }
91
+ const url = new URL(window.location.href)
92
+ if (
93
+ payload.processPaths.length &&
94
+ url.pathname.startsWith("/processes/start/") &&
95
+ parseListReturnDestination(url.searchParams.get("returnTo"), url.origin)
96
+ ) {
97
+ deferredProcessImport.current = payload
98
+ void invalidateImportCompletedQueries(queryClient, { processPaths: [] })
99
+ } else {
100
+ refreshImport(payload)
101
+ }
49
102
  }
50
103
  })
51
104
 
@@ -58,5 +111,9 @@ export function DevImportCompletedQueryInvalidation() {
58
111
  return () => events.close()
59
112
  }, [])
60
113
 
61
- return null
114
+ return (
115
+ <ImportRevision.Provider value={revision}>
116
+ {children}
117
+ </ImportRevision.Provider>
118
+ )
62
119
  }
@@ -8,14 +8,18 @@ export const invalidateImportCompletedQueries = (
8
8
  queryClient: QueryClient,
9
9
  payload: ImportCompletedPayload,
10
10
  ) => {
11
- if (payload.processPaths.length === 0) {
12
- return Promise.resolve()
13
- }
14
-
15
- return queryClient.invalidateQueries({
16
- queryKey: formMetadataQueryKey,
11
+ const lists = queryClient.invalidateQueries({
12
+ queryKey: ["availableLists"],
17
13
  refetchType: "active",
18
14
  })
15
+ if (payload.processPaths.length === 0) return lists
16
+ return Promise.all([
17
+ lists,
18
+ queryClient.invalidateQueries({
19
+ queryKey: formMetadataQueryKey,
20
+ refetchType: "active",
21
+ }),
22
+ ])
19
23
  }
20
24
 
21
25
  export const refreshImportCompletedCollections = async (
@@ -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)