@bluelibs/runner 4.7.0-alpha → 4.8.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 +88 -95
- package/README.md +205 -145
- package/dist/browser/index.cjs +738 -486
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.mjs +735 -486
- package/dist/browser/index.mjs.map +1 -1
- package/dist/define.d.ts +1 -1
- package/dist/definers/builders/asyncContext.d.ts +11 -0
- package/dist/definers/builders/error.d.ts +13 -0
- package/dist/definers/builders/middleware.d.ts +3 -3
- package/dist/definers/defineAsyncContext.d.ts +15 -0
- package/dist/definers/defineError.d.ts +26 -0
- package/dist/definers/tools.d.ts +6 -0
- package/dist/edge/index.cjs +738 -486
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.mjs +735 -486
- package/dist/edge/index.mjs.map +1 -1
- package/dist/errors.d.ts +60 -102
- package/dist/globals/debug.d.ts +10 -0
- package/dist/globals/globalMiddleware.d.ts +3 -3
- package/dist/globals/middleware/requireContext.middleware.d.ts +2 -2
- package/dist/globals/resources/tunnel/protocol.d.ts +8 -1
- package/dist/globals/resources/tunnel/serializer.d.ts +1 -1
- package/dist/globals/types.d.ts +1 -0
- package/dist/http-client.d.ts +4 -0
- package/dist/http-fetch-tunnel.resource.d.ts +11 -0
- package/dist/index.d.ts +14 -5
- package/dist/models/Store.d.ts +6 -2
- package/dist/models/StoreRegistry.d.ts +6 -0
- package/dist/node/exposure/httpResponse.d.ts +1 -1
- package/dist/node/exposure/requestContext.d.ts +1 -1
- package/dist/node/{mixed-http-client.node.d.ts → http-mixed-client.d.ts} +1 -1
- package/dist/node/http-smart-client.model.d.ts +2 -0
- package/dist/node/node.cjs +914 -531
- package/dist/node/node.cjs.map +1 -1
- package/dist/node/node.mjs +911 -531
- package/dist/node/node.mjs.map +1 -1
- package/dist/types/asyncContext.d.ts +39 -0
- package/dist/types/error.d.ts +34 -0
- package/dist/types/runner.d.ts +13 -0
- package/dist/types/symbols.d.ts +6 -0
- package/dist/types/utilities.d.ts +6 -4
- package/dist/universal/index.cjs +738 -486
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.mjs +735 -486
- package/dist/universal/index.mjs.map +1 -1
- package/dist/utils/detectRunnerMode.d.ts +9 -0
- package/package.json +1 -1
- package/dist/context.d.ts +0 -31
package/dist/errors.d.ts
CHANGED
|
@@ -1,104 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Error thrown when a resource is not found in the store
|
|
45
|
-
*/
|
|
46
|
-
export declare class ResourceNotFoundError extends RuntimeError {
|
|
47
|
-
constructor(id: string);
|
|
48
|
-
}
|
|
49
|
-
export declare class MiddlewareNotRegisteredError extends RuntimeError {
|
|
50
|
-
constructor(type: "task" | "resource", source: string, middlewareId: string);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Error thrown when a tag is not found in the registry
|
|
54
|
-
*/
|
|
55
|
-
export declare class TagNotFoundError extends RuntimeError {
|
|
56
|
-
constructor(id: string);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Error thrown when attempting to modify a locked component
|
|
60
|
-
*/
|
|
61
|
-
export declare class LockedError extends RuntimeError {
|
|
62
|
-
constructor(what: string);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Error thrown when attempting to initialize a store that's already initialized
|
|
66
|
-
*/
|
|
67
|
-
export declare class StoreAlreadyInitializedError extends RuntimeError {
|
|
68
|
-
constructor();
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Error thrown when validation fails for task input, resource config, middleware config, or event payload
|
|
72
|
-
*/
|
|
73
|
-
export declare class ValidationError extends RuntimeError {
|
|
74
|
-
constructor(type: string, id: string, originalError: Error | string);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Error thrown when an event emission cycle is detected
|
|
78
|
-
*/
|
|
79
|
-
export declare class EventCycleError extends RuntimeError {
|
|
80
|
-
constructor(path: Array<{
|
|
1
|
+
import type { DefaultErrorType } from "./types/error";
|
|
2
|
+
export declare const duplicateRegistrationError: import("./definers/defineError").ErrorHelper<{
|
|
3
|
+
type: string;
|
|
4
|
+
id: string;
|
|
5
|
+
} & DefaultErrorType>;
|
|
6
|
+
export declare const dependencyNotFoundError: import("./definers/defineError").ErrorHelper<{
|
|
7
|
+
key: string;
|
|
8
|
+
} & DefaultErrorType>;
|
|
9
|
+
export declare const unknownItemTypeError: import("./definers/defineError").ErrorHelper<{
|
|
10
|
+
item: unknown;
|
|
11
|
+
} & DefaultErrorType>;
|
|
12
|
+
export declare const contextError: import("./definers/defineError").ErrorHelper<{
|
|
13
|
+
details?: string;
|
|
14
|
+
} & DefaultErrorType>;
|
|
15
|
+
export declare const circularDependenciesError: import("./definers/defineError").ErrorHelper<{
|
|
16
|
+
cycles: string[];
|
|
17
|
+
} & DefaultErrorType>;
|
|
18
|
+
export declare const eventNotFoundError: import("./definers/defineError").ErrorHelper<{
|
|
19
|
+
id: string;
|
|
20
|
+
} & DefaultErrorType>;
|
|
21
|
+
export declare const resourceNotFoundError: import("./definers/defineError").ErrorHelper<{
|
|
22
|
+
id: string;
|
|
23
|
+
} & DefaultErrorType>;
|
|
24
|
+
export declare const middlewareNotRegisteredError: import("./definers/defineError").ErrorHelper<{
|
|
25
|
+
type: "task" | "resource";
|
|
26
|
+
source: string;
|
|
27
|
+
middlewareId: string;
|
|
28
|
+
} & DefaultErrorType>;
|
|
29
|
+
export declare const tagNotFoundError: import("./definers/defineError").ErrorHelper<{
|
|
30
|
+
id: string;
|
|
31
|
+
} & DefaultErrorType>;
|
|
32
|
+
export declare const lockedError: import("./definers/defineError").ErrorHelper<{
|
|
33
|
+
what: string;
|
|
34
|
+
} & DefaultErrorType>;
|
|
35
|
+
export declare const storeAlreadyInitializedError: import("./definers/defineError").ErrorHelper<DefaultErrorType>;
|
|
36
|
+
export declare const validationError: import("./definers/defineError").ErrorHelper<{
|
|
37
|
+
subject: string;
|
|
38
|
+
id: string;
|
|
39
|
+
originalError: string | Error;
|
|
40
|
+
} & DefaultErrorType>;
|
|
41
|
+
export declare const eventCycleError: import("./definers/defineError").ErrorHelper<{
|
|
42
|
+
path: Array<{
|
|
81
43
|
id: string;
|
|
82
44
|
source: string;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
export declare
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
export declare
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
export declare class CancellationError extends RuntimeError {
|
|
102
|
-
constructor(message?: string);
|
|
103
|
-
}
|
|
104
|
-
export declare function isCancellationError(err: unknown): err is CancellationError;
|
|
45
|
+
}>;
|
|
46
|
+
} & DefaultErrorType>;
|
|
47
|
+
export declare const eventEmissionCycleError: import("./definers/defineError").ErrorHelper<{
|
|
48
|
+
cycles: string[];
|
|
49
|
+
} & DefaultErrorType>;
|
|
50
|
+
export declare const platformUnsupportedFunctionError: import("./definers/defineError").ErrorHelper<{
|
|
51
|
+
functionName: string;
|
|
52
|
+
} & DefaultErrorType>;
|
|
53
|
+
export declare const cancellationError: import("./definers/defineError").ErrorHelper<{
|
|
54
|
+
reason?: string;
|
|
55
|
+
} & DefaultErrorType>;
|
|
56
|
+
export declare const tunnelOwnershipConflictError: import("./definers/defineError").ErrorHelper<{
|
|
57
|
+
taskId: string;
|
|
58
|
+
currentOwnerId: string;
|
|
59
|
+
attemptedOwnerId: string;
|
|
60
|
+
} & DefaultErrorType>;
|
|
61
|
+
export declare function isCancellationError(err: unknown): boolean;
|
|
62
|
+
export type { IErrorHelper } from "./types/error";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const debugLevels: {
|
|
2
|
+
normal: import("./types").DebugConfig;
|
|
3
|
+
verbose: import("./types").DebugConfig;
|
|
4
|
+
};
|
|
5
|
+
export declare const debug: {
|
|
6
|
+
levels: {
|
|
7
|
+
normal: import("./types").DebugConfig;
|
|
8
|
+
verbose: import("./types").DebugConfig;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAsyncContext } from "../definers/defineAsyncContext";
|
|
2
2
|
/**
|
|
3
3
|
* Global middlewares
|
|
4
4
|
*/
|
|
5
5
|
export declare const globalMiddlewares: {
|
|
6
6
|
requireContext: import("..").ITaskMiddleware<{
|
|
7
|
-
context:
|
|
7
|
+
context: IAsyncContext<any>;
|
|
8
8
|
}, void, void, any>;
|
|
9
9
|
task: {
|
|
10
10
|
requireContext: import("..").ITaskMiddleware<{
|
|
11
|
-
context:
|
|
11
|
+
context: IAsyncContext<any>;
|
|
12
12
|
}, void, void, any>;
|
|
13
13
|
cache: import("..").ITaskMiddleware<any, void, void, {
|
|
14
14
|
cache: import("..").IResource<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAsyncContext } from "../../definers/defineAsyncContext";
|
|
2
2
|
type RequireContextMiddlewareConfig = {
|
|
3
|
-
context:
|
|
3
|
+
context: IAsyncContext<any>;
|
|
4
4
|
};
|
|
5
5
|
export declare const requireContextTaskMiddleware: import("../..").ITaskMiddleware<RequireContextMiddlewareConfig, void, void, any>;
|
|
6
6
|
export {};
|
|
@@ -3,6 +3,8 @@ export interface ProtocolErrorShape {
|
|
|
3
3
|
code: string;
|
|
4
4
|
message: string;
|
|
5
5
|
details?: unknown;
|
|
6
|
+
id?: string;
|
|
7
|
+
data?: unknown;
|
|
6
8
|
}
|
|
7
9
|
export interface ProtocolEnvelope<T = unknown> {
|
|
8
10
|
ok: boolean;
|
|
@@ -30,7 +32,12 @@ export interface EventRequest {
|
|
|
30
32
|
export declare class TunnelError extends Error {
|
|
31
33
|
readonly code: string;
|
|
32
34
|
readonly details?: unknown;
|
|
33
|
-
|
|
35
|
+
readonly id?: string;
|
|
36
|
+
readonly data?: unknown;
|
|
37
|
+
constructor(code: string, message: string, details?: unknown, extras?: {
|
|
38
|
+
id?: string;
|
|
39
|
+
data?: unknown;
|
|
40
|
+
});
|
|
34
41
|
}
|
|
35
42
|
export declare function toTunnelError(input: unknown, fallbackMessage?: string): TunnelError;
|
|
36
43
|
export declare function assertOkEnvelope<T>(envelope: ProtocolEnvelope<T> | undefined, opts?: {
|
|
@@ -2,7 +2,7 @@ import { EJSON } from "@bluelibs/ejson";
|
|
|
2
2
|
export interface Serializer {
|
|
3
3
|
stringify(value: unknown): string;
|
|
4
4
|
parse<T = unknown>(text: string): T;
|
|
5
|
-
addType
|
|
5
|
+
addType?<TJson = unknown, T = unknown>(name: string, factory: (json: TJson) => T): void;
|
|
6
6
|
}
|
|
7
7
|
export declare const EjsonSerializer: Serializer;
|
|
8
8
|
export declare function getDefaultSerializer(): Serializer;
|
package/dist/globals/types.d.ts
CHANGED
package/dist/http-client.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Readable } from "stream";
|
|
2
2
|
import type { Serializer } from "./globals/resources/tunnel/serializer";
|
|
3
|
+
import type { IAsyncContext } from "./types/asyncContext";
|
|
4
|
+
import type { IErrorHelper } from "./types/error";
|
|
3
5
|
export interface HttpClientAuth {
|
|
4
6
|
header?: string;
|
|
5
7
|
token: string;
|
|
@@ -14,6 +16,8 @@ export interface HttpClientConfig {
|
|
|
14
16
|
url: string;
|
|
15
17
|
headers: Record<string, string>;
|
|
16
18
|
}) => void | Promise<void>;
|
|
19
|
+
contexts?: Array<IAsyncContext<any>>;
|
|
20
|
+
errorRegistry?: Map<string, IErrorHelper<any>>;
|
|
17
21
|
}
|
|
18
22
|
export interface HttpClient {
|
|
19
23
|
task<I = unknown, O = unknown>(id: string, input?: I): Promise<O | Readable | ReadableStream<Uint8Array>>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Serializer } from "./globals/resources/tunnel/serializer";
|
|
2
|
+
import type { IAsyncContext } from "./types/asyncContext";
|
|
3
|
+
import type { IErrorHelper } from "./types/error";
|
|
2
4
|
export { normalizeError } from "./globals/resources/tunnel/error-utils";
|
|
3
5
|
export interface ExposureFetchAuthConfig {
|
|
4
6
|
header?: string;
|
|
@@ -14,9 +16,18 @@ export interface ExposureFetchConfig {
|
|
|
14
16
|
url: string;
|
|
15
17
|
headers: Record<string, string>;
|
|
16
18
|
}) => void | Promise<void>;
|
|
19
|
+
contexts?: Array<IAsyncContext<any>>;
|
|
20
|
+
errorRegistry?: Map<string, IErrorHelper<any>>;
|
|
17
21
|
}
|
|
18
22
|
export interface ExposureFetchClient {
|
|
19
23
|
task<I = unknown, O = unknown>(id: string, input?: I): Promise<O>;
|
|
20
24
|
event<P = unknown>(id: string, payload?: P): Promise<void>;
|
|
21
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* This functions communicates with the exposure server over HTTP.
|
|
28
|
+
* It uses the @readmes/TUNNEL_HTTP_POLICY.md strategy.
|
|
29
|
+
*
|
|
30
|
+
* @param cfg
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
22
33
|
export declare function createExposureFetch(cfg: ExposureFetchConfig): ExposureFetchClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineTask, defineResource, defineEvent, defineTaskMiddleware, defineResourceMiddleware, defineTag, defineOverride, defineHook } from "./define";
|
|
2
|
-
import { createContext } from "./
|
|
2
|
+
import { defineAsyncContext, createContext as oldCreateContext } from "./definers/defineAsyncContext";
|
|
3
3
|
import { run } from "./run";
|
|
4
4
|
import { createTestResource } from "./testing";
|
|
5
5
|
declare const globals: {
|
|
@@ -34,11 +34,11 @@ declare const globals: {
|
|
|
34
34
|
};
|
|
35
35
|
middleware: {
|
|
36
36
|
requireContext: import(".").ITaskMiddleware<{
|
|
37
|
-
context: import("./
|
|
37
|
+
context: import("./types/asyncContext").IAsyncContext<any>;
|
|
38
38
|
}, void, void, any>;
|
|
39
39
|
task: {
|
|
40
40
|
requireContext: import(".").ITaskMiddleware<{
|
|
41
|
-
context: import("./
|
|
41
|
+
context: import("./types/asyncContext").IAsyncContext<any>;
|
|
42
42
|
}, void, void, any>;
|
|
43
43
|
cache: import(".").ITaskMiddleware<any, void, void, {
|
|
44
44
|
cache: import(".").IResource<{
|
|
@@ -75,15 +75,25 @@ declare const globals: {
|
|
|
75
75
|
createClient(cfg: import("./globals/tunnels").HttpCreateClientConfig): import("./http-fetch-tunnel.resource").ExposureFetchClient;
|
|
76
76
|
}>;
|
|
77
77
|
}>;
|
|
78
|
+
debug: {
|
|
79
|
+
levels: {
|
|
80
|
+
normal: import(".").DebugConfig;
|
|
81
|
+
verbose: import(".").DebugConfig;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
78
84
|
};
|
|
79
85
|
export { globals };
|
|
80
|
-
export { defineTask as task, defineResource as resource, defineEvent as event, defineTaskMiddleware as taskMiddleware, defineResourceMiddleware as resourceMiddleware, defineTag as tag, defineOverride as override, defineHook as hook, run,
|
|
86
|
+
export { defineTask as task, defineResource as resource, defineEvent as event, defineTaskMiddleware as taskMiddleware, defineResourceMiddleware as resourceMiddleware, defineAsyncContext as asyncContext, defineTag as tag, defineOverride as override, defineHook as hook, run, createTestResource, };
|
|
87
|
+
declare const createContext: typeof oldCreateContext;
|
|
88
|
+
export { createContext };
|
|
81
89
|
export declare const r: Readonly<{
|
|
82
90
|
resource: typeof import("./definers/builders/resource").resourceBuilder;
|
|
83
91
|
task: import("./definers/builders/task").TaskBuilderWithPhantom;
|
|
84
92
|
event: typeof import("./definers/builders/event").eventBuilder;
|
|
85
93
|
hook: typeof import("./definers/builders/hook").hookBuilder;
|
|
86
94
|
tag: typeof import("./definers/builders/tag").tagBuilder;
|
|
95
|
+
asyncContext: typeof import("./definers/builders/asyncContext").asyncContextBuilder;
|
|
96
|
+
error: typeof import("./definers/builders/error").errorBuilder;
|
|
87
97
|
middleware: Readonly<{
|
|
88
98
|
task: typeof import("./definers/builders/middleware").taskMiddlewareBuilder;
|
|
89
99
|
resource: typeof import("./definers/builders/middleware").resourceMiddlewareBuilder;
|
|
@@ -93,7 +103,6 @@ export * as definitions from "./defs";
|
|
|
93
103
|
export * from "./models";
|
|
94
104
|
export * from "./globals/types";
|
|
95
105
|
export * as Errors from "./errors";
|
|
96
|
-
export { Context } from "./context";
|
|
97
106
|
export { PlatformAdapter, setPlatform } from "./platform";
|
|
98
107
|
export { EJSON } from "@bluelibs/ejson";
|
|
99
108
|
export type * from "./defs";
|
package/dist/models/Store.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { ResourceStoreElementType, TaskStoreElementType, TaskMiddlewareStoreElem
|
|
|
5
5
|
import { TaskRunner } from "./TaskRunner";
|
|
6
6
|
import { OnUnhandledError } from "./UnhandledError";
|
|
7
7
|
import { MiddlewareManager } from "./MiddlewareManager";
|
|
8
|
+
import { RunnerMode } from "../types/runner";
|
|
8
9
|
export { ResourceStoreElementType, TaskStoreElementType, EventStoreElementType, };
|
|
9
10
|
/**
|
|
10
11
|
* Store class which is used to store all the resources, tasks, middleware and events.
|
|
@@ -20,15 +21,18 @@ export declare class Store {
|
|
|
20
21
|
private validator;
|
|
21
22
|
private taskRunner?;
|
|
22
23
|
private middlewareManager;
|
|
23
|
-
|
|
24
|
+
mode: RunnerMode;
|
|
25
|
+
constructor(eventManager: EventManager, logger: Logger, onUnhandledError: OnUnhandledError, mode?: RunnerMode);
|
|
24
26
|
get tasks(): Map<string, TaskStoreElementType>;
|
|
25
27
|
get hooks(): Map<string, import("..").HookStoreElementType>;
|
|
26
28
|
get resources(): Map<string, ResourceStoreElementType>;
|
|
27
29
|
get events(): Map<string, EventStoreElementType>;
|
|
30
|
+
get errors(): Map<string, import("../errors").IErrorHelper<any>>;
|
|
31
|
+
get asyncContexts(): Map<string, import("../types/asyncContext").IAsyncContext<any>>;
|
|
28
32
|
get taskMiddlewares(): Map<string, TaskMiddlewareStoreElementType>;
|
|
29
33
|
get resourceMiddlewares(): Map<string, ResourceMiddlewareStoreElementType>;
|
|
30
34
|
get tags(): Map<string, ITag<void, void, void>>;
|
|
31
|
-
get overrides(): Map<string, IResourceMiddleware<any, void, void, any> | ITask<any, any, {}, any, import("..").TagType[], import("..").TaskMiddlewareAttachmentType[]> | IResource<void, Promise<any>, any, any, any, import("..").TagType[], import("..").ResourceMiddlewareAttachmentType[]> | import("..").IResourceWithConfig<any, Promise<any>, any, any, any, import("..").TagType[], IResourceMiddleware<any, void, void, any>[]> | import("..").IHook<{}, any, any
|
|
35
|
+
get overrides(): Map<string, IResourceMiddleware<any, void, void, any> | ITaskMiddleware<any, void, void, any> | ITask<any, any, {}, any, import("..").TagType[], import("..").TaskMiddlewareAttachmentType[]> | IResource<void, Promise<any>, any, any, any, import("..").TagType[], import("..").ResourceMiddlewareAttachmentType[]> | import("..").IResourceWithConfig<any, Promise<any>, any, any, any, import("..").TagType[], IResourceMiddleware<any, void, void, any>[]> | import("..").IHook<{}, any, any>>;
|
|
32
36
|
get overrideRequests(): Set<{
|
|
33
37
|
source: string;
|
|
34
38
|
override: RegisterableItems;
|
|
@@ -3,6 +3,8 @@ import { TaskStoreElementType, TaskMiddlewareStoreElementType, ResourceMiddlewar
|
|
|
3
3
|
import { StoreValidator } from "./StoreValidator";
|
|
4
4
|
import { Store } from "./Store";
|
|
5
5
|
import { IDependentNode } from "./utils/findCircularDependencies";
|
|
6
|
+
import { IErrorHelper } from "../types/error";
|
|
7
|
+
import type { IAsyncContext } from "../types/asyncContext";
|
|
6
8
|
type StoringMode = "normal" | "override";
|
|
7
9
|
export declare class StoreRegistry {
|
|
8
10
|
protected readonly store: Store;
|
|
@@ -13,10 +15,14 @@ export declare class StoreRegistry {
|
|
|
13
15
|
resourceMiddlewares: Map<string, ResourceMiddlewareStoreElementType>;
|
|
14
16
|
hooks: Map<string, HookStoreElementType>;
|
|
15
17
|
tags: Map<string, ITag>;
|
|
18
|
+
asyncContexts: Map<string, IAsyncContext<any>>;
|
|
19
|
+
errors: Map<string, IErrorHelper<any>>;
|
|
16
20
|
private validator;
|
|
17
21
|
constructor(store: Store);
|
|
18
22
|
getValidator(): StoreValidator;
|
|
19
23
|
storeGenericItem<C>(item: RegisterableItems): void;
|
|
24
|
+
storeError<C>(item: IErrorHelper<any>): void;
|
|
25
|
+
storeAsyncContext<C>(item: IAsyncContext<any>): void;
|
|
20
26
|
storeTag(item: ITag<any, any, any>): void;
|
|
21
27
|
storeHook<C>(item: IHook<any, any>, overrideMode?: StoringMode): void;
|
|
22
28
|
storeTaskMiddleware<C>(item: ITaskMiddleware<any>, storingMode?: StoringMode): void;
|
|
@@ -5,6 +5,6 @@ export declare const EJSON_CONTENT_TYPE = "application/json; charset=utf-8";
|
|
|
5
5
|
export declare const NOT_FOUND_RESPONSE: JsonResponse;
|
|
6
6
|
export declare const METHOD_NOT_ALLOWED_RESPONSE: JsonResponse;
|
|
7
7
|
export declare function jsonOkResponse(data?: Record<string, unknown>): JsonResponse;
|
|
8
|
-
export declare function jsonErrorResponse(status: number, message: string, code?: string): JsonResponse;
|
|
8
|
+
export declare function jsonErrorResponse(status: number, message: string, code?: string, extra?: Record<string, unknown>): JsonResponse;
|
|
9
9
|
export declare function respondJson(res: ServerResponse, response: JsonResponse, serializer?: Serializer): void;
|
|
10
10
|
export declare function respondStream(res: ServerResponse, value: StreamingResponse | NodeJS.ReadableStream): void;
|
|
@@ -8,7 +8,7 @@ export interface ExposureRequestContextValue {
|
|
|
8
8
|
method?: string;
|
|
9
9
|
signal: AbortSignal;
|
|
10
10
|
}
|
|
11
|
-
export declare const ExposureRequestContext: import("
|
|
11
|
+
export declare const ExposureRequestContext: import("../../types/asyncContext").IAsyncContext<ExposureRequestContextValue>;
|
|
12
12
|
export declare function useExposureContext(): ExposureRequestContextValue;
|
|
13
13
|
/**
|
|
14
14
|
* Checks if the exposure request context is currently available without throwing an error.
|
|
@@ -23,5 +23,5 @@ export interface MixedHttpClient {
|
|
|
23
23
|
* Unified Node client that mixes JSON/EJSON fetch for standard calls and
|
|
24
24
|
* Smart client for streaming/multipart. Keeps transport details out of app code.
|
|
25
25
|
*/
|
|
26
|
-
export declare function
|
|
26
|
+
export declare function createHttpMixedClient(cfg: MixedHttpClientConfig): MixedHttpClient;
|
|
27
27
|
export type { Readable };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Readable } from "stream";
|
|
2
2
|
import type { Serializer } from "../globals/resources/tunnel/serializer";
|
|
3
|
+
import type { IAsyncContext } from "../types/asyncContext";
|
|
3
4
|
export interface HttpSmartClientAuthConfig {
|
|
4
5
|
header?: string;
|
|
5
6
|
token: string;
|
|
@@ -13,6 +14,7 @@ export interface HttpSmartClientConfig {
|
|
|
13
14
|
url: string;
|
|
14
15
|
headers: Record<string, string>;
|
|
15
16
|
}) => void | Promise<void>;
|
|
17
|
+
contexts?: Array<IAsyncContext<any>>;
|
|
16
18
|
}
|
|
17
19
|
export interface HttpSmartClient {
|
|
18
20
|
task<I = unknown, O = unknown>(id: string, input?: I): Promise<O | Readable>;
|