@bluelibs/runner 5.2.0 → 5.3.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 (44) hide show
  1. package/README.md +73 -10
  2. package/dist/browser/index.cjs +149 -59
  3. package/dist/browser/index.cjs.map +1 -1
  4. package/dist/browser/index.mjs +149 -60
  5. package/dist/browser/index.mjs.map +1 -1
  6. package/dist/edge/index.cjs +149 -59
  7. package/dist/edge/index.cjs.map +1 -1
  8. package/dist/edge/index.mjs +149 -60
  9. package/dist/edge/index.mjs.map +1 -1
  10. package/dist/node/node.cjs +384 -201
  11. package/dist/node/node.cjs.map +1 -1
  12. package/dist/node/node.mjs +382 -202
  13. package/dist/node/node.mjs.map +1 -1
  14. package/dist/types/definers/builders/error/fluent-builder.interface.d.ts +6 -0
  15. package/dist/types/definers/builders/error/index.d.ts +10 -1
  16. package/dist/types/definers/builders/error/types.d.ts +2 -0
  17. package/dist/types/definers/defineError.d.ts +5 -3
  18. package/dist/types/defs.d.ts +2 -0
  19. package/dist/types/globals/resources/tunnel/protocol.d.ts +3 -0
  20. package/dist/types/models/Store.d.ts +5 -3
  21. package/dist/types/models/StoreRegistry.d.ts +5 -3
  22. package/dist/types/node/durable/core/DurableResource.d.ts +23 -9
  23. package/dist/types/node/durable/core/DurableService.d.ts +15 -9
  24. package/dist/types/node/durable/core/interfaces/service.d.ts +27 -19
  25. package/dist/types/node/durable/core/interfaces/store.d.ts +1 -1
  26. package/dist/types/node/durable/core/managers/ExecutionManager.d.ts +34 -4
  27. package/dist/types/node/durable/core/managers/ScheduleManager.d.ts +5 -3
  28. package/dist/types/node/durable/core/managers/TaskRegistry.d.ts +5 -5
  29. package/dist/types/node/durable/core/managers/WaitManager.d.ts +1 -1
  30. package/dist/types/node/durable/index.d.ts +1 -0
  31. package/dist/types/node/durable/tags/durableWorkflow.tag.d.ts +14 -0
  32. package/dist/types/node/node.d.ts +2 -1
  33. package/dist/types/public.d.ts +4 -1
  34. package/dist/types/testing.d.ts +0 -1
  35. package/dist/types/types/error.d.ts +22 -1
  36. package/dist/types/types/resource.d.ts +2 -4
  37. package/dist/types/types/symbols.d.ts +2 -2
  38. package/dist/types/types/tagged.d.ts +18 -0
  39. package/dist/universal/index.cjs +149 -59
  40. package/dist/universal/index.cjs.map +1 -1
  41. package/dist/universal/index.mjs +149 -60
  42. package/dist/universal/index.mjs.map +1 -1
  43. package/package.json +2 -2
  44. package/readmes/AI.md +25 -9
package/README.md CHANGED
@@ -2,10 +2,19 @@
2
2
 
3
3
  ### Explicit TypeScript Dependency Injection Toolkit
4
4
 
5
- **Compose tasks and resources with predictable lifecycle, testing hooks, and runtime control**
5
+ **Build apps from tasks and resources with explicit dependencies, predictable lifecycle, and first-class testing**
6
6
 
