@t4h.framework/dev 0.14.2 → 0.16.0

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 (199) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +112 -58
  3. package/dist/AppProcess.d.ts +36 -0
  4. package/dist/AppProcess.js +126 -0
  5. package/dist/AppProcess.js.map +1 -0
  6. package/dist/Server.d.ts +41 -0
  7. package/dist/Server.js +177 -0
  8. package/dist/Server.js.map +1 -0
  9. package/dist/constants/panel-config.d.ts +2 -0
  10. package/dist/constants/panel-config.js +34 -0
  11. package/dist/constants/panel-config.js.map +1 -0
  12. package/dist/constants/server.d.ts +9 -0
  13. package/dist/constants/server.js +10 -0
  14. package/dist/constants/server.js.map +1 -0
  15. package/dist/http/create-app.d.ts +16 -0
  16. package/dist/http/create-app.js +138 -0
  17. package/dist/http/create-app.js.map +1 -0
  18. package/dist/http/helpers/to-http-error.d.ts +8 -0
  19. package/dist/http/helpers/to-http-error.js +9 -0
  20. package/dist/http/helpers/to-http-error.js.map +1 -0
  21. package/dist/http/middlewares/error-handler.middleware.d.ts +2 -0
  22. package/dist/http/middlewares/error-handler.middleware.js +27 -0
  23. package/dist/http/middlewares/error-handler.middleware.js.map +1 -0
  24. package/dist/http/middlewares/project-manifest.middleware.d.ts +11 -0
  25. package/dist/http/middlewares/project-manifest.middleware.js +11 -0
  26. package/dist/http/middlewares/project-manifest.middleware.js.map +1 -0
  27. package/dist/http/middlewares/read-json-body.middleware.d.ts +6 -0
  28. package/dist/http/middlewares/read-json-body.middleware.js +22 -0
  29. package/dist/http/middlewares/read-json-body.middleware.js.map +1 -0
  30. package/dist/http/middlewares/workflow-authorization.middleware.d.ts +12 -0
  31. package/dist/http/middlewares/workflow-authorization.middleware.js +28 -0
  32. package/dist/http/middlewares/workflow-authorization.middleware.js.map +1 -0
  33. package/dist/index.d.ts +3 -15
  34. package/dist/index.js +2 -15
  35. package/dist/index.js.map +1 -1
  36. package/dist/models/JSONRPCClient.d.ts +2 -0
  37. package/dist/models/JSONRPCClient.js +21 -4
  38. package/dist/models/JSONRPCClient.js.map +1 -1
  39. package/dist/models/JSONRPCError.d.ts +13 -0
  40. package/dist/models/JSONRPCError.js +11 -0
  41. package/dist/models/JSONRPCError.js.map +1 -0
  42. package/dist/models/JSONRPCServer.d.ts +2 -0
  43. package/dist/models/JSONRPCServer.js +10 -2
  44. package/dist/models/JSONRPCServer.js.map +1 -1
  45. package/dist/models/WorkflowAuthorizationMissingError.d.ts +5 -0
  46. package/dist/models/WorkflowAuthorizationMissingError.js +9 -0
  47. package/dist/models/WorkflowAuthorizationMissingError.js.map +1 -0
  48. package/dist/models/WorkflowRun.d.ts +20 -15
  49. package/dist/models/WorkflowRun.js +14 -9
  50. package/dist/models/WorkflowRun.js.map +1 -1
  51. package/dist/models/WorkflowRunActivity.d.ts +40 -27
  52. package/dist/models/WorkflowRunActivity.js +46 -34
  53. package/dist/models/WorkflowRunActivity.js.map +1 -1
  54. package/dist/models/claims/DevHttpClientRequestClaim.js +4 -5
  55. package/dist/models/claims/DevHttpClientRequestClaim.js.map +1 -1
  56. package/dist/models/claims/DevORMClaim.d.ts +15 -4
  57. package/dist/models/claims/DevORMClaim.js +128 -29
  58. package/dist/models/claims/DevORMClaim.js.map +1 -1
  59. package/dist/models/claims/DevWorkflowBatchClaim.js +3 -6
  60. package/dist/models/claims/DevWorkflowBatchClaim.js.map +1 -1
  61. package/dist/models/claims/DevWorkflowClaim.d.ts +1 -1
  62. package/dist/models/claims/DevWorkflowClaim.js +6 -11
  63. package/dist/models/claims/DevWorkflowClaim.js.map +1 -1
  64. package/dist/repositories/WorkflowRun.repository.d.ts +44 -6
  65. package/dist/repositories/WorkflowRun.repository.js +196 -11
  66. package/dist/repositories/WorkflowRun.repository.js.map +1 -1
  67. package/dist/repositories/WorkflowRunActivity.repository.d.ts +19 -6
  68. package/dist/repositories/WorkflowRunActivity.repository.js +73 -23
  69. package/dist/repositories/WorkflowRunActivity.repository.js.map +1 -1
  70. package/dist/repositories/WorkflowRunAsyncActivityPending.repository.d.ts +39 -0
  71. package/dist/repositories/WorkflowRunAsyncActivityPending.repository.js +160 -0
  72. package/dist/repositories/WorkflowRunAsyncActivityPending.repository.js.map +1 -0
  73. package/dist/services/ActivityRegistry.service.d.ts +7 -0
  74. package/dist/services/ActivityRegistry.service.js +32 -0
  75. package/dist/services/ActivityRegistry.service.js.map +1 -0
  76. package/dist/services/Database.service.d.ts +14 -0
  77. package/dist/services/Database.service.js +106 -0
  78. package/dist/services/Database.service.js.map +1 -0
  79. package/dist/services/TimeoutScheduler.service.js +9 -3
  80. package/dist/services/TimeoutScheduler.service.js.map +1 -1
  81. package/dist/services/WorkflowAuthorization.service.d.ts +19 -0
  82. package/dist/services/WorkflowAuthorization.service.js +75 -0
  83. package/dist/services/WorkflowAuthorization.service.js.map +1 -0
  84. package/dist/services/WorkflowRunAsyncActivityFacade.service.d.ts +8 -15
  85. package/dist/services/WorkflowRunAsyncActivityFacade.service.js +12 -26
  86. package/dist/services/WorkflowRunAsyncActivityFacade.service.js.map +1 -1
  87. package/dist/services/WorkflowRunEvents.service.d.ts +11 -0
  88. package/dist/services/WorkflowRunEvents.service.js +42 -0
  89. package/dist/services/WorkflowRunEvents.service.js.map +1 -0
  90. package/dist/services/WorkflowRunFacade.service.d.ts +106 -7
  91. package/dist/services/WorkflowRunFacade.service.js +65 -10
  92. package/dist/services/WorkflowRunFacade.service.js.map +1 -1
  93. package/dist/services/WorkflowRunLock.service.d.ts +6 -0
  94. package/dist/services/WorkflowRunLock.service.js +34 -0
  95. package/dist/services/WorkflowRunLock.service.js.map +1 -0
  96. package/dist/services/WorkflowRunSyncActivityFacade.service.d.ts +4 -4
  97. package/dist/services/WorkflowRunSyncActivityFacade.service.js +7 -7
  98. package/dist/services/WorkflowRunSyncActivityFacade.service.js.map +1 -1
  99. package/dist/tools/copy-additional-files.d.ts +0 -5
  100. package/dist/tools/copy-additional-files.js +0 -5
  101. package/dist/tools/copy-additional-files.js.map +1 -1
  102. package/dist/tools/find-free-port.d.ts +5 -0
  103. package/dist/tools/find-free-port.js +30 -0
  104. package/dist/tools/find-free-port.js.map +1 -0
  105. package/dist/tools/find-workflow-by-id.d.ts +2 -0
  106. package/dist/tools/find-workflow-by-id.js +9 -0
  107. package/dist/tools/find-workflow-by-id.js.map +1 -0
  108. package/dist/tools/format-routes.d.ts +10 -0
  109. package/dist/tools/format-routes.js +40 -0
  110. package/dist/tools/format-routes.js.map +1 -0
  111. package/dist/tools/replace.d.ts +1 -0
  112. package/dist/tools/replace.js +14 -0
  113. package/dist/tools/replace.js.map +1 -0
  114. package/dist/tools/to-rejected-reason.d.ts +5 -0
  115. package/dist/tools/to-rejected-reason.js +11 -0
  116. package/dist/tools/to-rejected-reason.js.map +1 -0
  117. package/dist/tools/to-workflow-run-activity-output.d.ts +24 -0
  118. package/dist/tools/to-workflow-run-activity-output.js +18 -0
  119. package/dist/tools/to-workflow-run-activity-output.js.map +1 -0
  120. package/dist/tools/to-workflow-run-output.d.ts +11 -0
  121. package/dist/tools/to-workflow-run-output.js +12 -0
  122. package/dist/tools/to-workflow-run-output.js.map +1 -0
  123. package/dist/transport/AppProcessJsonRpc.js +59 -0
  124. package/dist/transport/AppProcessJsonRpc.js.map +1 -0
  125. package/dist/use-cases/BuildWorkflowRunActivityHistory.usecase.d.ts +9 -0
  126. package/dist/use-cases/{WorkflowRunBuildHistory.usecase.js → BuildWorkflowRunActivityHistory.usecase.js} +18 -16
  127. package/dist/use-cases/BuildWorkflowRunActivityHistory.usecase.js.map +1 -0
  128. package/dist/use-cases/CreateWorkflowRun.usecase.d.ts +6 -6
  129. package/dist/use-cases/CreateWorkflowRun.usecase.js +20 -21
  130. package/dist/use-cases/CreateWorkflowRun.usecase.js.map +1 -1
  131. package/dist/use-cases/CreateWorkflowRunAsyncActivity.usecase.d.ts +9 -3
  132. package/dist/use-cases/CreateWorkflowRunAsyncActivity.usecase.js +45 -39
  133. package/dist/use-cases/CreateWorkflowRunAsyncActivity.usecase.js.map +1 -1
  134. package/dist/use-cases/EnqueueWorkflowRunNextTick.usecase.d.ts +9 -0
  135. package/dist/use-cases/EnqueueWorkflowRunNextTick.usecase.js +43 -0
  136. package/dist/use-cases/EnqueueWorkflowRunNextTick.usecase.js.map +1 -0
  137. package/dist/use-cases/ExecuteWorkflowRunActivity.usecase.d.ts +9 -0
  138. package/dist/use-cases/ExecuteWorkflowRunActivity.usecase.js +47 -0
  139. package/dist/use-cases/ExecuteWorkflowRunActivity.usecase.js.map +1 -0
  140. package/dist/use-cases/ExecuteWorkflowRunAsyncActivity.usecase.d.ts +22 -0
  141. package/dist/use-cases/ExecuteWorkflowRunAsyncActivity.usecase.js +117 -0
  142. package/dist/use-cases/ExecuteWorkflowRunAsyncActivity.usecase.js.map +1 -0
  143. package/dist/use-cases/NextTickWorkflowRun.usecase.d.ts +16 -7
  144. package/dist/use-cases/NextTickWorkflowRun.usecase.js +139 -130
  145. package/dist/use-cases/NextTickWorkflowRun.usecase.js.map +1 -1
  146. package/dist/use-cases/RunWorkflow.usecase.d.ts +10 -0
  147. package/dist/use-cases/RunWorkflow.usecase.js +46 -0
  148. package/dist/use-cases/RunWorkflow.usecase.js.map +1 -0
  149. package/dist/use-cases/WorkflowRunActivityFind.usecase.d.ts +34 -0
  150. package/dist/use-cases/WorkflowRunActivityFind.usecase.js +49 -0
  151. package/dist/use-cases/WorkflowRunActivityFind.usecase.js.map +1 -0
  152. package/dist/use-cases/WorkflowRunActivityFindById.usecase.d.ts +34 -0
  153. package/dist/use-cases/WorkflowRunActivityFindById.usecase.js +60 -0
  154. package/dist/use-cases/WorkflowRunActivityFindById.usecase.js.map +1 -0
  155. package/dist/use-cases/WorkflowRunAsyncActivityAdvance.usecase.d.ts +12 -4
  156. package/dist/use-cases/WorkflowRunAsyncActivityAdvance.usecase.js +41 -27
  157. package/dist/use-cases/WorkflowRunAsyncActivityAdvance.usecase.js.map +1 -1
  158. package/dist/use-cases/WorkflowRunAsyncActivityPendingFind.usecase.d.ts +24 -0
  159. package/dist/use-cases/WorkflowRunAsyncActivityPendingFind.usecase.js +56 -0
  160. package/dist/use-cases/WorkflowRunAsyncActivityPendingFind.usecase.js.map +1 -0
  161. package/dist/use-cases/WorkflowRunFind.usecase.d.ts +17 -0
  162. package/dist/use-cases/WorkflowRunFind.usecase.js +28 -0
  163. package/dist/use-cases/WorkflowRunFind.usecase.js.map +1 -0
  164. package/dist/use-cases/WorkflowRunFindById.usecase.d.ts +19 -0
  165. package/dist/use-cases/WorkflowRunFindById.usecase.js +45 -0
  166. package/dist/use-cases/WorkflowRunFindById.usecase.js.map +1 -0
  167. package/dist/workers/app-process.js +10 -1
  168. package/dist/workers/app-process.js.map +1 -1
  169. package/package.json +15 -5
  170. package/.ai/skills/framework-dev/SKILL.md +0 -348
  171. package/dist/DevServer.d.ts +0 -24
  172. package/dist/DevServer.js +0 -87
  173. package/dist/DevServer.js.map +0 -1
  174. package/dist/models/InMemoryDatabase.d.ts +0 -20
  175. package/dist/models/InMemoryDatabase.js +0 -111
  176. package/dist/models/InMemoryDatabase.js.map +0 -1
  177. package/dist/services/BuildWorkflowRunResult.service.d.ts +0 -8
  178. package/dist/services/BuildWorkflowRunResult.service.js +0 -49
  179. package/dist/services/BuildWorkflowRunResult.service.js.map +0 -1
  180. package/dist/tools/is-workflow-waiting.d.ts +0 -4
  181. package/dist/tools/is-workflow-waiting.js +0 -12
  182. package/dist/tools/is-workflow-waiting.js.map +0 -1
  183. package/dist/transport/DevServerJsonRpc.js +0 -42
  184. package/dist/transport/DevServerJsonRpc.js.map +0 -1
  185. package/dist/use-cases/CallbackWorkflowRunAsyncActivity.usecase.d.ts +0 -14
  186. package/dist/use-cases/CallbackWorkflowRunAsyncActivity.usecase.js +0 -64
  187. package/dist/use-cases/CallbackWorkflowRunAsyncActivity.usecase.js.map +0 -1
  188. package/dist/use-cases/TimeoutWorkflowRunAsyncActivity.usecase.d.ts +0 -8
  189. package/dist/use-cases/TimeoutWorkflowRunAsyncActivity.usecase.js +0 -40
  190. package/dist/use-cases/TimeoutWorkflowRunAsyncActivity.usecase.js.map +0 -1
  191. package/dist/use-cases/WorkflowRunAsyncActivity.usecase.d.ts +0 -7
  192. package/dist/use-cases/WorkflowRunAsyncActivity.usecase.js +0 -46
  193. package/dist/use-cases/WorkflowRunAsyncActivity.usecase.js.map +0 -1
  194. package/dist/use-cases/WorkflowRunBuildHistory.usecase.d.ts +0 -8
  195. package/dist/use-cases/WorkflowRunBuildHistory.usecase.js.map +0 -1
  196. package/dist/use-cases/WorkflowRunSyncActivity.usecase.d.ts +0 -4
  197. package/dist/use-cases/WorkflowRunSyncActivity.usecase.js +0 -28
  198. package/dist/use-cases/WorkflowRunSyncActivity.usecase.js.map +0 -1
  199. /package/dist/transport/{DevServerJsonRpc.d.ts → AppProcessJsonRpc.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @t4h.framework/dev
2
2
 
3
+ ## 0.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#151](https://github.com/tech4humans-brasil/framework/pull/151) [`d44eb5e`](https://github.com/tech4humans-brasil/framework/commit/d44eb5e1797f523612c9e2f560b0bb583ab8688f) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - host owns panel config and run rejection lives in output
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`d44eb5e`](https://github.com/tech4humans-brasil/framework/commit/d44eb5e1797f523612c9e2f560b0bb583ab8688f)]:
12
+ - @t4h.framework/vite-panel-plugin@0.2.0
13
+
14
+ ## 0.15.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [#145](https://github.com/tech4humans-brasil/framework/pull/145) [`09724c3`](https://github.com/tech4humans-brasil/framework/commit/09724c3f0bb573d55b94495835362e7b66bc570e) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Replaces the interactive REPL of `framework dev` with an HTTP dev server: Hono routes workflow (`POST /projects/:projectId/workflows/:workflowId/runs` answers `201 { id }`, `PATCH .../runs/:runId/activities/:activityId` advances a pending async activity), mandatory workflow authorization resolved from the app/workflow `Authorization` manifest, `/_dev` routes for tooling (manifest, runs, waiting activities, env, SSE events) and Vite in middleware mode for a UI. Workflow runs now live in an in-memory SQLite database inside the app process, the ORM dev claim stores its rows in `db.sqlite` instead of rewriting `db.json` on every change, child workflows run in parallel, and `framework dev` gains `--port` (`PORT`) and `--host`. `DevServer` and `isWorkflowWaiting` are gone; use `Server`.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [[`a3696b4`](https://github.com/tech4humans-brasil/framework/commit/a3696b48b48598eda9e51c53538a6086abe36018), [`a3696b4`](https://github.com/tech4humans-brasil/framework/commit/a3696b48b48598eda9e51c53538a6086abe36018), [`45182d4`](https://github.com/tech4humans-brasil/framework/commit/45182d4a27c86353747646aa9b70a39bc4c56610)]:
23
+ - @t4h.framework/vite-panel-plugin@0.1.0
24
+ - @t4h.framework/http@0.4.4
25
+ - @t4h.framework/oidc@0.5.0
26
+
3
27
  ## 0.14.2
4
28
 
5
29
  ### Patch Changes
package/README.md CHANGED
@@ -1,35 +1,38 @@
1
1
  # @t4h.framework/dev
2
2
 
3
- Local development runtime for [T4H Framework](https://github.com/tech4humans-brasil/framework) apps. Watches your project, compiles TypeScript, loads your `App`, and executes workflows with in-memory claim implementations — no external infrastructure required.
3
+ Local development runtime for [T4H Framework](https://github.com/tech4humans-brasil/framework) apps. Watches your project, compiles TypeScript, loads your `App` in a child process and exposes it over HTTP with the same routes as the production runtime — no external infrastructure required.
4
4
 
5
5
  ## What it does
6
6
 
7
7
  When you run `framework dev` (via `@t4h.framework/cli`), this package powers the experience behind the scenes:
8
8
 
9
9
  1. **TypeScript watch** — compiles your app on every change.
10
- 2. **App process** — forks a child Node process that loads your compiled `App`.
11
- 3. **JSON-RPC over IPC** — the parent process drives workflows, env vars, and async activity advancement through a typed RPC layer.
12
- 4. **Dev claims** — provides local implementations for ORM, HTTP, file system, cache, SMTP, and more.
10
+ 2. **App process** — forks a child Node process that loads your compiled `App` and runs the workflow engine on an in-memory SQLite database.
11
+ 3. **HTTP server** — a [Hono](https://hono.dev) app that exposes your workflows (create runs, advance pending activities), enforces the workflow authorization and adds `/_dev` routes for tooling.
12
+ 4. **Vite** — a Vite dev server in middleware mode serves the built-in panel and anything else that is not an API route.
13
+ 5. **Dev claims** — provides local implementations for ORM, HTTP, file system, cache, SMTP, and more.
13
14
 
14
15
  ```mermaid
15
16
  flowchart TB
16
- subgraph parent ["Parent process (DevServer)"]
17
+ subgraph parent ["Parent process (Server)"]
17
18
  Watch["TypeScript watch"]
18
- RPCClient["JSON-RPC client"]
19
- Watch -->|"build success"| Fork
20
- Fork["fork()"]
21
- Fork --> RPCClient
19
+ HTTP["Hono (/projects, /_dev)"]
20
+ Vite["Vite middlewares (UI)"]
21
+ Auth["Workflow authorization"]
22
+ Watch -->|"build success"| Fork["AppProcess.up()"]
23
+ HTTP --> Auth
22
24
  end
23
25
 
24
26
  subgraph child ["Child process (app-process worker)"]
25
27
  App["User App"]
26
- RPCServer["JSON-RPC server"]
28
+ Engine["Workflow engine + SQLite :memory:"]
27
29
  Claims["Dev claims"]
28
- App --> RPCServer
30
+ App --> Engine
29
31
  Claims --> App
30
32
  end
31
33
 
32
- RPCClient <-->|"IPC / JSON-RPC"| RPCServer
34
+ Fork --> App
35
+ HTTP <-->|"IPC / JSON-RPC"| Engine
33
36
  ```
34
37
 
35
38
  ## Installation
@@ -76,13 +79,17 @@ Then run:
76
79
  yarn dev
77
80
  ```
78
81
 
82
+ The server listens right away and prints the routes of every workflow once the first build finishes.
83
+
79
84
  ### Options
80
85
 
81
- | Flag | Description | Default |
82
- |------|-------------|---------|
83
- | `--entrypoint <path>` | Path to the project's `package.json` | `./package.json` |
84
- | `-e, --env <KEY=VALUE>` | Environment variable (repeatable) | — |
85
- | `--env-file-if-exists <path>` | Load variables from a `.env` file if it exists | — |
86
+ | Flag | Description | Default |
87
+ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------- |
88
+ | `--entrypoint <path>` | Path to the project's `package.json` | `./package.json` |
89
+ | `-e, --env <KEY=VALUE>` | Environment variable (repeatable) | — |
90
+ | `--env-file-if-exists <path>` | Load variables from a `.env` file if it exists | — |
91
+ | `-p, --port <port>` | HTTP port (also `PORT`); when something already answers on it, on any address of `--host`, the next free port up is taken and logged | `3000` |
92
+ | `--host <host>` | HTTP host | `localhost` |
86
93
 
87
94
  Example with env vars:
88
95
 
@@ -90,60 +97,107 @@ Example with env vars:
90
97
  framework dev --entrypoint ./package.json -e API_KEY=secret -e DB_HOST=localhost
91
98
  ```
92
99
 
93
- ## Programmatic usage
100
+ ## HTTP routes
101
+
102
+ The dev server has no tenants and a single live version (the last build), so the routes carry only the project and the workflow. `projectId` must match your `App` id.
103
+
104
+ | Method | Route | Authorization | Response |
105
+ | ------- | ------------------------------------------------------------------------------- | ------------- | -------------------------- |
106
+ | `GET` | `/projects/:projectId/manifest.json` | no | `200` the app manifest |
107
+ | `POST` | `/projects/:projectId/workflows/:workflowId/runs` | yes | `201 { "id": "<run id>" }` |
108
+ | `PATCH` | `/projects/:projectId/workflows/:workflowId/runs/:runId/activities/:activityId` | yes | `200 { id, type, status }` |
109
+
110
+ The `POST` body is the workflow input, validated against the workflow schema (`400` with the validation errors). The `PATCH` body is `{ "payload": ... }`, validated against the pending async activity schema (`400 Payload is invalid`, `400 AsyncActivity is not pending`). Errors use the NestJS shape `{ statusCode, message, error }`; `503` means the app process is still starting.
111
+
112
+ ```bash
113
+ curl -X POST http://localhost:3000/projects/my-app/workflows/my-workflow/runs \
114
+ -H 'content-type: application/json' \
115
+ -H 'x-signature: <hmac>' \
116
+ -d '{ "userId": "123" }'
117
+ ```
118
+
119
+ ### Authorization
120
+
121
+ Every `/projects` route requires an authorization: the workflow `authorization` wins over the app one, its manifest `pathToModule` is imported and its default export receives the manifest `context` templated with the request (`<< headers.x-signature >>`, `<< rawBody >>`, `<< body.id >>`, `<< params.projectId >>`, `<< query.token >>`). A falsy result or a thrown error answers `401`. A workflow without any authorization is refused when the manifest arrives (the server emits `error`) and answers `500` if reached.
122
+
123
+ `pathToModule` may be `@t4h.framework/hmac/authorize`, `@t4h.framework/jwks/authorize`, `@t4h.framework/oidc/authorize`, an absolute path, a path relative to the project or a `file://` URL.
124
+
125
+ ### Dev routes (no authorization)
94
126
 
95
- You can embed `DevServer` in your own tooling instead of using the interactive CLI:
127
+ | Method | Route | Description |
128
+ | ------ | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
129
+ | `GET` | `/_dev/manifest` | App manifest |
130
+ | `GET` | `/_dev/state` | `{ state: 'idle' \| 'starting' \| 'ready' \| 'exited' }` |
131
+ | `GET` | `/_dev/runs?status=&workflow=&id=&parentRun=&parentActivity=&rootOnly=&createdAfter=&createdBefore=&limit=&offset=` | `{ count, runs }` newest first; `id` is a prefix, `rootOnly=true` hides child runs, `createdAfter`/`createdBefore` are ISO 8601 |
132
+ | `GET` | `/_dev/runs/:id` | Run with `input` and `output`; a rejected run carries its reason as `output` (framework tagged JSON) |
133
+ | `GET` | `/_dev/activities/waiting` | Async activities waiting for an advance |
134
+ | `POST` | `/_dev/workflows/:workflowId/runs` | Starts a run without authorization; body is the input, answers `201 { id }` |
135
+ | `POST` | `/_dev/activities/:activityId/advance` | Advances a pending async activity without authorization; body is `{ payload }` |
136
+ | `GET` | `/_dev/events` | SSE: `manifest`, `build:status`, `build:fail`, `app:exit`, `run:created`, `run:updated` |
137
+
138
+ `run:created` and `run:updated` carry the run summary (the same object `/_dev/runs` lists); updates of one run are coalesced, so a tick that writes several rows produces one event.
139
+
140
+ Everything else is handed to Vite, which serves the panel that ships with this package: open the base URL to browse the workflows and start runs from their schema, follow runs live with the execution trace of each one (activities as a waterfall, child runs nested, input, output, duration, logs, the activity that failed) and advance waiting activities. Plugins from the project's `vite.config.*` (or `vite.plugins`) are served by the same Vite.
141
+
142
+ ## State
143
+
144
+ Workflow runs, activities, pending async activities and logs live in an in-memory SQLite database (`node:sqlite`) inside the app process. Every successful build forks a fresh process, so **a rebuild resets all runs, timers and pending activities**; the `manifest` SSE event tells a UI to reload. There is no durability, queue or resume in the dev server by design.
145
+
146
+ Sync activities run inline, `sleep` and other timers use `setTimeout`, and child workflows started with `startWorkflow` / `startWorkflowMany` run in parallel.
147
+
148
+ The ORM claim is the exception: its rows live in `db.sqlite` next to your `package.json` and survive rebuilds and restarts (add it to `.gitignore`). Delete the file to start over. The previous `db.json` is no longer read.
149
+
150
+ ## Programmatic usage
96
151
 
97
152
  ```typescript
98
- import { DevServer } from '@t4h.framework/dev'
99
-
100
- const devServer = new DevServer(
101
- {
102
- entrypoint: './package.json',
103
- env: { API_KEY: 'secret' },
104
- },
105
- manifest => {
106
- console.log('App loaded:', manifest.workflows.map(w => w.id))
107
- },
108
- )
109
-
110
- await devServer.start()
111
-
112
- const result = await devServer.runWorkflow('my-workflow/v1', {
113
- userId: '123',
114
- amount: 100,
153
+ import { Server } from '@t4h.framework/dev'
154
+
155
+ const server = new Server({
156
+ entrypoint: './package.json',
157
+ env: { API_KEY: 'secret' },
158
+ port: 3000,
159
+ host: 'localhost',
160
+ vite: { plugins: [myPanelPlugin()] },
161
+ })
162
+
163
+ server.on('manifest', manifest => {
164
+ console.log(
165
+ 'App ready:',
166
+ manifest.workflows.map(workflow => workflow.id),
167
+ )
115
168
  })
116
169
 
117
- await devServer.setEnv('API_KEY', 'new-value')
118
- const env = await devServer.listEnv()
170
+ const address = await server.up()
171
+
172
+ console.log(address.url)
119
173
 
120
- const pending = await devServer.listWaitingAsyncActivities()
121
- await devServer.advanceAsyncActivity(pending[0].id, { approved: true })
174
+ await server.down()
122
175
  ```
123
176
 
124
- ### DevServer API
177
+ ### Server API
178
+
179
+ | Member | Description |
180
+ | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
181
+ | `up()` | Starts HTTP + Vite, then the TypeScript watch; resolves with `{ host, port, url }`. `port` is the one actually bound: a port already in use moves it up. |
182
+ | `down()` | Stops the watch, the app process, Vite and the HTTP server. |
183
+ | `manifest` | Current app manifest or `null`. |
184
+ | `address` | Listening address (throws before `up()`). |
185
+ | events | `manifest`, `build:status`, `build:fail`, `app:exit`, `run:created`, `run:updated`, `error`. |
125
186
 
126
- | Method | Description |
127
- |--------|-------------|
128
- | `start()` | Resolves project paths, starts TypeScript watch, and boots the app process on first successful build. |
129
- | `runWorkflow(id, input)` | Runs a workflow by id with the given input. |
130
- | `setEnv(name, value)` | Sets an environment variable in the running app process. |
131
- | `listEnv()` | Returns all environment variables. |
132
- | `listWaitingAsyncActivities()` | Lists async activities waiting for manual advancement. |
133
- | `advanceAsyncActivity(id, payload)` | Advances a pending async activity with the given payload. |
187
+ `vite: false` disables Vite; `vite.root` / `vite.configFile` point at another Vite project. The server logs the listening URL, build output and the routes of every workflow through `logger` (default `console`, `false` to silence). A manifest with a workflow that has no authorization (and no app default) emits `error` with a `WorkflowAuthorizationMissingError`; `framework dev` exits with code 1 in that case.
134
188
 
135
189
  ## Dev claims
136
190
 
137
191
  In production, claims are fulfilled by the runtime (database connections, real HTTP clients, etc.). During local development, `@t4h.framework/dev` registers in-memory substitutes:
138
192
 
139
- | Claim | Dev implementation |
140
- |-------|-------------------|
141
- | `ORMClaim` | In-memory database |
142
- | `HttpClientRequestClaim` | Real HTTP via `undici` |
143
- | `FileSystemClaim` | Local file system with dev binary codec |
144
- | `SmtpSendEmailClaim` | Captures emails in memory (no delivery) |
145
- | `CacheClaim` | In-memory cache |
146
- | `WorkflowClaim` | Runs workflows through the local workflow engine |
193
+ | Claim | Dev implementation |
194
+ | ------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
195
+ | `ORMClaim` | SQLite file `db.sqlite` in the project directory; `where` keeps the Mongo-like semantics (`$like`, `$ilike`, `$or`, ...) |
196
+ | `HttpClientRequestClaim` | Real HTTP via `undici` |
197
+ | `FileSystemClaim` | Local file system with dev binary codec |
198
+ | `SmtpSendEmailClaim` | Captures emails in memory (no delivery) |
199
+ | `CacheClaim` | In-memory cache |
200
+ | `WorkflowClaim` | Runs workflows through the local workflow engine |
147
201
 
148
202
  Import the full claim registry:
149
203
 
@@ -164,7 +218,7 @@ import {
164
218
 
165
219
  ## Requirements
166
220
 
167
- - Node.js >= 22
221
+ - Node.js >= 22.13 (`node:sqlite`)
168
222
  - A T4H Framework `App` exported from your project's entry point (`default` or named `app` export)
169
223
 
170
224
  ## License
@@ -0,0 +1,36 @@
1
+ import { fork } from 'node:child_process';
2
+ import { EventEmitter } from 'node:events';
3
+ import type { App } from '@t4h.framework/core';
4
+ export type AppManifest = ReturnType<App['toManifest']>;
5
+ export type AppProcessState = 'idle' | 'starting' | 'ready' | 'exited';
6
+ export declare class AppProcessNotReadyError extends Error {
7
+ readonly name = "AppProcessNotReadyError";
8
+ }
9
+ export interface AppProcessOptions {
10
+ workerPath?: string;
11
+ readyTimeoutInMs?: number;
12
+ killTimeoutInMs?: number;
13
+ fork?: typeof fork;
14
+ }
15
+ export declare class AppProcess extends EventEmitter {
16
+ private readonly workerPath;
17
+ private readonly readyTimeoutInMs;
18
+ private readonly killTimeoutInMs;
19
+ private readonly forkProcess;
20
+ private readonly server;
21
+ private child;
22
+ private client;
23
+ private ready;
24
+ private currentManifest;
25
+ private currentState;
26
+ constructor({ workerPath, readyTimeoutInMs, killTimeoutInMs, fork: forkProcess, }?: AppProcessOptions);
27
+ get manifest(): AppManifest | null;
28
+ get state(): AppProcessState;
29
+ up(entrypoint: string, env: Record<string, string>): Promise<AppManifest>;
30
+ down(): Promise<void>;
31
+ private kill;
32
+ whenReady(): Promise<AppManifest>;
33
+ call<T = any>(method: string, ...params: any[]): Promise<T>;
34
+ private onManifest;
35
+ private onExit;
36
+ }
@@ -0,0 +1,126 @@
1
+ import { fork } from 'node:child_process';
2
+ import { EventEmitter } from 'node:events';
3
+ import path from 'node:path';
4
+ import { styleText } from 'node:util';
5
+ import Type from 'typebox';
6
+ import { APP_KILL_TIMEOUT_IN_MS, APP_READY_TIMEOUT_IN_MS, WORKFLOW_RUN_EVENTS, } from './constants/server.js';
7
+ import { JSONRPCClient } from './models/JSONRPCClient.js';
8
+ import { JSONRPCServer, JSONRPCServerMethod } from './models/JSONRPCServer.js';
9
+ export class AppProcessNotReadyError extends Error {
10
+ name = 'AppProcessNotReadyError';
11
+ }
12
+ export class AppProcess extends EventEmitter {
13
+ workerPath;
14
+ readyTimeoutInMs;
15
+ killTimeoutInMs;
16
+ forkProcess;
17
+ server;
18
+ child = null;
19
+ client = null;
20
+ ready = null;
21
+ currentManifest = null;
22
+ currentState = 'idle';
23
+ constructor({ workerPath = path.join(import.meta.dirname, 'workers', 'app-process.js'), readyTimeoutInMs = APP_READY_TIMEOUT_IN_MS, killTimeoutInMs = APP_KILL_TIMEOUT_IN_MS, fork: forkProcess = fork, } = {}) {
24
+ super();
25
+ this.workerPath = workerPath;
26
+ this.readyTimeoutInMs = readyTimeoutInMs;
27
+ this.killTimeoutInMs = killTimeoutInMs;
28
+ this.forkProcess = forkProcess;
29
+ this.server = new JSONRPCServer([
30
+ new JSONRPCServerMethod('manifest', { schema: [Type.Any()] }, (manifest) => this.onManifest(manifest)),
31
+ ...WORKFLOW_RUN_EVENTS.map(event => new JSONRPCServerMethod(event, { schema: [Type.Any()] }, (payload) => void this.emit(event, payload))),
32
+ ], message => {
33
+ this.child?.send(message);
34
+ });
35
+ }
36
+ get manifest() {
37
+ return this.currentManifest;
38
+ }
39
+ get state() {
40
+ return this.currentState;
41
+ }
42
+ async up(entrypoint, env) {
43
+ const previous = this.child;
44
+ this.child = null;
45
+ this.client?.rejectPending(new AppProcessNotReadyError('App process is restarting'));
46
+ this.client = null;
47
+ this.ready = Promise.withResolvers();
48
+ this.ready.promise.catch(() => { });
49
+ this.currentState = 'starting';
50
+ await this.kill(previous);
51
+ const child = this.forkProcess(this.workerPath, [
52
+ entrypoint,
53
+ ...Object.entries(env).map(([name, value]) => `${name}=${value}`),
54
+ ], { stdio: ['ignore', 'inherit', 'inherit', 'ipc'] });
55
+ const client = new JSONRPCClient(message => {
56
+ child.send(message);
57
+ });
58
+ this.child = child;
59
+ this.client = client;
60
+ child.on('message', message => Promise.all([this.server.handle(message), client.handle(message)]).catch(error => {
61
+ console.error(styleText('red', '[AppProcess] failed to handle message:', {
62
+ stream: process.stderr,
63
+ }), error);
64
+ }));
65
+ child.on('exit', code => this.onExit(child, code));
66
+ return this.whenReady();
67
+ }
68
+ async down() {
69
+ await this.kill(this.child);
70
+ }
71
+ async kill(child) {
72
+ if (!child)
73
+ return;
74
+ if (child.exitCode !== null || child.signalCode !== null)
75
+ return;
76
+ await new Promise(resolve => {
77
+ const timer = setTimeout(() => child.kill('SIGKILL'), this.killTimeoutInMs);
78
+ child.once('exit', () => {
79
+ clearTimeout(timer);
80
+ resolve();
81
+ });
82
+ child.kill();
83
+ });
84
+ }
85
+ whenReady() {
86
+ if (this.currentState === 'ready' && this.currentManifest)
87
+ return Promise.resolve(this.currentManifest);
88
+ if (this.currentState !== 'starting' || !this.ready)
89
+ return Promise.reject(new AppProcessNotReadyError('App process is not running'));
90
+ const { promise } = this.ready;
91
+ return new Promise((resolve, reject) => {
92
+ const timer = setTimeout(() => reject(new AppProcessNotReadyError(`App process did not become ready in ${this.readyTimeoutInMs}ms`)), this.readyTimeoutInMs);
93
+ promise.then(manifest => {
94
+ clearTimeout(timer);
95
+ resolve(manifest);
96
+ }, error => {
97
+ clearTimeout(timer);
98
+ reject(error);
99
+ });
100
+ });
101
+ }
102
+ async call(method, ...params) {
103
+ await this.whenReady();
104
+ if (!this.client)
105
+ throw new AppProcessNotReadyError('App process is not running');
106
+ return this.client.call(method, ...params);
107
+ }
108
+ onManifest(manifest) {
109
+ this.currentManifest = manifest;
110
+ this.currentState = 'ready';
111
+ this.ready?.resolve(manifest);
112
+ this.emit('manifest', manifest);
113
+ }
114
+ onExit(child, code) {
115
+ if (this.child !== child)
116
+ return;
117
+ const error = new AppProcessNotReadyError(`App process exited with code ${code}`);
118
+ this.child = null;
119
+ this.currentState = 'exited';
120
+ this.client?.rejectPending(error);
121
+ this.client = null;
122
+ this.ready?.reject(error);
123
+ this.emit('exit', code);
124
+ }
125
+ }
126
+ //# sourceMappingURL=AppProcess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppProcess.js","sourceRoot":"","sources":["../src/AppProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAqB,MAAM,oBAAoB,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAGrC,OAAO,IAAI,MAAM,SAAS,CAAA;AAE1B,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAM9E,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACvB,IAAI,GAAG,yBAAyB,CAAA;CAC1D;AASD,MAAM,OAAO,UAAW,SAAQ,YAAY;IACzB,UAAU,CAAQ;IAClB,gBAAgB,CAAQ;IACxB,eAAe,CAAQ;IACvB,WAAW,CAAa;IACxB,MAAM,CAAe;IAE9B,KAAK,GAAwB,IAAI,CAAA;IACjC,MAAM,GAAyB,IAAI,CAAA;IACnC,KAAK,GAA6C,IAAI,CAAA;IACtD,eAAe,GAAuB,IAAI,CAAA;IAC1C,YAAY,GAAoB,MAAM,CAAA;IAE9C,YAAY,EACV,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,EACxE,gBAAgB,GAAG,uBAAuB,EAC1C,eAAe,GAAG,sBAAsB,EACxC,IAAI,EAAE,WAAW,GAAG,IAAI,MACH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AA;QAE5B,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAAA;QACjC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAElB,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;QAEzB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACzB,CAAC;CACF"}
@@ -0,0 +1,41 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import type { PluginOption } from 'vite';
3
+ import { type AppManifest } from './AppProcess.js';
4
+ export interface ServerViteOptions {
5
+ root?: string;
6
+ configFile?: string | false;
7
+ plugins?: PluginOption[];
8
+ }
9
+ export type ServerLogger = Pick<Console, 'log' | 'error'>;
10
+ export interface ServerOptions {
11
+ entrypoint: string;
12
+ env: Record<string, string>;
13
+ port?: number;
14
+ host?: string;
15
+ vite?: ServerViteOptions | false;
16
+ logger?: ServerLogger | false;
17
+ }
18
+ export interface ServerAddress {
19
+ host: string;
20
+ port: number;
21
+ url: string;
22
+ }
23
+ export declare class Server extends EventEmitter {
24
+ private readonly options;
25
+ private readonly appProcess;
26
+ private readonly logger;
27
+ private routes;
28
+ private tsBuildWatcher;
29
+ private httpServer;
30
+ private vite;
31
+ private currentAddress;
32
+ private packageJsonPath;
33
+ private outDir;
34
+ constructor(options: ServerOptions);
35
+ get manifest(): AppManifest | null;
36
+ get address(): ServerAddress;
37
+ up(): Promise<ServerAddress>;
38
+ down(): Promise<void>;
39
+ private onTsBuildSuccess;
40
+ private createVite;
41
+ }