(filter: DatabaseFilter)
| 99 | // `DatabaseFilter`. Mirrors the legacy Pinia `getListDatabaseFilter` so the |
| 100 | // app store lists databases identically to the old store. |
| 101 | export function buildDatabaseFilter(filter: DatabaseFilter): string { |
| 102 | const params: string[] = []; |
| 103 | if (isValidProjectName(filter.project)) { |
| 104 | params.push(`project == "${filter.project}"`); |
| 105 | } |
| 106 | if (isValidInstanceName(filter.instance)) { |
| 107 | params.push(`instance == "${filter.instance}"`); |
| 108 | } |
| 109 | if (filter.environment === unknownEnvironment().name) { |
| 110 | params.push(`environment == ""`); |
| 111 | } else if (isValidEnvironmentName(filter.environment)) { |
| 112 | params.push(`environment == "${filter.environment}"`); |
| 113 | } |
| 114 | if (filter.excludeUnassigned) { |
| 115 | params.push(`exclude_unassigned == true`); |
| 116 | } |
| 117 | if (filter.engines && filter.engines.length > 0) { |
| 118 | params.push( |
| 119 | `engine in [${filter.engines.map((e) => `"${Engine[e]}"`).join(", ")}]` |
| 120 | ); |
| 121 | } else if (filter.excludeEngines && filter.excludeEngines.length > 0) { |
| 122 | params.push( |
| 123 | `!(engine in [${filter.excludeEngines |
| 124 | .map((e) => `"${Engine[e]}"`) |
| 125 | .join(", ")}])` |
| 126 | ); |
| 127 | } |
| 128 | const keyword = filter.query?.trim()?.toLowerCase(); |
| 129 | if (keyword) { |
| 130 | params.push(`name.contains("${keyword}")`); |
| 131 | } |
| 132 | if (filter.labels) { |
| 133 | params.push(...getLabelFilter(filter.labels)); |
| 134 | } |
| 135 | if (filter.table) { |
| 136 | params.push(`table.contains("${filter.table}")`); |
| 137 | } |
| 138 | return params.join(" && "); |
| 139 | } |
| 140 | |
| 141 | function bindingMemberToNames(member: string): string[] { |
| 142 | if (member === "allUsers" || member === "user:allUsers") { |
no test coverage detected