@bluelibs/runner 5.2.1 → 5.4.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/README.md +54 -1
- package/dist/browser/index.cjs +977 -800
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.mjs +975 -801
- package/dist/browser/index.mjs.map +1 -1
- package/dist/edge/index.cjs +977 -800
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.mjs +975 -801
- package/dist/edge/index.mjs.map +1 -1
- package/dist/node/node.cjs +1994 -2056
- package/dist/node/node.cjs.map +1 -1
- package/dist/node/node.mjs +1990 -2010
- package/dist/node/node.mjs.map +1 -1
- package/dist/types/definers/builders/error/fluent-builder.interface.d.ts +6 -0
- package/dist/types/definers/builders/error/index.d.ts +10 -1
- package/dist/types/definers/builders/error/types.d.ts +2 -0
- package/dist/types/definers/builders/event/utils.d.ts +1 -4
- package/dist/types/definers/builders/hook/utils.d.ts +1 -4
- package/dist/types/definers/builders/middleware/utils.d.ts +1 -4
- package/dist/types/definers/builders/resource/utils.d.ts +1 -4
- package/dist/types/definers/builders/shared/mergeUtils.d.ts +5 -0
- package/dist/types/definers/builders/task/utils.d.ts +1 -4
- package/dist/types/definers/builders/utils.d.ts +1 -1
- package/dist/types/definers/defineError.d.ts +5 -3
- package/dist/types/defs.d.ts +1 -0
- package/dist/types/errors.d.ts +20 -21
- package/dist/types/globals/resources/tunnel/protocol.d.ts +3 -0
- package/dist/types/models/DependencyProcessor.d.ts +1 -1
- package/dist/types/models/MiddlewareManager.d.ts +2 -2
- package/dist/types/models/RunResult.d.ts +1 -1
- package/dist/types/models/Store.d.ts +15 -13
- package/dist/types/models/StoreRegistry.d.ts +19 -16
- package/dist/types/models/middleware/ResourceMiddlewareComposer.d.ts +2 -2
- package/dist/types/models/utils/buildDependencyGraph.d.ts +12 -0
- package/dist/types/models/utils/dependencyStrategies.d.ts +15 -0
- package/dist/types/models/utils/disposeOrder.d.ts +7 -0
- package/dist/types/node/durable/core/DurableResource.d.ts +24 -9
- package/dist/types/node/durable/core/DurableService.d.ts +15 -9
- package/dist/types/node/durable/core/interfaces/service.d.ts +27 -19
- package/dist/types/node/durable/core/interfaces/store.d.ts +1 -1
- package/dist/types/node/durable/core/managers/ExecutionManager.d.ts +34 -4
- package/dist/types/node/durable/core/managers/ScheduleManager.d.ts +5 -3
- package/dist/types/node/durable/core/managers/TaskRegistry.d.ts +5 -5
- package/dist/types/node/durable/core/managers/WaitManager.d.ts +1 -1
- package/dist/types/node/durable/core/resource.d.ts +5 -5
- package/dist/types/node/durable/index.d.ts +1 -0
- package/dist/types/node/durable/resources/memoryDurableResource.d.ts +5 -5
- package/dist/types/node/durable/resources/redisDurableResource.d.ts +5 -5
- package/dist/types/node/durable/tags/durableWorkflow.tag.d.ts +19 -0
- package/dist/types/node/exposure/requestContext.d.ts +1 -1
- package/dist/types/node/exposure/resource.d.ts +7 -7
- package/dist/types/node/http/http-mixed-client.factory.resource.d.ts +1 -1
- package/dist/types/node/http/http-smart-client.factory.resource.d.ts +1 -1
- package/dist/types/node/node.d.ts +1 -184
- package/dist/types/platform/adapters/edge.d.ts +17 -0
- package/dist/types/platform/adapters/universal-generic.d.ts +3 -0
- package/dist/types/platform/index.d.ts +1 -0
- package/dist/types/platform/types.d.ts +7 -1
- package/dist/types/public.d.ts +6 -1
- package/dist/types/testing.d.ts +0 -1
- package/dist/types/tools/LockableMap.d.ts +20 -0
- package/dist/types/types/error.d.ts +22 -1
- package/dist/types/types/resource.d.ts +2 -4
- package/dist/types/types/symbols.d.ts +3 -3
- package/dist/types/types/tagged.d.ts +18 -0
- package/dist/types/types/task.d.ts +1 -1
- package/dist/ui/assets/index-Bo7Gi6Vq.js +141 -0
- package/dist/ui/assets/index-Y_9aLumt.css +1 -0
- package/dist/ui/index.html +2 -3
- package/dist/universal/index.cjs +977 -800
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.mjs +975 -801
- package/dist/universal/index.mjs.map +1 -1
- package/package.json +1 -2
- package/readmes/AI.md +59 -12
- package/dist/ui/assets/index-2cb8f39f.js +0 -141
- package/dist/ui/assets/index-b1f988bf.css +0 -1
- /package/dist/types/{tunnels → tools}/buildUniversalManifest.d.ts +0 -0
- /package/dist/types/{processHooks.d.ts → tools/processShutdownHooks.d.ts} +0 -0
|
@@ -23,9 +23,15 @@ export interface IAsyncLocalStorage<T> {
|
|
|
23
23
|
run<R>(store: T, callback: () => R): R;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Backward-compatible utility functions retained for consumers
|
|
27
|
+
* importing environment guards from `platform/types`.
|
|
27
28
|
*/
|
|
28
29
|
export declare function isNode(): boolean;
|
|
29
30
|
export declare function isBrowser(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Legacy alias kept for compatibility.
|
|
33
|
+
* Worker-like runtimes are now modeled under the "edge" platform id.
|
|
34
|
+
*/
|
|
30
35
|
export declare function isWebWorker(): boolean;
|
|
36
|
+
export declare function isEdge(): boolean;
|
|
31
37
|
export declare function isUniversal(): boolean;
|
package/dist/types/public.d.ts
CHANGED
|
@@ -193,7 +193,9 @@ export declare const r: Readonly<{
|
|
|
193
193
|
tag: typeof import("./definers/builders/tag").tagBuilder;
|
|
194
194
|
override: typeof overrideBuilder;
|
|
195
195
|
asyncContext: typeof import("./definers/builders/asyncContext").asyncContextBuilder;
|
|
196
|
-
error: typeof import("./definers/builders/error").errorBuilder
|
|
196
|
+
error: typeof import("./definers/builders/error").errorBuilder & {
|
|
197
|
+
is: (error: unknown) => error is import("./public").RunnerError;
|
|
198
|
+
};
|
|
197
199
|
middleware: Readonly<{
|
|
198
200
|
task: typeof import("./definers/builders/middleware").taskMiddlewareBuilder;
|
|
199
201
|
resource: typeof import("./definers/builders/middleware").resourceMiddlewareBuilder;
|
|
@@ -203,7 +205,10 @@ export * as definitions from "./defs";
|
|
|
203
205
|
export * from "./models";
|
|
204
206
|
export * from "./globals/types";
|
|
205
207
|
export * as Errors from "./errors";
|
|
208
|
+
export { cancellationError } from "./errors";
|
|
206
209
|
export { PlatformAdapter, setPlatform } from "./platform";
|
|
210
|
+
export { RunnerError } from "./definers/defineError";
|
|
211
|
+
export { LockableMap } from "./tools/LockableMap";
|
|
207
212
|
export * from "./http-client";
|
|
208
213
|
export * from "./http-fetch-tunnel.resource";
|
|
209
214
|
export { Serializer, SymbolPolicy, SymbolPolicyErrorMessage, } from "./serializer";
|
package/dist/types/testing.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export interface TestFacade {
|
|
|
12
12
|
* Helper to create a minimal test harness resource that wraps a root app (or any registerable)
|
|
13
13
|
* and exposes convenient testing utilities while running the full ecosystem
|
|
14
14
|
* (registration, overrides, middleware, events) without modifying the core API.
|
|
15
|
-
* @deprecated Use `run` instead with your testResource, as it provides the necessary toolkit.
|
|
16
15
|
*/
|
|
17
16
|
export declare function createTestResource(root: RegisterableItems, options?: {
|
|
18
17
|
overrides?: Array<IResource | ITask | ITaskMiddleware | IResourceMiddleware | IResourceWithConfig>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Map that can be permanently locked to prevent further mutations.
|
|
3
|
+
*
|
|
4
|
+
* Before locking it behaves exactly like a regular `Map`.
|
|
5
|
+
* After `lock()` is called, any call to `set`, `delete` or `clear`
|
|
6
|
+
* throws immediately — enforcing immutability at the data-structure level.
|
|
7
|
+
*/
|
|
8
|
+
export declare class LockableMap<K, V> extends Map<K, V> {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(name?: string);
|
|
11
|
+
/** Whether the map is currently locked. */
|
|
12
|
+
get locked(): boolean;
|
|
13
|
+
/** Permanently lock the map — no further mutations allowed. */
|
|
14
|
+
lock(): void;
|
|
15
|
+
/** @throws if the map is locked */
|
|
16
|
+
private throwIfLocked;
|
|
17
|
+
set(key: K, value: V): this;
|
|
18
|
+
delete(key: K): boolean;
|
|
19
|
+
clear(): void;
|
|
20
|
+
}
|
|
@@ -6,9 +6,16 @@ export type ErrorReference = string | IErrorHelper<any>;
|
|
|
6
6
|
export type ThrowsList = ReadonlyArray<ErrorReference>;
|
|
7
7
|
export interface IErrorDefinition<TData extends DefaultErrorType = DefaultErrorType> {
|
|
8
8
|
id: string;
|
|
9
|
+
httpCode?: number;
|
|
9
10
|
serialize?: (data: TData) => string;
|
|
10
11
|
parse?: (data: string) => TData;
|
|
11
12
|
format?: (data: TData) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional advice on how to fix the error. Appears in the stringified
|
|
15
|
+
* error message after the main message. Can be a static string or a
|
|
16
|
+
* function that receives the error data and returns a string.
|
|
17
|
+
*/
|
|
18
|
+
remediation?: string | ((data: TData) => string);
|
|
12
19
|
/**
|
|
13
20
|
* Validate error data on throw(). If provided, data is parsed first.
|
|
14
21
|
*/
|
|
@@ -17,8 +24,20 @@ export interface IErrorDefinition<TData extends DefaultErrorType = DefaultErrorT
|
|
|
17
24
|
}
|
|
18
25
|
export interface IErrorDefinitionFinal<TData extends DefaultErrorType> extends IErrorDefinition<TData> {
|
|
19
26
|
format: (data: TData) => string;
|
|
27
|
+
httpCode?: number;
|
|
28
|
+
remediation?: string | ((data: TData) => string);
|
|
20
29
|
}
|
|
21
30
|
export type DefaultErrorType = Record<string, unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* Runtime error shape thrown by r.error()/defineError() helpers.
|
|
33
|
+
* Consumers can use helper.is(error) to narrow unknown values to this type.
|
|
34
|
+
*/
|
|
35
|
+
export interface IRunnerError<TData extends DefaultErrorType = DefaultErrorType> extends Error {
|
|
36
|
+
id: string;
|
|
37
|
+
httpCode?: number;
|
|
38
|
+
data: TData;
|
|
39
|
+
remediation?: string;
|
|
40
|
+
}
|
|
22
41
|
/**
|
|
23
42
|
* Runtime helper returned by defineError()/r.error().
|
|
24
43
|
* Contains helpers to throw typed errors and perform type-safe checks.
|
|
@@ -26,10 +45,12 @@ export type DefaultErrorType = Record<string, unknown>;
|
|
|
26
45
|
export interface IErrorHelper<TData extends DefaultErrorType = DefaultErrorType> {
|
|
27
46
|
/** Unique id for registration and DI */
|
|
28
47
|
id: string;
|
|
48
|
+
/** Optional HTTP status code associated with this error helper */
|
|
49
|
+
httpCode?: number;
|
|
29
50
|
/** Throw a typed error with the given data */
|
|
30
51
|
throw(data: TData): never;
|
|
31
52
|
/** Type guard for checking if an unknown error is this error */
|
|
32
|
-
is(error: unknown):
|
|
53
|
+
is(error: unknown): error is IRunnerError<TData>;
|
|
33
54
|
/** Brand symbol for runtime detection */
|
|
34
55
|
[symbolError]: true;
|
|
35
56
|
/** Return an optional dependency wrapper for this error */
|
|
@@ -3,7 +3,7 @@ import { IResourceMiddleware, ResourceMiddlewareAttachmentType } from "./resourc
|
|
|
3
3
|
import { TagType } from "./tag";
|
|
4
4
|
import { IResourceMeta } from "./meta";
|
|
5
5
|
import type { ThrowsList } from "./error";
|
|
6
|
-
import { symbolFilePath, symbolResource, symbolResourceWithConfig
|
|
6
|
+
import { symbolFilePath, symbolForkedFrom, symbolResource, symbolResourceWithConfig } from "./symbols";
|
|
7
7
|
import { EnsureInputSatisfiesContracts, EnsureOutputSatisfiesContracts, HasInputContracts, HasOutputContracts, InferInputOrViolationFromContracts } from "./contracts";
|
|
8
8
|
export type { DependencyMapType, IOptionalDependency, IValidationSchema, OverridableElements, RegisterableItems, ResourceDependencyValuesType, } from "./utilities";
|
|
9
9
|
export type { ResourceMiddlewareAttachmentType } from "./resourceMiddleware";
|
|
@@ -27,8 +27,6 @@ export interface ResourceForkOptions {
|
|
|
27
27
|
export interface ResourceForkInfo {
|
|
28
28
|
/** The id of the resource that was forked. */
|
|
29
29
|
readonly fromId: string;
|
|
30
|
-
/** Best-effort call-site file path for the fork operation. */
|
|
31
|
-
readonly forkedAtFilePath: string;
|
|
32
30
|
}
|
|
33
31
|
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
34
32
|
export type IsUnspecified<T> = [T] extends [undefined] ? true : [T] extends [void] ? true : IsAny<T> extends true ? true : false;
|
|
@@ -109,7 +107,7 @@ export interface IResource<TConfig = void, TValue extends Promise<any> = Promise
|
|
|
109
107
|
[symbolFilePath]: string;
|
|
110
108
|
[symbolResource]: true;
|
|
111
109
|
/** Present only on forked resources. */
|
|
112
|
-
[
|
|
110
|
+
[symbolForkedFrom]?: ResourceForkInfo;
|
|
113
111
|
/** Normalized list of error ids declared via `throws`. */
|
|
114
112
|
throws?: readonly string[];
|
|
115
113
|
/** Return an optional dependency wrapper for this resource. */
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
7
|
export declare const symbolTask: unique symbol;
|
|
8
|
-
/** Marks a task as a phantom task (
|
|
8
|
+
/** Marks a task as a phantom task (throws when unrouted; meant to be tunneled/routed). */
|
|
9
9
|
export declare const symbolPhantomTask: unique symbol;
|
|
10
10
|
export declare const symbolResource: unique symbol;
|
|
11
|
-
/** @internal
|
|
12
|
-
export declare const
|
|
11
|
+
/** @internal Generic fork provenance metadata for definitions that support `.fork()` */
|
|
12
|
+
export declare const symbolForkedFrom: unique symbol;
|
|
13
13
|
export declare const symbolResourceWithConfig: unique symbol;
|
|
14
14
|
export declare const symbolEvent: unique symbol;
|
|
15
15
|
/** @internal Marks an error helper definition */
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { HasInputContracts, HasOutputContracts, InferInputOrViolationFromContracts, InferOutputOrViolationFromContracts } from "./contracts";
|
|
2
|
+
import type { IResource } from "./resource";
|
|
3
|
+
import type { ITask } from "./task";
|
|
4
|
+
import type { ITag } from "./tag";
|
|
5
|
+
type TagInputContract<TTag extends ITag<any, any, any>> = HasInputContracts<[TTag]> extends true ? InferInputOrViolationFromContracts<[TTag]> : any;
|
|
6
|
+
type TagOutputContract<TTag extends ITag<any, any, any>> = HasOutputContracts<[TTag]> extends true ? InferOutputOrViolationFromContracts<[TTag]> : any;
|
|
7
|
+
export type AnyResource = IResource<any, any, any, any, any, any, any>;
|
|
8
|
+
/**
|
|
9
|
+
* A task discovered by a concrete tag. If the tag carries contracts,
|
|
10
|
+
* its input/output contracts are reflected in the task signature.
|
|
11
|
+
*/
|
|
12
|
+
export type TaggedTask<TTag extends ITag<any, any, any>> = ITask<TagInputContract<TTag>, Promise<TagOutputContract<TTag>>, any, any, any, any>;
|
|
13
|
+
/**
|
|
14
|
+
* A resource discovered by a concrete tag. If the tag carries contracts,
|
|
15
|
+
* its config/value contracts are reflected in the resource signature.
|
|
16
|
+
*/
|
|
17
|
+
export type TaggedResource<TTag extends ITag<any, any, any>> = IResource<TagInputContract<TTag>, Promise<TagOutputContract<TTag>>, any, any, any, any, any>;
|
|
18
|
+
export {};
|
|
@@ -70,7 +70,7 @@ export interface ITask<TInput = any, TOutput extends Promise<any> = any, TDepend
|
|
|
70
70
|
tags: TTags;
|
|
71
71
|
}
|
|
72
72
|
export type AnyTask = ITask<any, any, any, any, any, any>;
|
|
73
|
-
/** Narrowed type for phantom tasks (
|
|
73
|
+
/** Narrowed type for phantom tasks (throws unless routed through a tunnel). */
|
|
74
74
|
export type IPhantomTask<TInput = any, TResolved = any, TDependencies extends DependencyMapType = {}, TMeta extends ITaskMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends TaskMiddlewareAttachmentType[] = TaskMiddlewareAttachmentType[]> = ITask<TInput, Promise<TResolved>, TDependencies, TMeta, TTags, TMiddleware> & {
|
|
75
75
|
[symbolPhantomTask]: true;
|
|
76
76
|
};
|