@bluelibs/runner 4.8.6 → 5.0.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 (177) hide show
  1. package/README.md +110 -3440
  2. package/dist/browser/index.cjs +6586 -3478
  3. package/dist/browser/index.cjs.map +1 -1
  4. package/dist/browser/index.d.mts +2890 -0
  5. package/dist/browser/index.d.ts +2890 -0
  6. package/dist/browser/index.mjs +6574 -3466
  7. package/dist/browser/index.mjs.map +1 -1
  8. package/dist/edge/index.cjs +6586 -3478
  9. package/dist/edge/index.cjs.map +1 -1
  10. package/dist/edge/index.d.mts +2890 -0
  11. package/dist/edge/index.d.ts +2890 -0
  12. package/dist/edge/index.mjs +6574 -3466
  13. package/dist/edge/index.mjs.map +1 -1
  14. package/dist/node/node.cjs +42337 -7087
  15. package/dist/node/node.cjs.map +1 -1
  16. package/dist/node/node.d.mts +4593 -0
  17. package/dist/node/node.d.ts +4546 -55
  18. package/dist/node/node.mjs +42251 -7035
  19. package/dist/node/node.mjs.map +1 -1
  20. package/dist/ui/assets/index-2cb8f39f.js +141 -0
  21. package/dist/ui/assets/index-b1f988bf.css +1 -0
  22. package/dist/ui/index.html +14 -0
  23. package/dist/universal/index.cjs +7109 -4003
  24. package/dist/universal/index.cjs.map +1 -1
  25. package/dist/universal/index.d.mts +2890 -0
  26. package/dist/universal/index.d.ts +2890 -0
  27. package/dist/universal/index.mjs +7102 -3996
  28. package/dist/universal/index.mjs.map +1 -1
  29. package/package.json +57 -25
  30. package/readmes/AI.md +534 -0
  31. package/AI.md +0 -454
  32. package/dist/define.d.ts +0 -9
  33. package/dist/definers/builders/asyncContext.d.ts +0 -13
  34. package/dist/definers/builders/core.d.ts +0 -30
  35. package/dist/definers/builders/error.d.ts +0 -15
  36. package/dist/definers/builders/event.d.ts +0 -12
  37. package/dist/definers/builders/hook.d.ts +0 -20
  38. package/dist/definers/builders/middleware.d.ts +0 -39
  39. package/dist/definers/builders/resource.d.ts +0 -40
  40. package/dist/definers/builders/tag.d.ts +0 -10
  41. package/dist/definers/builders/task.d.ts +0 -37
  42. package/dist/definers/builders/task.phantom.d.ts +0 -27
  43. package/dist/definers/builders/utils.d.ts +0 -4
  44. package/dist/definers/defineAsyncContext.d.ts +0 -15
  45. package/dist/definers/defineError.d.ts +0 -26
  46. package/dist/definers/defineEvent.d.ts +0 -2
  47. package/dist/definers/defineHook.d.ts +0 -6
  48. package/dist/definers/defineOverride.d.ts +0 -17
  49. package/dist/definers/defineResource.d.ts +0 -2
  50. package/dist/definers/defineResourceMiddleware.d.ts +0 -2
  51. package/dist/definers/defineTag.d.ts +0 -12
  52. package/dist/definers/defineTask.d.ts +0 -18
  53. package/dist/definers/defineTaskMiddleware.d.ts +0 -2
  54. package/dist/definers/tools.d.ts +0 -53
  55. package/dist/defs.d.ts +0 -31
  56. package/dist/errors.d.ts +0 -62
  57. package/dist/globals/debug.d.ts +0 -10
  58. package/dist/globals/globalEvents.d.ts +0 -8
  59. package/dist/globals/globalMiddleware.d.ts +0 -31
  60. package/dist/globals/globalResources.d.ts +0 -41
  61. package/dist/globals/globalTags.d.ts +0 -11
  62. package/dist/globals/middleware/cache.middleware.d.ts +0 -27
  63. package/dist/globals/middleware/requireContext.middleware.d.ts +0 -6
  64. package/dist/globals/middleware/retry.middleware.d.ts +0 -21
  65. package/dist/globals/middleware/timeout.middleware.d.ts +0 -9
  66. package/dist/globals/middleware/tunnel.middleware.d.ts +0 -2
  67. package/dist/globals/resources/debug/debug.resource.d.ts +0 -7
  68. package/dist/globals/resources/debug/debug.tag.d.ts +0 -2
  69. package/dist/globals/resources/debug/debugConfig.resource.d.ts +0 -22
  70. package/dist/globals/resources/debug/executionTracker.middleware.d.ts +0 -50
  71. package/dist/globals/resources/debug/globalEvent.hook.d.ts +0 -27
  72. package/dist/globals/resources/debug/hook.hook.d.ts +0 -30
  73. package/dist/globals/resources/debug/index.d.ts +0 -6
  74. package/dist/globals/resources/debug/middleware.hook.d.ts +0 -30
  75. package/dist/globals/resources/debug/types.d.ts +0 -25
  76. package/dist/globals/resources/debug/utils.d.ts +0 -2
  77. package/dist/globals/resources/httpClientFactory.resource.d.ts +0 -28
  78. package/dist/globals/resources/queue.resource.d.ts +0 -10
  79. package/dist/globals/resources/tunnel/ejson-extensions.d.ts +0 -1
  80. package/dist/globals/resources/tunnel/error-utils.d.ts +0 -1
  81. package/dist/globals/resources/tunnel/plan.d.ts +0 -19
  82. package/dist/globals/resources/tunnel/protocol.d.ts +0 -47
  83. package/dist/globals/resources/tunnel/serializer.d.ts +0 -9
  84. package/dist/globals/resources/tunnel/tunnel.policy.tag.d.ts +0 -18
  85. package/dist/globals/resources/tunnel/tunnel.tag.d.ts +0 -2
  86. package/dist/globals/resources/tunnel/types.d.ts +0 -42
  87. package/dist/globals/tunnels/index.d.ts +0 -23
  88. package/dist/globals/types.d.ts +0 -4
  89. package/dist/http-client.d.ts +0 -25
  90. package/dist/http-fetch-tunnel.resource.d.ts +0 -11
  91. package/dist/index.d.ts +0 -117
  92. package/dist/models/DependencyProcessor.d.ts +0 -48
  93. package/dist/models/EventManager.d.ts +0 -153
  94. package/dist/models/LogPrinter.d.ts +0 -55
  95. package/dist/models/Logger.d.ts +0 -85
  96. package/dist/models/MiddlewareManager.d.ts +0 -75
  97. package/dist/models/OverrideManager.d.ts +0 -13
  98. package/dist/models/Queue.d.ts +0 -26
  99. package/dist/models/ResourceInitializer.d.ts +0 -20
  100. package/dist/models/RunResult.d.ts +0 -35
  101. package/dist/models/Semaphore.d.ts +0 -61
  102. package/dist/models/Store.d.ts +0 -73
  103. package/dist/models/StoreRegistry.d.ts +0 -49
  104. package/dist/models/StoreValidator.d.ts +0 -8
  105. package/dist/models/TaskRunner.d.ts +0 -27
  106. package/dist/models/UnhandledError.d.ts +0 -11
  107. package/dist/models/index.d.ts +0 -11
  108. package/dist/models/middleware/InterceptorRegistry.d.ts +0 -56
  109. package/dist/models/middleware/MiddlewareResolver.d.ts +0 -31
  110. package/dist/models/middleware/ResourceMiddlewareComposer.d.ts +0 -34
  111. package/dist/models/middleware/TaskMiddlewareComposer.d.ts +0 -43
  112. package/dist/models/middleware/ValidationHelper.d.ts +0 -20
  113. package/dist/models/middleware/index.d.ts +0 -6
  114. package/dist/models/middleware/types.d.ts +0 -10
  115. package/dist/models/utils/findCircularDependencies.d.ts +0 -16
  116. package/dist/models/utils/safeStringify.d.ts +0 -3
  117. package/dist/node/exposure/allowList.d.ts +0 -3
  118. package/dist/node/exposure/authenticator.d.ts +0 -6
  119. package/dist/node/exposure/cors.d.ts +0 -4
  120. package/dist/node/exposure/createNodeExposure.d.ts +0 -2
  121. package/dist/node/exposure/exposureServer.d.ts +0 -18
  122. package/dist/node/exposure/httpResponse.d.ts +0 -10
  123. package/dist/node/exposure/logging.d.ts +0 -4
  124. package/dist/node/exposure/multipart.d.ts +0 -27
  125. package/dist/node/exposure/requestBody.d.ts +0 -11
  126. package/dist/node/exposure/requestContext.d.ts +0 -17
  127. package/dist/node/exposure/requestHandlers.d.ts +0 -24
  128. package/dist/node/exposure/resourceTypes.d.ts +0 -60
  129. package/dist/node/exposure/router.d.ts +0 -17
  130. package/dist/node/exposure/serverLifecycle.d.ts +0 -13
  131. package/dist/node/exposure/types.d.ts +0 -31
  132. package/dist/node/exposure/utils.d.ts +0 -17
  133. package/dist/node/exposure.resource.d.ts +0 -12
  134. package/dist/node/files.d.ts +0 -9
  135. package/dist/node/http-mixed-client.d.ts +0 -30
  136. package/dist/node/http-smart-client.model.d.ts +0 -24
  137. package/dist/node/index.d.ts +0 -1
  138. package/dist/node/inputFile.model.d.ts +0 -22
  139. package/dist/node/inputFile.utils.d.ts +0 -14
  140. package/dist/node/platform/createFile.d.ts +0 -9
  141. package/dist/node/resources/http-mixed-client.factory.resource.d.ts +0 -17
  142. package/dist/node/resources/http-smart-client.factory.resource.d.ts +0 -16
  143. package/dist/node/tunnel.allowlist.d.ts +0 -7
  144. package/dist/node/upload/manifest.d.ts +0 -22
  145. package/dist/platform/adapters/browser.d.ts +0 -14
  146. package/dist/platform/adapters/edge.d.ts +0 -5
  147. package/dist/platform/adapters/node-als.d.ts +0 -1
  148. package/dist/platform/adapters/node.d.ts +0 -15
  149. package/dist/platform/adapters/universal-generic.d.ts +0 -14
  150. package/dist/platform/adapters/universal.d.ts +0 -17
  151. package/dist/platform/createFile.d.ts +0 -10
  152. package/dist/platform/createWebFile.d.ts +0 -11
  153. package/dist/platform/factory.d.ts +0 -2
  154. package/dist/platform/index.d.ts +0 -27
  155. package/dist/platform/types.d.ts +0 -29
  156. package/dist/processHooks.d.ts +0 -2
  157. package/dist/run.d.ts +0 -14
  158. package/dist/testing.d.ts +0 -25
  159. package/dist/tools/getCallerFile.d.ts +0 -1
  160. package/dist/tunnels/buildUniversalManifest.d.ts +0 -24
  161. package/dist/types/asyncContext.d.ts +0 -41
  162. package/dist/types/contracts.d.ts +0 -63
  163. package/dist/types/error.d.ts +0 -36
  164. package/dist/types/event.d.ts +0 -74
  165. package/dist/types/hook.d.ts +0 -23
  166. package/dist/types/inputFile.d.ts +0 -34
  167. package/dist/types/meta.d.ts +0 -22
  168. package/dist/types/resource.d.ts +0 -87
  169. package/dist/types/resourceMiddleware.d.ts +0 -47
  170. package/dist/types/runner.d.ts +0 -68
  171. package/dist/types/storeTypes.d.ts +0 -40
  172. package/dist/types/symbols.d.ts +0 -32
  173. package/dist/types/tag.d.ts +0 -46
  174. package/dist/types/task.d.ts +0 -54
  175. package/dist/types/taskMiddleware.d.ts +0 -48
  176. package/dist/types/utilities.d.ts +0 -113
  177. package/dist/utils/detectRunnerMode.d.ts +0 -9
