(property: string)
| 225 | } |
| 226 | |
| 227 | export function transformPropertyKey(property: string) { |
| 228 | const propertyPatterns = ['properties', 'profile.properties']; |
| 229 | const match = propertyPatterns.find((pattern) => |
| 230 | property.startsWith(`${pattern}.`) |
| 231 | ); |
| 232 | |
| 233 | if (!match) { |
| 234 | return property; |
| 235 | } |
| 236 | |
| 237 | if (property.includes('*')) { |
| 238 | return property |
| 239 | .replace(/^properties\./, '') |
| 240 | .replace('.*.', '.%.') |
| 241 | .replace(/\[\*\]$/, '.%') |
| 242 | .replace(/\[\*\].?/, '.%.'); |
| 243 | } |
| 244 | |
| 245 | return `${match}['${property.replace(new RegExp(`^${match}.`), '')}']`; |
| 246 | } |
| 247 | |
| 248 | // Returns a SQL expression for a group property via the _g JOIN alias |
| 249 | // property format: "group.name", "group.type", "group.properties.plan" |
no test coverage detected