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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/README.md +48 -253
  2. package/dist/authentication-server.mjs +52 -84
  3. package/dist/{chunk-yhzbn4vx.js → chunk-04r0t2mb.js} +34324 -49067
  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-352j1ayk.js → chunk-r5s2v669.js} +51753 -36263
  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 +145 -19
  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 +34 -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 +190 -51
  308. package/package.json +64 -62
  309. package/dist/chunk-6ntmymmx.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
@@ -1,7 +1,6 @@
1
1
  import * as path from "node:path"
2
- import { FileSystem } from "@effect/platform"
3
- import { NodeFileSystem } from "@effect/platform-node"
4
- import { Config, Context, Effect, Layer } from "effect"
2
+ import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem"
3
+ import { Config, Context, Effect, FileSystem, Layer } from "effect"
5
4
  import { PolicyLoadError, SchemaLoadError } from "../../../auth-policy/src/index.ts"
6
5
  import { PolicyWatcherService, makePolicyWatcherLayer } from "./policy-watcher.ts"
7
6
 
@@ -12,15 +11,13 @@ import { PolicyWatcherService, makePolicyWatcherLayer } from "./policy-watcher.t
12
11
  * policiesText is an array to support merging default policies with
13
12
  * custom org-specific policies.
14
13
  */
15
- export class LocalCedarConfig extends Context.Tag(
16
- "processfocus:internal-tag/auth-local-cedar/LocalCedarConfig",
17
- )<
14
+ export class LocalCedarConfig extends Context.Service<
18
15
  LocalCedarConfig,
19
16
  {
20
17
  readonly policiesText: readonly string[]
21
18
  readonly schemaText: string
22
19
  }
23
- >() {}
20
+ >()("processfocus:internal-tag/auth-local-cedar/LocalCedarConfig") {}
24
21
 
25
22
  /**
26
23
  * Resolve the path to a file within a package.
@@ -29,13 +26,15 @@ export class LocalCedarConfig extends Context.Tag(
29
26
  * Note: Uses indirect require.resolve via eval to prevent bundlers (Turbopack, etc.)
30
27
  * from attempting static analysis on the dynamic package name.
31
28
  */