@@ -1,24 +0,0 @@
1
- import { Readable } from "stream";
2
- import type { Serializer } from "../globals/resources/tunnel/serializer";
3
- import type { IAsyncContext } from "../types/asyncContext";
4
- export interface HttpSmartClientAuthConfig {
5
- header?: string;
6
- token: string;
7
- }
8
- export interface HttpSmartClientConfig {
9
- baseUrl: string;
10
- auth?: HttpSmartClientAuthConfig;
11
- timeoutMs?: number;
12
- serializer: Serializer;
13
- onRequest?: (ctx: {
14
- url: string;
15
- headers: Record<string, string>;
16
- }) => void | Promise<void>;
17
- contexts?: Array<IAsyncContext<any>>;
18
- }
19
- export interface HttpSmartClient {
20
- task<I = unknown, O = unknown>(id: string, input?: I): Promise<O | Readable>;
21
- event<P = unknown>(id: string, payload?: P): Promise<void>;
22
- }
23
- export declare function createHttpSmartClient(cfg: HttpSmartClientConfig): HttpSmartClient;
24
- export type { Readable };
@@ -1 +0,0 @@
1
- export * from "./node";
@@ -1,22 +0,0 @@
1
- import type { InputFile } from "../types/inputFile";
2
- import { Readable } from "stream";
3
- export type NodeReadable = Readable;
4
- export declare class NodeInputFile implements InputFile<NodeReadable> {
5
- name: string;
6
- type?: string | undefined;
7
- size?: number | undefined;
8
- lastModified?: number | undefined;
9
- extra?: Record<string, unknown> | undefined;
10
- private _stream;
11
- private _consumed;
12
- constructor(meta: Omit<InputFile<NodeReadable>, "resolve" | "stream" | "toTempFile">, stream: NodeReadable);
13
- resolve(): Promise<{
14
- stream: NodeReadable;
15
- }>;
16
- stream(): NodeReadable;
17
- toTempFile(dir?: string): Promise<{
18
- path: string;
19
- bytesWritten: number;
20
- }>;
21
- }
22
- export declare function toPassThrough(stream: NodeReadable): NodeReadable;
@@ -1,14 +0,0 @@
1
- import type { InputFile } from "../types/inputFile";
2
- import type { Readable } from "stream";
3
- /**
4
- * Read an InputFile's contents fully into memory as a Buffer.
5
- * Note: InputFile streams are single-use; this will consume it.
6
- */
7
- export declare function readInputFileToBuffer(file: InputFile<Readable>): Promise<Buffer>;
8
- /**
9
- * Write an InputFile's contents to a specific path, returning bytesWritten.
10
- * Note: InputFile streams are single-use; this will consume it.
11
- */
12
- export declare function writeInputFileToPath(file: InputFile<Readable>, targetPath: string): Promise<{
13
- bytesWritten: number;
14
- }>;
@@ -1,9 +0,0 @@
1
- import type { Readable } from "stream";
2
- import type { InputFileMeta, EjsonFileSentinel } from "../../types/inputFile";
3
- export interface NodeFileSource {
4
- stream?: Readable;
5
- buffer?: Buffer;
6
- }
7
- export declare function createFile(meta: InputFileMeta, source: NodeFileSource, id?: string): EjsonFileSentinel & {
8
- _node: NodeFileSource;
9
- };
@@ -1,17 +0,0 @@
1
- import type { MixedHttpClient } from "../http-mixed-client";
2
- export interface HttpMixedClientFactoryConfig {
3
- baseUrl: string;
4
- auth?: {
5
- header?: string;
6
- token: string;
7
- };
8
- timeoutMs?: number;
9
- fetchImpl?: typeof fetch;
10
- onRequest?: (ctx: {
11
- url: string;
12
- headers: Record<string, string>;
13
- }) => void | Promise<void>;
14
- }
15
- export type HttpMixedClientFactory = (config: HttpMixedClientFactoryConfig) => MixedHttpClient;
16
- export declare const httpMixedClientFactory: import("..").IResource<void, Promise<HttpMixedClientFactory>, {}, any, any, import("..").TagType[], import("..").ResourceMiddlewareAttachmentType[]>;
17
- export type { MixedHttpClient };
@@ -1,16 +0,0 @@
1
- import type { HttpSmartClient } from "../http-smart-client.model";
2
- export interface HttpSmartClientFactoryConfig {
3
- baseUrl: string;
4
- auth?: {
5
- header?: string;
6
- token: string;
7
- };
8
- timeoutMs?: number;
9
- onRequest?: (ctx: {
10
- url: string;
11
- headers: Record<string, string>;
12
- }) => void | Promise<void>;
13
- }
14
- export type HttpSmartClientFactory = (config: HttpSmartClientFactoryConfig) => HttpSmartClient;
15
- export declare const httpSmartClientFactory: import("..").IResource<void, Promise<HttpSmartClientFactory>, {}, any, any, import("..").TagType[], import("..").ResourceMiddlewareAttachmentType[]>;
16
- export type { HttpSmartClient };
@@ -1,7 +0,0 @@
1
- import type { Store } from "../models/Store";
2
- export interface TunnelAllowList {
3
- enabled: boolean;
4
- taskIds: Set<string>;
5
- eventIds: Set<string>;
6
- }
7
- export declare function computeAllowList(store: Store): TunnelAllowList;
@@ -1,22 +0,0 @@
1
- import type { Readable } from "stream";
2
- import type { InputFileMeta } from "../../types/inputFile";
3
- export interface NodeFileSource {
4
- id: string;
5
- meta: InputFileMeta;
6
- source: {
7
- type: "buffer";
8
- buffer: Buffer;
9
- } | {
10
- type: "stream";
11
- stream: Readable;
12
- };
13
- }
14
- export interface BuiltManifest<T = any> {
15
- input: T;
16
- files: NodeFileSource[];
17
- }
18
- /**
19
- * Walk an input object and collect File sentinels having local Node sources.
20
- * It returns a shallow-cloned structure where any internal _node fields are removed.
21
- */
22
- export declare function buildNodeManifest<T = any>(input: T): BuiltManifest<T>;
@@ -1,14 +0,0 @@
1
- import type { IAsyncLocalStorage, IPlatformAdapter, PlatformId } from "../types";
2
- export declare class BrowserPlatformAdapter implements IPlatformAdapter {
3
- readonly id: PlatformId;
4
- init(): Promise<void>;
5
- onUncaughtException(handler: (error: any) => void): () => any;
6
- onUnhandledRejection(handler: (reason: any) => void): () => any;
7
- onShutdownSignal(handler: () => void): () => void;
8
- exit(): void;
9
- getEnv(key: string): any;
10
- hasAsyncLocalStorage(): boolean;
11
- createAsyncLocalStorage<T>(): IAsyncLocalStorage<T>;
12
- setTimeout: typeof setTimeout;
13
- clearTimeout: typeof clearTimeout;
14
- }
@@ -1,5 +0,0 @@
1
- import { BrowserPlatformAdapter } from "./browser";
2
- export declare class EdgePlatformAdapter extends BrowserPlatformAdapter {
3
- readonly id: "edge";
4
- onShutdownSignal(handler: () => void): () => void;
5
- }
@@ -1 +0,0 @@
1
- export declare function loadAsyncLocalStorageClass(): Promise<any>;
@@ -1,15 +0,0 @@
1
- import type { IAsyncLocalStorage, IPlatformAdapter } from "../types";
2
- export declare class NodePlatformAdapter implements IPlatformAdapter {
3
- readonly id: "node";
4
- private alsClass;
5
- init(): Promise<void>;
6
- onUncaughtException(handler: (error: any) => void): () => NodeJS.Process;
7
- onUnhandledRejection(handler: (reason: any) => void): () => NodeJS.Process;
8
- onShutdownSignal(handler: () => void): () => void;
9
- exit(code: number): void;
10
- getEnv(key: string): string | undefined;
11
- hasAsyncLocalStorage(): boolean;
12
- createAsyncLocalStorage<T>(): IAsyncLocalStorage<T>;
13
- setTimeout: typeof setTimeout;
14
- clearTimeout: typeof clearTimeout;
15
- }
@@ -1,14 +0,0 @@
1
- import type { IAsyncLocalStorage, IPlatformAdapter } from "../types";
2
- export declare class GenericUniversalPlatformAdapter implements IPlatformAdapter {
3
- readonly id: "universal";
4
- init(): Promise<void>;
5
- onUncaughtException(handler: (error: any) => void): () => any;
6
- onUnhandledRejection(handler: (reason: any) => void): () => any;
7
- onShutdownSignal(handler: () => void): () => void;
8
- exit(): void;
9
- getEnv(key: string): string | undefined;
10
- hasAsyncLocalStorage(): boolean;
11
- createAsyncLocalStorage<T>(): IAsyncLocalStorage<T>;
12
- setTimeout: typeof setTimeout;
13
- clearTimeout: typeof clearTimeout;
14
- }
@@ -1,17 +0,0 @@
1
- import type { IPlatformAdapter, PlatformId } from "../types";
2
- export declare function detectEnvironment(): PlatformId;
3
- export declare class UniversalPlatformAdapter implements IPlatformAdapter {
4
- readonly id: PlatformId;
5
- private inner;
6
- init(): Promise<void>;
7
- private get;
8
- onUncaughtException(handler: (error: Error) => void): () => void;
9
- onUnhandledRejection(handler: (reason: unknown) => void): () => void;
10
- onShutdownSignal(handler: () => void): () => void;
11
- exit(code: number): void;
12
- getEnv(key: string): string | undefined;
13
- hasAsyncLocalStorage(): boolean;
14
- createAsyncLocalStorage<T>(): import("..").IAsyncLocalStorage<T>;
15
- setTimeout: typeof setTimeout;
16
- clearTimeout: typeof clearTimeout;
17
- }
@@ -1,10 +0,0 @@
1
- import type { InputFileMeta, EjsonFileSentinel } from "../types/inputFile";
2
- /**
3
- * Universal/browser `createFile` helper. For Node, import from `@bluelibs/runner/node`.
4
- */
5
- export declare function createFile(meta: InputFileMeta, blob: Blob, id?: string): EjsonFileSentinel & {
6
- _web: {
7
- blob: Blob;
8
- };
9
- };
10
- export type { EjsonFileSentinel };
@@ -1,11 +0,0 @@
1
- import type { InputFileMeta, EjsonFileSentinel } from "../types/inputFile";
2
- /**
3
- * Browser/edge-friendly File sentinel creator.
4
- * Produces the same public EJSON File shape with a browser sidecar `_web`.
5
- * The sidecar will be stripped out by the universal manifest walker before upload.
6
- */
7
- export declare function createWebFile(meta: InputFileMeta, blob: Blob, id?: string): EjsonFileSentinel & {
8
- _web: {
9
- blob: Blob;
10
- };
11
- };
@@ -1,2 +0,0 @@
1
- import type { IPlatformAdapter } from "./types";
2
- export declare function createPlatformAdapter(): IPlatformAdapter;
@@ -1,27 +0,0 @@
1
- import type { IPlatformAdapter, IAsyncLocalStorage, PlatformId } from "./types";
2
- import { detectEnvironment } from "./adapters/universal";
3
- export { detectEnvironment };
4
- export declare function getPlatform(): IPlatformAdapter;
5
- export declare function setPlatform(adapter: IPlatformAdapter): void;
6
- export declare function resetPlatform(): void;
7
- export declare function getDetectedEnvironment(): PlatformId;
8
- export declare function isNode(): boolean;
9
- export declare function isBrowser(): boolean;
10
- export declare function isUniversal(): boolean;
11
- export type { IPlatformAdapter, IAsyncLocalStorage } from "./types";
12
- export declare class PlatformAdapter implements IPlatformAdapter {
13
- private inner;
14
- readonly env: PlatformId;
15
- readonly id: PlatformId;
16
- constructor(env?: PlatformId);
17
- init(): Promise<void>;
18
- onUncaughtException(handler: (error: any) => void): () => void;
19
- onUnhandledRejection(handler: (reason: any) => void): () => void;
20
- onShutdownSignal(handler: () => void): () => void;
21
- exit(code: number): void;
22
- getEnv(key: string): string | undefined;
23
- hasAsyncLocalStorage(): boolean;
24
- createAsyncLocalStorage<T>(): IAsyncLocalStorage<T>;
25
- setTimeout: typeof setTimeout;
26
- clearTimeout: typeof clearTimeout;
27
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * Platform abstraction interface for universal compatibility
3
- * Inspired by Remix's approach to Web APIs and runtime-agnostic design
4
- */
5
- export type PlatformId = "node" | "browser" | "edge" | "universal";
6
- export interface IPlatformAdapter {
7
- readonly id: PlatformId;
8
- onUncaughtException(handler: (error: Error) => void): () => void;
9
- onUnhandledRejection(handler: (reason: unknown) => void): () => void;
10
- onShutdownSignal(handler: () => void): () => void;
11
- exit(code: number): void;
12
- getEnv(key: string): string | undefined;
13
- hasAsyncLocalStorage(): boolean;
14
- createAsyncLocalStorage<T>(): IAsyncLocalStorage<T>;
15
- setTimeout: typeof globalThis.setTimeout;
16
- clearTimeout: typeof globalThis.clearTimeout;
17
- init: () => Promise<void>;
18
- }
19
- export interface IAsyncLocalStorage<T> {
20
- getStore(): T | undefined;
21
- run<R>(store: T, callback: () => R): R;
22
- }
23
- /**
24
- * Utility functions for environment detection
25
- */
26
- export declare function isNode(): boolean;
27
- export declare function isBrowser(): boolean;
28
- export declare function isWebWorker(): boolean;
29
- export declare function isUniversal(): boolean;
@@ -1,2 +0,0 @@
1
- export declare function registerProcessLevelSafetyNets(handler: (error: unknown, source: "uncaughtException" | "unhandledRejection") => void | Promise<void>): () => void;
2
- export declare function registerShutdownHook(disposeOnce: () => Promise<void>): () => void;
package/dist/run.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { IResource, IResourceWithConfig } from "./defs";
2
- import { RunResult } from "./models/RunResult";
3
- import { RunOptions } from "./types/runner";
4
- /**
5
- * This is the central function that kicks off you runner. You can run as many resources as you want in a single process, they will run in complete isolation.
6
- *
7
- * @param resourceOrResourceWithConfig - The resource or resource with config to run.
8
- * @param options - The options for the run.
9
- * @returns A promise that resolves to the result of the run.
10
- */
11
- export declare function run<C, V extends Promise<any>>(resourceOrResourceWithConfig: IResourceWithConfig<C, V> | IResource<void, V, any, any> | IResource<{
12
- [K in any]?: any;
13
- }, V, any, any>, // For optional config
14
- options?: RunOptions): Promise<RunResult<V extends Promise<infer U> ? U : V>>;
package/dist/testing.d.ts DELETED
@@ -1,25 +0,0 @@
1
- import { IResource, IResourceWithConfig, ITaskMiddleware, IResourceMiddleware, ITask, RegisterableItems, DependencyMapType } from "./defs";
2
- import { EventManager, Logger, Store, TaskRunner } from "./models";
3
- /**
4
- * Helper to create a minimal test harness resource that wraps a root app (or any registerable)
5
- * and exposes convenient testing utilities while running the full ecosystem
6
- * (registration, overrides, middleware, events) without modifying the core API.
7
- * @deprecated Use `run` instead with your testResource, as it provides the necessary toolkit.
8
- */
9
- export declare function createTestResource(root: RegisterableItems, options?: {
10
- overrides?: Array<IResource | ITask | ITaskMiddleware | IResourceMiddleware | IResourceWithConfig>;
11
- }): IResource<void, Promise<ReturnType<typeof buildTestFacade>>>;
12
- declare function buildTestFacade(deps: {
13
- taskRunner: TaskRunner;
14
- store: Store;
15
- logger: Logger;
16
- eventManager: EventManager;
17
- }): {
18
- runTask: <I, O extends Promise<any>, D extends DependencyMapType>(task: ITask<I, O, D>, ...args: I extends undefined ? [] : [I]) => Promise<Awaited<O> | undefined>;
19
- getResource: (id: string) => any;
20
- taskRunner: TaskRunner;
21
- store: Store;
22
- logger: Logger;
23
- eventManager: EventManager;
24
- };
25
- export {};
@@ -1 +0,0 @@
1
- export declare function getCallerFile(): string;
@@ -1,24 +0,0 @@
1
- import type { Readable } from "stream";
2
- import type { InputFileMeta } from "../types/inputFile";
3
- export interface NodeCollectedFile {
4
- id: string;
5
- meta: InputFileMeta;
6
- source: {
7
- type: "buffer";
8
- buffer: Buffer;
9
- } | {
10
- type: "stream";
11
- stream: Readable;
12
- };
13
- }
14
- export interface WebCollectedFile {
15
- id: string;
16
- meta: InputFileMeta;
17
- blob: Blob;
18
- }
19
- export interface BuiltUniversalManifest<T = any> {
20
- input: T;
21
- nodeFiles: NodeCollectedFile[];
22
- webFiles: WebCollectedFile[];
23
- }
24
- export declare function buildUniversalManifest<T = any>(input: T): BuiltUniversalManifest<T>;
@@ -1,41 +0,0 @@
1
- export declare const ASYNC_CONTEXT_TYPES_LOADED: true;
2
- import { symbolAsyncContext } from "./symbols";
3
- import { ITaskMiddlewareConfigured } from "./taskMiddleware";
4
- import type { IValidationSchema, IOptionalDependency } from "./utilities";
5
- import type { IAsyncContextMeta } from "./meta";
6
- export interface IAsyncContextDefinition<T> {
7
- id: string;
8
- serialize?(data: T): string;
9
- parse?(data: string): T;
10
- /**
11
- * When provided, context values will be validated when provide() is called.
12
- */
13
- configSchema?: IValidationSchema<T>;
14
- meta?: IAsyncContextMeta;
15
- }
16
- /**
17
- * The generic AsyncContext object returned by `defineAsyncContext`.
18
- */
19
- export interface IAsyncContext<T> {
20
- /** unique symbol used as key in the AsyncLocalStorage map */
21
- readonly id: string;
22
- /** Brand marker for registration and runtime checks */
23
- [symbolAsyncContext]: true;
24
- /** Retrieve the current context value or throw */
25
- use(): T;
26
- /**
27
- * Provide a value for this context during the lifetime of `fn()`
28
- */
29
- provide<R>(value: T, fn: () => Promise<R> | R): Promise<R> | R;
30
- /**
31
- * Generates a middleware that guarantees the context exists (and optionally
32
- * enforces that certain keys are present on the context object).
33
- */
34
- require<K extends keyof T = never>(keys?: K[]): ITaskMiddlewareConfigured<{
35
- context: IAsyncContext<T>;
36
- }>;
37
- serialize(data: T): string;
38
- parse(data: string): T;
39
- /** Return an optional dependency wrapper for this context */
40
- optional(): IOptionalDependency<IAsyncContext<T>>;
41
- }
@@ -1,63 +0,0 @@
1
- import { TagType } from "./tag";
2
- export declare const CONTRACT: unique symbol;
3
- export type CONTRACT = typeof CONTRACT;
4
- export interface IContractable<TConfig = any, TInput = void, TOutput = void> {
5
- readonly __containsContract: true;
6
- readonly [CONTRACT]: {
7
- config: TConfig;
8
- input: TInput;
9
- output: TOutput;
10
- };
11
- }
12
- type NonVoid<T> = [T] extends [void] ? never : T;
13
- type IsTuple<T extends readonly unknown[]> = number extends T["length"] ? false : true;
14
- type UnionToIntersection<U> = (U extends any ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never;
15
- type Simplify<T> = {
16
- [K in keyof T]: T[K];
17
- } & {};
18
- type IsUnknown<T> = unknown extends T ? [T] extends [unknown] ? true : false : false;
19
- type UnknownToNever<T> = IsUnknown<T> extends true ? never : T;
20
- type ExtractContractOf<T, Kind extends "input" | "output"> = T extends IContractable<any, infer I, infer O> ? UnknownToNever<Kind extends "input" ? NonVoid<I> : NonVoid<O>> : never;
21
- type FilterContractsKind<TItems extends readonly unknown[], Kind extends "input" | "output", Acc extends readonly unknown[] = []> = TItems extends readonly [infer H, ...infer R] ? ExtractContractOf<H, Kind> extends never ? FilterContractsKind<R, Kind, Acc> : FilterContractsKind<R, Kind, [...Acc, ExtractContractOf<H, Kind>]> : Acc;
22
- type ExtractContractsFromCollection<TItems extends readonly unknown[], Kind extends "input" | "output"> = IsTuple<TItems> extends true ? FilterContractsKind<TItems, Kind> : Array<ExtractContractOf<TItems[number], Kind>>;
23
- export type ExtractInputTypeFromContracts<TItems extends readonly unknown[]> = ExtractContractsFromCollection<TItems, "input">;
24
- export type ExtractOutputTypeFromContracts<TItems extends readonly unknown[]> = ExtractContractsFromCollection<TItems, "output">;
25
- type ContractsUnionInputs<TItems extends readonly unknown[]> = ExtractInputTypeFromContracts<TItems> extends readonly (infer U)[] ? U : never;
26
- type ContractsUnionOutputs<TItems extends readonly unknown[]> = ExtractOutputTypeFromContracts<TItems> extends readonly (infer U)[] ? U : never;
27
- type ContractsIntersectionInputs<TItems extends readonly unknown[]> = UnionToIntersection<ContractsUnionInputs<TItems>>;
28
- type ContractsIntersectionOutputs<TItems extends readonly unknown[]> = UnionToIntersection<ContractsUnionOutputs<TItems>>;
29
- export type HasInputContracts<TItems extends readonly unknown[]> = [
30
- ContractsUnionInputs<TItems>
31
- ] extends [never] ? false : true;
32
- export type HasOutputContracts<TItems extends readonly unknown[]> = [
33
- ContractsUnionOutputs<TItems>
34
- ] extends [never] ? false : true;
35
- type IsNever<T> = [T] extends [never] ? true : false;
36
- type KeysWithNever<T> = T extends object ? {
37
- [K in keyof T]-?: [T[K]] extends [never] ? K : never;
38
- }[keyof T] : never;
39
- type HasNeverProperty<T> = KeysWithNever<T> extends never ? false : true;
40
- type IsImpossibleIntersection<T> = IsNever<T> extends true ? true : HasNeverProperty<T> extends true ? true : false;
41
- export type InputContractViolationError<TItems extends readonly unknown[], TActual> = {
42
- message: "Value does not satisfy all input contracts";
43
- expected: Simplify<ContractsIntersectionInputs<TItems>>;
44
- received: TActual;
45
- };
46
- export type OutputContractViolationError<TItems extends readonly unknown[], TActual> = {
47
- message: "Value does not satisfy all output contracts";
48
- expected: Simplify<ContractsIntersectionOutputs<TItems>>;
49
- received: TActual;
50
- };
51
- export type EnsureInputSatisfiesContracts<TItems extends readonly unknown[], TValue> = [ContractsUnionInputs<TItems>] extends [never] ? TValue : TValue extends Promise<infer U> ? Promise<U extends ContractsIntersectionInputs<TItems> ? U : InputContractViolationError<TItems, U>> : TValue extends ContractsIntersectionInputs<TItems> ? TValue : InputContractViolationError<TItems, TValue>;
52
- export type EnsureOutputSatisfiesContracts<TItems extends readonly unknown[], TResponse> = [ContractsUnionOutputs<TItems>] extends [never] ? TResponse : TResponse extends Promise<infer U> ? Promise<U extends ContractsIntersectionOutputs<TItems> ? U : OutputContractViolationError<TItems, U>> : TResponse extends ContractsIntersectionOutputs<TItems> ? TResponse : OutputContractViolationError<TItems, TResponse>;
53
- export type InferInputOrViolationFromContracts<TItems extends readonly unknown[]> = HasInputContracts<TItems> extends false ? void : ContractsIntersectionInputs<TItems> extends infer I ? IsImpossibleIntersection<I> extends true ? InputContractViolationError<TItems, Simplify<I extends never ? never : I>> : Simplify<I> : never;
54
- export type InputArg<TItems extends readonly unknown[]> = [
55
- InferInputOrViolationFromContracts<TItems>
56
- ] extends [void] ? [] : [InferInputOrViolationFromContracts<TItems>];
57
- export type InputCollisionGuard<TItems extends readonly unknown[]> = IsImpossibleIntersection<ContractsIntersectionInputs<TItems>> extends true ? InputContractViolationError<TItems, Simplify<ContractsIntersectionInputs<TItems>>> : unknown;
58
- export type InferOutputOrViolationFromContracts<TItems extends readonly unknown[]> = HasOutputContracts<TItems> extends false ? unknown : ContractsIntersectionOutputs<TItems> extends infer O ? IsImpossibleIntersection<O> extends true ? OutputContractViolationError<TItems, Simplify<O extends never ? never : O>> : Simplify<O> : never;
59
- /** @deprecated Use ExtractOutputTypeFromContracts instead */
60
- export type ExtractTagsWithNonVoidReturnTypeFromTags<TTags extends TagType[]> = ExtractOutputTypeFromContracts<TTags>;
61
- /** @deprecated Use EnsureOutputSatisfiesContracts instead */
62
- export type EnsureResponseSatisfiesContracts<TTags extends TagType[], TResponse> = EnsureOutputSatisfiesContracts<TTags, TResponse>;
63
- export {};
@@ -1,36 +0,0 @@
1
- import { symbolError } from "./symbols";
2
- import type { IOptionalDependency } from "./utilities";
3
- import type { IValidationSchema } from "./utilities";
4
- import type { IErrorMeta } from "./meta";
5
- export declare const ERROR_TYPES_LOADED: true;
6
- export interface IErrorDefinition<TData extends DefaultErrorType = DefaultErrorType> {
7
- id: string;
8
- serialize?: (data: TData) => string;
9
- parse?: (data: string) => TData;
10
- format?: (data: TData) => string;
11
- /**
12
- * Validate error data on throw(). If provided, data is parsed first.
13
- */
14
- dataSchema?: IValidationSchema<TData>;
15
- meta?: IErrorMeta;
16
- }
17
- export interface IErrorDefinitionFinal<TData extends DefaultErrorType> extends IErrorDefinition<TData> {
18
- format: (data: TData) => string;
19
- }
20
- export type DefaultErrorType = Record<string, unknown>;
21
- /**
22
- * Runtime helper returned by defineError()/r.error().
23
- * Contains helpers to throw typed errors and perform type-safe checks.
24
- */
25
- export interface IErrorHelper<TData extends DefaultErrorType = DefaultErrorType> {
26
- /** Unique id for registration and DI */
27
- id: string;
28
- /** Throw a typed error with the given data */
29
- throw(data: TData): never;
30
- /** Type guard for checking if an unknown error is this error */
31
- is(error: unknown): boolean;
32
- /** Brand symbol for runtime detection */
33
- [symbolError]: true;
34
- /** Return an optional dependency wrapper for this error */
35
- optional(): IOptionalDependency<IErrorHelper<TData>>;
36
- }
@@ -1,74 +0,0 @@
1
- import { IOptionalDependency, IValidationSchema } from "../defs";
2
- import { TagType } from "./tag";
3
- import { IEventMeta } from "./meta";
4
- import { CommonPayload, symbolEvent, symbolFilePath } from "./utilities";
5
- export type EventHandlerType<T = any> = (event: IEventEmission<T>) => any | Promise<any>;
6
- export declare function onAnyOf<T extends readonly IEventDefinition<any>[]>(...defs: T): T;
7
- /**
8
- * Runtime guard that checks if an emission belongs to one of the given event defs.
9
- * Narrows payload type to the intersection of the provided events' payloads.
10
- */
11
- export declare function isOneOf<TDefs extends readonly IEventDefinition<any>[]>(emission: IEventEmission<any>, defs: TDefs): emission is IEventEmission<CommonPayload<TDefs>>;
12
- export interface IEventDefinition<TPayload = void> {
13
- id: string;
14
- meta?: IEventMeta;
15
- /**
16
- * Optional validation schema for runtime payload validation.
17
- * When provided, event payload will be validated when emitted.
18
- */
19
- payloadSchema?: IValidationSchema<TPayload>;
20
- tags?: TagType[];
21
- }
22
- /**
23
- * The definioten of the event.
24
- * This is different from the event emission.
25
- */
26
- export interface IEvent<TPayload = any> extends IEventDefinition<TPayload> {
27
- id: string;
28
- /**
29
- * We use this event to discriminate between resources with just 'id' and 'events' as they collide. This is a workaround, should be redone using classes and instanceof.
30
- */
31
- [symbolEvent]: true;
32
- [symbolFilePath]: string;
33
- /** Return an optional dependency wrapper for this event. */
34
- optional: () => IOptionalDependency<IEvent<TPayload>>;
35
- tags: TagType[];
36
- }
37
- /**
38
- * This represents the object that is passed to event handlers
39
- */
40
- export interface IEventEmission<TPayload = any> {
41
- /**
42
- * The ID of the event. This is the same as the event's ID.
43
- * This is useful for global event listeners.
44
- */
45
- id: string;
46
- /**
47
- * The data that the event carries. It can be anything.
48
- */
49
- data: TPayload;
50
- /**
51
- * The timestamp when the event was created.
52
- */
53
- timestamp: Date;
54
- /**
55
- * The source of the event. This can be useful for debugging.
56
- */
57
- source: string;
58
- /**
59
- * Metadata associated with the event definition.
60
- */
61
- meta: IEventMeta;
62
- /**
63
- * Stops propagation to remaining event listeners.
64
- */
65
- stopPropagation(): void;
66
- /**
67
- * Returns true if propagation has been stopped.
68
- */
69
- isPropagationStopped(): boolean;
70
- /**
71
- * The tags that the event carries.
72
- */
73
- tags: TagType[];
74
- }
@@ -1,23 +0,0 @@
1
- import { DependencyMapType, DependencyValuesType, IEventDefinition, IEventEmission, ExtractEventPayload } from "../defs";
2
- import { TagType } from "./tag";
3
- import { ITaskMeta } from "./meta";
4
- import { CommonPayload, symbolFilePath, symbolHook } from "./utilities";
5
- type OnType = "*" | IEventDefinition<any> | readonly IEventDefinition<any>[];
6
- export interface IHookDefinition<TDependencies extends DependencyMapType = {}, TOn extends OnType = any, TMeta extends ITaskMeta = any> {
7
- id: string;
8
- dependencies?: TDependencies | (() => TDependencies);
9
- on: TOn;
10
- /** Listener execution order. Lower numbers run first. */
11
- order?: number;
12
- meta?: TMeta;
13
- run: (event: IEventEmission<TOn extends "*" ? any : TOn extends readonly IEventDefinition<any>[] ? CommonPayload<TOn> : ExtractEventPayload<TOn>>, dependencies: DependencyValuesType<TDependencies>) => Promise<any>;
14
- tags?: TagType[];
15
- }
16
- export interface IHook<TDependencies extends DependencyMapType = {}, TOn extends OnType = any, TMeta extends ITaskMeta = any> extends IHookDefinition<TDependencies, TOn, TMeta> {
17
- id: string;
18
- dependencies: TDependencies | (() => TDependencies);
19
- [symbolFilePath]: string;
20
- [symbolHook]: true;
21
- tags: TagType[];
22
- }
23
- export {};