* The literals a table name stands for in `file`: declared there, or * imported. A value that holds a call's result — Medusa's `const routes = * getRouteMap({ … })` — stands for the tables the function returns.
(named: TableName, file: string, context: ResolutionContext, depth = 0)
| 2078 | * getRouteMap({ … })` — stands for the tables the function returns. |
| 2079 | */ |
| 2080 | function tableNamed(named: TableName, file: string, context: ResolutionContext, depth = 0): TableLiteral[] { |
| 2081 | const source = context.readFile(file); |
| 2082 | if (!source) return []; |
| 2083 | const safe = stripCommentsForRegex(source, 'typescript'); |
| 2084 | const local = declaredTable(safe, named.name, named.call, visibleAt(named.at, safe, file, context)); |
| 2085 | if (local.length > 0) return tablesAt(local, file, context, depth); |
| 2086 | const language = scriptLanguage(file); |
| 2087 | const mapping = context.getImportMappings(file, language).find((m) => m.localName === named.name); |
| 2088 | if (!mapping || mapping.isNamespace || depth > 3) return []; |
| 2089 | const target = resolveImportPath(mapping.source, file, language, context); |
| 2090 | if (!target) return []; |
| 2091 | return exportedTable(target, mapping.isDefault ? 'default' : mapping.exportedName, named.call, context, depth + 1); |
| 2092 | } |
| 2093 | |
| 2094 | /** The literals `sites` in `file` stand for: each literal written there, and the tables each function named returns. */ |
| 2095 | function tablesAt(sites: TableSite[], file: string, context: ResolutionContext, depth: number): TableLiteral[] { |
no test coverage detected