MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / transformPropertyKey

Function transformPropertyKey

packages/db/src/services/chart.service.ts:227–246  ·  view source on GitHub ↗
(property: string)

Source from the content-addressed store, hash-verified

225}
226
227export 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"

Callers 1

getSelectPropertyKeyFunction · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected