function parseSelector()

in packages/@aws-c2a/engine/lib/rules/rule-parser.ts [50:79]


function parseSelector(selector: CSelector): Selector {
  if(typeof selector === 'string')
    return parseStringSelector(selector);

  if(typeof selector !== 'object' || selector === null)
    throw Error('Selector format not supported');

  if(isPathCSelector(selector)){
    if(typeof selector.fromPath !== 'string')
      throw Error("'fromPath' selector must be a string");
    return {
      ...parseStringSelector(selector.fromPath),
      ...parseConditions(selector.where),
    };
  }

  if(isComponentCFilter(selector)){
    const { where, ...filter } = selector;
    return {
      filter: parseComponentCFilter(filter),
      ...parseConditions(where),
    };
  }

  const { where, ...filter } = selector;
  return {
    filter: parseGeneralFilter(filter),
    ...parseConditions(where),
  };
}