32
- const resolvePackagePath = (packageName: string, relativePath: string) => {
33
- const packagedCedarRoot = process.env["PF_CEDAR_ROOT"]
29
+ const resolvePackagePath = (
30
+ packageName: string,
31
+ relativePath: string,
32
+ packagedCedarRoot: string | undefined,
33
+ ) => {
34
34
  if (packageName === "processfocus:internal-tag/auth-policy" && packagedCedarRoot) {
35
35
  return path.join(packagedCedarRoot, path.basename(relativePath))
36
36
  }
37
37
 
38
- // Find the package.json location
39
38
  // biome-ignore lint/security/noGlobalEval: Required to hide dynamic require.resolve from bundler static analysis
40
39
  const packageJsonPath = eval(
41
40
  `require.resolve("${packageName}/package.json")`,
@@ -57,14 +56,22 @@ export const DEFAULT_SCHEMA_PATH = "cedar/schema.cedarschema"
57
56
  /**
58
57
  * Get the resolved path to the default policies file
59
58
  */
60
- export const getDefaultPoliciesPath = () =>
61
- resolvePackagePath("processfocus:internal-tag/auth-policy", DEFAULT_POLICIES_PATH)
59
+ export const getDefaultPoliciesPath = (
60
+ packagedCedarRoot = process.env["PF_CEDAR_ROOT"],
61
+ ) =>
62
+ resolvePackagePath(
63
+ "processfocus:internal-tag/auth-policy",
64
+ DEFAULT_POLICIES_PATH,
65
+ packagedCedarRoot,
66
+ )
62
67
 
63
68
  /**
64
69
  * Get the resolved path to the default schema file
65
70
  */
66
- export const getDefaultSchemaPath = () =>
67
- resolvePackagePath("processfocus:internal-tag/auth-policy", DEFAULT_SCHEMA_PATH)
71
+ export const getDefaultSchemaPath = (
72
+ packagedCedarRoot = process.env["PF_CEDAR_ROOT"],
73
+ ) =>
74
+ resolvePackagePath("processfocus:internal-tag/auth-policy", DEFAULT_SCHEMA_PATH, packagedCedarRoot)
68
75
 
69
76
  /**
70
77
  * Create a config layer from file paths.
@@ -112,7 +119,17 @@ export const localCedarConfigFromPaths = (
112
119
  * which would fail in serverless environments where processfocus:internal-tag/auth-policy package.json isn't available.
113
120
  */
114
121
  export const LocalCedarConfigDefault = () =>
115
- localCedarConfigFromPaths(getDefaultPoliciesPath(), getDefaultSchemaPath())
122
+ Layer.unwrap(
123
+ Effect.gen(function* () {
124
+ const root = yield* Config.String("PF_CEDAR_ROOT").pipe(
125
+ Config.withDefault(""),
126
+ )
127
+ return localCedarConfigFromPaths(
128
+ getDefaultPoliciesPath(root),
129
+ getDefaultSchemaPath(root),
130
+ )
131
+ }),
132
+ )
116
133
 
117
134
  /**
118
135
  * Configuration layer that reads Cedar policies from a directory.
@@ -134,10 +151,10 @@ export const LocalCedarConfigFromEnvDir = Layer.provide(
134
151
  Effect.gen(function* () {
135
152
  const fs = yield* FileSystem.FileSystem
136
153
 
137
- const policiesDir = yield* Config.string("CEDAR_PATH")
154
+ const policiesDir = yield* Config.String("CEDAR_PATH")
138
155
 
139
156
  // List all .cedar and .cedarschema files in the directory
140
- const dirEntries = yield* fs.readDirectory(policiesDir)
157
+ const dirEntries = (yield* fs.readDirectory(policiesDir)).sort()
141
158
  const cedarFiles = dirEntries.filter((entry) => entry.endsWith(".cedar"))
142
159
  const schemaFiles = dirEntries.filter((entry) =>
143
160
  entry.endsWith(".cedarschema"),
@@ -150,7 +167,6 @@ export const LocalCedarConfigFromEnvDir = Layer.provide(
150
167
  })
151
168
  }
152
169
 
153
- // Load all policy files
154
170
  const policiesText = yield* Effect.forEach(cedarFiles, (file) => {
155
171
  const fullPath = path.join(policiesDir, file)
156
172
  return fs
@@ -162,7 +178,6 @@ export const LocalCedarConfigFromEnvDir = Layer.provide(
162
178
  )
163
179
  })
164
180
 
165
- // Load all schema files from the same directory
166
181
  const schemaTexts = yield* Effect.forEach(schemaFiles, (file) => {
167
182
  const fullPath = path.join(policiesDir, file)
168
183
  return fs
@@ -208,28 +223,34 @@ export const LocalCedarConfigStatic = (
208
223
  LocalCedarConfig,
209
224
  Effect.gen(function* () {
210
225
  const fs = yield* FileSystem.FileSystem
226
+ const root = yield* Config.String("PF_CEDAR_ROOT").pipe(
227
+ Config.withDefault(""),
228
+ )
211
229
 
212
- // Load default policies
213
230
  const defaultPoliciesText = yield* fs
214
- .readFileString(getDefaultPoliciesPath())
231
+ .readFileString(getDefaultPoliciesPath(root))
215
232
  .pipe(
216
233
  Effect.mapError(
217
234
  (cause) =>
218
- new PolicyLoadError({ path: getDefaultPoliciesPath(), cause }),
235
+ new PolicyLoadError({
236
+ path: getDefaultPoliciesPath(root),
237
+ cause,
238
+ }),
219
239
  ),
220
240
  )
221
241
 
222
- // Load default schema
223
242
  const defaultSchemaText = yield* fs
224
- .readFileString(getDefaultSchemaPath())
243
+ .readFileString(getDefaultSchemaPath(root))
225
244
  .pipe(
226
245
  Effect.mapError(
227
246
  (cause) =>
228
- new SchemaLoadError({ path: getDefaultSchemaPath(), cause }),
247
+ new SchemaLoadError({
248
+ path: getDefaultSchemaPath(root),
249
+ cause,
250
+ }),
229
251
  ),
230
252
  )
231
253
 
232
- // Load custom policies if provided
233
254
  const customPoliciesText = customPolicyPaths
234
255
  ? yield* Effect.forEach(customPolicyPaths, (policyPath) =>
235
256
  fs
@@ -287,60 +308,75 @@ export const LocalCedarConfigHotReload = (
287
308
  basePath: string,
288
309
  customPolicyFiles: readonly string[],
289
310
  customSchemaFiles?: readonly string[],
290
- ) => {
291
- // Resolve custom policy paths relative to basePath
292
- const resolvedCustomPaths = customPolicyFiles.map((f) =>
293
- require("node:path").resolve(basePath, f),
294
- )
295
-
296
- // Combine default policy path with custom paths - all will be watched
297
- const allPolicyPaths = [getDefaultPoliciesPath(), ...resolvedCustomPaths]
298
-
299
- // Create watcher for all policy files (default + custom)
300
- // Pass "/" as basePath since paths are already absolute
301
- const policyWatcherLayer = makePolicyWatcherLayer("/", allPolicyPaths)
302
-
303
- // Create config layer that gets policies from watcher and loads schema
304
- const configLayer = Layer.effect(
305
- LocalCedarConfig,
311
+ ) =>
312
+ Layer.unwrap(
306
313
  Effect.gen(function* () {
307
- const fs = yield* FileSystem.FileSystem
308
- const watcher = yield* PolicyWatcherService
309
- const policiesText = yield* watcher.currentPolicies
310
-
311
- // Load default schema (not watched - schema changes are rare and require restart)
312
- const defaultSchemaText = yield* fs
313
- .readFileString(getDefaultSchemaPath())
314
- .pipe(
315
- Effect.mapError(
316
- (cause) =>
317
- new SchemaLoadError({ path: getDefaultSchemaPath(), cause }),
318
- ),
319
- )
314
+ const root = yield* Config.String("PF_CEDAR_ROOT").pipe(
315
+ Config.withDefault(""),
316
+ )
317
+ // Resolve custom policy paths relative to basePath
318
+ const resolvedCustomPaths = customPolicyFiles.map((f) =>
319
+ require("node:path").resolve(basePath, f),
320
+ )
320
321
 
321
- // Load custom schema files and concatenate with default schema
322
- const customSchemaTexts = customSchemaFiles
323
- ? yield* Effect.forEach(customSchemaFiles, (schemaPath) =>
324
- fs
325
- .readFileString(schemaPath)
326
- .pipe(
327
- Effect.mapError(
328
- (cause) => new SchemaLoadError({ path: schemaPath, cause }),
329
- ),
322
+ // Combine default policy path with custom paths - all will be watched
323
+ const allPolicyPaths = [
324
+ getDefaultPoliciesPath(root),
325
+ ...resolvedCustomPaths,
326
+ ]
327
+
328
+ // Create watcher for all policy files (default + custom)
329
+ // Pass "/" as basePath since paths are already absolute
330
+ const policyWatcherLayer = makePolicyWatcherLayer("/", allPolicyPaths)
331
+
332
+ // Create config layer that gets policies from watcher and loads schema
333
+ const configLayer = Layer.effect(
334
+ LocalCedarConfig,
335
+ Effect.gen(function* () {
336
+ const fs = yield* FileSystem.FileSystem
337
+ const watcher = yield* PolicyWatcherService
338
+ const policiesText = yield* watcher.currentPolicies
339
+
340
+ // Load default schema (not watched - schema changes are rare and require restart)
341
+ const defaultSchemaText = yield* fs
342
+ .readFileString(getDefaultSchemaPath(root))
343
+ .pipe(
344
+ Effect.mapError(
345
+ (cause) =>
346
+ new SchemaLoadError({
347
+ path: getDefaultSchemaPath(root),
348
+ cause,
349
+ }),
330
350
  ),
351
+ )
352
+
353
+ // Load custom schema files and concatenate with default schema
354
+ const customSchemaTexts = customSchemaFiles
355
+ ? yield* Effect.forEach(customSchemaFiles, (schemaPath) =>
356
+ fs
357
+ .readFileString(schemaPath)
358
+ .pipe(
359
+ Effect.mapError(
360
+ (cause) =>
361
+ new SchemaLoadError({ path: schemaPath, cause }),
362
+ ),
363
+ ),
364
+ )
365
+ : []
366
+
367
+ // Concatenate schemas: different namespaces (e.g. PF and Org) can coexist in one string
368
+ const schemaText = [defaultSchemaText, ...customSchemaTexts].join(
369
+ "\n\n",
331
370
  )
332
- : []
333
371
 
334
- // Concatenate schemas: different namespaces (e.g. PF and Org) can coexist in one string
335
- const schemaText = [defaultSchemaText, ...customSchemaTexts].join("\n\n")
372
+ return { policiesText, schemaText }
373
+ }),
374
+ ).pipe(Layer.provide(NodeFileSystem.layer))
336
375
 
337
- return { policiesText, schemaText }
376
+ // Combine: ConfigLayer needs PolicyWatcherService, and we want to provide both
377
+ return Layer.provideMerge(
378
+ Layer.provide(configLayer, policyWatcherLayer),
379
+ policyWatcherLayer,
380
+ )
338
381
  }),
339
- ).pipe(Layer.provide(NodeFileSystem.layer))
340
-
341
- // Combine: ConfigLayer needs PolicyWatcherService, and we want to provide both
342
- return Layer.provideMerge(
343
- Layer.provide(configLayer, policyWatcherLayer),
344
- policyWatcherLayer,
345
382
  )
346
- }
@@ -1,15 +1,14 @@
1
1
  import { watch as watchFileSystem } from "node:fs"
2
2
  import * as path from "node:path"
3
- import { FileSystem } from "@effect/platform"
4
- import { NodeFileSystem } from "@effect/platform-node"
3
+ import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem"
5
4
  import {
6
5
  Context,
7
6
  Effect,
8
- Either,
7
+ FileSystem,
9
8
  Layer,
10
9
  PubSub,
11
10
  Ref,
12
- Runtime,
11
+ Result,
13
12
  Stream,
14
13
  } from "effect"
15
14
  import { PolicyLoadError } from "../../../auth-policy/src/index.ts"
@@ -34,9 +33,10 @@ export interface PolicyWatcher {
34
33
  readonly currentPolicies: Effect.Effect<readonly string[]>
35
34
  }
36
35
 
37
- export class PolicyWatcherService extends Context.Tag(
38
- "processfocus:internal-tag/auth-local-cedar/PolicyWatcherService",
39
- )<PolicyWatcherService, PolicyWatcher>() {}
36
+ export class PolicyWatcherService extends Context.Service<
37
+ PolicyWatcherService,
38
+ PolicyWatcher
39
+ >()("processfocus:internal-tag/auth-local-cedar/PolicyWatcherService") {}
40
40
 
41
41
  /**
42
42
  * Create a layer that watches policy files and provides current policy text.
@@ -49,14 +49,13 @@ export const makePolicyWatcherLayer = (
49
49
  policyFiles: readonly string[],
50
50
  ) =>
51
51
  Layer.provide(
52
- Layer.scoped(
52
+ Layer.effect(
53
53
  PolicyWatcherService,
54
54
  Effect.gen(function* () {
55
55
  const fs = yield* FileSystem.FileSystem
56
56
  const pubsub = yield* PubSub.unbounded<void>()
57
- const runtime = yield* Effect.runtime()
57
+ const runtime = yield* Effect.context()
58
58
 
59
- // Resolve absolute paths
60
59
  const absolutePaths = policyFiles.map((f) => path.resolve(basePath, f))
61
60
 
62
61
  // Group watched files by parent directory so file replacement saves
@@ -70,7 +69,6 @@ export const makePolicyWatcherLayer = (
70
69
  watchedFilesByDirectory.set(directoryPath, watchedFiles)
71
70
  }
72
71
 
73
- // Read all policy files
74
72
  const readPolicies = Effect.forEach(absolutePaths, (filePath) =>
75
73
  fs
76
74
  .readFileString(filePath)
@@ -81,7 +79,6 @@ export const makePolicyWatcherLayer = (
81
79
  ),
82
80
  )
83
81
 
84
- // Initial read
85
82
  const initialPolicies = yield* readPolicies
86
83
  const policiesRef = yield* Ref.make<readonly string[]>(initialPolicies)
87
84
 
@@ -93,17 +90,16 @@ export const makePolicyWatcherLayer = (
93
90
  Effect.gen(function* () {
94
91
  yield* Effect.log(`Cedar policy file changed: ${changedPath}`)
95
92
 
96
- // Try to reload all policies
97
- const reloadResult = yield* Effect.either(readPolicies)
93
+ const reloadResult = yield* Effect.result(readPolicies)
98
94
 
99
- yield* Either.match(reloadResult, {
100
- onRight: (policies) =>
95
+ yield* Result.match(reloadResult, {
96
+ onSuccess: (policies) =>
101
97
  Effect.gen(function* () {
102
98
  yield* Ref.set(policiesRef, policies)
103
99
  yield* PubSub.publish(pubsub, undefined)
104
100
  yield* Effect.log("Cedar policies reloaded")
105
101
  }),
106
- onLeft: (error) =>
102
+ onFailure: (error) =>
107
103
  Effect.logWarning(
108
104
  `Failed to reload Cedar policies, keeping previous valid policies: ${error}`,
109
105
  ),
@@ -134,7 +130,7 @@ export const makePolicyWatcherLayer = (
134
130
  // Once the timer fires this reload is intentionally allowed to
135
131
  // complete outside the watcher scope; pending timers are cleared
136
132
  // by the finalizer before they get this far.
137
- Runtime.runFork(runtime, reloadPolicies(changedPath))
133
+ Effect.runForkWith(runtime)(reloadPolicies(changedPath))
138
134
  }, 100),
139
135
  )
140
136
  }
@@ -1,4 +1,5 @@
1
1
  export * from "./lib/auth-policy.ts"
2
2
  export * from "./lib/current-principal.ts"
3
3
  export * from "./lib/errors.ts"
4
+ export * from "./lib/policy-revision.ts"
4
5
  export * from "./lib/types.ts"
@@ -2,6 +2,8 @@ import { Context, type Effect } from "effect"
2
2
  import type { RequestTime } from "../../../request-time/src/index.ts"
3
3
  import type { AuthorizationError } from "./errors.ts"
4
4
  import type {
5
+ CompletionContext,
6
+ CronStartContext,
5
7
  DelegationIssuanceContext,
6
8
  DelegationPrincipalType,
7
9
  ExecutionResource,
@@ -17,7 +19,6 @@ import type {
17
19
  ServiceAccountPrincipal,
18
20
  ServiceAccountPrincipalType,
19
21
  StepResource,
20
- TodoResource,
21
22
  UserPrincipal,
22
23
  } from "./types.ts"
23
24
 
@@ -26,11 +27,11 @@ import type {
26
27
  * Provides policy-based access control using Cedar policies.
27
28
  * All methods require RequestTime context for audit and time-based policies.
28
29
  */
29
- export class AuthorizationService extends Context.Tag(
30
- "processfocus:internal-tag/auth-policy/AuthorizationService",
31
- )<
30
+ export class AuthorizationService extends Context.Service<
32
31
  AuthorizationService,
33
32
  {
33
+ /** Stable across processes; changes with the active schema/policies. Required for prepared authority. */
34
+ readonly policyVersion: Effect.Effect<string>
34
35
  readonly canManageDelegation: (
35
36
  principal: UserPrincipal | ServiceAccountPrincipalType,
36
37
  delegation: DelegationPrincipalType,
@@ -55,21 +56,22 @@ export class AuthorizationService extends Context.Tag(
55
56
 
56
57
  /**
57
58
  * Check if the principal can complete a step.
58
- * Uses Cedar policy: principal.roles.containsAny(resource.allowedRoles)
59
- * For start steps (startsProcess=true), custom policies can use resource.startsProcess
59
+ * Both process starts and existing work target their Step. Existing work
60
+ * supplies trusted instance context for assignment and public-link scoping.
60
61
  */
61
62
  readonly canCompleteStep: (
62
- principal: UserPrincipal | ServiceAccountPrincipal,
63
+ principal:
64
+ | UserPrincipal
65
+ | ServiceAccountPrincipal
66
+ | PublicLinkPrincipalType,
63
67
  resource: StepResource,
68
+ context?: CompletionContext | CronStartContext,
64
69
  ) => Effect.Effect<boolean, AuthorizationError, RequestTime>
65
70
 
66
- /**
67
- * Check if the principal can complete an existing todo. Todo resources carry
68
- * step role and direct-assignee context so Cedar owns active-work visibility.
69
- */
70
- readonly canCompleteTodo: (
71
+ /** Read public start-form data without granting access to Todo state. */
72
+ readonly canViewEmbeddedForm: (
71
73
  principal: UserPrincipal | ServiceAccountPrincipal,
72
- resource: TodoResource,
74
+ resource: StepResource,
73
75
  ) => Effect.Effect<boolean, AuthorizationError, RequestTime>
74
76
 
75
77
  /**
@@ -78,17 +80,8 @@ export class AuthorizationService extends Context.Tag(
78
80
  */
79
81
  readonly canCorrectPublicCompletionTodo: (
80
82
  principal: UserPrincipal,
81
- resource: TodoResource,
82
- ) => Effect.Effect<boolean, AuthorizationError, RequestTime>
83
-
84
- /**
85
- * Public todo capability tokens bind one public-link principal to the same
86
- * todo resource. The default Cedar check is intentionally a policy-owned
87
- * hook for future revocation/scoping rather than an extra token gate.
88
- */
89
- readonly canCompletePublicTodo: (
90
- principal: PublicLinkPrincipalType,
91
- resource: TodoResource,
83
+ resource: StepResource,
84
+ context: CompletionContext,
92
85
  ) => Effect.Effect<boolean, AuthorizationError, RequestTime>
93
86
 
94
87
  /**
@@ -101,16 +94,6 @@ export class AuthorizationService extends Context.Tag(
101
94
  resource: RoleResource,
102
95
  ) => Effect.Effect<boolean, AuthorizationError, RequestTime>
103
96
 
104
- /**
105
- * Check if the principal can request permission to impersonate a provider user.
106
- * Uses Cedar policy: principal == ServiceAccount::"..." and resource is PF::ProviderUser
107
- * There is no default permit; organisations may explicitly grant access.
108
- */
109
- readonly canRequestProviderUserPermissions: (
110
- principal: ServiceAccountPrincipalType | DelegationPrincipalType,
111
- resource: ProviderUserPrincipal,
112
- ) => Effect.Effect<boolean, AuthorizationError, RequestTime>
113
-
114
97
  /**
115
98
  * Check if the principal can act on behalf of a provider user.
116
99
  * Custom policies grant this to selected users or service accounts.
@@ -124,7 +107,6 @@ export class AuthorizationService extends Context.Tag(
124
107
  * Check if the principal can view an execution.
125
108
  * Uses Cedar policies:
126
109
  * - Provider users can view executions they started (principal == resource.startedBy)
127
- * - Provider users can view executions in their org unit (resource in principal.orgUnit)
128
110
  */
129
111
  readonly canViewExecution: (
130
112
  principal: UserPrincipal | ServiceAccountPrincipalType,
@@ -243,7 +225,7 @@ export class AuthorizationService extends Context.Tag(
243
225
  * File owners can always delete their own files.
244
226
  */
245
227
  readonly canDeleteFile: (
246
- principal: UserPrincipal,
228
+ principal: UserPrincipal | ServiceAccountPrincipalType,
247
229
  resource: FileResource,
248
230
  ) => Effect.Effect<boolean, AuthorizationError, RequestTime>
249
231
 
@@ -260,4 +242,4 @@ export class AuthorizationService extends Context.Tag(
260
242
  action: { type: string; id: string },
261
243
  ) => Effect.Effect<boolean, AuthorizationError, RequestTime>
262
244
  }
263
- >() {}
245
+ >()("processfocus:internal-tag/auth-policy/AuthorizationService") {}
@@ -1,34 +1,38 @@
1
- import { Context, Effect, FiberRef } from "effect"
2
- import type { ProviderUserPrincipal } from "./types.ts"
1
+ import { Context, type Effect } from "effect"
2
+ import type { ServiceAccountPrincipal, UserPrincipal } from "./types.ts"
3
3
 
4
- /**
5
- * FiberRef service holding the current request's provider user principal.
6
- *
7
- * Set to `null` for unauthenticated requests or service accounts.
8
- * Updated per-request in `wrapResolver` via `Effect.locally`.
9
- *
10
- * Usage:
11
- * ```typescript
12
- * const principal = yield* getCurrentPrincipal()
13
- * if (principal) {
14
- * // provider user principal available
15
- * }
16
- * ```
17
- */
18
- export class CurrentPrincipal extends Context.Tag(
19
- "processfocus:internal-tag/auth-policy/CurrentPrincipal",
20
- )<CurrentPrincipal, FiberRef.FiberRef<ProviderUserPrincipal | null>>() {}
4
+ /** Organisation-owned live grant for the project targeted by a deployment execution. */
5
+ export class DeploymentExecutionAccess extends Context.Service<
6
+ DeploymentExecutionAccess,
7
+ {
8
+ readonly permits: (
9
+ executionId: string,
10
+ clientId: string,
11
+ processPath: string,
12
+ ) => Effect.Effect<boolean>
13
+ }
14
+ >()("processfocus:internal-tag/auth-policy/DeploymentExecutionAccess") {}
15
+
16
+ /** Live project/environment authorization before handing a workload an upload capability. */
17
+ export class WorkloadDatabaseUploadAccess extends Context.Service<
18
+ WorkloadDatabaseUploadAccess,
19
+ {
20
+ readonly permits: (
21
+ clientId: string,
22
+ project: string,
23
+ environment: string,
24
+ ) => Effect.Effect<boolean>
25
+ }
26
+ >()("processfocus:internal-tag/auth-policy/WorkloadDatabaseUploadAccess") {}
27
+
28
+ /** Verified request actor; null represents unauthenticated or background work. */
29
+ export class CurrentPrincipal extends Context.Service<
30
+ CurrentPrincipal,
31
+ UserPrincipal | ServiceAccountPrincipal | null
32
+ >()("processfocus:internal-tag/auth-policy/CurrentPrincipal") {}
21
33
 
22
- /**
23
- * Helper to get the current principal from the FiberRef.
24
- * Returns `null` for unauthenticated requests or service accounts.
25
- */
26
34
  export const getCurrentPrincipal = (): Effect.Effect<
27
- ProviderUserPrincipal | null,
35
+ UserPrincipal | ServiceAccountPrincipal | null,
28
36
  never,
29
37
  CurrentPrincipal
30
- > =>
31
- Effect.gen(function* () {
32
- const principalRef = yield* CurrentPrincipal
33
- return yield* FiberRef.get(principalRef)
34
- })
38
+ > => CurrentPrincipal
@@ -0,0 +1,23 @@
1
+ import { Context, Data, type Effect } from "effect"
2
+
3
+ export class PolicyRevisionUnavailable extends Data.TaggedError(
4
+ "PolicyRevisionUnavailable",
5
+ )<Record<never, never>> {}
6
+
7
+ /** Opaque activation identity. Reading it never initializes a policy engine. */
8
+ export class ActivePolicyRevision extends Context.Service<
9
+ ActivePolicyRevision,
10
+ {
11
+ readonly current: Effect.Effect<string, PolicyRevisionUnavailable>
12
+ }
13
+ >()("processfocus:internal-tag/auth-policy/ActivePolicyRevision") {}
14
+
15
+ /** Only the authorization runtime publishes successfully activated revisions. */
16
+ export class PolicyRevisionPublisher extends Context.Service<
17
+ PolicyRevisionPublisher,
18
+ {
19
+ readonly publish: (
20
+ revision: string,
21
+ ) => Effect.Effect<void, PolicyRevisionUnavailable>
22
+ }
23
+ >()("processfocus:internal-tag/auth-policy/PolicyRevisionPublisher") {}