diff --git a/HISTORY.rst b/HISTORY.rst index 1a55312..a6c4f16 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,9 +2,12 @@ History ======= -1.7.0 (unreleased) +1.7.0 (2026-11-27) ------------------ +* Added ``json_string_indexes`` to ``FileDiscoveryLocatorResult``: + the indexes into ``locator``, counted from 0, of the elements whose value is serialized JSON. + It is ``None`` when there are none, or when the server predates the field. * Added an optional ``instance`` field to ``DatabaseConnectionConfig``: the SQL Server named instance, taken from the Instance input in the connection form's advanced settings. It round-trips through ``list_connections`` and ``create_or_update_connection``, diff --git a/datamasque/client/models/discovery.py b/datamasque/client/models/discovery.py index f2ccbd0..4bafbfc 100644 --- a/datamasque/client/models/discovery.py +++ b/datamasque/client/models/discovery.py @@ -476,6 +476,9 @@ class FileDiscoveryLocatorResult(BaseModel): data_types: list[str] safe_data_preview: Optional[SafeDataPreview] = None value_count: Optional[int] = None + # Indexes into `locator`, counted from 0, of the elements whose value is serialized JSON. + # None when there are none, or when the server predates the field. + json_string_indexes: Optional[list[int]] = None class FileDiscoveryFile(BaseModel): diff --git a/pyproject.toml b/pyproject.toml index 6f3eaed..7fced60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "datamasque-python" -version = "1.6.0" +version = "1.7.0" description = "Official Python client for the DataMasque data-masking API." authors = [ { name = "DataMasque Ltd" }, diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 7f7d328..09a4582 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -1094,6 +1094,32 @@ def test_file_discovery_value_counts_parse(): assert result.results[0].value_count == 30 +def test_file_discovery_json_string_indexes_parse(): + """A locator through serialized JSON carries its string indexes; one from an older server has none.""" + + def locator_result(**extra: object) -> dict: + return { + "locator": ["*", "event_payload", "email"], + "data_types": ["str"], + "matches": [{"flagged_by": "MDD", "description": "Email", "label": "email"}], + **extra, + } + + result = FileDiscoveryResult.model_validate( + { + "id": 10, + "connection": {"id": "conn-1", "name": "my files"}, + "file_type": "json", + "files": [{"path": "data/events.json", "file_type": "json"}], + "results": [locator_result(json_string_indexes=[1]), locator_result()], + } + ) + + through_a_string, from_an_older_server = result.results + assert through_a_string.json_string_indexes == [1] + assert from_an_older_server.json_string_indexes is None + + def test_file_discovery_uncounted_values_parse(): """A file type that holds no values reports the reason, no counts, and a null count on the locator.""" result = FileDiscoveryResult.model_validate( diff --git a/uv.lock b/uv.lock index 0fb45ec..c712118 100644 --- a/uv.lock +++ b/uv.lock @@ -419,7 +419,7 @@ toml = [ [[package]] name = "datamasque-python" -version = "1.6.0" +version = "1.7.0" source = { editable = "." } dependencies = [ { name = "pydantic" },