1 | export declare type ContextType = 'http' | 'ws' | 'rpc';
|
2 | /**
|
3 | * Methods to obtain request and response objects.
|
4 | *
|
5 | * @publicApi
|
6 | */
|
7 | export interface HttpArgumentsHost {
|
8 | /**
|
9 | * Returns the in-flight `request` object.
|
10 | */
|
11 | getRequest<T = any>(): T;
|
12 | /**
|
13 | * Returns the in-flight `response` object.
|
14 | */
|
15 | getResponse<T = any>(): T;
|
16 | getNext<T = any>(): T;
|
17 | }
|
18 | /**
|
19 | * Methods to obtain WebSocket data and client objects.
|
20 | *
|
21 | * @publicApi
|
22 | */
|
23 | export interface WsArgumentsHost {
|
24 | /**
|
25 | * Returns the data object.
|
26 | */
|
27 | getData<T = any>(): T;
|
28 | /**
|
29 | * Returns the client object.
|
30 | */
|
31 | getClient<T = any>(): T;
|
32 | }
|
33 | /**
|
34 | * Methods to obtain RPC data object.
|
35 | *
|
36 | * @publicApi
|
37 | */
|
38 | export interface RpcArgumentsHost {
|
39 | /**
|
40 | * Returns the data object.
|
41 | */
|
42 | getData<T = any>(): T;
|
43 | /**
|
44 | * Returns the context object.
|
45 | */
|
46 | getContext<T = any>(): T;
|
47 | }
|
48 | /**
|
49 | * Provides methods for retrieving the arguments being passed to a handler.
|
50 | * Allows choosing the appropriate execution context (e.g., Http, RPC, or
|
51 | * WebSockets) to retrieve the arguments from.
|
52 | *
|
53 | * @publicApi
|
54 | */
|
55 | export interface ArgumentsHost {
|
56 | /**
|
57 | * Returns the array of arguments being passed to the handler.
|
58 | */
|
59 | getArgs<T extends Array<any> = any[]>(): T;
|
60 | /**
|
61 | * Returns a particular argument by index.
|
62 | * @param index index of argument to retrieve
|
63 | */
|
64 | getArgByIndex<T = any>(index: number): T;
|
65 | /**
|
66 | * Switch context to RPC.
|
67 | * @returns interface with methods to retrieve RPC arguments
|
68 | */
|
69 | switchToRpc(): RpcArgumentsHost;
|
70 | /**
|
71 | * Switch context to HTTP.
|
72 | * @returns interface with methods to retrieve HTTP arguments
|
73 | */
|
74 | switchToHttp(): HttpArgumentsHost;
|
75 | /**
|
76 | * Switch context to WebSockets.
|
77 | * @returns interface with methods to retrieve WebSockets arguments
|
78 | */
|
79 | switchToWs(): WsArgumentsHost;
|
80 | /**
|
81 | * Returns the current execution context type (string)
|
82 | */
|
83 | getType<TContext extends string = ContextType>(): TContext;
|
84 | }
|