(filter: Filter, idByName: ReadonlyMap<string, string>)
| 153 | * at the name-translating boundaries before handing a filter to the query layer. |
| 154 | */ |
| 155 | export function filterNamesToIds(filter: Filter, idByName: ReadonlyMap<string, string>): Filter { |
| 156 | const out: Filter = {} |
| 157 | for (const [key, value] of Object.entries(filter)) { |
| 158 | if ((key === '$or' || key === '$and') && Array.isArray(value)) { |
| 159 | out[key] = (value as Filter[]).map((f) => filterNamesToIds(f, idByName)) |
| 160 | } else { |
| 161 | out[idByName.get(key) ?? key] = value |
| 162 | } |
| 163 | } |
| 164 | return out |
| 165 | } |
| 166 | |
| 167 | /** Translates a sort's field names → column ids. Unknown fields pass through. */ |
| 168 | export function sortNamesToIds(sort: Sort, idByName: ReadonlyMap<string, string>): Sort { |
no test coverage detected