UNPKG

serverless

Version:

Serverless Framework - Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more

28 lines (25 loc) 986 B
'use strict'; const processVariables = (propertyPath, variablesMeta, resultMap) => { if (!variablesMeta.variables) return; for (const variableMeta of variablesMeta.variables) { if (!variableMeta.sources) continue; for (const sourceData of variableMeta.sources) { if (!sourceData.type) continue; if (!resultMap.has(sourceData.type)) resultMap.set(sourceData.type, new Set()); resultMap.get(sourceData.type).add(propertyPath); if (sourceData.params) { for (const paramData of sourceData.params) { processVariables(propertyPath, paramData, resultMap); } } if (sourceData.address) processVariables(propertyPath, sourceData.address, resultMap); } } }; module.exports = (propertiesVariablesMeta) => { const resultMap = new Map(); for (const [propertyPath, propertyVariablesMeta] of propertiesVariablesMeta) { processVariables(propertyPath, propertyVariablesMeta, resultMap); } return resultMap; };