(route: KonnectRoute)
| 68 | * - The expression yields no usable fields — creating fallback requests would be misleading. |
| 69 | */ |
| 70 | export function applyExpressionFields(route: KonnectRoute): ApplyExpressionResult { |
| 71 | if (!route.expression) { |
| 72 | return { syncable: true, route }; |
| 73 | } |
| 74 | |
| 75 | if (/\btls\.sni\b/.test(route.expression)) { |
| 76 | return { |
| 77 | syncable: false, |
| 78 | routeName: route.name ?? `Route ${route.id}`, |
| 79 | reason: 'Expression route uses tls.sni matching — unsupported in Insomnia', |
| 80 | }; |
| 81 | } |
| 82 | |
| 83 | const extracted = extractFieldsFromExpression(route.expression); |
| 84 | |
| 85 | if (!extracted.methods && !extracted.paths && !extracted.hosts && !extracted.headers) { |
| 86 | return { |
| 87 | syncable: false, |
| 88 | routeName: route.name ?? `Route ${route.id}`, |
| 89 | reason: 'Expression route — no extractable fields (method/path/host/header)', |
| 90 | }; |
| 91 | } |
| 92 | |
| 93 | return { |
| 94 | syncable: true, |
| 95 | route: { |
| 96 | ...route, |
| 97 | methods: extracted.methods, |
| 98 | paths: extracted.paths, |
| 99 | hosts: extracted.hosts, |
| 100 | headers: extracted.headers, |
| 101 | }, |
| 102 | }; |
| 103 | } |
no test coverage detected