From 5a4dc5b77d33113dd9eac5432eb4d43736c91073 Mon Sep 17 00:00:00 2001 From: Marcin Niemyjski Date: Thu, 4 Sep 2025 12:50:05 +0200 Subject: [PATCH 1/5] added missing copy(), updated DEFAULT_QUERYABLES so it contains only generic attributes --- .../stac_fastapi/core/extensions/filter.py | 18 ------------------ .../sfeos_helpers/filter/client.py | 12 +++++------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/stac_fastapi/core/stac_fastapi/core/extensions/filter.py b/stac_fastapi/core/stac_fastapi/core/extensions/filter.py index c6859672..ddeb2600 100644 --- a/stac_fastapi/core/stac_fastapi/core/extensions/filter.py +++ b/stac_fastapi/core/stac_fastapi/core/extensions/filter.py @@ -41,24 +41,6 @@ "description": "Creation Timestamp", "$ref": "https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/datetime.json#/properties/updated", }, - "cloud_cover": { - "description": "Cloud Cover", - "$ref": "https://stac-extensions.github.io/eo/v1.0.0/schema.json#/definitions/fields/properties/eo:cloud_cover", - }, - "cloud_shadow_percentage": { - "title": "Cloud Shadow Percentage", - "description": "Cloud Shadow Percentage", - "type": "number", - "minimum": 0, - "maximum": 100, - }, - "nodata_pixel_percentage": { - "title": "No Data Pixel Percentage", - "description": "No Data Pixel Percentage", - "type": "number", - "minimum": 0, - "maximum": 100, - }, } """Queryables that are present in all collections.""" diff --git a/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py b/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py index 9d0eb69b..50283b45 100644 --- a/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py +++ b/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py @@ -49,13 +49,11 @@ async def get_queryables( if not collection_id: return queryables - properties: Dict[str, Any] = queryables["properties"] - queryables.update( - { - "properties": properties, - "additionalProperties": False, - } - ) + properties: Dict[str, Any] = queryables["properties"].copy() + queryables.update({ + "properties": properties, + "additionalProperties": False, + }) mapping_data = await self.database.get_items_mapping(collection_id) mapping_properties = next(iter(mapping_data.values()))["mappings"]["properties"] From defafc50bb23d3ad320f856b7cfe5ab078d7f4f8 Mon Sep 17 00:00:00 2001 From: Marcin Niemyjski Date: Thu, 4 Sep 2025 13:01:02 +0200 Subject: [PATCH 2/5] precommit fixes --- .../stac_fastapi/sfeos_helpers/filter/client.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py b/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py index 50283b45..512b1b02 100644 --- a/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py +++ b/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py @@ -50,10 +50,12 @@ async def get_queryables( return queryables properties: Dict[str, Any] = queryables["properties"].copy() - queryables.update({ - "properties": properties, - "additionalProperties": False, - }) + queryables.update( + { + "properties": properties, + "additionalProperties": False, + } + ) mapping_data = await self.database.get_items_mapping(collection_id) mapping_properties = next(iter(mapping_data.values()))["mappings"]["properties"] From c14529c43c2b5746fdbffb1ab8ae0d2c535e8486 Mon Sep 17 00:00:00 2001 From: Marcin Niemyjski Date: Thu, 4 Sep 2025 14:05:29 +0200 Subject: [PATCH 3/5] queryables, updated: "$schema" to the one from pgstac (seems newer and more advanced) "$id" made it dynamic --- .../stac_fastapi/sfeos_helpers/filter/client.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py b/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py index 512b1b02..e3df6ecb 100644 --- a/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py +++ b/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py @@ -4,6 +4,7 @@ from typing import Any, Dict, Optional, Tuple import attr +from fastapi import Request from stac_fastapi.core.base_database_logic import BaseDatabaseLogic from stac_fastapi.core.extensions.filter import ALL_QUERYABLES, DEFAULT_QUERYABLES @@ -20,6 +21,7 @@ class EsAsyncBaseFiltersClient(AsyncBaseFiltersClient): async def get_queryables( self, collection_id: Optional[str] = None, **kwargs ) -> Dict[str, Any]: + request: Optional[Request] = kwargs.get("request").url """Get the queryables available for the given collection_id. If collection_id is None, returns the intersection of all @@ -38,8 +40,8 @@ async def get_queryables( Dict[str, Any]: A dictionary containing the queryables for the given collection. """ queryables: Dict[str, Any] = { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://stac-api.example.com/queryables", + "$schema": "https://json-schema.org/draft-07/schema#", + "$id": f"{request!s}", "type": "object", "title": "Queryables for STAC API", "description": "Queryable names for the STAC API Item Search filter.", @@ -50,12 +52,10 @@ async def get_queryables( return queryables properties: Dict[str, Any] = queryables["properties"].copy() - queryables.update( - { - "properties": properties, - "additionalProperties": False, - } - ) + queryables.update({ + "properties": properties, + "additionalProperties": False, + }) mapping_data = await self.database.get_items_mapping(collection_id) mapping_properties = next(iter(mapping_data.values()))["mappings"]["properties"] From 45b4b96f00b902d34e802cd65aff81710e65c036 Mon Sep 17 00:00:00 2001 From: Marcin Niemyjski Date: Fri, 5 Sep 2025 10:43:26 +0200 Subject: [PATCH 4/5] provided mandatory fixes mentioned by Zaczero --- .../stac_fastapi/sfeos_helpers/filter/client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py b/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py index e3df6ecb..98893277 100644 --- a/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py +++ b/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py @@ -21,7 +21,6 @@ class EsAsyncBaseFiltersClient(AsyncBaseFiltersClient): async def get_queryables( self, collection_id: Optional[str] = None, **kwargs ) -> Dict[str, Any]: - request: Optional[Request] = kwargs.get("request").url """Get the queryables available for the given collection_id. If collection_id is None, returns the intersection of all @@ -39,9 +38,11 @@ async def get_queryables( Returns: Dict[str, Any]: A dictionary containing the queryables for the given collection. """ + request: Optional[Request] = kwargs.get("request") + url_str: Optional[str] = str(request.url) if request else "" queryables: Dict[str, Any] = { - "$schema": "https://json-schema.org/draft-07/schema#", - "$id": f"{request!s}", + "$schema": "https://json-schema.org/draft-07/schema", + "$id": f"{url_str}", "type": "object", "title": "Queryables for STAC API", "description": "Queryable names for the STAC API Item Search filter.", From 9b2c7f24e10b8bd89abe54cfc30e50d2414c062c Mon Sep 17 00:00:00 2001 From: Marcin Niemyjski Date: Fri, 5 Sep 2025 10:46:57 +0200 Subject: [PATCH 5/5] removed Optional from url_str --- .../sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py b/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py index 98893277..8a9cf428 100644 --- a/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py +++ b/stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/filter/client.py @@ -39,7 +39,7 @@ async def get_queryables( Dict[str, Any]: A dictionary containing the queryables for the given collection. """ request: Optional[Request] = kwargs.get("request") - url_str: Optional[str] = str(request.url) if request else "" + url_str: str = str(request.url) if request else "" queryables: Dict[str, Any] = { "$schema": "https://json-schema.org/draft-07/schema", "$id": f"{url_str}",