7
- Runner is a TypeScript-first framework for building applications from tasks (functions) and resources
8
- (singletons), with explicit dependency injection, middleware, events, hooks, and lifecycle management.
7
+ Runner is a TypeScript-first toolkit for building an `app` out of small, typed building blocks. You can find more details and a visual overview at [runner.bluelibs.com](https://runner.bluelibs.com/).
8
+
9
+ - **Tasks**: async functions with explicit `dependencies`, middleware, and input/output validation
10
+ - **Resources**: singletons with `init`/`dispose` lifecycle (databases, clients, servers, caches)
11
+ - **Reliability Middleware**: built-in `retry`, `timeout`, `circuitBreaker`, `cache`, and `rateLimit`
12
+ - **HTTP Tunnels**: cross-process execution (the "Distributed Monolith") with zero call-site changes
13
+ - **Durable Workflows**: persistent, crash-recoverable async logic for Node.js
14
+ - **Events & hooks**: typed signals and subscribers for decoupling
15
+ - **Runtime control**: run, observe, test, and dispose your `app` predictably
16
+
17
+ The goal is simple: keep dependencies explicit, keep lifecycle predictable, and make your runtime easy to control in production and in tests.
9
18
 
10
19
  <p align="center">
11
20
  <a href="https://github.com/bluelibs/runner/actions/workflows/ci.yml"><img src="https://github.com/bluelibs/runner/actions/workflows/ci.yml/badge.svg?branch=main" alt="Build Status" /></a>
@@ -16,7 +25,7 @@ Runner is a TypeScript-first framework for building applications from tasks (fun
16
25
  </p>
17
26
 
18
27
  ```typescript
19
- import { r, run } from "@bluelibs/runner";
28
+ import { r, run, globals } from "@bluelibs/runner";
20
29
  import { z } from "zod";
21
30
 
22
31
  const db = r
@@ -40,10 +49,11 @@ const mailer = r
40
49
  }))
41
50
  .build();
42
51
 
43
- // Define a task with dependencies, schema validation, and type-safe input/output
52
+ // Define a task with dependencies, middleware, and zod validation
44
53
  const createUser = r
45
54
  .task("users.create")
46
55
  .dependencies({ db, mailer })
56
+ .middleware([globals.middleware.task.retry.with({ attempts: 3 })])
47
57
  .inputSchema(z.object({ name: z.string(), email: z.string().email() }))
48
58
  .run(async (input, { db, mailer }) => {
49
59
  const user = await db.users.insert(input);
@@ -63,12 +73,13 @@ await runtime.runTask(createUser, { name: "Ada", email: "ada@example.com" });
63
73
 
64
74
  | Resource | Type | Description |
65
75
  | ------------------------------------------------------------------------------------------------------------------- | ------- | ----------------------------------- |
66
- | [Presentation Website](https://runner.bluelibs.com/) | Website | Overview and features |
76
+ | [Official Website & Documentation](https://runner.bluelibs.com/) | Website | Overview and features |
67
77
  | [GitHub Repository](https://github.com/bluelibs/runner) | GitHub | Source code, issues, and releases |
68
78
  | [Runner Dev Tools](https://github.com/bluelibs/runner-dev) | GitHub | Development CLI and tooling |
69
79
  | [API Documentation](https://bluelibs.github.io/runner/) | Docs | TypeDoc-generated reference |
70
80
  | [AI-Friendly Docs](./readmes/AI.md) | Docs | Compact summary (<5000 tokens) |
71
81
  | [Full Guide](./readmes/FULL_GUIDE.md) | Docs | Complete documentation (composed) |
82
+ | [Support & Release Policy](./readmes/ENTERPRISE.md) | Docs | Support windows and deprecation |
72
83
  | [Design Documents](https://github.com/bluelibs/runner/tree/main/readmes) | Docs | Architecture notes and deep dives |
73
84
  | [Example: Express + OpenAPI + SQLite](https://github.com/bluelibs/runner/tree/main/examples/express-openapi-sqlite) | Example | REST API with OpenAPI specification |
74
85
  | [Example: Fastify + MikroORM + PostgreSQL](https://github.com/bluelibs/runner/tree/main/examples/fastify-mikroorm) | Example | Full-stack application with ORM |
@@ -86,19 +97,35 @@ await runtime.runTask(createUser, { name: "Ada", email: "ada@example.com" });
86
97
  - **Need Node-only capabilities**: See [Durable Workflows](./readmes/DURABLE_WORKFLOWS.md)
87
98
  - **Need remote execution**: See [HTTP Tunnels](./readmes/TUNNELS.md) (expose from Node.js, call from any `fetch` runtime)
88
99
  - **Care about portability**: Read [Multi-Platform Architecture](./readmes/MULTI_PLATFORM.md)
100
+ - **Planning upgrades**: See [Support & Release Policy](./readmes/ENTERPRISE.md)
89
101
  - **Want the complete guide**: Read [FULL_GUIDE.md](./readmes/FULL_GUIDE.md)
90
102
  - **Want the short version**: Read [AI.md](./readmes/AI.md)
91
103
 
92
104
  ## Platform Support (Quick Summary)
93
105
 
94
- | Capability | Node.js | Browser | Edge | Notes |
95
- | ------------------------------------------- | ------- | ------- | ---- | ------------------------------------------ |
96
- | Core runtime (tasks/resources/events/hooks) | Full | Full | Full | Platform adapters hide runtime differences |
106
+ | Capability | Node.js | Browser | Edge | Notes |
107
+ | ------------------------------------------------------- | ------- | ------- | ---- | ------------------------------------------ |
108
+ | Core runtime (tasks/resources/middleware/events/hooks) | Full | Full | Full | Platform adapters hide runtime differences |
97
109
  | Async Context (`r.asyncContext`) | Full | None | None | Requires Node.js `AsyncLocalStorage` |
98
110
  | Durable workflows (`@bluelibs/runner/node`) | Full | None | None | Node-only module |
99
111
  | Tunnels client (`createExposureFetch`) | Full | Full | Full | Requires `fetch` |
100
112
  | Tunnels server (`@bluelibs/runner/node`) | Full | None | None | Exposes tasks/events over HTTP |
101
113
 
114
+ ---
115
+
116
+ ## Prerequisites
117
+
118
+ Use these minimums before starting:
119
+
120
+ | Requirement | Minimum | Notes |
121
+ | --------------- | ------------------------ | -------------------------------------------------------------------------- |
122
+ | Node.js | `18.x` | Enforced by `package.json#engines.node` |
123
+ | TypeScript | `5.6+` (recommended) | Required for typed DX and examples in this repository |
124
+ | Package manager | npm / pnpm / yarn / bun | Examples use npm, but any modern package manager works |
125
+ | `fetch` runtime | Built-in or polyfilled | Required for tunnel clients (`createExposureFetch`, universal HTTP client) |
126
+
127
+ If you use the Node-only package (`@bluelibs/runner/node`) for durable workflows or exposure, stay on a supported Node LTS line.
128
+
102
129
  ---
103
130
  ## Your First 5 Minutes
104
131
 
@@ -117,6 +144,8 @@ That's it. Now let's get you to a first successful run.
117
144
 
118
145
  This is the fastest way to run the TypeScript example at the top of this README:
119
146
 
147
+ 0. Confirm prerequisites from [Prerequisites](#prerequisites) (Node `18+`, TypeScript `5.6+` recommended)
148
+
120
149
  1. Install dependencies:
121
150
 
122
151
  ```bash
@@ -131,12 +160,41 @@ npm i -D typescript tsx
131
160
  npx tsx index.ts
132
161
  ```
133
162
 
134
- **Thats it!** You now have a working `Runtime` and you can execute tasks with `runtime.runTask(...)`.
163
+ **That's it!** You now have a working `Runtime` and you can execute tasks with `runtime.runTask(...)`.
135
164
 
136
165
  > **Tip:** If you prefer an end-to-end example with HTTP, OpenAPI, and persistence, jump to the examples below.
137
166
 
138
167
  ---
139
168
 
169
+ ## Runner Dev Tools Quick Start
170
+
171
+ `@bluelibs/runner-dev` gives you CLI scaffolding and runtime introspection.
172
+
173
+ 1. Install (or run without install):
174
+
175
+ ```bash
176
+ npm install -g @bluelibs/runner-dev
177
+ # or
178
+ npx @bluelibs/runner-dev --help
179
+ ```
180
+
181
+ 2. Three common commands:
182
+
183
+ ```bash
184
+ # Scaffold a new Runner project
185
+ runner-dev new my-app --install
186
+
187
+ # Query tasks from a local TypeScript entry file (dry-run mode)
188
+ runner-dev query 'query { tasks { id } }' --entry-file ./src/main.ts
189
+
190
+ # Inspect a running app via GraphQL endpoint
191
+ ENDPOINT=http://localhost:1337/graphql runner-dev overview --details 10
192
+ ```
193
+
194
+ For full CLI and Dev UI docs, see [Runner Dev Tools](https://github.com/bluelibs/runner-dev).
195
+
196
+ ---
197
+
140
198
  ## Real-World Examples
141
199
 
142
200
  - [Express + OpenAPI + SQLite](./examples/express-openapi-sqlite/README.md)
@@ -158,6 +216,11 @@ npx tsx index.ts
158
216
  - **Node-only features**:
159
217
  - [Durable Workflows](./readmes/DURABLE_WORKFLOWS.md)
160
218
  - [HTTP Tunnels](./readmes/TUNNELS.md)
219
+ - **Releases and upgrades**:
220
+ - [GitHub Releases](https://github.com/bluelibs/runner/releases)
221
+ - [Support & Release Policy](./readmes/ENTERPRISE.md)
222
+ - **Operational baseline**:
223
+ - [Production Readiness Checklist](./readmes/FULL_GUIDE.md#production-readiness-checklist)
161
224
  - **Multi-platform architecture**: Read [MULTI_PLATFORM.md](./readmes/MULTI_PLATFORM.md)
162
225
 
163
226
  ---