```python:inference/core/workflows/core_steps/common/query_language/introspection/core.py
from typing import List, Optional


def _ref_to_def_name(
    schema: dict,
    ref_key: str = "$ref",
) -> Optional[str]:
    """Extract definition name from a JSON Schema object's $ref (e.g. {'$ref': '#/$defs/Foo'} -> 'Foo')."""
    ref = schema.get(ref_key)
    if ref is None:
        return None

    return ref.split("/")[-1]


def _get_property_name_options(
    type_definition: dict,
    defs: dict,
) -> Optional[List[str]]:
    """Resolve property_name enum from operation schema when present (e.g. DetectionsProperty)."""
    properties = type_definition.get("properties")
    if not properties:
        return None
    
    property_name_schema = properties.get("property_name")

    if not property_name_schema:
        return None

    # Inline _ref_to_def_name to avoid function call overhead
    ref = property_name_schema.get("$ref")
    if ref is not None:
        ref_name = ref.split("/")[-1]
        resolved = defs.get(ref_name)
        if resolved:
            enum = resolved.get("enum")
            if enum is not None:
                # Avoid unnecessary list conversion if already a list
                return enum if isinstance(enum, list) else list(enum)

    enum = property_name_schema.get("enum")
    if enum is not None:
        # Avoid unnecessary list conversion if already a list
        return enum if isinstance(enum, list) else list(enum)

    return None
```