* `hashKey` from @tanstack/react-query JSON-stringifies (not hashes), so * `query_key` is a readable array of `{scope, ...}` parts. Joined: `clusters.list`.
(request: Request)
| 108 | * `query_key` is a readable array of `{scope, ...}` parts. Joined: `clusters.list`. |
| 109 | */ |
| 110 | function labelFromQueryKey(request: Request): string | undefined { |
| 111 | try { |
| 112 | const url = new URL(request.url()); |
| 113 | const raw = url.searchParams.get("query_key"); |
| 114 | if (!raw) return undefined; |
| 115 | const parsed = JSON.parse(raw); |
| 116 | if (!Array.isArray(parsed)) return undefined; |
| 117 | const scopes = parsed |
| 118 | .map((part) => |
| 119 | part && typeof part === "object" && typeof part.scope === "string" |
| 120 | ? part.scope |
| 121 | : undefined, |
| 122 | ) |
| 123 | .filter((s): s is string => !!s); |
| 124 | if (scopes.length === 0) return undefined; |
| 125 | return scopes.join("."); |
| 126 | } catch { |
| 127 | return undefined; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | function labelFromSql(sql: string): string | undefined { |
| 132 | for (const [label, pattern] of SQL_LABELS) { |