@bluelibs/runner 4.8.5 → 4.9.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.
- package/AI.md +8 -0
- package/README.md +39 -4
- package/dist/browser/index.cjs +596 -428
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.mts +2221 -0
- package/dist/browser/index.d.ts +2221 -0
- package/dist/browser/index.mjs +596 -428
- package/dist/browser/index.mjs.map +1 -1
- package/dist/edge/index.cjs +596 -428
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.d.mts +2221 -0
- package/dist/edge/index.d.ts +2221 -0
- package/dist/edge/index.mjs +596 -428
- package/dist/edge/index.mjs.map +1 -1
- package/dist/node/node.cjs +638 -447
- package/dist/node/node.cjs.map +1 -1
- package/dist/node/node.d.mts +2472 -0
- package/dist/node/node.d.ts +2425 -55
- package/dist/node/node.mjs +638 -447
- package/dist/node/node.mjs.map +1 -1
- package/dist/universal/index.cjs +594 -428
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.mts +2221 -0
- package/dist/universal/index.d.ts +2221 -0
- package/dist/universal/index.mjs +594 -428
- package/dist/universal/index.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/define.d.ts +0 -9
- package/dist/definers/builders/asyncContext.d.ts +0 -11
- package/dist/definers/builders/core.d.ts +0 -30
- package/dist/definers/builders/error.d.ts +0 -13
- package/dist/definers/builders/event.d.ts +0 -12
- package/dist/definers/builders/hook.d.ts +0 -20
- package/dist/definers/builders/middleware.d.ts +0 -39
- package/dist/definers/builders/resource.d.ts +0 -40
- package/dist/definers/builders/tag.d.ts +0 -10
- package/dist/definers/builders/task.d.ts +0 -37
- package/dist/definers/builders/task.phantom.d.ts +0 -27
- package/dist/definers/builders/utils.d.ts +0 -4
- package/dist/definers/defineAsyncContext.d.ts +0 -15
- package/dist/definers/defineError.d.ts +0 -26
- package/dist/definers/defineEvent.d.ts +0 -2
- package/dist/definers/defineHook.d.ts +0 -6
- package/dist/definers/defineOverride.d.ts +0 -17
- package/dist/definers/defineResource.d.ts +0 -2
- package/dist/definers/defineResourceMiddleware.d.ts +0 -2
- package/dist/definers/defineTag.d.ts +0 -12
- package/dist/definers/defineTask.d.ts +0 -18
- package/dist/definers/defineTaskMiddleware.d.ts +0 -2
- package/dist/definers/tools.d.ts +0 -53
- package/dist/defs.d.ts +0 -31
- package/dist/errors.d.ts +0 -62
- package/dist/globals/debug.d.ts +0 -10
- package/dist/globals/globalEvents.d.ts +0 -8
- package/dist/globals/globalMiddleware.d.ts +0 -31
- package/dist/globals/globalResources.d.ts +0 -41
- package/dist/globals/globalTags.d.ts +0 -11
- package/dist/globals/middleware/cache.middleware.d.ts +0 -27
- package/dist/globals/middleware/requireContext.middleware.d.ts +0 -6
- package/dist/globals/middleware/retry.middleware.d.ts +0 -21
- package/dist/globals/middleware/timeout.middleware.d.ts +0 -9
- package/dist/globals/middleware/tunnel.middleware.d.ts +0 -2
- package/dist/globals/resources/debug/debug.resource.d.ts +0 -7
- package/dist/globals/resources/debug/debug.tag.d.ts +0 -2
- package/dist/globals/resources/debug/debugConfig.resource.d.ts +0 -22
- package/dist/globals/resources/debug/executionTracker.middleware.d.ts +0 -50
- package/dist/globals/resources/debug/globalEvent.hook.d.ts +0 -27
- package/dist/globals/resources/debug/hook.hook.d.ts +0 -30
- package/dist/globals/resources/debug/index.d.ts +0 -6
- package/dist/globals/resources/debug/middleware.hook.d.ts +0 -30
- package/dist/globals/resources/debug/types.d.ts +0 -25
- package/dist/globals/resources/debug/utils.d.ts +0 -2
- package/dist/globals/resources/httpClientFactory.resource.d.ts +0 -28
- package/dist/globals/resources/queue.resource.d.ts +0 -10
- package/dist/globals/resources/tunnel/ejson-extensions.d.ts +0 -1
- package/dist/globals/resources/tunnel/error-utils.d.ts +0 -1
- package/dist/globals/resources/tunnel/plan.d.ts +0 -19
- package/dist/globals/resources/tunnel/protocol.d.ts +0 -47
- package/dist/globals/resources/tunnel/serializer.d.ts +0 -9
- package/dist/globals/resources/tunnel/tunnel.policy.tag.d.ts +0 -18
- package/dist/globals/resources/tunnel/tunnel.tag.d.ts +0 -2
- package/dist/globals/resources/tunnel/types.d.ts +0 -42
- package/dist/globals/tunnels/index.d.ts +0 -23
- package/dist/globals/types.d.ts +0 -4
- package/dist/http-client.d.ts +0 -25
- package/dist/http-fetch-tunnel.resource.d.ts +0 -11
- package/dist/index.d.ts +0 -117
- package/dist/models/DependencyProcessor.d.ts +0 -48
- package/dist/models/EventManager.d.ts +0 -153
- package/dist/models/LogPrinter.d.ts +0 -55
- package/dist/models/Logger.d.ts +0 -85
- package/dist/models/MiddlewareManager.d.ts +0 -75
- package/dist/models/OverrideManager.d.ts +0 -13
- package/dist/models/Queue.d.ts +0 -26
- package/dist/models/ResourceInitializer.d.ts +0 -20
- package/dist/models/RunResult.d.ts +0 -35
- package/dist/models/Semaphore.d.ts +0 -61
- package/dist/models/Store.d.ts +0 -73
- package/dist/models/StoreRegistry.d.ts +0 -49
- package/dist/models/StoreValidator.d.ts +0 -8
- package/dist/models/TaskRunner.d.ts +0 -27
- package/dist/models/UnhandledError.d.ts +0 -11
- package/dist/models/index.d.ts +0 -11
- package/dist/models/middleware/InterceptorRegistry.d.ts +0 -56
- package/dist/models/middleware/MiddlewareResolver.d.ts +0 -31
- package/dist/models/middleware/ResourceMiddlewareComposer.d.ts +0 -34
- package/dist/models/middleware/TaskMiddlewareComposer.d.ts +0 -43
- package/dist/models/middleware/ValidationHelper.d.ts +0 -20
- package/dist/models/middleware/index.d.ts +0 -6
- package/dist/models/middleware/types.d.ts +0 -10
- package/dist/models/utils/findCircularDependencies.d.ts +0 -16
- package/dist/models/utils/safeStringify.d.ts +0 -3
- package/dist/node/exposure/allowList.d.ts +0 -3
- package/dist/node/exposure/authenticator.d.ts +0 -6
- package/dist/node/exposure/cors.d.ts +0 -4
- package/dist/node/exposure/createNodeExposure.d.ts +0 -2
- package/dist/node/exposure/exposureServer.d.ts +0 -18
- package/dist/node/exposure/httpResponse.d.ts +0 -10
- package/dist/node/exposure/logging.d.ts +0 -4
- package/dist/node/exposure/multipart.d.ts +0 -27
- package/dist/node/exposure/requestBody.d.ts +0 -11
- package/dist/node/exposure/requestContext.d.ts +0 -17
- package/dist/node/exposure/requestHandlers.d.ts +0 -24
- package/dist/node/exposure/resourceTypes.d.ts +0 -60
- package/dist/node/exposure/router.d.ts +0 -17
- package/dist/node/exposure/serverLifecycle.d.ts +0 -13
- package/dist/node/exposure/types.d.ts +0 -31
- package/dist/node/exposure/utils.d.ts +0 -17
- package/dist/node/exposure.resource.d.ts +0 -12
- package/dist/node/files.d.ts +0 -9
- package/dist/node/http-mixed-client.d.ts +0 -30
- package/dist/node/http-smart-client.model.d.ts +0 -24
- package/dist/node/index.d.ts +0 -1
- package/dist/node/inputFile.model.d.ts +0 -22
- package/dist/node/inputFile.utils.d.ts +0 -14
- package/dist/node/platform/createFile.d.ts +0 -9
- package/dist/node/resources/http-mixed-client.factory.resource.d.ts +0 -17
- package/dist/node/resources/http-smart-client.factory.resource.d.ts +0 -16
- package/dist/node/tunnel.allowlist.d.ts +0 -7
- package/dist/node/upload/manifest.d.ts +0 -22
- package/dist/platform/adapters/browser.d.ts +0 -14
- package/dist/platform/adapters/edge.d.ts +0 -5
- package/dist/platform/adapters/node-als.d.ts +0 -1
- package/dist/platform/adapters/node.d.ts +0 -15
- package/dist/platform/adapters/universal-generic.d.ts +0 -14
- package/dist/platform/adapters/universal.d.ts +0 -17
- package/dist/platform/createFile.d.ts +0 -10
- package/dist/platform/createWebFile.d.ts +0 -11
- package/dist/platform/factory.d.ts +0 -2
- package/dist/platform/index.d.ts +0 -27
- package/dist/platform/types.d.ts +0 -29
- package/dist/processHooks.d.ts +0 -2
- package/dist/run.d.ts +0 -14
- package/dist/testing.d.ts +0 -25
- package/dist/tools/getCallerFile.d.ts +0 -1
- package/dist/tunnels/buildUniversalManifest.d.ts +0 -24
- package/dist/types/asyncContext.d.ts +0 -39
- package/dist/types/contracts.d.ts +0 -63
- package/dist/types/error.d.ts +0 -34
- package/dist/types/event.d.ts +0 -74
- package/dist/types/hook.d.ts +0 -23
- package/dist/types/inputFile.d.ts +0 -34
- package/dist/types/meta.d.ts +0 -18
- package/dist/types/resource.d.ts +0 -87
- package/dist/types/resourceMiddleware.d.ts +0 -47
- package/dist/types/runner.d.ts +0 -68
- package/dist/types/storeTypes.d.ts +0 -40
- package/dist/types/symbols.d.ts +0 -32
- package/dist/types/tag.d.ts +0 -46
- package/dist/types/task.d.ts +0 -54
- package/dist/types/taskMiddleware.d.ts +0 -48
- package/dist/types/utilities.d.ts +0 -113
- package/dist/utils/detectRunnerMode.d.ts +0 -9
package/AI.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
- [Async Context](#async-context)
|
|
16
16
|
- [Errors](#errors)
|
|
17
17
|
- [HTTP \& Tunnels](#http--tunnels)
|
|
18
|
+
- [HTTP Client Factory (Recommended)](#http-client-factory-recommended)
|
|
19
|
+
- [Direct Client Creation (Legacy)](#direct-client-creation-legacy)
|
|
18
20
|
- [Serialization](#serialization)
|
|
19
21
|
- [Testing](#testing)
|
|
20
22
|
- [Observability \& Debugging](#observability--debugging)
|
|
@@ -151,6 +153,12 @@ const sendWelcomeEmail = r
|
|
|
151
153
|
- Use `.on(onAnyOf(...))` to listen to several events while keeping inference.
|
|
152
154
|
- Hooks can set `.order(priority)`; lower numbers run first. Call `event.stopPropagation()` inside `run` to cancel downstream hooks.
|
|
153
155
|
- Wildcard hooks use `.on("*")` and receive every emission except events tagged with `globals.tags.excludeFromGlobalHooks`.
|
|
156
|
+
- Use `.parallel(true)` on event definitions to enable batched parallel execution:
|
|
157
|
+
- Listeners with the same `order` run concurrently within a batch
|
|
158
|
+
- Batches execute sequentially in ascending order priority
|
|
159
|
+
- All listeners in a failing batch run to completion; if multiple fail, an `AggregateError` with all errors is thrown
|
|
160
|
+
- Propagation is checked between batches only (not mid-batch since parallel listeners can't be stopped mid-flight)
|
|
161
|
+
- If any listener throws, subsequent batches will not run
|
|
154
162
|
|
|
155
163
|
### Middleware
|
|
156
164
|
|
package/README.md
CHANGED
|
@@ -467,7 +467,42 @@ const emergencyHandler = r
|
|
|
467
467
|
.build();
|
|
468
468
|
```
|
|
469
469
|
|
|
470
|
-
> **runtime:** "'A really good office messenger.' That
|
|
470
|
+
> **runtime:** "'A really good office messenger.' That's me in rollerblades. You launch a 'userRegistered' flare and I sprint across the building, high-fiving hooks and dodging middleware. `stopPropagation` is you sweeping my legs mid-stride. Rude. Effective. Slightly thrilling."
|
|
471
|
+
|
|
472
|
+
#### Parallel Event Execution
|
|
473
|
+
|
|
474
|
+
When an event fan-out needs more throughput, mark it as parallel to run same-priority listeners concurrently while preserving priority boundaries:
|
|
475
|
+
|
|
476
|
+
```typescript
|
|
477
|
+
const parallelEvent = r.event("app.events.parallel").parallel(true).build();
|
|
478
|
+
|
|
479
|
+
r.hook("app.hooks.first")
|
|
480
|
+
.on(parallelEvent)
|
|
481
|
+
.order(0)
|
|
482
|
+
.run(async (event) => {
|
|
483
|
+
await doWork(event.data);
|
|
484
|
+
})
|
|
485
|
+
.build();
|
|
486
|
+
|
|
487
|
+
r.hook("app.hooks.second")
|
|
488
|
+
.on(parallelEvent)
|
|
489
|
+
.order(0)
|
|
490
|
+
.run(async () => log.info("Runs alongside first"))
|
|
491
|
+
.build();
|
|
492
|
+
|
|
493
|
+
r.hook("app.hooks.after")
|
|
494
|
+
.on(parallelEvent)
|
|
495
|
+
.order(1) // Waits for order 0 batch to complete
|
|
496
|
+
.run(async () => followUp())
|
|
497
|
+
.build();
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
**Execution semantics:**
|
|
501
|
+
|
|
502
|
+
- Listeners sharing the same `order` run concurrently within a batch; batches execute sequentially in ascending order.
|
|
503
|
+
- All listeners in a batch run to completion even if some fail. If multiple listeners throw, an `AggregateError` containing all errors is thrown (or a single error if only one fails).
|
|
504
|
+
- If any listener in a batch throws, later batches are skipped.
|
|
505
|
+
- `stopPropagation()` is evaluated **between batches only**. Setting it inside a batch does not cancel peers already executing in that batch since parallel listeners cannot be stopped mid-flight.
|
|
471
506
|
|
|
472
507
|
### Middleware
|
|
473
508
|
|
|
@@ -481,8 +516,8 @@ import { r } from "@bluelibs/runner";
|
|
|
481
516
|
// Task middleware with config
|
|
482
517
|
type AuthMiddlewareConfig = { requiredRole: string };
|
|
483
518
|
const authMiddleware = r.middleware
|
|
484
|
-
.task("app.middleware.task.auth")
|
|
485
|
-
.run(async ({ task, next }, _deps, config
|
|
519
|
+
.task<AuthMiddlewareConfig>("app.middleware.task.auth")
|
|
520
|
+
.run(async ({ task, next }, _deps, config) => {
|
|
486
521
|
// Must return the value
|
|
487
522
|
return await next(task.input);
|
|
488
523
|
})
|
|
@@ -504,7 +539,7 @@ type AuthInput = { user: { role: string } };
|
|
|
504
539
|
type AuthOutput = { user: { role: string; verified: boolean } };
|
|
505
540
|
|
|
506
541
|
const authMiddleware = r.middleware
|
|
507
|
-
.task("app.middleware.task.auth")
|
|
542
|
+
.task<AuthConfig>("app.middleware.task.auth")
|
|
508
543
|
.run(async ({ task, next }, _deps, config: AuthConfig) => {
|
|
509
544
|
if ((task.input as AuthInput).user.role !== config.requiredRole) {
|
|
510
545
|
throw new Error("Insufficient permissions");
|