1 |
|
2 |
|
3 |
|
4 | import { TriggerMetadata } from '@azure/functions';
|
5 | import { RpcTypedData } from '@azure/functions-core';
|
6 | import { isHttpTrigger, isTimerTrigger } from '../utils/isTrigger';
|
7 | import { fromRpcTypedData } from './fromRpcTypedData';
|
8 | import { toCamelCaseKey, toCamelCaseValue } from './toCamelCase';
|
9 |
|
10 | export function fromRpcTriggerMetadata(
|
11 | triggerMetadata: Record<string, RpcTypedData> | null | undefined,
|
12 | triggerType: string
|
13 | ): TriggerMetadata | undefined {
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | if (!triggerMetadata || isHttpTrigger(triggerType) || isTimerTrigger(triggerType)) {
|
19 | return undefined;
|
20 | } else {
|
21 | const result: TriggerMetadata = {};
|
22 | for (const [key, value] of Object.entries(triggerMetadata)) {
|
23 | result[toCamelCaseKey(key)] = toCamelCaseValue(fromRpcTypedData(value));
|
24 | }
|
25 | return result;
|
26 | }
|
27 | }
|