1 |
|
2 |
|
3 |
|
4 | import * as types from '@azure/functions';
|
5 | import { ReadOnlyError } from '../errors';
|
6 | import { InvocationContext } from '../InvocationContext';
|
7 | import { nonNullProp } from '../utils/nonNull';
|
8 | import { HookContext } from './HookContext';
|
9 |
|
10 | export class InvocationHookContext extends HookContext implements types.InvocationHookContext {
|
11 | #init: types.InvocationHookContextInit;
|
12 |
|
13 | constructor(init?: types.InvocationHookContextInit) {
|
14 | super(init);
|
15 | this.#init = init ?? {};
|
16 | this.#init.inputs ??= [];
|
17 | this.#init.invocationContext ??= new InvocationContext();
|
18 | }
|
19 |
|
20 | get invocationContext(): types.InvocationContext {
|
21 | return nonNullProp(this.#init, 'invocationContext');
|
22 | }
|
23 |
|
24 | set invocationContext(_value: types.InvocationContext) {
|
25 | throw new ReadOnlyError('invocationContext');
|
26 | }
|
27 |
|
28 | get inputs(): unknown[] {
|
29 | return nonNullProp(this.#init, 'inputs');
|
30 | }
|
31 |
|
32 | set inputs(value: unknown[]) {
|
33 | this.#init.inputs = value;
|
34 | }
|
35 | }
|