UNPKG

1.13 kBPlain TextView Raw
1// Copyright (c) .NET Foundation. All rights reserved.
2// Licensed under the MIT License.
3
4import * as types from '@azure/functions';
5import { ReadOnlyError } from '../errors';
6import { InvocationContext } from '../InvocationContext';
7import { nonNullProp } from '../utils/nonNull';
8import { HookContext } from './HookContext';
9
10export 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}