1 |
|
2 |
|
3 |
|
4 | import { FunctionHandler } from '../index';
|
5 | import { InvocationContext } from '../InvocationContext';
|
6 | import { HookContext, HookContextInit } from './HookContext';
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export type PreInvocationHandler = (context: PreInvocationContext) => void | Promise<void>;
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | export declare class PreInvocationContext extends InvocationHookContext {
|
17 | |
18 |
|
19 |
|
20 | constructor(init?: PreInvocationContextInit);
|
21 |
|
22 | /**
|
23 | * The arguments passed to this specific invocation.
|
24 | * Changes to this array _will_ affect the inputs passed to your function
|
25 | */
|
26 | inputs: unknown[];
|
27 |
|
28 | /**
|
29 | * The function handler for this specific invocation. Changes to this value _will_ affect the function itself
|
30 | */
|
31 | functionHandler: FunctionHandler;
|
32 | }
|
33 |
|
34 | /**
|
35 | * Handler for post-invocation hooks
|
36 | */
|
37 | export type PostInvocationHandler = (context: PostInvocationContext) => void | Promise<void>;
|
38 |
|
39 | /**
|
40 | * Context on a function after it executes.
|
41 | */
|
42 | export declare class PostInvocationContext extends InvocationHookContext {
|
43 | |
44 |
|
45 |
|
46 | constructor(init?: PostInvocationContextInit);
|
47 |
|
48 | /**
|
49 | * The arguments passed to this specific invocation.
|
50 | */
|
51 | inputs: unknown[];
|
52 |
|
53 | /**
|
54 | * The result of the function. Changes to this value _will_ affect the overall result of the function
|
55 | */
|
56 | result: unknown;
|
57 |
|
58 | /**
|
59 | * The error thrown by the function, or null/undefined if there is no error. Changes to this value _will_ affect the overall result of the function
|
60 | */
|
61 | error: unknown;
|
62 | }
|
63 |
|
64 | /**
|
65 | * Base class for all invocation hook context objects
|
66 | */
|
67 | export declare class InvocationHookContext extends HookContext {
|
68 | |
69 |
|
70 |
|
71 | constructor(init?: InvocationHookContextInit);
|
72 |
|
73 | /**
|
74 | * The context object passed to the function.
|
75 | * This object is readonly. You may modify it, but attempting to overwrite it will throw an error
|
76 | */
|
77 | readonly invocationContext: InvocationContext;
|
78 | }
|
79 |
|
80 | /**
|
81 | * Object passed to InvocationHookContext constructors.
|
82 | * For testing purposes only
|
83 | */
|
84 | export interface InvocationHookContextInit extends HookContextInit {
|
85 | inputs?: unknown[];
|
86 |
|
87 | invocationContext?: InvocationContext;
|
88 | }
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | export interface PreInvocationContextInit extends InvocationHookContextInit {
|
95 | functionCallback?: FunctionHandler;
|
96 | }
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | export interface PostInvocationContextInit extends InvocationHookContextInit {
|
103 | result?: unknown;
|
104 |
|
105 | error?: unknown;
|
106 | }
|